[NVPTX] Re-enable support for virtual registers in the final output
[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   TEST
82 };
83
84 // A field inside TSFlags needs a shift and a mask. The usage is
85 // always as follows :
86 // ((TSFlags & fieldMask) >> fieldShift)
87 // The enum keeps the mask, the shift, and all valid values of the
88 // field in one place.
89 enum VecInstType {
90   VecInstTypeShift = 0,
91   VecInstTypeMask = 0xF,
92
93   VecNOP = 0,
94   VecLoad = 1,
95   VecStore = 2,
96   VecBuild = 3,
97   VecShuffle = 4,
98   VecExtract = 5,
99   VecInsert = 6,
100   VecDest = 7,
101   VecOther = 15
102 };
103
104 enum SimpleMove {
105   SimpleMoveMask = 0x10,
106   SimpleMoveShift = 4
107 };
108 enum LoadStore {
109   isLoadMask = 0x20,
110   isLoadShift = 5,
111   isStoreMask = 0x40,
112   isStoreShift = 6
113 };
114
115 namespace PTXLdStInstCode {
116 enum AddressSpace {
117   GENERIC = 0,
118   GLOBAL = 1,
119   CONSTANT = 2,
120   SHARED = 3,
121   PARAM = 4,
122   LOCAL = 5
123 };
124 enum FromType {
125   Unsigned = 0,
126   Signed,
127   Float
128 };
129 enum VecType {
130   Scalar = 1,
131   V2 = 2,
132   V4 = 4
133 };
134 }
135 }
136 } // end namespace llvm;
137
138 // Defines symbolic names for NVPTX registers.  This defines a mapping from
139 // register name to register number.
140 #define GET_REGINFO_ENUM
141 #include "NVPTXGenRegisterInfo.inc"
142
143 // Defines symbolic names for the NVPTX instructions.
144 #define GET_INSTRINFO_ENUM
145 #include "NVPTXGenInstrInfo.inc"
146
147 #endif