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.

Commit 6c06ffd1 authored by Kunshan Wang's avatar Kunshan Wang
Browse files

IRBuilder: SELECT

parent 97e188ad
......@@ -1371,6 +1371,27 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
},
}
},
NodeInst::NodeSelect { id: _, result_id, cond_ty, opnd_ty, cond, if_true, if_false } => {
let impl_cond_ty = self.get_built_type(cond_ty);
let impl_opnd_ty = self.get_built_type(opnd_ty);
let impl_cond = self.get_treenode(fcb, cond);
let impl_if_true = self.get_treenode(fcb, if_true);
let impl_if_false = self.get_treenode(fcb, if_false);
// NOTE: only implemented scalar SELECT. Vector select is not implemented yet.
let impl_rv = self.new_ssa(fcb, result_id, impl_opnd_ty.clone()).clone_value();
Instruction {
hdr: hdr,
value: Some(vec![impl_rv]),
ops: RwLock::new(vec![impl_cond, impl_if_true, impl_if_false]),
v: Instruction_::Select {
cond: 0,
true_val: 1,
false_val: 2,
},
}
},
NodeInst::NodeBranch { id: _, dest } => {
let mut ops: Vec<P<TreeNode>> = Vec::new();
......
......@@ -2,6 +2,6 @@ from util import fncptr_from_c_script
import ctypes
def test_select():
fnp = fncptr_from_c_script('test_select.c', 'test_fnc', [ctypes.c_byte])
fnp, _ = fncptr_from_c_script('test_select.c', 'test_fnc', [ctypes.c_byte])
assert fnp(0) == 20
assert fnp(1) == 10
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