Clippy lint and cleanup

This commit is contained in:
Brendan Hansknecht 2021-08-24 19:10:42 -07:00
parent 3badca4581
commit 5066b19901
3 changed files with 19 additions and 16 deletions

View file

@ -253,6 +253,10 @@ impl CallConv<AArch64GeneralReg, AArch64FloatReg> for AArch64Call {
) -> Result<(), String> { ) -> Result<(), String> {
Err("Returning structs not yet implemented for AArch64".to_string()) Err("Returning structs not yet implemented for AArch64".to_string())
} }
fn returns_via_arg_pointer(_ret_layout: &Layout) -> Result<bool, String> {
Err("Returning via arg pointer not yet implemented for AArch64".to_string())
}
} }
impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler { impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {

View file

@ -75,6 +75,9 @@ pub trait CallConv<GeneralReg: RegTrait, FloatReg: RegTrait> {
field_layouts: &[Layout<'a>], field_layouts: &[Layout<'a>],
ret_reg: Option<GeneralReg>, ret_reg: Option<GeneralReg>,
) -> Result<(), String>; ) -> Result<(), String>;
// returns true if the layout should be returned via an argument pointer.
fn returns_via_arg_pointer(ret_layout: &Layout) -> Result<bool, String>;
} }
/// Assembler contains calls to the backend assembly generator. /// Assembler contains calls to the backend assembly generator.

View file

@ -55,22 +55,6 @@ pub struct X86_64SystemV {}
const STACK_ALIGNMENT: u8 = 16; const STACK_ALIGNMENT: u8 = 16;
impl X86_64SystemV {
fn returns_via_arg_pointer<'a>(ret_layout: &Layout<'a>) -> Result<bool, String> {
// TODO: This may need to be more complex/extended to fully support the calling convention.
// details here: https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf
return Ok(ret_layout.stack_size(PTR_SIZE) > 16);
}
}
impl X86_64WindowsFastcall {
fn returns_via_arg_pointer<'a>(ret_layout: &Layout<'a>) -> Result<bool, String> {
// TODO: This is not fully correct there are some exceptions for "vector" types.
// details here: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-160#return-values
return Ok(ret_layout.stack_size(PTR_SIZE) > 8);
}
}
impl CallConv<X86_64GeneralReg, X86_64FloatReg> for X86_64SystemV { impl CallConv<X86_64GeneralReg, X86_64FloatReg> for X86_64SystemV {
const GENERAL_PARAM_REGS: &'static [X86_64GeneralReg] = &[ const GENERAL_PARAM_REGS: &'static [X86_64GeneralReg] = &[
X86_64GeneralReg::RDI, X86_64GeneralReg::RDI,
@ -393,6 +377,12 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg> for X86_64SystemV {
) -> Result<(), String> { ) -> Result<(), String> {
Err("Returning structs not yet implemented for X86_64".to_string()) Err("Returning structs not yet implemented for X86_64".to_string())
} }
fn returns_via_arg_pointer(ret_layout: &Layout) -> Result<bool, String> {
// TODO: This may need to be more complex/extended to fully support the calling convention.
// details here: https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf
Ok(ret_layout.stack_size(PTR_SIZE) > 16)
}
} }
impl CallConv<X86_64GeneralReg, X86_64FloatReg> for X86_64WindowsFastcall { impl CallConv<X86_64GeneralReg, X86_64FloatReg> for X86_64WindowsFastcall {
@ -707,6 +697,12 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg> for X86_64WindowsFastcall {
) -> Result<(), String> { ) -> Result<(), String> {
Err("Returning structs not yet implemented for X86_64WindowsFastCall".to_string()) Err("Returning structs not yet implemented for X86_64WindowsFastCall".to_string())
} }
fn returns_via_arg_pointer(ret_layout: &Layout) -> Result<bool, String> {
// TODO: This is not fully correct there are some exceptions for "vector" types.
// details here: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-160#return-values
Ok(ret_layout.stack_size(PTR_SIZE) > 8)
}
} }
#[inline(always)] #[inline(always)]