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 *createNVPTXISelDag(NVPTXTargetMachine &TM,
00063                                  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 FunctionPass *createNVPTXLowerStructArgsPass();
00073 
00074 bool isImageOrSamplerVal(const Value *, const Module *);
00075 
00076 extern Target TheNVPTXTarget32;
00077 extern Target TheNVPTXTarget64;
00078 
00079 namespace NVPTX {
00080 enum DrvInterface {
00081   NVCL,
00082   CUDA
00083 };
00084 
00085 // A field inside TSFlags needs a shift and a mask. The usage is
00086 // always as follows :
00087 // ((TSFlags & fieldMask) >> fieldShift)
00088 // The enum keeps the mask, the shift, and all valid values of the
00089 // field in one place.
00090 enum VecInstType {
00091   VecInstTypeShift = 0,
00092   VecInstTypeMask = 0xF,
00093 
00094   VecNOP = 0,
00095   VecLoad = 1,
00096   VecStore = 2,
00097   VecBuild = 3,
00098   VecShuffle = 4,
00099   VecExtract = 5,
00100   VecInsert = 6,
00101   VecDest = 7,
00102   VecOther = 15
00103 };
00104 
00105 enum SimpleMove {
00106   SimpleMoveMask = 0x10,
00107   SimpleMoveShift = 4
00108 };
00109 enum LoadStore {
00110   isLoadMask = 0x20,
00111   isLoadShift = 5,
00112   isStoreMask = 0x40,
00113   isStoreShift = 6
00114 };
00115 
00116 namespace PTXLdStInstCode {
00117 enum AddressSpace {
00118   GENERIC = 0,
00119   GLOBAL = 1,
00120   CONSTANT = 2,
00121   SHARED = 3,
00122   PARAM = 4,
00123   LOCAL = 5
00124 };
00125 enum FromType {
00126   Unsigned = 0,
00127   Signed,
00128   Float
00129 };
00130 enum VecType {
00131   Scalar = 1,
00132   V2 = 2,
00133   V4 = 4
00134 };
00135 }
00136 
00137 /// PTXCvtMode - Conversion code enumeration
00138 namespace PTXCvtMode {
00139 enum CvtMode {
00140   NONE = 0,
00141   RNI,
00142   RZI,
00143   RMI,
00144   RPI,
00145   RN,
00146   RZ,
00147   RM,
00148   RP,
00149 
00150   BASE_MASK = 0x0F,
00151   FTZ_FLAG = 0x10,
00152   SAT_FLAG = 0x20
00153 };
00154 }
00155 
00156 /// PTXCmpMode - Comparison mode enumeration
00157 namespace PTXCmpMode {
00158 enum CmpMode {
00159   EQ = 0,
00160   NE,
00161   LT,
00162   LE,
00163   GT,
00164   GE,
00165   LO,
00166   LS,
00167   HI,
00168   HS,
00169   EQU,
00170   NEU,
00171   LTU,
00172   LEU,
00173   GTU,
00174   GEU,
00175   NUM,
00176   // NAN is a MACRO
00177   NotANumber,
00178 
00179   BASE_MASK = 0xFF,
00180   FTZ_FLAG = 0x100
00181 };
00182 }
00183 }
00184 } // end namespace llvm;
00185 
00186 // Defines symbolic names for NVPTX registers.  This defines a mapping from
00187 // register name to register number.
00188 #define GET_REGINFO_ENUM
00189 #include "NVPTXGenRegisterInfo.inc"
00190 
00191 // Defines symbolic names for the NVPTX instructions.
00192 #define GET_INSTRINFO_ENUM
00193 #include "NVPTXGenInstrInfo.inc"
00194 
00195 #endif