Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 1 | //===- PTXSubtarget.cpp - PTX Subtarget Information ---------------*- 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 | // |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file implements the PTX specific subclass of TargetSubtargetInfo. |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "PTXSubtarget.h" |
Evan Cheng | ffc0e73 | 2011-07-09 05:47:46 +0000 | [diff] [blame^] | 15 | #include "PTX.h" |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 16 | #include "llvm/Support/ErrorHandling.h" |
Evan Cheng | ffc0e73 | 2011-07-09 05:47:46 +0000 | [diff] [blame^] | 17 | #include "llvm/Target/TargetRegistry.h" |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 18 | |
Evan Cheng | ebdeeab | 2011-07-08 01:53:10 +0000 | [diff] [blame] | 19 | #define GET_SUBTARGETINFO_ENUM |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 20 | #define GET_SUBTARGETINFO_MC_DESC |
| 21 | #define GET_SUBTARGETINFO_TARGET_DESC |
Evan Cheng | ebdeeab | 2011-07-08 01:53:10 +0000 | [diff] [blame] | 22 | #define GET_SUBTARGETINFO_CTOR |
Evan Cheng | 385e930 | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 23 | #include "PTXGenSubtargetInfo.inc" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 24 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 25 | using namespace llvm; |
| 26 | |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 27 | PTXSubtarget::PTXSubtarget(const std::string &TT, const std::string &CPU, |
| 28 | const std::string &FS, bool is64Bit) |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 29 | : PTXGenSubtargetInfo(TT, CPU, FS), |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 30 | PTXTarget(PTX_COMPUTE_1_0), |
Justin Holewinski | 625eec1 | 2011-03-15 13:24:15 +0000 | [diff] [blame] | 31 | PTXVersion(PTX_VERSION_2_0), |
Che-Liang Chiou | f48817c | 2011-03-02 07:36:48 +0000 | [diff] [blame] | 32 | SupportsDouble(false), |
Justin Holewinski | 657d1be | 2011-05-18 15:42:23 +0000 | [diff] [blame] | 33 | SupportsFMA(true), |
Justin Holewinski | 35f4fb3 | 2011-06-24 16:27:49 +0000 | [diff] [blame] | 34 | Is64Bit(is64Bit) { |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 35 | std::string TARGET = CPU; |
| 36 | if (TARGET.empty()) |
| 37 | TARGET = "generic"; |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 38 | ParseSubtargetFeatures(TARGET, FS); |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | std::string PTXSubtarget::getTargetString() const { |
Justin Holewinski | 35f4fb3 | 2011-06-24 16:27:49 +0000 | [diff] [blame] | 42 | switch(PTXTarget) { |
| 43 | default: llvm_unreachable("Unknown PTX target"); |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 44 | case PTX_SM_1_0: return "sm_10"; |
Justin Holewinski | 35f4fb3 | 2011-06-24 16:27:49 +0000 | [diff] [blame] | 45 | case PTX_SM_1_1: return "sm_11"; |
| 46 | case PTX_SM_1_2: return "sm_12"; |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 47 | case PTX_SM_1_3: return "sm_13"; |
| 48 | case PTX_SM_2_0: return "sm_20"; |
Justin Holewinski | 35f4fb3 | 2011-06-24 16:27:49 +0000 | [diff] [blame] | 49 | case PTX_SM_2_1: return "sm_21"; |
| 50 | case PTX_SM_2_2: return "sm_22"; |
| 51 | case PTX_SM_2_3: return "sm_23"; |
| 52 | case PTX_COMPUTE_1_0: return "compute_10"; |
| 53 | case PTX_COMPUTE_1_1: return "compute_11"; |
| 54 | case PTX_COMPUTE_1_2: return "compute_12"; |
| 55 | case PTX_COMPUTE_1_3: return "compute_13"; |
| 56 | case PTX_COMPUTE_2_0: return "compute_20"; |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 57 | } |
| 58 | } |
| 59 | |
| 60 | std::string PTXSubtarget::getPTXVersionString() const { |
| 61 | switch(PTXVersion) { |
| 62 | default: llvm_unreachable("Unknown PTX version"); |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 63 | case PTX_VERSION_2_0: return "2.0"; |
| 64 | case PTX_VERSION_2_1: return "2.1"; |
Justin Holewinski | 625eec1 | 2011-03-15 13:24:15 +0000 | [diff] [blame] | 65 | case PTX_VERSION_2_2: return "2.2"; |
Justin Holewinski | ab0145d | 2011-05-06 11:40:36 +0000 | [diff] [blame] | 66 | case PTX_VERSION_2_3: return "2.3"; |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 67 | } |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 68 | } |
Evan Cheng | ffc0e73 | 2011-07-09 05:47:46 +0000 | [diff] [blame^] | 69 | |
| 70 | |
| 71 | MCSubtargetInfo *createPTXMCSubtargetInfo(StringRef TT, StringRef CPU, |
| 72 | StringRef FS) { |
| 73 | MCSubtargetInfo *X = new MCSubtargetInfo(); |
| 74 | InitPTXMCSubtargetInfo(X, CPU, FS); |
| 75 | return X; |
| 76 | } |
| 77 | |
| 78 | extern "C" void LLVMInitializePTXMCSubtargetInfo() { |
| 79 | TargetRegistry::RegisterMCSubtargetInfo(ThePTX32Target, |
| 80 | createPTXMCSubtargetInfo); |
| 81 | TargetRegistry::RegisterMCSubtargetInfo(ThePTX64Target, |
| 82 | createPTXMCSubtargetInfo); |
| 83 | } |