55 lines
1008 B
Rust
55 lines
1008 B
Rust
mod compile;
|
|
mod encode;
|
|
#[cfg(test)]
|
|
mod test;
|
|
mod types;
|
|
mod util;
|
|
|
|
use crate::{
|
|
arch::Arch,
|
|
backend::{LinkedProgram, Program},
|
|
io::CompilerMsg,
|
|
};
|
|
|
|
pub use compile::*;
|
|
pub use encode::*;
|
|
pub use types::*;
|
|
use util::*;
|
|
|
|
pub struct X86_64;
|
|
|
|
impl Arch for X86_64 {
|
|
const NAME: &str = "x86_64";
|
|
type Asm = Asm;
|
|
type Addr = u64;
|
|
type CallConv = CallConv;
|
|
fn compile(p: &Program<Self>) -> Result<LinkedProgram<Self::Addr>, CompilerMsg> {
|
|
compile(p)
|
|
}
|
|
}
|
|
|
|
pub enum CallConv {
|
|
SystemV,
|
|
}
|
|
|
|
impl CallConv {
|
|
pub fn param(&self) -> &[Reg] {
|
|
use regs::*;
|
|
match self {
|
|
Self::SystemV => &[rdi, rsi, rdx, rcx, r8, r9],
|
|
}
|
|
}
|
|
pub fn scratch(&self) -> &[Reg] {
|
|
use regs::*;
|
|
match self {
|
|
Self::SystemV => &[rax, rdi, rsi, rdx, rcx, r8, r9, r10, r11],
|
|
}
|
|
}
|
|
pub fn ret(&self) -> &[Reg] {
|
|
use regs::*;
|
|
match self {
|
|
Self::SystemV => &[rax, rdx],
|
|
}
|
|
}
|
|
}
|