Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 21 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 17, 2009
@tomlokhorst tomlokhorst Creating a new branch from trunk (revision 1517).
This branch will be used to merge the existing dotnet branch into the trunk.
The reason for this new branch is because the dotnet branch is completely broken, since previous merges somehow missed things...
465995c
Commits on Mar 19, 2009
@tomlokhorst tomlokhorst Added CLR backend. 00efc41
View
21 EHC/configure
@@ -672,6 +672,7 @@ javacCmd
jarCmd
JAVAC_CMD
JAR_CMD
+ENABLE_CLR
ranlibCmd
RANLIB_CMD
arCmd
@@ -1336,6 +1337,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-java include java code generation
+ --enable-clr include clr code generation
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -2153,6 +2155,16 @@ echo "$as_me: error:
fi
+# Check whether --enable-clr was given.
+if test "${enable_clr+set}" = set; then
+ enableval=$enable_clr; enableClr=yes
+else
+ enableClr=no
+fi
+
+ENABLE_CLR=$enableClr
+
+
### ar, ranlib, libtool
# Extract the first word of "ranlib", so it can be a program name with args.
@@ -2573,6 +2585,10 @@ HADDOCK_VERSION=$haddockVersion
# GHC version dependencies: packages passed as option, cabal packages
cabal_base_lib_depends="base haskell98 mtl fgl directory old-time"
+if test x$enableClr = "xyes"
+then
+ cabal_base_lib_depends="$cabal_base_lib_depends language-cil"
+fi
cabal_extra_lib_depends=""
optCabalAllowUndecidableInstances=UndecidableInstances
optStandardGHCPackages=""
@@ -7432,6 +7448,7 @@ javacCmd!$javacCmd$ac_delim
jarCmd!$jarCmd$ac_delim
JAVAC_CMD!$JAVAC_CMD$ac_delim
JAR_CMD!$JAR_CMD$ac_delim
+ENABLE_CLR!$ENABLE_CLR$ac_delim
ranlibCmd!$ranlibCmd$ac_delim
RANLIB_CMD!$RANLIB_CMD$ac_delim
arCmd!$arCmd$ac_delim
@@ -7471,7 +7488,6 @@ cppCmd!$cppCmd$ac_delim
CPP_CMD!$CPP_CMD$ac_delim
llvmAs!$llvmAs$ac_delim
LLVM_AS_CMD!$LLVM_AS_CMD$ac_delim
-llvmOpt!$llvmOpt$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -7513,6 +7529,7 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
+llvmOpt!$llvmOpt$ac_delim
LLVM_OPT_CMD!$LLVM_OPT_CMD$ac_delim
llvmLlc!$llvmLlc$ac_delim
LLVM_LLC_CMD!$LLVM_LLC_CMD$ac_delim
@@ -7554,7 +7571,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 39; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 40; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
View
7 EHC/configure.ac
@@ -98,6 +98,9 @@ then
AC_SUBST(JAR_CMD,$jarCmd)
fi
+AC_ARG_ENABLE(clr, AS_HELP_STRING([--enable-clr],[include clr code generation]), [enableClr=yes], [enableClr=no])
+AC_SUBST(ENABLE_CLR,$enableClr)
+
### ar, ranlib, libtool
REQUIRED_PROG_FOR_EH(ranlibCmd,ranlib)
# See remarks about cpp
@@ -247,6 +250,10 @@ AC_SUBST(HADDOCK_VERSION, $haddockVersion)
# GHC version dependencies: packages passed as option, cabal packages
cabal_base_lib_depends="base haskell98 mtl fgl directory old-time"
+if test x$enableClr = "xyes"
+then
+ cabal_base_lib_depends="$cabal_base_lib_depends language-cil"
+fi
cabal_extra_lib_depends=""
optCabalAllowUndecidableInstances=UndecidableInstances
optStandardGHCPackages=""
View
BIN EHC/extlibs/cil/language-cil-0.1.0.tar.gz
Binary file not shown.
View
4 EHC/mk/config.mk.in
@@ -65,3 +65,7 @@ ifeq (@ENABLE_JAVA@,yes)
ENABLE_JAVA := yes
endif
+ifeq (@ENABLE_CLR@,yes)
+ENABLE_CLR := yes
+endif
+
View
9 EHC/src/ehc/Base/Opts.chs
@@ -331,6 +331,12 @@ ehcOptEmitLLVM :: EHCOpts -> Bool
ehcOptEmitLLVM = targetIsLLVM . ehcOptTarget
%%]
+%%[(8 codegen clr) export(ehcOptEmitCLR)
+-- generate CIL, as .il assembly file
+ehcOptEmitCLR :: EHCOpts -> Bool
+ehcOptEmitCLR = targetIsCLR . ehcOptTarget
+%%]
+
%%[(8 codegen) export(ehcOptEmitCore)
-- generate Core
ehcOptEmitCore :: EHCOpts -> Bool
@@ -663,6 +669,9 @@ ehcCmdLineOpts
-> o { ehcOptTarget = Target_FullProgAnal_Grin_LLVM
}
%%]]
+%%[[(8 codegen clr)
+ Just "clr" -> o { ehcOptTarget = Target_FullProgAnal_Grin_CLR }
+%%]]
%%[[(99 hmtyinfer)
Just "dt" -> o { ehcOptEmitDerivTree = DerivTreeWay_Final }
%%]]
View
27 EHC/src/ehc/Base/Target.chs
@@ -33,7 +33,7 @@ Target_<treatment>_<intermediate-lang>_<codegen-lang>
- C
- LLVM
- JVM
- - DOTNET
+ - CLR
- Jazy, Java lazy interpreter
Combinations are all hardcoded to make explicit that only particular combinations are allowed.
@@ -53,9 +53,11 @@ data Target
| Target_FullProgAnal_Grin_C -- full program analysis on grin, generating C
| Target_FullProgAnal_Grin_LLVM -- full program analysis on grin, generating LLVM
| Target_FullProgAnal_Grin_JVM -- full program analysis on grin, generating for Java VM
- | Target_FullProgAnal_Grin_DOTNET -- full program analysis on grin, generating for .net
| Target_Interpreter_Grin_C -- no full program analysis, grin interpreter, generating C
%%]]
+%%[[(8 codegen clr)
+ | Target_FullProgAnal_Grin_CLR -- full program analysis on grin, generating for Common Language Runtime (.NET / Mono)
+%%]]
deriving (Eq,Ord)
%%]
@@ -76,9 +78,11 @@ instance Show Target where
show Target_FullProgAnal_Grin_C = "C"
show Target_FullProgAnal_Grin_LLVM = "llvm"
show Target_FullProgAnal_Grin_JVM = "jvm"
- show Target_FullProgAnal_Grin_DOTNET = "dotnet"
show Target_Interpreter_Grin_C = "bc"
%%]]
+%%[[(8 codegen clr)
+ show Target_FullProgAnal_Grin_CLR = "clr"
+%%]]
%%]
Default target
@@ -114,6 +118,9 @@ supportedTargetMp :: Map.Map String Target
, mk Target_FullProgAnal_Grin_C [FFIWay_CCall]
]
%%]]
+%%[[(8 codegen clr)
+ ++ [ mk Target_FullProgAnal_Grin_CLR [FFIWay_CCall] ]
+%%]]
]
mk t ffis = (t,TargetInfo (FFIWay_Prim : ffis))
@@ -138,7 +145,9 @@ targetIsFullProgAnal t
Target_FullProgAnal_Grin_C -> True
Target_FullProgAnal_Grin_LLVM -> True
Target_FullProgAnal_Grin_JVM -> True
- Target_FullProgAnal_Grin_DOTNET -> True
+%%]]
+%%[[(8 codegen clr)
+ Target_FullProgAnal_Grin_CLR -> True
%%]]
_ -> False
%%]
@@ -223,6 +232,16 @@ targetIsLLVM t
_ -> False
%%]
+%%[(8 codegen) export(targetIsCLR)
+targetIsCLR :: Target -> Bool
+targetIsCLR t
+ = case t of
+%%[[(8 codegen clr)
+ Target_FullProgAnal_Grin_CLR -> True
+%%]]
+ _ -> False
+%%]
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Possible FFI interface routes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
View
44 EHC/src/ehc/EHC/GrinCompilerDriver.chs
@@ -97,6 +97,10 @@
%%]
%%[(8 codegen grin) import({%{EH}LLVM.Pretty(prettyLLVMModule)})
%%]
+%%[(8 codegen clr) hs import(Language.Cil (Assembly (..), cil))
+%%]
+%%[(8 codegen clr) import({%{EH}GrinCode.ToCil(grin2cil)})
+%%]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Compilerdriver entry point
@@ -183,6 +187,13 @@ doCompileGrin input opts
; caWriteLLVM
}
)
+%%[[(8 codegen clr)
+ ; when (ehcOptEmitCLR options)
+ (do { caGrin2Cil
+ ; caWriteCil ""
+ }
+ )
+%%]]
; caWriteSilly "" "c" prettyC ehcOptEmitC
-- ; caWriteSilly "" "s" prettyS ehcOptEmitC
}
@@ -196,6 +207,11 @@ initState opts
= GRINCompileState { gcsGrin = undefined
, gcsSilly = undefined
, gcsLLVM = undefined
+%%]
+%%[(8 codegen clr)
+ , gcsCil = undefined
+%%]
+%%[(8 codegen grin) -1.doCompileGrin
, gcsHptMap = undefined
, gcsPath = emptyFPath
, gcsOpts = opts
@@ -259,6 +275,18 @@ caSilly2LLVM = do
}
%%]
+%%[(8 codegen clr)
+caGrin2Cil :: CompileAction ()
+caGrin2Cil = do
+ { code <- gets gcsGrin
+ ; hptMap <- gets gcsHptMap
+ ; opts <- gets gcsOpts
+ ; let cilAst = grin2cil hptMap code opts
+ ; modify (gcsUpdateCil cilAst)
+ }
+
+%%]
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Low level compiler actions: output
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -279,7 +307,15 @@ caWriteLLVM :: CompileAction()
caWriteLLVM =
do { llvm <- gets gcsLLVM
; caWriteFile "" "ll" (const prettyLLVMModule) llvm
- }
+ }
+
+%%[[(8 codegen clr)
+caWriteCil :: String -> CompileAction()
+caWriteCil extra =
+ do { cilAst <- gets gcsCil
+ ; caWriteFile extra "il" (const (\c -> text (cil c ""))) cilAst
+ }
+%%]]
caWriteGrin :: String -> CompileAction ()
caWriteGrin extra
@@ -327,6 +363,9 @@ data GRINCompileState = GRINCompileState
{ gcsGrin :: GrModule
, gcsSilly :: SilModule
, gcsLLVM :: LLVMModule
+%%[[(8 codegen clr)
+ , gcsCil :: Assembly
+%%]]
, gcsHptMap :: HptMap
, gcsPath :: FPath
, gcsOpts :: EHCOpts
@@ -335,6 +374,9 @@ data GRINCompileState = GRINCompileState
gcsUpdateGrin x s = s { gcsGrin = x }
gcsUpdateSilly x s = s { gcsSilly = x }
gcsUpdateLLVM x s = s { gcsLLVM = x }
+%%[[(8 codegen clr)
+gcsUpdateCil x s = s { gcsCil = x }
+%%]]
gcsUpdateHptMap x s = s { gcsHptMap = x }
gcsGetCodeHpt
View
6 EHC/src/ehc/GrinCode/Common.chs
@@ -17,7 +17,7 @@
%% Special names %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%[(8 codegen grin) export(wildcardNm, wildcardNr, mainNr, getNr, throwTag, hsnMainFullProg)
+%%[(8 codegen grin) export(wildcardNm, wildcardNr, mainNr, getNr, throwTag, hsnMainFullProg, conName)
wildcardNm = HNm "_"
wildcardNr = HNmNr 0 (OrigLocal wildcardNm)
@@ -185,7 +185,7 @@ type Limitations = [Limitation]
%% Abstract interpretation result %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%[(8 codegen grin) export(HptMap, getBaseEnvList, getEnvVar, absFetch, addEnvElems, getEnvSize, getTags, getNodes, isBottom, showHptMap, isPAppTag, isFinalTag, isApplyTag, filterTaggedNodes, getApplyNodeVars)
+%%[(8 codegen grin) export(HptMap, getBaseEnvList, getEnvVar, getHeapLoc, absFetch, addEnvElems, getEnvSize, getTags, getNodes, isBottom, showHptMap, isPAppTag, isFinalTag, isApplyTag, filterTaggedNodes, getApplyNodeVars)
type HptMap = ( Array Int AbstractValue -- env
, Array Int AbstractValue -- heap
@@ -231,7 +231,7 @@ absFetch a (HNmNr i _) = case getEnvVar a i of
AbsBottom -> AbsNodes Map.empty
AbsError s -> error $ "analysis error absFetch: " ++ show a ++ s
AbsBasic -> error $ "variable " ++ show i ++ " is a basic value"
- AbsNodes _ -> error $ "variable " ++ show i ++ "is a node variable"
+ AbsNodes _ -> error $ "variable " ++ show i ++ " is a node variable"
absFetch a x = error ("absFetch tried on " ++ show x)
getTags av = case av of
View
1 EHC/src/ehc/files-ag-s.dep
@@ -54,6 +54,7 @@ GrinCode/Pretty.cag
GrinCode/FreeVars.cag
GrinCode/PointsToAnalysis.cag
GrinCode/ToGrinByteCode.cag
+GrinCode/ToCil.cag
GrinCode/ToSilly.cag
GrinCode/Trf/ForceEval.cag
GrinCode/Trf/AliasElim.cag
View
1 EHC/src/ehc/files1.mk
@@ -55,6 +55,7 @@ EHC_HS_MAIN_DRV_HS := $(patsubst $(SRC_EHC_PREFIX)%.chs,$(EHC_BLD_VARIANT_A
EHC_HS_UTIL_SRC_CHS := $(patsubst %,$(SRC_EHC_PREFIX)%.chs,\
Substitutable Gam VarMp Deriving Module Config BuiltinPrims NameAspect DerivationTree CHR Pred \
$(addprefix CHR/,Key Constraint Solve) \
+ $(addprefix Cil/,Common TyTag) \
$(addprefix Pred/,ToCHR CHR Evidence EvidenceToCore Heuristics CommonCHR RedGraph) \
$(addprefix Base/,Opts Target BasicAnnot Common Builtin Builtin2 HsName Debug Trie CfgPP ForceEval LaTeX HtmlCommon Binary) \
$(addprefix Scanner/,Common Machine Scanner Token TokenParser) \
View
2 EHC/src/ehc/variant.mk
@@ -6,7 +6,7 @@
# aspects, EHC_ASPECTS to be configured at top level, for now here
###########################################################################################
-EHC_ASPECTS := $(if $(ASPECTS),$(ASPECTS),base hmtyinfer codegen grin noHmTyRuler $(if $(ENABLE_JAVA),java jazy,))
+EHC_ASPECTS := $(if $(ASPECTS),$(ASPECTS),base hmtyinfer codegen grin noHmTyRuler $(if $(ENABLE_JAVA),java jazy,) $(if $(ENABLE_CLR),clr,))
EHC_ASPECTS_SUFFIX := $(if $(ASPECTS),-$(subst $(space),-,$(ASPECTS)),)
EHC_ASPECTS_SUFFIX2 := $(subst -,,$(EHC_ASPECTS_SUFFIX))
View
9 EHC/test/clr/1-add/Test.hs
@@ -0,0 +1,9 @@
+module Main where
+
+foreign import ccall "primAddInt" (+) :: Int -> Int -> Int
+
+inc :: Int -> Int
+inc x = x + 1
+
+main = inc 41
+
View
16 EHC/test/clr/2-datatypes/Test.hs
@@ -0,0 +1,16 @@
+module Main where
+
+data MyData =
+ One Int
+ | Two Int Int
+ | Three Int Int Int
+ | Four Int Int Int Int
+
+first :: MyData -> Int
+first (One i) = i
+first (Two i _) = i
+first (Three i _ _) = i
+first (Four i _ _ _) = i
+
+main = first (Two 7 3)
+
View
20 EHC/test/clr/3-functioncalls/Test.hs
@@ -0,0 +1,20 @@
+module Main where
+
+foreign import ccall "primAddInt" (+) :: Int -> Int -> Int
+
+inc :: Int -> Int
+inc x = x + 1
+
+data List =
+ Nil
+ | Cons Int List
+
+length :: List -> Int
+length Nil = 0
+length (Cons x xs) = inc (length xs)
+
+five :: List
+five = Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))
+
+main = length five
+
View
22 EHC/test/clr/4-tailcall/Test.hs
@@ -0,0 +1,22 @@
+module Main where
+
+foreign import ccall primAddInt :: Int -> Int -> Int
+
+inc :: Int -> Int
+inc x = primAddInt x 1
+
+data List =
+ Nil
+ | Cons Int List
+
+length :: List -> Int
+length = length' 0
+ where
+ length' x Nil = x
+ length' x (Cons y ys) = length' (inc x) ys
+
+five :: List
+five = Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))
+
+main = length five
+
View
13 EHC/test/clr/5-actualthunks/Test.hs
@@ -0,0 +1,13 @@
+module Main where
+
+foreign import ccall primAddInt :: Int -> Int -> Int
+
+inc :: Int -> Int
+inc x = primAddInt x 1
+
+add = primAddInt
+
+f x = add x x
+
+main = f (inc 41)
+
View
25 EHC/test/clr/6-datatypethunks/Test.hs
@@ -0,0 +1,25 @@
+module Main where
+
+foreign import ccall "primAddInt" (+) :: Int -> Int -> Int
+
+data Maybe =
+ Nothing
+ | Just Int
+
+double :: Int -> Int
+double x = x + x
+
+doubleJust :: Maybe -> Int
+doubleJust (Just x) = double x
+doubleJust Nothing = 42
+
+pick :: Maybe -> Maybe -> Maybe
+pick Nothing m = m
+pick m Nothing = m
+pick m _ = m
+
+split :: Maybe -> Maybe
+split m = pick m m
+
+main = doubleJust (split (Just 3))
+
View
15 EHC/test/clr/7-papps/Test.hs
@@ -0,0 +1,15 @@
+module Main where
+
+foreign import ccall primAddInt :: Int -> Int -> Int
+
+inc :: Int -> Int
+inc x = primAddInt x 1
+
+add = primAddInt
+
+f x y z = add z x
+
+g x = f 3 x
+
+main = g (inc 41) 4
+
View
37 EHC/test/clr/8-fib/Test.hs
@@ -0,0 +1,37 @@
+module Main where
+
+data Bool = False | True
+
+data ''[]'' a = a : [a] | ''[]''
+
+foreign import ccall "primAddInt" (+) :: Int -> Int -> Int
+foreign import ccall "primSubInt" (-) :: Int -> Int -> Int
+foreign import ccall "primEqInt" (==) :: Int -> Int -> Bool
+
+infixr 6 :
+
+zipWith :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int]
+zipWith f (x:xs) (y:ys) = f x y : zipWith f xs ys
+zipWith _ _ _ = []
+
+sum :: [Int] -> Int
+sum [] = 0
+sum (x:xs) = x + sum xs
+
+tail :: [Int] -> [Int]
+tail [] = []
+tail (x:xs) = xs
+
+take :: Int -> [Int] -> [Int]
+take _ [] = []
+take n (x:xs) = if n == 0
+ then []
+ else x : take (n-1) xs
+
+length [] = 0
+length (_:xs) = 1 + length xs
+
+fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
+
+main = sum (take 5 fibs)
+
View
17 EHC/test/clr/9-parity/Test.hs
@@ -0,0 +1,17 @@
+module Main where
+
+data Bool = False | True
+
+foreign import ccall "primSubInt" (-) :: Int -> Int -> Int
+foreign import ccall "primEqInt" (==) :: Int -> Int -> Bool
+
+even :: Int -> Bool
+even x | x == 0 = True
+ | True = odd (x - 1)
+
+odd :: Int -> Bool
+odd x | x == 0 = False
+ | True = even (x - 1)
+
+main = even 100000000
+
View
89 EHC/text/InternalDocEhcTechnical.cltex
@@ -4,6 +4,7 @@
%%@InternalDocEhcTechnical.GrinCode
%%@InternalDocEhcTechnical.Silly
%%@InternalDocEhcTechnical.JVMClass
+%%@InternalDocEhcTechnical.CLR
%%]
@@ -253,3 +254,91 @@ The following transformations are performed on the Silly program:
%%]
+%%[CLR
+
+\section{CLR backend}
+
+The CLR backend is a highly experimental backend for the EHC developed during the Advanced Compiler Construction seminar in early 2009.
+
+\subsection{Overview}
+
+\subsubsection{Common Language Runtime}
+
+The Common Language Runtime (CLR) is a runtime system, developed by Microsoft as .NET, that runs managed code. It exposes facilities such as a common type system, memory management and just in time compilation. Currently the three most promiment implementations are:
+
+\begin{itemize}
+ \item .NET on the Windows desktop
+ \item Mono under Linux/OSX machines
+ \item Silverlight for running in the browser on Windows and OSX
+\end{itemize}
+
+\subsubsection{EHC backend}
+The experimental backend adds a new target to generate assembly files for the CLR. Using the flag \verb"-tclr", the compiler can be directed to generate \verb".il" files that contain Common Intermediate Langauge (aka MSIL) assembly code.
+
+These \verb".il" files can be assembled into \verb".exe" files using \verb"ilasm.exe" under Windows (available in \verb"%WINDOWS%\Microsoft.NET\Framework\v2.0.50727\") and \verb"ilasm2" under Linux/OSX (available through Mono).
+
+Here is a running scenario:
+\begin{verbatim}
+$ cat > Test.hs
+const x y = x
+main = const 8 15
+^C
+$ EHC/install/8/bin/ehc -tclr Test.hs
+$ ilasm2 Test.il
+$ mono Test.exe
+Int 8
+\end{verbatim}
+
+\paragraph{Note:} This chapter describes some technical aspects of the implementation, but it doesn't describe the underlying ideas.
+
+Ideally, a new separate document will be written detailing the underlining concepts of the CLR backend. However, such a document doesn't yet exist, for now there are just the slides and a video from the authors from the \href{http://tom.lokhorst.eu/ehc/clr/}{final presentation} of the Advanced Compiler Construction seminar.
+
+
+\subsection{Architecture}
+
+Currently, the CLR backend only works in variant 8 of the EHC. Work is being done to get variant 100 to comipile.
+
+\subsubsection{language-cil}
+The CLR backend makes use of an external library called language-cil. This library exposes an AST, build functions and pretty printers for the Common Intermediate Language (CIL).
+
+This library will need to be installed before compiling the EHC.
+
+At some point in the future language-cil will be uploaded to Hackage, however currently it lives just in source control: \href{https://svn.cs.uu.nl:12443/repos/language-cil/tags/0.1.0/}{https://svn.cs.uu.nl:12443/repos/language-cil/tags/0.1.0/}
+
+\subsubsection{/src/ehc/Cil/Common.chs}
+%%@EHCilCommon.doesWhat
+
+\subsubsection{/src/ehc/Cil/TyTag.chs}
+%%@EHCilTyTag.doesWhat
+
+\subsubsection{/src/ehc/GrinCode/ToCil.chs}
+%%@EHGrinCodeToCil.doesWhat
+
+\subsection{Tests}
+
+In the directory \verb"/test/clr" are some CLR test cases, some of which don't compile anymore, see open issues.
+
+\subsection{Open issues}
+
+Some open bugs which haven't been resolved yet:
+
+\begin{itemize}
+ \item \verb"/tests/5-tailcalls" Fails due to the fact that one tail call to many is generated.
+ \item \verb"/tests/8-fibs" Fails. App TyTag isn't implemented yet (Con, Fun and PApp are).
+\end{itemize}
+
+\subsection{Todo}
+
+\begin{itemize}
+ \item Add clr aspect
+ \item Document conceptual ideas behind architectural choices.
+ \item Remove \verb"ReferenceObject" indirection.
+ \item Better support for primitive types, \verb"GrPatLam.EnumAnnot" is hardcoded to booleans.
+ \item Become more stack-oriented (move to Silly?).
+ \item Make use of stack allocated objects (Value types).
+ \item Use more unboxed types, adding two integers shouldn't have to create 6 heap objects.
+ \item Use generic types instead of using container types for primitives.
+\end{itemize}
+
+%%]
+

No commit comments for this range

Something went wrong with that request. Please try again.