1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
use crate::cdsl::operands::{EnumValues, OperandKind, OperandKindFields};
use std::collections::HashMap;
pub(crate) struct Immediates {
pub imm64: OperandKind,
pub uimm8: OperandKind,
pub uimm32: OperandKind,
pub uimm128: OperandKind,
pub pool_constant: OperandKind,
pub offset32: OperandKind,
pub ieee32: OperandKind,
pub ieee64: OperandKind,
pub boolean: OperandKind,
pub intcc: OperandKind,
pub floatcc: OperandKind,
pub memflags: OperandKind,
pub regunit: OperandKind,
pub trapcode: OperandKind,
}
fn new_imm(format_field_name: &'static str, rust_type: &'static str) -> OperandKind {
OperandKind::new(format_field_name, rust_type, OperandKindFields::ImmValue)
}
fn new_enum(
format_field_name: &'static str,
rust_type: &'static str,
values: EnumValues,
) -> OperandKind {
OperandKind::new(
format_field_name,
rust_type,
OperandKindFields::ImmEnum(values),
)
}
impl Immediates {
pub fn new() -> Self {
Self {
imm64: new_imm("imm", "ir::immediates::Imm64").with_doc("A 64-bit immediate integer."),
uimm8: new_imm("imm", "ir::immediates::Uimm8")
.with_doc("An 8-bit immediate unsigned integer."),
uimm32: new_imm("imm", "ir::immediates::Uimm32")
.with_doc("A 32-bit immediate unsigned integer."),
uimm128: new_imm("imm", "ir::Immediate")
.with_doc("A 128-bit immediate unsigned integer."),
pool_constant: new_imm("constant_handle", "ir::Constant")
.with_doc("A constant stored in the constant pool."),
offset32: new_imm("offset", "ir::immediates::Offset32")
.with_doc("A 32-bit immediate signed offset."),
ieee32: new_imm("imm", "ir::immediates::Ieee32")
.with_doc("A 32-bit immediate floating point number."),
ieee64: new_imm("imm", "ir::immediates::Ieee64")
.with_doc("A 64-bit immediate floating point number."),
boolean: new_imm("imm", "bool").with_doc("An immediate boolean."),
intcc: {
let mut intcc_values = HashMap::new();
intcc_values.insert("eq", "Equal");
intcc_values.insert("ne", "NotEqual");
intcc_values.insert("sge", "SignedGreaterThanOrEqual");
intcc_values.insert("sgt", "SignedGreaterThan");
intcc_values.insert("sle", "SignedLessThanOrEqual");
intcc_values.insert("slt", "SignedLessThan");
intcc_values.insert("uge", "UnsignedGreaterThanOrEqual");
intcc_values.insert("ugt", "UnsignedGreaterThan");
intcc_values.insert("ule", "UnsignedLessThanOrEqual");
intcc_values.insert("ult", "UnsignedLessThan");
intcc_values.insert("of", "Overflow");
intcc_values.insert("nof", "NotOverflow");
new_enum("cond", "ir::condcodes::IntCC", intcc_values)
.with_doc("An integer comparison condition code.")
},
floatcc: {
let mut floatcc_values = HashMap::new();
floatcc_values.insert("ord", "Ordered");
floatcc_values.insert("uno", "Unordered");
floatcc_values.insert("eq", "Equal");
floatcc_values.insert("ne", "NotEqual");
floatcc_values.insert("one", "OrderedNotEqual");
floatcc_values.insert("ueq", "UnorderedOrEqual");
floatcc_values.insert("lt", "LessThan");
floatcc_values.insert("le", "LessThanOrEqual");
floatcc_values.insert("gt", "GreaterThan");
floatcc_values.insert("ge", "GreaterThanOrEqual");
floatcc_values.insert("ult", "UnorderedOrLessThan");
floatcc_values.insert("ule", "UnorderedOrLessThanOrEqual");
floatcc_values.insert("ugt", "UnorderedOrGreaterThan");
floatcc_values.insert("uge", "UnorderedOrGreaterThanOrEqual");
new_enum("cond", "ir::condcodes::FloatCC", floatcc_values)
.with_doc("A floating point comparison condition code")
},
memflags: new_imm("flags", "ir::MemFlags").with_doc("Memory operation flags"),
regunit: new_imm("regunit", "isa::RegUnit")
.with_doc("A register unit in the target ISA"),
trapcode: {
let mut trapcode_values = HashMap::new();
trapcode_values.insert("stk_ovf", "StackOverflow");
trapcode_values.insert("heap_oob", "HeapOutOfBounds");
trapcode_values.insert("int_ovf", "IntegerOverflow");
trapcode_values.insert("int_divz", "IntegerDivisionByZero");
new_enum("code", "ir::TrapCode", trapcode_values).with_doc("A trap reason code.")
},
}
}
}