Skip to content

Commit

Permalink
winch(x64): Derive the operand size for masm.zero (#9292)
Browse files Browse the repository at this point in the history
This commit derives the operand size from `ABI::word_bytes()` in order
to zero the given register rather than hardcoding it as a 32-bit size
operand.

The motivation for this commit is mainly avoiding hardcoding operand
sizes in Winch's emission layer where possible, especially in the
MacroAssembler.
  • Loading branch information
saulecabrera committed Sep 20, 2024
1 parent e51a68e commit bd29809
Show file tree
Hide file tree
Showing 38 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/br_if/as_local_set_value.wat
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
;; movq %rsi, 0x10(%rsp)
;; movl %edx, 0xc(%rsp)
;; movl $0, 8(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movl 0xc(%rsp), %ecx
;; movl $0x11, %eax
;; testl %ecx, %ecx
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_add/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x30(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_copysign/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x50(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_div/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x30(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_eq/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x40(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_ge/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x40(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_gt/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x40(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_le/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x38(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_le/params.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x38(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_lt/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x38(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_max/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x58(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_min/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x58(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_mul/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x30(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_ne/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x40(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/f64_sub/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movsd 0x30(%rip), %xmm0
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_add/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $0xa, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_and/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_eq/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_ge_s/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_ge_u/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_gt_s/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_gt_u/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_le_s/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_le_u/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_lt_s/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_lt_u/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_mul/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $0xa, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_ne/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_or/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_rotl/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $1, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_rotr/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $1, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_shl/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $1, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_shr_s/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $1, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_shr_u/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $1, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_sub/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $0xa, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/i64_xor/locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;; subq $0x20, %rsp
;; movq %rdi, 0x18(%rsp)
;; movq %rsi, 0x10(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 8(%rsp)
;; movq %r11, (%rsp)
;; movq $2, %rax
Expand Down
2 changes: 1 addition & 1 deletion tests/disas/winch/x64/loop/for.wat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; movq %rdi, 0x28(%rsp)
;; movq %rsi, 0x20(%rsp)
;; movq %rdx, 0x18(%rsp)
;; xorl %r11d, %r11d
;; xorq %r11, %r11
;; movq %r11, 0x10(%rsp)
;; movq %r11, 8(%rsp)
;; movq $1, %rax
Expand Down
3 changes: 2 additions & 1 deletion winch/codegen/src/isa/x64/masm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ impl Masm for MacroAssembler {
}

fn zero(&mut self, reg: Reg) {
self.asm.xor_rr(reg, reg, OperandSize::S32);
self.asm
.xor_rr(reg, reg, OperandSize::from_bytes(<Self::ABI>::word_bytes()));
}

fn mov(&mut self, src: RegImm, dst: Reg, size: OperandSize) {
Expand Down

0 comments on commit bd29809

Please sign in to comment.