Skip to main content

luaur_code_gen/records/
ir_block.rs

1use crate::enums::ir_block_kind::IrBlockKind;
2use crate::records::label::Label;
3
4pub const kBlockNoStartPc: u32 = !0u32;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7#[repr(C)]
8pub struct IrBlock {
9    pub kind: IrBlockKind,
10    pub flags: u8,
11    pub use_count: u16,
12
13    /// 'start' and 'finish' define an inclusive range of instructions which belong to this block inside the function
14    /// When block has been constructed, 'finish' always points to the first and only terminating instruction
15    pub start: u32,
16    pub finish: u32,
17
18    pub sortkey: u32,
19    pub chainkey: u32,
20    pub expected_next_block: u32,
21
22    /// Bytecode PC position at which the block was generated
23    pub startpc: u32,
24
25    pub label: Label,
26}
27
28impl Default for IrBlock {
29    fn default() -> Self {
30        Self {
31            kind: IrBlockKind::Dead,
32            flags: 0,
33            use_count: 0,
34            start: !0u32,
35            finish: !0u32,
36            sortkey: !0u32,
37            chainkey: 0,
38            expected_next_block: !0u32,
39            startpc: kBlockNoStartPc,
40            label: Label {
41                id: 0,
42                location: !0u32,
43            },
44        }
45    }
46}