blob: 7cadd5807fa64c03571184822d7717eb43922844 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- LLVMBitCodes.h - Enum values for the LLVM bitcode format -*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner84e66db2007-12-29 19:59:42 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This header defines Bitcode enum values for LLVM IR bitcode files.
11//
12// The enum values defined in this file should be considered permanent. If
13// new features are added, they should have values added at the end of the
14// respective lists.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_BITCODE_LLVMBITCODES_H
19#define LLVM_BITCODE_LLVMBITCODES_H
20
21#include "llvm/Bitcode/BitCodes.h"
22
23namespace llvm {
24namespace bitc {
25 // The only top-level block type defined is for a module.
26 enum BlockIDs {
27 // Blocks
28 MODULE_BLOCK_ID = FIRST_APPLICATION_BLOCKID,
Misha Brukman662086a2009-02-20 23:04:06 +000029
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030 // Module sub-block id's.
31 PARAMATTR_BLOCK_ID,
32 TYPE_BLOCK_ID,
33 CONSTANTS_BLOCK_ID,
34 FUNCTION_BLOCK_ID,
35 TYPE_SYMTAB_BLOCK_ID,
Devang Patel0c0a6ca2009-07-22 17:43:22 +000036 VALUE_SYMTAB_BLOCK_ID,
Devang Pateladc37612009-09-18 19:26:43 +000037 METADATA_BLOCK_ID,
38 METADATA_ATTACHMENT_ID
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039 };
Misha Brukman662086a2009-02-20 23:04:06 +000040
41
Dan Gohmanf17a25c2007-07-18 16:29:46 +000042 /// MODULE blocks have a number of optional fields and subblocks.
43 enum ModuleCodes {
44 MODULE_CODE_VERSION = 1, // VERSION: [version#]
45 MODULE_CODE_TRIPLE = 2, // TRIPLE: [strchr x N]
46 MODULE_CODE_DATALAYOUT = 3, // DATALAYOUT: [strchr x N]
47 MODULE_CODE_ASM = 4, // ASM: [strchr x N]
48 MODULE_CODE_SECTIONNAME = 5, // SECTIONNAME: [strchr x N]
49 MODULE_CODE_DEPLIB = 6, // DEPLIB: [strchr x N]
50
Misha Brukman662086a2009-02-20 23:04:06 +000051 // GLOBALVAR: [pointer type, isconst, initid,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052 // linkage, alignment, section, visibility, threadlocal]
53 MODULE_CODE_GLOBALVAR = 7,
54
55 // FUNCTION: [type, callingconv, isproto, linkage, paramattrs, alignment,
56 // section, visibility]
57 MODULE_CODE_FUNCTION = 8,
Misha Brukman662086a2009-02-20 23:04:06 +000058
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059 // ALIAS: [alias type, aliasee val#, linkage]
60 MODULE_CODE_ALIAS = 9,
Misha Brukman662086a2009-02-20 23:04:06 +000061
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062 /// MODULE_CODE_PURGEVALS: [numvals]
Gordon Henriksen13fe5e32007-12-10 03:18:06 +000063 MODULE_CODE_PURGEVALS = 10,
Misha Brukman662086a2009-02-20 23:04:06 +000064
Gordon Henriksen1aed5992008-08-17 18:44:35 +000065 MODULE_CODE_GCNAME = 11 // GCNAME: [strchr x N]
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066 };
Misha Brukman662086a2009-02-20 23:04:06 +000067
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068 /// PARAMATTR blocks have code for defining a parameter attribute set.
Devang Pateld222f862008-09-25 21:00:45 +000069 enum AttributeCodes {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000070 PARAMATTR_CODE_ENTRY = 1 // ENTRY: [paramidx0, attr0, paramidx1, attr1...]
71 };
Misha Brukman662086a2009-02-20 23:04:06 +000072
Dan Gohmanf17a25c2007-07-18 16:29:46 +000073 /// TYPE blocks have codes for each type primitive they use.
74 enum TypeCodes {
75 TYPE_CODE_NUMENTRY = 1, // NUMENTRY: [numentries]
Misha Brukman662086a2009-02-20 23:04:06 +000076
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077 // Type Codes
78 TYPE_CODE_VOID = 2, // VOID
79 TYPE_CODE_FLOAT = 3, // FLOAT
80 TYPE_CODE_DOUBLE = 4, // DOUBLE
81 TYPE_CODE_LABEL = 5, // LABEL
82 TYPE_CODE_OPAQUE = 6, // OPAQUE
83 TYPE_CODE_INTEGER = 7, // INTEGER: [width]
84 TYPE_CODE_POINTER = 8, // POINTER: [pointee type]
85 TYPE_CODE_FUNCTION = 9, // FUNCTION: [vararg, retty, paramty x N]
86 TYPE_CODE_STRUCT = 10, // STRUCT: [ispacked, eltty x N]
87 TYPE_CODE_ARRAY = 11, // ARRAY: [numelts, eltty]
Dale Johannesenf325d9f2007-08-03 01:03:46 +000088 TYPE_CODE_VECTOR = 12, // VECTOR: [numelts, eltty]
89
90 // These are not with the other floating point types because they're
91 // a late addition, and putting them in the right place breaks
92 // binary compatibility.
93 TYPE_CODE_X86_FP80 = 13, // X86 LONG DOUBLE
94 TYPE_CODE_FP128 = 14, // LONG DOUBLE (112 bit mantissa)
Nick Lewycky29aaef82009-05-30 05:06:04 +000095 TYPE_CODE_PPC_FP128= 15, // PPC LONG DOUBLE (2 doubles)
96
97 TYPE_CODE_METADATA = 16 // METADATA
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098 };
Misha Brukman662086a2009-02-20 23:04:06 +000099
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100 // The type symbol table only has one code (TST_ENTRY_CODE).
101 enum TypeSymtabCodes {
102 TST_CODE_ENTRY = 1 // TST_ENTRY: [typeid, namechar x N]
103 };
Misha Brukman662086a2009-02-20 23:04:06 +0000104
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000105 // The value symbol table only has one code (VST_ENTRY_CODE).
106 enum ValueSymtabCodes {
107 VST_CODE_ENTRY = 1, // VST_ENTRY: [valid, namechar x N]
108 VST_CODE_BBENTRY = 2 // VST_BBENTRY: [bbid, namechar x N]
109 };
Misha Brukman662086a2009-02-20 23:04:06 +0000110
Devang Patel0c0a6ca2009-07-22 17:43:22 +0000111 enum MetadataCodes {
Devang Patel3e1ef932009-07-29 22:34:41 +0000112 METADATA_STRING = 1, // MDSTRING: [values]
113 METADATA_NODE = 2, // MDNODE: [n x (type num, value num)]
114 METADATA_NAME = 3, // STRING: [values]
Devang Pateladc37612009-09-18 19:26:43 +0000115 METADATA_NAMED_NODE = 4, // NAMEDMDNODE: [n x mdnodes]
116 METADATA_KIND = 5, // [n x [id, name]]
117 METADATA_ATTACHMENT = 6 // [m x [value, [n x [id, mdnode]]]
Devang Patel0c0a6ca2009-07-22 17:43:22 +0000118 };
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000119 // The constants block (CONSTANTS_BLOCK_ID) describes emission for each
120 // constant and maintains an implicit current type value.
121 enum ConstantsCodes {
122 CST_CODE_SETTYPE = 1, // SETTYPE: [typeid]
123 CST_CODE_NULL = 2, // NULL
124 CST_CODE_UNDEF = 3, // UNDEF
125 CST_CODE_INTEGER = 4, // INTEGER: [intval]
126 CST_CODE_WIDE_INTEGER = 5, // WIDE_INTEGER: [n x intval]
127 CST_CODE_FLOAT = 6, // FLOAT: [fpval]
128 CST_CODE_AGGREGATE = 7, // AGGREGATE: [n x value number]
129 CST_CODE_STRING = 8, // STRING: [values]
130 CST_CODE_CSTRING = 9, // CSTRING: [values]
131 CST_CODE_CE_BINOP = 10, // CE_BINOP: [opcode, opval, opval]
132 CST_CODE_CE_CAST = 11, // CE_CAST: [opcode, opty, opval]
133 CST_CODE_CE_GEP = 12, // CE_GEP: [n x operands]
134 CST_CODE_CE_SELECT = 13, // CE_SELECT: [opval, opval, opval]
135 CST_CODE_CE_EXTRACTELT = 14, // CE_EXTRACTELT: [opty, opval, opval]
136 CST_CODE_CE_INSERTELT = 15, // CE_INSERTELT: [opval, opval, opval]
137 CST_CODE_CE_SHUFFLEVEC = 16, // CE_SHUFFLEVEC: [opval, opval, opval]
138 CST_CODE_CE_CMP = 17, // CE_CMP: [opty, opval, opval, pred]
Nate Begemand6d715b2009-02-12 21:28:33 +0000139 CST_CODE_INLINEASM = 18, // INLINEASM: [sideeffect,asmstr,conststr]
Dan Gohman106b2ae2009-07-27 21:53:46 +0000140 CST_CODE_CE_SHUFVEC_EX = 19, // SHUFVEC_EX: [opty, opval, opval, opval]
141 CST_CODE_CE_INBOUNDS_GEP = 20 // INBOUNDS_GEP: [n x operands]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000142 };
Misha Brukman662086a2009-02-20 23:04:06 +0000143
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000144 /// CastOpcodes - These are values used in the bitcode files to encode which
145 /// cast a CST_CODE_CE_CAST or a XXX refers to. The values of these enums
146 /// have no fixed relation to the LLVM IR enum values. Changing these will
147 /// break compatibility with old files.
148 enum CastOpcodes {
149 CAST_TRUNC = 0,
150 CAST_ZEXT = 1,
151 CAST_SEXT = 2,
152 CAST_FPTOUI = 3,
153 CAST_FPTOSI = 4,
154 CAST_UITOFP = 5,
155 CAST_SITOFP = 6,
156 CAST_FPTRUNC = 7,
157 CAST_FPEXT = 8,
158 CAST_PTRTOINT = 9,
159 CAST_INTTOPTR = 10,
160 CAST_BITCAST = 11
161 };
Misha Brukman662086a2009-02-20 23:04:06 +0000162
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163 /// BinaryOpcodes - These are values used in the bitcode files to encode which
164 /// binop a CST_CODE_CE_BINOP or a XXX refers to. The values of these enums
165 /// have no fixed relation to the LLVM IR enum values. Changing these will
166 /// break compatibility with old files.
167 enum BinaryOpcodes {
168 BINOP_ADD = 0,
169 BINOP_SUB = 1,
170 BINOP_MUL = 2,
171 BINOP_UDIV = 3,
172 BINOP_SDIV = 4, // overloaded for FP
173 BINOP_UREM = 5,
174 BINOP_SREM = 6, // overloaded for FP
175 BINOP_SHL = 7,
176 BINOP_LSHR = 8,
177 BINOP_ASHR = 9,
178 BINOP_AND = 10,
179 BINOP_OR = 11,
180 BINOP_XOR = 12
181 };
Misha Brukman662086a2009-02-20 23:04:06 +0000182
Dan Gohman799a8c82009-07-20 21:19:07 +0000183 /// OverflowingBinaryOperatorOptionalFlags - Flags for serializing
184 /// OverflowingBinaryOperator's SubclassOptionalData contents.
185 enum OverflowingBinaryOperatorOptionalFlags {
Dan Gohmanb5ed4492009-08-20 17:11:38 +0000186 OBO_NO_UNSIGNED_WRAP = 0,
187 OBO_NO_SIGNED_WRAP = 1
Dan Gohman799a8c82009-07-20 21:19:07 +0000188 };
189
190 /// SDivOperatorOptionalFlags - Flags for serializing SDivOperator's
191 /// SubclassOptionalData contents.
192 enum SDivOperatorOptionalFlags {
193 SDIV_EXACT = 0
194 };
Misha Brukman662086a2009-02-20 23:04:06 +0000195
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196 // The function body block (FUNCTION_BLOCK_ID) describes function bodies. It
197 // can contain a constant block (CONSTANTS_BLOCK_ID).
198 enum FunctionCodes {
199 FUNC_CODE_DECLAREBLOCKS = 1, // DECLAREBLOCKS: [n]
Misha Brukman662086a2009-02-20 23:04:06 +0000200
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 FUNC_CODE_INST_BINOP = 2, // BINOP: [opcode, ty, opval, opval]
202 FUNC_CODE_INST_CAST = 3, // CAST: [opcode, ty, opty, opval]
203 FUNC_CODE_INST_GEP = 4, // GEP: [n x operands]
204 FUNC_CODE_INST_SELECT = 5, // SELECT: [ty, opval, opval, opval]
205 FUNC_CODE_INST_EXTRACTELT = 6, // EXTRACTELT: [opty, opval, opval]
206 FUNC_CODE_INST_INSERTELT = 7, // INSERTELT: [ty, opval, opval, opval]
207 FUNC_CODE_INST_SHUFFLEVEC = 8, // SHUFFLEVEC: [ty, opval, opval, opval]
208 FUNC_CODE_INST_CMP = 9, // CMP: [opty, opval, opval, pred]
Misha Brukman662086a2009-02-20 23:04:06 +0000209
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000210 FUNC_CODE_INST_RET = 10, // RET: [opty,opval<both optional>]
211 FUNC_CODE_INST_BR = 11, // BR: [bb#, bb#, cond] or [bb#]
Chris Lattner41fc6ad2009-10-27 21:27:42 +0000212 FUNC_CODE_INST_SWITCH = 12, // SWITCH: [opty, op0, op1, ...]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213 FUNC_CODE_INST_INVOKE = 13, // INVOKE: [attr, fnty, op0,op1, ...]
214 FUNC_CODE_INST_UNWIND = 14, // UNWIND
215 FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE
Misha Brukman662086a2009-02-20 23:04:06 +0000216
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000217 FUNC_CODE_INST_PHI = 16, // PHI: [ty, val0,bb0, ...]
218 FUNC_CODE_INST_MALLOC = 17, // MALLOC: [instty, op, align]
219 FUNC_CODE_INST_FREE = 18, // FREE: [opty, op]
220 FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, op, align]
221 FUNC_CODE_INST_LOAD = 20, // LOAD: [opty, op, align, vol]
Christopher Lamb20a39e92007-12-12 08:44:39 +0000222 // FIXME: Remove STORE in favor of STORE2 in LLVM 3.0
Christopher Lamb44d62f62007-12-11 08:59:05 +0000223 FUNC_CODE_INST_STORE = 21, // STORE: [valty,val,ptr, align, vol]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000224 FUNC_CODE_INST_CALL = 22, // CALL: [attr, fnty, fnid, args...]
Christopher Lamb44d62f62007-12-11 08:59:05 +0000225 FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, valist, instty]
226 // This store code encodes the pointer type, rather than the value type
227 // this is so information only available in the pointer type (e.g. address
228 // spaces) is retained.
Devang Patel774ee9e2008-02-22 02:49:49 +0000229 FUNC_CODE_INST_STORE2 = 24, // STORE: [ptrty,ptr,val, align, vol]
Dan Gohman29474e92008-07-23 00:34:11 +0000230 // FIXME: Remove GETRESULT in favor of EXTRACTVAL in LLVM 3.0
Dan Gohmane6b1ee62008-05-23 01:55:30 +0000231 FUNC_CODE_INST_GETRESULT = 25, // GETRESULT: [ty, opval, n]
232 FUNC_CODE_INST_EXTRACTVAL = 26, // EXTRACTVAL: [n x operands]
Dan Gohmanb60ca3c2008-09-09 01:02:47 +0000233 FUNC_CODE_INST_INSERTVAL = 27, // INSERTVAL: [n x operands]
Nick Lewycky8f5253b2009-07-08 03:04:38 +0000234 // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to
235 // support legacy vicmp/vfcmp instructions.
Dan Gohman3ecdb552008-09-23 18:27:53 +0000236 FUNC_CODE_INST_CMP2 = 28, // CMP2: [opty, opval, opval, pred]
Dan Gohman6fa5bce2008-09-16 01:01:33 +0000237 // new select on i1 or [N x i1]
Dan Gohman106b2ae2009-07-27 21:53:46 +0000238 FUNC_CODE_INST_VSELECT = 29, // VSELECT: [ty,opval,opval,predty,pred]
Chris Lattnere0787282009-10-27 19:13:16 +0000239 FUNC_CODE_INST_INBOUNDS_GEP= 30, // INBOUNDS_GEP: [n x operands]
Chris Lattner41fc6ad2009-10-27 21:27:42 +0000240 FUNC_CODE_INST_INDBR = 31 // INDBR: [opty, op0, op1, ...]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000241 };
242} // End bitc namespace
243} // End llvm namespace
244
245#endif