LLVM API Documentation
00001 //===- NVPTXSubtarget.cpp - NVPTX Subtarget Information -------------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the NVPTX specific subclass of TargetSubtarget. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "NVPTXSubtarget.h" 00015 00016 using namespace llvm; 00017 00018 #define DEBUG_TYPE "nvptx-subtarget" 00019 00020 #define GET_SUBTARGETINFO_ENUM 00021 #define GET_SUBTARGETINFO_TARGET_DESC 00022 #define GET_SUBTARGETINFO_CTOR 00023 #include "NVPTXGenSubtargetInfo.inc" 00024 00025 // Pin the vtable to this file. 00026 void NVPTXSubtarget::anchor() {} 00027 00028 static std::string computeDataLayout(bool is64Bit) { 00029 std::string Ret = "e"; 00030 00031 if (!is64Bit) 00032 Ret += "-p:32:32"; 00033 00034 Ret += "-i64:64-v16:16-v32:32-n16:32:64"; 00035 00036 return Ret; 00037 } 00038 00039 NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU, 00040 StringRef FS) { 00041 // Provide the default CPU if we don't have one. 00042 if (CPU.empty() && FS.size()) 00043 llvm_unreachable("we are not using FeatureStr"); 00044 TargetName = CPU.empty() ? "sm_20" : CPU; 00045 00046 ParseSubtargetFeatures(TargetName, FS); 00047 00048 // Set default to PTX 3.2 (CUDA 5.5) 00049 if (PTXVersion == 0) { 00050 PTXVersion = 32; 00051 } 00052 00053 return *this; 00054 } 00055 00056 NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU, 00057 const std::string &FS, const TargetMachine &TM, 00058 bool is64Bit) 00059 : NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0), 00060 SmVersion(20), DL(computeDataLayout(is64Bit)), 00061 InstrInfo(initializeSubtargetDependencies(CPU, FS)), 00062 TLInfo((const NVPTXTargetMachine &)TM), TSInfo(&DL), 00063 FrameLowering(*this) { 00064 00065 Triple T(TT); 00066 00067 if (T.getOS() == Triple::NVCL) 00068 drvInterface = NVPTX::NVCL; 00069 else 00070 drvInterface = NVPTX::CUDA; 00071 }