Home | History | Annotate | Download | only in Bitcode
      1 //===- LLVMBitCodes.h - Enum values for the LLVM bitcode format -*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      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 
     23 namespace llvm {
     24 namespace 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     PARAMATTR_GROUP_BLOCK_ID,
     33 
     34     CONSTANTS_BLOCK_ID,
     35     FUNCTION_BLOCK_ID,
     36 
     37     UNUSED_ID1,
     38 
     39     VALUE_SYMTAB_BLOCK_ID,
     40     METADATA_BLOCK_ID,
     41     METADATA_ATTACHMENT_ID,
     42 
     43     TYPE_BLOCK_ID_NEW,
     44 
     45     USELIST_BLOCK_ID
     46   };
     47 
     48 
     49   /// MODULE blocks have a number of optional fields and subblocks.
     50   enum ModuleCodes {
     51     MODULE_CODE_VERSION     = 1,    // VERSION:     [version#]
     52     MODULE_CODE_TRIPLE      = 2,    // TRIPLE:      [strchr x N]
     53     MODULE_CODE_DATALAYOUT  = 3,    // DATALAYOUT:  [strchr x N]
     54     MODULE_CODE_ASM         = 4,    // ASM:         [strchr x N]
     55     MODULE_CODE_SECTIONNAME = 5,    // SECTIONNAME: [strchr x N]
     56 
     57     // FIXME: Remove DEPLIB in 4.0.
     58     MODULE_CODE_DEPLIB      = 6,    // DEPLIB:      [strchr x N]
     59 
     60     // GLOBALVAR: [pointer type, isconst, initid,
     61     //             linkage, alignment, section, visibility, threadlocal]
     62     MODULE_CODE_GLOBALVAR   = 7,
     63 
     64     // FUNCTION:  [type, callingconv, isproto, linkage, paramattrs, alignment,
     65     //             section, visibility, gc, unnamed_addr]
     66     MODULE_CODE_FUNCTION    = 8,
     67 
     68     // ALIAS: [alias type, aliasee val#, linkage, visibility]
     69     MODULE_CODE_ALIAS       = 9,
     70 
     71     // MODULE_CODE_PURGEVALS: [numvals]
     72     MODULE_CODE_PURGEVALS   = 10,
     73 
     74     MODULE_CODE_GCNAME      = 11,  // GCNAME: [strchr x N]
     75     MODULE_CODE_COMDAT      = 12,  // COMDAT: [selection_kind, name]
     76   };
     77 
     78   /// PARAMATTR blocks have code for defining a parameter attribute set.
     79   enum AttributeCodes {
     80     // FIXME: Remove `PARAMATTR_CODE_ENTRY_OLD' in 4.0
     81     PARAMATTR_CODE_ENTRY_OLD  = 1, // ENTRY: [paramidx0, attr0,
     82                                    //         paramidx1, attr1...]
     83     PARAMATTR_CODE_ENTRY      = 2, // ENTRY: [paramidx0, attrgrp0,
     84                                    //         paramidx1, attrgrp1, ...]
     85     PARAMATTR_GRP_CODE_ENTRY  = 3  // ENTRY: [id, attr0, att1, ...]
     86   };
     87 
     88   /// TYPE blocks have codes for each type primitive they use.
     89   enum TypeCodes {
     90     TYPE_CODE_NUMENTRY =  1,    // NUMENTRY: [numentries]
     91 
     92     // Type Codes
     93     TYPE_CODE_VOID     =  2,    // VOID
     94     TYPE_CODE_FLOAT    =  3,    // FLOAT
     95     TYPE_CODE_DOUBLE   =  4,    // DOUBLE
     96     TYPE_CODE_LABEL    =  5,    // LABEL
     97     TYPE_CODE_OPAQUE   =  6,    // OPAQUE
     98     TYPE_CODE_INTEGER  =  7,    // INTEGER: [width]
     99     TYPE_CODE_POINTER  =  8,    // POINTER: [pointee type]
    100 
    101     TYPE_CODE_FUNCTION_OLD = 9, // FUNCTION: [vararg, attrid, retty,
    102                                 //            paramty x N]
    103 
    104     TYPE_CODE_HALF     =  10,   // HALF
    105 
    106     TYPE_CODE_ARRAY    = 11,    // ARRAY: [numelts, eltty]
    107     TYPE_CODE_VECTOR   = 12,    // VECTOR: [numelts, eltty]
    108 
    109     // These are not with the other floating point types because they're
    110     // a late addition, and putting them in the right place breaks
    111     // binary compatibility.
    112     TYPE_CODE_X86_FP80 = 13,    // X86 LONG DOUBLE
    113     TYPE_CODE_FP128    = 14,    // LONG DOUBLE (112 bit mantissa)
    114     TYPE_CODE_PPC_FP128= 15,    // PPC LONG DOUBLE (2 doubles)
    115 
    116     TYPE_CODE_METADATA = 16,    // METADATA
    117 
    118     TYPE_CODE_X86_MMX = 17,     // X86 MMX
    119 
    120     TYPE_CODE_STRUCT_ANON = 18, // STRUCT_ANON: [ispacked, eltty x N]
    121     TYPE_CODE_STRUCT_NAME = 19, // STRUCT_NAME: [strchr x N]
    122     TYPE_CODE_STRUCT_NAMED = 20,// STRUCT_NAMED: [ispacked, eltty x N]
    123 
    124     TYPE_CODE_FUNCTION = 21     // FUNCTION: [vararg, retty, paramty x N]
    125   };
    126 
    127   // The type symbol table only has one code (TST_ENTRY_CODE).
    128   enum TypeSymtabCodes {
    129     TST_CODE_ENTRY = 1     // TST_ENTRY: [typeid, namechar x N]
    130   };
    131 
    132   // The value symbol table only has one code (VST_ENTRY_CODE).
    133   enum ValueSymtabCodes {
    134     VST_CODE_ENTRY   = 1,  // VST_ENTRY: [valid, namechar x N]
    135     VST_CODE_BBENTRY = 2   // VST_BBENTRY: [bbid, namechar x N]
    136   };
    137 
    138   enum MetadataCodes {
    139     METADATA_STRING        = 1,   // MDSTRING:      [values]
    140     // 2 is unused.
    141     // 3 is unused.
    142     METADATA_NAME          = 4,   // STRING:        [values]
    143     // 5 is unused.
    144     METADATA_KIND          = 6,   // [n x [id, name]]
    145     // 7 is unused.
    146     METADATA_NODE          = 8,   // NODE:          [n x (type num, value num)]
    147     METADATA_FN_NODE       = 9,   // FN_NODE:       [n x (type num, value num)]
    148     METADATA_NAMED_NODE    = 10,  // NAMED_NODE:    [n x mdnodes]
    149     METADATA_ATTACHMENT    = 11   // [m x [value, [n x [id, mdnode]]]
    150   };
    151 
    152   // The constants block (CONSTANTS_BLOCK_ID) describes emission for each
    153   // constant and maintains an implicit current type value.
    154   enum ConstantsCodes {
    155     CST_CODE_SETTYPE       =  1,  // SETTYPE:       [typeid]
    156     CST_CODE_NULL          =  2,  // NULL
    157     CST_CODE_UNDEF         =  3,  // UNDEF
    158     CST_CODE_INTEGER       =  4,  // INTEGER:       [intval]
    159     CST_CODE_WIDE_INTEGER  =  5,  // WIDE_INTEGER:  [n x intval]
    160     CST_CODE_FLOAT         =  6,  // FLOAT:         [fpval]
    161     CST_CODE_AGGREGATE     =  7,  // AGGREGATE:     [n x value number]
    162     CST_CODE_STRING        =  8,  // STRING:        [values]
    163     CST_CODE_CSTRING       =  9,  // CSTRING:       [values]
    164     CST_CODE_CE_BINOP      = 10,  // CE_BINOP:      [opcode, opval, opval]
    165     CST_CODE_CE_CAST       = 11,  // CE_CAST:       [opcode, opty, opval]
    166     CST_CODE_CE_GEP        = 12,  // CE_GEP:        [n x operands]
    167     CST_CODE_CE_SELECT     = 13,  // CE_SELECT:     [opval, opval, opval]
    168     CST_CODE_CE_EXTRACTELT = 14,  // CE_EXTRACTELT: [opty, opval, opval]
    169     CST_CODE_CE_INSERTELT  = 15,  // CE_INSERTELT:  [opval, opval, opval]
    170     CST_CODE_CE_SHUFFLEVEC = 16,  // CE_SHUFFLEVEC: [opval, opval, opval]
    171     CST_CODE_CE_CMP        = 17,  // CE_CMP:        [opty, opval, opval, pred]
    172     CST_CODE_INLINEASM_OLD = 18,  // INLINEASM:     [sideeffect|alignstack,
    173                                   //                 asmstr,conststr]
    174     CST_CODE_CE_SHUFVEC_EX = 19,  // SHUFVEC_EX:    [opty, opval, opval, opval]
    175     CST_CODE_CE_INBOUNDS_GEP = 20,// INBOUNDS_GEP:  [n x operands]
    176     CST_CODE_BLOCKADDRESS  = 21,  // CST_CODE_BLOCKADDRESS [fnty, fnval, bb#]
    177     CST_CODE_DATA          = 22,  // DATA:          [n x elements]
    178     CST_CODE_INLINEASM     = 23   // INLINEASM:     [sideeffect|alignstack|
    179                                   //                 asmdialect,asmstr,conststr]
    180   };
    181 
    182   /// CastOpcodes - These are values used in the bitcode files to encode which
    183   /// cast a CST_CODE_CE_CAST or a XXX refers to.  The values of these enums
    184   /// have no fixed relation to the LLVM IR enum values.  Changing these will
    185   /// break compatibility with old files.
    186   enum CastOpcodes {
    187     CAST_TRUNC    =  0,
    188     CAST_ZEXT     =  1,
    189     CAST_SEXT     =  2,
    190     CAST_FPTOUI   =  3,
    191     CAST_FPTOSI   =  4,
    192     CAST_UITOFP   =  5,
    193     CAST_SITOFP   =  6,
    194     CAST_FPTRUNC  =  7,
    195     CAST_FPEXT    =  8,
    196     CAST_PTRTOINT =  9,
    197     CAST_INTTOPTR = 10,
    198     CAST_BITCAST  = 11,
    199     CAST_ADDRSPACECAST = 12
    200   };
    201 
    202   /// BinaryOpcodes - These are values used in the bitcode files to encode which
    203   /// binop a CST_CODE_CE_BINOP or a XXX refers to.  The values of these enums
    204   /// have no fixed relation to the LLVM IR enum values.  Changing these will
    205   /// break compatibility with old files.
    206   enum BinaryOpcodes {
    207     BINOP_ADD  =  0,
    208     BINOP_SUB  =  1,
    209     BINOP_MUL  =  2,
    210     BINOP_UDIV =  3,
    211     BINOP_SDIV =  4,    // overloaded for FP
    212     BINOP_UREM =  5,
    213     BINOP_SREM =  6,    // overloaded for FP
    214     BINOP_SHL  =  7,
    215     BINOP_LSHR =  8,
    216     BINOP_ASHR =  9,
    217     BINOP_AND  = 10,
    218     BINOP_OR   = 11,
    219     BINOP_XOR  = 12
    220   };
    221 
    222   /// These are values used in the bitcode files to encode AtomicRMW operations.
    223   /// The values of these enums have no fixed relation to the LLVM IR enum
    224   /// values.  Changing these will break compatibility with old files.
    225   enum RMWOperations {
    226     RMW_XCHG = 0,
    227     RMW_ADD = 1,
    228     RMW_SUB = 2,
    229     RMW_AND = 3,
    230     RMW_NAND = 4,
    231     RMW_OR = 5,
    232     RMW_XOR = 6,
    233     RMW_MAX = 7,
    234     RMW_MIN = 8,
    235     RMW_UMAX = 9,
    236     RMW_UMIN = 10
    237   };
    238 
    239   /// OverflowingBinaryOperatorOptionalFlags - Flags for serializing
    240   /// OverflowingBinaryOperator's SubclassOptionalData contents.
    241   enum OverflowingBinaryOperatorOptionalFlags {
    242     OBO_NO_UNSIGNED_WRAP = 0,
    243     OBO_NO_SIGNED_WRAP = 1
    244   };
    245 
    246   /// PossiblyExactOperatorOptionalFlags - Flags for serializing
    247   /// PossiblyExactOperator's SubclassOptionalData contents.
    248   enum PossiblyExactOperatorOptionalFlags {
    249     PEO_EXACT = 0
    250   };
    251 
    252   /// Encoded AtomicOrdering values.
    253   enum AtomicOrderingCodes {
    254     ORDERING_NOTATOMIC = 0,
    255     ORDERING_UNORDERED = 1,
    256     ORDERING_MONOTONIC = 2,
    257     ORDERING_ACQUIRE = 3,
    258     ORDERING_RELEASE = 4,
    259     ORDERING_ACQREL = 5,
    260     ORDERING_SEQCST = 6
    261   };
    262 
    263   /// Encoded SynchronizationScope values.
    264   enum AtomicSynchScopeCodes {
    265     SYNCHSCOPE_SINGLETHREAD = 0,
    266     SYNCHSCOPE_CROSSTHREAD = 1
    267   };
    268 
    269   // The function body block (FUNCTION_BLOCK_ID) describes function bodies.  It
    270   // can contain a constant block (CONSTANTS_BLOCK_ID).
    271   enum FunctionCodes {
    272     FUNC_CODE_DECLAREBLOCKS    =  1, // DECLAREBLOCKS: [n]
    273 
    274     FUNC_CODE_INST_BINOP       =  2, // BINOP:      [opcode, ty, opval, opval]
    275     FUNC_CODE_INST_CAST        =  3, // CAST:       [opcode, ty, opty, opval]
    276     FUNC_CODE_INST_GEP         =  4, // GEP:        [n x operands]
    277     FUNC_CODE_INST_SELECT      =  5, // SELECT:     [ty, opval, opval, opval]
    278     FUNC_CODE_INST_EXTRACTELT  =  6, // EXTRACTELT: [opty, opval, opval]
    279     FUNC_CODE_INST_INSERTELT   =  7, // INSERTELT:  [ty, opval, opval, opval]
    280     FUNC_CODE_INST_SHUFFLEVEC  =  8, // SHUFFLEVEC: [ty, opval, opval, opval]
    281     FUNC_CODE_INST_CMP         =  9, // CMP:        [opty, opval, opval, pred]
    282 
    283     FUNC_CODE_INST_RET         = 10, // RET:        [opty,opval<both optional>]
    284     FUNC_CODE_INST_BR          = 11, // BR:         [bb#, bb#, cond] or [bb#]
    285     FUNC_CODE_INST_SWITCH      = 12, // SWITCH:     [opty, op0, op1, ...]
    286     FUNC_CODE_INST_INVOKE      = 13, // INVOKE:     [attr, fnty, op0,op1, ...]
    287     // 14 is unused.
    288     FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE
    289 
    290     FUNC_CODE_INST_PHI         = 16, // PHI:        [ty, val0,bb0, ...]
    291     // 17 is unused.
    292     // 18 is unused.
    293     FUNC_CODE_INST_ALLOCA      = 19, // ALLOCA:     [instty, op, align]
    294     FUNC_CODE_INST_LOAD        = 20, // LOAD:       [opty, op, align, vol]
    295     // 21 is unused.
    296     // 22 is unused.
    297     FUNC_CODE_INST_VAARG       = 23, // VAARG:      [valistty, valist, instty]
    298     // This store code encodes the pointer type, rather than the value type
    299     // this is so information only available in the pointer type (e.g. address
    300     // spaces) is retained.
    301     FUNC_CODE_INST_STORE       = 24, // STORE:      [ptrty,ptr,val, align, vol]
    302     // 25 is unused.
    303     FUNC_CODE_INST_EXTRACTVAL  = 26, // EXTRACTVAL: [n x operands]
    304     FUNC_CODE_INST_INSERTVAL   = 27, // INSERTVAL:  [n x operands]
    305     // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to
    306     // support legacy vicmp/vfcmp instructions.
    307     FUNC_CODE_INST_CMP2        = 28, // CMP2:       [opty, opval, opval, pred]
    308     // new select on i1 or [N x i1]
    309     FUNC_CODE_INST_VSELECT     = 29, // VSELECT:    [ty,opval,opval,predty,pred]
    310     FUNC_CODE_INST_INBOUNDS_GEP= 30, // INBOUNDS_GEP: [n x operands]
    311     FUNC_CODE_INST_INDIRECTBR  = 31, // INDIRECTBR: [opty, op0, op1, ...]
    312     // 32 is unused.
    313     FUNC_CODE_DEBUG_LOC_AGAIN  = 33, // DEBUG_LOC_AGAIN
    314 
    315     FUNC_CODE_INST_CALL        = 34, // CALL:    [attr, cc, fnty, fnid, args...]
    316 
    317     FUNC_CODE_DEBUG_LOC        = 35, // DEBUG_LOC:  [Line,Col,ScopeVal, IAVal]
    318     FUNC_CODE_INST_FENCE       = 36, // FENCE: [ordering, synchscope]
    319     FUNC_CODE_INST_CMPXCHG     = 37, // CMPXCHG: [ptrty,ptr,cmp,new, align, vol,
    320                                      //           ordering, synchscope]
    321     FUNC_CODE_INST_ATOMICRMW   = 38, // ATOMICRMW: [ptrty,ptr,val, operation,
    322                                      //             align, vol,
    323                                      //             ordering, synchscope]
    324     FUNC_CODE_INST_RESUME      = 39, // RESUME:     [opval]
    325     FUNC_CODE_INST_LANDINGPAD  = 40, // LANDINGPAD: [ty,val,val,num,id0,val0...]
    326     FUNC_CODE_INST_LOADATOMIC  = 41, // LOAD: [opty, op, align, vol,
    327                                      //        ordering, synchscope]
    328     FUNC_CODE_INST_STOREATOMIC = 42  // STORE: [ptrty,ptr,val, align, vol
    329                                      //         ordering, synchscope]
    330   };
    331 
    332   enum UseListCodes {
    333     USELIST_CODE_ENTRY = 1   // USELIST_CODE_ENTRY: TBD.
    334   };
    335 
    336   enum AttributeKindCodes {
    337     // = 0 is unused
    338     ATTR_KIND_ALIGNMENT = 1,
    339     ATTR_KIND_ALWAYS_INLINE = 2,
    340     ATTR_KIND_BY_VAL = 3,
    341     ATTR_KIND_INLINE_HINT = 4,
    342     ATTR_KIND_IN_REG = 5,
    343     ATTR_KIND_MIN_SIZE = 6,
    344     ATTR_KIND_NAKED = 7,
    345     ATTR_KIND_NEST = 8,
    346     ATTR_KIND_NO_ALIAS = 9,
    347     ATTR_KIND_NO_BUILTIN = 10,
    348     ATTR_KIND_NO_CAPTURE = 11,
    349     ATTR_KIND_NO_DUPLICATE = 12,
    350     ATTR_KIND_NO_IMPLICIT_FLOAT = 13,
    351     ATTR_KIND_NO_INLINE = 14,
    352     ATTR_KIND_NON_LAZY_BIND = 15,
    353     ATTR_KIND_NO_RED_ZONE = 16,
    354     ATTR_KIND_NO_RETURN = 17,
    355     ATTR_KIND_NO_UNWIND = 18,
    356     ATTR_KIND_OPTIMIZE_FOR_SIZE = 19,
    357     ATTR_KIND_READ_NONE = 20,
    358     ATTR_KIND_READ_ONLY = 21,
    359     ATTR_KIND_RETURNED = 22,
    360     ATTR_KIND_RETURNS_TWICE = 23,
    361     ATTR_KIND_S_EXT = 24,
    362     ATTR_KIND_STACK_ALIGNMENT = 25,
    363     ATTR_KIND_STACK_PROTECT = 26,
    364     ATTR_KIND_STACK_PROTECT_REQ = 27,
    365     ATTR_KIND_STACK_PROTECT_STRONG = 28,
    366     ATTR_KIND_STRUCT_RET = 29,
    367     ATTR_KIND_SANITIZE_ADDRESS = 30,
    368     ATTR_KIND_SANITIZE_THREAD = 31,
    369     ATTR_KIND_SANITIZE_MEMORY = 32,
    370     ATTR_KIND_UW_TABLE = 33,
    371     ATTR_KIND_Z_EXT = 34,
    372     ATTR_KIND_BUILTIN = 35,
    373     ATTR_KIND_COLD = 36,
    374     ATTR_KIND_OPTIMIZE_NONE = 37,
    375     ATTR_KIND_IN_ALLOCA = 38,
    376     ATTR_KIND_NON_NULL = 39,
    377     ATTR_KIND_JUMP_TABLE = 40
    378   };
    379 
    380   enum ComdatSelectionKindCodes {
    381     COMDAT_SELECTION_KIND_ANY = 1,
    382     COMDAT_SELECTION_KIND_EXACT_MATCH = 2,
    383     COMDAT_SELECTION_KIND_LARGEST = 3,
    384     COMDAT_SELECTION_KIND_NO_DUPLICATES = 4,
    385     COMDAT_SELECTION_KIND_SAME_SIZE = 5,
    386   };
    387 
    388 } // End bitc namespace
    389 } // End llvm namespace
    390 
    391 #endif
    392