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" |
| 15 | #define GET_SUBTARGETINFO_ENUM |
| 16 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 17 | #define GET_SUBTARGETINFO_CTOR |
| 18 | #include "NVPTXGenSubtargetInfo.inc" |
| 19 | |
| 20 | using namespace llvm; |
| 21 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 22 | |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 23 | // Pin the vtable to this file. |
| 24 | void NVPTXSubtarget::anchor() {} |
| 25 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 26 | NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU, |
| 27 | const std::string &FS, bool is64Bit) |
Justin Holewinski | 0497ab1 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 28 | : NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0), |
Justin Holewinski | 59fd8ba | 2013-03-30 14:29:30 +0000 | [diff] [blame] | 29 | SmVersion(20) { |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 30 | |
Justin Holewinski | b6e6cd3 | 2013-06-21 18:51:49 +0000 | [diff] [blame] | 31 | Triple T(TT); |
| 32 | |
| 33 | if (T.getOS() == Triple::NVCL) |
| 34 | drvInterface = NVPTX::NVCL; |
| 35 | else |
| 36 | drvInterface = NVPTX::CUDA; |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 37 | |
| 38 | // Provide the default CPU if none |
Justin Holewinski | 59fd8ba | 2013-03-30 14:29:30 +0000 | [diff] [blame] | 39 | std::string defCPU = "sm_20"; |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 40 | |
Justin Holewinski | 1812ee9 | 2012-11-12 03:16:43 +0000 | [diff] [blame] | 41 | ParseSubtargetFeatures((CPU.empty() ? defCPU : CPU), FS); |
| 42 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 43 | // Get the TargetName from the FS if available |
| 44 | if (FS.empty() && CPU.empty()) |
| 45 | TargetName = defCPU; |
| 46 | else if (!CPU.empty()) |
| 47 | TargetName = CPU; |
| 48 | else |
| 49 | llvm_unreachable("we are not using FeatureStr"); |
| 50 | |
Justin Holewinski | 1812ee9 | 2012-11-12 03:16:43 +0000 | [diff] [blame] | 51 | // We default to PTX 3.1, but we cannot just default to it in the initializer |
| 52 | // since the attribute parser checks if the given option is >= the default. |
| 53 | // So if we set ptx31 as the default, the ptx30 attribute would never match. |
| 54 | // Instead, we use 0 as the default and manually set 31 if the default is |
| 55 | // used. |
| 56 | if (PTXVersion == 0) { |
| 57 | PTXVersion = 31; |
| 58 | } |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 59 | } |