cranelift: Allow call and call_indirect in runtests (#4667)
* cranelift: Change test runner order Changes the ordering of runtests to run per target and then per function. This change doesn't do a lot by itself, but helps future refactorings of runtests. * cranelift: Rename SingleFunctionCompiler to TestCaseCompiler * cranelift: Skip runtests per target instead of per run * cranelift: Deduplicate test names With the upcoming changes to the runtest infrastructure we require unique ExtNames for all tests. Note that for test names we have a 16 character limit on test names, and must be unique within those 16 characters. * cranelift: Add TestFileCompiler to runtests TestFileCompiler allows us to compile the entire file once, and then call the trampolines for each test. The previous code was compiling the function for each invocation of a test. * cranelift: Deduplicate ExtName for avg_round tests * cranelift: Rename functions as they are defined. The JIT internally only deals with User functions, and cannot link test name funcs. This also caches trampolines by signature. * cranelift: Preserve original name when reporting errors. * cranelift: Rename aarch64 test functions * cranelift: Add `call` and `call_indirect` tests! * cranelift: Add pauth runtests for aarch64 * cranelift: Rename duplicate s390x tests * cranelift: Delete `i128_bricmp_of` function from i128-bricmp It looks like we forgot to delete it when it was moved to `i128-bricmp-overflow`, and since it didn't have a run invocation it was never compiled. However, s390x does not support this, and panics when lowering. * cranelift: Add `colocated` call tests * cranelift: Rename *more* `s390x` tests * cranelift: Add pauth + sign_return_address call tests * cranelift: Undeduplicate test names With the latest main changes we now support *unlimited* length test names. This commit reverts: 52274676ff631c630f9879dd32e756566d3e700f 7989edc172493547cdf63e180bb58365e8a43a42 25c8a8395527d98976be6a34baa3b0b214776739 792e8cfa8f748077f9d80fe7ee5e958b7124e83b * cranelift: Add LibCall tests * cranelift: Revert more test names These weren't auto reverted by the previous revert. * cranelift: Disable libcall tests for aarch64 * cranelift: Runtest fibonacci tests * cranelift: Misc cleanup
This commit is contained in:
@@ -18,10 +18,10 @@ block0(v0: i32, v1: i64, v2: i16):
|
||||
v6 = load.i32 big v3
|
||||
return v6
|
||||
}
|
||||
; run: %atomic_rmw_add_little_i16(0x12345678, 0, 0x1111) == 0x23455678
|
||||
; run: %atomic_rmw_add_little_i16(0x12345678, 0, 0xffff) == 0x12335678
|
||||
; run: %atomic_rmw_add_little_i16(0x12345678, 2, 0x1111) == 0x12346789
|
||||
; run: %atomic_rmw_add_little_i16(0x12345678, 2, 0xffff) == 0x12345677
|
||||
; run: %atomic_rmw_add_big_i16(0x12345678, 0, 0x1111) == 0x23455678
|
||||
; run: %atomic_rmw_add_big_i16(0x12345678, 0, 0xffff) == 0x12335678
|
||||
; run: %atomic_rmw_add_big_i16(0x12345678, 2, 0x1111) == 0x12346789
|
||||
; run: %atomic_rmw_add_big_i16(0x12345678, 2, 0xffff) == 0x12345677
|
||||
|
||||
function %atomic_rmw_add_big_i8(i32, i64, i8) -> i32 {
|
||||
ss0 = explicit_slot 4
|
||||
|
||||
68
cranelift/filetests/filetests/runtests/call.clif
Normal file
68
cranelift/filetests/filetests/runtests/call.clif
Normal file
@@ -0,0 +1,68 @@
|
||||
test run
|
||||
target x86_64
|
||||
target aarch64
|
||||
target aarch64 sign_return_address
|
||||
target aarch64 has_pauth sign_return_address
|
||||
target s390x
|
||||
|
||||
|
||||
function %callee_i64(i64) -> i64 {
|
||||
block0(v0: i64):
|
||||
v1 = iadd_imm.i64 v0, 10
|
||||
return v1
|
||||
}
|
||||
|
||||
function %call_i64(i64) -> i64 {
|
||||
fn0 = %callee_i64(i64) -> i64
|
||||
|
||||
block0(v0: i64):
|
||||
v1 = call fn0(v0)
|
||||
return v1
|
||||
}
|
||||
; run: %call_i64(10) == 20
|
||||
|
||||
function %colocated_i64(i64) -> i64 {
|
||||
fn0 = colocated %callee_i64(i64) -> i64
|
||||
|
||||
block0(v0: i64):
|
||||
v1 = call fn0(v0)
|
||||
return v1
|
||||
}
|
||||
; run: %colocated_i64(10) == 20
|
||||
|
||||
|
||||
|
||||
|
||||
function %callee_f64(f64) -> f64 {
|
||||
block0(v0: f64):
|
||||
v1 = f64const 0x10.0
|
||||
v2 = fadd.f64 v0, v1
|
||||
return v2
|
||||
}
|
||||
|
||||
function %call_f64(f64) -> f64 {
|
||||
fn0 = %callee_f64(f64) -> f64
|
||||
|
||||
block0(v0: f64):
|
||||
v1 = call fn0(v0)
|
||||
return v1
|
||||
}
|
||||
; run: %call_f64(0x10.0) == 0x20.0
|
||||
|
||||
|
||||
|
||||
function %callee_b1(b1) -> b1 {
|
||||
block0(v0: b1):
|
||||
v1 = bnot.b1 v0
|
||||
return v1
|
||||
}
|
||||
|
||||
function %call_b1(b1) -> b1 {
|
||||
fn0 = %callee_b1(b1) -> b1
|
||||
|
||||
block0(v0: b1):
|
||||
v1 = call fn0(v0)
|
||||
return v1
|
||||
}
|
||||
; run: %call_b1(true) == false
|
||||
; run: %call_b1(false) == true
|
||||
36
cranelift/filetests/filetests/runtests/call_indirect.clif
Normal file
36
cranelift/filetests/filetests/runtests/call_indirect.clif
Normal file
@@ -0,0 +1,36 @@
|
||||
test run
|
||||
target x86_64
|
||||
target aarch64
|
||||
target aarch64 sign_return_address
|
||||
target aarch64 has_pauth sign_return_address
|
||||
target s390x
|
||||
|
||||
|
||||
function %callee_indirect(i64) -> i64 {
|
||||
block0(v0: i64):
|
||||
v1 = iadd_imm.i64 v0, 10
|
||||
return v1
|
||||
}
|
||||
|
||||
function %call_ind(i64) -> i64 {
|
||||
fn0 = %callee_indirect(i64) -> i64
|
||||
; sig0 = (i64) -> i64
|
||||
|
||||
block0(v0: i64):
|
||||
v1 = func_addr.i64 fn0
|
||||
v2 = call_indirect.i64 sig0, v1(v0)
|
||||
return v2
|
||||
}
|
||||
; run: %call_ind(10) == 20
|
||||
|
||||
|
||||
function %call_ind_colocated(i64) -> i64 {
|
||||
fn0 = colocated %callee_indirect(i64) -> i64
|
||||
; sig0 = (i64) -> i64
|
||||
|
||||
block0(v0: i64):
|
||||
v1 = func_addr.i64 fn0
|
||||
v2 = call_indirect.i64 sig0, v1(v0)
|
||||
return v2
|
||||
}
|
||||
; run: %call_ind_colocated(10) == 20
|
||||
26
cranelift/filetests/filetests/runtests/call_libcall.clif
Normal file
26
cranelift/filetests/filetests/runtests/call_libcall.clif
Normal file
@@ -0,0 +1,26 @@
|
||||
test run
|
||||
target x86_64
|
||||
; AArch64 Does not have these libcalls
|
||||
target s390x
|
||||
|
||||
|
||||
function %libcall_ceilf32(f32) -> f32 {
|
||||
fn0 = %CeilF32(f32) -> f32
|
||||
|
||||
block0(v0: f32):
|
||||
v1 = call fn0(v0)
|
||||
return v1
|
||||
}
|
||||
; run: %libcall_ceilf32(0x0.5) == 0x1.0
|
||||
|
||||
|
||||
function %libcall_indirect_ceilf32(f32) -> f32 {
|
||||
fn0 = %CeilF32(f32) -> f32
|
||||
; sig0 = (f32) -> f32
|
||||
|
||||
block0(v0: f32):
|
||||
v1 = func_addr.i64 fn0
|
||||
v2 = call_indirect.i64 sig0, v1(v0)
|
||||
return v2
|
||||
}
|
||||
; run: %libcall_indirect_ceilf32(0x0.5) == 0x1.0
|
||||
@@ -1,4 +1,10 @@
|
||||
test interpret
|
||||
test run
|
||||
target x86_64
|
||||
target aarch64
|
||||
target aarch64 sign_return_address
|
||||
target aarch64 has_pauth sign_return_address
|
||||
target s390x
|
||||
|
||||
; A non-recursive fibonacci implementation.
|
||||
function %fibonacci(i32) -> i32 {
|
||||
|
||||
@@ -232,17 +232,3 @@ block2:
|
||||
; run: %i128_bricmp_uge(0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFD, 0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF) == false
|
||||
; run: %i128_bricmp_uge(0xC0FFEEEE_C0FFEEEE_00000000_00000000, 0xDECAFFFF_DECAFFFF_00000000_00000000) == false
|
||||
; run: %i128_bricmp_uge(0xDECAFFFF_DECAFFFF_00000000_00000000, 0xC0FFEEEE_C0FFEEEE_00000000_00000000) == true
|
||||
|
||||
function %i128_bricmp_of(i128, i128) -> b1 {
|
||||
block0(v0: i128,v1: i128):
|
||||
br_icmp.i128 of v0, v1, block2
|
||||
jump block1
|
||||
|
||||
block1:
|
||||
v2 = bconst.b1 false
|
||||
return v2
|
||||
|
||||
block2:
|
||||
v3 = bconst.b1 true
|
||||
return v3
|
||||
}
|
||||
|
||||
23
cranelift/filetests/filetests/runtests/i128-call.clif
Normal file
23
cranelift/filetests/filetests/runtests/i128-call.clif
Normal file
@@ -0,0 +1,23 @@
|
||||
test run
|
||||
set enable_llvm_abi_extensions=true
|
||||
target x86_64
|
||||
target aarch64
|
||||
target aarch64 sign_return_address
|
||||
target aarch64 has_pauth sign_return_address
|
||||
target s390x
|
||||
|
||||
|
||||
function %callee_i128(i128) -> i128 {
|
||||
block0(v0: i128):
|
||||
v1 = iadd_imm.i128 v0, 10
|
||||
return v1
|
||||
}
|
||||
|
||||
function %call_i128(i128) -> i128 {
|
||||
fn0 = %callee_i128(i128) -> i128
|
||||
|
||||
block0(v0: i128):
|
||||
v1 = call fn0(v0)
|
||||
return v1
|
||||
}
|
||||
; run: %call_i128(10) == 20
|
||||
@@ -22,7 +22,7 @@ block0(v0: i8x16, v1: i8x16, v2: i8x16):
|
||||
; Remember that bitselect accepts: 1) the selector vector, 2) the "if true" vector, and 3) the "if false" vector.
|
||||
; run: %bitselect_i8x16([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255], [127 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42], [42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127]) == [42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42]
|
||||
|
||||
function %bitselect_i8x16() -> b1 {
|
||||
function %bitselect_i8x16_1() -> b1 {
|
||||
block0:
|
||||
v0 = vconst.i8x16 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255] ; the selector vector
|
||||
v1 = vconst.i8x16 [127 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42] ; for each 1-bit in v0 the bit of v1 is selected
|
||||
|
||||
@@ -25,7 +25,7 @@ block0:
|
||||
}
|
||||
; run: %vselect_i16x8() == [200 101 202 103 204 105 106 107]
|
||||
|
||||
function %vselect_i32x4() -> i32x4 {
|
||||
function %vselect_i32x4_const() -> i32x4 {
|
||||
block0:
|
||||
v1 = vconst.b32x4 [false true false true]
|
||||
v2 = vconst.i32x4 [100 101 102 103]
|
||||
@@ -33,7 +33,15 @@ block0:
|
||||
v4 = vselect v1, v2, v3
|
||||
return v4
|
||||
}
|
||||
; run: %vselect_i32x4() == [200 101 202 103]
|
||||
; run: %vselect_i32x4_const() == [200 101 202 103]
|
||||
|
||||
function %vselect_i32x4(b32x4, i32x4, i32x4) -> i32x4 {
|
||||
block0(v0: b32x4, v1: i32x4, v2: i32x4):
|
||||
v3 = vselect v0, v1, v2
|
||||
return v3
|
||||
}
|
||||
; Remember that vselect accepts: 1) the selector vector, 2) the "if true" vector, and 3) the "if false" vector.
|
||||
; run: %vselect_i32x4([true true false false], [1 2 -1 -1], [-1 -1 3 4]) == [1 2 3 4]
|
||||
|
||||
function %vselect_i64x2() -> i64x2 {
|
||||
block0:
|
||||
@@ -72,15 +80,3 @@ block0(v0: b64x2, v1: i64x2, v2: i64x2):
|
||||
return v3
|
||||
}
|
||||
; run: %vselect_p_i64x2([true false], [1 2], [100000000000 200000000000]) == [1 200000000000]
|
||||
|
||||
|
||||
function %vselect_i32x4(i32x4, i32x4) -> i32x4 {
|
||||
block0(v1: i32x4, v2: i32x4):
|
||||
; `make_trampoline` still does not know how to convert boolean vector types
|
||||
; so we load the value directly here.
|
||||
v0 = vconst.b32x4 [true true false false]
|
||||
v3 = vselect v0, v1, v2
|
||||
return v3
|
||||
}
|
||||
; Remember that vselect accepts: 1) the selector vector, 2) the "if true" vector, and 3) the "if false" vector.
|
||||
; run: %vselect_i32x4([1 2 -1 -1], [-1 -1 3 4]) == [1 2 3 4]
|
||||
|
||||
Reference in New Issue
Block a user