GitLab will be partched to the latest stable version on 15 July 2020 at 2.00pm (AEDT) to 2.30pm (AEDT) due to Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

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

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