149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//===- NVPTXSubtarget.cpp - NVPTX Subtarget Information -------------------===// 249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// The LLVM Compiler Infrastructure 449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// This file is distributed under the University of Illinois Open Source 649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// License. See LICENSE.TXT for details. 749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//===----------------------------------------------------------------------===// 949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 1049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// This file implements the NVPTX specific subclass of TargetSubtarget. 1149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 1249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//===----------------------------------------------------------------------===// 1349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 1449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "NVPTXSubtarget.h" 1549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#define GET_SUBTARGETINFO_ENUM 1649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#define GET_SUBTARGETINFO_TARGET_DESC 1749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#define GET_SUBTARGETINFO_CTOR 1849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "NVPTXGenSubtargetInfo.inc" 1949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 2049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinskiusing namespace llvm; 2149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 2249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 2349683f3c961379fbc088871a5d6304950f1f1cbcJustin HolewinskiNVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU, 2449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski const std::string &FS, bool is64Bit) 253639ce2575660a0e6938d2e84e8bd9a738fd7051Justin Holewinski : NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0), 26b24fc1c7f7545362fe283730d5532fa7e7375c9eJustin Holewinski SmVersion(20) { 2749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 280ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski Triple T(TT); 290ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski 300ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski if (T.getOS() == Triple::NVCL) 310ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski drvInterface = NVPTX::NVCL; 320ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski else 330ff4287fe2245f417ed78fa535fce360b8b8df23Justin Holewinski drvInterface = NVPTX::CUDA; 3449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 3549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski // Provide the default CPU if none 36b24fc1c7f7545362fe283730d5532fa7e7375c9eJustin Holewinski std::string defCPU = "sm_20"; 3749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 3808e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski ParseSubtargetFeatures((CPU.empty() ? defCPU : CPU), FS); 3908e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski 4049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski // Get the TargetName from the FS if available 4149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski if (FS.empty() && CPU.empty()) 4249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski TargetName = defCPU; 4349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski else if (!CPU.empty()) 4449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski TargetName = CPU; 4549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski else 4649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski llvm_unreachable("we are not using FeatureStr"); 4749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 4808e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski // We default to PTX 3.1, but we cannot just default to it in the initializer 4908e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski // since the attribute parser checks if the given option is >= the default. 5008e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski // So if we set ptx31 as the default, the ptx30 attribute would never match. 5108e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski // Instead, we use 0 as the default and manually set 31 if the default is 5208e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski // used. 5308e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski if (PTXVersion == 0) { 5408e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski PTXVersion = 31; 5508e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski } 5649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski} 57