diff options
author | John Ericson <git@JohnEricson.me> | 2019-06-03 23:47:10 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-01-07 00:11:31 -0500 |
commit | 06982b6cc886d65aa325475ddfb4ad38c69b2d96 (patch) | |
tree | a09811c44dd0e4fd774bc2de3fa10ea34f6409f4 /compiler/GHC/StgToCmm | |
parent | e981023eb1cfb2a0f6052763469252feee3e2d51 (diff) | |
download | haskell-06982b6cc886d65aa325475ddfb4ad38c69b2d96.tar.gz |
Make primops for `{Int,Word}32#`
Progress towards #19026.
The type was added before, but not its primops. We follow the
conventions in 36fcf9edee31513db2ddbf716ee0aa79766cbe69 and
2c959a1894311e59cd2fd469c1967491c1e488f3 for names and testing.
Along with the previous 8- and 16-bit primops, this will allow us to
avoid many conversions for 8-, 16-, and 32-bit sized numeric types.
Co-authored-by: Sylvain Henry <hsyl20@gmail.com>
Diffstat (limited to 'compiler/GHC/StgToCmm')
-rw-r--r-- | compiler/GHC/StgToCmm/Prim.hs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/compiler/GHC/StgToCmm/Prim.hs b/compiler/GHC/StgToCmm/Prim.hs index ef7b0feddc..afb495e9e7 100644 --- a/compiler/GHC/StgToCmm/Prim.hs +++ b/compiler/GHC/StgToCmm/Prim.hs @@ -1079,6 +1079,8 @@ emitPrimOp dflags primop = case primop of -- The rest just translate straightforwardly + Int32ToWord32Op -> \args -> opNop args + Word32ToInt32Op -> \args -> opNop args IntToWordOp -> \args -> opNop args WordToIntOp -> \args -> opNop args IntToAddrOp -> \args -> opNop args @@ -1269,11 +1271,47 @@ emitPrimOp dflags primop = case primop of Int32ToIntOp -> \args -> opTranslate args (MO_SS_Conv W32 (wordWidth platform)) IntToInt32Op -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W32) + Int32NegOp -> \args -> opTranslate args (MO_S_Neg W32) + Int32AddOp -> \args -> opTranslate args (MO_Add W32) + Int32SubOp -> \args -> opTranslate args (MO_Sub W32) + Int32MulOp -> \args -> opTranslate args (MO_Mul W32) + Int32QuotOp -> \args -> opTranslate args (MO_S_Quot W32) + Int32RemOp -> \args -> opTranslate args (MO_S_Rem W32) + + Int32SllOp -> \args -> opTranslate args (MO_Shl W32) + Int32SraOp -> \args -> opTranslate args (MO_S_Shr W32) + Int32SrlOp -> \args -> opTranslate args (MO_U_Shr W32) + + Int32EqOp -> \args -> opTranslate args (MO_Eq W32) + Int32GeOp -> \args -> opTranslate args (MO_S_Ge W32) + Int32GtOp -> \args -> opTranslate args (MO_S_Gt W32) + Int32LeOp -> \args -> opTranslate args (MO_S_Le W32) + Int32LtOp -> \args -> opTranslate args (MO_S_Lt W32) + Int32NeOp -> \args -> opTranslate args (MO_Ne W32) -- Word32# unsigned ops Word32ToWordOp -> \args -> opTranslate args (MO_UU_Conv W32 (wordWidth platform)) WordToWord32Op -> \args -> opTranslate args (MO_UU_Conv (wordWidth platform) W32) + Word32AddOp -> \args -> opTranslate args (MO_Add W32) + Word32SubOp -> \args -> opTranslate args (MO_Sub W32) + Word32MulOp -> \args -> opTranslate args (MO_Mul W32) + Word32QuotOp -> \args -> opTranslate args (MO_U_Quot W32) + Word32RemOp -> \args -> opTranslate args (MO_U_Rem W32) + + Word32AndOp -> \args -> opTranslate args (MO_And W32) + Word32OrOp -> \args -> opTranslate args (MO_Or W32) + Word32XorOp -> \args -> opTranslate args (MO_Xor W32) + Word32NotOp -> \args -> opTranslate args (MO_Not W32) + Word32SllOp -> \args -> opTranslate args (MO_Shl W32) + Word32SrlOp -> \args -> opTranslate args (MO_U_Shr W32) + + Word32EqOp -> \args -> opTranslate args (MO_Eq W32) + Word32GeOp -> \args -> opTranslate args (MO_U_Ge W32) + Word32GtOp -> \args -> opTranslate args (MO_U_Gt W32) + Word32LeOp -> \args -> opTranslate args (MO_U_Le W32) + Word32LtOp -> \args -> opTranslate args (MO_U_Lt W32) + Word32NeOp -> \args -> opTranslate args (MO_Ne W32) -- Char# ops @@ -1380,6 +1418,11 @@ emitPrimOp dflags primop = case primop of then Left (MO_S_QuotRem W16) else Right (genericIntQuotRemOp W16) + Int32QuotRemOp -> \args -> opCallishHandledLater args $ + if ncg && (x86ish || ppc) && not (quotRemCanBeOptimized args) + then Left (MO_S_QuotRem W32) + else Right (genericIntQuotRemOp W32) + WordQuotRemOp -> \args -> opCallishHandledLater args $ if ncg && (x86ish || ppc) && not (quotRemCanBeOptimized args) then Left (MO_U_QuotRem (wordWidth platform)) @@ -1400,6 +1443,11 @@ emitPrimOp dflags primop = case primop of then Left (MO_U_QuotRem W16) else Right (genericWordQuotRemOp W16) + Word32QuotRemOp -> \args -> opCallishHandledLater args $ + if ncg && (x86ish || ppc) && not (quotRemCanBeOptimized args) + then Left (MO_U_QuotRem W32) + else Right (genericWordQuotRemOp W32) + WordAdd2Op -> \args -> opCallishHandledLater args $ if (ncg && (x86ish || ppc)) || llvm then Left (MO_Add2 (wordWidth platform)) |