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