blob: 477b0bac6ca83c33cccdd3cb534976131c6ae1cc [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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_NVPTX_NVPTX_H
16#define LLVM_LIB_TARGET_NVPTX_NVPTX_H
Justin Holewinskiae556d32012-05-04 20:18:50 +000017
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
Jacques Pienaar0c7dc9f2014-12-03 23:21:02 +000062FunctionPass *createNVPTXISelDag(NVPTXTargetMachine &TM,
63 llvm::CodeGenOpt::Level OptLevel);
Eli Bendersky264cd462014-03-31 15:56:26 +000064ModulePass *createNVPTXAssignValidGlobalNamesPass();
Justin Holewinski01f89f02013-05-20 12:13:32 +000065ModulePass *createGenericToNVVMPass();
Eli Benderskybbef1722014-04-03 21:18:25 +000066FunctionPass *createNVPTXFavorNonGenericAddrSpacesPass();
Justin Holewinski18f3a1f2013-05-20 16:42:16 +000067ModulePass *createNVVMReflectPass();
68ModulePass *createNVVMReflectPass(const StringMap<int>& Mapping);
Justin Holewinskidbb3b2f2013-05-31 12:14:49 +000069MachineFunctionPass *createNVPTXPrologEpilogPass();
Justin Holewinski30d56a72014-04-09 15:39:15 +000070MachineFunctionPass *createNVPTXReplaceImageHandlesPass();
71FunctionPass *createNVPTXImageOptimizerPass();
Jingyue Wua2f60272015-06-04 21:28:26 +000072FunctionPass *createNVPTXLowerKernelArgsPass(const NVPTXTargetMachine *TM);
Justin Holewinskiae556d32012-05-04 20:18:50 +000073
74bool isImageOrSamplerVal(const Value *, const Module *);
75
76extern Target TheNVPTXTarget32;
77extern Target TheNVPTXTarget64;
78
Justin Holewinski0497ab12013-03-30 14:29:21 +000079namespace NVPTX {
Justin Holewinskiae556d32012-05-04 20:18:50 +000080enum DrvInterface {
81 NVCL,
Justin Holewinskib6e6cd32013-06-21 18:51:49 +000082 CUDA
Justin Holewinskiae556d32012-05-04 20:18:50 +000083};
84
85// A field inside TSFlags needs a shift and a mask. The usage is
86// always as follows :
87// ((TSFlags & fieldMask) >> fieldShift)
88// The enum keeps the mask, the shift, and all valid values of the
89// field in one place.
90enum VecInstType {
91 VecInstTypeShift = 0,
92 VecInstTypeMask = 0xF,
93
94 VecNOP = 0,
95 VecLoad = 1,
96 VecStore = 2,
97 VecBuild = 3,
98 VecShuffle = 4,
99 VecExtract = 5,
100 VecInsert = 6,
101 VecDest = 7,
102 VecOther = 15
103};
104
105enum SimpleMove {
106 SimpleMoveMask = 0x10,
107 SimpleMoveShift = 4
108};
109enum LoadStore {
110 isLoadMask = 0x20,
111 isLoadShift = 5,
112 isStoreMask = 0x40,
113 isStoreShift = 6
114};
115
116namespace PTXLdStInstCode {
Justin Holewinski0497ab12013-03-30 14:29:21 +0000117enum AddressSpace {
Justin Holewinskiae556d32012-05-04 20:18:50 +0000118 GENERIC = 0,
119 GLOBAL = 1,
120 CONSTANT = 2,
121 SHARED = 3,
122 PARAM = 4,
123 LOCAL = 5
124};
125enum FromType {
126 Unsigned = 0,
127 Signed,
128 Float
129};
130enum VecType {
131 Scalar = 1,
132 V2 = 2,
133 V4 = 4
134};
135}
Justin Holewinskidc5e3b62013-06-28 17:58:04 +0000136
137/// PTXCvtMode - Conversion code enumeration
138namespace PTXCvtMode {
139enum CvtMode {
140 NONE = 0,
141 RNI,
142 RZI,
143 RMI,
144 RPI,
145 RN,
146 RZ,
147 RM,
148 RP,
149
150 BASE_MASK = 0x0F,
151 FTZ_FLAG = 0x10,
152 SAT_FLAG = 0x20
153};
154}
155
156/// PTXCmpMode - Comparison mode enumeration
157namespace PTXCmpMode {
158enum CmpMode {
159 EQ = 0,
160 NE,
161 LT,
162 LE,
163 GT,
164 GE,
165 LO,
166 LS,
167 HI,
168 HS,
169 EQU,
170 NEU,
171 LTU,
172 LEU,
173 GTU,
174 GEU,
175 NUM,
176 // NAN is a MACRO
177 NotANumber,
178
179 BASE_MASK = 0xFF,
180 FTZ_FLAG = 0x100
181};
182}
Justin Holewinskiae556d32012-05-04 20:18:50 +0000183}
184} // end namespace llvm;
185
186// Defines symbolic names for NVPTX registers. This defines a mapping from
187// register name to register number.
188#define GET_REGINFO_ENUM
189#include "NVPTXGenRegisterInfo.inc"
190
191// Defines symbolic names for the NVPTX instructions.
192#define GET_INSTRINFO_ENUM
193#include "NVPTXGenInstrInfo.inc"
194
195#endif