Add RISC-V call instruction encodings.
Calls are jal with a fixed %x1 link register.
This commit is contained in:
@@ -8,13 +8,12 @@ use predicates::is_signed_int;
|
||||
include!(concat!(env!("OUT_DIR"), "/binemit-riscv.rs"));
|
||||
|
||||
/// RISC-V relocation kinds.
|
||||
#[allow(dead_code)]
|
||||
pub enum RelocKind {
|
||||
/// A conditional (SB-type) branch to an EBB.
|
||||
Branch,
|
||||
/// A jal call to a function.
|
||||
Call,
|
||||
}
|
||||
|
||||
pub static RELOC_NAMES: [&'static str; 1] = ["Branch"];
|
||||
pub static RELOC_NAMES: [&'static str; 1] = ["Call"];
|
||||
|
||||
impl Into<Reloc> for RelocKind {
|
||||
fn into(self) -> Reloc {
|
||||
@@ -318,3 +317,13 @@ fn recipe_uj<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS)
|
||||
panic!("Expected Jump format: {:?}", func.dfg[inst]);
|
||||
}
|
||||
}
|
||||
|
||||
fn recipe_ujcall<CS: CodeSink + ?Sized>(func: &Function, inst: Inst, sink: &mut CS) {
|
||||
if let InstructionData::Call { func_ref, .. } = func.dfg[inst] {
|
||||
sink.reloc_func(RelocKind::Call.into(), func_ref);
|
||||
// rd=%x1 is the standard link register.
|
||||
put_uj(func.encodings[inst].bits(), 0, 1, sink);
|
||||
} else {
|
||||
panic!("Expected Call format: {:?}", func.dfg[inst]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user