summaryrefslogtreecommitdiff
path: root/compiler/llvmGen/LlvmCodeGen
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-09-12 11:31:11 +0100
committerIan Lynagh <ian@well-typed.com>2012-09-12 11:31:11 +0100
commitf611396a581e733c41cee41750c95675bdb64961 (patch)
tree5ac98a36e98a6a58e97de9d1a7605386a41cd688 /compiler/llvmGen/LlvmCodeGen
parent6986eb91102b42ed61953500b60724c385dd658c (diff)
downloadhaskell-f611396a581e733c41cee41750c95675bdb64961.tar.gz
Pass DynFlags down to bWord
I've switched to passing DynFlags rather than Platform, as (a) it's simpler to not have to extract targetPlatform in so many places, and (b) it may be useful to have DynFlags around in future.
Diffstat (limited to 'compiler/llvmGen/LlvmCodeGen')
-rw-r--r--compiler/llvmGen/LlvmCodeGen/CodeGen.hs18
-rw-r--r--compiler/llvmGen/LlvmCodeGen/Data.hs10
2 files changed, 17 insertions, 11 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
index 7f80cab617..a4b7652f8a 100644
--- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
@@ -243,10 +243,12 @@ genCall env (CmmPrim _ (Just stmts)) _ _ _
-- Handle all other foreign calls and prim ops.
genCall env target res args ret = do
+ let dflags = getDflags env
+
-- parameter types
let arg_type (CmmHinted _ AddrHint) = i8Ptr
-- cast pointers to i8*. Llvm equivalent of void*
- arg_type (CmmHinted expr _ ) = cmmToLlvmType $ cmmExprType expr
+ arg_type (CmmHinted expr _ ) = cmmToLlvmType $ cmmExprType dflags expr
-- ret type
let ret_type ([]) = LMVoid
@@ -755,11 +757,12 @@ exprToVarOpt env opt e = case e of
-> genMachOp env opt op exprs
CmmRegOff r i
- -> exprToVar env $ expandCmmReg (r, i)
+ -> exprToVar env $ expandCmmReg dflags (r, i)
CmmStackSlot _ _
-> panic "exprToVar: CmmStackSlot not supported!"
+ where dflags = getDflags env
-- | Handle CmmMachOp expressions
genMachOp :: LlvmEnv -> EOption -> MachOp -> [CmmExpr] -> UniqSM ExprData
@@ -1171,9 +1174,10 @@ genLit env (CmmFloat r w)
nilOL, [])
genLit env cmm@(CmmLabel l)
- = let label = strCLabel_llvm env l
+ = let dflags = getDflags env
+ label = strCLabel_llvm env l
ty = funLookup label env
- lmty = cmmToLlvmType $ cmmLitType cmm
+ lmty = cmmToLlvmType $ cmmLitType dflags cmm
in case ty of
-- Make generic external label definition and then pointer to it
Nothing -> do
@@ -1340,9 +1344,9 @@ doExpr ty expr = do
-- | Expand CmmRegOff
-expandCmmReg :: (CmmReg, Int) -> CmmExpr
-expandCmmReg (reg, off)
- = let width = typeWidth (cmmRegType reg)
+expandCmmReg :: DynFlags -> (CmmReg, Int) -> CmmExpr
+expandCmmReg dflags (reg, off)
+ = let width = typeWidth (cmmRegType dflags reg)
voff = CmmLit $ CmmInt (fromIntegral off) width
in CmmMachOp (MO_Add width) [CmmReg reg, voff]
diff --git a/compiler/llvmGen/LlvmCodeGen/Data.hs b/compiler/llvmGen/LlvmCodeGen/Data.hs
index 8e42149dce..eae8246138 100644
--- a/compiler/llvmGen/LlvmCodeGen/Data.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Data.hs
@@ -38,11 +38,12 @@ structStr = fsLit "_struct"
-- done by 'resolveLlvmData'.
genLlvmData :: LlvmEnv -> (Section, CmmStatics) -> LlvmUnresData
genLlvmData env (sec, Statics lbl xs) =
- let static = map genData xs
+ let dflags = getDflags env
+ static = map genData xs
label = strCLabel_llvm env lbl
types = map getStatTypes static
- getStatTypes (Left x) = cmmToLlvmType $ cmmLitType x
+ getStatTypes (Left x) = cmmToLlvmType $ cmmLitType dflags x
getStatTypes (Right x) = getStatType x
strucTy = LMStruct types
@@ -106,9 +107,10 @@ resData :: LlvmEnv -> UnresStatic -> (LlvmEnv, LlvmStatic, [LMGlobal])
resData env (Right stat) = (env, stat, [])
resData env (Left cmm@(CmmLabel l)) =
- let label = strCLabel_llvm env l
+ let dflags = getDflags env
+ label = strCLabel_llvm env l
ty = funLookup label env
- lmty = cmmToLlvmType $ cmmLitType cmm
+ lmty = cmmToLlvmType $ cmmLitType dflags cmm
in case ty of
-- Make generic external label defenition and then pointer to it
Nothing ->