Justin Holewinski | ae556d3 | 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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H |
| 15 | #define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 16 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 17 | #include "NVPTX.h" |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 18 | #include "NVPTXFrameLowering.h" |
| 19 | #include "NVPTXISelLowering.h" |
| 20 | #include "NVPTXInstrInfo.h" |
| 21 | #include "NVPTXRegisterInfo.h" |
Benjamin Kramer | f9172fd4 | 2016-01-27 16:32:26 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/SelectionDAGTargetInfo.h" |
David Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 24 | #include "llvm/IR/DataLayout.h" |
Chandler Carruth | ff55593 | 2014-04-22 02:28:45 +0000 | [diff] [blame] | 25 | #include <string> |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 26 | |
| 27 | #define GET_SUBTARGETINFO_HEADER |
| 28 | #include "NVPTXGenSubtargetInfo.inc" |
| 29 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 30 | namespace llvm { |
| 31 | |
| 32 | class NVPTXSubtarget : public NVPTXGenSubtargetInfo { |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 33 | virtual void anchor(); |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 34 | std::string TargetName; |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 35 | |
Justin Holewinski | 1812ee9 | 2012-11-12 03:16:43 +0000 | [diff] [blame] | 36 | // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31 |
| 37 | unsigned PTXVersion; |
| 38 | |
| 39 | // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31 |
| 40 | unsigned int SmVersion; |
| 41 | |
Eric Christopher | 6aad8b1 | 2015-02-19 00:08:14 +0000 | [diff] [blame] | 42 | const NVPTXTargetMachine &TM; |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 43 | NVPTXInstrInfo InstrInfo; |
| 44 | NVPTXTargetLowering TLInfo; |
Benjamin Kramer | f9172fd4 | 2016-01-27 16:32:26 +0000 | [diff] [blame] | 45 | SelectionDAGTargetInfo TSInfo; |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 46 | |
| 47 | // NVPTX does not have any call stack frame, but need a NVPTX specific |
| 48 | // FrameLowering class because TargetFrameLowering is abstract. |
| 49 | NVPTXFrameLowering FrameLowering; |
| 50 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 51 | public: |
| 52 | /// This constructor initializes the data members to match that |
| 53 | /// of the specified module. |
| 54 | /// |
Daniel Sanders | a73f1fd | 2015-06-10 12:11:26 +0000 | [diff] [blame] | 55 | NVPTXSubtarget(const Triple &TT, const std::string &CPU, |
Eric Christopher | 02389e3 | 2015-02-19 00:08:27 +0000 | [diff] [blame] | 56 | const std::string &FS, const NVPTXTargetMachine &TM); |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 57 | |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 58 | const TargetFrameLowering *getFrameLowering() const override { |
| 59 | return &FrameLowering; |
| 60 | } |
| 61 | const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; } |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 62 | const NVPTXRegisterInfo *getRegisterInfo() const override { |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 63 | return &InstrInfo.getRegisterInfo(); |
| 64 | } |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 65 | const NVPTXTargetLowering *getTargetLowering() const override { |
| 66 | return &TLInfo; |
| 67 | } |
Benjamin Kramer | f9172fd4 | 2016-01-27 16:32:26 +0000 | [diff] [blame] | 68 | const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 69 | return &TSInfo; |
| 70 | } |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 71 | |
Artem Belevich | 3e12115 | 2016-09-28 17:25:38 +0000 | [diff] [blame] | 72 | bool hasAtomAddF64() const { return SmVersion >= 60; } |
Artem Belevich | 24e8a68 | 2018-04-11 17:51:19 +0000 | [diff] [blame] | 73 | bool hasAtomScope() const { return SmVersion >= 60; } |
Artem Belevich | 3e12115 | 2016-09-28 17:25:38 +0000 | [diff] [blame] | 74 | bool hasAtomBitwise64() const { return SmVersion >= 32; } |
| 75 | bool hasAtomMinMax64() const { return SmVersion >= 32; } |
Justin Holewinski | be8dc64 | 2013-02-12 14:18:49 +0000 | [diff] [blame] | 76 | bool hasLDG() const { return SmVersion >= 32; } |
Justin Holewinski | c3f31eb | 2014-06-27 18:35:16 +0000 | [diff] [blame] | 77 | inline bool hasHWROT32() const { return SmVersion >= 32; } |
Eric Christopher | beffc4e | 2015-02-19 00:08:23 +0000 | [diff] [blame] | 78 | bool hasImageHandles() const; |
Artem Belevich | 64dc9be | 2017-01-13 20:56:17 +0000 | [diff] [blame] | 79 | bool hasFP16Math() const { return SmVersion >= 53; } |
| 80 | bool allowFP16Math() const; |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 81 | unsigned int getSmVersion() const { return SmVersion; } |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 82 | std::string getTargetName() const { return TargetName; } |
| 83 | |
Justin Holewinski | 1812ee9 | 2012-11-12 03:16:43 +0000 | [diff] [blame] | 84 | unsigned getPTXVersion() const { return PTXVersion; } |
| 85 | |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 86 | NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 87 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 90 | } // End llvm namespace |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 91 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 92 | #endif |