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

Extra test & IR validation

parent 50f25766
...@@ -22,8 +22,8 @@ use utils::bit_utils::bits_ones; ...@@ -22,8 +22,8 @@ use utils::bit_utils::bits_ones;
use std; use std;
macro_rules! assert_ir { macro_rules! assert_ir {
($ cond : expr ) => { debug_assert!($cond) }; ($ cond : expr ) => { assert!($cond) };
($ cond : expr , $ ( $ arg : tt ) + ) => { debug_assert!($cond, $($arg)+)}; ($ cond : expr , $ ( $ arg : tt ) + ) => { assert!($cond, $($arg)+)};
} }
pub struct MuIRBuilder { pub struct MuIRBuilder {
...@@ -1283,7 +1283,8 @@ struct BundleLoader<'lb, 'lvm> { ...@@ -1283,7 +1283,8 @@ struct BundleLoader<'lb, 'lvm> {
built_uptr_of: IdPMap<MuType>, built_uptr_of: IdPMap<MuType>,
built_constint_of: HashMap<u64, P<Value>>, built_constint_of: HashMap<u64, P<Value>>,
current_sig: Option<P<MuFuncSig>> current_sig: Option<P<MuFuncSig>>,
current_entry: MuID,
} }
fn load_bundle(b: &mut MuIRBuilder) { fn load_bundle(b: &mut MuIRBuilder) {
...@@ -1322,7 +1323,8 @@ fn load_bundle(b: &mut MuIRBuilder) { ...@@ -1322,7 +1323,8 @@ fn load_bundle(b: &mut MuIRBuilder) {
built_iref_of: Default::default(), built_iref_of: Default::default(),
built_uptr_of: Default::default(), built_uptr_of: Default::default(),
built_constint_of: Default::default(), built_constint_of: Default::default(),
current_sig: Default::default() current_sig: Default::default(),
current_entry: Default::default(),
}; };
bl.load_bundle(); bl.load_bundle();
...@@ -2258,6 +2260,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> { ...@@ -2258,6 +2260,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let mut fcb: FuncCtxBuilder = Default::default(); let mut fcb: FuncCtxBuilder = Default::default();
let entry_id = *fv.bbs.first().unwrap(); let entry_id = *fv.bbs.first().unwrap();
self.current_entry = entry_id;
let mut blocks = fv.bbs let mut blocks = fv.bbs
.iter() .iter()
.map(|bbid| { .map(|bbid| {
...@@ -3581,12 +3584,10 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> { ...@@ -3581,12 +3584,10 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
inst_result_ids: &[MuID], inst_result_ids: &[MuID],
blocks: &LinkedHashMap<MuID, Block> blocks: &LinkedHashMap<MuID, Block>
) -> Destination { ) -> Destination {
// Note: according to the mu spec you can't branch to the entry block
// but we allow that here anyway
let dest_clause = self.b.bundle.dest_clauses.get(&id).unwrap(); let dest_clause = self.b.bundle.dest_clauses.get(&id).unwrap();
let target = dest_clause.dest; let target = dest_clause.dest;
assert_ir!(target != self.current_entry);
let target_block = blocks[&target].content.as_ref().unwrap(); let target_block = blocks[&target].content.as_ref().unwrap();
assert_ir!(target_block.args.len() == dest_clause.vars.len()); assert_ir!(target_block.args.len() == dest_clause.vars.len());
......
...@@ -320,7 +320,6 @@ def test_newthread_threadlocal(): ...@@ -320,7 +320,6 @@ def test_newthread_threadlocal():
.funcdef test_newthread_threadlocal <main_sig> .funcdef test_newthread_threadlocal <main_sig>
{ {
entry(<int<32>>argc <uptr<uptr<char>>>argv): entry(<int<32>>argc <uptr<uptr<char>>>argv):
cs = COMMINST uvm.current_stack()
s = COMMINST uvm.new_stack<[()->()]>(test_newthread_threadlocal_thread) s = COMMINST uvm.new_stack<[()->()]>(test_newthread_threadlocal_thread)
tr = NEW <int<32>> tr = NEW <int<32>>
...@@ -362,4 +361,35 @@ def test_newthread_stack_args(): ...@@ -362,4 +361,35 @@ def test_newthread_stack_args():
COMMINST uvm.thread_exit() COMMINST uvm.thread_exit()
} }
""", "test_newthread_stack_args"); """, "test_newthread_stack_args");
assert(execute("test_newthread_stack_args", []) == 45); assert(execute("test_newthread_stack_args", []) == 45);
\ No newline at end of file
def test_swapstack_threadlocal():
compile_bundle(
"""
.funcdef test_swapstack_threadlocal_stack <(stackref)->()>
{
entry(<stackref>s):
tr = NEW <int<32>>
tri = GETIREF <int<32>> tr
STORE <int<32>> tri <int<32>> 3
tl = REFCAST <ref<int<32>> ref<void>> tr
t = NEWTHREAD s THREADLOCAL (tl) PASS_VALUES<>()
COMMINST uvm.thread_exit()
}
.funcdef test_swapstack_threadlocal <main_sig>
{
entry(<int<32>>argc <uptr<uptr<char>>>argv):
cs = COMMINST uvm.current_stack()
s = COMMINST uvm.new_stack<[()->()]>(test_swapstack_threadlocal_stack)
r = SWAPSTACK s RET_WITH<> PASS_VALUES<stackref>(cs)
tv = COMMINST uvm.get_threadlocal()
tr = REFCAST <ref<void> ref<int<32>>> tv
tvi = GETIREF <int<32>> tr
tv = LOAD <int<32>> tvi
RET (tv)
}
""", "test_swapstack_threadlocal");
assert(execute("test_swapstack_threadlocal", []) == 3);
\ No newline at end of file
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