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