WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.2% of users enabled 2FA.

Commit b1bebecf authored by Kunshan Wang's avatar Kunshan Wang
Browse files

IRBuilder: Builds cmp, branch, branch2, ret.

parent 25aef1f5
......@@ -80,7 +80,7 @@ pub struct NodeExpFunc { pub id: MuID, pub func: MuFuncNode, pub callconv: usize
pub struct NodeFuncVer { pub id: MuID, pub func: MuFuncNode, pub bbs: Vec<MuBBNode> }
#[derive(Debug)]
pub struct NodeBB { pub id: MuID, pub norParamIDs: Vec<MuID>, pub norParamTys: Vec<MuTypeNode>, pub excParamID: Option<MuID>, pub insts: Vec<MuInstNode> }
pub struct NodeBB { pub id: MuID, pub nor_param_ids: Vec<MuID>, pub nor_param_types: Vec<MuTypeNode>, pub exc_param_id: Option<MuID>, pub insts: Vec<MuInstNode> }
#[derive(Debug)]
pub struct NodeDestClause { pub id: MuID, pub dest: MuBBNode, pub vars: Vec<MuVarNode> }
......@@ -102,41 +102,41 @@ pub struct NodeNscThrowExc { pub id: MuID, pub exc: MuVarNode }
#[derive(Debug)]
pub enum NodeInst {
NodeBinOp { id: MuID, resultID: MuID, statusResultIDs: Vec<MuID>, optr: MuBinOptr, flags: MuBinOpStatus, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode, excClause: Option<MuExcClause> },
NodeCmp { id: MuID, resultID: MuID, optr: MuCmpOptr, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode },
NodeConv { id: MuID, resultID: MuID, optr: MuConvOptr, fromTy: MuTypeNode, toTy: MuTypeNode, opnd: MuVarNode },
NodeSelect { id: MuID, resultID: MuID, condTy: MuTypeNode, opndTy: MuTypeNode, cond: MuVarNode, ifTrue: MuVarNode, ifFalse: MuVarNode },
NodeBinOp { id: MuID, result_id: MuID, status_result_ids: Vec<MuID>, optr: MuBinOptr, flags: MuBinOpStatus, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode, exc_clause: Option<MuExcClause> },
NodeCmp { id: MuID, result_id: MuID, optr: MuCmpOptr, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode },
NodeConv { id: MuID, result_id: MuID, optr: MuConvOptr, from_ty: MuTypeNode, to_ty: MuTypeNode, opnd: MuVarNode },
NodeSelect { id: MuID, result_id: MuID, cond_ty: MuTypeNode, opnd_ty: MuTypeNode, cond: MuVarNode, if_true: MuVarNode, if_false: MuVarNode },
NodeBranch { id: MuID, dest: MuDestClause },
NodeBranch2 { id: MuID, cond: MuVarNode, ifTrue: MuDestClause, ifFalse: MuDestClause },
NodeSwitch { id: MuID, opndTy: MuTypeNode, opnd: MuVarNode, defaultDest: MuDestClause, cases: Vec<MuConstNode>, dests: Vec<MuDestClause> },
NodeCall { id: MuID, resultIDs: Vec<MuID>, sig: MuFuncSigNode, callee: MuVarNode, args: Vec<MuVarNode>, excClause: Option<MuExcClause>, keepaliveClause: Option<MuKeepaliveClause> },
NodeBranch2 { id: MuID, cond: MuVarNode, if_true: MuDestClause, if_false: MuDestClause },
NodeSwitch { id: MuID, opnd_ty: MuTypeNode, opnd: MuVarNode, default_dest: MuDestClause, cases: Vec<MuConstNode>, dests: Vec<MuDestClause> },
NodeCall { id: MuID, result_ids: Vec<MuID>, sig: MuFuncSigNode, callee: MuVarNode, args: Vec<MuVarNode>, exc_clause: Option<MuExcClause>, keepalive_clause: Option<MuKeepaliveClause> },
NodeTailCall { id: MuID, sig: MuFuncSigNode, callee: MuVarNode, args: Vec<MuVarNode> },
NodeRet { id: MuID, rvs: Vec<MuVarNode> },
NodeThrow { id: MuID, exc: MuVarNode },
NodeExtractValue { id: MuID, resultID: MuID, strty: MuTypeNode, index: i32, opnd: MuVarNode },
NodeInsertValue { id: MuID, resultID: MuID, strty: MuTypeNode, index: i32, opnd: MuVarNode, newval: MuVarNode },
NodeExtractElement { id: MuID, resultID: MuID, seqty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode },
NodeInsertElement { id: MuID, resultID: MuID, seqty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode, newval: MuVarNode },
NodeShuffleVector { id: MuID, resultID: MuID, vecty: MuTypeNode, maskty: MuTypeNode, vec1: MuVarNode, vec2: MuVarNode, mask: MuVarNode },
NodeNew { id: MuID, resultID: MuID, allocty: MuTypeNode, excClause: Option<MuExcClause> },
NodeNewHybrid { id: MuID, resultID: MuID, allocty: MuTypeNode, lenty: MuTypeNode, length: MuVarNode, excClause: Option<MuExcClause> },
NodeAlloca { id: MuID, resultID: MuID, allocty: MuTypeNode, excClause: Option<MuExcClause> },
NodeAllocaHybrid { id: MuID, resultID: MuID, allocty: MuTypeNode, lenty: MuTypeNode, length: MuVarNode, excClause: Option<MuExcClause> },
NodeGetIRef { id: MuID, resultID: MuID, refty: MuTypeNode, opnd: MuVarNode },
NodeGetFieldIRef { id: MuID, resultID: MuID, isPtr: bool, refty: MuTypeNode, index: i32, opnd: MuVarNode },
NodeGetElemIRef { id: MuID, resultID: MuID, isPtr: bool, refty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode },
NodeShiftIRef { id: MuID, resultID: MuID, isPtr: bool, refty: MuTypeNode, offty: MuTypeNode, opnd: MuVarNode, offset: MuVarNode },
NodeGetVarPartIRef { id: MuID, resultID: MuID, isPtr: bool, refty: MuTypeNode, opnd: MuVarNode },
NodeLoad { id: MuID, resultID: MuID, isPtr: bool, ord: MuMemoryOrder, refty: MuTypeNode, loc: MuVarNode, excClause: Option<MuExcClause> },
NodeStore { id: MuID, isPtr: bool, ord: MuMemoryOrder, refty: MuTypeNode, loc: MuVarNode, newval: MuVarNode, excClause: Option<MuExcClause> },
NodeCmpXchg { id: MuID, valueResultID: MuID, succResultID: MuID, isPtr: bool, isWeak: bool, ordSucc: MuMemoryOrder, ordFail: MuMemoryOrder, refty: MuTypeNode, loc: MuVarNode, expected: MuVarNode, desired: MuVarNode, excClause: Option<MuExcClause> },
NodeAtomicRMW { id: MuID, resultID: MuID, isPtr: bool, ord: MuMemoryOrder, optr: MuAtomicRMWOptr, refTy: MuTypeNode, loc: MuVarNode, opnd: MuVarNode, excClause: Option<MuExcClause> },
NodeExtractValue { id: MuID, result_id: MuID, strty: MuTypeNode, index: i32, opnd: MuVarNode },
NodeInsertValue { id: MuID, result_id: MuID, strty: MuTypeNode, index: i32, opnd: MuVarNode, newval: MuVarNode },
NodeExtractElement { id: MuID, result_id: MuID, seqty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode },
NodeInsertElement { id: MuID, result_id: MuID, seqty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode, newval: MuVarNode },
NodeShuffleVector { id: MuID, result_id: MuID, vecty: MuTypeNode, maskty: MuTypeNode, vec1: MuVarNode, vec2: MuVarNode, mask: MuVarNode },
NodeNew { id: MuID, result_id: MuID, allocty: MuTypeNode, exc_clause: Option<MuExcClause> },
NodeNewHybrid { id: MuID, result_id: MuID, allocty: MuTypeNode, lenty: MuTypeNode, length: MuVarNode, exc_clause: Option<MuExcClause> },
NodeAlloca { id: MuID, result_id: MuID, allocty: MuTypeNode, exc_clause: Option<MuExcClause> },
NodeAllocaHybrid { id: MuID, result_id: MuID, allocty: MuTypeNode, lenty: MuTypeNode, length: MuVarNode, exc_clause: Option<MuExcClause> },
NodeGetIRef { id: MuID, result_id: MuID, refty: MuTypeNode, opnd: MuVarNode },
NodeGetFieldIRef { id: MuID, result_id: MuID, is_ptr: bool, refty: MuTypeNode, index: i32, opnd: MuVarNode },
NodeGetElemIRef { id: MuID, result_id: MuID, is_ptr: bool, refty: MuTypeNode, indty: MuTypeNode, opnd: MuVarNode, index: MuVarNode },
NodeShiftIRef { id: MuID, result_id: MuID, is_ptr: bool, refty: MuTypeNode, offty: MuTypeNode, opnd: MuVarNode, offset: MuVarNode },
NodeGetVarPartIRef { id: MuID, result_id: MuID, is_ptr: bool, refty: MuTypeNode, opnd: MuVarNode },
NodeLoad { id: MuID, result_id: MuID, is_ptr: bool, ord: MuMemoryOrder, refty: MuTypeNode, loc: MuVarNode, exc_clause: Option<MuExcClause> },
NodeStore { id: MuID, is_ptr: bool, ord: MuMemoryOrder, refty: MuTypeNode, loc: MuVarNode, newval: MuVarNode, exc_clause: Option<MuExcClause> },
NodeCmpXchg { id: MuID, value_result_id: MuID, succ_result_id: MuID, is_ptr: bool, is_weak: bool, ord_succ: MuMemoryOrder, ord_fail: MuMemoryOrder, refty: MuTypeNode, loc: MuVarNode, expected: MuVarNode, desired: MuVarNode, exc_clause: Option<MuExcClause> },
NodeAtomicRMW { id: MuID, result_id: MuID, is_ptr: bool, ord: MuMemoryOrder, optr: MuAtomicRMWOptr, ref_ty: MuTypeNode, loc: MuVarNode, opnd: MuVarNode, exc_clause: Option<MuExcClause> },
NodeFence { id: MuID, ord: MuMemoryOrder, },
NodeTrap { id: MuID, resultIDs: Vec<MuID>, rettys: Vec<MuTypeNode>, excClause: Option<MuExcClause>, keepaliveClause: Option<MuKeepaliveClause> },
NodeWatchPoint { id: MuID, wpid: MuWPID, resultIDs: Vec<MuID>, rettys: Vec<MuTypeNode>, dis: MuDestClause, ena: MuDestClause, exc: Option<MuDestClause>, keepaliveClause: Option<MuKeepaliveClause> },
NodeTrap { id: MuID, result_ids: Vec<MuID>, rettys: Vec<MuTypeNode>, exc_clause: Option<MuExcClause>, keepalive_clause: Option<MuKeepaliveClause> },
NodeWatchPoint { id: MuID, wpid: MuWPID, result_ids: Vec<MuID>, rettys: Vec<MuTypeNode>, dis: MuDestClause, ena: MuDestClause, exc: Option<MuDestClause>, keepalive_clause: Option<MuKeepaliveClause> },
NodeWPBranch { id: MuID, wpid: MuWPID, dis: MuDestClause, ena: MuDestClause },
NodeCCall { id: MuID, resultIDs: Vec<MuID>, callconv: Flag, calleeTy: MuTypeNode, sig: MuFuncSigNode, callee: MuVarNode, args: Vec<MuVarNode>, excClause: Option<MuExcClause>, keepaliveClause: Option<MuKeepaliveClause> },
NodeNewThread { id: MuID, resultID: MuID, stack: MuVarNode, threadlocal: Option<MuVarNode>, newStackClause: MuNewStackClause, excClause: Option<MuExcClause> },
NodeSwapStack { id: MuID, resultIDs: Vec<MuID>, swappee: MuVarNode, curStackClause: MuCurStackClause, newStackClause: MuNewStackClause, excClause: Option<MuExcClause>, keepaliveClause: Option<MuKeepaliveClause> },
NodeCommInst { id: MuID, resultIDs: Vec<MuID>, opcode: MuCommInst, flags: Vec<Flag>, tys: Vec<MuTypeNode>, sigs: Vec<MuFuncSigNode>, args: Vec<MuVarNode>, excClause: Option<MuExcClause>, keepaliveClause: Option<MuKeepaliveClause> },
NodeCCall { id: MuID, result_ids: Vec<MuID>, callconv: Flag, callee_ty: MuTypeNode, sig: MuFuncSigNode, callee: MuVarNode, args: Vec<MuVarNode>, exc_clause: Option<MuExcClause>, keepalive_clause: Option<MuKeepaliveClause> },
NodeNewThread { id: MuID, result_id: MuID, stack: MuVarNode, threadlocal: Option<MuVarNode>, new_stack_clause: MuNewStackClause, exc_clause: Option<MuExcClause> },
NodeSwapStack { id: MuID, result_ids: Vec<MuID>, swappee: MuVarNode, cur_stack_clause: MuCurStackClause, new_stack_clause: MuNewStackClause, exc_clause: Option<MuExcClause>, keepalive_clause: Option<MuKeepaliveClause> },
NodeCommInst { id: MuID, result_ids: Vec<MuID>, opcode: MuCommInst, flags: Vec<Flag>, tys: Vec<MuTypeNode>, sigs: Vec<MuFuncSigNode>, args: Vec<MuVarNode>, exc_clause: Option<MuExcClause>, keepalive_clause: Option<MuKeepaliveClause> },
}
This diff is collapsed.
......@@ -168,63 +168,85 @@ fn test_function_loading() {
let b = ((*ctx).new_ir_builder)(ctx);
let id1 = ((*b).gen_sym)(b, csp.get("@i32"));
let id2 = ((*b).gen_sym)(b, csp.get("@i64"));
let id3 = ((*b).gen_sym)(b, csp.get("@sig"));
let id4 = ((*b).gen_sym)(b, csp.get("@func"));
let id_i32 = ((*b).gen_sym)(b, csp.get("@i32"));
let id_i64 = ((*b).gen_sym)(b, csp.get("@i64"));
let id_sig = ((*b).gen_sym)(b, csp.get("@sig"));
let id_func = ((*b).gen_sym)(b, csp.get("@func"));
((*b).new_type_int)(b, id1, 32);
((*b).new_type_int)(b, id2, 64);
((*b).new_type_int)(b, id_i32, 32);
((*b).new_type_int)(b, id_i64, 64);
let mut ptys = vec![id1];
let mut rtys = vec![id2];
((*b).new_funcsig)(b, id3,
let mut ptys = vec![id_i32];
let mut rtys = vec![id_i64];
((*b).new_funcsig)(b, id_sig,
ptys.as_mut_ptr(), ptys.len(),
rtys.as_mut_ptr(), rtys.len());
((*b).new_func)(b, id4, id3);
((*b).new_func)(b, id_func, id_sig);
let id_const99 = ((*b).gen_sym)(b, csp.get("@const_i32_99"));
((*b).new_const_int)(b, id_const99, id1, 99);
let id5 = ((*b).gen_sym)(b, csp.get("@func.v1"));
let id6 = ((*b).gen_sym)(b, csp.get("@func.v1.entry"));
let id7 = ((*b).gen_sym)(b, csp.get("@func.v1.entry.x"));
let id8 = ((*b).gen_sym)(b, csp.get("@func.v1.bb1"));
let id9 = ((*b).gen_sym)(b, csp.get("@func.v1.bb1.exc"));
//let id4 = ((*b).gen_sym)(b, csp.get("@func"));
((*b).new_const_int)(b, id_const99, id_i32, 99);
let id_funcver = ((*b).gen_sym)(b, csp.get("@func.v1"));
let mut bbs = vec![id6, id8];
((*b).new_func_ver)(b, id5, id4, bbs.as_mut_ptr(), bbs.len());
let id_entry = ((*b).gen_sym)(b, csp.get("@func.v1.entry"));
let id_bb1 = ((*b).gen_sym)(b, csp.get("@func.v1.bb1"));
let id_bbxxx = ((*b).gen_sym)(b, csp.get("@func.v1.bbxxx"));
let mut bbs = vec![id_entry, id_bb1, id_bbxxx];
((*b).new_func_ver)(b, id_funcver, id_func, bbs.as_mut_ptr(), bbs.len());
{
let mut args = vec![id7];
let mut argtys = vec![id1];
let id_x = ((*b).gen_sym)(b, csp.get("@func.v1.entry.x"));
let mut args = vec![id_x];
let mut argtys = vec![id_i32];
let id_add = ((*b).gen_sym)(b, csp.get("@func.v1.entry.add"));
let id_sub = ((*b).gen_sym)(b, csp.get("@func.v1.entry.sub"));
let mut insts = vec![id_add, id_sub];
let id_branch = ((*b).gen_sym)(b, csp.get("@func.v1.entry.branch"));
let mut insts = vec![id_add, id_sub, id_branch];
((*b).new_bb)(b, id6,
((*b).new_bb)(b, id_entry,
args.as_mut_ptr(), argtys.as_mut_ptr(), args.len(),
0,
insts.as_mut_ptr(), insts.len());
let id_y = ((*b).gen_sym)(b, csp.get("@func.v1.entry.y"));
((*b).new_binop)(b, id_add, id_y, CMU_BINOP_ADD, id1, id7, id7, 0);
((*b).new_binop)(b, id_add, id_y, CMU_BINOP_ADD, id_i32, id_x, id_x, 0);
let id_z = ((*b).gen_sym)(b, csp.get("@func.v1.entry.z"));
((*b).new_binop)(b, id_sub, id_z, CMU_BINOP_SUB, id1, id_y, id_const99, 0);
((*b).new_binop)(b, id_sub, id_z, CMU_BINOP_SUB, id_i32, id_y, id_const99, 0);
let id_dest = ((*b).gen_sym)(b, csp.get("@func.v1.entry.dest"));
let mut dest_args = vec![id_z];
((*b).new_dest_clause)(b, id_dest, id_bb1, dest_args.as_mut_ptr(), dest_args.len());
((*b).new_branch)(b, id_branch, id_dest);
}
{
let id_a = ((*b).gen_sym)(b, csp.get("@func.v1.bb1.a"));
let id_ret = ((*b).gen_sym)(b, csp.get("@func.v1.bb1.ret"));
let mut args = vec![id_a];
let mut argtys = vec![id_i32];
let mut insts = vec![id_ret];
((*b).new_bb)(b, id_bb1,
args.as_mut_ptr(), argtys.as_mut_ptr(), args.len(),
0,
insts.as_mut_ptr(), insts.len());
let mut rvs = vec![id_a];
((*b).new_ret)(b, id_ret, rvs.as_mut_ptr(), rvs.len())
}
{
let id_exc = ((*b).gen_sym)(b, csp.get("@func.v1.bbxxx.exc"));
let mut args = vec![];
let mut argtys = vec![];
let mut insts = vec![];
((*b).new_bb)(b, id8,
((*b).new_bb)(b, id_bbxxx,
args.as_mut_ptr(), argtys.as_mut_ptr(), args.len(),
id9,
id_exc,
insts.as_mut_ptr(), insts.len());
}
......
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