Skip to content

Commit

Permalink
asm: bless Cranelift file tests
Browse files Browse the repository at this point in the history
Using the new assembler's pretty-printing results in slightly different
disassembly of compiled CLIF. This is because the assembler matches a
certain configuration of `capstone`, causing the following obvious
differences:

- instructions with only two operands only print two operands; the
  original `MInst` instructions separate out the read-write operand into
  two separate operands (SSA-like)
- the original instructions have some space padding after the
  instruction mnemonic, those from the new assembler do not

This change uses the slightly new style as-is, but this is open for
debate; we can change the configuration of `capstone` that we fuzz
against. My only preferences would be to (1) retain some way to visually
distinguish the new assembler instructions in the disassembly
(temporarily, for debugging) and (2) eventually transition to
pretty-printing instructions in Intel-style (`rw, r`) instead of the
current (`r, rw`).
  • Loading branch information
abrown committed Jan 24, 2025
1 parent c27bb22 commit 557f153
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 141 deletions.
6 changes: 3 additions & 3 deletions cranelift/filetests/filetests/isa/x64/bmi2.clif
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ block0(v0: i32, v1: i32):
; pushq %rbp
; movq %rsp, %rbp
; block0:
; andl %esi, $31, %esi
; andl $0x1f, %esi
; bzhi %edi, %esi, %eax
; movq %rbp, %rsp
; popq %rbp
Expand Down Expand Up @@ -299,7 +299,7 @@ block0(v0: i64, v1: i64):
; pushq %rbp
; movq %rsp, %rbp
; block0:
; andq %rsi, $63, %rsi
; andq $0x3f, %rsi
; bzhi %rdi, %rsi, %rax
; movq %rbp, %rsp
; popq %rbp
Expand Down Expand Up @@ -330,7 +330,7 @@ block0(v0: i64, v1: i32):
; pushq %rbp
; movq %rsp, %rbp
; block0:
; andl %esi, $31, %esi
; andl $0x1f, %esi
; bzhi 20(%rdi), %esi, %eax
; movq %rbp, %rsp
; popq %rbp
Expand Down
8 changes: 4 additions & 4 deletions cranelift/filetests/filetests/isa/x64/cmp-mem-bug.clif
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ block0(v0: f64, v1: i64):
; ucomisd %xmm1, %xmm0
; setnp %dil
; setz %al
; andl %edi, %eax, %edi
; andb %al, %dil
; movzbq %dil, %rax
; ucomisd %xmm1, %xmm0
; movdqa %xmm0, %xmm2
Expand All @@ -77,13 +77,13 @@ block0(v0: f64, v1: i64):
; ucomisd %xmm1, %xmm0
; setnp %dil
; sete %al
; andl %eax, %edi
; andb %al, %dil
; movzbq %dil, %rax
; ucomisd %xmm1, %xmm0
; movdqa %xmm0, %xmm2
; jnp 0x2c
; jnp 0x2d
; movsd %xmm2, %xmm0
; je 0x36
; je 0x37
; movsd %xmm2, %xmm0
; movq %rbp, %rsp
; popq %rbp
Expand Down
102 changes: 51 additions & 51 deletions cranelift/filetests/filetests/isa/x64/i128.clif
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ block0(v0: i128, v1: i128):
; movq %rsp, %rbp
; block0:
; movq %rdi, %rax
; andq %rax, %rdx, %rax
; andq %rdx, %rax
; movq %rsi, %rdx
; andq %rdx, %rcx, %rdx
; andq %rcx, %rdx
; movq %rbp, %rsp
; popq %rbp
; ret
Expand Down Expand Up @@ -367,15 +367,15 @@ block0(v0: i128, v1: i128):
; cmpq %rdx, %rdi
; sbbq %rsi, %rcx, %rsi
; setnb %dil
; andl %eax, %r9d, %eax
; andl %r8d, %r11d, %r8d
; andl %r10d, %r14d, %r10d
; andl %r13d, %ebx, %r13d
; andl %r15d, %edi, %r15d
; andl %eax, %r8d, %eax
; andl %r10d, %r13d, %r10d
; andl %eax, %r10d, %eax
; andl %eax, %r15d, %eax
; andb %r9b, %al
; andb %r11b, %r8b
; andb %r14b, %r10b
; andb %bl, %r13b
; andb %dil, %r15b
; andb %r8b, %al
; andb %r13b, %r10b
; andb %r10b, %al
; andb %r15b, %al
; movq 0(%rsp), %rbx
; movq 8(%rsp), %r12
; movq 16(%rsp), %r13
Expand Down Expand Up @@ -440,15 +440,15 @@ block0(v0: i128, v1: i128):
; cmpq %rdx, %rdi
; sbbq %rcx, %rsi
; setae %dil
; andl %r9d, %eax
; andl %r11d, %r8d
; andl %r14d, %r10d
; andl %ebx, %r13d
; andl %edi, %r15d
; andl %r8d, %eax
; andl %r13d, %r10d
; andl %r10d, %eax
; andl %r15d, %eax
; andb %r9b, %al
; andb %r11b, %r8b
; andb %r14b, %r10b
; andb %bl, %r13b
; andb %dil, %r15b
; andb %r8b, %al
; andb %r13b, %r10b
; andb %r10b, %al
; andb %r15b, %al
; movq (%rsp), %rbx
; movq 8(%rsp), %r12
; movq 0x10(%rsp), %r13
Expand Down Expand Up @@ -757,38 +757,38 @@ block0(v0: i128):
; movq %rdi, %rax
; shrq $1, %rax, %rax
; movabsq $8608480567731124087, %r8
; andq %rax, %r8, %rax
; andq %r8, %rax
; subq %rdi, %rax, %rdi
; shrq $1, %rax, %rax
; andq %rax, %r8, %rax
; andq %r8, %rax
; subq %rdi, %rax, %rdi
; shrq $1, %rax, %rax
; andq %rax, %r8, %rax
; andq %r8, %rax
; subq %rdi, %rax, %rdi
; movq %rdi, %rax
; shrq $4, %rax, %rax
; addq %rax, %rdi, %rax
; movabsq $1085102592571150095, %rdi
; andq %rax, %rdi, %rax
; andq %rdi, %rax
; movabsq $72340172838076673, %rdx
; imulq %rax, %rdx, %rax
; shrq $56, %rax, %rax
; movq %rsi, %rdi
; shrq $1, %rdi, %rdi
; movabsq $8608480567731124087, %rcx
; andq %rdi, %rcx, %rdi
; andq %rcx, %rdi
; subq %rsi, %rdi, %rsi
; shrq $1, %rdi, %rdi
; andq %rdi, %rcx, %rdi
; andq %rcx, %rdi
; subq %rsi, %rdi, %rsi
; shrq $1, %rdi, %rdi
; andq %rdi, %rcx, %rdi
; andq %rcx, %rdi
; subq %rsi, %rdi, %rsi
; movq %rsi, %rdi
; shrq $4, %rdi, %rdi
; addq %rdi, %rsi, %rdi
; movabsq $1085102592571150095, %r10
; andq %rdi, %r10, %rdi
; andq %r10, %rdi
; movabsq $72340172838076673, %rcx
; imulq %rdi, %rcx, %rdi
; shrq $56, %rdi, %rdi
Expand Down Expand Up @@ -859,83 +859,83 @@ block0(v0: i128):
; block0:
; movabsq $6148914691236517205, %rcx
; movq %rsi, %rdx
; andq %rdx, %rcx, %rdx
; andq %rcx, %rdx
; shrq $1, %rsi, %rsi
; andq %rsi, %rcx, %rsi
; andq %rcx, %rsi
; shlq $1, %rdx, %rdx
; orq %rdx, %rsi, %rdx
; movabsq $3689348814741910323, %r9
; movq %rdx, %r10
; andq %r10, %r9, %r10
; andq %r9, %r10
; shrq $2, %rdx, %rdx
; andq %rdx, %r9, %rdx
; andq %r9, %rdx
; shlq $2, %r10, %r10
; orq %r10, %rdx, %r10
; movabsq $1085102592571150095, %rsi
; movq %r10, %rax
; andq %rax, %rsi, %rax
; andq %rsi, %rax
; shrq $4, %r10, %r10
; andq %r10, %rsi, %r10
; andq %rsi, %r10
; shlq $4, %rax, %rax
; orq %rax, %r10, %rax
; movabsq $71777214294589695, %rcx
; movq %rax, %rdx
; andq %rdx, %rcx, %rdx
; andq %rcx, %rdx
; shrq $8, %rax, %rax
; andq %rax, %rcx, %rax
; andq %rcx, %rax
; shlq $8, %rdx, %rdx
; orq %rdx, %rax, %rdx
; movabsq $281470681808895, %r10
; movq %rdx, %r9
; andq %r9, %r10, %r9
; andq %r10, %r9
; shrq $16, %rdx, %rdx
; andq %rdx, %r10, %rdx
; andq %r10, %rdx
; shlq $16, %r9, %r9
; orq %r9, %rdx, %r9
; movabsq $4294967295, %rsi
; movq %r9, %rax
; andq %rax, %rsi, %rax
; andq %rsi, %rax
; shrq $32, %r9, %r9
; shlq $32, %rax, %rax
; orq %rax, %r9, %rax
; movabsq $6148914691236517205, %rdx
; movq %rdi, %rcx
; andq %rcx, %rdx, %rcx
; andq %rdx, %rcx
; shrq $1, %rdi, %rdi
; andq %rdi, %rdx, %rdi
; andq %rdx, %rdi
; shlq $1, %rcx, %rcx
; orq %rcx, %rdi, %rcx
; movabsq $3689348814741910323, %rdx
; movq %rcx, %r8
; andq %r8, %rdx, %r8
; andq %rdx, %r8
; shrq $2, %rcx, %rcx
; andq %rcx, %rdx, %rcx
; andq %rdx, %rcx
; shlq $2, %r8, %r8
; orq %r8, %rcx, %r8
; movabsq $1085102592571150095, %r10
; movq %r8, %r11
; andq %r11, %r10, %r11
; andq %r10, %r11
; shrq $4, %r8, %r8
; andq %r8, %r10, %r8
; andq %r10, %r8
; shlq $4, %r11, %r11
; orq %r11, %r8, %r11
; movabsq $71777214294589695, %rdi
; movq %r11, %rcx
; andq %rcx, %rdi, %rcx
; andq %rdi, %rcx
; shrq $8, %r11, %r11
; andq %r11, %rdi, %r11
; andq %rdi, %r11
; shlq $8, %rcx, %rcx
; orq %rcx, %r11, %rcx
; movabsq $281470681808895, %rdx
; movq %rcx, %r8
; andq %r8, %rdx, %r8
; andq %rdx, %r8
; shrq $16, %rcx, %rcx
; andq %rcx, %rdx, %rcx
; andq %rdx, %rcx
; shlq $16, %r8, %r8
; orq %r8, %rcx, %r8
; movabsq $4294967295, %r10
; movq %r8, %rdx
; andq %rdx, %r10, %rdx
; andq %r10, %rdx
; shrq $32, %r8, %r8
; shlq $32, %rdx, %rdx
; orq %rdx, %r8, %rdx
Expand Down Expand Up @@ -1431,7 +1431,7 @@ block0(v0: i8, v1: i128):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $7, %rcx
; andq $7, %rcx
; movq %rdi, %rax
; shlb %cl, %al, %al
; movq %rbp, %rsp
Expand Down
2 changes: 1 addition & 1 deletion cranelift/filetests/filetests/isa/x64/immediates.clif
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ block0(v0: i64, v1: i64):
; subq %r11, const(0), %r11
; movq %r11, 0(%rsi)
; movq %rdi, %rax
; andq %rax, const(0), %rax
; andq (%rip), %rax
; movq %rax, 0(%rsi)
; orq %rdi, const(0), %rdi
; movq %rdi, 0(%rsi)
Expand Down
20 changes: 10 additions & 10 deletions cranelift/filetests/filetests/isa/x64/ishl.clif
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ block0(v0: i16, v1: i128):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $15, %rcx
; andq $0xf, %rcx
; movq %rdi, %rax
; shlw %cl, %ax, %ax
; movq %rbp, %rsp
Expand Down Expand Up @@ -391,7 +391,7 @@ block0(v0: i8, v1: i128):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $7, %rcx
; andq $7, %rcx
; movq %rdi, %rax
; shlb %cl, %al, %al
; movq %rbp, %rsp
Expand Down Expand Up @@ -654,7 +654,7 @@ block0(v0: i16, v1: i64):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $15, %rcx
; andq $0xf, %rcx
; movq %rdi, %rax
; shlw %cl, %ax, %ax
; movq %rbp, %rsp
Expand Down Expand Up @@ -685,7 +685,7 @@ block0(v0: i16, v1: i32):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $15, %rcx
; andq $0xf, %rcx
; movq %rdi, %rax
; shlw %cl, %ax, %ax
; movq %rbp, %rsp
Expand Down Expand Up @@ -716,7 +716,7 @@ block0(v0: i16, v1: i16):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $15, %rcx
; andq $0xf, %rcx
; movq %rdi, %rax
; shlw %cl, %ax, %ax
; movq %rbp, %rsp
Expand Down Expand Up @@ -747,7 +747,7 @@ block0(v0: i16, v1: i8):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $15, %rcx
; andq $0xf, %rcx
; movq %rdi, %rax
; shlw %cl, %ax, %ax
; movq %rbp, %rsp
Expand Down Expand Up @@ -778,7 +778,7 @@ block0(v0: i8, v1: i64):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $7, %rcx
; andq $7, %rcx
; movq %rdi, %rax
; shlb %cl, %al, %al
; movq %rbp, %rsp
Expand Down Expand Up @@ -809,7 +809,7 @@ block0(v0: i8, v1: i32):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $7, %rcx
; andq $7, %rcx
; movq %rdi, %rax
; shlb %cl, %al, %al
; movq %rbp, %rsp
Expand Down Expand Up @@ -840,7 +840,7 @@ block0(v0: i8, v1: i16):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $7, %rcx
; andq $7, %rcx
; movq %rdi, %rax
; shlb %cl, %al, %al
; movq %rbp, %rsp
Expand Down Expand Up @@ -871,7 +871,7 @@ block0(v0: i8, v1: i8):
; movq %rsp, %rbp
; block0:
; movq %rsi, %rcx
; andq %rcx, $7, %rcx
; andq $7, %rcx
; movq %rdi, %rax
; shlb %cl, %al, %al
; movq %rbp, %rsp
Expand Down
Loading

0 comments on commit 557f153

Please sign in to comment.