1use num_enum::TryFromPrimitive;
4
5#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
6#[repr(u8)]
7pub enum AttrKind {
8 Alignment = 1,
10 AlwaysInline = 2,
11 ByVal = 3,
12 InlineHint = 4,
13 InReg = 5,
14 MinSize = 6,
15 Naked = 7,
16 Nest = 8,
17 NoAlias = 9,
18 NoBuiltin = 10,
19 NoCapture = 11,
20 NoDuplicate = 12,
21 NoImplicitFloat = 13,
22 NoInline = 14,
23 NonLazyBind = 15,
24 NoRedZone = 16,
25 NoReturn = 17,
26 NoUnwind = 18,
27 OptimizeForSize = 19,
28 ReadNone = 20,
29 ReadOnly = 21,
30 Returned = 22,
31 ReturnsTwice = 23,
32 SExt = 24,
33 StackAlignment = 25,
34 StackProtect = 26,
35 StackProtectReq = 27,
36 StackProtectStrong = 28,
37 StructRet = 29,
38 SanitizeAddress = 30,
39 SanitizeThread = 31,
40 SanitizeMemory = 32,
41 UwTable = 33,
42 ZExt = 34,
43 Builtin = 35,
44 Cold = 36,
45 OptimizeNone = 37,
46 InAlloca = 38,
47 NonNull = 39,
48 JumpTable = 40,
49 Dereferenceable = 41,
50 DereferenceableOrNull = 42,
51 Convergent = 43,
52 Safestack = 44,
53 ArgMemOnly = 45,
55 SwiftSelf = 46,
56 SwiftError = 47,
57 NoRecurse = 48,
58 InaccessibleMemOnly = 49,
60 InaccessiblememOrArgMemOnly = 50,
62 AllocSize = 51,
63 Writeonly = 52,
64 Speculatable = 53,
65 StrictFp = 54,
66 SanitizeHwaddress = 55,
67 NocfCheck = 56,
68 OptForFuzzing = 57,
69 Shadowcallstack = 58,
70 SpeculativeLoadHardening = 59,
71 Immarg = 60,
72 Willreturn = 61,
73 Nofree = 62,
74 Nosync = 63,
75 SanitizeMemtag = 64,
76 Preallocated = 65,
77 NoMerge = 66,
78 NullPointerIsValid = 67,
79 Noundef = 68,
80 Byref = 69,
81 Mustprogress = 70,
82 NoCallback = 71,
83 Hot = 72,
84 NoProfile = 73,
85 VscaleRange = 74,
86 SwiftAsync = 75,
87 NoSanitizeCoverage = 76,
88 Elementtype = 77,
89 DisableSanitizerInstrumentation = 78,
90 NoSanitizeBounds = 79,
91 AllocAlign = 80,
92 AllocatedPointer = 81,
93 AllocKind = 82,
94 PresplitCoroutine = 83,
95 FnretthunkExtern = 84,
96 SkipProfile = 85,
97 Memory = 86,
98 Nofpclass = 87,
99 OptimizeForDebugging = 88,
100 Writable = 89,
101 CoroOnlyDestroyWhenComplete = 90,
102 DeadOnUnwind = 91,
103 Range = 92,
104 SanitizeNumericalStability = 93,
105 Initializes = 94,
106 HybridPatchable = 95,
107}
108
109#[derive(Debug, TryFromPrimitive)]
112#[repr(u8)]
113pub enum CastOpcode {
114 Trunc = 0,
115 ZExt = 1,
116 SExt = 2,
117 FpToUi = 3,
118 FpToSi = 4,
119 UiToFp = 5,
120 SiToFp = 6,
121 FpTrunc = 7,
122 FpExt = 8,
123 PtrToInt = 9,
124 IntToPtr = 10,
125 Bitcast = 11,
126 Addrspace = 12,
127}
128
129#[derive(Debug, TryFromPrimitive)]
130#[repr(u8)]
131pub enum Linkage {
132 External = 0,
133 Weak = 1,
134 Appending = 2,
135 Internal = 3,
136 Linkonce = 4,
137 Dllimport = 5,
138 Dllexport = 6,
139 ExternWeak = 7,
140 Common = 8,
141 Private = 9,
142 WeakOdr = 10,
143 LinkonceOdr = 11,
144 AvailableExternally = 12,
145 Deprecated1 = 13,
146 Deprecated2 = 14,
147}
148
149#[derive(Debug, TryFromPrimitive)]
150#[repr(u8)]
151pub enum DllStorageClass {
152 Default = 0,
153 Import = 1,
154 Export = 2,
155}
156
157#[derive(Debug, TryFromPrimitive)]
158#[repr(u8)]
159pub enum CallConv {
160 C = 0,
161 Fast = 8,
162 Cold = 9,
163 GHC = 10,
164 HiPE = 11,
165 AnyReg = 13,
166 PreserveMost = 14,
167 PreserveAll = 15,
168 Swift = 16,
169 CxxFastTls = 17,
171 Tail = 18,
172 CFGuardCheck = 19,
174 SwiftTail = 20,
175 PreserveNone = 21,
176 X86StdCall = 64,
178 X86FastCall = 65,
180 ArmApcs = 66,
182 ArmAapcs = 67,
184 ArmAapcsVfp = 68,
186 Msp430Intr = 69,
188 X86ThisCall = 70,
190 PTXKernel = 71,
192 PTXDevice = 72,
194 SpirFunc = 75,
196 SpirKernel = 76,
198 IntelOclBi = 77,
200 X8664SysV = 78,
202 Win64 = 79,
204 X86VectorCall = 80,
206 DummyHhvm = 81,
208 DummyHhvmC = 82,
210 X86Intr = 83,
212 AvrIntr = 84,
214 AvrSignal = 85,
216 AvrBuiltin = 86,
218 AmdGpuVs = 87,
220 AmdGpuGs = 88,
222 AmdGpuPs = 89,
224 AmdGpuCs = 90,
226 AmdGpuKernel = 91,
228 X86RegCall = 92,
230 AmdGpuHs = 93,
232 Msp430Builtin = 94,
234 AmdGpuLs = 95,
236 AmdGpuEs = 96,
238 AArch64VectorCall = 97,
240 AArch64SVEVectorCall = 98,
242 WasmEmscriptenInvoke = 99,
244 AmdGpuGfx = 100,
246 M68kIntr = 101,
248 AArch64SmeAbiSupportRoutinesPreserveMostFromX0 = 102,
249 AArch64SmeAbiSupportRoutinesPreserveMostFromX2 = 103,
250 AmdGpuCSChain = 104,
251 AmdGpuCSChainPreserve = 105,
252 M68kRTD = 106,
253 Graal = 107,
254 Arm64ECThunkX64 = 108,
255 Arm64ECThunkNative = 109,
256 RiscVVectorCall = 110,
257 AArch64SmeAbiSupportRoutinesPreserveMostFromX1 = 111,
258}
259
260impl CallConv {
262 pub fn from_flags(ccinfo_flags: u64) -> Result<Self, String> {
263 let id = u8::try_from((ccinfo_flags & 0x7ff) >> 1).map_err(|e| e.to_string())?;
265 Self::try_from_primitive(id).map_err(|e| e.to_string())
266 }
267}
268
269#[derive(Debug, TryFromPrimitive)]
272#[repr(u8)]
273pub enum BinOpcode {
274 Add = 0,
275 Sub = 1,
276 Mul = 2,
277 Udiv = 3,
278 Sdiv = 4,
280 Urem = 5,
281 Srem = 6,
283 Shl = 7,
284 Lshr = 8,
285 Ashr = 9,
286 And = 10,
287 Or = 11,
288 Xor = 12,
289}
290
291#[derive(Debug, TryFromPrimitive, Default)]
293#[repr(u8)]
294pub enum AtomicOrdering {
295 #[default]
296 Notatomic = 0,
297 Unordered = 1,
298 Monotonic = 2,
299 Acquire = 3,
300 Release = 4,
301 AcqRel = 5,
302 SeqCst = 6,
303}
304
305#[derive(Debug, Clone, Copy, TryFromPrimitive)]
308#[repr(u8)]
309pub enum ComdatSelectionKind {
310 Any = 1,
311 ExactMatch = 2,
312 Largest = 3,
313 NoDuplicates = 4,
314 SameSize = 5,
315}
316
317#[derive(Debug, Clone, Copy, TryFromPrimitive)]
319#[repr(u8)]
320#[non_exhaustive]
321pub enum RmwOperation {
322 Xchg = 0,
324
325 Add = 1,
327
328 Sub = 2,
330
331 And = 3,
333
334 Nand = 4,
336
337 Or = 5,
339
340 Xor = 6,
342
343 Max = 7,
345
346 Min = 8,
348
349 Umax = 9,
351
352 Umin = 10,
354
355 Fadd = 11,
357
358 Fsub = 12,
360
361 Fmax = 13,
363
364 Fmin = 14,
366
367 UincWrap = 15,
369
370 UdecWrap = 16,
372
373 UsSubCond = 17,
375
376 UsSubSat = 18,
378}
379
380#[derive(Debug, Clone, Copy, TryFromPrimitive)]
382#[repr(u8)]
383#[non_exhaustive]
384pub enum UnaryOpcode {
385 Fneg = 0,
387}
388
389#[derive(Debug, Clone, Copy, TryFromPrimitive)]
392#[repr(u8)]
393#[non_exhaustive]
394pub enum OverflowingBinaryOperatorOptionalFlags {
395 NoUnsignedWrap = 0,
396 NoSignedWrap = 1,
397}
398
399#[derive(Debug, Clone, Copy, TryFromPrimitive)]
402#[repr(u8)]
403#[non_exhaustive]
404pub enum TruncInstOptionalFlags {
405 NoUnsignedWrap = 0,
406 NoSignedWrap = 1,
407}
408
409#[derive(Debug, Clone, Copy, TryFromPrimitive)]
413#[repr(u8)]
414pub enum FastMathMap {
415 UnsafeAlgebra = 1 << 0, NoNaNs = 1 << 1,
417 NoInfs = 1 << 2,
418 NoSignedZeros = 1 << 3,
419 AllowReciprocal = 1 << 4,
420 AllowContract = 1 << 5,
421 ApproxFunc = 1 << 6,
422 AllowReassoc = 1 << 7,
423}
424
425#[derive(Debug, Clone, Copy, TryFromPrimitive)]
428#[repr(u8)]
429#[non_exhaustive]
430pub enum GetElementPtrOptionalFlags {
431 Inbounds = 0,
432 Nusw = 1,
433 Nuw = 2,
434}
435
436#[derive(Debug, Clone, Copy, TryFromPrimitive)]
438#[repr(u8)]
439#[non_exhaustive]
440pub enum CallMarkersFlags {
441 Tail = 0,
442 Cconv = 1,
443 MustTail = 14,
444 ExplicitType = 15,
445 NoTail = 16,
446 Fmf = 17, }