Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 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 | |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 18 | #include "MCTargetDesc/NVPTXBaseInfo.h" |
Justin Holewinski | d223675 | 2013-05-20 16:42:16 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/StringMap.h" |
Chandler Carruth | 0b8c9a8 | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 20 | #include "llvm/IR/Module.h" |
| 21 | #include "llvm/IR/Value.h" |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 22 | #include "llvm/Support/ErrorHandling.h" |
| 23 | #include "llvm/Target/TargetMachine.h" |
Yuan Lin | 09b5df8 | 2012-06-05 19:06:13 +0000 | [diff] [blame] | 24 | #include <cassert> |
| 25 | #include <iosfwd> |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 26 | |
| 27 | namespace llvm { |
| 28 | class NVPTXTargetMachine; |
| 29 | class FunctionPass; |
| 30 | class formatted_raw_ostream; |
| 31 | |
| 32 | namespace NVPTXCC { |
| 33 | enum CondCodes { |
| 34 | EQ, |
| 35 | NE, |
| 36 | LT, |
| 37 | LE, |
| 38 | GT, |
| 39 | GE |
| 40 | }; |
| 41 | } |
| 42 | |
| 43 | inline static const char *NVPTXCondCodeToString(NVPTXCC::CondCodes CC) { |
| 44 | switch (CC) { |
Justin Holewinski | 3639ce2 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 45 | case NVPTXCC::NE: |
| 46 | return "ne"; |
| 47 | case NVPTXCC::EQ: |
| 48 | return "eq"; |
| 49 | case NVPTXCC::LT: |
| 50 | return "lt"; |
| 51 | case NVPTXCC::LE: |
| 52 | return "le"; |
| 53 | case NVPTXCC::GT: |
| 54 | return "gt"; |
| 55 | case NVPTXCC::GE: |
| 56 | return "ge"; |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 57 | } |
Chandler Carruth | 917644d | 2012-05-04 21:35:49 +0000 | [diff] [blame] | 58 | llvm_unreachable("Unknown condition code"); |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Justin Holewinski | 3639ce2 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 61 | FunctionPass * |
| 62 | createNVPTXISelDag(NVPTXTargetMachine &TM, llvm::CodeGenOpt::Level OptLevel); |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 63 | FunctionPass *createLowerStructArgsPass(NVPTXTargetMachine &); |
| 64 | FunctionPass *createNVPTXReMatPass(NVPTXTargetMachine &); |
| 65 | FunctionPass *createNVPTXReMatBlockPass(NVPTXTargetMachine &); |
Justin Holewinski | 7536ecf | 2013-05-20 12:13:32 +0000 | [diff] [blame] | 66 | ModulePass *createGenericToNVVMPass(); |
Justin Holewinski | d223675 | 2013-05-20 16:42:16 +0000 | [diff] [blame] | 67 | ModulePass *createNVVMReflectPass(); |
| 68 | ModulePass *createNVVMReflectPass(const StringMap<int>& Mapping); |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 69 | |
| 70 | bool isImageOrSamplerVal(const Value *, const Module *); |
| 71 | |
| 72 | extern Target TheNVPTXTarget32; |
| 73 | extern Target TheNVPTXTarget64; |
| 74 | |
Justin Holewinski | 3639ce2 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 75 | namespace NVPTX { |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 76 | enum DrvInterface { |
| 77 | NVCL, |
| 78 | CUDA, |
| 79 | TEST |
| 80 | }; |
| 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. |
| 87 | enum 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 | |
| 102 | enum SimpleMove { |
| 103 | SimpleMoveMask = 0x10, |
| 104 | SimpleMoveShift = 4 |
| 105 | }; |
| 106 | enum LoadStore { |
| 107 | isLoadMask = 0x20, |
| 108 | isLoadShift = 5, |
| 109 | isStoreMask = 0x40, |
| 110 | isStoreShift = 6 |
| 111 | }; |
| 112 | |
| 113 | namespace PTXLdStInstCode { |
Justin Holewinski | 3639ce2 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 114 | enum AddressSpace { |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 115 | GENERIC = 0, |
| 116 | GLOBAL = 1, |
| 117 | CONSTANT = 2, |
| 118 | SHARED = 3, |
| 119 | PARAM = 4, |
| 120 | LOCAL = 5 |
| 121 | }; |
| 122 | enum FromType { |
| 123 | Unsigned = 0, |
| 124 | Signed, |
| 125 | Float |
| 126 | }; |
| 127 | enum VecType { |
| 128 | Scalar = 1, |
| 129 | V2 = 2, |
| 130 | V4 = 4 |
| 131 | }; |
| 132 | } |
| 133 | } |
| 134 | } // end namespace llvm; |
| 135 | |
| 136 | // Defines symbolic names for NVPTX registers. This defines a mapping from |
| 137 | // register name to register number. |
| 138 | #define GET_REGINFO_ENUM |
| 139 | #include "NVPTXGenRegisterInfo.inc" |
| 140 | |
| 141 | // Defines symbolic names for the NVPTX instructions. |
| 142 | #define GET_INSTRINFO_ENUM |
| 143 | #include "NVPTXGenInstrInfo.inc" |
| 144 | |
| 145 | #endif |