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