Mercurial > hg > Papers > 2015 > kaito-lola
diff cfopm.tex @ 3:c50a033e6635
create presentation slide
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 01 Jul 2015 19:06:07 +0900 |
parents | 771136eae970 |
children | 117760bfcae9 |
line wrap: on
line diff
--- a/cfopm.tex Mon Jun 22 19:44:08 2015 +0900 +++ b/cfopm.tex Wed Jul 01 19:06:07 2015 +0900 @@ -80,8 +80,7 @@ % As a general rule, do not put math, special symbols or citations % in the abstract \begin{abstract} - The proposed programming paradigm uses data segments and code segments. This paradigm uses Continuation based C (CbC), which is an extension and subset of C. - CbC has a standalone compiler and the GNU Compiler Collection (GCC). This study details and evaluates the implementation of a CbC compiler for LLVM and Clang 3.7. +The programming paradigm which use data segments and code segments are proposed. CbC is a slight modified C for this paradigm. CbC has standalone compiler and GCC(GNU Compiler Collection) version. GCC based CbC compiler is developed in 2008\cite{DBLP:journals/corr/abs-1109-4048} and nested function based goto with environment is implemented in 2011\cite{CbC2011}. In this study, we report a latest CbC compiler which is inplemented in LLVM and Clang 3.7. The detail of implementation and evaluation are shown. \end{abstract} % no keywords @@ -106,7 +105,7 @@ Code segments are connected to data segments by a meta data segment called a context. After the execution of a code segment and its context, the next code segment (continuation) is executed. -Continuation based C (CbC) \cite{DBLP:journals/corr/abs-1109-4048}, hereafter referred to as CbC, is an extension and subset of C which supports code segments. It is compatible with C and has continuation as a goto statement. +Continuation based C (CbC) \cite{DBLP:journals/corr/abs-1109-4048}, hereafter referred to as CbC, is a slight modified C which supports code segments. It is compatible with C and has continuation as a goto statement. Code segments and data segments are low level enough to represent computational details, and are architecture independent. They can be used as architecture independent assemblers. @@ -135,7 +134,9 @@ \label{src:example} \end{table} -In this example, the code segment {\bf f} takes the input data segment {\bf allocate} (allocate is the data segments identifier) and sends f's outuput to the code segment {\bf g}. The Cbc compiler generates the data segment definition automatically, so writing it is unnecessary. There is no return from code segment {\bf g}. {\bf G} should call another continuation using {\bf goto}. Code segments have one input data segment and several output data segments, and their dependency is proved by the data segments. +In this example, the code segment {\bf f} takes the input data segment {\bf allocate} (allocate is the data segments identifier) and sends f's outuput to the code segment {\bf g}. The CbC compiler generates the data segment definition automatically, so writing it is unnecessary. There is no return from code segment {\bf g}. {\bf G} should call another continuation using {\bf goto}. Code segments have input data segments and output data segments. Data segments have two kind of dependency with code segments. +First, Code segments access the contents of data segments using field names. So data segments should have the named fields. +The second dependency is a data dependency, that is all input data segments should be ready before their execution. \begin{figure}[htp] \begin{center} @@ -155,14 +156,14 @@ __code hello(char *s, __code(*ret)(int, void*), void *env) { printf(s); - goto (*ret)(0); + goto (*ret)(123); } \end{lstlisting} \caption{Call C Functions in a Code Segment} \label{src:example} \end{table} -In this hello world example, the environment of {\bf main}() and its continuation is kept in the variable {\bf \_\_environment}. The environment and the continuation can be accessed using {\bf \_\_environment} and {\bf \_\_return}.The arbitrary mixing of code segments and functions is allowed. The continuation of a {\bf goto} statement never returns to the original function, but goes to the caller or the original function. In that case, it returns the result 0 to the operating system. This continuation is called {\bf goto with environment}. +In this hello world example, the environment of {\bf main}() and its continuation is kept in the variable {\bf \_\_environment}. The environment and the continuation can be accessed using {\bf \_\_environment} and {\bf \_\_return}.The arbitrary mixing of code segments and functions is allowed. The continuation of a {\bf goto} statement never returns to the original function, but goes to the caller or the original function. In that case, it returns the result 123 to the operating system. This continuation is called {\bf goto with environment}. \section{LLVM and Clang} The LLVM Project is a collection of modular and reusable compilers and toolchain technologies, and the LLVM Core libraries provide a modern source and target independent optimizer, along with code generation support for many popular CPUs. Clang is an LLVM native C/C++/Objective-C compiler. Figure \ref{fig:structure} shows Clang and LLVM's compilation flow. @@ -193,7 +194,7 @@ All code segments have the void return type and writing statements after continuation is not allowed. As a result, type problems and after statement problems are solved. Tail call elimination passes are enabled in {\bf BackendUtil.cpp}. In Clang, when the optimization level is two or more, tail call elimination passing is enable. Here it has been modified to be enabled anytime, however if the optimization level is one or less, tail call elimination passes only work for code segments. -A calling convention problem was also solved. fastcc was selected for a code segment's calling convention. In Clang, calling conventions are managed by the CGFunctionInfo class and its information is set in {\bf CGCall.ccp}, which is where cod segments calling conventions were set to fastcc. +A calling convention problem was also solved. fastcc was selected for a code segment's calling convention. In Clang, calling conventions are managed by the CGFunctionInfo class and its information is set in {\bf CGCall.ccp} ( a part of CodeGen ), which is where code segments calling conventions were set to fastcc. Goto with environment is implemented by code rearranging. If the {\bf \_\_environment} or {\bf \_\_return} is declared, the CbC compiler rearranges the code for goto with environment. Setjmp and longjmp are used to do this. setjmp to save the environment before continuation and longjmp to restore it. @@ -223,6 +224,7 @@ It is written in C and CbC and there are several optimizations possible. When the argument is 1, CbC continuation is used. When the argument is 2 or 3, optimization is enabled. +In this benchmark, inline optimization was omitted. The benchmark results are shown in TABLE \ref{result}. \begin{table}[htpb] @@ -238,7 +240,7 @@ \label{result} \end{table} -LLVM and Clang compilers are faster than Micro-C when optimization is enabled. This means LLVM's optimization is powerful and useful. The LLVM and Clang complier is slower than GCC, but GCC cannot compile safely without optimization. This means LLVM can compile more reliably than GCC. +LLVM and Clang compilers are faster than Micro-C when optimization is enabled. This means CbC get benefits from LLVM optimizations. The LLVM and Clang complier is slower than GCC, but GCC cannot compile safely without optimization. This means LLVM can compile more reliably than GCC. \section{Conclusion} This Continuation based language has been designed and implemented for practical use. CbC has been partially implemented using LLVM and Clang 3.7.