diff options
author | David Terei <davidterei@gmail.com> | 2012-06-25 01:42:44 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2012-06-25 01:42:44 -0700 |
commit | 3a8f9ea196fd663fb0c17da88a9c39aea2652dfe (patch) | |
tree | e3ce4c6aa6c75b6caf9a0b6ad026d1a6197f4d35 /compiler/llvmGen | |
parent | 41b37a233e92b3f7df07f1d8d4240e80643dff96 (diff) | |
download | haskell-3a8f9ea196fd663fb0c17da88a9c39aea2652dfe.tar.gz |
Warn if using unsupported version of LLVM.
Diffstat (limited to 'compiler/llvmGen')
-rw-r--r-- | compiler/llvmGen/LlvmCodeGen.hs | 21 | ||||
-rw-r--r-- | compiler/llvmGen/LlvmCodeGen/Base.hs | 11 |
2 files changed, 27 insertions, 5 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs index 4465957de4..62335b4fe2 100644 --- a/compiler/llvmGen/LlvmCodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen.hs @@ -27,6 +27,7 @@ import UniqSupply import Util import SysTools ( figureLlvmVersion ) +import Control.Monad ( when ) import Data.IORef ( writeIORef ) import Data.Maybe ( fromMaybe ) import System.IO @@ -51,9 +52,7 @@ llvmCodeGen dflags h us cmms dumpIfSet_dyn dflags Opt_D_dump_llvm "LLVM Code" pprLlvmHeader bufh <- newBufHandle h Prt.bufLeftRender bufh $ withPprStyleDoc dflags (mkCodeStyle CStyle) pprLlvmHeader - ver <- (fromMaybe defaultLlvmVersion) `fmap` figureLlvmVersion dflags - -- cache llvm version for later use - writeIORef (llvmVersion dflags) ver + ver <- getLlvmVersion env' <- {-# SCC "llvm_datas_gen" #-} cmmDataLlvmGens dflags bufh (setLlvmVer ver env) cdata [] {-# SCC "llvm_procs_gen" #-} @@ -61,6 +60,22 @@ llvmCodeGen dflags h us cmms bFlush bufh return () + where + -- | Handle setting up the LLVM version. + getLlvmVersion = do + ver <- (fromMaybe defaultLlvmVersion) `fmap` figureLlvmVersion dflags + -- cache llvm version for later use + writeIORef (llvmVersion dflags) ver + when (ver < minSupportLlvmVersion) $ + errorMsg dflags (text "You are using an old version of LLVM that" + <> text "isn't supported anymore!" + $+$ text "We will try though...") + when (ver > maxSupportLlvmVersion) $ + putMsg dflags (text "You are using a new version of LLVM that" + <> text "hasn't been tested yet!" + $+$ text "We will try though...") + return ver + -- ----------------------------------------------------------------------------- -- | Do LLVM code generation on all these Cmms data sections. diff --git a/compiler/llvmGen/LlvmCodeGen/Base.hs b/compiler/llvmGen/LlvmCodeGen/Base.hs index 2239dbb006..19ca511f16 100644 --- a/compiler/llvmGen/LlvmCodeGen/Base.hs +++ b/compiler/llvmGen/LlvmCodeGen/Base.hs @@ -9,7 +9,8 @@ module LlvmCodeGen.Base ( LlvmCmmDecl, LlvmBasicBlock, LlvmUnresData, LlvmData, UnresLabel, UnresStatic, - LlvmVersion, defaultLlvmVersion, + LlvmVersion, defaultLlvmVersion, minSupportLlvmVersion, + maxSupportLlvmVersion, LlvmEnv, initLlvmEnv, clearVars, varLookup, varInsert, funLookup, funInsert, getLlvmVer, setLlvmVer, getLlvmPlatform, @@ -144,7 +145,13 @@ type LlvmVersion = Int -- | The LLVM Version we assume if we don't know defaultLlvmVersion :: LlvmVersion -defaultLlvmVersion = 28 +defaultLlvmVersion = 30 + +minSupportLlvmVersion :: LlvmVersion +minSupportLlvmVersion = 28 + +maxSupportLlvmVersion :: LlvmVersion +maxSupportLlvmVersion = 31 -- ---------------------------------------------------------------------------- -- * Environment Handling |