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