Skip to main content

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