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