Commit dc957fb5 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Added tagref64 tests and update ci script

parent 62635f6d
......@@ -30,12 +30,6 @@ stages:
- build
- test
build_vm:
stage: build
script:
- rustc --version
- time CARGO_HOME=.cargo RUST_BACKTRACE=1 CC=clang cargo build --release
build_test:
stage: build
script:
......@@ -56,22 +50,22 @@ before_script:
test:cargo:api:
stage: test
script:
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --release test_api 2> /dev/null
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 ./test-release --release test_api 2> /dev/null
test:cargo:ir:
stage: test
script:
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --release test_ir 2> /dev/null
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 ./test-release --release test_ir 2> /dev/null
test:cargo:compiler:
stage: test
script:
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --release test_compiler 2> /dev/null
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 ./test-release --release test_compiler 2> /dev/null
test:cargo:runtime:
stage: test
script:
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --release test_runtime 2> /dev/null
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 ./test-release test_runtime 2> /dev/null
testjit:milestones:
stage: test
......@@ -136,10 +130,5 @@ testjit:som:
- if [ -d "tests/test_jit/RPySOM" ]; then rm -Rf tests/test_jit/RPySOM; fi
- git clone https://github.com/microvm/RPySOM.git tests/test_jit/RPySOM
- cd tests/test_jit/RPySOM; git submodule init; git submodule update; cd $CI_PROJECT_DIR
- if [ -d "tests/test_jit/mu-client-pypy" ]; then rm -Rf tests/test_jit/mu-client-pypy; fi
- git clone https://gitlab.anu.edu.au/mu/mu-client-pypy.git tests/test_jit/mu-client-pypy
- cd tests/test_jit/mu-client-pypy
- git checkout mu-rewrite
- git apply pypy.patch
- cd $CI_PROJECT_DIR/tests/test_jit
- MU_LOG_LEVEL=info LD_LIBRARY_PATH=. RUST_BACKTRACE=1 PYTHONPATH=mu-client-pypy:RPySOM/src RPYSOM=RPySOM pytest test_som.py -v
\ No newline at end of file
......@@ -1239,23 +1239,23 @@ impl <'a> InstructionSelection {
let tmp_res = self.get_result_value(node, 0);
let tmp_op = self.emit_ireg(op, f_content, f_context, vm);
let tmp1 = cast_value(&tmp_res, &UINT64_TYPE);
let tmp_res_r64 = cast_value(&tmp_res, &UINT64_TYPE);
let tmp1 = make_temporary(f_context, UINT64_TYPE.clone(), vm);
let tmp2 = make_temporary(f_context, UINT64_TYPE.clone(), vm);
let tmp3 = make_temporary(f_context, UINT64_TYPE.clone(), vm);
//res = (op & 0x7ff0000000000003 != 0x7ff0000000000002) & ((!op & 0x7ff0000000000001) != 0)
emit_mov_u64(self.backend.as_mut(), &tmp1, 0x7ff0000000000001);
self.backend.emit_add_imm(&tmp2, &tmp1, 2, false);
self.backend.emit_add_imm(&tmp3, &tmp1, 1, false);
self.backend.emit_and(&tmp2, &tmp_op, &tmp2);
self.backend.emit_cmp(&tmp2, &tmp3);
self.backend.emit_cset(&tmp2, "NE");
emit_mov_u64(self.backend.as_mut(), &tmp_res_r64, 0x7ff0000000000001);
self.backend.emit_add_imm(&tmp1, &tmp_res_r64, 2, false);
self.backend.emit_add_imm(&tmp2, &tmp_res_r64, 1, false);
self.backend.emit_and(&tmp1, &tmp_op, &tmp1);
self.backend.emit_bics(&XZR, &tmp1, &tmp_op);
self.backend.emit_cmp(&tmp1, &tmp2);
self.backend.emit_cset(&tmp1, "NE");
self.backend.emit_and(&tmp_res, &tmp2, &tmp1);
self.backend.emit_bics(&XZR, &tmp_res_r64, &tmp_op);
self.backend.emit_cset(&tmp_res_r64, "NE");
self.backend.emit_and(&tmp_res_r64, &tmp1, &tmp_res_r64);
},
Instruction_::CommonInst_Tr64FromFp(index) => {
......@@ -1276,16 +1276,17 @@ impl <'a> InstructionSelection {
});
} else {
let tmp_op = self.emit_fpreg(op, f_content, f_context, vm);
let tmp1 = make_temporary(f_context, UINT64_TYPE.clone(), vm);
// isNaN(op) ? (op & 0xfff8000000000000) | 0x0000000000000008 : op
self.backend.emit_fmov(&tmp_res, &tmp_op);
self.backend.emit_and_imm(&tmp_res, &tmp_res, 0xfff8000000000000);
self.backend.emit_orr_imm(&tmp_res, &tmp_res, 0x0000000000000008);
self.backend.emit_and_imm(&tmp1, &tmp_res, 0xfff8000000000000);
self.backend.emit_orr_imm(&tmp1, &tmp1, 0x0000000000000008);
// Sets V flag if tmp_op is unordered with tmp_op (i.e. it is a NaN)
self.backend.emit_fcmp(&tmp_op, &tmp_op);
// sets tmp_res to tmp2 if V is set
self.backend.emit_csel(&tmp_res, &tmp_res, &tmp_res, "VS");
// sets tmp_res to tmp1 if V is set
self.backend.emit_csel(&tmp_res, &tmp1, &tmp_res, "VS");
}
},
//(0x7ff0000000000001u64 | ((opnd & 0x7ffffffffffffu64) << 1) | ((opnd & 0x8000000000000u64) << 12))
......@@ -1296,13 +1297,15 @@ impl <'a> InstructionSelection {
if match_node_int_imm(op) {
let int_val: u64 = node_imm_to_u64(op);
emit_mov_u64(self.backend.as_mut(), &tmp_res,
0x7FF0000000000001 | (((int_val & 0x8000000000000000) << 12) | (int_val & 0x7ffffffffffffu64) << 1));
0x7FF0000000000001 | (((int_val & 0x8000000000000) << 12) |
(int_val & 0x7ffffffffffffu64) << 1));
} else {
let tmp_op = self.emit_fpreg(op, f_content, f_context, vm);
let tmp = make_temporary(f_context, UINT64_TYPE.clone(), vm);
// res = 0x7FF0000000000001 | (((op & 0x8000000000000000) << 12) | (opnd & 0x7ffffffffffffu64) << 1)
// res = 0x7FF0000000000001 | (((op & 0x8000000000000000) << 12)
// | (opnd & 0x7ffffffffffffu64) << 1)
self.backend.emit_and_imm(&tmp_res, &tmp_res, 0x8000000000000);
self.backend.emit_lsl_imm(&tmp_res, &tmp_op, 12);
......@@ -1317,8 +1320,6 @@ impl <'a> InstructionSelection {
let ref op1 = ops[index1];
let ref op2 = ops[index2];
let tmp_res = self.get_result_value(node, 0);
if match_node_ref_imm(op1) && match_node_int_imm(op2) {
let tag: u64 = node_imm_to_u64(op2);
emit_mov_u64(self.backend.as_mut(), &tmp_res,
......@@ -1360,7 +1361,7 @@ impl <'a> InstructionSelection {
}
self.backend.emit_orr(&tmp_res, &tmp, &tmp_res);
emit_mov_u64(self.backend.as_mut(), &tmp, 0xFF0000000000002);
emit_mov_u64(self.backend.as_mut(), &tmp, 0x7ff0000000000002);
self.backend.emit_orr(&tmp_res, &tmp_res, &tmp);
}
},
......
......@@ -1388,8 +1388,8 @@ impl <'a> VM {
let opnd = value.v.as_tr64();
self.new_handle(APIHandle {
id: handle_id,
v : APIHandleValue::Int(
(((opnd & 0xffffffffffffeu64) >> 1) | ((opnd & 0x8000000000000000u64) >> 12)),
v : APIHandleValue::Int(((opnd & 0xffffffffffffeu64) >> 1) |
((opnd & 0x8000000000000000u64) >> 12),
52
)
})
......@@ -1402,10 +1402,9 @@ impl <'a> VM {
self.new_handle(APIHandle {
id: handle_id,
v : APIHandleValue::Ref(types::REF_VOID_TYPE.clone(),
unsafe { Address::from_usize(
((opnd & 0x7ffffffffff8u64) |
u64_asr((opnd & 0x8000000000000000u64), 16)) as usize
) })
unsafe { Address::from_usize(((opnd & 0x7ffffffffff8u64) |
u64_asr((opnd & 0x8000000000000000u64), 16)) as usize)
})
})
}
......@@ -1415,8 +1414,8 @@ impl <'a> VM {
let opnd = value.v.as_tr64();
self.new_handle(APIHandle {
id: handle_id,
v : APIHandleValue::Int(
(u64_asr((opnd & 0x000f800000000000u64), 46) | (u64_asr((opnd & 0x4), 2))),
v : APIHandleValue::Int(u64_asr((opnd & 0x000f800000000000u64), 46) |
(u64_asr((opnd & 0x4), 2)),
6
)
})
......@@ -1445,10 +1444,8 @@ impl <'a> VM {
let opnd = value.v.as_int();
self.new_handle(APIHandle {
id: handle_id,
v : APIHandleValue::TagRef64(
(0x7ff0000000000001u64 | ((opnd & 0x7ffffffffffffu64) << 1) |
((opnd & 0x8000000000000u64) << 12))
)
v : APIHandleValue::TagRef64(0x7ff0000000000001u64 | ((opnd & 0x7ffffffffffffu64) << 1)
| ((opnd & 0x8000000000000u64) << 12))
})
}
......@@ -1460,9 +1457,8 @@ impl <'a> VM {
let tag_ = tag.v.as_int();
self.new_handle (APIHandle {
id: handle_id,
v : APIHandleValue::TagRef64(
(0x7ff0000000000002u64 | (addr_ & 0x7ffffffffff8u64) | ((addr_ & 0x800000000000u64) << 16)
| ((tag_ & 0x3eu64) << 46) | ((tag_ & 0x1) << 2))
v : APIHandleValue::TagRef64(0x7ff0000000000002u64 | (addr_ & 0x7ffffffffff8u64) |
((addr_ & 0x800000000000u64) << 16) | ((tag_ & 0x3eu64) << 46) | ((tag_ & 0x1) << 2)
)
})
}
......
......@@ -12,24 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from util import execute_bundle, load_bundle, get_function;
from util import execute, compile_bundle, load_bundle, get_function;
import pytest;
import ctypes;
def test_argc():
assert(execute_bundle(
compile_bundle(
"""
.funcdef test_argc <main_sig>
{
entry(<int<32>>argc <uptr<uptr<char>>>argv):
RET argc
}
""",
"test_argc", ["2", "3", "4"]) == 4);
""", "test_argc");
assert(execute("test_argc", ["2", "3", "4"]) == 4);
@pytest.mark.xfail(reason = "1 bit division is not implemented on x86-64")
def test_int1():
assert(execute_bundle(
compile_bundle(
"""
.funcdef test_int <main_sig>
{
......@@ -41,7 +41,8 @@ def test_int1():
RET res
}
""",
"test_int") == 1);
"test_int")
assert(execute("test_int") == 1);
def test_add():
......@@ -54,13 +55,13 @@ def test_add():
RET res
}
""",
"test_add.so");
"test_add");
test_add = get_function(lib.test_add, [ctypes.c_int64, ctypes.c_int64], ctypes.c_int64);
assert(test_add(1, 2) == 3);
assert(test_add(-40, 60) == 20);
def test_except_stack_args():
assert(execute_bundle(
compile_bundle(
"""
.funcsig stack_sig = (int<64> int<64> int<64> int<64> int<64> int<64> int<64>)->()
.funcdef stack_args <stack_sig>
......@@ -78,4 +79,5 @@ def test_except_stack_args():
RET status
}
""",
"test_except_stack_args") == 1);
"test_except_stack_args");
assert(execute("test_except_stack_args") == 1);
This diff is collapsed.
......@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os, subprocess, ctypes;
import os, subprocess, ctypes, sys;
import struct;
muc = os.environ.get('MUC', 'muc'); #type: str
emit = os.environ.get('MU_EMIT_DIR', 'emit'); #type: str
libext = '.dylib' if sys.platform.startswith('darwin') else \
'.so' if sys.platform.startswith('linux') else sys.exit("Unsupported platform");
prelude = """
.funcsig exit_sig = (int<32>) -> ()
......@@ -41,6 +43,7 @@ def get_output_file(name): # type: (str) -> str
return os.path.join(emit, name);
def execute_muc(bundle, name, primordial=None): # type: (str, str, Optional[str]) -> None
sys.stderr.write(bundle);
muc_proc = subprocess.Popen([muc, "-r"]
+ (["-f", primordial] if primordial is not None else [])
+ ["/dev/stdin", get_output_file(name)],
......@@ -48,13 +51,15 @@ def execute_muc(bundle, name, primordial=None): # type: (str, str, Optional[str]
muc_proc.communicate(bundle); # Send the bundle to muc
assert (muc_proc.returncode == 0); # Check that muc worked
def execute_bundle(bundle, name, args = [], main = None): # type: (str, str, Optional[List[str]], Optional[str]) -> int
def compile_bundle(bundle, name, main = None): # type: (str, str, Optional[str]) -> None
execute_muc(prelude + bundle + make_primordial(main if main is not None else name), name, "primordial");
def execute(name, args = []): # type: (str, Optional[List[str]]) -> int
return subprocess.call([get_output_file(name)] + args);
def load_bundle(bundle, name): # type: (str, str) -> ctypes.CDLL
execute_muc(prelude + bundle, name);
return ctypes.CDLL(get_output_file(name));
execute_muc(prelude + bundle, name + libext);
return ctypes.CDLL(get_output_file(name + libext));
def get_function(func, argtypes, restype): # type: (ctypes._FuncPtr) -> (ctypes._FuncPtr)
func.argtypes = argtypes;
......
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