blob: cd9f96577ba3df19edf7ff4b6db7122f720855b8 [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);
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 Holewinskiae556d32012-05-04 20:18:50 +000070
71bool isImageOrSamplerVal(const Value *, const Module *);
72
73extern Target TheNVPTXTarget32;
74extern Target TheNVPTXTarget64;
75
Justin Holewinski0497ab12013-03-30 14:29:21 +000076namespace NVPTX {
Justin Holewinskiae556d32012-05-04 20:18:50 +000077enum DrvInterface {
78 NVCL,
Justin Holewinskib6e6cd32013-06-21 18:51:49 +000079 CUDA
Justin Holewinskiae556d32012-05-04 20:18:50 +000080};
81
82// A field inside TSFlags needs a shift and a mask. The usage is
83// always as follows :
84// ((TSFlags & fieldMask) >> fieldShift)
85// The enum keeps the mask, the shift, and all valid values of the
86// field in one place.
87enum VecInstType {
88 VecInstTypeShift = 0,
89 VecInstTypeMask = 0xF,
90
91 VecNOP = 0,
92 VecLoad = 1,
93 VecStore = 2,
94 VecBuild = 3,
95 VecShuffle = 4,
96 VecExtract = 5,
97 VecInsert = 6,
98 VecDest = 7,
99 VecOther = 15
100};
101
102enum SimpleMove {
103 SimpleMoveMask = 0x10,
104 SimpleMoveShift = 4
105};
106enum LoadStore {
107 isLoadMask = 0x20,
108 isLoadShift = 5,
109 isStoreMask = 0x40,
110 isStoreShift = 6
111};
112
113namespace PTXLdStInstCode {
Justin Holewinski0497ab12013-03-30 14:29:21 +0000114enum AddressSpace {
Justin Holewinskiae556d32012-05-04 20:18:50 +0000115 GENERIC = 0,
116 GLOBAL = 1,
117 CONSTANT = 2,
118 SHARED = 3,
119 PARAM = 4,
120 LOCAL = 5
121};
122enum FromType {
123 Unsigned = 0,
124 Signed,
125 Float
126};
127enum VecType {
128 Scalar = 1,
129 V2 = 2,
130 V4 = 4
131};
132}
Justin Holewinskidc5e3b62013-06-28 17:58:04 +0000133
134/// PTXCvtMode - Conversion code enumeration
135namespace PTXCvtMode {
136enum CvtMode {
137 NONE = 0,
138 RNI,
139 RZI,
140 RMI,
141 RPI,
142 RN,
143 RZ,
144 RM,
145 RP,
146
147 BASE_MASK = 0x0F,
148 FTZ_FLAG = 0x10,
149 SAT_FLAG = 0x20
150};
151}
152
153/// PTXCmpMode - Comparison mode enumeration
154namespace PTXCmpMode {
155enum CmpMode {
156 EQ = 0,
157 NE,
158 LT,
159 LE,
160 GT,
161 GE,
162 LO,
163 LS,
164 HI,
165 HS,
166 EQU,
167 NEU,
168 LTU,
169 LEU,
170 GTU,
171 GEU,
172 NUM,
173 // NAN is a MACRO
174 NotANumber,
175
176 BASE_MASK = 0xFF,
177 FTZ_FLAG = 0x100
178};
179}
Justin Holewinskiae556d32012-05-04 20:18:50 +0000180}
181} // end namespace llvm;
182
183// Defines symbolic names for NVPTX registers. This defines a mapping from
184// register name to register number.
185#define GET_REGINFO_ENUM
186#include "NVPTXGenRegisterInfo.inc"
187
188// Defines symbolic names for the NVPTX instructions.
189#define GET_INSTRINFO_ENUM
190#include "NVPTXGenInstrInfo.inc"
191
192#endif