1 //===- NaClLLVMBitCodes.h ---------------------------------------*- C++ -*-===// 2 // Enum values for the NaCl bitcode wire format 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is distributed under the University of Illinois Open Source 7 // License. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 // 11 // This header defines Bitcode enum values for NaCl bitcode wire format. 12 // 13 // The enum values defined in this file should be considered permanent. If 14 // new features are added, they should have values added at the end of the 15 // respective lists. 16 // 17 // Note: PNaCl version 1 is no longer supported, and has been removed from 18 // comments. 19 // 20 //===----------------------------------------------------------------------===// 21 22 #ifndef LLVM_BITCODE_NACL_NACLLLVMBITCODES_H 23 #define LLVM_BITCODE_NACL_NACLLLVMBITCODES_H 24 25 #include "llvm/Bitcode/NaCl/NaClBitCodes.h" 26 27 namespace llvm { 28 namespace naclbitc { 29 // The only top-level block type defined is for a module. 30 enum NaClBlockIDs { 31 // Blocks 32 MODULE_BLOCK_ID = FIRST_APPLICATION_BLOCKID, 33 34 // Module sub-block id's. 35 PARAMATTR_BLOCK_ID, // Not used in PNaCl. 36 PARAMATTR_GROUP_BLOCK_ID, // Not used in PNaCl. 37 38 CONSTANTS_BLOCK_ID, 39 FUNCTION_BLOCK_ID, 40 41 UNUSED_ID1, 42 43 VALUE_SYMTAB_BLOCK_ID, 44 METADATA_BLOCK_ID, // Not used in PNaCl. 45 METADATA_ATTACHMENT_ID, // Not used in PNaCl. 46 47 TYPE_BLOCK_ID_NEW, 48 49 USELIST_BLOCK_ID, // Not used in PNaCl. 50 GLOBALVAR_BLOCK_ID 51 }; 52 53 54 /// MODULE blocks have a number of optional fields and subblocks. 55 enum NaClModuleCodes { 56 MODULE_CODE_VERSION = 1, // VERSION: [version#] 57 MODULE_CODE_TRIPLE = 2, // Not used in PNaCl 58 MODULE_CODE_DATALAYOUT = 3, // Not used in PNaCl 59 MODULE_CODE_ASM = 4, // Not used in PNaCl 60 MODULE_CODE_SECTIONNAME = 5, // Not used in PNaCl 61 MODULE_CODE_DEPLIB = 6, // Not used in PNaCl 62 MODULE_CODE_GLOBALVAR = 7, // Not used in PNaCl 63 // FUNCTION: [type, callingconv, isproto, linkage] 64 MODULE_CODE_FUNCTION = 8, 65 MODULE_CODE_ALIAS = 9, // Not used in PNaCl 66 MODULE_CODE_PURGEVALS = 10, // Not used in PNaCl 67 MODULE_CODE_GCNAME = 11 // Not used in PNaCl 68 }; 69 70 /// PARAMATTR blocks have code for defining a parameter attribute set. 71 enum NaClAttributeCodes { 72 // FIXME: Remove `PARAMATTR_CODE_ENTRY_OLD' in 4.0 73 PARAMATTR_CODE_ENTRY_OLD = 1, // ENTRY: [paramidx0, attr0, 74 // paramidx1, attr1...] 75 PARAMATTR_CODE_ENTRY = 2, // ENTRY: [paramidx0, attrgrp0, 76 // paramidx1, attrgrp1, ...] 77 PARAMATTR_GRP_CODE_ENTRY = 3 // ENTRY: [id, attr0, att1, ...] 78 }; 79 80 /// TYPE blocks have codes for each type primitive they use. 81 enum NaClTypeCodes { 82 TYPE_CODE_NUMENTRY = 1, // NUMENTRY: [numentries] 83 84 // Type Codes 85 TYPE_CODE_VOID = 2, // VOID 86 TYPE_CODE_FLOAT = 3, // FLOAT 87 TYPE_CODE_DOUBLE = 4, // DOUBLE 88 // TODO(mseaborn): Remove LABEL when we drop support for v1 of the 89 // PNaCl bitcode format. The writer no longer generates it. 90 TYPE_CODE_LABEL = 5, // LABEL 91 TYPE_CODE_OPAQUE = 6, // Not used in PNaCl. 92 TYPE_CODE_INTEGER = 7, // INTEGER: [width] 93 TYPE_CODE_POINTER = 8, // POINTER: [pointee type] 94 95 TYPE_CODE_FUNCTION_OLD = 9, // Not used in PNaCl. 96 97 TYPE_CODE_HALF = 10, // Not used in PNaCl. 98 99 TYPE_CODE_ARRAY = 11, // Not used in PNaCl. 100 TYPE_CODE_VECTOR = 12, // VECTOR: [numelts, eltty] 101 102 // These are not with the other floating point types because they're 103 // a late addition, and putting them in the right place breaks 104 // binary compatibility. 105 TYPE_CODE_X86_FP80 = 13, // Not used in PNaCl. 106 TYPE_CODE_FP128 = 14, // Not used in PNaCl. 107 TYPE_CODE_PPC_FP128= 15, // Not used in PNaCl. 108 109 TYPE_CODE_METADATA = 16, // Not used in PNaCl. 110 111 TYPE_CODE_X86_MMX = 17, // Not used in PNaCl. 112 113 TYPE_CODE_STRUCT_ANON = 18, // Not used in PNaCl. 114 TYPE_CODE_STRUCT_NAME = 19, // Not used in PNaCl. 115 TYPE_CODE_STRUCT_NAMED = 20,// Not used in PNaCl. 116 117 TYPE_CODE_FUNCTION = 21 // FUNCTION: [vararg, retty, paramty x N] 118 }; 119 120 // The type symbol table only has one code (TST_ENTRY_CODE). 121 enum NaClTypeSymtabCodes { 122 TST_CODE_ENTRY = 1 // TST_ENTRY: [typeid, namechar x N] 123 }; 124 125 // The value symbol table only has one code (VST_ENTRY_CODE). 126 enum NaClValueSymtabCodes { 127 VST_CODE_ENTRY = 1, // VST_ENTRY: [valid, namechar x N] 128 VST_CODE_BBENTRY = 2 // VST_BBENTRY: [bbid, namechar x N] 129 }; 130 131 // Not used in PNaCl. 132 enum NaClMetadataCodes { 133 METADATA_STRING = 1, // MDSTRING: [values] 134 // 2 is unused. 135 // 3 is unused. 136 METADATA_NAME = 4, // STRING: [values] 137 // 5 is unused. 138 METADATA_KIND = 6, // [n x [id, name]] 139 // 7 is unused. 140 METADATA_NODE = 8, // NODE: [n x (type num, value num)] 141 METADATA_FN_NODE = 9, // FN_NODE: [n x (type num, value num)] 142 METADATA_NAMED_NODE = 10, // NAMED_NODE: [n x mdnodes] 143 METADATA_ATTACHMENT = 11 // [m x [value, [n x [id, mdnode]]] 144 }; 145 146 // The constants block (CONSTANTS_BLOCK_ID) describes emission for each 147 // constant and maintains an implicit current type value. 148 enum NaClConstantsCodes { 149 CST_CODE_SETTYPE = 1, // SETTYPE: [typeid] 150 CST_CODE_NULL = 2, // Not used in PNaCl. 151 CST_CODE_UNDEF = 3, // UNDEF 152 CST_CODE_INTEGER = 4, // INTEGER: [intval] 153 CST_CODE_WIDE_INTEGER = 5, // Not used in PNaCl. 154 CST_CODE_FLOAT = 6, // FLOAT: [fpval] 155 CST_CODE_AGGREGATE = 7, // Not used in PNaCl. 156 CST_CODE_STRING = 8, // Not used in PNaCl. 157 CST_CODE_CSTRING = 9, // Not used in PNaCl. 158 CST_CODE_CE_BINOP = 10, // Not used in PNaCl. 159 CST_CODE_CE_CAST = 11, // Not used in PNaCl. 160 CST_CODE_CE_GEP = 12, // Not used in PNaCl. 161 CST_CODE_CE_SELECT = 13, // Not used in PNaCl. 162 CST_CODE_CE_EXTRACTELT = 14, // Not used in PNaCl. 163 CST_CODE_CE_INSERTELT = 15, // Not used in PNaCl. 164 CST_CODE_CE_SHUFFLEVEC = 16, // Not used in PNaCl. 165 CST_CODE_CE_CMP = 17, // Not used in PNaCl. 166 CST_CODE_INLINEASM_OLD = 18, // No longer used. 167 CST_CODE_CE_SHUFVEC_EX = 19, // Not used in PNaCl. 168 CST_CODE_CE_INBOUNDS_GEP = 20,// Not used in PNaCl. 169 CST_CODE_BLOCKADDRESS = 21, // Not used in PNaCl. 170 CST_CODE_DATA = 22, // Not used in PNaCl. 171 CST_CODE_INLINEASM = 23 // Not used in PNaCl. 172 }; 173 174 /// GlobalVarOpcodes - These are values used in the bitcode files to 175 /// encode records defining global variables. 176 /// 177 /// The structure of global variables can be summarized as follows: 178 /// 179 /// The global variable block begins with a GLOBALVAR_COUNT, defining 180 /// the number of global variables in the bitcode file. After that, 181 /// each global variable is defined. 182 /// 183 /// Global variables are defined by a GLOBALVAR_VAR record, followed 184 /// by 1 or more records defining its initial value. Simple 185 /// variables have a single initializer. Structured variables are 186 /// defined by an initial GLOBALVAR_COMPOUND record defining the 187 /// number of fields in the structure, followed by an initializer 188 /// for each of its fields. In this context, a field is either data, 189 /// or a relocation. A data field is defined by a 190 /// GLOBALVAR_ZEROFILL or GLOBALVAR_DATA record. A relocation field 191 /// is defined by a GLOBALVAR_RELOC record. 192 enum NaClGlobalVarOpcodes { 193 GLOBALVAR_VAR = 0, // VAR: [align, isconst] 194 GLOBALVAR_COMPOUND = 1, // COMPOUND: [size] 195 GLOBALVAR_ZEROFILL = 2, // ZEROFILL: [size] 196 GLOBALVAR_DATA = 3, // DATA: [b0, b1, ...] 197 GLOBALVAR_RELOC = 4, // RELOC: [val, [addend]] 198 GLOBALVAR_COUNT = 5 // COUNT: [n] 199 }; 200 201 /// CastOpcodes - These are values used in the bitcode files to encode which 202 /// cast a CST_CODE_CE_CAST or a XXX refers to. The values of these enums 203 /// have no fixed relation to the LLVM IR enum values. Changing these will 204 /// break compatibility with old files. 205 enum NaClCastOpcodes { 206 CAST_TRUNC = 0, 207 CAST_ZEXT = 1, 208 CAST_SEXT = 2, 209 CAST_FPTOUI = 3, 210 CAST_FPTOSI = 4, 211 CAST_UITOFP = 5, 212 CAST_SITOFP = 6, 213 CAST_FPTRUNC = 7, 214 CAST_FPEXT = 8, 215 // 9 was CAST_PTRTOINT; not used in PNaCl. 216 // 10 was CAST_INTTOPTR; not used in PNaCl. 217 CAST_BITCAST = 11 218 }; 219 220 /// BinaryOpcodes - These are values used in the bitcode files to encode which 221 /// binop a CST_CODE_CE_BINOP or a XXX refers to. The values of these enums 222 /// have no fixed relation to the LLVM IR enum values. Changing these will 223 /// break compatibility with old files. 224 enum NaClBinaryOpcodes { 225 BINOP_ADD = 0, 226 BINOP_SUB = 1, 227 BINOP_MUL = 2, 228 BINOP_UDIV = 3, 229 BINOP_SDIV = 4, // overloaded for FP 230 BINOP_UREM = 5, 231 BINOP_SREM = 6, // overloaded for FP 232 BINOP_SHL = 7, 233 BINOP_LSHR = 8, 234 BINOP_ASHR = 9, 235 BINOP_AND = 10, 236 BINOP_OR = 11, 237 BINOP_XOR = 12 238 }; 239 240 /// OverflowingBinaryOperatorOptionalFlags - Flags for serializing 241 /// OverflowingBinaryOperator's SubclassOptionalData contents. 242 /// Note: This enum is no longer used in PNaCl, because these 243 /// flags can't exist in files that meet the PNaCl ABI. 244 enum NaClOverflowingBinaryOperatorOptionalFlags { 245 OBO_NO_UNSIGNED_WRAP = 0, 246 OBO_NO_SIGNED_WRAP = 1 247 }; 248 249 /// PossiblyExactOperatorOptionalFlags - Flags for serializing 250 /// PossiblyExactOperator's SubclassOptionalData contents. 251 /// Note: This enum is no longer used in PNaCl, because these 252 /// flags can't exist in files that meet the PNaCl ABI. 253 enum NaClPossiblyExactOperatorOptionalFlags { 254 PEO_EXACT = 0 255 }; 256 257 /// \brief Flags for serializing floating point binary operators's 258 /// SubclassOptionalData contents. 259 /// Note: This enum is no longer used in PNaCl, because these 260 /// flags shouldn't exist in files that meet the PNaCl ABI, unless 261 /// they are old. In the latter case, they are ignored by the reader. 262 enum NaClFloatingPointBinaryOperatorOptionalFlags { 263 FPO_UNSAFE_ALGEBRA = 0, 264 FPO_NO_NANS = 1, 265 FPO_NO_INFS = 2, 266 FPO_NO_SIGNED_ZEROS = 3, 267 FPO_ALLOW_RECIPROCAL = 4 268 }; 269 270 /// Encoded function calling conventions. 271 enum NaClCallingConventions { 272 C_CallingConv = 0 273 }; 274 275 /// Encoded comparison predicates. 276 enum NaClComparisonPredicates { 277 // Opcode U L G E Intuitive operation 278 FCMP_FALSE = 0, ///< 0 0 0 0 Always false (always folded) 279 FCMP_OEQ = 1, ///< 0 0 0 1 True if ordered and equal 280 FCMP_OGT = 2, ///< 0 0 1 0 True if ordered and greater than 281 FCMP_OGE = 3, ///< 0 0 1 1 True if ordered and greater than or equal 282 FCMP_OLT = 4, ///< 0 1 0 0 True if ordered and less than 283 FCMP_OLE = 5, ///< 0 1 0 1 True if ordered and less than or equal 284 FCMP_ONE = 6, ///< 0 1 1 0 True if ordered and operands are unequal 285 FCMP_ORD = 7, ///< 0 1 1 1 True if ordered (no nans) 286 FCMP_UNO = 8, ///< 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 287 FCMP_UEQ = 9, ///< 1 0 0 1 True if unordered or equal 288 FCMP_UGT = 10, ///< 1 0 1 0 True if unordered or greater than 289 FCMP_UGE = 11, ///< 1 0 1 1 True if unordered, greater than, or equal 290 FCMP_ULT = 12, ///< 1 1 0 0 True if unordered or less than 291 FCMP_ULE = 13, ///< 1 1 0 1 True if unordered, less than, or equal 292 FCMP_UNE = 14, ///< 1 1 1 0 True if unordered or not equal 293 FCMP_TRUE = 15, ///< 1 1 1 1 Always true (always folded) 294 ICMP_EQ = 32, ///< equal 295 ICMP_NE = 33, ///< not equal 296 ICMP_UGT = 34, ///< unsigned greater than 297 ICMP_UGE = 35, ///< unsigned greater or equal 298 ICMP_ULT = 36, ///< unsigned less than 299 ICMP_ULE = 37, ///< unsigned less or equal 300 ICMP_SGT = 38, ///< signed greater than 301 ICMP_SGE = 39, ///< signed greater or equal 302 ICMP_SLT = 40, ///< signed less than 303 ICMP_SLE = 41 ///< signed less or equal 304 }; 305 306 enum NaClLinkageTypes { 307 LINKAGE_EXTERNAL = 0, 308 LINKAGE_INTERNAL = 3 309 }; 310 311 // The function body block (FUNCTION_BLOCK_ID) describes function bodies. It 312 // can contain a constant block (CONSTANTS_BLOCK_ID). 313 enum NaClFunctionCodes { 314 FUNC_CODE_DECLAREBLOCKS = 1, // DECLAREBLOCKS: [n] 315 316 FUNC_CODE_INST_BINOP = 2, // BINOP: [opval, opval, opcode] 317 // Note: because old PNaCl bitcode files 318 // may contain flags (which we now ignore), 319 // the reader must also support: 320 // BINOP: [opval, opval, opcode, flags] 321 FUNC_CODE_INST_CAST = 3, // CAST: [opval, destty, castopc] 322 FUNC_CODE_INST_GEP = 4, // Not used in PNaCl. 323 FUNC_CODE_INST_SELECT = 5, // Not used in PNaCl. Replaced by VSELECT. 324 FUNC_CODE_INST_EXTRACTELT = 6, // EXTRACTELT: [opval, opval] 325 FUNC_CODE_INST_INSERTELT = 7, // INSERTELT: [opval, opval, opval] 326 FUNC_CODE_INST_SHUFFLEVEC = 8, // Not used in PNaCl. 327 FUNC_CODE_INST_CMP = 9, // Not used in PNaCl. Replaced by CMP2. 328 FUNC_CODE_INST_RET = 10, // RET: [opval<optional>] 329 FUNC_CODE_INST_BR = 11, // BR: [bb#, bb#, cond] or [bb#] 330 FUNC_CODE_INST_SWITCH = 12, // SWITCH: [opty, op0, op1, ...] 331 FUNC_CODE_INST_INVOKE = 13, // Not used in PNaCl. 332 // 14 is unused. 333 FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE 334 335 FUNC_CODE_INST_PHI = 16, // PHI: [ty, val0,bb0, ...] 336 // 17 is unused. 337 // 18 is unused. 338 FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [op, align] 339 FUNC_CODE_INST_LOAD = 20, // LOAD: [op, align, ty] 340 // 21 is unused. 341 // 22 is unused. 342 FUNC_CODE_INST_VAARG = 23, // Not used in PNaCl. 343 FUNC_CODE_INST_STORE = 24, // STORE: [ptr, val, align] 344 // 25 is unused. 345 FUNC_CODE_INST_EXTRACTVAL = 26, // Not used in PNaCl. 346 FUNC_CODE_INST_INSERTVAL = 27, // Not used in PNaCl. 347 // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to 348 // support legacy vicmp/vfcmp instructions. 349 FUNC_CODE_INST_CMP2 = 28, // CMP2: [opval, opval, pred] 350 // new select on i1 or [N x i1] 351 FUNC_CODE_INST_VSELECT = 29, // VSELECT: [opval, opval, pred] 352 FUNC_CODE_INST_INBOUNDS_GEP= 30, // Not used in PNaCl. 353 FUNC_CODE_INST_INDIRECTBR = 31, // Not used in PNaCl. 354 // 32 is unused. 355 FUNC_CODE_DEBUG_LOC_AGAIN = 33, // Not used in PNaCl. 356 357 FUNC_CODE_INST_CALL = 34, // CALL: [cc, fnid, args...] 358 // See FUNC_CODE_INST_CALL_INDIRECT below. 359 FUNC_CODE_DEBUG_LOC = 35, // Not used in PNaCl. 360 FUNC_CODE_INST_FENCE = 36, // Not used in PNaCl. 361 FUNC_CODE_INST_CMPXCHG = 37, // Not used in PNaCl. 362 FUNC_CODE_INST_ATOMICRMW = 38, // Not used in PNaCl. 363 FUNC_CODE_INST_RESUME = 39, // Not used in PNaCl. 364 FUNC_CODE_INST_LANDINGPAD = 40, // Not used in PNaCl. 365 FUNC_CODE_INST_LOADATOMIC = 41, // Not used in PNaCl. 366 FUNC_CODE_INST_STOREATOMIC = 42, // Not used in PNaCl. 367 FUNC_CODE_INST_FORWARDTYPEREF = 43, // TYPE: [opval, ty] 368 // CALL_INDIRECT: [cc, fnid, returnty, args...] 369 FUNC_CODE_INST_CALL_INDIRECT = 44 370 }; 371 } // End naclbitc namespace 372 } // End llvm namespace 373 374 #endif 375