refactor Reloc to an enum of every architecture's reloc types
https://github.com/stoklund/cretonne/pull/206#issuecomment-350905016
This commit is contained in:
committed by
Jakob Stoklund Olesen
parent
a888b2a6f1
commit
88b30ff386
@@ -5,5 +5,3 @@ use ir::{Function, Inst};
|
||||
use regalloc::RegDiversions;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/binemit-arm32.rs"));
|
||||
|
||||
pub static RELOC_NAMES: [&'static str; 1] = ["Call"];
|
||||
|
||||
@@ -107,8 +107,4 @@ impl TargetIsa for Isa {
|
||||
fn emit_function(&self, func: &ir::Function, sink: &mut MemoryCodeSink) {
|
||||
emit_function(func, binemit::emit_inst, sink)
|
||||
}
|
||||
|
||||
fn reloc_names(&self) -> &'static [&'static str] {
|
||||
&binemit::RELOC_NAMES
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,5 +5,3 @@ use ir::{Function, Inst};
|
||||
use regalloc::RegDiversions;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/binemit-arm64.rs"));
|
||||
|
||||
pub static RELOC_NAMES: [&'static str; 1] = ["Call"];
|
||||
|
||||
@@ -100,8 +100,4 @@ impl TargetIsa for Isa {
|
||||
fn emit_function(&self, func: &ir::Function, sink: &mut MemoryCodeSink) {
|
||||
emit_function(func, binemit::emit_inst, sink)
|
||||
}
|
||||
|
||||
fn reloc_names(&self) -> &'static [&'static str] {
|
||||
&binemit::RELOC_NAMES
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,26 +9,6 @@ use super::registers::RU;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/binemit-intel.rs"));
|
||||
|
||||
/// Intel relocations.
|
||||
pub enum RelocKind {
|
||||
/// A 4-byte relative function reference. Based from relocation + 4 bytes.
|
||||
PCRel4,
|
||||
|
||||
/// A 4-byte absolute function reference.
|
||||
Abs4,
|
||||
|
||||
/// An 8-byte absolute function reference.
|
||||
Abs8,
|
||||
}
|
||||
|
||||
pub static RELOC_NAMES: [&'static str; 3] = ["PCRel4", "Abs4", "Abs8"];
|
||||
|
||||
impl Into<Reloc> for RelocKind {
|
||||
fn into(self) -> Reloc {
|
||||
Reloc(self as u16)
|
||||
}
|
||||
}
|
||||
|
||||
// Convert a stack base to the corresponding register.
|
||||
fn stk_base(base: StackBase) -> RegUnit {
|
||||
let ru = match base {
|
||||
|
||||
@@ -111,10 +111,6 @@ impl TargetIsa for Isa {
|
||||
emit_function(func, binemit::emit_inst, sink)
|
||||
}
|
||||
|
||||
fn reloc_names(&self) -> &'static [&'static str] {
|
||||
&binemit::RELOC_NAMES
|
||||
}
|
||||
|
||||
fn prologue_epilogue(&self, func: &mut ir::Function) -> result::CtonResult {
|
||||
let _tt = timing::prologue_epilogue();
|
||||
abi::prologue_epilogue(func, self)
|
||||
|
||||
@@ -272,10 +272,4 @@ pub trait TargetIsa {
|
||||
///
|
||||
/// This is more performant than calling `emit_inst` for each instruction.
|
||||
fn emit_function(&self, func: &ir::Function, sink: &mut binemit::MemoryCodeSink);
|
||||
|
||||
/// Get a static array of names associated with relocations in this ISA.
|
||||
///
|
||||
/// This array can be indexed by the contents of `binemit::Reloc` objects passed to a
|
||||
/// `CodeSink`.
|
||||
fn reloc_names(&self) -> &'static [&'static str];
|
||||
}
|
||||
|
||||
@@ -9,20 +9,6 @@ use std::u32;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/binemit-riscv.rs"));
|
||||
|
||||
/// RISC-V relocation kinds.
|
||||
pub enum RelocKind {
|
||||
/// A jal call to a function.
|
||||
Call,
|
||||
}
|
||||
|
||||
pub static RELOC_NAMES: [&'static str; 1] = ["Call"];
|
||||
|
||||
impl Into<Reloc> for RelocKind {
|
||||
fn into(self) -> Reloc {
|
||||
Reloc(self as u16)
|
||||
}
|
||||
}
|
||||
|
||||
/// R-type instructions.
|
||||
///
|
||||
/// 31 24 19 14 11 6
|
||||
|
||||
@@ -107,10 +107,6 @@ impl TargetIsa for Isa {
|
||||
fn emit_function(&self, func: &ir::Function, sink: &mut MemoryCodeSink) {
|
||||
emit_function(func, binemit::emit_inst, sink)
|
||||
}
|
||||
|
||||
fn reloc_names(&self) -> &'static [&'static str] {
|
||||
&binemit::RELOC_NAMES
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user