Skip to content

Commit 9d7677c

Browse files
authored
x64: Refactor x64_load helper (#12877)
It's mostly unused nowadays so whittle it down to exactly what's necessary, which is to say: * Loading 64-bits is "const propagated" to `x64_movq_rm` * The helper itself is now `x64_load_xmm` and returns a typed `Xmm` register which handles only XMM-related types.
1 parent 9661ca8 commit 9d7677c

2 files changed

Lines changed: 14 additions & 35 deletions

File tree

cranelift/codegen/src/isa/x64/inst.isle

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,33 +1355,14 @@
13551355

13561356
;;;; Helpers for Emitting Loads ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13571357

1358-
;; Load a value into a register.
1359-
(decl x64_load (Type SyntheticAmode ExtKind) Reg)
1360-
1361-
(rule 1 (x64_load (fits_in_32 ty) addr (ExtKind.SignExtend))
1362-
(x64_movsx (ext_mode (ty_bytes ty) 8)
1363-
addr))
1364-
1365-
(rule 2 (x64_load $I64 addr _ext_kind)
1366-
(x64_movq_rm addr))
1367-
1368-
(rule 2 (x64_load $F32 addr _ext_kind)
1369-
(x64_movss_load addr))
1370-
1371-
(rule 2 (x64_load $F64 addr _ext_kind)
1372-
(x64_movsd_load addr))
1373-
1374-
(rule 2 (x64_load $F128 addr _ext_kind)
1375-
(x64_movdqu_load addr))
1376-
1377-
(rule 2 (x64_load $F32X4 addr _ext_kind)
1378-
(x64_movups_load addr))
1379-
1380-
(rule 2 (x64_load $F64X2 addr _ext_kind)
1381-
(x64_movupd_load addr))
1382-
1383-
(rule 0 (x64_load (multi_lane _bits _lanes) addr _ext_kind)
1384-
(x64_movdqu_load addr))
1358+
;; Load a value into an XMM register.
1359+
(decl x64_load_xmm (Type SyntheticAmode) Xmm)
1360+
(rule 1 (x64_load_xmm $F32 addr) (x64_movss_load addr))
1361+
(rule 1 (x64_load_xmm $F64 addr) (x64_movsd_load addr))
1362+
(rule 1 (x64_load_xmm $F128 addr) (x64_movdqu_load addr))
1363+
(rule 1 (x64_load_xmm $F32X4 addr) (x64_movups_load addr))
1364+
(rule 1 (x64_load_xmm $F64X2 addr) (x64_movupd_load addr))
1365+
(rule 0 (x64_load_xmm (multi_lane _bits _lanes) addr) (x64_movdqu_load addr))
13851366

13861367
(decl x64_mov (SyntheticAmode) Reg)
13871368
(spec (x64_mov addr)
@@ -1521,7 +1502,7 @@
15211502
;; Load a constant into an XMM register.
15221503
(decl x64_xmm_load_const (Type VCodeConstant) Xmm)
15231504
(rule (x64_xmm_load_const ty const)
1524-
(x64_load ty (const_to_synthetic_amode const) (ExtKind.None)))
1505+
(x64_load_xmm ty (const_to_synthetic_amode const)))
15251506

15261507

15271508
;;;; Flag Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

cranelift/codegen/src/isa/x64/lower.isle

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@
623623
;; the mask below.
624624
(unmasked Xmm (x64_psllw src (mov_rmi_to_xmm masked_amt)))
625625
(mask_addr SyntheticAmode (ishl_i8x16_mask masked_amt))
626-
(mask Reg (x64_load $I8X16 mask_addr (ExtKind.None))))
626+
(mask Reg (x64_movdqu_load mask_addr)))
627627
(sse_and $I8X16 unmasked (RegMem.Reg mask))))
628628

629629
;; Get the address of the mask to use when fixing up the lanes that weren't
@@ -656,7 +656,7 @@
656656
(mem_flags_trusted))))
657657

658658
(rule (ishl_i8x16_mask (RegMemImm.Mem amt))
659-
(ishl_i8x16_mask (RegMemImm.Reg (x64_load $I64 amt (ExtKind.None)))))
659+
(ishl_i8x16_mask (RegMemImm.Reg (x64_movq_rm amt))))
660660

661661
;; 16x8, 32x4, and 64x2 shifts can each use a single instruction, once the shift amount is masked.
662662

@@ -762,7 +762,7 @@
762762
(mem_flags_trusted))))
763763

764764
(rule (ushr_i8x16_mask (RegMemImm.Mem amt))
765-
(ushr_i8x16_mask (RegMemImm.Reg (x64_load $I64 amt (ExtKind.None)))))
765+
(ushr_i8x16_mask (RegMemImm.Reg (x64_movq_rm amt))))
766766

767767
;; 16x8, 32x4, and 64x2 shifts can each use a single instruction, once the shift amount is masked.
768768

@@ -3624,9 +3624,7 @@
36243624
(x64_rsp))
36253625

36263626
(rule (lower (get_return_address _))
3627-
(x64_load $I64
3628-
(Amode.ImmReg 8 (x64_rbp) (mem_flags_trusted))
3629-
(ExtKind.None)))
3627+
(x64_movq_rm (Amode.ImmReg 8 (x64_rbp) (mem_flags_trusted))))
36303628

36313629
;; Rules for `jump` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
36323630

@@ -4355,7 +4353,7 @@
43554353
)
43564354
(x64_movlhps result a1)))
43574355
(rule (x64_round ty (RegMem.Mem addr) imm)
4358-
(x64_round ty (RegMem.Reg (x64_load ty addr (ExtKind.ZeroExtend))) imm))
4356+
(x64_round ty (RegMem.Reg (x64_load_xmm ty addr)) imm))
43594357

43604358
(decl round_libcall (Type RoundImm) LibCall)
43614359
(rule (round_libcall $F32 (RoundImm.RoundUp)) (LibCall.CeilF32))

0 commit comments

Comments
 (0)