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