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 
     33     UNUSED_ID1,
     34 
     35     CONSTANTS_BLOCK_ID,
     36     FUNCTION_BLOCK_ID,
     37 
     38     UNUSED_ID2,
     39 
     40     VALUE_SYMTAB_BLOCK_ID,
     41     METADATA_BLOCK_ID,
     42     METADATA_ATTACHMENT_ID,
     43 
     44     TYPE_BLOCK_ID_NEW,
     45 
     46     USELIST_BLOCK_ID
     47   };
     48 
     49 
     50   /// MODULE blocks have a number of optional fields and subblocks.
     51   enum ModuleCodes {
     52     MODULE_CODE_VERSION     = 1,    // VERSION:     [version#]
     53     MODULE_CODE_TRIPLE      = 2,    // TRIPLE:      [strchr x N]
     54     MODULE_CODE_DATALAYOUT  = 3,    // DATALAYOUT:  [strchr x N]
     55     MODULE_CODE_ASM         = 4,    // ASM:         [strchr x N]
     56     MODULE_CODE_SECTIONNAME = 5,    // SECTIONNAME: [strchr x N]
     57     MODULE_CODE_DEPLIB      = 6,    // DEPLIB:      [strchr x N]
     58 
     59     // GLOBALVAR: [pointer type, isconst, initid,
     60     //             linkage, alignment, section, visibility, threadlocal]
     61     MODULE_CODE_GLOBALVAR   = 7,
     62 
     63     // FUNCTION:  [type, callingconv, isproto, linkage, paramattrs, alignment,
     64     //             section, visibility, gc, unnamed_addr]
     65     MODULE_CODE_FUNCTION    = 8,
     66 
     67     // ALIAS: [alias type, aliasee val#, linkage, visibility]
     68     MODULE_CODE_ALIAS       = 9,
     69 
     70     /// MODULE_CODE_PURGEVALS: [numvals]
     71     MODULE_CODE_PURGEVALS   = 10,
     72 
     73     MODULE_CODE_GCNAME      = 11   // GCNAME: [strchr x N]
     74   };
     75 
     76   /// PARAMATTR blocks have code for defining a parameter attribute set.
     77   enum AttributeCodes {
     78     PARAMATTR_CODE_ENTRY = 1   // ENTRY: [paramidx0, attr0, paramidx1, attr1...]
     79   };
     80 
     81   /// TYPE blocks have codes for each type primitive they use.
     82   enum TypeCodes {
     83     TYPE_CODE_NUMENTRY =  1,    // NUMENTRY: [numentries]
     84 
     85     // Type Codes
     86     TYPE_CODE_VOID     =  2,    // VOID
     87     TYPE_CODE_FLOAT    =  3,    // FLOAT
     88     TYPE_CODE_DOUBLE   =  4,    // DOUBLE
     89     TYPE_CODE_LABEL    =  5,    // LABEL
     90     TYPE_CODE_OPAQUE   =  6,    // OPAQUE
     91     TYPE_CODE_INTEGER  =  7,    // INTEGER: [width]
     92     TYPE_CODE_POINTER  =  8,    // POINTER: [pointee type]
     93 
     94     TYPE_CODE_FUNCTION_OLD = 9, // FUNCTION: [vararg, attrid, retty,
     95                                 //            paramty x N]
     96 
     97     TYPE_CODE_HALF     =  10,   // HALF
     98 
     99     TYPE_CODE_ARRAY    = 11,    // ARRAY: [numelts, eltty]
    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,    // X86 LONG DOUBLE
    106     TYPE_CODE_FP128    = 14,    // LONG DOUBLE (112 bit mantissa)
    107     TYPE_CODE_PPC_FP128= 15,    // PPC LONG DOUBLE (2 doubles)
    108 
    109     TYPE_CODE_METADATA = 16,    // METADATA
    110 
    111     TYPE_CODE_X86_MMX = 17,     // X86 MMX
    112 
    113     TYPE_CODE_STRUCT_ANON = 18, // STRUCT_ANON: [ispacked, eltty x N]
    114     TYPE_CODE_STRUCT_NAME = 19, // STRUCT_NAME: [strchr x N]
    115     TYPE_CODE_STRUCT_NAMED = 20,// STRUCT_NAMED: [ispacked, eltty x N]
    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 TypeSymtabCodes {
    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 ValueSymtabCodes {
    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   enum MetadataCodes {
    132     METADATA_STRING        = 1,   // MDSTRING:      [values]
    133     // 2 is unused.
    134     // 3 is unused.
    135     METADATA_NAME          = 4,   // STRING:        [values]
    136     // 5 is unused.
    137     METADATA_KIND          = 6,   // [n x [id, name]]
    138     // 7 is unused.
    139     METADATA_NODE          = 8,   // NODE:          [n x (type num, value num)]
    140     METADATA_FN_NODE       = 9,   // FN_NODE:       [n x (type num, value num)]
    141     METADATA_NAMED_NODE    = 10,  // NAMED_NODE:    [n x mdnodes]
    142     METADATA_ATTACHMENT    = 11   // [m x [value, [n x [id, mdnode]]]
    143   };
    144   // The constants block (CONSTANTS_BLOCK_ID) describes emission for each
    145   // constant and maintains an implicit current type value.
    146   enum ConstantsCodes {
    147     CST_CODE_SETTYPE       =  1,  // SETTYPE:       [typeid]
    148     CST_CODE_NULL          =  2,  // NULL
    149     CST_CODE_UNDEF         =  3,  // UNDEF
    150     CST_CODE_INTEGER       =  4,  // INTEGER:       [intval]
    151     CST_CODE_WIDE_INTEGER  =  5,  // WIDE_INTEGER:  [n x intval]
    152     CST_CODE_FLOAT         =  6,  // FLOAT:         [fpval]
    153     CST_CODE_AGGREGATE     =  7,  // AGGREGATE:     [n x value number]
    154     CST_CODE_STRING        =  8,  // STRING:        [values]
    155     CST_CODE_CSTRING       =  9,  // CSTRING:       [values]
    156     CST_CODE_CE_BINOP      = 10,  // CE_BINOP:      [opcode, opval, opval]
    157     CST_CODE_CE_CAST       = 11,  // CE_CAST:       [opcode, opty, opval]
    158     CST_CODE_CE_GEP        = 12,  // CE_GEP:        [n x operands]
    159     CST_CODE_CE_SELECT     = 13,  // CE_SELECT:     [opval, opval, opval]
    160     CST_CODE_CE_EXTRACTELT = 14,  // CE_EXTRACTELT: [opty, opval, opval]
    161     CST_CODE_CE_INSERTELT  = 15,  // CE_INSERTELT:  [opval, opval, opval]
    162     CST_CODE_CE_SHUFFLEVEC = 16,  // CE_SHUFFLEVEC: [opval, opval, opval]
    163     CST_CODE_CE_CMP        = 17,  // CE_CMP:        [opty, opval, opval, pred]
    164     CST_CODE_INLINEASM_OLD = 18,  // INLINEASM:     [sideeffect|alignstack,
    165                                   //                 asmstr,conststr]
    166     CST_CODE_CE_SHUFVEC_EX = 19,  // SHUFVEC_EX:    [opty, opval, opval, opval]
    167     CST_CODE_CE_INBOUNDS_GEP = 20,// INBOUNDS_GEP:  [n x operands]
    168     CST_CODE_BLOCKADDRESS  = 21,  // CST_CODE_BLOCKADDRESS [fnty, fnval, bb#]
    169     CST_CODE_DATA          = 22,  // DATA:          [n x elements]
    170     CST_CODE_INLINEASM     = 23   // INLINEASM:     [sideeffect|alignstack|
    171                                   //                 asmdialect,asmstr,conststr]
    172   };
    173 
    174   /// CastOpcodes - These are values used in the bitcode files to encode which
    175   /// cast a CST_CODE_CE_CAST or a XXX refers to.  The values of these enums
    176   /// have no fixed relation to the LLVM IR enum values.  Changing these will
    177   /// break compatibility with old files.
    178   enum CastOpcodes {
    179     CAST_TRUNC    =  0,
    180     CAST_ZEXT     =  1,
    181     CAST_SEXT     =  2,
    182     CAST_FPTOUI   =  3,
    183     CAST_FPTOSI   =  4,
    184     CAST_UITOFP   =  5,
    185     CAST_SITOFP   =  6,
    186     CAST_FPTRUNC  =  7,
    187     CAST_FPEXT    =  8,
    188     CAST_PTRTOINT =  9,
    189     CAST_INTTOPTR = 10,
    190     CAST_BITCAST  = 11
    191   };
    192 
    193   /// BinaryOpcodes - These are values used in the bitcode files to encode which
    194   /// binop a CST_CODE_CE_BINOP or a XXX refers to.  The values of these enums
    195   /// have no fixed relation to the LLVM IR enum values.  Changing these will
    196   /// break compatibility with old files.
    197   enum BinaryOpcodes {
    198     BINOP_ADD  =  0,
    199     BINOP_SUB  =  1,
    200     BINOP_MUL  =  2,
    201     BINOP_UDIV =  3,
    202     BINOP_SDIV =  4,    // overloaded for FP
    203     BINOP_UREM =  5,
    204     BINOP_SREM =  6,    // overloaded for FP
    205     BINOP_SHL  =  7,
    206     BINOP_LSHR =  8,
    207     BINOP_ASHR =  9,
    208     BINOP_AND  = 10,
    209     BINOP_OR   = 11,
    210     BINOP_XOR  = 12
    211   };
    212 
    213   /// These are values used in the bitcode files to encode AtomicRMW operations.
    214   /// The values of these enums have no fixed relation to the LLVM IR enum
    215   /// values.  Changing these will break compatibility with old files.
    216   enum RMWOperations {
    217     RMW_XCHG = 0,
    218     RMW_ADD = 1,
    219     RMW_SUB = 2,
    220     RMW_AND = 3,
    221     RMW_NAND = 4,
    222     RMW_OR = 5,
    223     RMW_XOR = 6,
    224     RMW_MAX = 7,
    225     RMW_MIN = 8,
    226     RMW_UMAX = 9,
    227     RMW_UMIN = 10
    228   };
    229 
    230   /// OverflowingBinaryOperatorOptionalFlags - Flags for serializing
    231   /// OverflowingBinaryOperator's SubclassOptionalData contents.
    232   enum OverflowingBinaryOperatorOptionalFlags {
    233     OBO_NO_UNSIGNED_WRAP = 0,
    234     OBO_NO_SIGNED_WRAP = 1
    235   };
    236 
    237   /// PossiblyExactOperatorOptionalFlags - Flags for serializing
    238   /// PossiblyExactOperator's SubclassOptionalData contents.
    239   enum PossiblyExactOperatorOptionalFlags {
    240     PEO_EXACT = 0
    241   };
    242 
    243   /// Encoded AtomicOrdering values.
    244   enum AtomicOrderingCodes {
    245     ORDERING_NOTATOMIC = 0,
    246     ORDERING_UNORDERED = 1,
    247     ORDERING_MONOTONIC = 2,
    248     ORDERING_ACQUIRE = 3,
    249     ORDERING_RELEASE = 4,
    250     ORDERING_ACQREL = 5,
    251     ORDERING_SEQCST = 6
    252   };
    253 
    254   /// Encoded SynchronizationScope values.
    255   enum AtomicSynchScopeCodes {
    256     SYNCHSCOPE_SINGLETHREAD = 0,
    257     SYNCHSCOPE_CROSSTHREAD = 1
    258   };
    259 
    260   // The function body block (FUNCTION_BLOCK_ID) describes function bodies.  It
    261   // can contain a constant block (CONSTANTS_BLOCK_ID).
    262   enum FunctionCodes {
    263     FUNC_CODE_DECLAREBLOCKS    =  1, // DECLAREBLOCKS: [n]
    264 
    265     FUNC_CODE_INST_BINOP       =  2, // BINOP:      [opcode, ty, opval, opval]
    266     FUNC_CODE_INST_CAST        =  3, // CAST:       [opcode, ty, opty, opval]
    267     FUNC_CODE_INST_GEP         =  4, // GEP:        [n x operands]
    268     FUNC_CODE_INST_SELECT      =  5, // SELECT:     [ty, opval, opval, opval]
    269     FUNC_CODE_INST_EXTRACTELT  =  6, // EXTRACTELT: [opty, opval, opval]
    270     FUNC_CODE_INST_INSERTELT   =  7, // INSERTELT:  [ty, opval, opval, opval]
    271     FUNC_CODE_INST_SHUFFLEVEC  =  8, // SHUFFLEVEC: [ty, opval, opval, opval]
    272     FUNC_CODE_INST_CMP         =  9, // CMP:        [opty, opval, opval, pred]
    273 
    274     FUNC_CODE_INST_RET         = 10, // RET:        [opty,opval<both optional>]
    275     FUNC_CODE_INST_BR          = 11, // BR:         [bb#, bb#, cond] or [bb#]
    276     FUNC_CODE_INST_SWITCH      = 12, // SWITCH:     [opty, op0, op1, ...]
    277     FUNC_CODE_INST_INVOKE      = 13, // INVOKE:     [attr, fnty, op0,op1, ...]
    278     // 14 is unused.
    279     FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE
    280 
    281     FUNC_CODE_INST_PHI         = 16, // PHI:        [ty, val0,bb0, ...]
    282     // 17 is unused.
    283     // 18 is unused.
    284     FUNC_CODE_INST_ALLOCA      = 19, // ALLOCA:     [instty, op, align]
    285     FUNC_CODE_INST_LOAD        = 20, // LOAD:       [opty, op, align, vol]
    286     // 21 is unused.
    287     // 22 is unused.
    288     FUNC_CODE_INST_VAARG       = 23, // VAARG:      [valistty, valist, instty]
    289     // This store code encodes the pointer type, rather than the value type
    290     // this is so information only available in the pointer type (e.g. address
    291     // spaces) is retained.
    292     FUNC_CODE_INST_STORE       = 24, // STORE:      [ptrty,ptr,val, align, vol]
    293     // 25 is unused.
    294     FUNC_CODE_INST_EXTRACTVAL  = 26, // EXTRACTVAL: [n x operands]
    295     FUNC_CODE_INST_INSERTVAL   = 27, // INSERTVAL:  [n x operands]
    296     // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to
    297     // support legacy vicmp/vfcmp instructions.
    298     FUNC_CODE_INST_CMP2        = 28, // CMP2:       [opty, opval, opval, pred]
    299     // new select on i1 or [N x i1]
    300     FUNC_CODE_INST_VSELECT     = 29, // VSELECT:    [ty,opval,opval,predty,pred]
    301     FUNC_CODE_INST_INBOUNDS_GEP= 30, // INBOUNDS_GEP: [n x operands]
    302     FUNC_CODE_INST_INDIRECTBR  = 31, // INDIRECTBR: [opty, op0, op1, ...]
    303     // 32 is unused.
    304     FUNC_CODE_DEBUG_LOC_AGAIN  = 33, // DEBUG_LOC_AGAIN
    305 
    306     FUNC_CODE_INST_CALL        = 34, // CALL:       [attr, fnty, fnid, args...]
    307 
    308     FUNC_CODE_DEBUG_LOC        = 35, // DEBUG_LOC:  [Line,Col,ScopeVal, IAVal]
    309     FUNC_CODE_INST_FENCE       = 36, // FENCE: [ordering, synchscope]
    310     FUNC_CODE_INST_CMPXCHG     = 37, // CMPXCHG: [ptrty,ptr,cmp,new, align, vol,
    311                                      //           ordering, synchscope]
    312     FUNC_CODE_INST_ATOMICRMW   = 38, // ATOMICRMW: [ptrty,ptr,val, operation,
    313                                      //             align, vol,
    314                                      //             ordering, synchscope]
    315     FUNC_CODE_INST_RESUME      = 39, // RESUME:     [opval]
    316     FUNC_CODE_INST_LANDINGPAD  = 40, // LANDINGPAD: [ty,val,val,num,id0,val0...]
    317     FUNC_CODE_INST_LOADATOMIC  = 41, // LOAD: [opty, op, align, vol,
    318                                      //        ordering, synchscope]
    319     FUNC_CODE_INST_STOREATOMIC = 42  // STORE: [ptrty,ptr,val, align, vol
    320                                      //         ordering, synchscope]
    321   };
    322 
    323   enum UseListCodes {
    324     USELIST_CODE_ENTRY = 1   // USELIST_CODE_ENTRY: TBD.
    325   };
    326 } // End bitc namespace
    327 } // End llvm namespace
    328 
    329 #endif
    330