Skip to main content

llvm_bitcode/schema/
dwarf.rs

1use num_enum::TryFromPrimitive;
2
3/// DWARF language identifiers
4///
5/// `dwarf::SourceLanguage` in LLVM's `Dwarf.h`
6#[derive(Debug, Copy, Clone, Eq, PartialEq, TryFromPrimitive)]
7#[repr(u32)]
8#[non_exhaustive]
9pub enum SourceLanguage {
10    C89 = 0x0001,
11    C = 0x0002,
12    Ada83 = 0x0003,
13    Cpp = 0x0004,
14    Cobol74 = 0x0005,
15    Cobol85 = 0x0006,
16    Fortran77 = 0x0007,
17    Fortran90 = 0x0008,
18    Pascal83 = 0x0009,
19    Modula2 = 0x000a,
20    Java = 0x000b,
21    C99 = 0x000c,
22    Ada95 = 0x000d,
23    Fortran95 = 0x000e,
24    PLI = 0x000f,
25    ObjC = 0x0010,
26    ObjCpp = 0x0011,
27    UPC = 0x0012,
28    D = 0x0013,
29    Python = 0x0014,
30    OpenCL = 0x0015,
31    Go = 0x0016,
32    Modula3 = 0x0017,
33    Haskell = 0x0018,
34    Cpp03 = 0x0019,
35    Cpp11 = 0x001a,
36    OCaml = 0x001b,
37    Rust = 0x001c,
38    C11 = 0x001d,
39    Swift = 0x001e,
40    Julia = 0x001f,
41    Dylan = 0x0020,
42    Cpp14 = 0x0021,
43    Fortran03 = 0x0022,
44    Fortran08 = 0x0023,
45    RenderScript = 0x0024,
46    BLISS = 0x0025,
47    Kotlin = 0x0026,
48    Zig = 0x0027,
49    Crystal = 0x0028,
50    Cpp17 = 0x002a,
51    Cpp20 = 0x002b,
52    C17 = 0x002c,
53    Fortran18 = 0x002d,
54    Ada2005 = 0x002e,
55    Ada2012 = 0x002f,
56    HIP = 0x0030,
57    Assembly = 0x0031,
58    CSharp = 0x0032,
59    Mojo = 0x0033,
60    GLSL = 0x0034,
61    GLSLES = 0x0035,
62    HLSL = 0x0036,
63    OpenCLCpp = 0x0037,
64    CppForOpenCL = 0x0038,
65    SYCL = 0x0039,
66    Metal = 0x003d,
67    Ruby = 0x0040,
68    Move = 0x0041,
69    Hylo = 0x0042,
70}
71
72/// DWARF type encoding values (`DW_ATE_*`)
73#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, TryFromPrimitive)]
74#[repr(u8)]
75#[non_exhaustive]
76pub enum DwarfEncoding {
77    #[default]
78    None = 0x00,
79    Address = 0x01,
80    Boolean = 0x02,
81    ComplexFloat = 0x03,
82    Float = 0x04,
83    Signed = 0x05,
84    SignedChar = 0x06,
85    Unsigned = 0x07,
86    UnsignedChar = 0x08,
87    ImaginaryFloat = 0x09,
88    PackedDecimal = 0x0a,
89    NumericString = 0x0b,
90    Edited = 0x0c,
91    SignedFixed = 0x0d,
92    UnsignedFixed = 0x0e,
93    DecimalFloat = 0x0f,
94    UTF = 0x10,
95    UCS = 0x11,
96    ASCII = 0x12,
97}
98
99/// DWARF tag values (`DW_TAG_*`)
100#[derive(Debug, Copy, Clone, Eq, PartialEq, TryFromPrimitive)]
101#[repr(u16)]
102#[non_exhaustive]
103pub enum DwarfTag {
104    Null = 0x0000,
105    ArrayType = 0x0001,
106    ClassType = 0x0002,
107    EntryPoint = 0x0003,
108    EnumerationType = 0x0004,
109    FormalParameter = 0x0005,
110    ImportedDeclaration = 0x0008,
111    Label = 0x000a,
112    LexicalBlock = 0x000b,
113    Member = 0x000d,
114    PointerType = 0x000f,
115    ReferenceType = 0x0010,
116    CompileUnit = 0x0011,
117    StringType = 0x0012,
118    StructureType = 0x0013,
119    SubroutineType = 0x0015,
120    Typedef = 0x0016,
121    UnionType = 0x0017,
122    UnspecifiedParameters = 0x0018,
123    Variant = 0x0019,
124    CommonBlock = 0x001a,
125    CommonInclusion = 0x001b,
126    Inheritance = 0x001c,
127    InlinedSubroutine = 0x001d,
128    Module = 0x001e,
129    PtrToMemberType = 0x001f,
130    SetType = 0x0020,
131    SubrangeType = 0x0021,
132    WithStmt = 0x0022,
133    AccessDeclaration = 0x0023,
134    BaseType = 0x0024,
135    CatchBlock = 0x0025,
136    ConstType = 0x0026,
137    Constant = 0x0027,
138    Enumerator = 0x0028,
139    FileType = 0x0029,
140    Friend = 0x002a,
141    Namelist = 0x002b,
142    NamelistItem = 0x002c,
143    PackedType = 0x002d,
144    Subprogram = 0x002e,
145    TemplateTypeParameter = 0x002f,
146    TemplateValueParameter = 0x0030,
147    ThrownType = 0x0031,
148    TryBlock = 0x0032,
149    VariantPart = 0x0033,
150    Variable = 0x0034,
151    VolatileType = 0x0035,
152    DwarfProcedure = 0x0036,
153    RestrictType = 0x0037,
154    InterfaceType = 0x0038,
155    Namespace = 0x0039,
156    ImportedModule = 0x003a,
157    UnspecifiedType = 0x003b,
158    PartialUnit = 0x003c,
159    ImportedUnit = 0x003d,
160    Condition = 0x003f,
161    SharedType = 0x0040,
162    TypeUnit = 0x0041,
163    RvalueReferenceType = 0x0042,
164    TemplateAlias = 0x0043,
165    CoarrayType = 0x0044,
166    GenericSubrange = 0x0045,
167    DynamicType = 0x0046,
168    AtomicType = 0x0047,
169    CallSite = 0x0048,
170    CallSiteParameter = 0x0049,
171    SkeletonUnit = 0x004a,
172    ImmutableType = 0x004b,
173}
174
175// `DW_CC_*`
176#[derive(Debug, Copy, Clone, Eq, PartialEq, TryFromPrimitive)]
177#[repr(u8)]
178#[non_exhaustive]
179pub enum DwarfCallConv {
180    Normal = 0x01,
181    Program = 0x02,
182    NoCall = 0x03,
183    // New in DWARF v5:
184    PassByReference = 0x04,
185    PassByValue = 0x05,
186    // Vendor extensions:
187    GnuRenesasSh = 0x40,
188    GnuBorlandFastcalli386 = 0x41,
189    BorlandSafecall = 0xb0,
190    BorlandStdcall = 0xb1,
191    BorlandPascal = 0xb2,
192    BorlandMsfastcall = 0xb3,
193    BorlandMsreturn = 0xb4,
194    BorlandThiscall = 0xb5,
195    BorlandFastcall = 0xb6,
196    LlvmVectorcall = 0xc0,
197    LlvmWin64 = 0xc1,
198    LlvmX8664SysV = 0xc2,
199    LlvmAapcs = 0xc3,
200    LlvmAapcsVfp = 0xc4,
201    LlvmIntelOclBicc = 0xc5,
202    LlvmSpirFunction = 0xc6,
203    LlvmDeviceKernel = 0xc7,
204    LlvmSwift = 0xc8,
205    LlvmPreserveMost = 0xc9,
206    LlvmPreserveAll = 0xca,
207    LlvmX86RegCall = 0xcb,
208    LlvmM68kRtd = 0xcc,
209    LlvmPreserveNone = 0xcd,
210    LlvmRiscVVectorCall = 0xce,
211    LlvmSwiftTail = 0xcf,
212    LlvmRiscVVlsCall = 0xd0,
213}