on master help sign in
Merge pull request #389 from melted/optllvm
0c1deafEdwin Brady
Setup.hs+10−2
@@ -143,6 +143,12 @@ javaFlag flags =
143 Just False -> False
143 Just False -> False
144 Nothing -> False
144 Nothing -> False
145
145
146+llvmFlag flags =
147+ case lookup (FlagName "LLVM") (S.configConfigurationsFlags flags) of
148+ Just True -> True
149+ Just False -> False
150+ Nothing -> False
151+
146noEffectsFlag flags =
152noEffectsFlag flags =
147 case lookup (FlagName "noeffects") (S.configConfigurationsFlags flags) of
153 case lookup (FlagName "noeffects") (S.configConfigurationsFlags flags) of
148 Just True -> True
154 Just True -> True
@@ -167,7 +173,8 @@ main = do
167 let withoutEffects = noEffectsFlag $ configFlags lbi
173 let withoutEffects = noEffectsFlag $ configFlags lbi
168 installStdLib pkg lbi withoutEffects verb
174 installStdLib pkg lbi withoutEffects verb
169 (S.fromFlag $ S.copyDest flags)
175 (S.fromFlag $ S.copyDest flags)
176+ when (llvmFlag $ configFlags lbi)
170− installLLVMLib verb pkg lbi (S.fromFlag $ S.copyDest flags)
177+ (installLLVMLib verb pkg lbi (S.fromFlag $ S.copyDest flags))
171 when (javaFlag $ configFlags lbi)
178 when (javaFlag $ configFlags lbi)
172 (installJavaLib pkg
179 (installJavaLib pkg
173 lbi
180 lbi
@@ -180,7 +187,8 @@ main = do
180 let withoutEffects = noEffectsFlag $ configFlags lbi
187 let withoutEffects = noEffectsFlag $ configFlags lbi
181 installStdLib pkg lbi withoutEffects verb
188 installStdLib pkg lbi withoutEffects verb
182 NoCopyDest
189 NoCopyDest
190+ when (llvmFlag $ configFlags lbi)
183− installLLVMLib verb pkg lbi NoCopyDest
191+ (installLLVMLib verb pkg lbi NoCopyDest)
184 when (javaFlag $ configFlags lbi)
192 when (javaFlag $ configFlags lbi)
185 (installJavaLib pkg
193 (installJavaLib pkg
186 lbi
194 lbi
idris.cabal+13−2
@@ -242,6 +242,11 @@ Flag NoEffects
242 Description: Do not build the effects package
242 Description: Do not build the effects package
243 Default: False
243 Default: False
244
244
245+Flag LLVM
246+ Description: Build the LLVM backend
247+ Default: True
248+ manual: True
249+
245Executable idris
250Executable idris
246 Main-is: Main.hs
251 Main-is: Main.hs
247 hs-source-dirs: src
252 hs-source-dirs: src
@@ -267,7 +272,7 @@ Executable idris
267 IRTS.CodegenC, IRTS.Defunctionalise, IRTS.Inliner,
272 IRTS.CodegenC, IRTS.Defunctionalise, IRTS.Inliner,
268 IRTS.Compiler, IRTS.CodegenJava, IRTS.Java.ASTBuilding,
273 IRTS.Compiler, IRTS.CodegenJava, IRTS.Java.ASTBuilding,
269 IRTS.Java.JTypes, IRTS.Java.Mangling, IRTS.BCImp,
274 IRTS.Java.JTypes, IRTS.Java.Mangling, IRTS.BCImp,
270− IRTS.CodegenJavaScript, IRTS.CodegenLLVM,
275+ IRTS.CodegenJavaScript,
271 IRTS.CodegenCommon, IRTS.DumpBC
276 IRTS.CodegenCommon, IRTS.DumpBC
272
277
273 Paths_idris
278 Paths_idris
@@ -276,7 +281,7 @@ Executable idris
276 haskeline>=0.7, split, directory,
281 haskeline>=0.7, split, directory,
277 containers, process, transformers, filepath,
282 containers, process, transformers, filepath,
278 directory, binary, bytestring, text, pretty,
283 directory, binary, bytestring, text, pretty,
279− language-java>=0.2.2, libffi, llvm-general>=3.3.4.1 && <3.3.5,
284+ language-java>=0.2.2, libffi,
280 vector, vector-binary-instances
285 vector, vector-binary-instances
281
286
282 Extensions: MultiParamTypeClasses, FunctionalDependencies,
287 Extensions: MultiParamTypeClasses, FunctionalDependencies,
@@ -292,3 +297,9 @@ Executable idris
292 if os(windows)
297 if os(windows)
293 cpp-options: -DWINDOWS
298 cpp-options: -DWINDOWS
294 build-depends: Win32
299 build-depends: Win32
300+ if flag(LLVM)
301+ other-modules: IRTS.CodegenLLVM
302+ cpp-options: -DIDRIS_LLVM
303+ build-depends: llvm-general>=3.3.4.1 && <3.3.5
304+ else
305+ other-modules: Util.LLVMStubs
src/IRTS/Compiler.hs+5−1
@@ -1,4 +1,4 @@
1−{-# LANGUAGE PatternGuards, TypeSynonymInstances #-}
1+{-# LANGUAGE PatternGuards, TypeSynonymInstances, CPP #-}
2
2
3module IRTS.Compiler where
3module IRTS.Compiler where
4
4
@@ -10,7 +10,11 @@ import IRTS.CodegenC
10import IRTS.CodegenJava
10import IRTS.CodegenJava
11import IRTS.DumpBC
11import IRTS.DumpBC
12import IRTS.CodegenJavaScript
12import IRTS.CodegenJavaScript
13+#ifdef IDRIS_LLVM
13import IRTS.CodegenLLVM
14import IRTS.CodegenLLVM
15+#else
16+import Util.LLVMStubs
17+#endif
14import IRTS.Inliner
18import IRTS.Inliner
15
19
16import Idris.AbsSyntax
20import Idris.AbsSyntax
src/Idris/REPL.hs+5−3
@@ -1,5 +1,5 @@
1{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, DeriveFunctor,
1{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, DeriveFunctor,
2− PatternGuards #-}
2+ PatternGuards, CPP #-}
3
3
4module Idris.REPL where
4module Idris.REPL where
5
5
@@ -38,9 +38,11 @@ import IRTS.CodegenCommon
38-- import RTS.Bytecode
38-- import RTS.Bytecode
39-- import RTS.PreC
39-- import RTS.PreC
40-- import RTS.CodegenC
40-- import RTS.CodegenC
41−
41+#ifdef IDRIS_LLVM
42import LLVM.General.Target
42import LLVM.General.Target
43−
43+#else
44+import Util.LLVMStubs
45+#endif
44import System.Console.Haskeline as H
46import System.Console.Haskeline as H
45import System.FilePath
47import System.FilePath
46import System.Exit
48import System.Exit
src/Util/LLVMStubs.hsnew file+30
@@ -0,0 +1,30 @@
1+{--
2+
3+Things needed to build without LLVM
4+Replaces stuff from LLVM.General.Target and IRTS.CodegenLLVM.
5+
6+--}
7+
8+module Util.LLVMStubs where
9+
10+import qualified Core.TT as TT
11+import IRTS.Simplified
12+import IRTS.CodegenCommon
13+
14+
15+getDefaultTargetTriple :: IO String
16+getDefaultTargetTriple = return ""
17+
18+getHostCPUName :: IO String
19+getHostCPUName = return ""
20+
21+
22+codegenLLVM :: [(TT.Name, SDecl)] ->
23+ String -> -- target triple
24+ String -> -- target CPU
25+ Int -> -- Optimization degree
26+ FilePath -> -- output file name
27+ OutputType ->
28+ IO ()
29+
30+codegenLLVM _ _ _ _ _ _ = print "Error: This Idris was compiled without the LLVM backend."