Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 1 | //===- NVPTXSubtarget.cpp - NVPTX Subtarget Information -------------------===// |
| 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 implements the NVPTX specific subclass of TargetSubtarget. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "NVPTXSubtarget.h" |
Eric Christopher | 6aad8b1 | 2015-02-19 00:08:14 +0000 | [diff] [blame^] | 15 | #include "NVPTXTargetMachine.h" |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 16 | |
Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame] | 17 | using namespace llvm; |
| 18 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 19 | #define DEBUG_TYPE "nvptx-subtarget" |
| 20 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 21 | #define GET_SUBTARGETINFO_ENUM |
| 22 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 23 | #define GET_SUBTARGETINFO_CTOR |
| 24 | #include "NVPTXGenSubtargetInfo.inc" |
| 25 | |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 26 | // Pin the vtable to this file. |
| 27 | void NVPTXSubtarget::anchor() {} |
| 28 | |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 29 | NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU, |
| 30 | StringRef FS) { |
| 31 | // Provide the default CPU if we don't have one. |
Eric Christopher | d813286 | 2014-06-27 02:05:19 +0000 | [diff] [blame] | 32 | if (CPU.empty() && FS.size()) |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 33 | llvm_unreachable("we are not using FeatureStr"); |
Eric Christopher | d813286 | 2014-06-27 02:05:19 +0000 | [diff] [blame] | 34 | TargetName = CPU.empty() ? "sm_20" : CPU; |
| 35 | |
| 36 | ParseSubtargetFeatures(TargetName, FS); |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 37 | |
Justin Holewinski | 602fa5b | 2014-06-27 18:35:18 +0000 | [diff] [blame] | 38 | // Set default to PTX 3.2 (CUDA 5.5) |
| 39 | if (PTXVersion == 0) { |
| 40 | PTXVersion = 32; |
| 41 | } |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 42 | |
| 43 | return *this; |
| 44 | } |
| 45 | |
| 46 | NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU, |
Eric Christopher | 6aad8b1 | 2015-02-19 00:08:14 +0000 | [diff] [blame^] | 47 | const std::string &FS, |
| 48 | const NVPTXTargetMachine &TM, bool is64Bit) |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 49 | : NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0), |
Eric Christopher | 6aad8b1 | 2015-02-19 00:08:14 +0000 | [diff] [blame^] | 50 | SmVersion(20), TM(TM), |
| 51 | InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this), |
| 52 | TSInfo(TM.getDataLayout()), FrameLowering(*this) {} |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 53 | |
Eric Christopher | 6aad8b1 | 2015-02-19 00:08:14 +0000 | [diff] [blame^] | 54 | NVPTX::DrvInterface NVPTXSubtarget::getDrvInterface() const { |
| 55 | return TM.getDrvInterface(); |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 56 | } |