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