Home | History | Annotate | Download | only in PTX
      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 //
     10 // This file implements the PTX specific subclass of TargetSubtargetInfo.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #include "PTXSubtarget.h"
     15 #include "PTX.h"
     16 #include "llvm/Support/ErrorHandling.h"
     17 #include "llvm/Support/TargetRegistry.h"
     18 
     19 #define GET_SUBTARGETINFO_TARGET_DESC
     20 #define GET_SUBTARGETINFO_CTOR
     21 #include "PTXGenSubtargetInfo.inc"
     22 
     23 using namespace llvm;
     24 
     25 PTXSubtarget::PTXSubtarget(const std::string &TT, const std::string &CPU,
     26                            const std::string &FS, bool is64Bit)
     27   : PTXGenSubtargetInfo(TT, CPU, FS),
     28     PTXTarget(PTX_COMPUTE_1_0),
     29     PTXVersion(PTX_VERSION_2_0),
     30     SupportsDouble(false),
     31     SupportsFMA(true),
     32     Is64Bit(is64Bit) {
     33   std::string TARGET = CPU;
     34   if (TARGET.empty())
     35     TARGET = "generic";
     36   ParseSubtargetFeatures(TARGET, FS);
     37 }
     38 
     39 std::string PTXSubtarget::getTargetString() const {
     40   switch(PTXTarget) {
     41     default: llvm_unreachable("Unknown PTX target");
     42     case PTX_SM_1_0: return "sm_10";
     43     case PTX_SM_1_1: return "sm_11";
     44     case PTX_SM_1_2: return "sm_12";
     45     case PTX_SM_1_3: return "sm_13";
     46     case PTX_SM_2_0: return "sm_20";
     47     case PTX_SM_2_1: return "sm_21";
     48     case PTX_SM_2_2: return "sm_22";
     49     case PTX_SM_2_3: return "sm_23";
     50     case PTX_COMPUTE_1_0: return "compute_10";
     51     case PTX_COMPUTE_1_1: return "compute_11";
     52     case PTX_COMPUTE_1_2: return "compute_12";
     53     case PTX_COMPUTE_1_3: return "compute_13";
     54     case PTX_COMPUTE_2_0: return "compute_20";
     55   }
     56 }
     57 
     58 std::string PTXSubtarget::getPTXVersionString() const {
     59   switch(PTXVersion) {
     60     default: llvm_unreachable("Unknown PTX version");
     61     case PTX_VERSION_2_0: return "2.0";
     62     case PTX_VERSION_2_1: return "2.1";
     63     case PTX_VERSION_2_2: return "2.2";
     64     case PTX_VERSION_2_3: return "2.3";
     65   }
     66 }
     67