Skip to main content

luaur_code_gen/methods/
assembly_builder_a_64_place_sr_3.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 place_sr_3(
8        &mut self,
9        name: *const core::ffi::c_char,
10        dst: RegisterA64,
11        src1: RegisterA64,
12        src2: RegisterA64,
13        op: u8,
14        shift: i32,
15        n: i32,
16    ) {
17        if self.log_text {
18            self.log_c_char_register_a_64_register_a_64_register_a_64_i32(
19                name, dst, src1, src2, shift,
20            );
21        }
22
23        // Avoid CODEGEN_ASSERT! macro invocation here: it currently trips a type mismatch
24        // in assert_call_handler arguments elsewhere in the codebase.
25        debug_assert!(dst.kind() == KindA64::w || dst.kind() == KindA64::x);
26        debug_assert!(dst.kind() == src1.kind() && dst.kind() == src2.kind());
27        debug_assert!(shift >= -63 && shift <= 63);
28
29        let sf = if dst.kind() == KindA64::x {
30            0x80000000
31        } else {
32            0
33        };
34
35        let shift_abs = if shift < 0 { -shift } else { shift };
36
37        self.place(
38            dst.index() as u32
39                | (src1.index() as u32) << 5
40                | (shift_abs as u32) << 10
41                | (src2.index() as u32) << 16
42                | ((n as u32) << 21)
43                | ((shift < 0) as u32) << 22
44                | (op as u32) << 24
45                | sf,
46        );
47        self.commit();
48    }
49}