diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-03-09 11:37:18 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-17 19:05:50 -0400 |
commit | 84927818ee68c6826327abc26d4647fb56053fb7 (patch) | |
tree | 108ab49003f77c80a1b2eeb755df44ecad416f22 /compiler/GHC/CmmToLlvm/Base.hs | |
parent | 540fa6b2cff3802877ff56a47ab3611e33a9ac86 (diff) | |
download | haskell-84927818ee68c6826327abc26d4647fb56053fb7.tar.gz |
llvmGen: Accept range of LLVM versions
Previously we would support only one LLVM major version. Here we
generalize this to accept a range, taking this range to be LLVM 10 to 11,
as 11 is necessary for Apple M1 support. We also accept 12, as that is
what apple ships with BigSur on the M1.
Diffstat (limited to 'compiler/GHC/CmmToLlvm/Base.hs')
-rw-r--r-- | compiler/GHC/CmmToLlvm/Base.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/GHC/CmmToLlvm/Base.hs b/compiler/GHC/CmmToLlvm/Base.hs index a943bfcebb..eda29c1ec7 100644 --- a/compiler/GHC/CmmToLlvm/Base.hs +++ b/compiler/GHC/CmmToLlvm/Base.hs @@ -15,7 +15,8 @@ module GHC.CmmToLlvm.Base ( LiveGlobalRegs, LlvmUnresData, LlvmData, UnresLabel, UnresStatic, - LlvmVersion, supportedLlvmVersion, llvmVersionSupported, parseLlvmVersion, + LlvmVersion, supportedLlvmVersionMin, supportedLlvmVersionMax, + llvmVersionSupported, parseLlvmVersion, llvmVersionStr, llvmVersionList, LlvmM, @@ -265,6 +266,7 @@ llvmPtrBits platform = widthInBits $ typeWidth $ gcWord platform -- Newtype to avoid using the Eq instance! newtype LlvmVersion = LlvmVersion { llvmVersionNE :: NE.NonEmpty Int } + deriving (Eq, Ord) parseLlvmVersion :: String -> Maybe LlvmVersion parseLlvmVersion = @@ -281,11 +283,13 @@ parseLlvmVersion = (ver_str, rest) = span isDigit s -- | The LLVM Version that is currently supported. -supportedLlvmVersion :: LlvmVersion -supportedLlvmVersion = LlvmVersion (sUPPORTED_LLVM_VERSION NE.:| []) +supportedLlvmVersionMin, supportedLlvmVersionMax :: LlvmVersion +supportedLlvmVersionMin = LlvmVersion (sUPPORTED_LLVM_VERSION_MIN NE.:| []) +supportedLlvmVersionMax = LlvmVersion (sUPPORTED_LLVM_VERSION_MAX NE.:| []) llvmVersionSupported :: LlvmVersion -> Bool -llvmVersionSupported (LlvmVersion v) = NE.head v == sUPPORTED_LLVM_VERSION +llvmVersionSupported v = + v > supportedLlvmVersionMin && v <= supportedLlvmVersionMax llvmVersionStr :: LlvmVersion -> String llvmVersionStr = intercalate "." . map show . llvmVersionList |