summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorMichal Terepeta <michal.terepeta@gmail.com>2015-07-04 12:52:02 +0200
committerBen Gamari <ben@smart-cactus.org>2015-07-04 12:52:03 +0200
commitb1d1c652908ecd7bfcf13cf2e5dd06ac7926992c (patch)
tree376136663cd16de698e4c957b2da6ffb11381985 /compiler/codeGen
parent69beef56a4c020d08e1b0243d4c1a629f972e019 (diff)
downloadhaskell-b1d1c652908ecd7bfcf13cf2e5dd06ac7926992c.tar.gz
Support MO_{Add,Sub}IntC and MO_Add2 in the LLVM backend
This includes: - Adding new LlvmType called LMStructP that represents an unpacked struct (this is necessary since LLVM's instructions the llvm.sadd.with.overflow.* return an unpacked struct). - Modifications to LlvmCodeGen.CodeGen to generate the LLVM instructions for the primops. - Modifications to StgCmmPrim to actually use those three instructions if we use the LLVM backend (so far they were only used for NCG). Test Plan: validate Reviewers: austin, rwbarton, bgamari Reviewed By: bgamari Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D991 GHC Trac Issues: #9430
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/StgCmmPrim.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index d812905594..563f6dcc4a 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -811,13 +811,16 @@ callishPrimOpSupported dflags op
WordQuotRem2Op | ncg && x86ish -> Left (MO_U_QuotRem2 (wordWidth dflags))
| otherwise -> Right (genericWordQuotRem2Op dflags)
- WordAdd2Op | ncg && x86ish -> Left (MO_Add2 (wordWidth dflags))
+ WordAdd2Op | (ncg && x86ish)
+ || llvm -> Left (MO_Add2 (wordWidth dflags))
| otherwise -> Right genericWordAdd2Op
- IntAddCOp | ncg && x86ish -> Left (MO_AddIntC (wordWidth dflags))
+ IntAddCOp | (ncg && x86ish)
+ || llvm -> Left (MO_AddIntC (wordWidth dflags))
| otherwise -> Right genericIntAddCOp
- IntSubCOp | ncg && x86ish -> Left (MO_SubIntC (wordWidth dflags))
+ IntSubCOp | (ncg && x86ish)
+ || llvm -> Left (MO_SubIntC (wordWidth dflags))
| otherwise -> Right genericIntSubCOp
WordMul2Op | ncg && x86ish -> Left (MO_U_Mul2 (wordWidth dflags))
@@ -828,7 +831,9 @@ callishPrimOpSupported dflags op
ncg = case hscTarget dflags of
HscAsm -> True
_ -> False
-
+ llvm = case hscTarget dflags of
+ HscLlvm -> True
+ _ -> False
x86ish = case platformArch (targetPlatform dflags) of
ArchX86 -> True
ArchX86_64 -> True