Sketch of prologue generation
This commit is contained in:
committed by
Jakob Stoklund Olesen
parent
fdfe24760a
commit
60b6bc3ab7
@@ -10,9 +10,14 @@ use binemit::{CodeSink, MemoryCodeSink, emit_function};
|
|||||||
use super::super::settings as shared_settings;
|
use super::super::settings as shared_settings;
|
||||||
use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings};
|
use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings};
|
||||||
use isa::Builder as IsaBuilder;
|
use isa::Builder as IsaBuilder;
|
||||||
use isa::{TargetIsa, RegInfo, RegClass, EncInfo};
|
use isa::{TargetIsa, RegInfo, RegClass, EncInfo, RegUnit};
|
||||||
|
use self::registers::RU;
|
||||||
use ir;
|
use ir;
|
||||||
use regalloc;
|
use regalloc;
|
||||||
|
use result;
|
||||||
|
use ir::InstBuilder;
|
||||||
|
use legalizer;
|
||||||
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct Isa {
|
struct Isa {
|
||||||
@@ -111,4 +116,44 @@ impl TargetIsa for Isa {
|
|||||||
fn reloc_names(&self) -> &'static [&'static str] {
|
fn reloc_names(&self) -> &'static [&'static str] {
|
||||||
&binemit::RELOC_NAMES
|
&binemit::RELOC_NAMES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn prologue_epilogue(&self, func: &mut ir::Function) -> result::CtonResult {
|
||||||
|
use stack_layout::layout_stack;
|
||||||
|
use cursor::{Cursor, EncCursor};
|
||||||
|
|
||||||
|
let word_size = if self.flags().is_64bit() { 8 } else { 4 };
|
||||||
|
let stack_size = layout_stack(&mut func.stack_slots, word_size)?;
|
||||||
|
|
||||||
|
// Append frame pointer to function signature
|
||||||
|
let rbp_arg = ir::AbiParam::special_reg(
|
||||||
|
ir::types::I64,
|
||||||
|
ir::ArgumentPurpose::FramePointer,
|
||||||
|
RU::rbp as RegUnit,
|
||||||
|
);
|
||||||
|
func.signature.params.push(rbp_arg);
|
||||||
|
|
||||||
|
// Append param to entry EBB
|
||||||
|
let entry_ebb = func.layout.entry_block().expect("missing entry block");
|
||||||
|
func.dfg.append_ebb_param(entry_ebb, ir::types::I64);
|
||||||
|
|
||||||
|
// Find our frame pointer parameter Value
|
||||||
|
let fp = func.special_param(ir::ArgumentPurpose::FramePointer)
|
||||||
|
.expect("missing frame pointer");
|
||||||
|
|
||||||
|
// Assign it a location
|
||||||
|
func.locations[fp] = ir::ValueLoc::Reg(RU::rbp as RegUnit);
|
||||||
|
|
||||||
|
// Insert prologue
|
||||||
|
let mut pos = EncCursor::new(func, self).at_first_insertion_point(entry_ebb);
|
||||||
|
pos.ins().x86_push(fp);
|
||||||
|
pos.ins().copy_special(
|
||||||
|
RU::rbp as RegUnit,
|
||||||
|
RU::rsp as RegUnit,
|
||||||
|
);
|
||||||
|
pos.ins().adjust_sp_imm(-(stack_size as i32));
|
||||||
|
|
||||||
|
//legalizer::legalize_function(func, &mut func.cfg, self);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user