Mercurial > hg > Papers > 2015 > kaito-lola
comparison cfopm.tex @ 1:97e85476344e
fix typos
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 02 Jun 2015 18:30:29 +0900 |
parents | c0d36568602d |
children | 771136eae970 |
comparison
equal
deleted
inserted
replaced
0:c0d36568602d | 1:97e85476344e |
---|---|
108 Data segment is a set of typed data. | 108 Data segment is a set of typed data. |
109 Code segments are connected to data segments with a context, which is a meta data segment. | 109 Code segments are connected to data segments with a context, which is a meta data segment. |
110 After an execution of a code segment and its context, next code segments (Continuation) is executed. | 110 After an execution of a code segment and its context, next code segments (Continuation) is executed. |
111 | 111 |
112 We had developed a programming language ``Continuation based C (CbC)'' \cite{DBLP:journals/corr/abs-1109-4048}. | 112 We had developed a programming language ``Continuation based C (CbC)'' \cite{DBLP:journals/corr/abs-1109-4048}. |
113 Hear after we call it CbC, which supports code segments. | 113 Hearafter we call it CbC, which supports code segments. |
114 CbC is compatible with C language and it has continuation as a goto statement. | 114 CbC is compatible with the C language and it has continuation as a goto statement. |
115 | 115 |
116 Code segments and data segments are low level enough to represent computation details, | 116 Code segments and data segments are low level enough to represent computation details, |
117 and it is architecture independent. | 117 and it is architecture independent. |
118 It can be used as an architecture independent assembler. | 118 It can be used as an architecture independent assembler. |
119 | 119 |
120 CbC has standalone compiler and GCC version. Here we report new partial implementation of CbC compiler based on LLVM and Clang 3.7. | 120 CbC has standalone compiler and GCC version. Here we report new partial implementation of CbC compiler based on LLVM and Clang 3.7. |
121 | 121 |
122 First we show CbC language overview. | 122 First we show the CbC language overview. |
123 \section{Continuation based C} | 123 \section{Continuation based C} |
124 CbC's basic programing unit is a code segment. It is not a subroutine, but it looks like a function, because it has input and output. These interfaces should be data segments and we are currently designing data segments part. | 124 CbC's basic programing unit is a code segment. It is not a subroutine, but it looks like a function, because it has input and output. These interfaces should be data segments and we are currently designing data segments part. |
125 | 125 |
126 \begin{table}[html] | 126 \begin{table}[html] |
127 \begin{lstlisting} | 127 \begin{lstlisting} |
140 \end{lstlisting} | 140 \end{lstlisting} |
141 \caption{CbC Example} | 141 \caption{CbC Example} |
142 \label{src:example} | 142 \label{src:example} |
143 \end{table} | 143 \end{table} |
144 | 144 |
145 In this example, a code segment {\bf f} has input datasegment {\bf allocate} (Allocate is a data segment identifier) and sends output it to a code segmnet {\bf g}. CbC compiler generates data segment definition automatically so we do not have to write it. There is no return from code segment {\bf g}, {\bf g} should call another continuation using {\bf goto}. Code segments has one input data segment and several output data segment, and their dependency is proved by data segments. | 145 In this example, a code segment {\bf f} has input datasegment {\bf allocate} (Allocate is a data segment identifier) and sends output it to a code segment {\bf g}. CbC compiler generates data segment definition automatically so we do not have to write it. There is no return from code segment {\bf g}, {\bf g} should call another continuation using {\bf goto}. Code segments has one input data segment and several output data segment, and their dependency is proved by data segments. |
146 \begin{figure}[htp] | 146 \begin{figure}[htp] |
147 \begin{center} | 147 \begin{center} |
148 \scalebox{0.5}{\includegraphics{fig/csds.pdf}} | 148 \scalebox{0.5}{\includegraphics{fig/csds.pdf}} |
149 \end{center} | 149 \end{center} |
150 \caption{Code Segmnets and Data Segments on CbC} | 150 \caption{Code Segments and Data Segments on CbC} |
151 \label{fig:csds} | 151 \label{fig:csds} |
152 \end{figure} | 152 \end{figure} |
153 | 153 |
154 In CbC, we can go to a code segment from a C function and we can call C functions in a code segment. So we don't have to shift completely from C to CbC. The later one is straight forward, but the former one needs further extensions. | 154 In CbC, we can go to a code segment from a C function and we can call C functions in a code segment. So we don't have to shift completely from C to CbC. The later one is straight forward, but the former one needs further extensions. |
155 | 155 |
191 \item Transition is implemented by forced tail call. | 191 \item Transition is implemented by forced tail call. |
192 \item Goto with environment is implemented by setjmp and longjmp. | 192 \item Goto with environment is implemented by setjmp and longjmp. |
193 \end{itemize} | 193 \end{itemize} |
194 | 194 |
195 {\bf \_\_code} is implemented as a new type keyword in LLVM and Clang. You may think {\bf \_\_code} is an attribute of a function, which means that the function can call in tail call elimination only. | 195 {\bf \_\_code} is implemented as a new type keyword in LLVM and Clang. You may think {\bf \_\_code} is an attribute of a function, which means that the function can call in tail call elimination only. |
196 Because of this implementation, we can actually call code segmnet as a C function call. | 196 Because of this implementation, we can actually call code segment as a C function call. |
197 | 197 |
198 Forcing tail call require many condisions. For example, there should be no statement after tail call, caller and callee's calling convention have to be the same and type is cc10, cc11 or fastcc, callee's return value type have to be the same as caller's it, add tail call elimination pass, and so on. | 198 Forcing tail call require many conditions. For example, there should be no statement after tail call, caller and callee's calling convention have to be the same and type is cc10, cc11 or fastcc, callee's return value type have to be the same as caller's it, add tail call elimination pass, and so on. |
199 | 199 |
200 All code segment has the void return type and we do not allow to write statement after continuation, so type problem and after statement problem is solved. | 200 All code segment has the void return type and we do not allow to write statement after continuation, so type problem and after statement problem is solved. |
201 | 201 |
202 Tail call elimination pass is enabled in {\bf BackendUtil.cpp}. In the clang, when optimize level is two or more, tail call elimination pass is enabled. We modify it to enable anytime and if optimize level is one or less, tail call elimination pass work for only code segment. | 202 Tail call elimination pass is enabled in {\bf BackendUtil.cpp}. In the clang, when optimize level is two or more, tail call elimination pass is enabled. We modify it to enable anytime and if optimize level is one or less, tail call elimination pass work for only code segment. |
203 | 203 |
204 Next, we solve a calling convention problem. We select fastcc for code segment's calling convention. In the clang, calling convention is managed by CGFunctionInfo class and its infomations are set in {\bf CGCall.cpp}. We modify here to set fastcc to code segmnets. | 204 Next, we solve a calling convention problem. We select fastcc for code segment's calling convention. In the clang, calling convention is managed by CGFunctionInfo class and its infomations are set in {\bf CGCall.cpp}. We modify here to set fastcc to code segments. |
205 | 205 |
206 Goto with environment is implemented by code rearranging. If the {\bf \_\_environment} or {\bf \_\_return} is declared, CbC compiler rearrange code for goto with environment. We use setjmp and longjmp for it. Setjmp save environment before continuation, and longjmp restore it. | 206 Goto with environment is implemented by code rearranging. If the {\bf \_\_environment} or {\bf \_\_return} is declared, CbC compiler rearrange code for goto with environment. We use setjmp and longjmp for it. Setjmp save environment before continuation, and longjmp restore it. |
207 | 207 |
208 \section{Result} | 208 \section{Result} |
209 Here is our bench mark program. | 209 Here is our benchmark program. |
210 | 210 |
211 \begin{table}[html] | 211 \begin{table}[html] |
212 \begin{lstlisting} | 212 \begin{lstlisting} |
213 int f0(int i) { | 213 int f0(int i) { |
214 int k,j; | 214 int k,j; |
223 | 223 |
224 int h0(int i) { | 224 int h0(int i) { |
225 return i+4; | 225 return i+4; |
226 } | 226 } |
227 \end{lstlisting} | 227 \end{lstlisting} |
228 \caption{bench mark program conv1} | 228 \caption{benchmark program conv1} |
229 \label{src:example} | 229 \label{src:example} |
230 \end{table} | 230 \end{table} |
231 | 231 |
232 It is written in C and CbC and there are several optimization is possible. | 232 It is written in C and CbC and there are several optimization is possible. |
233 When argument is 1, use CbC continuation. When argument is 2 or 3, optimization is enabled. | 233 When argument is 1, use CbC continuation. When argument is 2 or 3, optimization is enabled. |
234 | 234 |
235 Here we show bench mark result (TABLE \ref{result}). | 235 Here we show benchmark result (TABLE \ref{result}). |
236 | 236 |
237 \begin{table}[htpb] | 237 \begin{table}[htpb] |
238 \centering | 238 \centering |
239 \begin{tabular}{|l|r|r|r|} \hline | 239 \begin{tabular}{|l|r|r|r|} \hline |
240 & ./conv1 1 & ./conv1 2 & ./conv1 3 \\ \hline | 240 & ./conv1 1 & ./conv1 2 & ./conv1 3 \\ \hline |
250 LLVM and clang compiler is faster than Micro-C when optimization is enabled. It mean LLVM's optimization is powerful and useful. LLVM and clang compiler is slower than GCC but GCC cannot compile safety without optimization. It means LLVM can compile more reliability than GCC. | 250 LLVM and clang compiler is faster than Micro-C when optimization is enabled. It mean LLVM's optimization is powerful and useful. LLVM and clang compiler is slower than GCC but GCC cannot compile safety without optimization. It means LLVM can compile more reliability than GCC. |
251 | 251 |
252 \section{Conclusion} | 252 \section{Conclusion} |
253 We have designed and implemented Continuation based language for practical use. We have partial implementation of CbC using LLVM and Clang 3.7. CbC can use LLVM's optimization. We did not modify LLVM IR to implement CbC compiler. | 253 We have designed and implemented Continuation based language for practical use. We have partial implementation of CbC using LLVM and Clang 3.7. CbC can use LLVM's optimization. We did not modify LLVM IR to implement CbC compiler. |
254 | 254 |
255 In future, we design and implement data segmnet and meta code segment, meta data segment for meta computation. | 255 In future, we design and implement data segment and meta code segment, meta data segment for meta computation. |
256 \nocite{opac-b1092711, LLVMIR, LLVM, clang} | 256 \nocite{opac-b1092711, LLVMIR, LLVM, clang} |
257 \bibliographystyle{IEEEtran} | 257 \bibliographystyle{IEEEtran} |
258 \bibliography{IEEEabrv,reference} | 258 \bibliography{IEEEabrv,reference} |
259 | 259 |
260 | 260 |