Add a simple boilerplate.
This commit is contained in:
committed by
Dan Gohman
parent
08240761d5
commit
b42696f207
@@ -2,7 +2,7 @@
|
||||
|
||||
use error::Error;
|
||||
use dynasmrt::x64::Assembler;
|
||||
use dynasmrt::{DynasmApi, AssemblyOffset, ExecutableBuffer};
|
||||
use dynasmrt::{DynasmApi, DynasmLabelApi, AssemblyOffset, ExecutableBuffer, DynamicLabel};
|
||||
|
||||
/// Size of a pointer on the target in bytes.
|
||||
const WORD_SIZE: u32 = 8;
|
||||
@@ -82,6 +82,10 @@ impl Registers {
|
||||
}
|
||||
}
|
||||
|
||||
/// Label in code.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct Label(DynamicLabel);
|
||||
|
||||
/// Describes location of a argument.
|
||||
enum ArgLocation {
|
||||
/// Argument is passed via some register.
|
||||
@@ -175,6 +179,19 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new undefined label.
|
||||
pub fn create_label(ctx: &mut Context) -> Label {
|
||||
Label(ctx.asm.new_dynamic_label())
|
||||
}
|
||||
|
||||
/// Define the given label at the current position.
|
||||
///
|
||||
/// Multiple labels can be defined at the same position. However, a label
|
||||
/// can be defined only once.
|
||||
pub fn define_label(ctx: &mut Context, label: Label) {
|
||||
ctx.asm.dynamic_label(label.0);
|
||||
}
|
||||
|
||||
fn push_i32(ctx: &mut Context, gpr: GPR) {
|
||||
// For now, do an actual push (and pop below). In the future, we could
|
||||
// do on-the-fly register allocation here.
|
||||
@@ -284,7 +301,7 @@ pub fn epilogue(ctx: &mut Context) {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn unsupported_opcode(ctx: &mut Context) {
|
||||
pub fn trap(ctx: &mut Context) {
|
||||
dynasm!(ctx.asm
|
||||
; ud2
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user