changeset 5:ac2ec4334d49

implementation
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Wed, 01 Jul 2015 23:29:41 +0900
parents 20257f618ddd
children a780e089f357
files presentation/presen.html
diffstat 1 files changed, 68 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/presentation/presen.html	Wed Jul 01 22:18:59 2015 +0900
+++ b/presentation/presen.html	Wed Jul 01 23:29:41 2015 +0900
@@ -426,7 +426,7 @@
           <li>TCE is one of the optimization.
           <li>If the function call is immediately followed by return, it is tail call.
           <li>TCE replace tail call's call instructions with jmp instructions.
-          <li>Code segments' transition is implemented by forced tail call elimination.
+          <li>Code segments transition is implemented by forced tail call elimination.
         </ul>
         <div align='center'><img src="fig/TCE.svg" width="40%"></div>
       </div>
@@ -440,7 +440,29 @@
 
       <div class='slide'>
         <h2>Forcing Tail Call Elimination</h2>
-        <p>LLVM IR has function call flags. We can give LLVM some information for function call by them. We use them for force to tail call elimination.
+        <ul>
+          <li>LLVM IR has function call flags.
+          <li>tail mean it is tail call.
+          <li>Calling convention tell compiler how callee functions receive parameters from their caller.
+        </ul>
+        <table width='100%'>
+          <tr>
+            <td style="border: double;">
+              <pre class='code'>
+define fastcc void @factorial(i32 %x) #0 {
+  entry:
+  <font color='red'>tail</font> call <font color='red'>fastcc</font> void @factorial0(i32 1, i32 %x)
+  ret void
+}
+              </pre>
+            </td>
+          </tr>
+        </table>
+        <div align='center'><h3>Use them for force to tail call elimination.</h3></div>
+      </div>
+
+      <div class='slide'>
+        <h2>Forcing Tail Call Elimination</h2>
         <p>We have to meet the following requirements.</p>
         <ul>
           <li>set tail flag at the code segments call.
@@ -448,7 +470,10 @@
           <li>the caller and calle's calling conventions must be the same and their types should be cc10, cc11 or fastcc.
           <li>return value type has to be the same as the caller's.
         </ul>
-        <br>
+      </div>
+
+      <div class='slide'>
+        <h2>Forcing Tail Call Elimination</h2>
         <p>We met them by following ways.</p>
         <ul>
           <li>Always add tail call elimination pass and set flag at the code segments call.
@@ -576,10 +601,50 @@
       </div>
 
       <div class='slide'>
+        <h2>Compiling result</h2>
+        <p>Tail Call Elimination が強制されているかどうかをアセンブリコードから判断する.</p>
+        <table width='100%' align='center' border='1'>
+          <tr>
+            <td valign='top'>
+              <pre class='small_code'>
+
+__code caller(int x)
+{
+  goto code1(1, x); // should be jmp
+}
+              </pre>
+            <td>
+              <pre class='small_code'>
+_caller:                             ## @factorial
+        .cfi_startproc
+## BB#0:                                ## %entry
+        subq    $24, %rsp
+Ltmp5:
+        .cfi_def_cfa_offset 32
+        movl    $1, %eax
+        movl    %edi, 20(%rsp)          ## 4-byte Spill
+        movl    %eax, %edi
+        movl    20(%rsp), %esi          ## 4-byte Reload
+        addq    $24, %rsp
+        <font color='red'>jmp</font>     _code1             ## TAILCALL
+        .cfi_endproc
+              </pre>
+          </tr>
+        </table>
+        <ul>
+          <li>Code1 should called by jmp instruction.
+          <li>In assembly code, code1 called by jmp instruction.
+          <li>Tail call elimination was forced.
+          <li>If tail call elimination was failed, compiler output error messages.
+        </ul>
+      </div>
+
+      <div class='slide'>
         <h2>Conclusion</h2>
         <ul>
           <li>CbC compiler on LLVM and Clang was implemented.
           <li>LLVM IR was not modified.
+          <li>
         </ul>
       </div>