blob: 6898256b2d6e535d48af7c2ed16c7c1e6cf17a87 [file] [log] [blame]
Justin Holewinskiae556d32012-05-04 20:18:50 +00001//===- 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"
Chandler Carruthe96dd892014-04-21 22:55:11 +000015
16#define DEBUG_TYPE "nvptx-subtarget"
17
Justin Holewinskiae556d32012-05-04 20:18:50 +000018#define GET_SUBTARGETINFO_ENUM
19#define GET_SUBTARGETINFO_TARGET_DESC
20#define GET_SUBTARGETINFO_CTOR
21#include "NVPTXGenSubtargetInfo.inc"
22
23using namespace llvm;
24
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000025// Pin the vtable to this file.
26void NVPTXSubtarget::anchor() {}
27
Justin Holewinskiae556d32012-05-04 20:18:50 +000028NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
29 const std::string &FS, bool is64Bit)
Justin Holewinski0497ab12013-03-30 14:29:21 +000030 : NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0),
Justin Holewinski59fd8ba2013-03-30 14:29:30 +000031 SmVersion(20) {
Justin Holewinskiae556d32012-05-04 20:18:50 +000032
Justin Holewinskib6e6cd32013-06-21 18:51:49 +000033 Triple T(TT);
34
35 if (T.getOS() == Triple::NVCL)
36 drvInterface = NVPTX::NVCL;
37 else
38 drvInterface = NVPTX::CUDA;
Justin Holewinskiae556d32012-05-04 20:18:50 +000039
40 // Provide the default CPU if none
Justin Holewinski59fd8ba2013-03-30 14:29:30 +000041 std::string defCPU = "sm_20";
Justin Holewinskiae556d32012-05-04 20:18:50 +000042
Justin Holewinski1812ee92012-11-12 03:16:43 +000043 ParseSubtargetFeatures((CPU.empty() ? defCPU : CPU), FS);
44
Justin Holewinskiae556d32012-05-04 20:18:50 +000045 // Get the TargetName from the FS if available
46 if (FS.empty() && CPU.empty())
47 TargetName = defCPU;
48 else if (!CPU.empty())
49 TargetName = CPU;
50 else
51 llvm_unreachable("we are not using FeatureStr");
52
Justin Holewinski1812ee92012-11-12 03:16:43 +000053 // We default to PTX 3.1, but we cannot just default to it in the initializer
54 // since the attribute parser checks if the given option is >= the default.
55 // So if we set ptx31 as the default, the ptx30 attribute would never match.
56 // Instead, we use 0 as the default and manually set 31 if the default is
57 // used.
58 if (PTXVersion == 0) {
59 PTXVersion = 31;
60 }
Justin Holewinskiae556d32012-05-04 20:18:50 +000061}