This PR switches the default backend on x86, for both the `cranelift-codegen` crate and for Wasmtime, to the new (`MachInst`-style, `VCode`-based) backend that has been under development and testing for some time now. The old backend is still available by default in builds with the `old-x86-backend` feature, or by requesting `BackendVariant::Legacy` from the appropriate APIs. As part of that switch, it adds some more runtime-configurable plumbing to the testing infrastructure so that tests can be run using the appropriate backend. `clif-util test` is now capable of parsing a backend selector option from filetests and instantiating the correct backend. CI has been updated so that the old x86 backend continues to run its tests, just as we used to run the new x64 backend separately. At some point, we will remove the old x86 backend entirely, once we are satisfied that the new backend has not caused any unforeseen issues and we do not need to revert.
134 lines
2.7 KiB
Plaintext
134 lines
2.7 KiB
Plaintext
; Test the custom legalizations.
|
|
test legalizer
|
|
target i686 legacy
|
|
target x86_64 legacy
|
|
|
|
; regex: V=v\d+
|
|
; regex: BB=block\d+
|
|
|
|
function %cond_trap(i32) {
|
|
block0(v1: i32):
|
|
trapz v1, user67
|
|
return
|
|
; check: block0(v1: i32
|
|
; nextln: $(f=$V) = ifcmp_imm v1, 0
|
|
; nextln: trapif eq $f, user67
|
|
; nextln: return
|
|
}
|
|
|
|
function %cond_trap2(i32) {
|
|
block0(v1: i32):
|
|
trapnz v1, int_ovf
|
|
return
|
|
; check: block0(v1: i32
|
|
; nextln: $(f=$V) = ifcmp_imm v1, 0
|
|
; nextln: trapif ne $f, int_ovf
|
|
; nextln: return
|
|
}
|
|
|
|
function %cond_trap_b1(i32) {
|
|
block0(v1: i32):
|
|
v2 = icmp_imm eq v1, 6
|
|
trapz v2, user7
|
|
return
|
|
; check: block0(v1: i32
|
|
; check: brnz v2, $(new=$BB)
|
|
; check: jump $(trap=$BB)
|
|
; check: $trap:
|
|
; nextln: trap user7
|
|
; check: $new:
|
|
; nextln: return
|
|
}
|
|
|
|
function %cond_trap2_b1(i32) {
|
|
block0(v1: i32):
|
|
v2 = icmp_imm eq v1, 6
|
|
trapnz v2, user9
|
|
return
|
|
; check: block0(v1: i32
|
|
; check: brz v2, $(new=$BB)
|
|
; check: jump $(trap=$BB)
|
|
; check: $trap:
|
|
; nextln: trap user9
|
|
; check: $new:
|
|
; nextln: return
|
|
}
|
|
|
|
function %f32const() -> f32 {
|
|
block0:
|
|
v1 = f32const 0x1.0p1
|
|
; check: $(tmp=$V) = iconst.i32
|
|
; check: v1 = bitcast.f32 $tmp
|
|
return v1
|
|
}
|
|
|
|
function %select_f64(f64, f64, i32) -> f64 {
|
|
block0(v0: f64, v1: f64, v2: i32):
|
|
v3 = select v2, v0, v1
|
|
; check: brnz v2, $(new=$BB)(v0)
|
|
; nextln: jump $new(v1)
|
|
; check: $new(v3: f64):
|
|
; nextln: return v3
|
|
return v3
|
|
}
|
|
|
|
function %f32_min(f32, f32) -> f32 {
|
|
block0(v0: f32, v1: f32):
|
|
v2 = fmin v0, v1
|
|
return v2
|
|
; check: $(vnat=$V) = x86_fmin.f32 v0, v1
|
|
; nextln: jump $(done=$BB)($vnat)
|
|
|
|
; check: $(uno=$BB):
|
|
; nextln: $(vuno=$V) = fadd.f32 v0, v1
|
|
; nextln: jump $(done=$BB)($vuno)
|
|
|
|
; check: $(ueq=$BB):
|
|
; check: $(veq=$V) = bor.f32 v0, v1
|
|
; nextln: jump $(done=$BB)($veq)
|
|
|
|
; check: $done(v2: f32):
|
|
; nextln: return v2
|
|
}
|
|
|
|
function %ineg_legalized_i8() {
|
|
block0:
|
|
v0 = iconst.i8 1
|
|
v1 = ineg v0
|
|
; check: v2 = iconst.i32 1
|
|
; nextln: v0 = ireduce.i8 v2
|
|
; nextln: v3 = iconst.i8 0
|
|
; nextln: v4 = uextend.i32 v3
|
|
; nextln: v5 = uextend.i32 v0
|
|
; nextln: v6 = isub v4, v5
|
|
; nextln: v1 = ireduce.i8 v6
|
|
|
|
return
|
|
}
|
|
|
|
function %ineg_legalized_i16() {
|
|
block0:
|
|
v0 = iconst.i16 1
|
|
v1 = ineg v0
|
|
; check: v2 = iconst.i32 1
|
|
; nextln: v0 = ireduce.i16 v2
|
|
; nextln: v3 = iconst.i16 0
|
|
; nextln: v4 = uextend.i32 v3
|
|
; nextln: v5 = uextend.i32 v0
|
|
; nextln: v6 = isub v4, v5
|
|
; nextln: v1 = ireduce.i16 v6
|
|
|
|
return
|
|
}
|
|
|
|
function %ineg_legalized_i32() {
|
|
block0:
|
|
v0 = iconst.i32 1
|
|
v1 = ineg v0
|
|
; check: v0 = iconst.i32 1
|
|
; nextln: v2 = iconst.i32 0
|
|
; nextln: v1 = isub v2, v0
|
|
|
|
return
|
|
}
|