Skip to main content

llvm_bitcode/schema/
blocks.rs

1//! From the LLVM Project, under the [Apache License v2.0 with LLVM Exceptions](https://llvm.org/LICENSE.txt)
2
3use num_enum::TryFromPrimitive;
4
5/// Block IDs
6///
7/// The only top-level block types are MODULE, IDENTIFICATION, STRTAB and SYMTAB.
8#[derive(Debug, Copy, Clone, PartialEq, Hash, TryFromPrimitive)]
9#[repr(u8)]
10#[non_exhaustive]
11pub enum BlockId {
12    /// `MODULE`
13    Module = 8,
14
15    // Module sub-block IDs
16    /// `PARAMATTR`
17    ///
18    /// See [`AttributeCode`]
19    ParamAttr,
20
21    /// `PARAMATTR_GROUP`
22    ParamAttrGroup,
23
24    /// `CONSTANTS`
25    Constants,
26
27    /// `FUNCTION`
28    Function,
29
30    /// Obsolete.
31    ///
32    /// Block intended to contain information on the bitcode versioning. Can be
33    /// used to provide better error messages when we fail to parse a bitcode file.
34    Identification,
35
36    /// `VALUE_SYMTAB`
37    ValueSymtab,
38
39    /// `METADATA`
40    Metadata,
41
42    /// `METADATA_ATTACHMENT_ID`
43    MetadataAttachment,
44
45    /// `TYPE_BLOCK_ID_NEW = 17`
46    Type = 17,
47
48    /// `USELIST`
49    Uselist,
50
51    /// `MODULE_STRTAB`
52    ModuleStrtab,
53
54    /// Obsolete.
55    ///
56    /// `GLOBALVAL_SUMMARY`
57    #[deprecated]
58    GlobalvalSummary,
59
60    /// `OPERAND_BUNDLE_TAGS`
61    OperandBundleTags,
62
63    /// `METADATA_KIND`
64    MetadataKind,
65
66    /// `STRTAB`
67    Strtab,
68
69    /// `FULL_LTO_GLOBALVAL_SUMMARY`
70    FullLtoGlobalvalSummary,
71
72    /// `SYMTAB`
73    Symtab,
74
75    /// `SYNC_SCOPE_NAMES`
76    SyncScopeNames,
77}
78
79/// `OperandBundle` tag codes
80#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
81#[repr(u8)]
82#[non_exhaustive]
83pub enum OperandBundleTagCode {
84    /// `TAG`
85    ///
86    /// [strchr x N]
87    Tag = 1,
88}
89
90/// Sync scope name codes
91#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
92#[repr(u8)]
93#[non_exhaustive]
94pub enum SyncScopeNameCode {
95    /// `SYNC_SCOPE_NAME`
96    Name = 1,
97}
98
99/// STRTAB block codes
100#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
101#[repr(u8)]
102#[non_exhaustive]
103pub enum StrtabCode {
104    /// `STRTAB_BLOB`
105    Blob = 1,
106}
107
108/// SYMTAB block codes
109#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
110#[repr(u8)]
111#[non_exhaustive]
112pub enum SymtabCode {
113    /// `SYMTAB_BLOB`
114    Blob = 1,
115}
116
117/// `MODULE` blocks have a number of optional fields and subblocks.
118#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
119#[repr(u8)]
120#[non_exhaustive]
121pub enum ModuleCode {
122    /// `VERSION`
123    ///
124    /// [version#]
125    Version = 1,
126
127    /// `TRIPLE`
128    ///
129    /// [strchr x N]
130    Triple = 2,
131
132    /// `DATALAYOUT`
133    ///
134    /// [strchr x N]
135    Datalayout = 3,
136
137    /// `ASM`
138    ///
139    /// [strchr x N]
140    Asm = 4,
141
142    /// `SECTIONNAME`
143    ///
144    /// [strchr x N]
145    SectionName = 5,
146
147    /// Obsolete.
148    ///
149    /// `DEPLIB`
150    ///
151    /// [strchr x N]
152    #[deprecated]
153    Deplib = 6,
154
155    /// `GLOBALVAR`
156    ///
157    /// [pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal]
158    GlobalVar = 7,
159
160    /// `FUNCTION`
161    ///
162    /// [type, callingconv, isproto, linkage, paramattrs, alignment, section, visibility, gc, unnamed_addr]
163    Function = 8,
164
165    /// Obsolete alias record; replaced by `MODULE_CODE_ALIAS`
166    ///
167    /// `ALIAS`
168    ///
169    /// [alias type, aliasee val#, linkage, visibility]
170    #[deprecated]
171    AliasOld = 9,
172
173    /// `GCNAME`
174    ///
175    /// [strchr x N]
176    GCName = 11,
177
178    /// `COMDAT`
179    ///
180    /// [selection_kind, name]
181    Comdat = 12,
182
183    /// `VSTOFFSET`
184    ///
185    /// [offset]
186    VstOffset = 13,
187
188    /// `ALIAS`
189    ///
190    /// `[strtab_offset, strtab_size, alias_type, addrspace,  aliasee_val#, linkage, visibility, dllstorageclass,  threadlocal, unnamed_addr, preemption_specifier,  (partition_offset, partition_size)?]`
191    Alias = 14,
192
193    /// Obsolete.
194    #[deprecated]
195    MetadataValuesUnused = 15,
196
197    /// `SOURCE_FILENAME`
198    ///
199    /// [namechar x N]
200    SourceFilename = 16,
201
202    /// `HASH`
203    ///
204    /// [5*i32]
205    Hash = 17,
206
207    /// `IFUNC`
208    ///
209    /// [ifunc value type, addrspace, resolver val#, linkage, visibility]
210    Ifunc = 18,
211
212    /// `ASM_PROPERTY`
213    ///
214    /// [strchr x N]
215    AsmProperty = 19,
216
217    /// `GUIDLIST`
218    ///
219    /// [n x i64]
220    GuidList = 20,
221}
222
223/// The summary section uses different codes in the per-module
224/// and combined index cases.
225#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
226#[repr(u8)]
227#[non_exhaustive]
228pub enum GlobalValueSummaryCode {
229    /// `PERMODULE`
230    ///
231    /// [valueid, flags, instcount, numrefs, numrefs x valueid, n x (valueid)]
232    PerModule = 1,
233
234    /// `PERMODULE_PROFILE`
235    ///
236    /// [valueid, flags, instcount, numrefs, numrefs x valueid, n x (valueid, hotness+tailcall)]
237    PerModuleProfile = 2,
238
239    /// `PERMODULE_GLOBALVAR_INIT_REFS`
240    ///
241    /// [valueid, flags, n x valueid]
242    PerModuleGlobalvarInitRefs = 3,
243
244    /// `COMBINED`
245    ///
246    /// [valueid, modid, flags, instcount, numrefs, numrefs x valueid, n x (valueid)]
247    Combined = 4,
248
249    /// `COMBINED_PROFILE`
250    ///
251    /// [valueid, modid, flags, instcount, numrefs, numrefs x valueid, n x (valueid, hotness+tailcall)]
252    CombinedProfile = 5,
253
254    /// `COMBINED_GLOBALVAR_INIT_REFS`
255    ///
256    /// [valueid, modid, flags, n x valueid]
257    CombinedGlobalvarInitRefs = 6,
258
259    /// `ALIAS`
260    ///
261    /// [valueid, flags, valueid]
262    Alias = 7,
263
264    /// `COMBINED_ALIAS`
265    ///
266    /// [valueid, modid, flags, valueid]
267    CombinedAlias = 8,
268
269    /// `COMBINED_ORIGINAL_NAME`
270    ///
271    /// [original_name_hash]
272    CombinedOriginalName = 9,
273
274    /// `VERSION` of the summary, bumped when adding flags for instance.
275    Version = 10,
276
277    /// The list of `llvm.type.test` type identifiers used by the following function that are used
278    /// other than by an `llvm.assume`.
279    ///
280    /// [n x typeid]
281    TypeTests = 11,
282
283    /// The list of virtual calls made by this function using `llvm.assume(llvm.type.test)` intrinsics
284    /// that do not have all constant integer arguments.
285    ///
286    /// [n x (typeid, offset)]
287    TypeTestAssumeVCalls = 12,
288
289    /// The list of virtual calls made by this function using `llvm.type.checked.load` intrinsics
290    /// that do not have all constant integer arguments.
291    ///
292    /// [n x (typeid, offset)]
293    TypeCheckedLoadVCalls = 13,
294
295    /// Identifies a virtual call made by this function using an `llvm.assume(llvm.type.test)`
296    /// intrinsic with all constant integer arguments.
297    ///
298    /// [typeid, offset, n x arg]
299    TypeTestAssumeConstVCall = 14,
300
301    /// Identifies a virtual call made by this function using an `llvm.type.checked.load` intrinsic
302    /// with all constant integer arguments.
303    ///
304    /// [typeid, offset, n x arg]
305    TypeCheckedLoadConstVCall = 15,
306
307    /// Assigns a GUID to a value ID. This normally appears only in combined summaries,
308    /// but it can also appear in per-module summaries for PGO data.
309    ///
310    /// [valueid, guid]
311    ValueGuid = 16,
312
313    /// The list of local functions with CFI jump tables. Function names are strings in `strtab`.
314    ///
315    /// [n * name]
316    CfiFunctionDefs = 17,
317
318    /// The list of external functions with CFI jump tables. Function names are strings in `strtab`.
319    ///
320    /// [n * name]
321    CfiFunctionDecls = 18,
322
323    /// Per-module summary that also adds relative block frequency to callee info.
324    ///
325    /// `PERMODULE_RELBF`
326    ///
327    /// [valueid, flags, instcount, numrefs, numrefs x valueid, n x (valueid, relblockfreq+tailcall)]
328    PerModuleRelBf = 19,
329
330    /// Index-wide flags
331    Flags = 20,
332
333    /// Maps type identifier to summary information for that type identifier. Produced by the thin link
334    /// (only lives in combined index).
335    ///
336    /// `TYPE_ID`
337    ///
338    /// [typeid, kind, bitwidth, align, size, bitmask, inlinebits, n x (typeid, kind, name, numrba, numrba x (numarg, numarg x arg, kind, info, byte, bit)]
339    TypeId = 21,
340
341    /// Maps type identifier to summary information for that type identifier computed from type metadata:
342    /// the valueid of each vtable definition decorated with a type metadata for that identifier,
343    /// and the offset from the corresponding type metadata.
344    /// Exists in the per-module summary to provide information to thin link for index-based whole
345    /// program devirtualization.
346    ///
347    /// For background see overview at <https://llvm.org/docs/TypeMetadata.html>.
348    /// The type metadata includes both the type identifier and the offset of
349    /// the address point of the type (the address held by objects of that type
350    /// which may not be the beginning of the virtual table). Vtable definitions
351    /// are decorated with type metadata for the types they are compatible with.
352    ///
353    /// `TYPE_ID_METADATA`
354    ///
355    /// [typeid, n x (valueid, offset)]
356    TypeIdMetadata = 22,
357
358    /// Summarizes vtable definition for use in index-based whole program devirtualization during the thin link.
359    ///
360    /// `PERMODULE_VTABLE_GLOBALVAR_INIT_REFS`
361    ///
362    /// [valueid, flags, varflags, numrefs, numrefs x valueid, n x (valueid, offset)]
363    PerModuleVtableGlobalvarInitRefs = 23,
364
365    /// The total number of basic blocks in the module.
366    ///
367    /// This is for pre-allocation of storage.
368    BlockCount = 24,
369
370    /// Range information for accessed offsets for every argument.
371    ///
372    /// [n x (paramno, range, numcalls, numcalls x (callee_guid, paramno, range))]
373    ParamAccess = 25,
374
375    /// Summary of per-module memprof callsite metadata.
376    ///
377    /// [valueid, n x stackidindex]
378    PerModuleCallsiteInfo = 26,
379
380    /// Summary of per-module allocation memprof metadata.
381    ///
382    /// [nummib, nummib x (alloc type, context radix tree index), [nummib x (numcontext x total size)]?]
383    PerModuleAllocInfo = 27,
384
385    /// Summary of combined index memprof callsite metadata.
386    ///
387    /// [valueid, context radix tree index, numver, numver x version]
388    CombinedCallsiteInfo = 28,
389
390    /// Summary of combined index allocation memprof metadata.
391    ///
392    /// [nummib, numver, nummib x (alloc type, numstackids, numstackids x stackidindex), numver x version]
393    CombinedAllocInfo = 29,
394
395    /// List of all stack ids referenced by index in the callsite and alloc infos.
396    ///
397    /// [n x stack id]
398    StackIds = 30,
399
400    /// List of all full stack id pairs corresponding to the total sizes recorded
401    /// at the end of the alloc info when reporting of hinted bytes is enabled.
402    /// We use a fixed-width array, which is more efficient as these ids typically
403    /// are close to 64 bits in size. The max fixed width value supported is 32
404    /// bits so each 64-bit context id hash is recorded as a pair (upper 32 bits
405    /// first). This record must immediately precede the associated alloc info, and
406    /// the entries must be in the exact same order as the corresponding sizes.
407    ///
408    /// [nummib x (numcontext x full stack id)]
409    AllocContextIds = 31,
410
411    /// Linearized radix tree of allocation contexts.
412    ///
413    /// [n x entry]
414    ContextRadixTreeArray = 32,
415}
416
417/// `METADATA` block codes
418#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
419#[repr(u8)]
420#[non_exhaustive]
421pub enum MetadataCode {
422    /// `MDSTRING`
423    ///
424    /// [values]
425    #[deprecated]
426    StringOld = 1,
427
428    /// `VALUE`
429    ///
430    /// [type num, value num]
431    Value = 2,
432
433    /// `NODE`
434    ///
435    /// [n x md num]
436    Node = 3,
437
438    /// `NAME` (string)
439    ///
440    /// This is before `METADATA_NAMED_NODE`
441    ///
442    /// [values]
443    Name = 4,
444
445    /// `DISTINCT_NODE`
446    ///
447    /// [n x md num]
448    DistinctNode = 5,
449
450    /// `KIND`
451    ///
452    /// [n x [id, name]]
453    Kind = 6,
454
455    /// `LOCATION`
456    ///
457    /// [distinct, line, col, scope, inlined-at?]
458    Location = 7,
459
460    /// `OLD_NODE`
461    ///
462    /// [n x (type num, value num)]
463    OldNode = 8,
464
465    /// `OLD_FN_NODE`
466    ///
467    /// [n x (type num, value num)]
468    OldFnNode = 9,
469
470    /// `NAMED_NODE`
471    ///
472    /// [n x mdnodes]
473    NamedNode = 10,
474
475    /// `ATTACHMENT`
476    ///
477    /// [m x [value, [n x [id, mdnode]]]
478    Attachment = 11,
479
480    /// `GENERIC_DEBUG`
481    ///
482    /// [distinct, tag, vers, header, n x md num]
483    GenericDebug = 12,
484
485    /// `SUBRANGE`
486    ///
487    /// [distinct, count, lo]
488    Subrange = 13,
489
490    /// `ENUMERATOR`
491    ///
492    /// [isUnsigned|distinct, value, name]
493    Enumerator = 14,
494
495    /// `BASIC_TYPE`
496    ///
497    /// [distinct, tag, name, size, align, enc]
498    BasicType = 15,
499
500    /// `FILE`
501    ///
502    /// [distinct, filename, directory, checksumkind, checksum]
503    File = 16,
504
505    /// `DERIVED_TYPE`
506    ///
507    /// [distinct, ...]
508    DerivedType = 17,
509
510    /// `COMPOSITE_TYPE`
511    ///
512    /// [distinct, ...]
513    CompositeType = 18,
514
515    /// `SUBROUTINE_TYPE`
516    ///
517    /// [distinct, flags, types, cc]
518    SubroutineType = 19,
519
520    /// `COMPILE_UNIT`
521    ///
522    /// [distinct, ...]
523    CompileUnit = 20,
524
525    /// `SUBPROGRAM`
526    ///
527    /// [distinct, ...]
528    Subprogram = 21,
529
530    /// `LEXICAL_BLOCK`
531    ///
532    /// [distinct, scope, file, line, column]
533    LexicalBlock = 22,
534
535    /// `LEXICAL_BLOCK_FILE`
536    ///
537    /// [distinct, scope, file, discriminator]
538    LexicalBlockFile = 23,
539
540    /// `NAMESPACE`
541    ///
542    /// [distinct, scope, file, name, line, exportSymbols]
543    Namespace = 24,
544
545    /// `TEMPLATE_TYPE`
546    ///
547    /// [distinct, scope, name, type, ...]
548    TemplateType = 25,
549
550    /// `TEMPLATE_VALUE`
551    ///
552    /// [distinct, scope, name, type, value, ...]
553    TemplateValue = 26,
554
555    /// `GLOBAL_VAR`
556    ///
557    /// [distinct, ...]
558    GlobalVar = 27,
559
560    /// `LOCAL_VAR`
561    ///
562    /// [distinct, ...]
563    LocalVar = 28,
564
565    /// `EXPRESSION`
566    ///
567    /// [distinct, n x element]
568    Expression = 29,
569
570    /// `OBJC_PROPERTY`
571    ///
572    /// [distinct, name, file, line, ...]
573    ObjcProperty = 30,
574
575    /// `IMPORTED_ENTITY`
576    ///
577    /// [distinct, tag, scope, entity, line, name]
578    ImportedEntity = 31,
579
580    /// `MODULE`
581    ///
582    /// [distinct, scope, name, ...]
583    Module = 32,
584
585    /// `MACRO`
586    ///
587    /// [distinct, macinfo, line, name, value]
588    Macro = 33,
589
590    /// `MACRO_FILE`
591    ///
592    /// [distinct, macinfo, line, file, ...]
593    MacroFile = 34,
594
595    /// `STRINGS`
596    ///
597    /// All the metadata strings in a metadata block are emitted in a single
598    /// record.  The sizes and strings themselves are shoved into a blob.
599    ///
600    /// [count, offset] blob([lengths][chars])
601    Strings = 35,
602
603    /// `GLOBAL_DECL_ATTACHMENT`
604    ///
605    /// [valueid, n x [id, mdnode]]
606    GlobalDeclAttachment = 36,
607
608    /// `GLOBAL_VAR_EXPR`
609    ///
610    /// [distinct, var, expr]
611    GlobalVarExpr = 37,
612
613    /// `INDEX_OFFSET`
614    ///
615    /// [offset]
616    IndexOffset = 38,
617
618    /// `INDEX`
619    ///
620    /// [bitpos]
621    Index = 39,
622
623    /// `LABEL`
624    ///
625    /// [distinct, scope, name, file, line]
626    Label = 40,
627
628    /// `STRING_TYPE`
629    ///
630    /// [distinct, name, size, align, ..]
631    StringType = 41,
632
633    /// `COMMON_BLOCK`
634    ///
635    /// [distinct, scope, name, variable, ..]
636    CommonBlock = 44,
637
638    /// `GENERIC_SUBRANGE`
639    ///
640    /// [distinct, count, lo, up, stride]
641    GenericSubrange = 45,
642
643    /// `ARG_LIST`
644    ///
645    /// [n x [type num, value num]]
646    ArgList = 46,
647
648    /// `ASSIGN_ID`
649    ///
650    /// [distinct, ...]
651    AssignId = 47,
652}
653
654/// `USELISTBLOCK` encoded values for a value's use-list.
655#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
656#[repr(u8)]
657#[non_exhaustive]
658pub enum UselistCode {
659    /// `DEFAULT`
660    ///
661    /// [index..., value-id]
662    Default = 1,
663
664    /// `BB`
665    ///
666    /// [index..., bb-id]
667    BB = 2,
668}
669
670/// Identification block contains a string that describes the producer details,
671/// and an epoch that defines the auto-upgrade capability.
672#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
673#[repr(u8)]
674#[non_exhaustive]
675pub enum IdentificationCode {
676    /// `IDENTIFICATION`
677    ///
678    /// [strchr x N]
679    String = 1,
680
681    /// `EPOCH`
682    ///
683    /// [epoch#]
684    Epoch = 2,
685}
686
687/// `PARAMATTR` blocks have code for defining a parameter attribute set.
688#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
689#[repr(u8)]
690#[non_exhaustive]
691pub enum AttributeCode {
692    /// Obsolete.
693    ///
694    /// `ENTRY_OLD`
695    ///
696    /// [paramidx0, attr0, paramidx1, attr1...]
697    #[deprecated]
698    EntryOld = 1,
699
700    /// `ENTRY`
701    ///
702    /// [attrgrp0, attrgrp1, ...]
703    Entry = 2,
704
705    /// `GRP_CODE_ENTRY`
706    ///
707    /// [grpid, idx, attr0, attr1, ...]
708    GroupEntry = 3,
709}
710
711/// Value symbol table codes.
712#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
713#[repr(u8)]
714#[non_exhaustive]
715pub enum ValueSymtabCode {
716    /// `VST_ENTRY`
717    ///
718    /// [valueid, namechar x N]
719    Entry = 1,
720
721    /// `VST_BBENTRY`
722    ///
723    /// [bbid, namechar x N]
724    BbEntry = 2,
725
726    /// `VST_FNENTRY`
727    ///
728    /// Unused when strtab is present
729    ///
730    /// [valueid, offset, namechar x N]
731    FnEntry = 3,
732
733    /// Obsolete.
734    ///
735    /// `VST_COMBINED_ENTRY`
736    ///
737    /// [valueid, refguid]
738    CombinedEntry = 5,
739}
740
741/// `TYPE` blocks have codes for each type primitive they use.
742#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
743#[repr(u8)]
744#[non_exhaustive]
745pub enum TypeCode {
746    /// `NUMENTRY`
747    ///
748    /// Allows pre-allocating storage
749    ///
750    /// [numentries]
751    NumEntry = 1,
752
753    /// `VOID`
754    Void = 2,
755
756    /// `FLOAT`
757    Float = 3,
758
759    /// `DOUBLE`
760    Double = 4,
761
762    /// `LABEL`
763    Label = 5,
764
765    /// `OPAQUE`
766    Opaque = 6,
767
768    /// `INTEGER`
769    ///
770    /// [width]
771    Integer = 7,
772
773    /// Typed pointers are obsolete.
774    ///
775    /// [pointee type]
776    #[deprecated]
777    Pointer = 8,
778
779    /// Obsolete
780    ///
781    /// [vararg, attrid, retty, paramty x N]
782    #[deprecated]
783    FunctionOld = 9,
784
785    /// `HALF`
786    Half = 10,
787
788    /// `ARRAY`
789    ///
790    /// [num_elements, elements_type]
791    Array = 11,
792
793    /// `VECTOR`
794    ///
795    /// [num_elements, elements_type]
796    Vector = 12,
797
798    // These are not with the other floating point types because they're
799    // a late addition, and putting them in the right place breaks
800    // binary compatibility.
801    /// X86 LONG DOUBLE
802    X86Fp80 = 13,
803
804    /// LONG DOUBLE (112 bit mantissa)
805    Fp128 = 14,
806
807    /// PPC LONG DOUBLE (2 doubles)
808    PpcFp128 = 15,
809
810    /// `METADATA`
811    Metadata = 16,
812
813    /// Unused
814    ///
815    /// `X86 MMX`
816    X86Mmx = 17,
817
818    /// `STRUCT_ANON`
819    ///
820    /// [ispacked, elements_type x N]
821    StructAnon = 18,
822
823    /// `STRUCT_NAME`
824    ///
825    /// [strchr x N]
826    StructName = 19,
827
828    /// `STRUCT_NAMED`
829    ///
830    /// [ispacked, elements_type x N]
831    StructNamed = 20,
832
833    /// `FUNCTION`
834    ///
835    /// [vararg, retty, paramty x N]
836    Function = 21,
837
838    /// `TOKEN`
839    Token = 22,
840
841    /// `BRAIN FLOATING POINT`
842    BFloat = 23,
843
844    /// `X86 AMX`
845    X86Amx = 24,
846
847    /// `OPAQUE_POINTER`
848    ///
849    /// [addrspace]
850    OpaquePointer = 25,
851
852    /// `TARGET_TYPE`
853    TargetType = 26,
854}
855
856/// The constants block (`CONSTANTS_BLOCK_ID` describes emission for each
857/// constant and maintains an implicit current type value.
858#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
859#[repr(u8)]
860#[non_exhaustive]
861pub enum ConstantsCodes {
862    /// `SETTYPE`
863    ///
864    /// The initial implicit type is `i32`
865    ///
866    /// [typeid]
867    Settype = 1,
868
869    /// `NULL`
870    Null = 2,
871
872    /// `UNDEF`
873    Undef = 3,
874
875    /// `INTEGER`
876    ///
877    /// [intval]
878    Integer = 4,
879
880    /// `WIDE_INTEGER`
881    ///
882    /// [n x intval]
883    WideInteger = 5,
884
885    /// `FLOAT`
886    ///
887    /// [fpval]
888    Float = 6,
889
890    /// `AGGREGATE`
891    ///
892    /// [n x value number]
893    Aggregate = 7,
894
895    /// `STRING`
896    ///
897    /// [values]
898    String = 8,
899
900    /// `CSTRING`
901    ///
902    /// [values]
903    CString = 9,
904
905    /// `CE_BINOP`
906    ///
907    /// [opcode, opval, opval]
908    BinOp = 10,
909
910    /// `CE_CAST`
911    ///
912    /// [opcode, opty, opval]
913    Cast = 11,
914
915    /// Obsolete “constant expression” GEP record; replaced by `CST_CODE_CE_GEP`
916    ///
917    /// `CE_GEP`
918    ///
919    /// [n x operands]
920    #[deprecated]
921    GepOld = 12,
922
923    /// Unused
924    ///
925    /// `CE_SELECT`
926    ///
927    /// [opval, opval, opval]
928    Select = 13,
929
930    /// `CE_EXTRACTELT`
931    ///
932    /// [opty, opval, opval]
933    ExtractElt = 14,
934
935    /// `CE_INSERTELT`
936    ///
937    /// [opval, opval, opval]
938    InsertElt = 15,
939
940    /// `CE_SHUFFLEVEC`
941    ///
942    /// [opval, opval, opval]
943    ShuffleVec = 16,
944
945    /// Unused.
946    ///
947    /// `CE_CMP`
948    ///
949    /// [opty, opval, opval, pred]
950    #[deprecated]
951    Cmp = 17,
952
953    /// Obsolete inline asm record variant
954    ///
955    /// `INLINEASM`
956    ///
957    /// [sideeffect|alignstack, asmstr, onststr]
958    #[deprecated]
959    InlineasmOld = 18,
960
961    /// `SHUFVEC_EX`
962    ///
963    /// [opty, opval, opval, opval]
964    ShufVecEx = 19,
965
966    /// Obsolete.
967    ///
968    /// `INBOUNDS_GEP`
969    ///
970    /// [n x operands]
971    #[deprecated]
972    InboundsGep = 20,
973
974    /// `BLOCKADDRESS`
975    ///
976    /// [fnty, fnval, bb#]
977    BlockAddress = 21,
978
979    /// `DATA`
980    ///
981    /// [n x elements]
982    Data = 22,
983
984    /// Obsolete inline asm encoding variant
985    ///
986    /// `INLINEASM`
987    ///
988    /// [sideeffect|alignstack|asmdialect, smstr, onststr]
989    #[deprecated]
990    InlineAsmOld2 = 23,
991
992    /// [opty, flags, n x operands]
993    #[deprecated]
994    GepWithInrangeIndexOld = 24,
995
996    /// `CST_CODE_CE_UNOP`
997    ///
998    /// [opcode, opval]
999    UnOp = 25,
1000
1001    /// `POISON`
1002    Poison = 26,
1003
1004    /// `DSO_LOCAL_EQUIVALENT`
1005    ///
1006    /// [gvty, gv]
1007    DsoLocalEquivalent = 27,
1008
1009    /// Obsolete variant for inline asm
1010    ///
1011    /// `INLINEASM`
1012    ///
1013    /// [sideeffect|alignstack|asmdialect|unwind, asmstr, onststr]
1014    #[deprecated]
1015    InlineAsmOld3 = 28,
1016
1017    /// `NO_CFI`
1018    ///
1019    /// [fty, f]
1020    NoCfiValue = 29,
1021
1022    /// `INLINEASM`
1023    ///
1024    /// [fnty, sideeffect|alignstack|asmdialect|unwind, asmstr, onststr]
1025    InlineAsm = 30,
1026
1027    /// `CST_CODE_CE_GEP_WITH_INRANGE`
1028    /// [opty, flags, range, n x operands]
1029    GepWithInrange = 31,
1030
1031    /// `CST_CODE_CE_GEP`
1032    /// [opty, flags, n x operands]
1033    Gep = 32,
1034
1035    /// `CST_CODE_PTRAUTH`
1036    /// [ptr, key, disc, addrdisc]
1037    PtrAuth = 33,
1038}
1039
1040// The function body block (`FUNCTION_BLOCK_ID`) describes function bodies. It
1041// can contain a constant block (`CONSTANTS_BLOCK_ID`).
1042#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
1043#[repr(u8)]
1044#[non_exhaustive]
1045pub enum FunctionCode {
1046    /// `DECLAREBLOCKS`
1047    ///
1048    /// [n]
1049    DeclareBlocks = 1,
1050
1051    /// `BINOP`
1052    ///
1053    /// [opcode, ty, opval, opval]
1054    BinOp = 2,
1055
1056    /// `CAST`
1057    ///
1058    /// [opcode, ty, opty, opval]
1059    Cast = 3,
1060
1061    /// Old GEP instruction record; superseded by `FUNC_CODE_INST_GEP`
1062    ///
1063    /// `GEP`
1064    ///
1065    /// [n x operands]
1066    #[deprecated]
1067    GepOld = 4,
1068
1069    /// Unused.
1070    ///
1071    /// `SELECT`
1072    ///
1073    /// [ty, opval, opval, opval]
1074    #[deprecated]
1075    SelectOld = 5,
1076
1077    /// `EXTRACTELT`
1078    ///
1079    /// [opty, opval, opval]
1080    ExtractElt = 6,
1081
1082    /// `INSERTELT`
1083    ///
1084    /// [ty, opval, opval, opval]
1085    InsertElt = 7,
1086
1087    /// `SHUFFLEVEC`
1088    ///
1089    /// [ty, opval, opval, opval]
1090    ShuffleVec = 8,
1091
1092    /// `CMP`
1093    ///
1094    /// [opty, opval, opval, pred]
1095    #[deprecated]
1096    Cmp = 9,
1097
1098    /// `RET`
1099    ///
1100    /// [opty, pval<both optional>]
1101    Ret = 10,
1102
1103    /// `BR`
1104    ///
1105    /// [bb#, bb#, cond] or [bb#]
1106    Br = 11,
1107
1108    /// `SWITCH`
1109    ///
1110    /// [opty, op0, op1, ...]
1111    Switch = 12,
1112
1113    /// `INVOKE`
1114    ///
1115    /// [attr, fnty, op0, op1, ...]
1116    Invoke = 13,
1117
1118    /// `UNREACHABLE`
1119    Unreachable = 15,
1120
1121    /// `PHI`
1122    ///
1123    /// [ty, val0, b0, ...]
1124    Phi = 16,
1125
1126    /// `ALLOCA`
1127    ///
1128    /// [instty, opty, op, packed_flags_align, ?addrspace]
1129    Alloca = 19,
1130
1131    /// `LOAD`
1132    ///
1133    /// [opty, op, ret_ty, align, vol]
1134    Load = 20,
1135
1136    /// `VAARG`
1137    ///
1138    /// [valistty, valist, instty]
1139    VaArg = 23,
1140
1141    // This store code encodes the pointer type, rather than the value type
1142    // this is so information only available in the pointer type (e.g. address
1143    // spaces) is retained.
1144    /// Obsolete store record; replaced by `FUNC_CODE_INST_STORE`
1145    ///
1146    /// `STORE`
1147    ///
1148    /// [ptrty, tr, al, align, vol]
1149    #[deprecated]
1150    StoreOld = 24,
1151
1152    /// `EXTRACTVAL`
1153    ///
1154    /// [n x operands]
1155    ExtractVal = 26,
1156
1157    /// `INSERTVAL`
1158    ///
1159    /// [n x operands]
1160    InsertVal = 27,
1161
1162    /// `CMP2`
1163    ///
1164    /// fcmp/icmp returning `Int1TY` or vector of `Int1Ty`. Same as `CMP`, exists to
1165    /// support legacy vicmp/vfcmp instructions.
1166    ///
1167    /// [opty, opval, opval, pred]
1168    Cmp2 = 28,
1169
1170    /// `VSELECT`
1171    ///
1172    /// new select on i1 or [N x i1]
1173    ///
1174    /// [ty, pval, pval, redty, red]
1175    Vselect = 29,
1176
1177    /// Obsolete inbounds GEP record; replaced by the newer `FUNC_CODE_INST_GEP`
1178    ///
1179    /// `INBOUNDS_GEP`
1180    ///
1181    /// [n x operands]
1182    #[deprecated]
1183    InboundsGepOld = 30,
1184
1185    /// `INDIRECTBR`
1186    ///
1187    /// [opty, op0, op1, ...]
1188    IndirectBr = 31,
1189
1190    /// `DEBUG_LOC_AGAIN`
1191    DebugLocAgain = 33,
1192
1193    /// `CALL`
1194    ///
1195    /// [attr, cc, fnty, fnid, args...]
1196    Call = 34,
1197
1198    /// `DEBUG_LOC`
1199    ///
1200    /// [Line, ol, copeVal, IAVal]
1201    DebugLoc = 35,
1202
1203    /// `FENCE`
1204    ///
1205    /// [ordering, synchscope]
1206    Fence = 36,
1207
1208    /// Old cmpxchg record; replaced by `FUNC_CODE_INST_CMPXCHG`
1209    ///
1210    /// `CMPXCHG`
1211    ///
1212    /// [ptrty, ptr, cmp, val, vol, ordering, synchscope, failure_ordering?, weak?]
1213    #[deprecated]
1214    CmpXchgOld = 37,
1215
1216    /// Obsolete atomicrmw record; replaced by `FUNC_CODE_INST_ATOMICRMW`
1217    ///
1218    /// `ATOMICRMW`
1219    ///
1220    /// [ptrty, tr, al, operation, align, vol, ordering, synchscope]
1221    #[deprecated]
1222    AtomicRmwOld = 38,
1223
1224    /// `RESUME`
1225    ///
1226    /// [opval]
1227    Resume = 39,
1228
1229    /// Obsolete landingpad record; replaced by `FUNC_CODE_INST_LANDINGPAD`
1230    ///
1231    /// `LANDINGPAD`
1232    ///
1233    /// [ty, al, al, um, d0, al0...]
1234    #[deprecated]
1235    LandingPadOld = 40,
1236
1237    /// `LOADATOMIC`
1238    ///
1239    /// [opty, op, ret_ty, align, vol, ordering, synchscope]
1240    LoadAtomic = 41,
1241
1242    /// Obsolete store-atomic record; replaced by `FUNC_CODE_INST_STOREATOMIC`
1243    ///
1244    /// `STORE`
1245    ///
1246    /// [ptrty, tr, al, align, vol ordering, synchscope]
1247    #[deprecated]
1248    StoreAtomicOld = 42,
1249
1250    /// `GEP`
1251    ///
1252    /// [inbounds, n x operands]
1253    Gep = 43,
1254
1255    /// `STORE`
1256    ///
1257    /// [ptr_val_id, ptr_type_id?, stored_val_id, stored_type_id?, align, vol]
1258    /// Type IDs only present for forward references
1259    Store = 44,
1260
1261    /// `STORE`
1262    ///
1263    /// [ptrty, tr, al, align, vol]
1264    StoreAtomic = 45,
1265
1266    /// `CMPXCHG`
1267    ///
1268    /// [ptrty, ptr, cmp, val, vol, success_ordering, synchscope, failure_ordering, weak]
1269    AtomicCmpXchg = 46,
1270
1271    /// `LANDINGPAD`
1272    ///
1273    /// [ty, al, um, d0, al0...]
1274    LandingPad = 47,
1275
1276    /// `CLEANUPRET`
1277    ///
1278    /// [val] or [val, b#]
1279    CleanupRet = 48,
1280
1281    /// `CATCHRET`
1282    ///
1283    /// [val, b#]
1284    CatchRet = 49,
1285
1286    /// `CATCHPAD`
1287    ///
1288    /// [parent_pad, num_args, args...]
1289    CatchPad = 50,
1290
1291    /// `CLEANUPPAD`
1292    ///
1293    /// [parent_pad, num_args, args...]
1294    CleanupPad = 51,
1295
1296    /// `CATCHSWITCH`
1297    ///
1298    /// [parent_pad, num_handlers, handlers..., unwind_dest?]
1299    CatchSwitch = 52,
1300
1301    /// `OPERAND_BUNDLE`
1302    ///
1303    /// [tag#, value...]
1304    OperandBundle = 55,
1305
1306    /// `UNOP`
1307    ///
1308    /// [opcode, ty, opval]
1309    UnOp = 56,
1310
1311    /// `CALLBR`
1312    ///
1313    /// [attr, cc, norm, transfs, fnty, fnid, args...]
1314    CallBr = 57,
1315
1316    /// `FREEZE`
1317    ///
1318    /// [opty, opval]
1319    Freeze = 58,
1320
1321    /// `ATOMICRMW`
1322    ///
1323    /// [ptrty, ptr, valty, val, operation, align, vol, ordering, synchscope]
1324    AtomicRmw = 59,
1325
1326    /// `BLOCKADDR_USERS`
1327    ///
1328    /// [value...]
1329    BlockaddrUsers = 60,
1330
1331    /// [DILocation, DILocalVariable, DIExpression, ValueAsMetadata]
1332    DebugRecordValue = 61,
1333
1334    /// [DILocation, DILocalVariable, DIExpression, ValueAsMetadata]
1335    DebugRecordDeclare = 62,
1336
1337    /// [DILocation, DILocalVariable, DIExpression, ValueAsMetadata, DIAssignID, DIExpression (addr), ValueAsMetadata (addr)]
1338    DebugRecordAssign = 63,
1339
1340    /// [DILocation, DILocalVariable, DIExpression, Value]
1341    DebugRecordValueSimple = 64,
1342
1343    /// [DILocation, DILabel]
1344    DebugRecordLabel = 65,
1345}
1346
1347/// The module path symbol table only has one code (`MST_CODE_ENTRY`).
1348#[derive(Debug, Copy, Clone, PartialEq, TryFromPrimitive)]
1349#[repr(u8)]
1350#[non_exhaustive]
1351pub enum ModulePathSymtabCode {
1352    /// `MST_CODE_ENTRY`
1353    ///
1354    /// [modid, namechar x N]
1355    Entry = 1,
1356
1357    /// `MST_CODE_HASH`
1358    ///
1359    /// [5*i32]
1360    Hash = 2,
1361}