blob: 2d2a88ab28aa091e033e535d74d2ff4cb2c71cd8 [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
Chandler Carruthd174b722014-04-22 02:03:14 +000016using namespace llvm;
17
Chandler Carruthe96dd892014-04-21 22:55:11 +000018#define DEBUG_TYPE "nvptx-subtarget"
19
Justin Holewinskiae556d32012-05-04 20:18:50 +000020#define GET_SUBTARGETINFO_ENUM
21#define GET_SUBTARGETINFO_TARGET_DESC
22#define GET_SUBTARGETINFO_CTOR
23#include "NVPTXGenSubtargetInfo.inc"
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
Eric Christopherd8132862014-06-27 02:05:19 +000040 // Provide the default CPU if we don't have one.
41 if (CPU.empty() && FS.size())
Justin Holewinskiae556d32012-05-04 20:18:50 +000042 llvm_unreachable("we are not using FeatureStr");
Eric Christopherd8132862014-06-27 02:05:19 +000043 TargetName = CPU.empty() ? "sm_20" : CPU;
44
45 ParseSubtargetFeatures(TargetName, FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +000046
Justin Holewinski1812ee92012-11-12 03:16:43 +000047 // We default to PTX 3.1, but we cannot just default to it in the initializer
48 // since the attribute parser checks if the given option is >= the default.
49 // So if we set ptx31 as the default, the ptx30 attribute would never match.
50 // Instead, we use 0 as the default and manually set 31 if the default is
51 // used.
52 if (PTXVersion == 0) {
53 PTXVersion = 31;
54 }
Justin Holewinskiae556d32012-05-04 20:18:50 +000055}