blob: 03dac9ebede9695a6bf0cdc5d9574c2c4261dba7 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- LLVMBitCodes.h - Enum values for the LLVM bitcode format -*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8//
9// This header defines Bitcode enum values for LLVM IR bitcode files.
10//
11// The enum values defined in this file should be considered permanent. If
12// new features are added, they should have values added at the end of the
13// respective lists.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_BITCODE_LLVMBITCODES_H
18#define LLVM_BITCODE_LLVMBITCODES_H
19
Andrew Walbran3d2c1972020-04-07 12:24:26 +010020#include "llvm/Bitstream/BitCodes.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010021
22namespace llvm {
23namespace bitc {
24// The only top-level block types are MODULE, IDENTIFICATION, STRTAB and SYMTAB.
25enum BlockIDs {
26 // Blocks
27 MODULE_BLOCK_ID = FIRST_APPLICATION_BLOCKID,
28
29 // Module sub-block id's.
30 PARAMATTR_BLOCK_ID,
31 PARAMATTR_GROUP_BLOCK_ID,
32
33 CONSTANTS_BLOCK_ID,
34 FUNCTION_BLOCK_ID,
35
36 // Block intended to contains information on the bitcode versioning.
37 // Can be used to provide better error messages when we fail to parse a
38 // bitcode file.
39 IDENTIFICATION_BLOCK_ID,
40
41 VALUE_SYMTAB_BLOCK_ID,
42 METADATA_BLOCK_ID,
43 METADATA_ATTACHMENT_ID,
44
45 TYPE_BLOCK_ID_NEW,
46
47 USELIST_BLOCK_ID,
48
49 MODULE_STRTAB_BLOCK_ID,
50 GLOBALVAL_SUMMARY_BLOCK_ID,
51
52 OPERAND_BUNDLE_TAGS_BLOCK_ID,
53
54 METADATA_KIND_BLOCK_ID,
55
56 STRTAB_BLOCK_ID,
57
58 FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID,
59
60 SYMTAB_BLOCK_ID,
61
62 SYNC_SCOPE_NAMES_BLOCK_ID,
63};
64
65/// Identification block contains a string that describes the producer details,
66/// and an epoch that defines the auto-upgrade capability.
67enum IdentificationCodes {
68 IDENTIFICATION_CODE_STRING = 1, // IDENTIFICATION: [strchr x N]
69 IDENTIFICATION_CODE_EPOCH = 2, // EPOCH: [epoch#]
70};
71
72/// The epoch that defines the auto-upgrade compatibility for the bitcode.
73///
74/// LLVM guarantees in a major release that a minor release can read bitcode
75/// generated by previous minor releases. We translate this by making the reader
76/// accepting only bitcode with the same epoch, except for the X.0 release which
77/// also accepts N-1.
78enum { BITCODE_CURRENT_EPOCH = 0 };
79
80/// MODULE blocks have a number of optional fields and subblocks.
81enum ModuleCodes {
82 MODULE_CODE_VERSION = 1, // VERSION: [version#]
83 MODULE_CODE_TRIPLE = 2, // TRIPLE: [strchr x N]
84 MODULE_CODE_DATALAYOUT = 3, // DATALAYOUT: [strchr x N]
85 MODULE_CODE_ASM = 4, // ASM: [strchr x N]
86 MODULE_CODE_SECTIONNAME = 5, // SECTIONNAME: [strchr x N]
87
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020088 // Deprecated, but still needed to read old bitcode files.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010089 MODULE_CODE_DEPLIB = 6, // DEPLIB: [strchr x N]
90
91 // GLOBALVAR: [pointer type, isconst, initid,
92 // linkage, alignment, section, visibility, threadlocal]
93 MODULE_CODE_GLOBALVAR = 7,
94
95 // FUNCTION: [type, callingconv, isproto, linkage, paramattrs, alignment,
96 // section, visibility, gc, unnamed_addr]
97 MODULE_CODE_FUNCTION = 8,
98
99 // ALIAS: [alias type, aliasee val#, linkage, visibility]
100 MODULE_CODE_ALIAS_OLD = 9,
101
102 MODULE_CODE_GCNAME = 11, // GCNAME: [strchr x N]
103 MODULE_CODE_COMDAT = 12, // COMDAT: [selection_kind, name]
104
105 MODULE_CODE_VSTOFFSET = 13, // VSTOFFSET: [offset]
106
107 // ALIAS: [alias value type, addrspace, aliasee val#, linkage, visibility]
108 MODULE_CODE_ALIAS = 14,
109
110 MODULE_CODE_METADATA_VALUES_UNUSED = 15,
111
112 // SOURCE_FILENAME: [namechar x N]
113 MODULE_CODE_SOURCE_FILENAME = 16,
114
115 // HASH: [5*i32]
116 MODULE_CODE_HASH = 17,
117
118 // IFUNC: [ifunc value type, addrspace, resolver val#, linkage, visibility]
119 MODULE_CODE_IFUNC = 18,
120};
121
122/// PARAMATTR blocks have code for defining a parameter attribute set.
123enum AttributeCodes {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200124 // Deprecated, but still needed to read old bitcode files.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100125 PARAMATTR_CODE_ENTRY_OLD = 1, // ENTRY: [paramidx0, attr0,
126 // paramidx1, attr1...]
127 PARAMATTR_CODE_ENTRY = 2, // ENTRY: [attrgrp0, attrgrp1, ...]
128 PARAMATTR_GRP_CODE_ENTRY = 3 // ENTRY: [grpid, idx, attr0, attr1, ...]
129};
130
131/// TYPE blocks have codes for each type primitive they use.
132enum TypeCodes {
133 TYPE_CODE_NUMENTRY = 1, // NUMENTRY: [numentries]
134
135 // Type Codes
136 TYPE_CODE_VOID = 2, // VOID
137 TYPE_CODE_FLOAT = 3, // FLOAT
138 TYPE_CODE_DOUBLE = 4, // DOUBLE
139 TYPE_CODE_LABEL = 5, // LABEL
140 TYPE_CODE_OPAQUE = 6, // OPAQUE
141 TYPE_CODE_INTEGER = 7, // INTEGER: [width]
142 TYPE_CODE_POINTER = 8, // POINTER: [pointee type]
143
144 TYPE_CODE_FUNCTION_OLD = 9, // FUNCTION: [vararg, attrid, retty,
145 // paramty x N]
146
147 TYPE_CODE_HALF = 10, // HALF
148
149 TYPE_CODE_ARRAY = 11, // ARRAY: [numelts, eltty]
150 TYPE_CODE_VECTOR = 12, // VECTOR: [numelts, eltty]
151
152 // These are not with the other floating point types because they're
153 // a late addition, and putting them in the right place breaks
154 // binary compatibility.
155 TYPE_CODE_X86_FP80 = 13, // X86 LONG DOUBLE
156 TYPE_CODE_FP128 = 14, // LONG DOUBLE (112 bit mantissa)
157 TYPE_CODE_PPC_FP128 = 15, // PPC LONG DOUBLE (2 doubles)
158
159 TYPE_CODE_METADATA = 16, // METADATA
160
161 TYPE_CODE_X86_MMX = 17, // X86 MMX
162
163 TYPE_CODE_STRUCT_ANON = 18, // STRUCT_ANON: [ispacked, eltty x N]
164 TYPE_CODE_STRUCT_NAME = 19, // STRUCT_NAME: [strchr x N]
165 TYPE_CODE_STRUCT_NAMED = 20, // STRUCT_NAMED: [ispacked, eltty x N]
166
167 TYPE_CODE_FUNCTION = 21, // FUNCTION: [vararg, retty, paramty x N]
168
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200169 TYPE_CODE_TOKEN = 22, // TOKEN
170
171 TYPE_CODE_BFLOAT = 23, // BRAIN FLOATING POINT
172 TYPE_CODE_X86_AMX = 24 // X86 AMX
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100173};
174
175enum OperandBundleTagCode {
176 OPERAND_BUNDLE_TAG = 1, // TAG: [strchr x N]
177};
178
179enum SyncScopeNameCode {
180 SYNC_SCOPE_NAME = 1,
181};
182
183// Value symbol table codes.
184enum ValueSymtabCodes {
185 VST_CODE_ENTRY = 1, // VST_ENTRY: [valueid, namechar x N]
186 VST_CODE_BBENTRY = 2, // VST_BBENTRY: [bbid, namechar x N]
187 VST_CODE_FNENTRY = 3, // VST_FNENTRY: [valueid, offset, namechar x N]
188 // VST_COMBINED_ENTRY: [valueid, refguid]
189 VST_CODE_COMBINED_ENTRY = 5
190};
191
192// The module path symbol table only has one code (MST_CODE_ENTRY).
193enum ModulePathSymtabCodes {
194 MST_CODE_ENTRY = 1, // MST_ENTRY: [modid, namechar x N]
195 MST_CODE_HASH = 2, // MST_HASH: [5*i32]
196};
197
198// The summary section uses different codes in the per-module
199// and combined index cases.
200enum GlobalValueSummarySymtabCodes {
201 // PERMODULE: [valueid, flags, instcount, numrefs, numrefs x valueid,
202 // n x (valueid)]
203 FS_PERMODULE = 1,
204 // PERMODULE_PROFILE: [valueid, flags, instcount, numrefs,
205 // numrefs x valueid,
206 // n x (valueid, hotness)]
207 FS_PERMODULE_PROFILE = 2,
208 // PERMODULE_GLOBALVAR_INIT_REFS: [valueid, flags, n x valueid]
209 FS_PERMODULE_GLOBALVAR_INIT_REFS = 3,
210 // COMBINED: [valueid, modid, flags, instcount, numrefs, numrefs x valueid,
211 // n x (valueid)]
212 FS_COMBINED = 4,
213 // COMBINED_PROFILE: [valueid, modid, flags, instcount, numrefs,
214 // numrefs x valueid,
215 // n x (valueid, hotness)]
216 FS_COMBINED_PROFILE = 5,
217 // COMBINED_GLOBALVAR_INIT_REFS: [valueid, modid, flags, n x valueid]
218 FS_COMBINED_GLOBALVAR_INIT_REFS = 6,
219 // ALIAS: [valueid, flags, valueid]
220 FS_ALIAS = 7,
221 // COMBINED_ALIAS: [valueid, modid, flags, valueid]
222 FS_COMBINED_ALIAS = 8,
223 // COMBINED_ORIGINAL_NAME: [original_name_hash]
224 FS_COMBINED_ORIGINAL_NAME = 9,
225 // VERSION of the summary, bumped when adding flags for instance.
226 FS_VERSION = 10,
227 // The list of llvm.type.test type identifiers used by the following function
228 // that are used other than by an llvm.assume.
229 // [n x typeid]
230 FS_TYPE_TESTS = 11,
231 // The list of virtual calls made by this function using
232 // llvm.assume(llvm.type.test) intrinsics that do not have all constant
233 // integer arguments.
234 // [n x (typeid, offset)]
235 FS_TYPE_TEST_ASSUME_VCALLS = 12,
236 // The list of virtual calls made by this function using
237 // llvm.type.checked.load intrinsics that do not have all constant integer
238 // arguments.
239 // [n x (typeid, offset)]
240 FS_TYPE_CHECKED_LOAD_VCALLS = 13,
241 // Identifies a virtual call made by this function using an
242 // llvm.assume(llvm.type.test) intrinsic with all constant integer arguments.
243 // [typeid, offset, n x arg]
244 FS_TYPE_TEST_ASSUME_CONST_VCALL = 14,
245 // Identifies a virtual call made by this function using an
246 // llvm.type.checked.load intrinsic with all constant integer arguments.
247 // [typeid, offset, n x arg]
248 FS_TYPE_CHECKED_LOAD_CONST_VCALL = 15,
249 // Assigns a GUID to a value ID. This normally appears only in combined
250 // summaries, but it can also appear in per-module summaries for PGO data.
251 // [valueid, guid]
252 FS_VALUE_GUID = 16,
253 // The list of local functions with CFI jump tables. Function names are
254 // strings in strtab.
255 // [n * name]
256 FS_CFI_FUNCTION_DEFS = 17,
257 // The list of external functions with CFI jump tables. Function names are
258 // strings in strtab.
259 // [n * name]
260 FS_CFI_FUNCTION_DECLS = 18,
261 // Per-module summary that also adds relative block frequency to callee info.
262 // PERMODULE_RELBF: [valueid, flags, instcount, numrefs,
263 // numrefs x valueid,
264 // n x (valueid, relblockfreq)]
265 FS_PERMODULE_RELBF = 19,
266 // Index-wide flags
267 FS_FLAGS = 20,
268 // Maps type identifier to summary information for that type identifier.
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100269 // Produced by the thin link (only lives in combined index).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100270 // TYPE_ID: [typeid, kind, bitwidth, align, size, bitmask, inlinebits,
271 // n x (typeid, kind, name, numrba,
272 // numrba x (numarg, numarg x arg, kind, info, byte, bit))]
273 FS_TYPE_ID = 21,
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100274 // For background see overview at https://llvm.org/docs/TypeMetadata.html.
275 // The type metadata includes both the type identifier and the offset of
276 // the address point of the type (the address held by objects of that type
277 // which may not be the beginning of the virtual table). Vtable definitions
278 // are decorated with type metadata for the types they are compatible with.
279 //
280 // Maps type identifier to summary information for that type identifier
281 // computed from type metadata: the valueid of each vtable definition
282 // decorated with a type metadata for that identifier, and the offset from
283 // the corresponding type metadata.
284 // Exists in the per-module summary to provide information to thin link
285 // for index-based whole program devirtualization.
286 // TYPE_ID_METADATA: [typeid, n x (valueid, offset)]
287 FS_TYPE_ID_METADATA = 22,
288 // Summarizes vtable definition for use in index-based whole program
289 // devirtualization during the thin link.
290 // PERMODULE_VTABLE_GLOBALVAR_INIT_REFS: [valueid, flags, varflags,
291 // numrefs, numrefs x valueid,
292 // n x (valueid, offset)]
293 FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS = 23,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200294 // The total number of basic blocks in the module.
295 FS_BLOCK_COUNT = 24,
296 // Range information for accessed offsets for every argument.
297 // [n x (paramno, range, numcalls, numcalls x (callee_guid, paramno, range))]
298 FS_PARAM_ACCESS = 25,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100299};
300
301enum MetadataCodes {
302 METADATA_STRING_OLD = 1, // MDSTRING: [values]
303 METADATA_VALUE = 2, // VALUE: [type num, value num]
304 METADATA_NODE = 3, // NODE: [n x md num]
305 METADATA_NAME = 4, // STRING: [values]
306 METADATA_DISTINCT_NODE = 5, // DISTINCT_NODE: [n x md num]
307 METADATA_KIND = 6, // [n x [id, name]]
308 METADATA_LOCATION = 7, // [distinct, line, col, scope, inlined-at?]
309 METADATA_OLD_NODE = 8, // OLD_NODE: [n x (type num, value num)]
310 METADATA_OLD_FN_NODE = 9, // OLD_FN_NODE: [n x (type num, value num)]
311 METADATA_NAMED_NODE = 10, // NAMED_NODE: [n x mdnodes]
312 METADATA_ATTACHMENT = 11, // [m x [value, [n x [id, mdnode]]]
313 METADATA_GENERIC_DEBUG = 12, // [distinct, tag, vers, header, n x md num]
314 METADATA_SUBRANGE = 13, // [distinct, count, lo]
315 METADATA_ENUMERATOR = 14, // [isUnsigned|distinct, value, name]
316 METADATA_BASIC_TYPE = 15, // [distinct, tag, name, size, align, enc]
317 METADATA_FILE = 16, // [distinct, filename, directory, checksumkind, checksum]
318 METADATA_DERIVED_TYPE = 17, // [distinct, ...]
319 METADATA_COMPOSITE_TYPE = 18, // [distinct, ...]
320 METADATA_SUBROUTINE_TYPE = 19, // [distinct, flags, types, cc]
321 METADATA_COMPILE_UNIT = 20, // [distinct, ...]
322 METADATA_SUBPROGRAM = 21, // [distinct, ...]
323 METADATA_LEXICAL_BLOCK = 22, // [distinct, scope, file, line, column]
324 METADATA_LEXICAL_BLOCK_FILE = 23, //[distinct, scope, file, discriminator]
325 METADATA_NAMESPACE = 24, // [distinct, scope, file, name, line, exportSymbols]
326 METADATA_TEMPLATE_TYPE = 25, // [distinct, scope, name, type, ...]
327 METADATA_TEMPLATE_VALUE = 26, // [distinct, scope, name, type, value, ...]
328 METADATA_GLOBAL_VAR = 27, // [distinct, ...]
329 METADATA_LOCAL_VAR = 28, // [distinct, ...]
330 METADATA_EXPRESSION = 29, // [distinct, n x element]
331 METADATA_OBJC_PROPERTY = 30, // [distinct, name, file, line, ...]
332 METADATA_IMPORTED_ENTITY = 31, // [distinct, tag, scope, entity, line, name]
333 METADATA_MODULE = 32, // [distinct, scope, name, ...]
334 METADATA_MACRO = 33, // [distinct, macinfo, line, name, value]
335 METADATA_MACRO_FILE = 34, // [distinct, macinfo, line, file, ...]
336 METADATA_STRINGS = 35, // [count, offset] blob([lengths][chars])
337 METADATA_GLOBAL_DECL_ATTACHMENT = 36, // [valueid, n x [id, mdnode]]
338 METADATA_GLOBAL_VAR_EXPR = 37, // [distinct, var, expr]
339 METADATA_INDEX_OFFSET = 38, // [offset]
340 METADATA_INDEX = 39, // [bitpos]
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100341 METADATA_LABEL = 40, // [distinct, scope, name, file, line]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200342 METADATA_STRING_TYPE = 41, // [distinct, name, size, align,...]
343 // Codes 42 and 43 are reserved for support for Fortran array specific debug
344 // info.
345 METADATA_COMMON_BLOCK = 44, // [distinct, scope, name, variable,...]
346 METADATA_GENERIC_SUBRANGE = 45 // [distinct, count, lo, up, stride]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100347};
348
349// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
350// constant and maintains an implicit current type value.
351enum ConstantsCodes {
352 CST_CODE_SETTYPE = 1, // SETTYPE: [typeid]
353 CST_CODE_NULL = 2, // NULL
354 CST_CODE_UNDEF = 3, // UNDEF
355 CST_CODE_INTEGER = 4, // INTEGER: [intval]
356 CST_CODE_WIDE_INTEGER = 5, // WIDE_INTEGER: [n x intval]
357 CST_CODE_FLOAT = 6, // FLOAT: [fpval]
358 CST_CODE_AGGREGATE = 7, // AGGREGATE: [n x value number]
359 CST_CODE_STRING = 8, // STRING: [values]
360 CST_CODE_CSTRING = 9, // CSTRING: [values]
361 CST_CODE_CE_BINOP = 10, // CE_BINOP: [opcode, opval, opval]
362 CST_CODE_CE_CAST = 11, // CE_CAST: [opcode, opty, opval]
363 CST_CODE_CE_GEP = 12, // CE_GEP: [n x operands]
364 CST_CODE_CE_SELECT = 13, // CE_SELECT: [opval, opval, opval]
365 CST_CODE_CE_EXTRACTELT = 14, // CE_EXTRACTELT: [opty, opval, opval]
366 CST_CODE_CE_INSERTELT = 15, // CE_INSERTELT: [opval, opval, opval]
367 CST_CODE_CE_SHUFFLEVEC = 16, // CE_SHUFFLEVEC: [opval, opval, opval]
368 CST_CODE_CE_CMP = 17, // CE_CMP: [opty, opval, opval, pred]
369 CST_CODE_INLINEASM_OLD = 18, // INLINEASM: [sideeffect|alignstack,
370 // asmstr,conststr]
371 CST_CODE_CE_SHUFVEC_EX = 19, // SHUFVEC_EX: [opty, opval, opval, opval]
372 CST_CODE_CE_INBOUNDS_GEP = 20, // INBOUNDS_GEP: [n x operands]
373 CST_CODE_BLOCKADDRESS = 21, // CST_CODE_BLOCKADDRESS [fnty, fnval, bb#]
374 CST_CODE_DATA = 22, // DATA: [n x elements]
375 CST_CODE_INLINEASM = 23, // INLINEASM: [sideeffect|alignstack|
376 // asmdialect,asmstr,conststr]
377 CST_CODE_CE_GEP_WITH_INRANGE_INDEX = 24, // [opty, flags, n x operands]
Andrew Walbran16937d02019-10-22 13:54:20 +0100378 CST_CODE_CE_UNOP = 25, // CE_UNOP: [opcode, opval]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200379 CST_CODE_POISON = 26, // POISON
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100380};
381
382/// CastOpcodes - These are values used in the bitcode files to encode which
383/// cast a CST_CODE_CE_CAST or a XXX refers to. The values of these enums
384/// have no fixed relation to the LLVM IR enum values. Changing these will
385/// break compatibility with old files.
386enum CastOpcodes {
387 CAST_TRUNC = 0,
388 CAST_ZEXT = 1,
389 CAST_SEXT = 2,
390 CAST_FPTOUI = 3,
391 CAST_FPTOSI = 4,
392 CAST_UITOFP = 5,
393 CAST_SITOFP = 6,
394 CAST_FPTRUNC = 7,
395 CAST_FPEXT = 8,
396 CAST_PTRTOINT = 9,
397 CAST_INTTOPTR = 10,
398 CAST_BITCAST = 11,
399 CAST_ADDRSPACECAST = 12
400};
401
Andrew Walbran16937d02019-10-22 13:54:20 +0100402/// UnaryOpcodes - These are values used in the bitcode files to encode which
403/// unop a CST_CODE_CE_UNOP or a XXX refers to. The values of these enums
404/// have no fixed relation to the LLVM IR enum values. Changing these will
405/// break compatibility with old files.
406enum UnaryOpcodes {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200407 UNOP_FNEG = 0
Andrew Walbran16937d02019-10-22 13:54:20 +0100408};
409
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100410/// BinaryOpcodes - These are values used in the bitcode files to encode which
411/// binop a CST_CODE_CE_BINOP or a XXX refers to. The values of these enums
412/// have no fixed relation to the LLVM IR enum values. Changing these will
413/// break compatibility with old files.
414enum BinaryOpcodes {
415 BINOP_ADD = 0,
416 BINOP_SUB = 1,
417 BINOP_MUL = 2,
418 BINOP_UDIV = 3,
419 BINOP_SDIV = 4, // overloaded for FP
420 BINOP_UREM = 5,
421 BINOP_SREM = 6, // overloaded for FP
422 BINOP_SHL = 7,
423 BINOP_LSHR = 8,
424 BINOP_ASHR = 9,
425 BINOP_AND = 10,
426 BINOP_OR = 11,
427 BINOP_XOR = 12
428};
429
430/// These are values used in the bitcode files to encode AtomicRMW operations.
431/// The values of these enums have no fixed relation to the LLVM IR enum
432/// values. Changing these will break compatibility with old files.
433enum RMWOperations {
434 RMW_XCHG = 0,
435 RMW_ADD = 1,
436 RMW_SUB = 2,
437 RMW_AND = 3,
438 RMW_NAND = 4,
439 RMW_OR = 5,
440 RMW_XOR = 6,
441 RMW_MAX = 7,
442 RMW_MIN = 8,
443 RMW_UMAX = 9,
Andrew Walbran16937d02019-10-22 13:54:20 +0100444 RMW_UMIN = 10,
445 RMW_FADD = 11,
446 RMW_FSUB = 12
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100447};
448
449/// OverflowingBinaryOperatorOptionalFlags - Flags for serializing
450/// OverflowingBinaryOperator's SubclassOptionalData contents.
451enum OverflowingBinaryOperatorOptionalFlags {
452 OBO_NO_UNSIGNED_WRAP = 0,
453 OBO_NO_SIGNED_WRAP = 1
454};
455
456/// FastMath Flags
457/// This is a fixed layout derived from the bitcode emitted by LLVM 5.0
458/// intended to decouple the in-memory representation from the serialization.
459enum FastMathMap {
460 UnsafeAlgebra = (1 << 0), // Legacy
461 NoNaNs = (1 << 1),
462 NoInfs = (1 << 2),
463 NoSignedZeros = (1 << 3),
464 AllowReciprocal = (1 << 4),
465 AllowContract = (1 << 5),
466 ApproxFunc = (1 << 6),
467 AllowReassoc = (1 << 7)
468};
469
470/// PossiblyExactOperatorOptionalFlags - Flags for serializing
471/// PossiblyExactOperator's SubclassOptionalData contents.
472enum PossiblyExactOperatorOptionalFlags { PEO_EXACT = 0 };
473
474/// Encoded AtomicOrdering values.
475enum AtomicOrderingCodes {
476 ORDERING_NOTATOMIC = 0,
477 ORDERING_UNORDERED = 1,
478 ORDERING_MONOTONIC = 2,
479 ORDERING_ACQUIRE = 3,
480 ORDERING_RELEASE = 4,
481 ORDERING_ACQREL = 5,
482 ORDERING_SEQCST = 6
483};
484
485/// Markers and flags for call instruction.
486enum CallMarkersFlags {
487 CALL_TAIL = 0,
488 CALL_CCONV = 1,
489 CALL_MUSTTAIL = 14,
490 CALL_EXPLICIT_TYPE = 15,
491 CALL_NOTAIL = 16,
492 CALL_FMF = 17 // Call has optional fast-math-flags.
493};
494
495// The function body block (FUNCTION_BLOCK_ID) describes function bodies. It
496// can contain a constant block (CONSTANTS_BLOCK_ID).
497enum FunctionCodes {
498 FUNC_CODE_DECLAREBLOCKS = 1, // DECLAREBLOCKS: [n]
499
500 FUNC_CODE_INST_BINOP = 2, // BINOP: [opcode, ty, opval, opval]
501 FUNC_CODE_INST_CAST = 3, // CAST: [opcode, ty, opty, opval]
502 FUNC_CODE_INST_GEP_OLD = 4, // GEP: [n x operands]
503 FUNC_CODE_INST_SELECT = 5, // SELECT: [ty, opval, opval, opval]
504 FUNC_CODE_INST_EXTRACTELT = 6, // EXTRACTELT: [opty, opval, opval]
505 FUNC_CODE_INST_INSERTELT = 7, // INSERTELT: [ty, opval, opval, opval]
506 FUNC_CODE_INST_SHUFFLEVEC = 8, // SHUFFLEVEC: [ty, opval, opval, opval]
507 FUNC_CODE_INST_CMP = 9, // CMP: [opty, opval, opval, pred]
508
509 FUNC_CODE_INST_RET = 10, // RET: [opty,opval<both optional>]
510 FUNC_CODE_INST_BR = 11, // BR: [bb#, bb#, cond] or [bb#]
511 FUNC_CODE_INST_SWITCH = 12, // SWITCH: [opty, op0, op1, ...]
512 FUNC_CODE_INST_INVOKE = 13, // INVOKE: [attr, fnty, op0,op1, ...]
513 // 14 is unused.
514 FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE
515
516 FUNC_CODE_INST_PHI = 16, // PHI: [ty, val0,bb0, ...]
517 // 17 is unused.
518 // 18 is unused.
519 FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, opty, op, align]
520 FUNC_CODE_INST_LOAD = 20, // LOAD: [opty, op, align, vol]
521 // 21 is unused.
522 // 22 is unused.
523 FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, valist, instty]
524 // This store code encodes the pointer type, rather than the value type
525 // this is so information only available in the pointer type (e.g. address
526 // spaces) is retained.
527 FUNC_CODE_INST_STORE_OLD = 24, // STORE: [ptrty,ptr,val, align, vol]
528 // 25 is unused.
529 FUNC_CODE_INST_EXTRACTVAL = 26, // EXTRACTVAL: [n x operands]
530 FUNC_CODE_INST_INSERTVAL = 27, // INSERTVAL: [n x operands]
531 // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to
532 // support legacy vicmp/vfcmp instructions.
533 FUNC_CODE_INST_CMP2 = 28, // CMP2: [opty, opval, opval, pred]
534 // new select on i1 or [N x i1]
535 FUNC_CODE_INST_VSELECT = 29, // VSELECT: [ty,opval,opval,predty,pred]
536 FUNC_CODE_INST_INBOUNDS_GEP_OLD = 30, // INBOUNDS_GEP: [n x operands]
537 FUNC_CODE_INST_INDIRECTBR = 31, // INDIRECTBR: [opty, op0, op1, ...]
538 // 32 is unused.
539 FUNC_CODE_DEBUG_LOC_AGAIN = 33, // DEBUG_LOC_AGAIN
540
541 FUNC_CODE_INST_CALL = 34, // CALL: [attr, cc, fnty, fnid, args...]
542
543 FUNC_CODE_DEBUG_LOC = 35, // DEBUG_LOC: [Line,Col,ScopeVal, IAVal]
544 FUNC_CODE_INST_FENCE = 36, // FENCE: [ordering, synchscope]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200545 FUNC_CODE_INST_CMPXCHG_OLD = 37, // CMPXCHG: [ptrty, ptr, cmp, val, vol,
546 // ordering, synchscope,
547 // failure_ordering?, weak?]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100548 FUNC_CODE_INST_ATOMICRMW = 38, // ATOMICRMW: [ptrty,ptr,val, operation,
549 // align, vol,
550 // ordering, synchscope]
551 FUNC_CODE_INST_RESUME = 39, // RESUME: [opval]
552 FUNC_CODE_INST_LANDINGPAD_OLD =
553 40, // LANDINGPAD: [ty,val,val,num,id0,val0...]
554 FUNC_CODE_INST_LOADATOMIC = 41, // LOAD: [opty, op, align, vol,
555 // ordering, synchscope]
556 FUNC_CODE_INST_STOREATOMIC_OLD = 42, // STORE: [ptrty,ptr,val, align, vol
557 // ordering, synchscope]
558 FUNC_CODE_INST_GEP = 43, // GEP: [inbounds, n x operands]
559 FUNC_CODE_INST_STORE = 44, // STORE: [ptrty,ptr,valty,val, align, vol]
560 FUNC_CODE_INST_STOREATOMIC = 45, // STORE: [ptrty,ptr,val, align, vol
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200561 FUNC_CODE_INST_CMPXCHG = 46, // CMPXCHG: [ptrty, ptr, cmp, val, vol,
562 // success_ordering, synchscope,
563 // failure_ordering, weak]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100564 FUNC_CODE_INST_LANDINGPAD = 47, // LANDINGPAD: [ty,val,num,id0,val0...]
565 FUNC_CODE_INST_CLEANUPRET = 48, // CLEANUPRET: [val] or [val,bb#]
566 FUNC_CODE_INST_CATCHRET = 49, // CATCHRET: [val,bb#]
567 FUNC_CODE_INST_CATCHPAD = 50, // CATCHPAD: [bb#,bb#,num,args...]
568 FUNC_CODE_INST_CLEANUPPAD = 51, // CLEANUPPAD: [num,args...]
569 FUNC_CODE_INST_CATCHSWITCH =
570 52, // CATCHSWITCH: [num,args...] or [num,args...,bb]
571 // 53 is unused.
572 // 54 is unused.
573 FUNC_CODE_OPERAND_BUNDLE = 55, // OPERAND_BUNDLE: [tag#, value...]
Andrew Walbran16937d02019-10-22 13:54:20 +0100574 FUNC_CODE_INST_UNOP = 56, // UNOP: [opcode, ty, opval]
575 FUNC_CODE_INST_CALLBR = 57, // CALLBR: [attr, cc, norm, transfs,
576 // fnty, fnid, args...]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200577 FUNC_CODE_INST_FREEZE = 58, // FREEZE: [opty, opval]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100578};
579
580enum UseListCodes {
581 USELIST_CODE_DEFAULT = 1, // DEFAULT: [index..., value-id]
582 USELIST_CODE_BB = 2 // BB: [index..., bb-id]
583};
584
585enum AttributeKindCodes {
586 // = 0 is unused
587 ATTR_KIND_ALIGNMENT = 1,
588 ATTR_KIND_ALWAYS_INLINE = 2,
589 ATTR_KIND_BY_VAL = 3,
590 ATTR_KIND_INLINE_HINT = 4,
591 ATTR_KIND_IN_REG = 5,
592 ATTR_KIND_MIN_SIZE = 6,
593 ATTR_KIND_NAKED = 7,
594 ATTR_KIND_NEST = 8,
595 ATTR_KIND_NO_ALIAS = 9,
596 ATTR_KIND_NO_BUILTIN = 10,
597 ATTR_KIND_NO_CAPTURE = 11,
598 ATTR_KIND_NO_DUPLICATE = 12,
599 ATTR_KIND_NO_IMPLICIT_FLOAT = 13,
600 ATTR_KIND_NO_INLINE = 14,
601 ATTR_KIND_NON_LAZY_BIND = 15,
602 ATTR_KIND_NO_RED_ZONE = 16,
603 ATTR_KIND_NO_RETURN = 17,
604 ATTR_KIND_NO_UNWIND = 18,
605 ATTR_KIND_OPTIMIZE_FOR_SIZE = 19,
606 ATTR_KIND_READ_NONE = 20,
607 ATTR_KIND_READ_ONLY = 21,
608 ATTR_KIND_RETURNED = 22,
609 ATTR_KIND_RETURNS_TWICE = 23,
610 ATTR_KIND_S_EXT = 24,
611 ATTR_KIND_STACK_ALIGNMENT = 25,
612 ATTR_KIND_STACK_PROTECT = 26,
613 ATTR_KIND_STACK_PROTECT_REQ = 27,
614 ATTR_KIND_STACK_PROTECT_STRONG = 28,
615 ATTR_KIND_STRUCT_RET = 29,
616 ATTR_KIND_SANITIZE_ADDRESS = 30,
617 ATTR_KIND_SANITIZE_THREAD = 31,
618 ATTR_KIND_SANITIZE_MEMORY = 32,
619 ATTR_KIND_UW_TABLE = 33,
620 ATTR_KIND_Z_EXT = 34,
621 ATTR_KIND_BUILTIN = 35,
622 ATTR_KIND_COLD = 36,
623 ATTR_KIND_OPTIMIZE_NONE = 37,
624 ATTR_KIND_IN_ALLOCA = 38,
625 ATTR_KIND_NON_NULL = 39,
626 ATTR_KIND_JUMP_TABLE = 40,
627 ATTR_KIND_DEREFERENCEABLE = 41,
628 ATTR_KIND_DEREFERENCEABLE_OR_NULL = 42,
629 ATTR_KIND_CONVERGENT = 43,
630 ATTR_KIND_SAFESTACK = 44,
631 ATTR_KIND_ARGMEMONLY = 45,
632 ATTR_KIND_SWIFT_SELF = 46,
633 ATTR_KIND_SWIFT_ERROR = 47,
634 ATTR_KIND_NO_RECURSE = 48,
635 ATTR_KIND_INACCESSIBLEMEM_ONLY = 49,
636 ATTR_KIND_INACCESSIBLEMEM_OR_ARGMEMONLY = 50,
637 ATTR_KIND_ALLOC_SIZE = 51,
638 ATTR_KIND_WRITEONLY = 52,
639 ATTR_KIND_SPECULATABLE = 53,
640 ATTR_KIND_STRICT_FP = 54,
641 ATTR_KIND_SANITIZE_HWADDRESS = 55,
642 ATTR_KIND_NOCF_CHECK = 56,
643 ATTR_KIND_OPT_FOR_FUZZING = 57,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100644 ATTR_KIND_SHADOWCALLSTACK = 58,
Andrew Scull0372a572018-11-16 15:47:06 +0000645 ATTR_KIND_SPECULATIVE_LOAD_HARDENING = 59,
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100646 ATTR_KIND_IMMARG = 60,
647 ATTR_KIND_WILLRETURN = 61,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200648 ATTR_KIND_NOFREE = 62,
649 ATTR_KIND_NOSYNC = 63,
650 ATTR_KIND_SANITIZE_MEMTAG = 64,
651 ATTR_KIND_PREALLOCATED = 65,
652 ATTR_KIND_NO_MERGE = 66,
653 ATTR_KIND_NULL_POINTER_IS_VALID = 67,
654 ATTR_KIND_NOUNDEF = 68,
655 ATTR_KIND_BYREF = 69,
656 ATTR_KIND_MUSTPROGRESS = 70,
657 ATTR_KIND_NO_CALLBACK = 71,
658 ATTR_KIND_HOT = 72,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100659};
660
661enum ComdatSelectionKindCodes {
662 COMDAT_SELECTION_KIND_ANY = 1,
663 COMDAT_SELECTION_KIND_EXACT_MATCH = 2,
664 COMDAT_SELECTION_KIND_LARGEST = 3,
665 COMDAT_SELECTION_KIND_NO_DUPLICATES = 4,
666 COMDAT_SELECTION_KIND_SAME_SIZE = 5,
667};
668
669enum StrtabCodes {
670 STRTAB_BLOB = 1,
671};
672
673enum SymtabCodes {
674 SYMTAB_BLOB = 1,
675};
676
677} // End bitc namespace
678} // End llvm namespace
679
680#endif