blob: 7b62cce2c65c03521577f6d455e1b4a6faf2c154 [file] [log] [blame]
Justin Holewinski49683f32012-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"
15#define GET_SUBTARGETINFO_ENUM
16#define GET_SUBTARGETINFO_TARGET_DESC
17#define GET_SUBTARGETINFO_CTOR
18#include "NVPTXGenSubtargetInfo.inc"
19
20using namespace llvm;
21
22// Select Driver Interface
23#include "llvm/Support/CommandLine.h"
24namespace {
25cl::opt<NVPTX::DrvInterface>
26DriverInterface(cl::desc("Choose driver interface:"),
27 cl::values(
28 clEnumValN(NVPTX::NVCL, "drvnvcl", "Nvidia OpenCL driver"),
29 clEnumValN(NVPTX::CUDA, "drvcuda", "Nvidia CUDA driver"),
30 clEnumValN(NVPTX::TEST, "drvtest", "Plain Test"),
31 clEnumValEnd),
32 cl::init(NVPTX::NVCL));
33}
34
35NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
36 const std::string &FS, bool is64Bit)
Justin Holewinski08e9cb42012-11-12 03:16:43 +000037: NVPTXGenSubtargetInfo(TT, CPU, FS),
38 Is64Bit(is64Bit),
39 PTXVersion(0),
40 SmVersion(10) {
Justin Holewinski49683f32012-05-04 20:18:50 +000041
42 drvInterface = DriverInterface;
43
44 // Provide the default CPU if none
45 std::string defCPU = "sm_10";
46
Justin Holewinski08e9cb42012-11-12 03:16:43 +000047 ParseSubtargetFeatures((CPU.empty() ? defCPU : CPU), FS);
48
Justin Holewinski49683f32012-05-04 20:18:50 +000049 // Get the TargetName from the FS if available
50 if (FS.empty() && CPU.empty())
51 TargetName = defCPU;
52 else if (!CPU.empty())
53 TargetName = CPU;
54 else
55 llvm_unreachable("we are not using FeatureStr");
56
Justin Holewinski08e9cb42012-11-12 03:16:43 +000057 // We default to PTX 3.1, but we cannot just default to it in the initializer
58 // since the attribute parser checks if the given option is >= the default.
59 // So if we set ptx31 as the default, the ptx30 attribute would never match.
60 // Instead, we use 0 as the default and manually set 31 if the default is
61 // used.
62 if (PTXVersion == 0) {
63 PTXVersion = 31;
64 }
Justin Holewinski49683f32012-05-04 20:18:50 +000065}