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.4% of users enabled 2FA.

Commit 87442324 authored by qinsoon's avatar qinsoon
Browse files

select inst for floating point values, other fixes

parent ace11dec
......@@ -322,25 +322,26 @@ impl <'a> InstructionSelection {
let ref true_val = ops[true_val];
let ref false_val = ops[false_val];
// generate compare
let cmpop = if self.match_cmp_res(cond) {
self.emit_cmp_res(cond, f_content, f_context, vm)
} else if self.match_ireg(cond) {
let tmp_cond = self.emit_ireg(cond, f_content, f_context, vm);
// emit: cmp cond_reg 1
self.backend.emit_cmp_imm_r(1, &tmp_cond);
EQ
} else {
panic!("expected cond to be ireg, found {}", cond)
};
if self.match_ireg(true_val) {
// moving integers/pointers
let tmp_res = self.get_result_value(node);
// generate compare
let cmpop = if self.match_cmp_res(cond) {
self.emit_cmp_res(cond, f_content, f_context, vm)
} else if self.match_ireg(cond) {
let tmp_cond = self.emit_ireg(cond, f_content, f_context, vm);
// emit: cmp cond_reg 1
self.backend.emit_cmp_imm_r(1, &tmp_cond);
EQ
} else {
panic!("expected ireg, found {}", cond)
};
// use cmov for 16/32/64bit integer
// use jcc for 8 bit
// FIXME: could use 32bit register to implement 8bit select
match tmp_res.ty.get_int_length() {
// cmov
Some(len) if len > 8 => {
......@@ -374,9 +375,9 @@ impl <'a> InstructionSelection {
}
// jcc
_ => {
let blk_true = format!("{}_select_true", node.id());
let blk_false = format!("{}_select_false", node.id());
let blk_end = format!("{}_select_end", node.id());
let blk_true = format!("{}_{}_select_true", self.current_fv_id, node.id());
let blk_false = format!("{}_{}_select_false", self.current_fv_id, node.id());
let blk_end = format!("{}_{}_select_end", self.current_fv_id, node.id());
// jump to blk_true if true
match cmpop {
......@@ -432,8 +433,66 @@ impl <'a> InstructionSelection {
self.current_block = Some(blk_end.clone());
}
}
} else if self.match_fpreg(true_val) {
let tmp_res = self.get_result_value(node);
let blk_true = format!("{}_{}_select_true", self.current_fv_id, node.id());
let blk_false = format!("{}_{}_select_false", self.current_fv_id, node.id());
let blk_end = format!("{}_{}_select_end", self.current_fv_id, node.id());
// jump to blk_true if true
match cmpop {
EQ => self.backend.emit_je (blk_true.clone()),
NE => self.backend.emit_jne(blk_true.clone()),
SGE => self.backend.emit_jge(blk_true.clone()),
SGT => self.backend.emit_jg (blk_true.clone()),
SLE => self.backend.emit_jle(blk_true.clone()),
SLT => self.backend.emit_jl (blk_true.clone()),
UGE => self.backend.emit_jae(blk_true.clone()),
UGT => self.backend.emit_ja (blk_true.clone()),
ULE => self.backend.emit_jbe(blk_true.clone()),
ULT => self.backend.emit_jb (blk_true.clone()),
FOEQ | FUEQ => self.backend.emit_je (blk_true.clone()),
FONE | FUNE => self.backend.emit_jne(blk_true.clone()),
FOGT | FUGT => self.backend.emit_ja (blk_true.clone()),
FOGE | FUGE => self.backend.emit_jae(blk_true.clone()),
FOLT | FULT => self.backend.emit_jb (blk_true.clone()),
FOLE | FULE => self.backend.emit_jbe(blk_true.clone()),
_ => unimplemented!()
}
// finishing current block
let cur_block = self.current_block.as_ref().unwrap().clone();
self.backend.end_block(cur_block.clone());
// blk_false:
self.current_block = Some(blk_false.clone());
self.backend.start_block(blk_false.clone());
// mov false result here
self.emit_move_node_to_value(&tmp_res, &false_val, f_content, f_context, vm);
// jmp to end
self.backend.emit_jmp(blk_end.clone());
// finishing current block
let cur_block = self.current_block.as_ref().unwrap().clone();
self.backend.end_block(cur_block.clone());
// blk_true:
self.current_block = Some(blk_true.clone());
self.backend.start_block(blk_true.clone());
// mov true value -> result
self.emit_move_node_to_value(&tmp_res, &true_val, f_content, f_context, vm);
self.backend.end_block(blk_true.clone());
// blk_end:
self.backend.start_block(blk_end.clone());
self.current_block = Some(blk_end.clone());
} else {
// moving vectors, floatingpoints
unimplemented!()
}
},
......@@ -4620,10 +4679,7 @@ impl <'a> InstructionSelection {
#[cfg(feature = "aot")]
fn get_mem_for_funcref(&mut self, func_id: MuID, vm: &VM) -> P<Value> {
// use compiler::backend::x86_64::asm_backend;
//
let func_name = vm.name_of(func_id);
// let label = asm_backend::symbol(func_name);
let func_name = vm.get_func_name(func_id);
P(Value {
hdr: MuEntityHeader::unnamed(vm.next_id()),
......
......@@ -591,11 +591,15 @@ impl <'a> VM {
None => panic!("cannot find id for name: {}", name)
}
}
/// should only used by client
/// 'name' used internally may be slightly different to remove some special symbols
pub fn id_of(&self, name: &str) -> MuID {
self.id_of_by_refstring(&name.to_string())
}
/// should only used by client
/// 'name' used internally may be slightly different to remove some special symbols
pub fn name_of(&self, id: MuID) -> MuName {
let map = self.id_name_map.read().unwrap();
map.get(&id).unwrap().clone()
......@@ -765,6 +769,15 @@ impl <'a> VM {
info!("declare func #{} = {}", id, func);
funcs.insert(id, RwLock::new(func));
}
/// this is different than vm.name_of()
pub fn get_func_name(&self, id: MuID) -> MuName {
let funcs_lock = self.funcs.read().unwrap();
match funcs_lock.get(&id) {
Some(func) => func.read().unwrap().name().unwrap(),
None => panic!("cannot find name for Mu function #{}")
}
}
/// The IR builder needs to look-up the function signature from the existing function ID.
pub fn get_func_sig_for_func(&self, id: MuID) -> P<MuFuncSig> {
......
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