Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 1 | //=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- 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 declares the NVPTX specific subclass of TargetSubtarget. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef NVPTXSUBTARGET_H |
| 15 | #define NVPTXSUBTARGET_H |
| 16 | |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 17 | #include "NVPTX.h" |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetSubtargetInfo.h" |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 19 | |
| 20 | #define GET_SUBTARGETINFO_HEADER |
| 21 | #include "NVPTXGenSubtargetInfo.inc" |
| 22 | |
| 23 | #include <string> |
| 24 | |
| 25 | namespace llvm { |
| 26 | |
| 27 | class NVPTXSubtarget : public NVPTXGenSubtargetInfo { |
Justin Holewinski | 3639ce2 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 28 | |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 29 | std::string TargetName; |
| 30 | NVPTX::DrvInterface drvInterface; |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 31 | bool Is64Bit; |
| 32 | |
Justin Holewinski | 08e9cb4 | 2012-11-12 03:16:43 +0000 | [diff] [blame] | 33 | // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31 |
| 34 | unsigned PTXVersion; |
| 35 | |
| 36 | // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31 |
| 37 | unsigned int SmVersion; |
| 38 | |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 39 | public: |
| 40 | /// This constructor initializes the data members to match that |
| 41 | /// of the specified module. |
| 42 | /// |
| 43 | NVPTXSubtarget(const std::string &TT, const std::string &CPU, |
| 44 | const std::string &FS, bool is64Bit); |
| 45 | |
| 46 | bool hasBrkPt() const { return SmVersion >= 11; } |
| 47 | bool hasAtomRedG32() const { return SmVersion >= 11; } |
| 48 | bool hasAtomRedS32() const { return SmVersion >= 12; } |
| 49 | bool hasAtomRedG64() const { return SmVersion >= 12; } |
| 50 | bool hasAtomRedS64() const { return SmVersion >= 20; } |
| 51 | bool hasAtomRedGen32() const { return SmVersion >= 20; } |
| 52 | bool hasAtomRedGen64() const { return SmVersion >= 20; } |
| 53 | bool hasAtomAddF32() const { return SmVersion >= 20; } |
| 54 | bool hasVote() const { return SmVersion >= 12; } |
| 55 | bool hasDouble() const { return SmVersion >= 13; } |
| 56 | bool reqPTX20() const { return SmVersion >= 20; } |
| 57 | bool hasF32FTZ() const { return SmVersion >= 20; } |
| 58 | bool hasFMAF32() const { return SmVersion >= 20; } |
| 59 | bool hasFMAF64() const { return SmVersion >= 13; } |
Justin Holewinski | 7eacad0 | 2013-02-12 14:18:49 +0000 | [diff] [blame] | 60 | bool hasLDG() const { return SmVersion >= 32; } |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 61 | bool hasLDU() const { return SmVersion >= 20; } |
| 62 | bool hasGenericLdSt() const { return SmVersion >= 20; } |
| 63 | inline bool hasHWROT32() const { return false; } |
Justin Holewinski | 3639ce2 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 64 | inline bool hasSWROT32() const { return true; } |
| 65 | inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); } |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 66 | inline bool hasROT64() const { return SmVersion >= 20; } |
| 67 | |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 68 | bool is64Bit() const { return Is64Bit; } |
| 69 | |
| 70 | unsigned int getSmVersion() const { return SmVersion; } |
| 71 | NVPTX::DrvInterface getDrvInterface() const { return drvInterface; } |
| 72 | std::string getTargetName() const { return TargetName; } |
| 73 | |
Justin Holewinski | 08e9cb4 | 2012-11-12 03:16:43 +0000 | [diff] [blame] | 74 | unsigned getPTXVersion() const { return PTXVersion; } |
| 75 | |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 76 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
| 77 | |
| 78 | std::string getDataLayout() const { |
| 79 | const char *p; |
| 80 | if (is64Bit()) |
| 81 | p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" |
| 82 | "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-" |
| 83 | "n16:32:64"; |
| 84 | else |
| 85 | p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" |
| 86 | "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-" |
| 87 | "n16:32:64"; |
| 88 | |
| 89 | return std::string(p); |
| 90 | } |
| 91 | |
| 92 | }; |
| 93 | |
| 94 | } // End llvm namespace |
| 95 | |
Justin Holewinski | 3639ce2 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 96 | #endif // NVPTXSUBTARGET_H |