Home | History | Annotate | Download | only in NVPTX
      1 //===-- NVPTX.h - Top-level interface for NVPTX representation --*- 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 file contains the entry points for global functions defined in
     11 // the LLVM NVPTX back-end.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTX_H
     16 #define LLVM_LIB_TARGET_NVPTX_NVPTX_H
     17 
     18 #include "MCTargetDesc/NVPTXBaseInfo.h"
     19 #include "llvm/ADT/StringMap.h"
     20 #include "llvm/IR/Module.h"
     21 #include "llvm/IR/Value.h"
     22 #include "llvm/Support/ErrorHandling.h"
     23 #include "llvm/Target/TargetMachine.h"
     24 #include <cassert>
     25 #include <iosfwd>
     26 
     27 namespace llvm {
     28 class NVPTXTargetMachine;
     29 class FunctionPass;
     30 class MachineFunctionPass;
     31 class formatted_raw_ostream;
     32 
     33 namespace NVPTXCC {
     34 enum CondCodes {
     35   EQ,
     36   NE,
     37   LT,
     38   LE,
     39   GT,
     40   GE
     41 };
     42 }
     43 
     44 FunctionPass *createNVPTXISelDag(NVPTXTargetMachine &TM,
     45                                  llvm::CodeGenOpt::Level OptLevel);
     46 ModulePass *createNVPTXAssignValidGlobalNamesPass();
     47 ModulePass *createGenericToNVVMPass();
     48 FunctionPass *createNVPTXFavorNonGenericAddrSpacesPass();
     49 FunctionPass *createNVPTXInferAddressSpacesPass();
     50 FunctionPass *createNVVMIntrRangePass(unsigned int SmVersion);
     51 FunctionPass *createNVVMReflectPass();
     52 FunctionPass *createNVVMReflectPass(const StringMap<int> &Mapping);
     53 MachineFunctionPass *createNVPTXPrologEpilogPass();
     54 MachineFunctionPass *createNVPTXReplaceImageHandlesPass();
     55 FunctionPass *createNVPTXImageOptimizerPass();
     56 FunctionPass *createNVPTXLowerKernelArgsPass(const NVPTXTargetMachine *TM);
     57 BasicBlockPass *createNVPTXLowerAllocaPass();
     58 MachineFunctionPass *createNVPTXPeephole();
     59 
     60 extern Target TheNVPTXTarget32;
     61 extern Target TheNVPTXTarget64;
     62 
     63 namespace NVPTX {
     64 enum DrvInterface {
     65   NVCL,
     66   CUDA
     67 };
     68 
     69 // A field inside TSFlags needs a shift and a mask. The usage is
     70 // always as follows :
     71 // ((TSFlags & fieldMask) >> fieldShift)
     72 // The enum keeps the mask, the shift, and all valid values of the
     73 // field in one place.
     74 enum VecInstType {
     75   VecInstTypeShift = 0,
     76   VecInstTypeMask = 0xF,
     77 
     78   VecNOP = 0,
     79   VecLoad = 1,
     80   VecStore = 2,
     81   VecBuild = 3,
     82   VecShuffle = 4,
     83   VecExtract = 5,
     84   VecInsert = 6,
     85   VecDest = 7,
     86   VecOther = 15
     87 };
     88 
     89 enum SimpleMove {
     90   SimpleMoveMask = 0x10,
     91   SimpleMoveShift = 4
     92 };
     93 enum LoadStore {
     94   isLoadMask = 0x20,
     95   isLoadShift = 5,
     96   isStoreMask = 0x40,
     97   isStoreShift = 6
     98 };
     99 
    100 namespace PTXLdStInstCode {
    101 enum AddressSpace {
    102   GENERIC = 0,
    103   GLOBAL = 1,
    104   CONSTANT = 2,
    105   SHARED = 3,
    106   PARAM = 4,
    107   LOCAL = 5
    108 };
    109 enum FromType {
    110   Unsigned = 0,
    111   Signed,
    112   Float
    113 };
    114 enum VecType {
    115   Scalar = 1,
    116   V2 = 2,
    117   V4 = 4
    118 };
    119 }
    120 
    121 /// PTXCvtMode - Conversion code enumeration
    122 namespace PTXCvtMode {
    123 enum CvtMode {
    124   NONE = 0,
    125   RNI,
    126   RZI,
    127   RMI,
    128   RPI,
    129   RN,
    130   RZ,
    131   RM,
    132   RP,
    133 
    134   BASE_MASK = 0x0F,
    135   FTZ_FLAG = 0x10,
    136   SAT_FLAG = 0x20
    137 };
    138 }
    139 
    140 /// PTXCmpMode - Comparison mode enumeration
    141 namespace PTXCmpMode {
    142 enum CmpMode {
    143   EQ = 0,
    144   NE,
    145   LT,
    146   LE,
    147   GT,
    148   GE,
    149   LO,
    150   LS,
    151   HI,
    152   HS,
    153   EQU,
    154   NEU,
    155   LTU,
    156   LEU,
    157   GTU,
    158   GEU,
    159   NUM,
    160   // NAN is a MACRO
    161   NotANumber,
    162 
    163   BASE_MASK = 0xFF,
    164   FTZ_FLAG = 0x100
    165 };
    166 }
    167 }
    168 } // end namespace llvm;
    169 
    170 // Defines symbolic names for NVPTX registers.  This defines a mapping from
    171 // register name to register number.
    172 #define GET_REGINFO_ENUM
    173 #include "NVPTXGenRegisterInfo.inc"
    174 
    175 // Defines symbolic names for the NVPTX instructions.
    176 #define GET_INSTRINFO_ENUM
    177 #include "NVPTXGenInstrInfo.inc"
    178 
    179 #endif
    180