Commit 4d5dbf7b authored by Yi Lin's avatar Yi Lin

Merge branch 'tree-gen-fix' into 'develop'

Tree gen fix

See merge request !48
parents 1dbd1d9b 059709a3
......@@ -599,7 +599,7 @@ impl Instruction {
} => {
let ptr = select_value!(is_ptr, " PTR", "");
format!(
"GETELEMIREF{}<{} {}>{} {}",
"SHIFTIREF{}<{} {}>{} {}",
ptr,
ops[base].ty().get_referent_ty().unwrap(),
ops[offset].ty(),
......
......@@ -154,6 +154,7 @@ rodal_struct!(Callsite {
exception_destination,
stack_arg_size
});
#[derive(Debug)]
pub struct Callsite {
pub name: MuName,
pub exception_destination: Option<MuName>,
......@@ -1103,8 +1104,8 @@ impl Value {
}
}
const DISPLAY_ID: bool = false;
const DISPLAY_TYPE: bool = false;
const DISPLAY_ID: bool = true;
const DISPLAY_TYPE: bool = true;
const PRINT_ABBREVIATE_NAME: bool = true;
impl fmt::Debug for Value {
......
......@@ -2007,7 +2007,7 @@ impl ASMCodeGen {
if is_zero_register_id(id1) {
// zero register, ignore
} else if uses.contains_key(&id1) {
let mut locs = uses.get_mut(&id1).unwrap();
let locs = uses.get_mut(&id1).unwrap();
vec_utils::add_unique(locs, loc1);
} else {
......@@ -2060,7 +2060,7 @@ impl ASMCodeGen {
if is_zero_register_id(id2) {
// zero register, ignore
} else if uses.contains_key(&id2) {
let mut locs = uses.get_mut(&id2).unwrap();
let locs = uses.get_mut(&id2).unwrap();
vec_utils::add_unique(locs, loc2);
} else {
uses.insert(id2, vec![loc2]);
......@@ -2089,7 +2089,7 @@ impl ASMCodeGen {
if is_zero_register_id(id1) {
// zero register, ignore
} else if uses.contains_key(&id1) {
let mut locs = uses.get_mut(&id1).unwrap();
let locs = uses.get_mut(&id1).unwrap();
vec_utils::add_unique(locs, loc1);
} else {
uses.insert(id1, vec![loc1]);
......@@ -2098,7 +2098,7 @@ impl ASMCodeGen {
if is_zero_register_id(id2) {
// zero register, ignore
} else if uses.contains_key(&id2) {
let mut locs = uses.get_mut(&id2).unwrap();
let locs = uses.get_mut(&id2).unwrap();
vec_utils::add_unique(locs, loc2);
} else {
uses.insert(id2, vec![loc2]);
......@@ -2132,7 +2132,7 @@ impl ASMCodeGen {
if is_zero_register_id(id2) {
// zero register, ignore
} else if uses.contains_key(&id2) {
let mut locs = uses.get_mut(&id2).unwrap();
let locs = uses.get_mut(&id2).unwrap();
vec_utils::add_unique(locs, loc2);
} else {
uses.insert(id2, vec![loc2]);
......@@ -2141,7 +2141,7 @@ impl ASMCodeGen {
if is_zero_register_id(id3) {
// zero register, ignore
} else if uses.contains_key(&id3) {
let mut locs = uses.get_mut(&id3).unwrap();
let locs = uses.get_mut(&id3).unwrap();
vec_utils::add_unique(locs, loc3);
} else {
uses.insert(id3, vec![loc3]);
......
......@@ -228,17 +228,7 @@ pub fn is_machine_reg(val: &P<Value>) -> bool {
// Returns a P<Value> to the register id
pub fn get_register_from_id(id: MuID) -> P<Value> {
if id < FPR_ID_START {
match GPR_ALIAS_LOOKUP.get(&id) {
Some(val) => val.clone(),
None => panic!("cannot find GPR {}", id)
}
} else {
match FPR_ALIAS_LOOKUP.get(&id) {
Some(val) => val.clone(),
None => panic!("cannot find FPR {}", id)
}
}
ALL_MACHINE_REGS.get(&id).unwrap().clone()
}
pub fn get_alias_for_length(id: MuID, length: usize) -> P<Value> {
......@@ -916,7 +906,7 @@ pub fn is_callee_saved(reg_id: MuID) -> bool {
// The stack size needed for a call to the given function signature
pub fn call_stack_size(sig: P<MuFuncSig>, vm: &VM) -> usize {
compute_argument_locations(&sig.ret_tys, &SP, 0, &vm).2
compute_argument_locations(&sig.ret_tys, &SP, 0, false, &vm).2
}
// TODO: Check that these numbers are reasonable (THEY ARE ONLY AN ESTIMATE)
use ast::inst::*;
......@@ -2906,6 +2896,7 @@ fn compute_argument_locations(
arg_types: &Vec<P<MuType>>,
stack: &P<Value>,
offset: i64,
is_callee_saved: bool,
vm: &VM
) -> (Vec<bool>, Vec<P<Value>>, usize) {
if arg_types.len() == 0 {
......@@ -2913,6 +2904,18 @@ fn compute_argument_locations(
return (vec![], vec![], 0);
}
let fpr_regs = if is_callee_saved {
CALLEE_SAVED_FPRS.as_ref()
} else {
ARGUMENT_FPRS.as_ref()
};
let gpr_regs = if is_callee_saved {
CALLEE_SAVED_GPRS.as_ref()
} else {
ARGUMENT_GPRS.as_ref()
};
let mut ngrn = 0 as usize; // The Next General-purpose Register Number
let mut nsrn = 0 as usize; // The Next SIMD and Floating-point Register Number
let mut nsaa = 0 as usize; // The next stacked argument address (an offset from the SP)
......@@ -2954,7 +2957,7 @@ fn compute_argument_locations(
Float | Double => {
if nsrn < 8 {
locations.push(get_alias_for_length(
ARGUMENT_FPRS[nsrn].id(),
fpr_regs[nsrn].id(),
get_bit_size(&t, vm)
));
nsrn += 1;
......@@ -2976,7 +2979,7 @@ fn compute_argument_locations(
// Note: the argument will occupy succesiv registers
// (one for each element)
locations.push(get_alias_for_length(
ARGUMENT_FPRS[nsrn].id(),
fpr_regs[nsrn].id(),
get_bit_size(&t, vm) / hfa_n
));
nsrn += hfa_n;
......@@ -2999,7 +3002,7 @@ fn compute_argument_locations(
// The struct should be packed, starting here
// (note: this may result in multiple struct fields in the same regsiter
// or even floating points in a GPR)
locations.push(ARGUMENT_GPRS[ngrn].clone());
locations.push(gpr_regs[ngrn].clone());
// How many GPRS are taken up by t
ngrn += if size % 8 != 0 {
size / 8 + 1
......@@ -3027,7 +3030,7 @@ fn compute_argument_locations(
if size <= 8 {
if ngrn < 8 {
locations.push(get_alias_for_length(
ARGUMENT_GPRS[ngrn].id(),
gpr_regs[ngrn].id(),
get_bit_size(&t, vm)
));
ngrn += 1;
......@@ -3046,7 +3049,7 @@ fn compute_argument_locations(
ngrn = align_up(ngrn, 2); // align NGRN to the next even number
if ngrn < 7 {
locations.push(ARGUMENT_GPRS[ngrn].clone());
locations.push(gpr_regs[ngrn].clone());
ngrn += 2;
} else {
ngrn = 8;
......
......@@ -602,7 +602,6 @@ fn build_cfg_nodes(cf: &mut CompiledFunction) -> LinkedHashMap<MuName, CFGBlockN
Some(range) => range,
None => panic!("cannot find range for block {}", block)
};
// start inst
let first_inst = range.start;
// last inst (we need to skip symbols)
......
......@@ -399,7 +399,13 @@ fn process_dest(
}
let new_blk_id = vm.next_id();
let new_blck_name = Arc::new(format!("{}:{}:#{}-#{}", inst, label, new_blk_id, target));
let new_blck_name = Arc::new(format!(
"{}:{}:#{}-#{}",
inst,
label,
new_blk_id,
target.name()
));
let dest = Destination {
target: MuEntityHeader::named(new_blk_id, new_blck_name.clone()),
......
......@@ -84,7 +84,7 @@ begin_func muthread_start_exceptional
// Save the current SP to old_sp_loc
MOV X11, SP
STR X11, [X1]
STR X11, [X2]
// Swap to the new stack
MOV SP, X1
......@@ -104,4 +104,4 @@ begin_func muentry_thread_exit
pop_callee_saved
exit_frame
BR LR
end_func muentry_thread_exit
\ No newline at end of file
end_func muentry_thread_exit
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