inline Num.IsZero of gen-dev

This commit is contained in:
satotake 2021-11-22 15:08:12 +00:00 committed by GitHub
parent c9ec095741
commit 6f42ea3260
4 changed files with 87 additions and 8 deletions

View file

@ -186,6 +186,8 @@ pub trait Assembler<GeneralReg: RegTrait, FloatReg: RegTrait> {
src2: GeneralReg,
);
fn is_zero_reg64_reg64(buf: &mut Vec<'_, u8>, dst: GeneralReg, src: GeneralReg);
fn ret(buf: &mut Vec<'_, u8>);
}
@ -500,12 +502,7 @@ impl<
// move return value to dst.
match ret_layout {
Layout::Builtin(Builtin::Int1) => {
let dst_reg = self.claim_general_reg(dst)?;
ASM::mov_reg64_reg64(&mut self.buf, dst_reg, CC::GENERAL_RETURN_REGS[0]);
Ok(())
}
Layout::Builtin(Builtin::Int64) => {
Layout::Builtin(Builtin::Int64 | Builtin::Int1) => {
let dst_reg = self.claim_general_reg(dst)?;
ASM::mov_reg64_reg64(&mut self.buf, dst_reg, CC::GENERAL_RETURN_REGS[0]);
Ok(())
@ -899,6 +896,23 @@ impl<
}
}
fn build_num_is_zero(
&mut self,
dst: &Symbol,
src: &Symbol,
arg_layout: &Layout<'a>,
) -> Result<(), String> {
match arg_layout {
Layout::Builtin(Builtin::Int64) => {
let dst_reg = self.claim_general_reg(dst)?;
let src_reg = self.load_to_general_reg(src)?;
ASM::is_zero_reg64_reg64(&mut self.buf, dst_reg, src_reg);
Ok(())
}
x => Err(format!("NumIsZero: layout, {:?}, not implemented yet", x)),
}
}
fn create_struct(
&mut self,
sym: &Symbol,