luaur_code_gen/methods/
assembly_builder_a_64_place_cs.rs1use crate::enums::condition_a_64::ConditionA64;
2use crate::enums::kind_a_64::KindA64;
3use crate::macros::codegen_assert::CODEGEN_ASSERT;
4use crate::records::assembly_builder_a_64::AssemblyBuilderA64;
5use crate::records::register_a_64::RegisterA64;
6
7impl AssemblyBuilderA64 {
8 pub fn place_cs(
9 &mut self,
10 name: *const core::ffi::c_char,
11 dst: RegisterA64,
12 src1: RegisterA64,
13 src2: RegisterA64,
14 cond: ConditionA64,
15 op: u8,
16 opc: u8,
17 invert: i32,
18 ) {
19 if self.log_text {
20 self.log_c_char_register_a_64_register_a_64_register_a_64_condition_a_64(
21 name, dst, src1, src2, cond,
22 );
23 }
24
25 debug_assert!(dst.kind() == src1.kind() && dst.kind() == src2.kind());
28
29 let sf = if dst.kind() == KindA64::x {
30 0x80000000
31 } else {
32 0
33 };
34
35 let code_for_condition = [
36 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
37 ];
38
39 let cond_val = code_for_condition[cond as usize] as u32;
40
41 self.place(
42 (dst.index() as u32)
43 | ((src1.index() as u32) << 5)
44 | ((opc as u32) << 10)
45 | ((cond_val ^ (invert as u32)) << 12)
46 | ((src2.index() as u32) << 16)
47 | ((op as u32) << 21)
48 | sf,
49 );
50 self.commit();
51 }
52}