blob: f1809a25d091af079fbb01247a6262acd77f127e [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,
29
30 // 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,
36 VALUE_SYMTAB_BLOCK_ID
37 };
38
39
40 /// MODULE blocks have a number of optional fields and subblocks.
41 enum ModuleCodes {
42 MODULE_CODE_VERSION = 1, // VERSION: [version#]
43 MODULE_CODE_TRIPLE = 2, // TRIPLE: [strchr x N]
44 MODULE_CODE_DATALAYOUT = 3, // DATALAYOUT: [strchr x N]
45 MODULE_CODE_ASM = 4, // ASM: [strchr x N]
46 MODULE_CODE_SECTIONNAME = 5, // SECTIONNAME: [strchr x N]
47 MODULE_CODE_DEPLIB = 6, // DEPLIB: [strchr x N]
48
Christopher Lamb44d62f62007-12-11 08:59:05 +000049 // GLOBALVAR: [pointer type, isconst, initid,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050 // linkage, alignment, section, visibility, threadlocal]
51 MODULE_CODE_GLOBALVAR = 7,
52
53 // FUNCTION: [type, callingconv, isproto, linkage, paramattrs, alignment,
54 // section, visibility]
55 MODULE_CODE_FUNCTION = 8,
56
57 // ALIAS: [alias type, aliasee val#, linkage]
58 MODULE_CODE_ALIAS = 9,
59
60 /// MODULE_CODE_PURGEVALS: [numvals]
Gordon Henriksen13fe5e32007-12-10 03:18:06 +000061 MODULE_CODE_PURGEVALS = 10,
62
Gordon Henriksen1aed5992008-08-17 18:44:35 +000063 MODULE_CODE_GCNAME = 11 // GCNAME: [strchr x N]
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064 };
65
66 /// PARAMATTR blocks have code for defining a parameter attribute set.
Devang Pateld222f862008-09-25 21:00:45 +000067 enum AttributeCodes {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068 PARAMATTR_CODE_ENTRY = 1 // ENTRY: [paramidx0, attr0, paramidx1, attr1...]
69 };
70
71 /// TYPE blocks have codes for each type primitive they use.
72 enum TypeCodes {
73 TYPE_CODE_NUMENTRY = 1, // NUMENTRY: [numentries]
74
75 // Type Codes
76 TYPE_CODE_VOID = 2, // VOID
77 TYPE_CODE_FLOAT = 3, // FLOAT
78 TYPE_CODE_DOUBLE = 4, // DOUBLE
79 TYPE_CODE_LABEL = 5, // LABEL
80 TYPE_CODE_OPAQUE = 6, // OPAQUE
81 TYPE_CODE_INTEGER = 7, // INTEGER: [width]
82 TYPE_CODE_POINTER = 8, // POINTER: [pointee type]
83 TYPE_CODE_FUNCTION = 9, // FUNCTION: [vararg, retty, paramty x N]
84 TYPE_CODE_STRUCT = 10, // STRUCT: [ispacked, eltty x N]
85 TYPE_CODE_ARRAY = 11, // ARRAY: [numelts, eltty]
Dale Johannesenf325d9f2007-08-03 01:03:46 +000086 TYPE_CODE_VECTOR = 12, // VECTOR: [numelts, eltty]
87
88 // These are not with the other floating point types because they're
89 // a late addition, and putting them in the right place breaks
90 // binary compatibility.
91 TYPE_CODE_X86_FP80 = 13, // X86 LONG DOUBLE
92 TYPE_CODE_FP128 = 14, // LONG DOUBLE (112 bit mantissa)
93 TYPE_CODE_PPC_FP128= 15 // PPC LONG DOUBLE (2 doubles)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094 // Any other type code is assumed to be an unknown type.
95 };
96
97 // The type symbol table only has one code (TST_ENTRY_CODE).
98 enum TypeSymtabCodes {
99 TST_CODE_ENTRY = 1 // TST_ENTRY: [typeid, namechar x N]
100 };
101
102 // The value symbol table only has one code (VST_ENTRY_CODE).
103 enum ValueSymtabCodes {
104 VST_CODE_ENTRY = 1, // VST_ENTRY: [valid, namechar x N]
105 VST_CODE_BBENTRY = 2 // VST_BBENTRY: [bbid, namechar x N]
106 };
107
108 // The constants block (CONSTANTS_BLOCK_ID) describes emission for each
109 // constant and maintains an implicit current type value.
110 enum ConstantsCodes {
111 CST_CODE_SETTYPE = 1, // SETTYPE: [typeid]
112 CST_CODE_NULL = 2, // NULL
113 CST_CODE_UNDEF = 3, // UNDEF
114 CST_CODE_INTEGER = 4, // INTEGER: [intval]
115 CST_CODE_WIDE_INTEGER = 5, // WIDE_INTEGER: [n x intval]
116 CST_CODE_FLOAT = 6, // FLOAT: [fpval]
117 CST_CODE_AGGREGATE = 7, // AGGREGATE: [n x value number]
118 CST_CODE_STRING = 8, // STRING: [values]
119 CST_CODE_CSTRING = 9, // CSTRING: [values]
120 CST_CODE_CE_BINOP = 10, // CE_BINOP: [opcode, opval, opval]
121 CST_CODE_CE_CAST = 11, // CE_CAST: [opcode, opty, opval]
122 CST_CODE_CE_GEP = 12, // CE_GEP: [n x operands]
123 CST_CODE_CE_SELECT = 13, // CE_SELECT: [opval, opval, opval]
124 CST_CODE_CE_EXTRACTELT = 14, // CE_EXTRACTELT: [opty, opval, opval]
125 CST_CODE_CE_INSERTELT = 15, // CE_INSERTELT: [opval, opval, opval]
126 CST_CODE_CE_SHUFFLEVEC = 16, // CE_SHUFFLEVEC: [opval, opval, opval]
127 CST_CODE_CE_CMP = 17, // CE_CMP: [opty, opval, opval, pred]
Nate Begemand6d715b2009-02-12 21:28:33 +0000128 CST_CODE_INLINEASM = 18, // INLINEASM: [sideeffect,asmstr,conststr]
129 CST_CODE_CE_SHUFVEC_EX = 19 // SHUFVEC_EX: [opty, opval, opval, opval]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130 };
131
132 /// CastOpcodes - These are values used in the bitcode files to encode which
133 /// cast a CST_CODE_CE_CAST or a XXX refers to. The values of these enums
134 /// have no fixed relation to the LLVM IR enum values. Changing these will
135 /// break compatibility with old files.
136 enum CastOpcodes {
137 CAST_TRUNC = 0,
138 CAST_ZEXT = 1,
139 CAST_SEXT = 2,
140 CAST_FPTOUI = 3,
141 CAST_FPTOSI = 4,
142 CAST_UITOFP = 5,
143 CAST_SITOFP = 6,
144 CAST_FPTRUNC = 7,
145 CAST_FPEXT = 8,
146 CAST_PTRTOINT = 9,
147 CAST_INTTOPTR = 10,
148 CAST_BITCAST = 11
149 };
150
151 /// BinaryOpcodes - These are values used in the bitcode files to encode which
152 /// binop a CST_CODE_CE_BINOP or a XXX refers to. The values of these enums
153 /// have no fixed relation to the LLVM IR enum values. Changing these will
154 /// break compatibility with old files.
155 enum BinaryOpcodes {
156 BINOP_ADD = 0,
157 BINOP_SUB = 1,
158 BINOP_MUL = 2,
159 BINOP_UDIV = 3,
160 BINOP_SDIV = 4, // overloaded for FP
161 BINOP_UREM = 5,
162 BINOP_SREM = 6, // overloaded for FP
163 BINOP_SHL = 7,
164 BINOP_LSHR = 8,
165 BINOP_ASHR = 9,
166 BINOP_AND = 10,
167 BINOP_OR = 11,
168 BINOP_XOR = 12
169 };
170
171
172 // The function body block (FUNCTION_BLOCK_ID) describes function bodies. It
173 // can contain a constant block (CONSTANTS_BLOCK_ID).
174 enum FunctionCodes {
175 FUNC_CODE_DECLAREBLOCKS = 1, // DECLAREBLOCKS: [n]
176
177 FUNC_CODE_INST_BINOP = 2, // BINOP: [opcode, ty, opval, opval]
178 FUNC_CODE_INST_CAST = 3, // CAST: [opcode, ty, opty, opval]
179 FUNC_CODE_INST_GEP = 4, // GEP: [n x operands]
180 FUNC_CODE_INST_SELECT = 5, // SELECT: [ty, opval, opval, opval]
181 FUNC_CODE_INST_EXTRACTELT = 6, // EXTRACTELT: [opty, opval, opval]
182 FUNC_CODE_INST_INSERTELT = 7, // INSERTELT: [ty, opval, opval, opval]
183 FUNC_CODE_INST_SHUFFLEVEC = 8, // SHUFFLEVEC: [ty, opval, opval, opval]
184 FUNC_CODE_INST_CMP = 9, // CMP: [opty, opval, opval, pred]
185
186 FUNC_CODE_INST_RET = 10, // RET: [opty,opval<both optional>]
187 FUNC_CODE_INST_BR = 11, // BR: [bb#, bb#, cond] or [bb#]
188 FUNC_CODE_INST_SWITCH = 12, // SWITCH: [opty, opval, n, n x ops]
189 FUNC_CODE_INST_INVOKE = 13, // INVOKE: [attr, fnty, op0,op1, ...]
190 FUNC_CODE_INST_UNWIND = 14, // UNWIND
191 FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE
192
193 FUNC_CODE_INST_PHI = 16, // PHI: [ty, val0,bb0, ...]
194 FUNC_CODE_INST_MALLOC = 17, // MALLOC: [instty, op, align]
195 FUNC_CODE_INST_FREE = 18, // FREE: [opty, op]
196 FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, op, align]
197 FUNC_CODE_INST_LOAD = 20, // LOAD: [opty, op, align, vol]
Christopher Lamb20a39e92007-12-12 08:44:39 +0000198 // FIXME: Remove STORE in favor of STORE2 in LLVM 3.0
Christopher Lamb44d62f62007-12-11 08:59:05 +0000199 FUNC_CODE_INST_STORE = 21, // STORE: [valty,val,ptr, align, vol]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 FUNC_CODE_INST_CALL = 22, // CALL: [attr, fnty, fnid, args...]
Christopher Lamb44d62f62007-12-11 08:59:05 +0000201 FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, valist, instty]
202 // This store code encodes the pointer type, rather than the value type
203 // this is so information only available in the pointer type (e.g. address
204 // spaces) is retained.
Devang Patel774ee9e2008-02-22 02:49:49 +0000205 FUNC_CODE_INST_STORE2 = 24, // STORE: [ptrty,ptr,val, align, vol]
Dan Gohman29474e92008-07-23 00:34:11 +0000206 // FIXME: Remove GETRESULT in favor of EXTRACTVAL in LLVM 3.0
Dan Gohmane6b1ee62008-05-23 01:55:30 +0000207 FUNC_CODE_INST_GETRESULT = 25, // GETRESULT: [ty, opval, n]
208 FUNC_CODE_INST_EXTRACTVAL = 26, // EXTRACTVAL: [n x operands]
Dan Gohmanb60ca3c2008-09-09 01:02:47 +0000209 FUNC_CODE_INST_INSERTVAL = 27, // INSERTVAL: [n x operands]
Dan Gohman6fa5bce2008-09-16 01:01:33 +0000210 // fcmp/icmp returning Int1TY or vector of Int1Ty, NOT for vicmp/vfcmp
Dan Gohman3ecdb552008-09-23 18:27:53 +0000211 FUNC_CODE_INST_CMP2 = 28, // CMP2: [opty, opval, opval, pred]
Dan Gohman6fa5bce2008-09-16 01:01:33 +0000212 // new select on i1 or [N x i1]
213 FUNC_CODE_INST_VSELECT = 29 // VSELECT: [ty,opval,opval,predty,pred]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000214 };
215} // End bitc namespace
216} // End llvm namespace
217
218#endif