custom changes

This commit is contained in:
T0b1
2023-04-14 18:46:16 +02:00
parent a97e82c6e2
commit 606ae9b4d1
8 changed files with 25 additions and 9 deletions

View File

@@ -27,7 +27,7 @@ serde = { version = "1.0.94", features = ["derive"], optional = true }
bincode = { version = "1.2.1", optional = true }
gimli = { workspace = true, features = ["write"], optional = true }
smallvec = { workspace = true }
regalloc2 = { version = "0.6.1", features = ["checker"] }
regalloc2 = { path = "../../../regalloc2/", features = ["checker", "trace-log"] }
souper-ir = { version = "2.1.0", optional = true }
sha2 = { version = "0.10.2", optional = true }
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.

View File

@@ -230,6 +230,7 @@ pub fn create_reg_env(flags: &settings::Flags) -> MachineEnv {
],
],
fixed_stack_slots: vec![],
scratch_by_class: [None, None],
};
if !flags.enable_pinned_reg() {

View File

@@ -182,6 +182,7 @@ pub fn crate_reg_eviroment(_flags: &settings::Flags) -> MachineEnv {
preferred_regs_by_class,
non_preferred_regs_by_class,
fixed_stack_slots: vec![],
scratch_by_class: [None, None],
}
}

View File

@@ -151,6 +151,7 @@ pub fn create_machine_env(_flags: &settings::Flags) -> MachineEnv {
],
],
fixed_stack_slots: vec![],
scratch_by_class: [None, None],
}
}

View File

@@ -203,6 +203,7 @@ pub(crate) fn create_reg_env_systemv(flags: &settings::Flags) -> MachineEnv {
vec![],
],
fixed_stack_slots: vec![],
scratch_by_class: [None, None]
};
debug_assert_eq!(r15(), pinned_reg());

View File

@@ -51,6 +51,7 @@ pub fn compile<B: LowerBackend + TargetIsa>(
let _tt = timing::regalloc();
let mut options = RegallocOptions::default();
options.verbose_log = b.flags().regalloc_verbose_logs();
options.fast_alloc = true;
if cfg!(debug_assertions) {
options.validate_ssa = true;

View File

@@ -908,6 +908,7 @@ impl<I: VCodeInst> VCode<I> {
for inst_or_edit in regalloc.block_insts_and_edits(&self, block) {
match inst_or_edit {
InstOrEdit::Inst(iix) => {
trace!("Emitting inst {}", iix.index());
if !self.debug_value_labels.is_empty() {
// If we need to produce debug info,
// record the offset of each instruction
@@ -1009,6 +1010,7 @@ impl<I: VCodeInst> VCode<I> {
// immediately emit it.
match (from.as_reg(), to.as_reg()) {
(Some(from), Some(to)) => {
trace!("Emitting move from {} to {}", from, to);
// Reg-to-reg move.
let from_rreg = Reg::from(from);
let to_rreg = Writable::from_reg(Reg::from(to));
@@ -1018,6 +1020,7 @@ impl<I: VCodeInst> VCode<I> {
do_emit(&mv, &[], &mut disasm, &mut buffer, &mut state);
}
(Some(from), None) => {
trace!("Emitting move from {} to slot {}", from, to.as_stack().unwrap().index());
// Spill from register to spillslot.
let to = to.as_stack().unwrap();
let from_rreg = RealReg::from(from);
@@ -1025,6 +1028,7 @@ impl<I: VCodeInst> VCode<I> {
do_emit(&spill, &[], &mut disasm, &mut buffer, &mut state);
}
(None, Some(to)) => {
trace!("Emitting move from slot {} to {}", from.as_stack().unwrap().index(), to);
// Load from spillslot to register.
let from = from.as_stack().unwrap();
let to_rreg = Writable::from_reg(RealReg::from(to));
@@ -1100,6 +1104,10 @@ impl<I: VCodeInst> VCode<I> {
self.compute_value_labels_ranges(regalloc, &inst_offsets[..], func_body_len);
let frame_size = self.abi.frame_size();
if want_disasm {
trace!("Disassembly:\n{}", disasm);
}
EmitResult {
buffer,
bb_offsets,
@@ -1282,14 +1290,6 @@ impl<I: VCodeInst> RegallocFunction for VCode<I> {
self.insts[insn.index()].is_safepoint()
}
fn is_move(&self, insn: InsnIndex) -> Option<(Operand, Operand)> {
let (a, b) = self.is_move.get(&insn)?;
Some((
self.assert_operand_not_vreg_alias(*a),
self.assert_operand_not_vreg_alias(*b),
))
}
fn inst_operands(&self, insn: InsnIndex) -> &[Operand] {
let (start, end) = self.operand_ranges[insn.index()];
let ret = &self.operands[start as usize..end as usize];

View File

@@ -17,6 +17,7 @@ use std::cmp::max;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use thiserror::Error;
use log::trace;
const TESTFILE_NAMESPACE: u32 = 0;
@@ -191,6 +192,7 @@ impl TestFileCompiler {
// First, rename the function
let func_original_name = func.name;
func.name = UserFuncName::User(defined_func.new_name.clone());
trace!("Rename func from '{}' to '{}'", func_original_name, func.name);
// Rename any functions that it references
// Do this in stages to appease the borrow checker
@@ -233,6 +235,10 @@ impl TestFileCompiler {
.get(&func.name)
.ok_or(anyhow!("Undeclared function {} found!", &func.name))?;
if log::log_enabled!(log::Level::Trace) {
self.ctx.set_disasm(true);
}
self.ctx.func = self.apply_func_rename(func, defined_func)?;
self.module.define_function_with_control_plane(
defined_func.func_id,
@@ -277,6 +283,11 @@ impl TestFileCompiler {
// available).
self.module.finalize_definitions()?;
for (name, func) in self.defined_functions.iter() {
let ptr = self.module.get_finalized_function(func.func_id);
trace!("Function '{}' at {:#X}", name, ptr as u64);
}
Ok(CompiledTestFile {
module: Some(self.module),
defined_functions: self.defined_functions,