-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be77b30
commit 5dfe58d
Showing
31 changed files
with
2,640 additions
and
2,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
12 changes: 7 additions & 5 deletions
12
ir/crates/back/src/codegen/machine/abi/calling_convention.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
use natrix_middle::Type; | ||
use crate::codegen::machine; | ||
use crate::codegen::machine::Size; | ||
use crate::codegen::{ | ||
machine, | ||
machine::Size, | ||
}; | ||
|
||
pub trait CallingConvention { | ||
type Reg: machine::PhysicalRegister; | ||
|
||
fn parameter_slots(params: impl Iterator<Item=Size>) -> impl Iterator<Item=Slot<Self::Reg>>; | ||
fn parameter_slots(params: impl Iterator<Item=Size>) | ||
-> impl Iterator<Item=Slot<Self::Reg>>; | ||
|
||
fn return_slot(size: Size) -> Slot<Self::Reg>; | ||
} | ||
|
||
pub enum Slot<R: machine::PhysicalRegister> { | ||
Register(R), | ||
Stack | ||
Stack, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,3 @@ | ||
use std::fmt::Debug; | ||
use std::hash::Hash; | ||
|
||
pub use calling_convention::CallingConvention; | ||
|
||
use crate::codegen::machine; | ||
use crate::codegen::machine::asm::Assembler; | ||
|
||
pub mod calling_convention; | ||
|
||
pub trait Abi: Debug + Default + Clone + PartialEq + Eq + Hash { | ||
type I: machine::MachineInstr<Abi=Self>; | ||
|
||
type REG: machine::PhysicalRegister + 'static + Hash + Copy; | ||
|
||
type ASSEMBLER: Assembler<Self>; | ||
|
||
type CallingConvention: CallingConvention<Reg=Self::REG>; | ||
|
||
fn get_assembler(base_addr: u64) -> Self::ASSEMBLER { | ||
Self::ASSEMBLER::new(base_addr) | ||
} | ||
} | ||
|
||
pub mod calling_convention; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::fmt::Debug; | ||
|
||
use smallvec::SmallVec; | ||
|
||
use crate::codegen::{ | ||
machine::{ | ||
function::{ | ||
builder::{ | ||
MatchedPattern, | ||
PatternIn, | ||
}, | ||
Function, | ||
}, | ||
TargetMachine, | ||
}, | ||
selection_dag::Immediate, | ||
}; | ||
use crate::codegen::machine::Instr; | ||
|
||
type Reg<B> = <<B as Backend>::TM as TargetMachine>::Reg; | ||
type BackInstr<B> = <<B as Backend>::TM as TargetMachine>::Instr; | ||
|
||
pub trait Backend { | ||
type TM: TargetMachine; | ||
|
||
type P: Pattern<TM=Self::TM>; | ||
|
||
fn patterns() -> &'static [Self::P]; | ||
|
||
fn mov(dest: Reg<Self>, src: Reg<Self>) -> BackInstr<Self>; | ||
|
||
fn mov_imm(dest: Reg<Self>, imm: Immediate) -> BackInstr<Self>; | ||
|
||
fn ret() -> BackInstr<Self>; | ||
|
||
fn new() -> Self; | ||
} | ||
|
||
pub trait Pattern: Sized + Debug + Clone + PartialEq + Eq + 'static { | ||
type TM: TargetMachine; | ||
|
||
fn in_(&self) -> PatternIn; | ||
|
||
fn into_instr( | ||
self, | ||
function: &mut Function<Self::TM>, | ||
matched: MatchedPattern<Self::TM>, | ||
) -> SmallVec<[Instr<Self::TM>; 2]>; | ||
} |
Oops, something went wrong.