Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

cranelift: Allow call and call_indirect in runtests #4667

Merged
merged 22 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eb9da04
cranelift: Change test runner order
afonso360 Aug 8, 2022
26f320b
cranelift: Rename SingleFunctionCompiler to TestCaseCompiler
afonso360 Aug 8, 2022
e81127b
cranelift: Skip runtests per target instead of per run
afonso360 Aug 8, 2022
46e2c0d
cranelift: Deduplicate test names
afonso360 Aug 9, 2022
75518d5
cranelift: Add TestFileCompiler to runtests
afonso360 Aug 9, 2022
8fc50c0
cranelift: Deduplicate ExtName for avg_round tests
afonso360 Aug 16, 2022
62bd895
cranelift: Rename functions as they are defined.
afonso360 Aug 16, 2022
2654e31
cranelift: Preserve original name when reporting errors.
afonso360 Aug 16, 2022
88771d7
cranelift: Rename aarch64 test functions
afonso360 Aug 17, 2022
98c1452
cranelift: Add `call` and `call_indirect` tests!
afonso360 Aug 17, 2022
fb04e83
cranelift: Add pauth runtests for aarch64
afonso360 Aug 17, 2022
644de9f
cranelift: Rename duplicate s390x tests
afonso360 Aug 17, 2022
3c18bf8
cranelift: Delete `i128_bricmp_of` function from i128-bricmp
afonso360 Aug 17, 2022
4562dd4
cranelift: Add `colocated` call tests
afonso360 Aug 17, 2022
314a058
cranelift: Rename *more* `s390x` tests
afonso360 Aug 17, 2022
8fb1ca3
cranelift: Add pauth + sign_return_address call tests
afonso360 Aug 17, 2022
1364ad2
cranelift: Undeduplicate test names
afonso360 Aug 24, 2022
1eb3ac8
cranelift: Add LibCall tests
afonso360 Aug 24, 2022
628d00c
cranelift: Revert more test names
afonso360 Aug 24, 2022
ceccde2
cranelift: Disable libcall tests for aarch64
afonso360 Aug 24, 2022
ad7f62d
cranelift: Runtest fibonacci tests
afonso360 Aug 25, 2022
dcd55cc
cranelift: Misc cleanup
afonso360 Aug 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cranelift/codegen/src/ir/extname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::function::FunctionParameters;
/// This is used both for naming a function (for debugging purposes) and for declaring external
/// functions. In the latter case, this becomes an `ExternalName`, which gets embedded in
/// relocations later, etc.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub enum UserFuncName {
/// A user-defined name, with semantics left to the user.
Expand All @@ -39,7 +39,7 @@ impl UserFuncName {

/// Create a new external name from a user-defined external function reference.
pub fn user(namespace: u32, index: u32) -> Self {
Self::User(UserExternalName { namespace, index })
Self::User(UserExternalName::new(namespace, index))
}
}

Expand Down Expand Up @@ -70,6 +70,13 @@ pub struct UserExternalName {
pub index: u32,
}

impl UserExternalName {
/// Creates a new [UserExternalName].
pub fn new(namespace: u32, index: u32) -> Self {
Self { namespace, index }
}
}

impl fmt::Display for UserExternalName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "u{}:{}", self.namespace, self.index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 68 additions & 0 deletions cranelift/filetests/filetests/runtests/call.clif
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
test run
target x86_64
target aarch64
target aarch64 sign_return_address
afonso360 marked this conversation as resolved.
Show resolved Hide resolved
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 changes: 36 additions & 0 deletions cranelift/filetests/filetests/runtests/call_indirect.clif
Original file line number Diff line number Diff line change
@@ -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 changes: 26 additions & 0 deletions cranelift/filetests/filetests/runtests/call_libcall.clif
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions cranelift/filetests/filetests/runtests/fibonacci.clif
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
14 changes: 0 additions & 14 deletions cranelift/filetests/filetests/runtests/i128-bricmp.clif
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
cfallin marked this conversation as resolved.
Show resolved Hide resolved
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 changes: 23 additions & 0 deletions cranelift/filetests/filetests/runtests/i128-call.clif
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 10 additions & 14 deletions cranelift/filetests/filetests/runtests/simd-vselect.clif
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@ 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]
v3 = vconst.i32x4 [200 201 202 203]
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:
Expand Down Expand Up @@ -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]
Loading