New working test groups: test_inline, test_int, test_int128

parent eb63e1e7
Pipeline #797 failed with stages
in 12 minutes and 13 seconds
......@@ -862,6 +862,7 @@ macro_rules! emit_test {
});
};
/*
emit_test! ((vm) (double_add double_add_test1 double_add_test1_v1 Double,Double,Double,FOEQ (double_add_sig, double(1f64), double(1f64), double(2f64))));
*/
......@@ -1180,6 +1181,77 @@ macro_rules! emit_test {
});
};
/*
emit_test! ((vm) (add_twice add_twice_test1 add_twice_test1_v1 Int,Int,Int,Int,EQ (add_twice_sig, int64(1u64), int64(1u64), int64(1u64), int64(3u64))));
*/
(($vm: expr) ($name: ident $test_name: ident $tester_name: ident $Arg1Type: ident,$Arg2Type: ident,$Arg3Type: ident,$Arg4Type: ident,$CMPType: ident ($test_sig: ident, $ty1: ident($in1: expr), $ty2: ident($in2: expr), $ty3: ident($in3: expr), $ty4: ident($out: expr)))) => {
typedef! (($vm) int1 = mu_int(1));
typedef! (($vm) int64t = mu_int(64));
constdef! (($vm) <int64t> int64_pass = Constant::Int(0));
constdef! (($vm) <int64t> int64_fail = Constant::Int(1));
constdef! (($vm) <$ty1> arg_0 = Constant::$Arg1Type($in1));
constdef! (($vm) <$ty2> arg_1 = Constant::$Arg2Type($in2));
constdef! (($vm) <$ty2> arg_2 = Constant::$Arg3Type($in3));
constdef! (($vm) <$ty3> arg_3 = Constant::$Arg3Type($out));
funcsig! (($vm) tester_sig = () -> ());
funcdecl! (($vm) <tester_sig> $test_name);
funcdef! (($vm) <tester_sig> $test_name VERSION $tester_name);
ssa! (($vm, $tester_name) <$ty1> a);
ssa! (($vm, $tester_name) <$ty2> b);
ssa! (($vm, $tester_name) <$ty3> c);
typedef! (($vm) type_funcref = mu_funcref($test_sig));
constdef! (($vm) <type_funcref> const_funcref = Constant::FuncRef($vm.id_of(stringify!($name))));
// blk_entry
consta! (($vm, $tester_name) arg_0_local = arg_0);
consta! (($vm, $tester_name) arg_1_local = arg_1);
consta! (($vm, $tester_name) arg_2_local = arg_2);
block! (($vm, $tester_name) blk_entry);
consta! (($vm, $tester_name) const_funcref_local = const_funcref);
ssa! (($vm, $tester_name) <$ty4> result);
inst! (($vm, $tester_name) blk_entry_call:
result = EXPRCALL (CallConvention::Mu, is_abort: false) const_funcref_local (arg_0_local, arg_1_local, arg_2_local)
);
consta! (($vm, $tester_name) arg_3_local = arg_3);
consta! (($vm, $tester_name) int64_pass_local = int64_pass);
consta! (($vm, $tester_name) int64_fail_local = int64_fail);
ssa! (($vm, $tester_name) <int1> cmp_res);
inst! (($vm, $tester_name) blk_entry_cmp:
cmp_res = CMPOP (CmpOp::$CMPType) result arg_3_local
);
ssa! (($vm, $tester_name) <int64t> blk_entry_ret);
inst! (($vm, $tester_name) blk_entry_inst_select:
blk_entry_ret = SELECT cmp_res int64_pass_local int64_fail_local
);
inst! (($vm, $tester_name) blk_entry_inst_ret:
SET_RETVAL blk_entry_ret
);
inst! (($vm, $tester_name) blk_entry_inst_exit:
THREADEXIT
);
define_block! (($vm, $tester_name) blk_entry(a, b) {
blk_entry_call,
blk_entry_cmp,
blk_entry_inst_select,
blk_entry_inst_ret,
blk_entry_inst_exit
});
define_func_ver! (($vm) $tester_name (entry: blk_entry) {
blk_entry
});
};
}
/*
......
......@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#![feature(i128_type)]
extern crate mu;
extern crate utils;
#[macro_use]
......
......@@ -22,17 +22,13 @@ use mu::vm::*;
use mu::testutil;
use mu::utils::LinkedHashMap;
use mu::compiler::*;
use mu::testutil::aot;
use std::sync::Arc;
#[test]
fn test_inline_add_simple() {
let lib = testutil::compile_fncs("add_trampoline", vec!["add_trampoline", "add"], &inline_add);
unsafe {
let inline_add : libloading::Symbol<unsafe extern fn(u64, u64) -> u64> = lib.get(b"add_trampoline").unwrap();
let inline_add_1_1 = inline_add(1, 1);
println!("add(1, 1) = {}", inline_add_1_1);
assert!(inline_add_1_1 == 2);
}
build_and_run_test!(add_trampoline AND add, add_trampoline_test1, inline_add);
}
fn inline_add() -> VM {
......@@ -64,7 +60,7 @@ fn inline_add() -> VM {
define_func_ver!((vm) add_v1 (entry: blk_entry) {blk_entry});
}
{
// {
// add_trampoline
typedef! ((vm) funcref_to_sig = mu_funcref(sig));
constdef! ((vm) <funcref_to_sig> funcref_add = Constant::FuncRef(add));
......@@ -89,22 +85,16 @@ fn inline_add() -> VM {
define_block! ((vm, add_trampoline_v1) tramp_blk_entry(tramp_x, tramp_y) {tramp_blk_call, tramp_blk_ret});
define_func_ver!((vm) add_trampoline_v1 (entry: tramp_blk_entry) {tramp_blk_entry});
}
// }
emit_test! ((vm) (add_trampoline add_trampoline_test1 add_trampoline_test1_v1 Int,Int,Int,EQ (sig, int64(1u64), int64(1u64), int64(2u64))));
vm
}
#[test]
fn test_inline_add_twice() {
let lib = testutil::compile_fncs("add_twice", vec!["add_twice", "add"], &inline_add_twice);
unsafe {
let add_twice : libloading::Symbol<unsafe extern fn(u64, u64, u64) -> u64> = lib.get(b"add_twice").unwrap();
let res = add_twice(1, 1, 1);
println!("add(1, 1, 1) = {}", res);
assert!(res == 3);
}
build_and_run_test!(add_twice AND add, add_twice_test1, inline_add_twice);
}
fn inline_add_twice() -> VM {
......@@ -136,7 +126,7 @@ fn inline_add_twice() -> VM {
define_func_ver!((vm) add_v1 (entry: blk_entry) {blk_entry});
}
{
// {
// add_twice
typedef! ((vm) funcref_to_sig = mu_funcref(sig));
constdef! ((vm) <funcref_to_sig> funcref_add = Constant::FuncRef(add));
......@@ -169,22 +159,16 @@ fn inline_add_twice() -> VM {
define_block! ((vm, add_twice_v1) blk_entry(x, y, z) {call, call2, ret});
define_func_ver!((vm) add_twice_v1 (entry: blk_entry) {blk_entry});
}
// }
emit_test! ((vm) (add_twice add_twice_test1 add_twice_test1_v1 Int,Int,Int,Int,EQ (add_twice_sig, int64(1u64), int64(1u64), int64(1u64), int64(3u64))));
vm
}
#[test]
fn test_inline_add_with_extra_norm_args() {
let lib = testutil::compile_fncs("inline_add_with_extra_norm_args", vec!["add_with_extra_norm_args", "add"], &inline_add_with_extra_norm_args);
unsafe {
let add_twice : libloading::Symbol<unsafe extern fn(u64, u64, u64) -> u64> = lib.get(b"add_with_extra_norm_args").unwrap();
let res = add_twice(1, 1, 1);
println!("add(1, 1, 1) = {}", res);
assert!(res == 103);
}
build_and_run_test!(add_with_extra_norm_args AND add, add_with_extra_norm_args_test1, inline_add_with_extra_norm_args);
}
fn inline_add_with_extra_norm_args() -> VM {
......@@ -216,7 +200,7 @@ fn inline_add_with_extra_norm_args() -> VM {
define_func_ver!((vm) add_v1 (entry: blk_entry) {blk_entry});
}
{
// {
// inline_add_with_extra_norm_args
typedef! ((vm) funcref_to_sig = mu_funcref(sig));
constdef! ((vm) <funcref_to_sig> funcref_add = Constant::FuncRef(add));
......@@ -284,7 +268,9 @@ fn inline_add_with_extra_norm_args() -> VM {
});
define_func_ver!((vm) add_with_extra_norm_args_v1 (entry: blk_entry) {blk_entry, blk_norm, blk_exn});
}
// }
emit_test! ((vm) (add_with_extra_norm_args add_with_extra_norm_args_test1 add_with_extra_norm_args_test1_v1 Int,Int,Int,Int,EQ (sig_add_with_extra_norm_args, int64(1u64), int64(1u64), int64(1u64), int64(103u64))));
vm
}
\ No newline at end of file
......@@ -24,21 +24,14 @@ use self::mu::utils::LinkedHashMap;
use mu::testutil;
use self::mu::compiler::*;
use self::mu::testutil::aot;
use std::sync::Arc;
#[test]
fn test_add_u8() {
let lib = testutil::compile_fnc("add_u8", &add_u8);
unsafe {
let add_u8 : libloading::Symbol<unsafe extern fn(u8, u8) -> u8> = lib.get(b"add_u8").unwrap();
let add_u8_1_1 = add_u8(1, 1);
println!("add_u8(1, 1) = {}", add_u8_1_1);
assert!(add_u8_1_1 == 2);
let add_u8_255_1 = add_u8(255u8, 1u8);
println!("add_u8(255, 1) = {}", add_u8_255_1);
assert!(add_u8_255_1 == 0);
}
build_and_run_test!(add_u8, add_u8_test1);
build_and_run_test!(add_u8, add_u8_test2);
}
fn add_u8() -> VM {
......@@ -74,21 +67,16 @@ fn add_u8() -> VM {
define_func_ver!((vm) add_u8_v1 (entry: blk_entry) {
blk_entry
});
emit_test! ((vm) (add_u8 add_u8_test1 add_u8_test1_v1 Int,Int,Int,EQ (add_u8_sig, u8(1u8 as u64), u8(1u8 as u64), u8(2u8 as u64))));
emit_test! ((vm) (add_u8 add_u8_test2 add_u8_test2_v1 Int,Int,Int,EQ (add_u8_sig, u8(255u8 as u64), u8(1u8 as u64), u8(0u8 as u64))));
vm
}
#[test]
fn test_truncate() {
let lib = testutil::compile_fnc("truncate", &truncate);
unsafe {
let truncate : libloading::Symbol<unsafe extern fn(u64) -> u8> = lib.get(b"truncate").unwrap();
let res = truncate(0xF01u64);
println!("truncate(0xF01) = {}", res);
assert!(res == 1);
}
build_and_run_test!(truncate, truncate_test1);
}
fn truncate() -> VM {
......@@ -125,21 +113,15 @@ fn truncate() -> VM {
});
define_func_ver! ((vm) truncate_v1 (entry: blk_entry) {blk_entry});
emit_test! ((vm) (truncate truncate_test1 truncate_test1_v1 Int,Int,EQ (sig, u64(0xF01u64), u64(1u64))));
vm
}
#[test]
fn test_sext() {
let lib = testutil::compile_fnc("sext", &sext);
unsafe {
let sext : libloading::Symbol<unsafe extern fn(i8) -> i64> = lib.get(b"sext").unwrap();
let res = sext(-1);
println!("truncate(-1) = {}", res);
assert!(res == -1);
}
build_and_run_test!(sext, sext_test1);
}
fn sext() -> VM {
......@@ -174,21 +156,15 @@ fn sext() -> VM {
define_func_ver!((vm) sext_v1 (entry: blk_entry) {
blk_entry
});
emit_test! ((vm) (sext sext_test1 sext_test1_v1 Int,Int,EQ (sext_sig, i8(-1i8 as u64), i64(-1i64 as u64))));
vm
}
#[test]
fn test_add_9f() {
let lib = testutil::compile_fnc("add_9f", &add_9f);
unsafe {
let add_9f : libloading::Symbol<unsafe extern fn(u64) -> u64> = lib.get(b"add_9f").unwrap();
let add_9f_1 = add_9f(1);
println!("add_9f(1) = {}", add_9f_1);
assert!(add_9f_1 == 0x1000000000);
}
build_and_run_test!(add_9f, add_9f_test1);
}
fn add_9f() -> VM {
......@@ -226,6 +202,8 @@ fn add_9f() -> VM {
define_func_ver!((vm) add_9f_v1(entry: blk_entry) {
blk_entry
});
emit_test! ((vm) (add_9f add_9f_test1 add_9f_test1_v1 Int,Int,EQ (add_9f_sig, u64(1u64), u64(0x1000000000u64))));
vm
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment