blob: c22418cc57a70972a644f06022aa35bef694beef [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"
Eric Christopher6aad8b12015-02-19 00:08:14 +000015#include "NVPTXTargetMachine.h"
Chandler Carruthe96dd892014-04-21 22:55:11 +000016
Chandler Carruthd174b722014-04-22 02:03:14 +000017using namespace llvm;
18
Chandler Carruthe96dd892014-04-21 22:55:11 +000019#define DEBUG_TYPE "nvptx-subtarget"
20
Justin Holewinskiae556d32012-05-04 20:18:50 +000021#define GET_SUBTARGETINFO_ENUM
22#define GET_SUBTARGETINFO_TARGET_DESC
23#define GET_SUBTARGETINFO_CTOR
24#include "NVPTXGenSubtargetInfo.inc"
25
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000026// Pin the vtable to this file.
27void NVPTXSubtarget::anchor() {}
28
Eric Christopher493f91b2014-06-27 04:33:14 +000029NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,
30 StringRef FS) {
31 // Provide the default CPU if we don't have one.
Eric Christopherd8132862014-06-27 02:05:19 +000032 if (CPU.empty() && FS.size())
Justin Holewinskiae556d32012-05-04 20:18:50 +000033 llvm_unreachable("we are not using FeatureStr");
Eric Christopherd8132862014-06-27 02:05:19 +000034 TargetName = CPU.empty() ? "sm_20" : CPU;
35
36 ParseSubtargetFeatures(TargetName, FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +000037
Justin Holewinski602fa5b2014-06-27 18:35:18 +000038 // Set default to PTX 3.2 (CUDA 5.5)
39 if (PTXVersion == 0) {
40 PTXVersion = 32;
41 }
Eric Christopher493f91b2014-06-27 04:33:14 +000042
43 return *this;
44}
45
46NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
Eric Christopher6aad8b12015-02-19 00:08:14 +000047 const std::string &FS,
48 const NVPTXTargetMachine &TM, bool is64Bit)
Eric Christopher493f91b2014-06-27 04:33:14 +000049 : NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0),
Eric Christopher6aad8b12015-02-19 00:08:14 +000050 SmVersion(20), TM(TM),
51 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
52 TSInfo(TM.getDataLayout()), FrameLowering(*this) {}
Eric Christopher493f91b2014-06-27 04:33:14 +000053
Eric Christopher6aad8b12015-02-19 00:08:14 +000054NVPTX::DrvInterface NVPTXSubtarget::getDrvInterface() const {
55 return TM.getDrvInterface();
Justin Holewinskiae556d32012-05-04 20:18:50 +000056}