Skip to main content

asmkit/core/
globals.rs

1use bitflags::bitflags;
2
3pub const ALLOC_OVERHEAD: u32 = core::mem::size_of::<usize>() as u32 * 4;
4pub const ALLOC_ALIGNMENT: u32 = 8;
5pub const GROW_THRESHOLD: u32 = 1024 * 1024 * 16;
6pub const MAX_TREE_HEIGHT: u32 = if cfg!(target_pointer_width = "32") {
7    30
8} else {
9    61
10} + 1;
11pub const MAX_OP_COUNT: usize = 6;
12pub const MAX_FUNC_ARGS: u32 = 32;
13pub const MAX_VALUE_PACK: u32 = 4;
14pub const MAX_PHYS_REGS: u32 = 32;
15pub const MAX_ALIGNMENT: u32 = 64;
16pub const MAX_LABEL_NAME_SIZE: u32 = 2048;
17pub const MAX_SECTION_NAME_SIZE: u32 = 35;
18pub const MAX_COMMENT_SIZE: u32 = 1024;
19pub const INVALID_ID: u32 = 0xFFFFFFFFu32;
20pub const NOT_FOUND: u32 = 0xFFFFFFFFu32;
21pub const NO_BASE_ADDRESS: u64 = !0u64;
22pub const NUM_VIRT_GROUPS: usize = 4;
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum CondCode {
26    /// (no condition code) (always)
27    AL = 0x00,
28    /// (not available)     (special)
29    NA = 0x01,
30    ///        Z==1         (any_sign ==)
31    EQ = 0x02,
32    ///        Z==0         (any_sign !=)
33    NE = 0x03,
34    /// C==1                (unsigned >=)
35    CS = 0x04,
36
37    /// C==0                (unsigned < )
38    LO = 0x05,
39
40    ///               N==1  (is negative)
41    MI = 0x06,
42    ///               N==0  (is positive or zero)
43    PL = 0x07,
44    ///               V==1  (is overflow)
45    VS = 0x08,
46    ///               V==0  (no overflow)
47    VC = 0x09,
48    /// C==1 & Z==0         (unsigned > )
49    HI = 0x0A,
50    /// C==0 | Z==1         (unsigned <=)
51    LS = 0x0B,
52    ///               N==V  (signed   >=)
53    GE = 0x0C,
54    ///               N!=V  (signed   < )
55    LT = 0x0D,
56    ///        Z==0 & N==V  (signed   > )
57    GT = 0x0E,
58    ///        Z==1 | N!=V  (signed   <=)
59    LE = 0x0F,
60}
61impl CondCode {
62    pub const MAX_VALUE: Self = Self::LE;
63    pub const CC: Self = Self::LO;
64    pub const HS: Self = Self::CS;
65}
66
67bitflags! {
68    pub struct InstOptions: u32 {
69        const NONE = 0;
70        const RESERVED =  0x00000001;
71        const UNFOLLOW = 0x00000002;
72        const OVERWRITE = 0x00000004;
73        const SHORT_FORM = 0x00000010;
74        const LONG_FORM = 0x00000020;
75        const TAKEN = 0x00000040;
76        const NOT_TAKEN = 0x00000080;
77    }
78}