Mercurial > hg > Papers > 2011 > nobu-prosym
annotate presen/index.html @ 71:64d22e65489c
modify TCE
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 02 Jan 2012 05:34:11 +0900 |
parents | 79894ca66a9a |
children | 48de60dd51d1 |
rev | line source |
---|---|
54 | 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
3 | |
4 <html xmlns="http://www.w3.org/1999/xhtml"> | |
5 | |
6 <head> | |
71 | 7 <style type="text/css"> |
8 tr.srctr { | |
9 font-size:28px; | |
10 } | |
11 td.srctd { | |
12 height:20em; | |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
13 } |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
14 pre.srcbox { |
71 | 15 height: 100%; |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
16 overflow: scroll; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
17 } |
64 | 18 .src{ |
19 overflow: scroll; | |
20 width: 90%; | |
21 height: 60%; | |
22 } | |
54 | 23 .center { |
24 margin-left: auto; | |
25 margin-right: auto; | |
26 text-align: center; | |
27 } | |
28 .textcenter { | |
29 text-align: center; | |
30 } | |
31 .taninaritop { | |
32 margin: auto; | |
33 width: 95%; | |
34 font-weight: bold; | |
35 } | |
36 </style> | |
37 <title>2012/ 1/ 7</title> | |
38 <!-- metadata --> | |
39 <meta name="generator" content="S5" /> | |
40 <meta name="version" content="S5 1.1" /> | |
41 <meta name="presdate" content="20120107" /> | |
42 <meta name="author" content="Nobuyasu Oshiro" /> | |
43 <meta name="company" content="University of the Ryukyu" /> | |
44 <!-- meta temporary --> | |
45 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
46 <meta http-equiv="Content-Script-Type" content="text/javascript" /> | |
47 <meta http-equiv="Content-Style-Type" content="text/css" /> | |
48 <!-- configuration parameters --> | |
49 <meta name="defaultView" content="slideshow" /> | |
50 <meta name="controlVis" content="hidden" /> | |
51 <!-- configuration extensions --> | |
52 <meta name="tranSitions" content="true" /> | |
53 <meta name="fadeDuration" content="500" /> | |
54 <meta name="incrDuration" content="250" /> | |
55 <!-- configuration autoplay extension --> | |
56 <meta name="autoMatic" content="false" /> | |
57 <meta name="playLoop" content="true" /> | |
58 <meta name="playDelay" content="10" /> | |
59 <!-- configuration audio extension --> | |
60 <meta name="audioSupport" content="false" /> | |
61 <meta name="audioVolume" content="100" /> | |
62 <meta name="audioError" content="false" /> | |
63 <!-- configuration audio debug --> | |
64 <meta name="audioDebug" content="false" /> | |
65 <!-- style sheet links --> | |
66 <link rel="stylesheet" href="ui/default_utf/slides.css" type="text/css" media="projection" id="slideProj" /> | |
67 <link rel="stylesheet" href="ui/default_utf/outline.css" type="text/css" media="screen" id="outlineStyle" /> | |
68 <link rel="stylesheet" href="ui/default_utf/print.css" type="text/css" media="print" id="slidePrint" /> | |
69 <link rel="stylesheet" href="ui/default_utf/opera.css" type="text/css" media="projection" id="operaFix" /> | |
70 <!-- embedded styles --> | |
71 <style type="text/css" media="all"> | |
72 .imgcon {width: 100%; margin: 0 auto; padding: 0; text-align: center;} | |
73 #anim {width: 33%; height: 320px; position: relative;} | |
74 #anim img {position: absolute; top: 0px; left: 0px;} | |
75 </style> | |
76 <!-- S5 JS --> | |
77 <script src="ui/default_utf/slides.js" type="text/javascript"></script> | |
78 </head> | |
79 <body> | |
80 | |
81 <div class="layout"> | |
82 <div id="controls"><!-- DO NOT EDIT --></div> | |
83 <div id="currentSlide"><!-- DO NOT EDIT --></div> | |
84 <div id="header"></div> | |
85 <div id="footer"> | |
86 <h1>プログラミングシンポジウム: 2012/ 1/ 7</h1> | |
87 <h2>並列信頼研</h2> | |
88 </div> | |
89 </div> | |
90 | |
91 <div class="presentation"> | |
92 | |
93 <div class="slide"> | |
94 <h1>Continuation based Cの GCC 4.6 上の実装について</li> | |
95 <h3></h3> | |
96 <li>大城 信康</li> | |
97 <h4><a href="http://ie.u-ryukyu.ac.jp/" rel="external">琉球大学 並列信頼研究室</a></h4> | |
98 <div class="handout"></div> | |
99 </div> | |
100 <!-- PAGE --> | |
101 <div class="slide"> | |
102 <h1>目的と背景(1)</h1> | |
103 <li>当研究室ではコードセグメント単位で記述するプログラミング言語Continuation based C (以下CbC)という言語を開発している。</li> | |
104 <li>コードセグメントは並列実行の単位として使うことができ、プログラムの正しさを示す単位としても使用することができる。</li> | |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
105 <li>Many Core での並列実行を高い性能と高い信頼性で実現することができると考えている。</li> |
54 | 106 </div> |
107 <!-- PAGE --> | |
108 <div class="slide"> | |
109 <h1>目的と背景(2)</h1> | |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
110 <li>CbC のコンパイラは2001年に Micro-C 版、2008年には GCC 4.2 をベースとしたコンパイラが開発された。</li> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
111 <li>GCC をベースとした CbC コンパイラは、修正・追加されていく最適化の機能を使用する為に、 GCC のアップデートに合わせ変更する必要がある。</li> |
58 | 112 <li>本研究ではCbC コンパイラを GCC-4.6 へとアップデートを行った。 </li> |
54 | 113 </div> |
114 <!-- PAGE --> | |
115 <div class="slide"> | |
116 <h1>発表内容</h1> | |
117 <ol> | |
118 <li>CbC の紹介</li> | |
119 <li>GCC でのコンパイルの流れ</li> | |
58 | 120 <font color="red"> |
121 <li>CbC の実装</li> | |
122 </font> | |
54 | 123 <!-- |
124 <ul> | |
125 <li>Tail Call Elimination</li> | |
126 <li>goto シンタックスの追加</li> | |
127 <li>環境付き継続</li> | |
128 </ul> | |
129 --> | |
130 <li>Micro-C との性能比較</li> | |
64 | 131 <!-- |
54 | 132 <li>mercurial を用いたアップデートの方法</li> |
64 | 133 --> |
54 | 134 <li>まとめ</li> |
135 <ol> | |
136 </div> | |
137 <!-- PAGE --> | |
138 <div class="slide"> | |
139 <h1>Continuation based C </h1> | |
55
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
140 <h2>コードセグメント単位での記述と継続を基本としたプログラミング言語。</h2> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
141 <ul> |
55
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
142 <li>プログラムの記述は C の構文と同じだが、ループ制御や関数コールが取り除かれる。</li> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
143 </ul> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
144 <br> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
145 <h2>コードセグメント</h2> |
55
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
146 <ul> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
147 <li>C の関数よりも細かい単位。</li> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
148 <li>コードセグメントの処理は最後に別のコードセグメントへ継続(goto)することで続いていく。</li> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
149 </ul> |
54 | 150 </div> |
151 <!-- PAGE --> | |
152 <div class="slide"> | |
58 | 153 <h1>Continuation Based C</h1> |
154 <h2>継続:現在の処理を実行していく為の情報</h2> | |
155 <!-- | |
156 <li>Cでは関数呼び出しの後、呼び出し元の環境に復帰する必要がある。</li> | |
157 --> | |
158 <li>Cにおいての継続</li> | |
159 <ul> | |
160 <li>続く命令のアドレス</li> | |
161 <li>命令に必要なデータ</li> | |
162 <li>スタックに積まれている値(環境)</li> | |
163 </ul> | |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
164 </div> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
165 <!-- PAGE --> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
166 <div class="slide"> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
167 <h1>Continuation Based C (軽量継続)</h1> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
168 <h2>CbCの継続(軽量継続)</h2> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
169 <li>関数コールが無い -> 呼び出し元への復帰がない</li> |
58 | 170 <ul> |
59
6ef99d3e66b2
modify light-weight continuation
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
58
diff
changeset
|
171 <li>Cの継続から環境を除外</li> |
6ef99d3e66b2
modify light-weight continuation
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
58
diff
changeset
|
172 <li>続く命令とその命令に必要なデータのみ</li> |
58 | 173 </ul> |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
174 <!-- <li>継続の際にスタックに載せるデータはコードセグメントへの引数だけとなる。</li> --> |
59
6ef99d3e66b2
modify light-weight continuation
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
58
diff
changeset
|
175 <!-- <li>スタックポインタの位置を変えずにすむ。</li> --> |
6ef99d3e66b2
modify light-weight continuation
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
58
diff
changeset
|
176 <p style=" margin-right:auto; margin-left:auto;"> |
66
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
177 <table width=90% class="center" border=1> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
178 <tr> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
179 <td><small>Cの関数呼び出し</small></td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
180 <td><small>CbCの継続</></small></td> |
66
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
181 </tr> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
182 <tr> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
183 <td> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
184 <img class="scale" src="./pix/func_call.png" style="height: 6em;"> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
185 </td> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
186 <td> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
187 <img class="scale" src="./pix/cs_stack.png" style="height: 6em;"> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
188 </td> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
189 </tr> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
190 </table> |
59
6ef99d3e66b2
modify light-weight continuation
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
58
diff
changeset
|
191 </p> |
6ef99d3e66b2
modify light-weight continuation
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
58
diff
changeset
|
192 </div> |
6ef99d3e66b2
modify light-weight continuation
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
58
diff
changeset
|
193 <!-- PAGE --> |
58 | 194 <div class="slide"> |
54 | 195 <h1>Continuation based C </h1> |
196 <small> | |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
197 <table width=100% border=1> |
54 | 198 <caption>階乗を求めるCbCのプログラム</caption> |
71 | 199 <tr class="srctr"> |
54 | 200 <td width=50%> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
201 <pre class="srcbox"> |
54 | 202 __code print_factorial(int prod) { |
203 printf("factorial = %d\n",prod); | |
204 exit(0); | |
205 } | |
58 | 206 |
54 | 207 __code factorial0(int prod, int x) { |
208 if ( x >= 1) { | |
209 goto factorial0(prod*x, x-1); | |
210 }else{ | |
211 goto print_factorial(prod); | |
212 } | |
213 } | |
214 </pre> | |
215 </td> | |
216 <td> | |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
217 <pre class="srcbox"> |
54 | 218 __code factorial(int x) { |
219 goto factorial0(1, x); | |
220 } | |
58 | 221 |
54 | 222 int main(int argc, char **argv) { |
223 int i; | |
224 i = atoi(argv[1]); | |
225 goto factorial(i); | |
226 return 0; | |
227 } | |
228 </pre> | |
229 </td> | |
230 </tr> | |
231 </table> | |
232 </small> | |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
233 <li>__code キーワードによるコードセグメントの宣言</li> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
234 <li>goto によるコードセグメントへの継続(Cの関数呼び出しと同等)</li> |
54 | 235 </div> |
236 <!-- PAGE --> | |
237 <div class="slide"> | |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
238 <h1>GCC</h1> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
239 <li>本来はGnu Compiler Collectionのことを指すが、 |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
240 <br>ここで扱うのはGnu C Compiler(cc1)になる。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
241 <ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
242 <li>GCCではアセンブラ言語を出力するまでに読み込まれたソースコード次の4つの内部表現へと変換される。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
243 </ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
244 <!-- |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
245 <li>GCCでは、アセンブラのコードを出力するまでに次の4つの内部表現が扱われる。</li> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
246 <ol> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
247 <li>Generic Tree</li> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
248 <li>GIMPLE</li> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
249 <li>Tree SSA</li> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
250 <li>RTL</li> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
251 </ol> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
252 --> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
253 </div> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
254 <!-- PAGE --> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
255 <div class="slide"> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
256 <h1>GCC</h1> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
257 <ol> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
258 <li>Generic Tree:ソースコードを構文木の形に直したもの</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
259 <li>GIMPLE: Generic Treeの命令を簡単にした構文木</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
260 <li>Tree SSA: GIMPLEの中で変数代入を一度しか行わせない形にした構文木</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
261 <li>RTL: レジスタの割り当てといった低レベルの表現でアセンブラとほぼ同じ命令の表現ができる。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
262 </ol> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
263 <li class="incremental">それぞれは次のようなデータを構文木にして持っている。</li> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
264 </div> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
265 <!-- PAGE --> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
266 <div class="slide"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
267 <h1>GCC</h1> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
268 <table width=100% border=1> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
269 <tr> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
270 <td>Generic(ソースコード)</td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
271 <td>GIMPLE</td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
272 </tr> |
71 | 273 <tr class="srctr"> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
274 <td> |
71 | 275 <pre class="srcbox"> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
276 void factorial(int x) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
277 { |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
278 int prod,i; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
279 for(i=1,prod=1; i <= x; i++){ |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
280 prod = prod*i; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
281 } |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
282 print_factorial(prod); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
283 } |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
284 </pre> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
285 </td> |
71 | 286 <td width=50%> |
287 <pre class="srcbox"> | |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
288 factorial (int x) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
289 { |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
290 int prod; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
291 int i; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
292 |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
293 i = 1; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
294 prod = 1; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
295 goto <D.2846>; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
296 <D.2845>: |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
297 prod = prod * i; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
298 i = i + 1; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
299 <D.2846>: |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
300 if (i <= x) goto <D.2845>; else goto <D.2847>; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
301 <D.2847>: |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
302 print_factorial (prod); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
303 } |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
304 </pre> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
305 </td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
306 </tr> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
307 </table> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
308 </div> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
309 <!-- PAGE --> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
310 <div class="slide"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
311 <h1>GCC</h1> |
71 | 312 <table border=1 width=100% height=100%> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
313 <tr> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
314 <td width=50%>SSA</td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
315 <td width=50%>RTL</td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
316 </tr> |
71 | 317 <tr class="srctr"> |
318 <td class="srctd"> | |
319 <pre class="srcbox"> | |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
320 factorial (int x) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
321 { |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
322 int i; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
323 int prod; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
324 |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
325 <bb 2>: |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
326 i_3 = 1; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
327 prod_4 = 1; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
328 goto <bb 4>; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
329 |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
330 <bb 3>: |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
331 prod_6 = prod_1 * i_2; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
332 i_7 = i_2 + 1; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
333 |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
334 <bb 4>: |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
335 # prod_1 = PHI <prod_4(2), prod_6(3)> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
336 # i_2 = PHI <i_3(2), i_7(3)> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
337 if (i_2 <= x_5(D)) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
338 goto <bb 3>; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
339 else |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
340 goto <bb 5>; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
341 |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
342 <bb 5>: |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
343 print_factorial (prod_1); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
344 return; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
345 } |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
346 |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
347 </pre> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
348 </td> |
71 | 349 <td class="srctd"> |
350 <pre class="srcbox" style="width:25em;"> | |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
351 (call (mem:QI (symbol_ref:DI ("print_factorial") [flags 0x403] <function_decl 0x146f6b200 print_factorial>) [0 S1 A8]) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
352 (const_int 0 [0])) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
353 </pre> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
354 </td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
355 </tr> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
356 </table> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
357 </div> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
358 <!-- PAGE --> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
359 <div class="slide"> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
360 <h1>GCC</h1> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
361 <p class="center"> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
362 <img src="./pix/ir.png" style="height: 6em;"> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
363 </p> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
364 <li class="incremental">CbCの実装においてはGeneric Tree生成部分とRTLへの変換部分に修正が加えられる。</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
365 <li class="incremental">Generic Tree生成部分について詳しく触れてみる。</li> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
366 </div> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
367 <!-- PAGE --> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
368 <div class="slide"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
369 <h1>GCC:Generic Tree</h1> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
370 <li>Generic Treeではソースコードの内容が FUNCTION_TYPE, CALL_EXPR, MODIFY_EXPR 等と言った形で表される。</li> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
371 <table class="center" width=100% border=1> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
372 <tr> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
373 <td></td> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
374 <td><small>値の代入:MODIFY_EXPR</small></td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
375 <td><small>関数呼び出し:CALL_EXPR</small></td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
376 </t> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
377 <tr> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
378 <td>命令</td> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
379 <td>b = a * 10</td> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
380 <td>func(a,10)</td> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
381 </t> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
382 <tr> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
383 <td><small>Generic<br>Tree</small></td> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
384 <td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
385 <img src="./pix/MODIFY_EXPR.png" style="height: 6em;"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
386 </td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
387 <td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
388 <img src="./pix/CALL_EXPR.png" style="height: 7em;"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
389 </td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
390 </tr> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
391 </table> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
392 <p class="center"><small>Generic Treeでの表現</small></p> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
393 </div> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
394 <!-- PAGE --> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
395 <div class="slide"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
396 <h1>GCC:Generic Tree</h1> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
397 <li>それぞれの命令はSTATEMENT_LISTでまとめて保持される。</li> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
398 <table width=100% border=1> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
399 <tr> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
400 <td class="center"><small>ソースコード</small></td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
401 <td class="center"><small>Generic Treeでの表現</small></td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
402 </tr> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
403 <tr> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
404 <td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
405 <small> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
406 <pre> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
407 int main() { |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
408 int a, b; |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
409 a = 3; |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
410 b = func(a, 10); |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
411 return b; |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
412 } |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
413 </pre> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
414 </small> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
415 </td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
416 <td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
417 <p class="center"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
418 <img src="./pix/STATEMENT_LIST.png" style="height: 6em;"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
419 </p> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
420 </td> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
421 </tr> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
422 </table> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
423 <li class="incremental">CbCの実装においてこのGeneric Treeの生成を意識していくことになる。</li> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
424 </div> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
425 <!-- PAGE --> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
426 <!-- |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
427 <div class="slide"> |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
428 <h1>GCC</h1> |
54 | 429 <li>GCC についての簡単な説明を行う...</li> |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
430 <li>TODO: NEXT_PASS() の把握</li> |
54 | 431 <img src="./pix/ir.png" style="height: 6em;"> |
432 <li>CbCの実装は主に Parser の部分と RTL を生成する部分に行われる。</li> | |
433 </div> | |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
434 --> |
54 | 435 <!-- PAGE --> |
436 <div class="slide"> | |
61
2c543a47737b
modify explanation of fastcall
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
437 <h1>CbCの実装</h1> |
54 | 438 <ul> |
439 <li>シンタックスの追加</li> | |
61
2c543a47737b
modify explanation of fastcall
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
440 <li>レジスタによる引数渡し(fastcall属性の付与)</li> |
54 | 441 <li>Tail Call Elimination</li> |
442 <li>環境付き継続</li> | |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
443 <li>__rectype の実装</li> |
54 | 444 </ul> |
445 </div> | |
446 <!-- PAGE --> | |
447 <div class="slide"> | |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
448 <h1>CbCの実装:シンタックスの追加</h1> |
54 | 449 <ul> |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
450 <li>__code キーワードでのコードセグメントの宣言</li> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
451 <ul> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
452 <li>__code 用idとkeywordを作成。</li> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
453 <li>戻り値が無い為、コードセグメントは void 型の関数で作成される木と同じ木が作られる。</li> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
454 </ul> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
455 <li>goto によるコードセグメントへの継続</li> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
456 <ul> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
457 <li>通常の goto に加え、コードセグメントへ継続する処理を追加。</li> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
458 <li>コードセグメントへのgotoの後に、returnの処理を自動で追加。</li> |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
459 </ul> |
54 | 460 </ul> |
61
2c543a47737b
modify explanation of fastcall
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
461 <li class="incremental">追加したgotoシンタックスの実際のソースは次のようになる。</li> |
54 | 462 </div> |
463 <!-- PAGE --> | |
464 <div class="slide"> | |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
465 <h1>CbCの実装:シンタックスの追加</h1> |
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
466 <h2>gotoシンタックスの追加</h2> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
467 <pre class="srcbox" style="font-size:25px; height:20em;"> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
468 case RID_GOTO: |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
469 c_parser_consume_token (parser); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
470 if ( c_parser_next_token_is (parser, CPP_NAME) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
471 && c_parser_peek_2nd_token (parser)->type == CPP_SEMICOLON ) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
472 { |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
473 stmt = c_finish_goto_label (loc, |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
474 c_parser_peek_token (parser)->value); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
475 c_parser_consume_token (parser); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
476 } |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
477 else if (c_parser_next_token_is (parser, CPP_MULT)) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
478 { |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
479 tree val; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
480 |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
481 c_parser_consume_token (parser); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
482 val = c_parser_expression (parser).value; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
483 mark_exp_read (val); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
484 stmt = c_finish_goto_ptr (loc, val); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
485 } |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
486 else |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
487 expr = c_parser_expr_no_commas (parser, NULL); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
488 if (TREE_CODE(expr.value) == CALL_EXPR ) |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
489 { |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
490 location_t loc = c_parser_peek_token (parser)->location; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
491 cbc_replace_arguments (loc, expr.value); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
492 TREE_TYPE(expr.value) = void_type_node; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
493 CbC_IS_CbC_GOTO (expr.value) = 1; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
494 CALL_EXPR_TAILCALL (expr.value) = 1; |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
495 add_stmt(expr.value); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
496 stmt = c_finish_return(loc, NULL_TREE, NULL_TREE); |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
497 } |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
498 </pre> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
499 <small> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
500 <li>cbc_replace_arguments関数は引数のデータを一時的な変数へ避難させる。</li> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
501 <li>CALL_EXPR_TAILCALLマクロでtail callフラグを立てる。</li> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
502 <li class="incremental">最後にc_finish_return関数によりreturn文を生成している。</li> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
503 </small> |
54 | 504 </div> |
505 <!-- PAGE --> | |
506 <div class="slide"> | |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
507 <h1>CbCの実装:シンタックスの追加</h1> |
61
2c543a47737b
modify explanation of fastcall
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
508 <h2>gotoシンタックスの追加</h2> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
509 <li>最後にリターン文を生成することにより、次へと制御を移させず、末尾最適化がかかるようになる。</li> |
55
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
510 <table border=1 width=100%> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
511 <tr class="center"> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
512 <small> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
513 <td>実際のコード </td> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
514 <td>GCC 内で処理されるコード</td> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
515 </small> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
516 </tr> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
517 <tr style="margin-top: auto;"> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
518 <td> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
519 <pre> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
520 goto factorial0(1, x); |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
521 </pre> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
522 </td> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
523 <td> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
524 <pre> |
58 | 525 factorial0(1, x); |
55
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
526 return; |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
527 </pre> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
528 </td> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
529 </tr> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
530 </table> |
60
a21d16da431a
modify addition of goto syntax
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
59
diff
changeset
|
531 <li>末尾最適化(末尾除去)については後ほど詳しく説明する。</li> |
54 | 532 </div> |
533 <!-- PAGE --> | |
534 <div class="slide"> | |
61
2c543a47737b
modify explanation of fastcall
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
535 <h1>CbCの実装:引数渡し</h1> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
536 <li>GCC版コンパイラー開発当初、コンパイルしたCbCのプログラムはMicro-C版に速度面で勝てなかった。</li> |
58 | 537 <ul> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
538 <li class="incremental">Micro-Cでは関数呼び出しの際にできるだけレジスタを使うようにしていた。</li> |
58 | 539 </ul> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
540 <li class="incremental">そこで、GCC版CbCコンパイラの引数渡しもできるだけレジスタで行うことに。</li> |
58 | 541 </div> |
542 <!-- PAGE --> | |
543 <div class="slide"> | |
61
2c543a47737b
modify explanation of fastcall
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
544 <h1>CbCの実装:引数渡し(fastcall)</h1> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
545 <h2>fastcall</h2> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
546 <ul> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
547 <li>i386 において関数呼び出しの際、引数渡しをできるだけレジスタを用いるGCCの拡張機能。</li> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
548 <li>関数に『__attribute__ ((fastcall))』をつけることで使えるようになる。</li> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
549 </ul> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
550 <li>__codeで宣言された関数は自動でfastcall属性が付与されるように以下のコードを追加。</li> |
58 | 551 <small> |
55
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
552 <pre> |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
553 if(!TARGET_64BIT) { |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
554 attrs = build_tree_list (get_identifier("fastcall"), NULL_TREE); |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
555 declspecs_add_attrs(specs, attrs); |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
556 } |
06ce8fb8e278
modify presen/index.html
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
54
diff
changeset
|
557 </pre> |
58 | 558 </small> |
559 <p><small>Intel64 ではレジスタが増えている為、fastcallは標準でつくようになっている。</small></p> | |
560 </div> | |
561 <!-- PAGE --> | |
562 <div class="slide"> | |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
563 <h1>CbCの実装:引数渡し</h1> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
564 <table width=100% border=1 class="center"> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
565 <caption>引数渡しに使われるレジスタの数(gcc)</caption> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
566 <tr> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
567 <td>arch</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
568 <td>int(整数型)</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
569 <td>float(浮動小数点型)</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
570 <td>double(浮動小数点型)</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
571 </tr> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
572 <tr> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
573 <td>i386</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
574 <td>2</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
575 <td>0<br>(stackを使用)</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
576 <td>0<br>(stackを使用)</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
577 </tr> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
578 <tr> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
579 <td>x86_64</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
580 <td>6</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
581 <td>8</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
582 <td>8</td> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
583 </tr> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
584 </table> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
585 </div> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
586 <!-- PAGE --> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
587 <div class="slide"> |
71 | 588 <h1>CbCの実装:TCE(末尾除去)</h1> |
61
2c543a47737b
modify explanation of fastcall
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
589 <h2>Tail Call Elimination(TCE):末尾除去</h2> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
590 <ul> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
591 <li>関数呼び出しをcallではなくjmp命令で行う最適化。</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
592 </ul> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
593 <li><small>以下のソースの場合 関数a から関数b へjmp命令で処理が移る。</small></li> |
71 | 594 <br> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
595 <table width=100%> |
71 | 596 <tr class="srctr"> |
597 <td width=50%> | |
598 <pre class="srcbox"> | |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
599 int main() { |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
600 int num = a(2); |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
601 printf("main:num=%d\n",num); |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
602 return 0; |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
603 } |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
604 int a(int num) { |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
605 return b(num+5); |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
606 } |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
607 int b(int num) { |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
608 printf("b:a = %d\n",num); |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
609 return num+3; |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
610 } |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
611 </pre> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
612 </td> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
613 <td class="center"> |
71 | 614 <img src="./pix/continuation.png" style="height:100%;"> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
615 </td> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
616 </tr> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
617 </table> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
618 </div> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
619 <!-- PAGE --> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
620 <div class="slide"> |
71 | 621 <h1>CbCの実装:TCE(末尾除去)の動作</h1> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
622 <li>スタック:呼び出し元関数と同じ範囲を使うことになる。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
623 <table width=100% border=1> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
624 <td> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
625 <p class="center"> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
626 <img src="./pix/tce.png" style="height: 6em;"> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
627 </p> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
628 </td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
629 <td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
630 <ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
631 <li><small>func_bの引数はfunc_aのスタックに上書する</small></li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
632 <li><small>func_bの為にスタックポインタは伸ばされない</small></li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
633 </ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
634 </td> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
635 </table> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
636 <li class="incremental">CbCにおけるコードセグメントへの継続はこのTCEを用いて実装されている。</li> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
637 <li class="incremental">TCEにかかるには条件が幾つかある。</li> |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
638 </div> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
639 <!-- PAGE --> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
640 <div class="slide"> |
71 | 641 <h1>CbCの実装:TCE(末尾除去)</h1> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
642 <li>TCEにかかる条件</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
643 <ol> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
644 <li>caller側とcallee側の戻値の型の一致している。</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
645 <li>関数呼び出しがリターン直前に行われている。</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
646 <li>呼出先関数の引数に用いられるスタックサイズが呼出元のそれより少ない。</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
647 <li>引数の並びのコピーに上書きがない。</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
648 </ol> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
649 </div> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
650 <!-- PAGE --> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
651 <div class="slide"> |
71 | 652 <h1>CbCの実装:TCE(末尾除去)</h1> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
653 <li>条件を回避する為以下の実装にする。</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
654 <ol> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
655 <li>型はvoid型で統一する。</li> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
656 <li>gotoの直後にreturnを置く。</li> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
657 <li>スタックサイズは固定する。</li> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
658 <li>引数は一旦、一時変数にコピーする。</li> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
659 </ol> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
660 </small> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
661 </div> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
662 <!-- PAGE --> |
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
663 <div class="slide"> |
71 | 664 <h1>CbCの実装:TCE(末尾除去)</h1> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
665 <li>TCEの条件はexpand_call関数で調べられる。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
666 <ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
667 <li>Treeで表された関数からRTLを生成する関数</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
668 <li>スタックの領域確保、引数の格納、関数へのcall命令の発行が行わる。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
669 <li>try_taill_call(変数名)フラグがあり、TCEの条件に合わなければこのフラグが落とされる。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
670 </ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
671 <li>具体的な実装</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
672 <ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
673 <li>try_tail_callフラグを落とさせない処理が追加されている。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
674 </ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
675 </div> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
676 <!-- PAGE --> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
677 <!-- |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
678 <div class="slide"> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
679 <h1>CbCの実装:TCE</h1> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
680 <li>TCEにかかる条件</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
681 <ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
682 <li>try_tail_callフラグを落とさせない。</li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
683 </ul> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
684 <li></li> |
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
685 </div> |
69
9dc6013b0559
modify explanation of tce
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
68
diff
changeset
|
686 --> |
54 | 687 <!-- PAGE --> |
688 <div class="slide"> | |
71 | 689 <h1>CbCの実装:TCE(末尾除去)</h1> |
690 <li>try_tail_callフラグが落とされるif文</li> | |
691 <pre class="srcbox"> | |
692 if (currently_expanding_call++ != 0 | |
693 || ((!fndecl || !CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl))) | |
694 && !flag_optimize_sibling_calls) | |
695 || args_size.var | |
696 || dbg_cnt (tail_call) == false) | |
697 try_tail_call = 0; | |
698 </pre> | |
699 </div> | |
700 <!-- PAGE --> | |
701 <div class="slide"> | |
702 <li>try_tail_callフラグが落とされる部分</li> | |
703 <table> | |
704 <tr class="srctr"> | |
705 <td class="srctd"> | |
706 <pre class="srcbox"> | |
707 if ( | |
708 #ifdef HAVE_sibcall_epilogue | |
709 !HAVE_sibcall_epilogue | |
710 #else | |
711 1 | |
712 #endif | |
713 || !try_tail_call | |
714 || structure_value_addr != NULL_RTX | |
715 #ifdef REG_PARM_STACK_SPACE | |
716 || (OUTGOING_REG_PARM_STACK_SPACE (funtype) | |
717 != OUTGOING_REG_PARM_STACK_SPACE (TREE_TYPE (current_function_decl))) | |
718 || (reg_parm_stack_space != REG_PARM_STACK_SPACE (fndecl)) | |
719 #endif | |
720 || !targetm.function_ok_for_sibcall (fndecl, exp) | |
721 || (flags & (ECF_RETURNS_TWICE | ECF_NORETURN)) | |
722 || TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (addr))) | |
723 || (fndecl && decl_function_context (fndecl) == current_function_decl) | |
724 || args_size.constant > (crtl->args.size | |
725 - crtl->args.pretend_args_size) | |
726 || (targetm.calls.return_pops_args (fndecl, funtype, args_size.constant) | |
727 != targetm.calls.return_pops_args (current_function_decl, | |
728 TREE_TYPE (current_function_decl), | |
729 crtl->args.size)) | |
730 || !lang_hooks.decls.ok_for_sibcall (fndecl)) | |
731 try_tail_call = 0; | |
732 </pre> | |
733 </td> | |
734 </tr> | |
735 </table> | |
736 | |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
737 </div> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
738 <!-- PAGE --> |
64 | 739 <!-- |
63
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
740 <div class="slide"> |
3cc4a8603489
modify explanation of TCE
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
62
diff
changeset
|
741 <h1>CbCの実装:環境付き継続</h1> |
62 | 742 <li>CbCにおけるCとの互換性を保つための機能。</li> |
743 <li>コードセグメントを呼び出したCの関数に戻ることができる。</li> | |
64 | 744 <li>論文における訂正</li> |
745 <li>『GCC 4.6 と Lion の組合せでは Closure は正しく動作していないことが分かった.』</li> | |
746 <ul> | |
747 <li>GCC 4.6 への CbC の実装のせいでクロージャがうまくできていなかったことが判明。</li> | |
748 <li>GCC 4.6 と Lion でのクロージャは特に問題はない。</li> | |
749 </ul> | |
750 </div> | |
751 --> | |
752 <!-- PAGE --> | |
753 <!-- | |
754 <div class="slide"> | |
755 <h1>環境付き継続:論文におけるクロージャの問題の訂正</h1> | |
756 <p><small>『GCC 4.6とLionの組み合わせではclosureは正しく動作してないことが分かった。』<br> | |
757 とあるが、これはCbCの実装でTCEを強制的に立てることが原因であったことを訂正させて頂きます。</small></p> | |
758 </div> | |
759 --> | |
760 <!-- PAGE --> | |
761 <div class="slide"> | |
762 <h1>CbCの実装:環境付き継続</h1> | |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
763 <ul> |
64 | 764 <li>CbCにおけるCとの互換性を保つための機能。コードセグメントを呼び出したCの関数に戻ることができる。</li> |
765 <li>__returnキーワードを引数に渡すことで使うことができる。</li> | |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
766 </ul> |
64 | 767 <li>以下の使い方の場合は1を返す。</li> |
71 | 768 <table border=1 width=100%> |
769 <td> | |
64 | 770 <small> |
71 | 771 <pre class="srcbox"> |
64 | 772 __code c1(__code ret(int,void *),void *env) { |
773 goto ret(1,env); | |
774 } | |
775 int main() { | |
776 goto c1(__return, __environment); | |
777 } | |
778 </pre> | |
71 | 779 </small> |
780 </td> | |
781 </table> | |
782 <p><small>__environmentキーワードは関数の環境を保持する。</small></p> | |
54 | 783 </div> |
784 <!-- PAGE --> | |
785 <div class="slide"> | |
64 | 786 <h1>CbCの実装:環境付き継続</h1> |
787 <h2>実際には以下のコードを生成している。</h2> | |
788 <small> | |
71 | 789 <pre class="srcbox"> |
790 | |
64 | 791 goto c1(__return, __environment); |
792 | |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
793 goto c1(({ |
64 | 794 __label__ _cbc_exit0; |
795 static int retval; | |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
796 void _cbc_internal_return(int retval_, void *_envp) { |
64 | 797 retval = retval_; |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
798 goto _cbc_exit0; |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
799 } |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
800 if (0) { |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
801 _cbc_exit0: |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
802 return retval; |
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
803 } |
64 | 804 _cbc_internal_return; |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
805 }), __environment); |
64 | 806 </pre> |
807 <p>retval変数はint型になっているが、実際には継続を行った関数と同じ戻値の型となる。</p> | |
808 </small> | |
809 <li class="incremental">上記のコードをGCC内で生成するのが次のソースとなる。</li> | |
54 | 810 </div> |
811 <!-- PAGE --> | |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
812 <!-- |
54 | 813 <div class="slide"> |
64 | 814 <h1>CbCの実装:環境付き継続</l> |
815 <h2>環境付き継続の生成部分:</h2> | |
816 <div class="src"> | |
817 <small> | |
818 <pre> | |
819 { | |
820 tree value, stmt, label, tlab, decl; | |
821 c_parser_consume_token (parser); | |
822 | |
823 stmt = c_begin_stmt_expr (); | |
824 cbc_return_f = c_parser_peek_token (parser)->value; | |
825 location_t location = c_parser_peek_token (parser)->location; | |
826 | |
827 /* create label. (__label__ _cbc_exit0;) */ | |
828 label = get_identifier ("_cbc_exit0"); | |
829 tlab = declare_label (label); | |
830 C_DECLARED_LABEL_FLAG (tlab) = 1; | |
831 add_stmt (build_stmt (location, DECL_EXPR, tlab)); | |
832 | |
833 /* declare retval. (int retval;) */ | |
834 tree decl_cond = | |
835 build_decl (location, VAR_DECL, get_identifier ("retval"), | |
836 TREE_TYPE (TREE_TYPE (current_function_decl))); | |
837 TREE_STATIC (decl_cond) = 1; | |
838 TREE_USED (decl_cond) = 1; | |
839 | |
840 /* Use thread-local */ | |
841 DECL_TLS_MODEL (decl_cond) = decl_default_tls_model (decl_cond); | |
842 DECL_NONLOCAL (decl_cond) = 1; | |
843 add_stmt (build_stmt(location, DECL_EXPR, pushdecl (decl_cond))); | |
844 | |
845 /* define nested function. */ | |
846 decl = | |
847 cbc_finish_nested_function (location, label, decl_cond); | |
848 TREE_USED(decl) = 1; | |
849 | |
850 /* define if-ed goto label and return statement. */ | |
851 cbc_finish_labeled_goto (location, label, decl_cond); | |
852 | |
853 /* get pointer to nested function. */ | |
854 value = build_addr (decl , current_function_decl); | |
855 TREE_USED (current_function_decl) = 1; | |
856 SET_EXPR_LOCATION (value, location); | |
857 add_stmt (value); | |
858 | |
859 TREE_SIDE_EFFECTS (stmt) = 1; | |
860 expr.value = c_finish_stmt_expr (location, stmt); | |
861 expr.original_code = ERROR_MARK; | |
862 } | |
863 </pre> | |
54 | 864 </small> |
64 | 865 </div> |
54 | 866 </div> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
867 --> |
54 | 868 <!-- PAGE --> |
869 <div class="slide"> | |
64 | 870 <h1>CbCの実装:環境付き継続</h1> |
871 <h2>作成されるTree</h2> | |
872 <img src="./pix/STATEMENT_LIST_1.png" style="height: 10em;"> | |
873 <!-- | |
874 <small> | |
875 <pre> | |
876 ({ | |
877 __label__ _cbc_exit0; | |
878 static int retval; | |
879 void _cbc_internal_return(int retval_, void *_envp){ | |
880 retval = retval_; | |
881 goto _cbc_exit0; } | |
882 if (0) { _cbc_exit0: | |
883 return retval; } | |
884 _cbc_internal_return; | |
885 }), | |
886 </pre> | |
887 </small> | |
888 --> | |
889 </div> | |
890 <!-- PAGE --> | |
891 <div class="slide"> | |
892 <h1>環境付き継続:実装の問題</h1> | |
893 <ul> | |
894 <li>リターンするretval変数が重要になってくる。</li> | |
895 <li>retval変数のデータをどうやって確保するか。</li> | |
896 </ul> | |
897 <li>次の方法が考えられる。</li> | |
898 <ul> | |
899 <li>クロージャでの確保</li> | |
900 <li>staticでの確保</li> | |
901 <li>static thread local storage(tls)を用いての確保</li> | |
902 </ul> | |
903 </div> | |
904 <!-- PAGE --> | |
905 <div class="slide"> | |
906 <h1>環境付き継続:実装の問題</h1> | |
907 <li>クロージャでの実装</li> | |
54 | 908 <ul> |
64 | 909 <li>クロージャにしてスタックに値を確保する。</li> |
910 <li></li> | |
911 </ul> | |
912 <li>問題点</li> | |
913 <ul> | |
914 <li class="incremental">しかしCbCではスタックの値は破棄されていく。</li> | |
915 <li class="incremental">その為スタックに値を確保するのは好ましくない。</li> | |
916 </ul> | |
917 </div> | |
918 <!-- PAGE --> | |
919 <div class="slide"> | |
920 <h1>環境付き継続:実装の問題</h1> | |
921 <li>staticでの実装</li> | |
922 <ul> | |
923 <li>静的に値を確保することでスタック破棄の影響を受けない。</li> | |
924 </ul> | |
925 <li>問題点</li> | |
926 <ul> | |
927 <li class="incremental">マルチスレッドのプログラムに対応できない。</li> | |
928 <li class="incremental">値を返し切る前に別スレッドによって値が書き換えられる可能性がある。</li> | |
54 | 929 </ul> |
64 | 930 </div> |
931 <!-- PAGE --> | |
932 <div class="slide"> | |
933 <h1>環境付き継続:実装の問題</h1> | |
934 <li>static tlsでの実装</li> | |
935 <ul> | |
936 <li>スレッド毎に静的に値を確保する。</li> | |
937 </ul> | |
938 <li>現在はこの方法で実装を行なっている。</li> | |
939 <li>しかし、最適化にかけると正しい値が返ってこない。 | |
940 <br>(恐らくTreeの生成の部分が間違っている。)</li> | |
941 </div> | |
942 <!-- PAGE --> | |
943 <div class="slide"> | |
944 <h1>環境付き継続:その他の実装方法</h1> | |
945 <ul> | |
946 <li>setjmpでの実装</li> | |
947 <ul> | |
948 <li>setjmpを行うTreeを生成するのが少し手間になる。</li> | |
949 <li>int型の戻値しか得られない。</li> | |
950 </ul> | |
951 <li>戻値を入れるレジスタを明示的に指定する。</li> | |
952 <ul> | |
953 <li>まだ実装を試していない。</li> | |
954 </ul> | |
955 </ul> | |
54 | 956 </div> |
957 <!-- PAGE --> | |
958 <div class="slide"> | |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
959 <h1>CbCの機能の拡張:__rectype の実装</h1> |
57
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
960 <li>通常、関数の引数に関数ポインタを渡した際は以下の様に使われる。</li> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
961 <small> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
962 <pre> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
963 void factorial(int n, int result, void(*print)()){ |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
964 : |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
965 (*print)(n,result,print,exit1, envp); |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
966 } |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
967 </pre> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
968 </small> |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
969 <li>以下の様に引数に()をつけて受けてることをやめたい。</li> |
57
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
970 <small> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
971 <pre> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
972 void factorial(int n, int result, void *print){ |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
973 : |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
974 void(*print)(n,result,print,exit1, envp); |
57
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
975 } |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
976 </pre> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
977 </small> |
54 | 978 </div> |
979 <!-- PAGE --> | |
980 <div class="slide"> | |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
981 <h1>CbCの機能の拡張:__rectype の実装</h1> |
57
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
982 <li>そこで、__rectype という予約後を作り、以下の宣言を行えるようにした。</li> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
983 <pre> |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
984 __code factorial(int n, int result, __rectype *print) { |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
985 : |
70
79894ca66a9a
modify explanation of GCC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
69
diff
changeset
|
986 goto (*print)(n,result,print,exit1, envp); |
57
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
987 } |
ce844f6c504d
modify __rectype
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
988 </pre> |
54 | 989 </div> |
990 <!-- PAGE --> | |
991 <div class="slide"> | |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
992 <h1>CbCの機能の拡張:selftype</h1> |
64 | 993 <h2>selftypeの実装</h2> |
994 <li>以下の宣言が行えるようにしたい。</li> | |
995 <small> | |
996 <pre> | |
997 typedef sturct node { | |
998 selftype *left; | |
999 selftype *right; | |
1000 int num; | |
1001 }*NODE | |
1002 </pre> | |
1003 <p>selftype は struct node を指す。</p> | |
1004 </small> | |
1005 <ul> | |
1006 <li>上記の構文は実装を行う予定である。</li> | |
1007 </ul> | |
1008 </div> | |
1009 <!-- PAGE --> | |
1010 <div class="slide"> | |
66
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1011 <h1>Micro-Cとの比較</h1> |
68
1399414ea3f6
modify explanation of Generic Tree
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
1012 <li>Micro-C,GCC-4.4とGCC-4.6のCbCコンパイラでコンパイルしたプログラムの実行の速度</li> |
66
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1013 <table width=100% class="center"> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1014 <td> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1015 <img src="./pix/mac_conv.png"> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1016 </td> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1017 <td> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1018 <img src="./pix/linux_conv.png"> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1019 </td> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1020 </table> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1021 <li>GCC版の最適化無しの場合、引数を全て一時変数に代入するという処理が入る。 |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1022 その為に明らかに遅くなっていることが分かる。</li> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1023 <li>だがGCCの最適化有りの場合はMicro-C版よりも早い。</li> |
54 | 1024 </div> |
1025 <!-- PAGE --> | |
64 | 1026 <div class="slide"> |
1027 <h1></h1> | |
1028 <li></li> | |
1029 </div> | |
1030 <!-- PAGE --> | |
1031 <div class="slide"> | |
1032 <h1>まとめ</h1> | |
66
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1033 <ul> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1034 <li>今回GCC版CbCコンパイラのアップデートを行った。</li> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1035 <li>TCEにかかる判定の部分と環境付き継続の実装の修正を行った。 |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1036 <br>おかげで、以前より楽な管理ができる実装にすることができた。</li> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1037 <li>後は環境付き継続の最適化の問題の修正とselftypeの実装を行う。</li> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1038 <li>全ての実装を終えたらGCC版CbCコンパイラの実装はアップデートを行なっていくだけとなる。</li> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1039 </ul> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1040 </div> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1041 <!-- PAGE --> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1042 <div class="slide"> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1043 <h1>今後の予定</h1> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1044 <ul> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1045 <li>CbCを用いたプログラムの作成</li> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1046 <ul> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1047 <li>CbCによるタスクマネージャの作成</li> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1048 </ul> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1049 <li>llvmへのCbCの実装</li> |
26a3713b2989
modify explanation of CbC
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
64
diff
changeset
|
1050 </ul> |
64 | 1051 </div> |
1052 <!-- PAGE --> | |
54 | 1053 </div> |
1054 </body> | |
1055 </html> |