summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/CmmToAsm/Wasm/Asm.hs3
-rw-r--r--compiler/GHC/CmmToAsm/Wasm/FromCmm.hs25
-rw-r--r--compiler/GHC/CmmToAsm/Wasm/Types.hs3
3 files changed, 21 insertions, 10 deletions
diff --git a/compiler/GHC/CmmToAsm/Wasm/Asm.hs b/compiler/GHC/CmmToAsm/Wasm/Asm.hs
index 2cc08a58b3..7de170bbf0 100644
--- a/compiler/GHC/CmmToAsm/Wasm/Asm.hs
+++ b/compiler/GHC/CmmToAsm/Wasm/Asm.hs
@@ -308,9 +308,6 @@ asmTellWasmInstr ty_word instr = case instr of
WasmConvert Unsigned t0 t1 ->
asmTellLine $
asmFromWasmType t1 <> ".convert_" <> asmFromWasmType t0 <> "_u"
- WasmClz ty -> asmTellLine $ asmFromWasmType ty <> ".clz"
- WasmCtz ty -> asmTellLine $ asmFromWasmType ty <> ".ctz"
- WasmPopcnt ty -> asmTellLine $ asmFromWasmType ty <> ".popcnt"
WasmAdd ty -> asmTellLine $ asmFromWasmType ty <> ".add"
WasmSub ty -> asmTellLine $ asmFromWasmType ty <> ".sub"
WasmMul ty -> asmTellLine $ asmFromWasmType ty <> ".mul"
diff --git a/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs b/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
index d41b95feba..4e138ba263 100644
--- a/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
+++ b/compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
@@ -1238,8 +1238,13 @@ lower_CallishMachOp lbl (MO_Memcmp {}) rs xs =
CmmMayReturn
rs
xs
-lower_CallishMachOp lbl (MO_PopCnt {}) rs xs =
- lower_CMO_Un_Prim lbl WasmPopcnt rs xs
+lower_CallishMachOp lbl (MO_PopCnt w0) rs xs =
+ lower_CmmUnsafeForeignCall
+ lbl
+ (Left $ fromString $ "hs_popcnt" <> show (widthInBits w0))
+ CmmMayReturn
+ rs
+ xs
lower_CallishMachOp lbl (MO_Pdep w0) rs xs =
lower_CmmUnsafeForeignCall
lbl
@@ -1254,8 +1259,20 @@ lower_CallishMachOp lbl (MO_Pext w0) rs xs =
CmmMayReturn
rs
xs
-lower_CallishMachOp lbl (MO_Clz {}) rs xs = lower_CMO_Un_Prim lbl WasmClz rs xs
-lower_CallishMachOp lbl (MO_Ctz {}) rs xs = lower_CMO_Un_Prim lbl WasmCtz rs xs
+lower_CallishMachOp lbl (MO_Clz w0) rs xs =
+ lower_CmmUnsafeForeignCall
+ lbl
+ (Left $ fromString $ "hs_clz" <> show (widthInBits w0))
+ CmmMayReturn
+ rs
+ xs
+lower_CallishMachOp lbl (MO_Ctz w0) rs xs =
+ lower_CmmUnsafeForeignCall
+ lbl
+ (Left $ fromString $ "hs_ctz" <> show (widthInBits w0))
+ CmmMayReturn
+ rs
+ xs
lower_CallishMachOp lbl (MO_BSwap w0) rs xs =
lower_CmmUnsafeForeignCall
lbl
diff --git a/compiler/GHC/CmmToAsm/Wasm/Types.hs b/compiler/GHC/CmmToAsm/Wasm/Types.hs
index ab052dc353..06d2c246e6 100644
--- a/compiler/GHC/CmmToAsm/Wasm/Types.hs
+++ b/compiler/GHC/CmmToAsm/Wasm/Types.hs
@@ -279,9 +279,6 @@ data WasmInstr :: WasmType -> [WasmType] -> [WasmType] -> Type where
w
(t0 : pre)
(t1 : pre)
- WasmClz :: WasmTypeTag t -> WasmInstr w (t : pre) (t : pre)
- WasmCtz :: WasmTypeTag t -> WasmInstr w (t : pre) (t : pre)
- WasmPopcnt :: WasmTypeTag t -> WasmInstr w (t : pre) (t : pre)
WasmAdd :: WasmTypeTag t -> WasmInstr w (t : t : pre) (t : pre)
WasmSub :: WasmTypeTag t -> WasmInstr w (t : t : pre) (t : pre)
WasmMul :: WasmTypeTag t -> WasmInstr w (t : t : pre) (t : pre)