LLVM API Documentation

NVPTX.h
Go to the documentation of this file.
00001 //===-- NVPTX.h - Top-level interface for NVPTX representation --*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the entry points for global functions defined in
00011 // the LLVM NVPTX back-end.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTX_H
00016 #define LLVM_LIB_TARGET_NVPTX_NVPTX_H
00017 
00018 #include "MCTargetDesc/NVPTXBaseInfo.h"
00019 #include "llvm/ADT/StringMap.h"
00020 #include "llvm/IR/Module.h"
00021 #include "llvm/IR/Value.h"
00022 #include "llvm/Support/ErrorHandling.h"
00023 #include "llvm/Target/TargetMachine.h"
00024 #include <cassert>
00025 #include <iosfwd>
00026 
00027 namespace llvm {
00028 class NVPTXTargetMachine;
00029 class FunctionPass;
00030 class MachineFunctionPass;
00031 class formatted_raw_ostream;
00032 
00033 namespace NVPTXCC {
00034 enum CondCodes {
00035   EQ,
00036   NE,
00037   LT,
00038   LE,
00039   GT,
00040   GE
00041 };
00042 }
00043 
00044 inline static const char *NVPTXCondCodeToString(NVPTXCC::CondCodes CC) {
00045   switch (CC) {
00046   case NVPTXCC::NE:
00047     return "ne";
00048   case NVPTXCC::EQ:
00049     return "eq";
00050   case NVPTXCC::LT:
00051     return "lt";
00052   case NVPTXCC::LE:
00053     return "le";
00054   case NVPTXCC::GT:
00055     return "gt";
00056   case NVPTXCC::GE:
00057     return "ge";
00058   }
00059   llvm_unreachable("Unknown condition code");
00060 }
00061 
00062 FunctionPass *
00063 createNVPTXISelDag(NVPTXTargetMachine &TM, llvm::CodeGenOpt::Level OptLevel);
00064 ModulePass *createNVPTXAssignValidGlobalNamesPass();
00065 ModulePass *createGenericToNVVMPass();
00066 FunctionPass *createNVPTXFavorNonGenericAddrSpacesPass();
00067 ModulePass *createNVVMReflectPass();
00068 ModulePass *createNVVMReflectPass(const StringMap<int>& Mapping);
00069 MachineFunctionPass *createNVPTXPrologEpilogPass();
00070 MachineFunctionPass *createNVPTXReplaceImageHandlesPass();
00071 FunctionPass *createNVPTXImageOptimizerPass();
00072 
00073 bool isImageOrSamplerVal(const Value *, const Module *);
00074 
00075 extern Target TheNVPTXTarget32;
00076 extern Target TheNVPTXTarget64;
00077 
00078 namespace NVPTX {
00079 enum DrvInterface {
00080   NVCL,
00081   CUDA
00082 };
00083 
00084 // A field inside TSFlags needs a shift and a mask. The usage is
00085 // always as follows :
00086 // ((TSFlags & fieldMask) >> fieldShift)
00087 // The enum keeps the mask, the shift, and all valid values of the
00088 // field in one place.
00089 enum VecInstType {
00090   VecInstTypeShift = 0,
00091   VecInstTypeMask = 0xF,
00092 
00093   VecNOP = 0,
00094   VecLoad = 1,
00095   VecStore = 2,
00096   VecBuild = 3,
00097   VecShuffle = 4,
00098   VecExtract = 5,
00099   VecInsert = 6,
00100   VecDest = 7,
00101   VecOther = 15
00102 };
00103 
00104 enum SimpleMove {
00105   SimpleMoveMask = 0x10,
00106   SimpleMoveShift = 4
00107 };
00108 enum LoadStore {
00109   isLoadMask = 0x20,
00110   isLoadShift = 5,
00111   isStoreMask = 0x40,
00112   isStoreShift = 6
00113 };
00114 
00115 namespace PTXLdStInstCode {
00116 enum AddressSpace {
00117   GENERIC = 0,
00118   GLOBAL = 1,
00119   CONSTANT = 2,
00120   SHARED = 3,
00121   PARAM = 4,
00122   LOCAL = 5
00123 };
00124 enum FromType {
00125   Unsigned = 0,
00126   Signed,
00127   Float
00128 };
00129 enum VecType {
00130   Scalar = 1,
00131   V2 = 2,
00132   V4 = 4
00133 };
00134 }
00135 
00136 /// PTXCvtMode - Conversion code enumeration
00137 namespace PTXCvtMode {
00138 enum CvtMode {
00139   NONE = 0,
00140   RNI,
00141   RZI,
00142   RMI,
00143   RPI,
00144   RN,
00145   RZ,
00146   RM,
00147   RP,
00148 
00149   BASE_MASK = 0x0F,
00150   FTZ_FLAG = 0x10,
00151   SAT_FLAG = 0x20
00152 };
00153 }
00154 
00155 /// PTXCmpMode - Comparison mode enumeration
00156 namespace PTXCmpMode {
00157 enum CmpMode {
00158   EQ = 0,
00159   NE,
00160   LT,
00161   LE,
00162   GT,
00163   GE,
00164   LO,
00165   LS,
00166   HI,
00167   HS,
00168   EQU,
00169   NEU,
00170   LTU,
00171   LEU,
00172   GTU,
00173   GEU,
00174   NUM,
00175   // NAN is a MACRO
00176   NotANumber,
00177 
00178   BASE_MASK = 0xFF,
00179   FTZ_FLAG = 0x100
00180 };
00181 }
00182 }
00183 } // end namespace llvm;
00184 
00185 // Defines symbolic names for NVPTX registers.  This defines a mapping from
00186 // register name to register number.
00187 #define GET_REGINFO_ENUM
00188 #include "NVPTXGenRegisterInfo.inc"
00189 
00190 // Defines symbolic names for the NVPTX instructions.
00191 #define GET_INSTRINFO_ENUM
00192 #include "NVPTXGenInstrInfo.inc"
00193 
00194 #endif