Fixed/added namespace ending comments using clang-tidy. NFC
[oota-llvm.git] / lib / Target / NVPTX / NVPTX.h
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 inline static const char *NVPTXCondCodeToString(NVPTXCC::CondCodes CC) {
45   switch (CC) {
46   case NVPTXCC::NE:
47     return "ne";
48   case NVPTXCC::EQ:
49     return "eq";
50   case NVPTXCC::LT:
51     return "lt";
52   case NVPTXCC::LE:
53     return "le";
54   case NVPTXCC::GT:
55     return "gt";
56   case NVPTXCC::GE:
57     return "ge";
58   }
59   llvm_unreachable("Unknown condition code");
60 }
61
62 FunctionPass *createNVPTXISelDag(NVPTXTargetMachine &TM,
63                                  llvm::CodeGenOpt::Level OptLevel);
64 ModulePass *createNVPTXAssignValidGlobalNamesPass();
65 ModulePass *createGenericToNVVMPass();
66 FunctionPass *createNVPTXFavorNonGenericAddrSpacesPass();
67 ModulePass *createNVVMReflectPass();
68 ModulePass *createNVVMReflectPass(const StringMap<int>& Mapping);
69 MachineFunctionPass *createNVPTXPrologEpilogPass();
70 MachineFunctionPass *createNVPTXReplaceImageHandlesPass();
71 FunctionPass *createNVPTXImageOptimizerPass();
72 FunctionPass *createNVPTXLowerKernelArgsPass(const NVPTXTargetMachine *TM);
73 BasicBlockPass *createNVPTXLowerAllocaPass();
74
75 bool isImageOrSamplerVal(const Value *, const Module *);
76
77 extern Target TheNVPTXTarget32;
78 extern Target TheNVPTXTarget64;
79
80 namespace NVPTX {
81 enum DrvInterface {
82   NVCL,
83   CUDA
84 };
85
86 // A field inside TSFlags needs a shift and a mask. The usage is
87 // always as follows :
88 // ((TSFlags & fieldMask) >> fieldShift)
89 // The enum keeps the mask, the shift, and all valid values of the
90 // field in one place.
91 enum VecInstType {
92   VecInstTypeShift = 0,
93   VecInstTypeMask = 0xF,
94
95   VecNOP = 0,
96   VecLoad = 1,
97   VecStore = 2,
98   VecBuild = 3,
99   VecShuffle = 4,
100   VecExtract = 5,
101   VecInsert = 6,
102   VecDest = 7,
103   VecOther = 15
104 };
105
106 enum SimpleMove {
107   SimpleMoveMask = 0x10,
108   SimpleMoveShift = 4
109 };
110 enum LoadStore {
111   isLoadMask = 0x20,
112   isLoadShift = 5,
113   isStoreMask = 0x40,
114   isStoreShift = 6
115 };
116
117 namespace PTXLdStInstCode {
118 enum AddressSpace {
119   GENERIC = 0,
120   GLOBAL = 1,
121   CONSTANT = 2,
122   SHARED = 3,
123   PARAM = 4,
124   LOCAL = 5
125 };
126 enum FromType {
127   Unsigned = 0,
128   Signed,
129   Float
130 };
131 enum VecType {
132   Scalar = 1,
133   V2 = 2,
134   V4 = 4
135 };
136 } // namespace PTXLdStInstCode
137
138 /// PTXCvtMode - Conversion code enumeration
139 namespace PTXCvtMode {
140 enum CvtMode {
141   NONE = 0,
142   RNI,
143   RZI,
144   RMI,
145   RPI,
146   RN,
147   RZ,
148   RM,
149   RP,
150
151   BASE_MASK = 0x0F,
152   FTZ_FLAG = 0x10,
153   SAT_FLAG = 0x20
154 };
155 } // namespace PTXCvtMode
156
157 /// PTXCmpMode - Comparison mode enumeration
158 namespace PTXCmpMode {
159 enum CmpMode {
160   EQ = 0,
161   NE,
162   LT,
163   LE,
164   GT,
165   GE,
166   LO,
167   LS,
168   HI,
169   HS,
170   EQU,
171   NEU,
172   LTU,
173   LEU,
174   GTU,
175   GEU,
176   NUM,
177   // NAN is a MACRO
178   NotANumber,
179
180   BASE_MASK = 0xFF,
181   FTZ_FLAG = 0x100
182 };
183 } // namespace PTXCmpMode
184 } // namespace NVPTX
185 } // namespace llvm
186
187 // Defines symbolic names for NVPTX registers.  This defines a mapping from
188 // register name to register number.
189 #define GET_REGINFO_ENUM
190 #include "NVPTXGenRegisterInfo.inc"
191
192 // Defines symbolic names for the NVPTX instructions.
193 #define GET_INSTRINFO_ENUM
194 #include "NVPTXGenInstrInfo.inc"
195
196 #endif