blob: 7be3f9aa2f7e99a1761d474f37ad56fef18754b1 [file] [log] [blame]
Justin Holewinskiae556d32012-05-04 20:18:50 +00001//===-- 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
Chandler Carruth802d7552012-12-04 07:12:27 +000018#include "MCTargetDesc/NVPTXBaseInfo.h"
Justin Holewinski18f3a1f2013-05-20 16:42:16 +000019#include "llvm/ADT/StringMap.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000020#include "llvm/IR/Module.h"
21#include "llvm/IR/Value.h"
Justin Holewinskiae556d32012-05-04 20:18:50 +000022#include "llvm/Support/ErrorHandling.h"
23#include "llvm/Target/TargetMachine.h"
Yuan Lin572a3a22012-06-05 19:06:13 +000024#include <cassert>
25#include <iosfwd>
Justin Holewinskiae556d32012-05-04 20:18:50 +000026
27namespace llvm {
28class NVPTXTargetMachine;
29class FunctionPass;
Justin Holewinskidbb3b2f2013-05-31 12:14:49 +000030class MachineFunctionPass;
Justin Holewinskiae556d32012-05-04 20:18:50 +000031class formatted_raw_ostream;
32
33namespace NVPTXCC {
34enum CondCodes {
35 EQ,
36 NE,
37 LT,
38 LE,
39 GT,
40 GE
41};
42}
43
44inline static const char *NVPTXCondCodeToString(NVPTXCC::CondCodes CC) {
45 switch (CC) {
Justin Holewinski0497ab12013-03-30 14:29:21 +000046 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";
Justin Holewinskiae556d32012-05-04 20:18:50 +000058 }
Chandler Carruthcd3464e2012-05-04 21:35:49 +000059 llvm_unreachable("Unknown condition code");
Justin Holewinskiae556d32012-05-04 20:18:50 +000060}
61
Justin Holewinski0497ab12013-03-30 14:29:21 +000062FunctionPass *
63createNVPTXISelDag(NVPTXTargetMachine &TM, llvm::CodeGenOpt::Level OptLevel);
Justin Holewinskiae556d32012-05-04 20:18:50 +000064FunctionPass *createLowerStructArgsPass(NVPTXTargetMachine &);
65FunctionPass *createNVPTXReMatPass(NVPTXTargetMachine &);
66FunctionPass *createNVPTXReMatBlockPass(NVPTXTargetMachine &);
Justin Holewinski01f89f02013-05-20 12:13:32 +000067ModulePass *createGenericToNVVMPass();
Justin Holewinski18f3a1f2013-05-20 16:42:16 +000068ModulePass *createNVVMReflectPass();
69ModulePass *createNVVMReflectPass(const StringMap<int>& Mapping);
Justin Holewinskidbb3b2f2013-05-31 12:14:49 +000070MachineFunctionPass *createNVPTXPrologEpilogPass();
Justin Holewinskiae556d32012-05-04 20:18:50 +000071
72bool isImageOrSamplerVal(const Value *, const Module *);
73
74extern Target TheNVPTXTarget32;
75extern Target TheNVPTXTarget64;
76
Justin Holewinski0497ab12013-03-30 14:29:21 +000077namespace NVPTX {
Justin Holewinskiae556d32012-05-04 20:18:50 +000078enum DrvInterface {
79 NVCL,
Justin Holewinskib6e6cd32013-06-21 18:51:49 +000080 CUDA
Justin Holewinskiae556d32012-05-04 20:18:50 +000081};
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.
88enum 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
103enum SimpleMove {
104 SimpleMoveMask = 0x10,
105 SimpleMoveShift = 4
106};
107enum LoadStore {
108 isLoadMask = 0x20,
109 isLoadShift = 5,
110 isStoreMask = 0x40,
111 isStoreShift = 6
112};
113
114namespace PTXLdStInstCode {
Justin Holewinski0497ab12013-03-30 14:29:21 +0000115enum AddressSpace {
Justin Holewinskiae556d32012-05-04 20:18:50 +0000116 GENERIC = 0,
117 GLOBAL = 1,
118 CONSTANT = 2,
119 SHARED = 3,
120 PARAM = 4,
121 LOCAL = 5
122};
123enum FromType {
124 Unsigned = 0,
125 Signed,
126 Float
127};
128enum VecType {
129 Scalar = 1,
130 V2 = 2,
131 V4 = 4
132};
133}
Justin Holewinskidc5e3b62013-06-28 17:58:04 +0000134
135/// PTXCvtMode - Conversion code enumeration
136namespace PTXCvtMode {
137enum 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
155namespace PTXCmpMode {
156enum 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}
Justin Holewinskiae556d32012-05-04 20:18:50 +0000181}
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