summaryrefslogtreecommitdiff
path: root/compiler/llvmGen
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2019-06-22 10:13:51 +1000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-24 01:11:46 -0400
commit71aca77c780dad8496054a06a7fe65704a13a742 (patch)
tree9c809e4619fecd7662b56cc9ce07720ea669c12c /compiler/llvmGen
parent9bbcc3be51180dcefde0c89daf8ad6f69c680b40 (diff)
downloadhaskell-71aca77c780dad8496054a06a7fe65704a13a742.tar.gz
Fixes for LLVM 7
LLVM version numberinf changed recently. Previously, releases were numbered 4.0, 5.0 and 6.0 but with version 7, they dropped the redundant ".0". Fix requires for Llvm detection and some code.
Diffstat (limited to 'compiler/llvmGen')
-rw-r--r--compiler/llvmGen/LlvmCodeGen.hs2
-rw-r--r--compiler/llvmGen/LlvmCodeGen/Base.hs19
2 files changed, 16 insertions, 5 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs
index a24a416256..88901be4d6 100644
--- a/compiler/llvmGen/LlvmCodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen.hs
@@ -3,7 +3,7 @@
-- -----------------------------------------------------------------------------
-- | This is the top-level module in the LLVM code generator.
--
-module LlvmCodeGen ( llvmCodeGen, llvmFixupAsm ) where
+module LlvmCodeGen ( LlvmVersion (..), llvmCodeGen, llvmFixupAsm ) where
#include "HsVersions.h"
diff --git a/compiler/llvmGen/LlvmCodeGen/Base.hs b/compiler/llvmGen/LlvmCodeGen/Base.hs
index b47bf6aff6..81f3b9f84c 100644
--- a/compiler/llvmGen/LlvmCodeGen/Base.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Base.hs
@@ -13,7 +13,7 @@ module LlvmCodeGen.Base (
LiveGlobalRegs,
LlvmUnresData, LlvmData, UnresLabel, UnresStatic,
- LlvmVersion, supportedLlvmVersion, llvmVersionStr,
+ LlvmVersion (..), supportedLlvmVersion, llvmVersionStr,
LlvmM,
runLlvm, liftStream, withClearVars, varLookup, varInsert,
@@ -177,14 +177,25 @@ llvmPtrBits dflags = widthInBits $ typeWidth $ gcWord dflags
--
-- | LLVM Version Number
-type LlvmVersion = (Int, Int)
+data LlvmVersion
+ = LlvmVersion Int
+ | LlvmVersionOld Int Int
+ deriving Eq
+
+-- Custom show instance for backwards compatibility.
+instance Show LlvmVersion where
+ show (LlvmVersion maj) = show maj
+ show (LlvmVersionOld maj min) = show maj ++ "." ++ show min
-- | The LLVM Version that is currently supported.
supportedLlvmVersion :: LlvmVersion
-supportedLlvmVersion = sUPPORTED_LLVM_VERSION
+supportedLlvmVersion = LlvmVersion sUPPORTED_LLVM_VERSION
llvmVersionStr :: LlvmVersion -> String
-llvmVersionStr (major, minor) = show major ++ "." ++ show minor
+llvmVersionStr v =
+ case v of
+ LlvmVersion maj -> show maj
+ LlvmVersionOld maj min -> show maj ++ "." ++ show min
-- ----------------------------------------------------------------------------
-- * Environment Handling