mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Move NVPTX subtarget dependent variables from the target machine
to the subtarget. llvm-svn: 211860
This commit is contained in:
parent
19ebc28a85
commit
d9c871322b
@ -16,7 +16,6 @@
|
||||
#define NVPTXISELLOWERING_H
|
||||
|
||||
#include "NVPTX.h"
|
||||
#include "NVPTXSubtarget.h"
|
||||
#include "llvm/CodeGen/SelectionDAG.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
|
||||
@ -167,6 +166,8 @@ enum NodeType {
|
||||
};
|
||||
}
|
||||
|
||||
class NVPTXSubtarget;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// TargetLowering Implementation
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -25,19 +25,20 @@ using namespace llvm;
|
||||
// Pin the vtable to this file.
|
||||
void NVPTXSubtarget::anchor() {}
|
||||
|
||||
NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, bool is64Bit)
|
||||
: NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0),
|
||||
SmVersion(20) {
|
||||
static std::string computeDataLayout(bool is64Bit) {
|
||||
std::string Ret = "e";
|
||||
|
||||
Triple T(TT);
|
||||
if (!is64Bit)
|
||||
Ret += "-p:32:32";
|
||||
|
||||
if (T.getOS() == Triple::NVCL)
|
||||
drvInterface = NVPTX::NVCL;
|
||||
else
|
||||
drvInterface = NVPTX::CUDA;
|
||||
Ret += "-i64:64-v16:16-v32:32-n16:32:64";
|
||||
|
||||
// Provide the default CPU if we don't have one.
|
||||
return Ret;
|
||||
}
|
||||
|
||||
NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
StringRef FS) {
|
||||
// Provide the default CPU if we don't have one.
|
||||
if (CPU.empty() && FS.size())
|
||||
llvm_unreachable("we are not using FeatureStr");
|
||||
TargetName = CPU.empty() ? "sm_20" : CPU;
|
||||
@ -49,7 +50,24 @@ NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
|
||||
// So if we set ptx31 as the default, the ptx30 attribute would never match.
|
||||
// Instead, we use 0 as the default and manually set 31 if the default is
|
||||
// used.
|
||||
if (PTXVersion == 0) {
|
||||
if (PTXVersion == 0)
|
||||
PTXVersion = 31;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, const TargetMachine &TM,
|
||||
bool is64Bit)
|
||||
: NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0),
|
||||
SmVersion(20), DL(computeDataLayout(is64Bit)),
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
||||
TLInfo((NVPTXTargetMachine &)TM), TSInfo(&DL), FrameLowering(*this) {
|
||||
|
||||
Triple T(TT);
|
||||
|
||||
if (T.getOS() == Triple::NVCL)
|
||||
drvInterface = NVPTX::NVCL;
|
||||
else
|
||||
drvInterface = NVPTX::CUDA;
|
||||
}
|
||||
|
@ -15,6 +15,12 @@
|
||||
#define NVPTXSUBTARGET_H
|
||||
|
||||
#include "NVPTX.h"
|
||||
#include "NVPTXFrameLowering.h"
|
||||
#include "NVPTXISelLowering.h"
|
||||
#include "NVPTXInstrInfo.h"
|
||||
#include "NVPTXRegisterInfo.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/Target/TargetSelectionDAGInfo.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
#include <string>
|
||||
|
||||
@ -35,12 +41,30 @@ class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
|
||||
// SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
|
||||
unsigned int SmVersion;
|
||||
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
NVPTXInstrInfo InstrInfo;
|
||||
NVPTXTargetLowering TLInfo;
|
||||
TargetSelectionDAGInfo TSInfo;
|
||||
|
||||
// NVPTX does not have any call stack frame, but need a NVPTX specific
|
||||
// FrameLowering class because TargetFrameLowering is abstract.
|
||||
NVPTXFrameLowering FrameLowering;
|
||||
|
||||
public:
|
||||
/// This constructor initializes the data members to match that
|
||||
/// of the specified module.
|
||||
///
|
||||
NVPTXSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, bool is64Bit);
|
||||
const std::string &FS, const TargetMachine &TM, bool is64Bit);
|
||||
|
||||
const TargetFrameLowering *getFrameLowering() const { return &FrameLowering; }
|
||||
const NVPTXInstrInfo *getInstrInfo() const { return &InstrInfo; }
|
||||
const DataLayout *getDataLayout() const { return &DL; }
|
||||
const NVPTXRegisterInfo *getRegisterInfo() const {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
const NVPTXTargetLowering *getTargetLowering() const { return &TLInfo; }
|
||||
const TargetSelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; }
|
||||
|
||||
bool hasBrkPt() const { return SmVersion >= 11; }
|
||||
bool hasAtomRedG32() const { return SmVersion >= 11; }
|
||||
@ -76,6 +100,7 @@ public:
|
||||
|
||||
unsigned getPTXVersion() const { return PTXVersion; }
|
||||
|
||||
NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
|
||||
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
|
||||
};
|
||||
|
||||
|
@ -66,26 +66,13 @@ extern "C" void LLVMInitializeNVPTXTarget() {
|
||||
*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(const NVPTXSubtarget &ST) {
|
||||
std::string Ret = "e";
|
||||
|
||||
if (!ST.is64Bit())
|
||||
Ret += "-p:32:32";
|
||||
|
||||
Ret += "-i64:64-v16:16-v32:32-n16:32:64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, StringRef TT,
|
||||
StringRef CPU, StringRef FS,
|
||||
const TargetOptions &Options,
|
||||
Reloc::Model RM, CodeModel::Model CM,
|
||||
CodeGenOpt::Level OL, bool is64bit)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
Subtarget(TT, CPU, FS, is64bit), DL(computeDataLayout(Subtarget)),
|
||||
InstrInfo(Subtarget), TLInfo(*this), TSInfo(&DL),
|
||||
FrameLowering(Subtarget) {
|
||||
Subtarget(TT, CPU, FS, *this, is64bit) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
||||
|
@ -14,13 +14,8 @@
|
||||
#ifndef NVPTX_TARGETMACHINE_H
|
||||
#define NVPTX_TARGETMACHINE_H
|
||||
|
||||
#include "ManagedStringPool.h"
|
||||
#include "NVPTXFrameLowering.h"
|
||||
#include "NVPTXISelLowering.h"
|
||||
#include "NVPTXInstrInfo.h"
|
||||
#include "NVPTXRegisterInfo.h"
|
||||
#include "NVPTXSubtarget.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "ManagedStringPool.h"
|
||||
#include "llvm/Target/TargetFrameLowering.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetSelectionDAGInfo.h"
|
||||
@ -31,14 +26,6 @@ namespace llvm {
|
||||
///
|
||||
class NVPTXTargetMachine : public LLVMTargetMachine {
|
||||
NVPTXSubtarget Subtarget;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
NVPTXInstrInfo InstrInfo;
|
||||
NVPTXTargetLowering TLInfo;
|
||||
TargetSelectionDAGInfo TSInfo;
|
||||
|
||||
// NVPTX does not have any call stack frame, but need a NVPTX specific
|
||||
// FrameLowering class because TargetFrameLowering is abstract.
|
||||
NVPTXFrameLowering FrameLowering;
|
||||
|
||||
// Hold Strings that can be free'd all together with NVPTXTargetMachine
|
||||
ManagedStringPool ManagedStrPool;
|
||||
@ -49,22 +36,25 @@ public:
|
||||
CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
|
||||
|
||||
const TargetFrameLowering *getFrameLowering() const override {
|
||||
return &FrameLowering;
|
||||
return getSubtargetImpl()->getFrameLowering();
|
||||
}
|
||||
const NVPTXInstrInfo *getInstrInfo() const override {
|
||||
return getSubtargetImpl()->getInstrInfo();
|
||||
}
|
||||
const DataLayout *getDataLayout() const override {
|
||||
return getSubtargetImpl()->getDataLayout();
|
||||
}
|
||||
const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||
|
||||
const NVPTXRegisterInfo *getRegisterInfo() const override {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
return getSubtargetImpl()->getRegisterInfo();
|
||||
}
|
||||
|
||||
const NVPTXTargetLowering *getTargetLowering() const override {
|
||||
return &TLInfo;
|
||||
return getSubtargetImpl()->getTargetLowering();
|
||||
}
|
||||
|
||||
const TargetSelectionDAGInfo *getSelectionDAGInfo() const override {
|
||||
return &TSInfo;
|
||||
return getSubtargetImpl()->getSelectionDAGInfo();
|
||||
}
|
||||
|
||||
ManagedStringPool *getManagedStrPool() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user