diff options
author | Cheng Shao <terrorjack@type.dance> | 2022-11-28 08:43:27 +0000 |
---|---|---|
committer | Cheng Shao <terrorjack@type.dance> | 2022-11-28 08:55:53 +0000 |
commit | 0eb1c3311aa01646fd19334f2541f96a701c1e20 (patch) | |
tree | 99be9f7cc17e6f58c5fb1f7a98f26d4c3979d0f9 | |
parent | 2da5c38a45fcfd9778d7d89d0946aa475ae96627 (diff) | |
download | haskell-0eb1c3311aa01646fd19334f2541f96a701c1e20.tar.gz |
Move hs_mulIntMayOflo cbits to ghc-prim
It's only used by wasm NCG at the moment, but ghc-prim is a more
reasonable place for hosting out-of-line primops. Also, we only need a
single version of hs_mulIntMayOflo.
-rw-r--r-- | compiler/GHC/CmmToAsm/Wasm/FromCmm.hs | 17 | ||||
-rw-r--r-- | libraries/ghc-prim/cbits/mulIntMayOflo.c | 3 | ||||
-rw-r--r-- | libraries/ghc-prim/ghc-prim.cabal | 1 | ||||
-rw-r--r-- | rts/rts.cabal.in | 1 | ||||
-rw-r--r-- | rts/wasm/Ops.c | 9 |
5 files changed, 10 insertions, 21 deletions
diff --git a/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs b/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs index 034a75aea2..d41b95feba 100644 --- a/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs +++ b/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs @@ -443,27 +443,22 @@ lower_MO_S_Shr lbl w0 [x, y] = case someWasmTypeFromCmmType (cmmBits w0) of lower_MO_S_Shr _ _ _ = panic "lower_MO_S_Shr: unreachable" -- | Lower a 'MO_MulMayOflo' operation. It's translated to a ccall to --- one of the @hs_mulIntMayOflo@ functions in rts/wasm/Ops.c, +-- @hs_mulIntMayOflo@ function in @ghc-prim/cbits/mulIntMayOflo@, -- otherwise it's quite non-trivial to implement as inline assembly. lower_MO_MulMayOflo :: - CLabel -> - Width -> - [CmmExpr] -> - WasmCodeGenM - w - (SomeWasmExpr w) + CLabel -> Width -> [CmmExpr] -> WasmCodeGenM w (SomeWasmExpr w) lower_MO_MulMayOflo lbl w0 [x, y] = case someWasmTypeFromCmmType ty_cmm of SomeWasmType ty -> do WasmExpr x_instr <- lower_CmmExpr_Typed lbl ty x WasmExpr y_instr <- lower_CmmExpr_Typed lbl ty y - onFuncSym f [ty_cmm, ty_cmm] [ty_cmm] + onFuncSym "hs_mulIntMayOflo" [ty_cmm, ty_cmm] [ty_cmm] pure $ SomeWasmExpr ty $ WasmExpr $ - x_instr `WasmConcat` y_instr `WasmConcat` WasmCCall f + x_instr + `WasmConcat` y_instr + `WasmConcat` WasmCCall "hs_mulIntMayOflo" where - f = fromString $ "hs_mulIntMayOflo" <> show (widthInBits w0) - ty_cmm = cmmBits w0 lower_MO_MulMayOflo _ _ _ = panic "lower_MO_MulMayOflo: unreachable" diff --git a/libraries/ghc-prim/cbits/mulIntMayOflo.c b/libraries/ghc-prim/cbits/mulIntMayOflo.c new file mode 100644 index 0000000000..afea8bf60b --- /dev/null +++ b/libraries/ghc-prim/cbits/mulIntMayOflo.c @@ -0,0 +1,3 @@ +#include "Rts.h" + +W_ hs_mulIntMayOflo(W_ a, W_ b) { return mulIntMayOflo(a, b); } diff --git a/libraries/ghc-prim/ghc-prim.cabal b/libraries/ghc-prim/ghc-prim.cabal index db1fc1453e..24b412e970 100644 --- a/libraries/ghc-prim/ghc-prim.cabal +++ b/libraries/ghc-prim/ghc-prim.cabal @@ -89,6 +89,7 @@ Library cbits/ctz.c cbits/debug.c cbits/longlong.c + cbits/mulIntMayOflo.c cbits/pdep.c cbits/pext.c cbits/popcnt.c diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in index 34da06a365..641502ff45 100644 --- a/rts/rts.cabal.in +++ b/rts/rts.cabal.in @@ -615,7 +615,6 @@ library asm-sources: wasm/Wasm.S c-sources: wasm/StgRun.c wasm/GetTime.c - wasm/Ops.c wasm/OSMem.c wasm/OSThreads.c posix/Select.c diff --git a/rts/wasm/Ops.c b/rts/wasm/Ops.c deleted file mode 100644 index 198c8e5ded..0000000000 --- a/rts/wasm/Ops.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "Stg.h" - -StgWord8 hs_mulIntMayOflo8(StgWord8 _0, StgWord8 _1) { return mulIntMayOflo(_0, _1); } - -StgWord16 hs_mulIntMayOflo16(StgWord16 _0, StgWord16 _1) { return mulIntMayOflo(_0, _1); } - -StgWord32 hs_mulIntMayOflo32(StgWord32 _0, StgWord32 _1) { return mulIntMayOflo(_0, _1); } - -StgWord64 hs_mulIntMayOflo64(StgWord64 _0, StgWord64 _1) { return mulIntMayOflo(_0, _1); } |