Commit 5dc3db74 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo

Switch to LLVM version 3.7

parent e5baf62d
...@@ -117,6 +117,7 @@ ppLlvmMeta (MetaNamed n m) ...@@ -117,6 +117,7 @@ ppLlvmMeta (MetaNamed n m)
-- | Print out an LLVM metadata value. -- | Print out an LLVM metadata value.
ppLlvmMetaExpr :: MetaExpr -> SDoc ppLlvmMetaExpr :: MetaExpr -> SDoc
ppLlvmMetaExpr (MetaVar (LMLitVar (LMNullLit _))) = text "null"
ppLlvmMetaExpr (MetaStr s ) = text "!" <> doubleQuotes (ftext s) ppLlvmMetaExpr (MetaStr s ) = text "!" <> doubleQuotes (ftext s)
ppLlvmMetaExpr (MetaNode n ) = text "!" <> int n ppLlvmMetaExpr (MetaNode n ) = text "!" <> int n
ppLlvmMetaExpr (MetaVar v ) = ppr v ppLlvmMetaExpr (MetaVar v ) = ppr v
...@@ -273,17 +274,12 @@ ppCall ct fptr args attrs = case fptr of ...@@ -273,17 +274,12 @@ ppCall ct fptr args attrs = case fptr of
++ "local var of pointer function type." ++ "local var of pointer function type."
where where
ppCall' (LlvmFunctionDecl _ _ cc ret argTy params _) = ppCall' (LlvmFunctionDecl _ _ cc ret _ _ _) =
let tc = if ct == TailCall then text "tail " else empty let tc = if ct == TailCall then text "tail " else empty
ppValues = hsep $ punctuate comma $ map ppCallMetaExpr args ppValues = hsep $ punctuate comma $ map ppCallMetaExpr args
ppArgTy = (ppCommaJoin $ map fst params) <>
(case argTy of
VarArgs -> text ", ..."
FixedArgs -> empty)
fnty = space <> lparen <> ppArgTy <> rparen <> char '*'
attrDoc = ppSpaceJoin attrs attrDoc = ppSpaceJoin attrs
in tc <> text "call" <+> ppr cc <+> ppr ret in tc <> text "call" <+> ppr cc <+> ppr ret
<> fnty <+> ppName fptr <> lparen <+> ppValues <+> ppName fptr <> lparen <+> ppValues
<+> rparen <+> attrDoc <+> rparen <+> attrDoc
-- Metadata needs to be marked as having the `metadata` type when used -- Metadata needs to be marked as having the `metadata` type when used
...@@ -362,8 +358,11 @@ ppCmpXChg addr old new s_ord f_ord = ...@@ -362,8 +358,11 @@ ppCmpXChg addr old new s_ord f_ord =
-- of specifying alignment. -- of specifying alignment.
ppLoad :: LlvmVar -> SDoc ppLoad :: LlvmVar -> SDoc
ppLoad var = text "load" <+> ppr var <> align ppLoad var = text "load" <+> derefType <+> ppr var <> align
where where
derefType = case getVarType var of
LMPointer x -> ppr x <> comma
_ -> empty
align | isVector . pLower . getVarType $ var = text ", align 1" align | isVector . pLower . getVarType $ var = text ", align 1"
| otherwise = empty | otherwise = empty
...@@ -373,7 +372,10 @@ ppALoad ord st var = sdocWithDynFlags $ \dflags -> ...@@ -373,7 +372,10 @@ ppALoad ord st var = sdocWithDynFlags $ \dflags ->
align = text ", align" <+> ppr alignment align = text ", align" <+> ppr alignment
sThreaded | st = text " singlethread" sThreaded | st = text " singlethread"
| otherwise = empty | otherwise = empty
in text "load atomic" <+> ppr var <> sThreaded <+> ppSyncOrdering ord <> align derefType = case getVarType var of
LMPointer x -> ppr x <> comma
_ -> empty
in text "load atomic" <+> derefType <+> ppr var <> sThreaded <+> ppSyncOrdering ord <> align
ppStore :: LlvmVar -> LlvmVar -> SDoc ppStore :: LlvmVar -> LlvmVar -> SDoc
ppStore val dst ppStore val dst
...@@ -386,10 +388,10 @@ ppStore val dst ...@@ -386,10 +388,10 @@ ppStore val dst
ppCast :: LlvmCastOp -> LlvmVar -> LlvmType -> SDoc ppCast :: LlvmCastOp -> LlvmVar -> LlvmType -> SDoc
ppCast op from to ppCast op from to
= ppr op = ppr op
<+> ppr (getVarType from) <+> ppName from <+> ppr (getVarType from) <+> ppName from
<+> text "to" <+> text "to"
<+> ppr to <+> ppr to
...@@ -409,7 +411,10 @@ ppGetElementPtr :: Bool -> LlvmVar -> [LlvmVar] -> SDoc ...@@ -409,7 +411,10 @@ ppGetElementPtr :: Bool -> LlvmVar -> [LlvmVar] -> SDoc
ppGetElementPtr inb ptr idx = ppGetElementPtr inb ptr idx =
let indexes = comma <+> ppCommaJoin idx let indexes = comma <+> ppCommaJoin idx
inbound = if inb then text "inbounds" else empty inbound = if inb then text "inbounds" else empty
in text "getelementptr" <+> inbound <+> ppr ptr <> indexes derefType = case getVarType ptr of
LMPointer x -> ppr x <> comma
_ -> error "ppGetElementPtr"
in text "getelementptr" <+> inbound <+> derefType <+> ppr ptr <> indexes
ppReturn :: Maybe LlvmVar -> SDoc ppReturn :: Maybe LlvmVar -> SDoc
......
...@@ -581,6 +581,7 @@ instance Outputable LlvmCallConvention where ...@@ -581,6 +581,7 @@ instance Outputable LlvmCallConvention where
ppr CC_Ccc = text "ccc" ppr CC_Ccc = text "ccc"
ppr CC_Fastcc = text "fastcc" ppr CC_Fastcc = text "fastcc"
ppr CC_Coldcc = text "coldcc" ppr CC_Coldcc = text "coldcc"
ppr (CC_Ncc 10) = text "ghccc"
ppr (CC_Ncc i) = text "cc " <> ppr i ppr (CC_Ncc i) = text "cc " <> ppr i
ppr CC_X86_Stdcc = text "x86_stdcallcc" ppr CC_X86_Stdcc = text "x86_stdcallcc"
......
...@@ -47,21 +47,16 @@ llvmCodeGen dflags h us cmm_stream ...@@ -47,21 +47,16 @@ llvmCodeGen dflags h us cmm_stream
showPass dflags "LLVM CodeGen" showPass dflags "LLVM CodeGen"
-- get llvm version, cache for later use -- get llvm version, cache for later use
ver <- (fromMaybe defaultLlvmVersion) `fmap` figureLlvmVersion dflags ver <- (fromMaybe supportedLlvmVersion) `fmap` figureLlvmVersion dflags
writeIORef (llvmVersion dflags) ver writeIORef (llvmVersion dflags) ver
-- warn if unsupported -- warn if unsupported
debugTraceMsg dflags 2 debugTraceMsg dflags 2
(text "Using LLVM version:" <+> text (show ver)) (text "Using LLVM version:" <+> text (show ver))
let doWarn = wopt Opt_WarnUnsupportedLlvmVersion dflags let doWarn = wopt Opt_WarnUnsupportedLlvmVersion dflags
when (ver < minSupportLlvmVersion && doWarn) $ when (ver /= supportedLlvmVersion && doWarn) $
errorMsg dflags (text "You are using an old version of LLVM that" putMsg dflags (text "You are using an unsupported version of LLVM!"
<> text " isn't supported anymore!"
$+$ text "We will try though...") $+$ text "We will try though...")
when (ver > maxSupportLlvmVersion && doWarn) $
putMsg dflags (text "You are using a new version of LLVM that"
<> text " hasn't been tested yet!"
$+$ text "We will try though...")
-- run code generation -- run code generation
runLlvm dflags ver bufh us $ runLlvm dflags ver bufh us $
......
...@@ -12,8 +12,7 @@ module LlvmCodeGen.Base ( ...@@ -12,8 +12,7 @@ module LlvmCodeGen.Base (
LiveGlobalRegs, LiveGlobalRegs,
LlvmUnresData, LlvmData, UnresLabel, UnresStatic, LlvmUnresData, LlvmData, UnresLabel, UnresStatic,
LlvmVersion, defaultLlvmVersion, minSupportLlvmVersion, LlvmVersion, supportedLlvmVersion,
maxSupportLlvmVersion,
LlvmM, LlvmM,
runLlvm, liftStream, withClearVars, varLookup, varInsert, runLlvm, liftStream, withClearVars, varLookup, varInsert,
...@@ -174,15 +173,9 @@ llvmPtrBits dflags = widthInBits $ typeWidth $ gcWord dflags ...@@ -174,15 +173,9 @@ llvmPtrBits dflags = widthInBits $ typeWidth $ gcWord dflags
-- | LLVM Version Number -- | LLVM Version Number
type LlvmVersion = Int type LlvmVersion = Int
-- | The LLVM Version we assume if we don't know -- | The LLVM Version that is currently supported.
defaultLlvmVersion :: LlvmVersion supportedLlvmVersion :: LlvmVersion
defaultLlvmVersion = 36 supportedLlvmVersion = 37
minSupportLlvmVersion :: LlvmVersion
minSupportLlvmVersion = 36
maxSupportLlvmVersion :: LlvmVersion
maxSupportLlvmVersion = 36
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
-- * Environment Handling -- * Environment Handling
......
...@@ -553,7 +553,7 @@ esac ...@@ -553,7 +553,7 @@ esac
# tools we are looking for. In the past, GHC supported a number of # tools we are looking for. In the past, GHC supported a number of
# versions of LLVM simultaneously, but that stopped working around # versions of LLVM simultaneously, but that stopped working around
# 3.5/3.6 release of LLVM. # 3.5/3.6 release of LLVM.
LlvmVersion=3.6 LlvmVersion=3.7
AC_SUBST([LlvmVersion]) AC_SUBST([LlvmVersion])
dnl ** Which LLVM llc to use? dnl ** Which LLVM llc to use?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment