diff presen/index.html~ @ 85:7ed352ddae10

modify spell miss
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Sat, 07 Jan 2012 12:52:25 +0900
parents 07c5304622ac
children
line wrap: on
line diff
--- a/presen/index.html~	Sat Jan 07 09:16:58 2012 +0900
+++ b/presen/index.html~	Sat Jan 07 12:52:25 2012 +0900
@@ -112,6 +112,14 @@
 	<li>本研究ではCbCコンパイラをGCC-4.6へとアップデートを行った。 </li>
       </div>
       <!-- PAGE -->
+<!--
+      <div class="">
+	<h1>先行研究</h1>
+	<li>Continuation based c コン パイラの gcc-4.2 による実装</li>
+	<li></li>
+      </div>
+-->
+      <!-- PAGE -->
       <div class="slide">
 	<h1>発表内容</h1>
 	<ol>
@@ -400,18 +408,7 @@
    if ( c_parser_next_token_is (parser, CPP_NAME)
 	&& c_parser_peek_2nd_token (parser)->type == CPP_SEMICOLON )
      {
-       stmt = c_finish_goto_label (loc,
-				   c_parser_peek_token (parser)->value);
-       c_parser_consume_token (parser);
-     }
-   else if (c_parser_next_token_is (parser, CPP_MULT))
-     {
-       tree val;
-
-       c_parser_consume_token (parser);
-       val = c_parser_expression (parser).value;
-       mark_exp_read (val);
-       stmt = c_finish_goto_ptr (loc, val);
+          :
      }
 #ifndef noCbC
    else
@@ -572,9 +569,9 @@
 	<ul>
 	  <li>expand_call関数</li>
 	<ul>
-	  <li>Treeで表された関数からRTLを生成する関数</li>
+	  <li>SSAへの変換を終えたGIMPLEからとり出されたCALL_EXPREのTreeからRTLを生成する関数</li>
 	  <li>スタックの領域確保、引数の格納、関数へのcall命令の発行が行わる。</li>
-	  <li>try_taill_call(変数名)フラグがあり、末尾除去の条件に合わなければこのフラグが落とされる。</li>
+	  <li>try_taill_call(局所変数)フラグがあり、末尾除去の条件に合わなければこのフラグが落とされる。</li>
 	</ul>
 	<li class="incremental">具体的な実装内容</li>
 	<ul>
@@ -587,98 +584,23 @@
       <!-- PAGE -->
       <div class="slide">
 	<h1>CbCの実装:軽量継続(末尾除去)</h1>
-	<li>try_tail_callフラグが落とされる部分</li>
-	<table width=100%>
-	  <tr class="srctr">
-	    <td class="srctd">
-	<pre class="srcbox">
-
+	<ul>
+	<li><small>try_tail_callフラグを落とさせない。</small></li>
+	<pre class="srcbox" style="font-size:28px;">
   if (currently_expanding_call++ != 0
       || ((!fndecl || !CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl))) 
          && !flag_optimize_sibling_calls)
       || args_size.var
       || dbg_cnt (tail_call) == false)
     try_tail_call = 0;
-
-     :
-
-  if (
-#ifdef HAVE_sibcall_epilogue
-      !HAVE_sibcall_epilogue
-#else
-      1
-#endif
-      || !try_tail_call
-      || structure_value_addr != NULL_RTX
-#ifdef REG_PARM_STACK_SPACE
-      || (OUTGOING_REG_PARM_STACK_SPACE (funtype)
-          != OUTGOING_REG_PARM_STACK_SPACE (TREE_TYPE (current_function_decl)))
-      || (reg_parm_stack_space != REG_PARM_STACK_SPACE (fndecl))
-#endif
-      || !targetm.function_ok_for_sibcall (fndecl, exp)
-      || (flags & (ECF_RETURNS_TWICE | ECF_NORETURN))
-      || TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (addr)))
-      || (fndecl && decl_function_context (fndecl) == current_function_decl)
-      || args_size.constant > (crtl->args.size
-                               - crtl->args.pretend_args_size)
-      || (targetm.calls.return_pops_args (fndecl, funtype, args_size.constant)
-          != targetm.calls.return_pops_args (current_function_decl,
-                                             TREE_TYPE (current_function_decl),
-                                             crtl->args.size))
-      || !lang_hooks.decls.ok_for_sibcall (fndecl))
-    try_tail_call = 0;
-
-      :
-
-  /* Check if caller and callee disagree in promotion of function                                                                                                                      
-     return value.  */
-#ifndef noCbC
-  if (try_tail_call && (!fndecl || !CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl))))
-#else
-    if (try_tail_call)
-#endif
-    {
-      enum machine_mode caller_mode, caller_promoted_mode;
-      enum machine_mode callee_mode, callee_promoted_mode;
-      int caller_unsignedp, callee_unsignedp;
-      tree caller_res = DECL_RESULT (current_function_decl);
-
-      caller_unsignedp = TYPE_UNSIGNED (TREE_TYPE (caller_res));
-      caller_mode = DECL_MODE (caller_res);
-      callee_unsignedp = TYPE_UNSIGNED (TREE_TYPE (funtype));
-      callee_mode = TYPE_MODE (TREE_TYPE (funtype));
-      caller_promoted_mode
-        = promote_function_mode (TREE_TYPE (caller_res), caller_mode,
-                                 &caller_unsignedp,
-                                 TREE_TYPE (current_function_decl), 1);
-      callee_promoted_mode
-        = promote_function_mode (TREE_TYPE (funtype), callee_mode,
-                                 &callee_unsignedp,
-                                 funtype, 1);
-      if (caller_mode != VOIDmode
-          && (caller_promoted_mode != callee_promoted_mode
-              || ((caller_mode != caller_promoted_mode
-                   || callee_mode != callee_promoted_mode)
-                  && (caller_unsignedp != callee_unsignedp
-                      || GET_MODE_BITSIZE (caller_mode)
-                         < GET_MODE_BITSIZE (callee_mode)))))
-        try_tail_call = 0;
-    }
 	</pre>
-	    </td>
-	  </tr>
-	</table>
-	<li><string>!CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)により条件を回避</string></li>
-      </div>
-      <!-- PAGE -->
-      <div class="slide">
-	<h1>CbCの実装:軽量継続(末尾除去)</h1>
-	<li>try_tail_callフラグ矯正付与のソースコード</li>
-	<table width=100%>
-	  <tr class="srctr">
-	    <td>
-	  <pre class="srcbox">
-#ifndef noCbC
+	<ul>
+<!--
+	  <li>!CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)により条件を回避</li>
+-->
+	</ul>
+	<li><small>try_tail_callフラグ矯正付与のソースコード</small></li>
+	  <pre class="srcbox" style="font-size:28px;">
   if (fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl))
       && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl))
       && try_tail_call == 0)
@@ -689,14 +611,7 @@
                         name_callee);
       try_tail_call = 1;
     }
-#endif
 	</pre>
-	  </td>
-	  </tr>
-	  </table>
-	<ul>
-	  <li>try_tail_callフラグが落とされた場合warningを出してフラグを立たせる。<small>(最適化の矯正付与)</small></li>
-	</ul>
       </div>
       <!-- PAGE -->
       <div class="slide">
@@ -741,7 +656,7 @@
  }	  
 	</pre>
 	</small>
-	<p><small>Intel64 ではレジスタが増えている為、fastcallは標準でつくようになっている。</small></p>
+	<p><small>Intel64 ではレジスタが増えていてfastcallの機能は標準でつくようになっている。</small></p>
       </div>
       <!-- PAGE -->
       <div class="slide">
@@ -750,6 +665,7 @@
 	  <li>fastcall属性の付与によりMicro-C版に速度で勝るようになった。</li>
 	</ul>
 	<br>
+	  <br>
 	<table width=100% border=1 class="center">
 	  <caption><small>引数渡しに使われるレジスタの数(gcc)</small></caption>
 	  <tr>
@@ -886,22 +802,6 @@
 -->
       </div>
       <!-- PAGE -->
-<!--
-      <div class="slide">
-	<h1>CbCの実装:環境付き継続</h1>
-	<table border=1 width=100%>
-	  <tr>
-	    <td width=50%><small>生成されるTree</small></td>
-	    <td width=50%><small>生成する為のコード</small></td>
-	  </tr>
-	  <tr class="srctr">
-	    <td class="srctd">
-	      <img src="./pix/STATEMENT_LIST_1.png" style="height: 10em;">
-	    </td>
-	  </tr>
-	</table>
-      </div>
--->
       <!-- PAGE -->
       <div class="slide">
 	<h1>環境付き継続:実装の問題</h1>
@@ -986,9 +886,8 @@
 	    <img src="./pix/linux_conv.png" style="height:10em">
 	  </td>
 	  </table>
-	  <li><small>GCC版の最適化無しの場合、引数を全て一時変数に代入するという処理が入る。
-	    その為に明らかに遅くなっていることが分かる。</small></li>
-	  <li><small>だがGCCの最適化有りの場合はMicro-C版よりも早い。</small></li>
+	  <li><small>最適化無しだと、引数を全て一時変数に代入するGCCは遅い。
+	      だが、最適化にかければ不要な代入は減りMicro-C版より早くなる。</small></li>
       </div>
       <!-- PAGE -->
       <div class="slide">
@@ -1003,7 +902,7 @@
 	</div>
       <!-- PAGE -->
       <div class="slide">
-	<h1>今後の予定</h1>
+	<h1>今後の課題</h1>
 	<ul>
      	  <li>CbCを用いたプログラムの作成</li>
 	  <ul>
@@ -1053,6 +952,21 @@
       </div>
       <!-- PAGE -->
       <div class="slide">
+	<h1>call_insn</h1>
+	<li>expand_callより作成されたRTLのTreeは以下のS式となる。</li>
+	<pre class="srcbox" style="font-size:28px; width:45em;">
+
+(call_insn/j 18 17 19 3 (call (mem:QI (symbol_ref:DI ("factorial") [flags 0x403]  &lt;function_decl 0x1443b4400 factorial&gt;) [0 S1 A8])
+        (const_int 1024 [0x400])) factorial.cbc:30 -1
+     (expr_list:REG_EH_REGION (const_int 0 [0])
+        (nil))
+    (expr_list:REG_DEP_TRUE (use (reg:SI 5 di))
+        (nil)))
+	</pre>
+	<li></li>
+      </div>
+      <!-- PAGE -->
+      <div class="slide">
 	<h1>__rectype の実装</h1>
 	<ul>
 	<li>通常、関数の引数に関数ポインタを渡した際は以下の様に使われる。</li>
@@ -1088,6 +1002,120 @@
 	</small>
       </div>
       <!-- PAGE -->
+      <div class="slide">
+	<h1>環境付き継続</h1>
+	<table border=1 width=100%>
+	  <tr>
+	    <td width=50%><small>生成する為のコード</small></td>
+	    <td width=50%><small>生成されるTree</small></td>
+	  </tr>
+	  <tr class="srctr">
+	    <td class="srctd">
+	      <pre class="srcbox" style="width:25em;">
+
+    case RID_CbC_RET:
+{
+  tree value, stmt, label, tlab, decl;
+  c_parser_consume_token (parser);
+
+  stmt = c_begin_stmt_expr ();
+  cbc_return_f = c_parser_peek_token (parser)->value;
+  location_t location = c_parser_peek_token (parser)->location;
+
+  /* create label. (__label__ _cbc_exit0;) */
+  label = get_identifier ("_cbc_exit0");
+  tlab = declare_label (label);
+  C_DECLARED_LABEL_FLAG (tlab) = 1;
+  add_stmt (build_stmt (location, DECL_EXPR, tlab));
+
+  /* declare retval.  (int retval;) */
+  tree decl_cond =
+    build_decl (location, VAR_DECL, get_identifier ("retval"),
+		TREE_TYPE (TREE_TYPE (current_function_decl)));
+  TREE_STATIC (decl_cond) = 1;
+  TREE_USED (decl_cond) = 1;
+
+  /* Use thread-local */
+  DECL_TLS_MODEL (decl_cond) = decl_default_tls_model (decl_cond);
+  DECL_NONLOCAL (decl_cond) = 1;
+  add_stmt (build_stmt(location, DECL_EXPR,  pushdecl (decl_cond)));
+
+  /* define nested function.  */
+  decl =
+    cbc_finish_nested_function (location, label, decl_cond);
+  TREE_USED(decl) = 1;
+
+  /* define if-ed goto label and return statement. */
+  cbc_finish_labeled_goto (location, label, decl_cond);
+
+  /* get pointer to nested function.  */
+  value = build_addr (decl , current_function_decl);
+  TREE_USED (current_function_decl) = 1;
+  SET_EXPR_LOCATION (value, location);
+  add_stmt (value);
+
+  TREE_SIDE_EFFECTS (stmt) = 1;
+  expr.value = c_finish_stmt_expr (location, stmt);
+  expr.original_code = ERROR_MARK;
+}
+			 </pre>
+	    </td>
+
+
+	    <td class="srctd">
+	      <img src="./pix/STATEMENT_LIST_1.png" style="height: 10em;">
+	    </td>
+
+	  </tr>
+	</table>
+      </div>
+	<!--PAGE-->
+	<div class="slide">
+	  <h1>環境付き継続</h1>
+	<table border=1 width=100%>
+	  <tr>
+	    <td><small>生成しているコード</small></td>
+	    <td><small>生成されるTree</small></td>
+	  </tr>
+	  <tr class="srctr">
+	    <td width=50% class="srctd">
+	  <pre class="srcbox" style="width:25em;">
+
+//goto c1(__return, __environment);
+goto c1(({
+	  __label__ _cbc_exit0;
+	  static int retval;
+	  void _cbc_internal_return(int retval_, void *_envp) {
+	    retval = retval_;
+	    goto _cbc_exit0; 
+          }
+	  if (0) { 
+            _cbc_exit0:
+	    return retval; 
+          }
+	  _cbc_internal_return;
+	}), __environment);
+	  </pre>
+	    </td>
+	    <td class="srctd">
+	      <img src="./pix/STATEMENT_LIST_1.png" style="height: 10em;">
+	    </td>
+	    </tr>
+	  </table>
+	</div>
+	<!--PAGE-->
+	<div class="slide">
+	  <h1></h1>
+	  <li>引数の並びの上書きにコピーが無い。</li>
+	  <pre style="font-size:28px;">
+__code cs_a(int a, int b) {
+  goto cs_b(b,a);
+}
+	  </pre>
+	  <img src="./pix/cs_prog.png">
+	</div>
+	<!--PAGE-->
+
 </div>
 </body>
 </html>