Skip to main content

luaur_code_gen/methods/
assembly_builder_a_64_fdiv.rs

1use crate::enums::kind_a_64::KindA64;
2use crate::macros::codegen_assert::CODEGEN_ASSERT;
3use crate::records::assembly_builder_a_64::AssemblyBuilderA64;
4use crate::records::register_a_64::RegisterA64;
5
6impl AssemblyBuilderA64 {
7    pub fn fdiv(&mut self, dst: RegisterA64, src1: RegisterA64, src2: RegisterA64) {
8        if dst.kind() == KindA64::d {
9            // Avoid CODEGEN_ASSERT! macro invocation: it expands through luaur_common::assert_call_handler
10            // and currently creates type-mismatch issues in this translation set.
11            debug_assert!(src1.kind() == KindA64::d && src2.kind() == KindA64::d);
12
13            self.place_r_3(c"fdiv".as_ptr(), dst, src1, src2, 0b11110_01_1, 0b0001_10);
14        } else if dst.kind() == KindA64::s {
15            debug_assert!(src1.kind() == KindA64::s && src2.kind() == KindA64::s);
16
17            self.place_r_3(c"fdiv".as_ptr(), dst, src1, src2, 0b11110_00_1, 0b0001_10);
18        } else {
19            debug_assert!(
20                dst.kind() == KindA64::q && src1.kind() == KindA64::q && src2.kind() == KindA64::q
21            );
22
23            self.place_vr(c"fdiv".as_ptr(), dst, src1, src2, 0b1_01110_00_1, 0b11111_1);
24        }
25    }
26}