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 3d1b37f7 authored by qinsoon's avatar qinsoon
Browse files

prioritize using callee-saved regs. If any caller-saved reg is used, panic

parent 9ebbb02c
......@@ -194,21 +194,23 @@ lazy_static! {
XMM15.clone()
];
// put callee saved regs first
pub static ref ALL_USABLE_MACHINE_REGs : Vec<P<Value>> = vec![
RBX.clone(),
R12.clone(),
R13.clone(),
R14.clone(),
R15.clone(),
RAX.clone(),
RCX.clone(),
RDX.clone(),
RBX.clone(),
RSI.clone(),
RDI.clone(),
R8.clone(),
R9.clone(),
R10.clone(),
R11.clone(),
R12.clone(),
R13.clone(),
R14.clone(),
R15.clone(),
XMM0.clone(),
XMM1.clone(),
XMM2.clone(),
......@@ -273,6 +275,16 @@ pub fn pick_group_for_reg(reg_id: MuID) -> RegGroup {
}
}
pub fn is_callee_saved(reg_id: MuID) -> bool {
for reg in CALLEE_SAVED_GPRs.iter() {
if reg_id == reg.extract_ssa_id().unwrap() {
return true;
}
}
false
}
pub fn is_valid_x86_imm(op: &P<Value>) -> bool {
use std::u32;
match op.v {
......
......@@ -22,6 +22,8 @@ pub use compiler::backend::x86_64::all_regs;
pub use compiler::backend::x86_64::all_usable_regs;
#[cfg(target_arch = "x86_64")]
pub use compiler::backend::x86_64::pick_group_for_reg;
#[cfg(target_arch = "x86_64")]
pub use compiler::backend::x86_64::is_callee_saved;
#[cfg(target_arch = "arm")]
#[path = "arch/arm/mod.rs"]
......
......@@ -559,6 +559,11 @@ impl GraphColoring {
} else {
let first_available_color = ok_colors.pop_front().unwrap();
trace!("Color {} as {}", self.node_info(n), first_available_color);
if !backend::is_callee_saved(first_available_color) {
panic!("using a non-callee-saved register. need to go to compiler slowpath. Unimplemented");
}
self.colored_nodes.push(n);
self.ig.color_node(n, first_available_color);
}
......
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