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