Remove all use of getDrvInterface off of NVPTXSubtarget and clean

up code accordingly. Delete code that was checking for all cases
of an enum.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2015-02-19 00:08:23 +00:00
parent 9d2ea22e2b
commit c72978539d
4 changed files with 23 additions and 51 deletions

View File

@ -164,7 +164,7 @@ void NVPTXAsmPrinter::emitLineNumberAsDotLoc(const MachineInstr &MI) {
void NVPTXAsmPrinter::EmitInstruction(const MachineInstr *MI) {
SmallString<128> Str;
raw_svector_ostream OS(Str);
if (nvptxSubtarget->getDrvInterface() == NVPTX::CUDA)
if (static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() == NVPTX::CUDA)
emitLineNumberAsDotLoc(*MI);
MCInst Inst;
@ -908,9 +908,10 @@ void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O,
O << ".target ";
O << STI.getTargetName();
if (STI.getDrvInterface() == NVPTX::NVCL)
const NVPTXTargetMachine &TM = static_cast<const NVPTXTargetMachine &>(TM);
if (TM.getDrvInterface() == NVPTX::NVCL)
O << ", texmode_independent";
if (STI.getDrvInterface() == NVPTX::CUDA) {
else {
if (!STI.hasDouble())
O << ", map_f64_to_f32";
}
@ -921,7 +922,7 @@ void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O,
O << "\n";
O << ".address_size ";
if (static_cast<const NVPTXTargetMachine &>(TM).is64Bit())
if (TM.is64Bit())
O << "64";
else
O << "32";
@ -992,7 +993,7 @@ bool NVPTXAsmPrinter::doFinalization(Module &M) {
void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V,
raw_ostream &O) {
if (nvptxSubtarget->getDrvInterface() == NVPTX::CUDA) {
if (static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() == NVPTX::CUDA) {
if (V->hasExternalLinkage()) {
if (isa<GlobalVariable>(V)) {
const GlobalVariable *GVar = cast<GlobalVariable>(V);
@ -1413,39 +1414,11 @@ static unsigned int getOpenCLAlignment(const DataLayout *TD, Type *Ty) {
void NVPTXAsmPrinter::printParamName(Function::const_arg_iterator I,
int paramIndex, raw_ostream &O) {
if ((nvptxSubtarget->getDrvInterface() == NVPTX::NVCL) ||
(nvptxSubtarget->getDrvInterface() == NVPTX::CUDA))
O << *getSymbol(I->getParent()) << "_param_" << paramIndex;
else {
std::string argName = I->getName();
const char *p = argName.c_str();
while (*p) {
if (*p == '.')
O << "_";
else
O << *p;
p++;
}
}
O << *getSymbol(I->getParent()) << "_param_" << paramIndex;
}
void NVPTXAsmPrinter::printParamName(int paramIndex, raw_ostream &O) {
Function::const_arg_iterator I, E;
int i = 0;
if ((nvptxSubtarget->getDrvInterface() == NVPTX::NVCL) ||
(nvptxSubtarget->getDrvInterface() == NVPTX::CUDA)) {
O << *CurrentFnSym << "_param_" << paramIndex;
return;
}
for (I = F->arg_begin(), E = F->arg_end(); I != E; ++I, i++) {
if (i == paramIndex) {
printParamName(I, paramIndex, O);
return;
}
}
llvm_unreachable("paramIndex out of bound");
O << *CurrentFnSym << "_param_" << paramIndex;
}
void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
@ -1522,7 +1495,8 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
// Special handling for pointer arguments to kernel
O << "\t.param .u" << thePointerTy.getSizeInBits() << " ";
if (nvptxSubtarget->getDrvInterface() != NVPTX::CUDA) {
if (static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() !=
NVPTX::CUDA) {
Type *ETy = PTy->getElementType();
int addrSpace = PTy->getAddressSpace();
switch (addrSpace) {

View File

@ -16,6 +16,7 @@
#include "NVPTX.h"
#include "NVPTXMachineFunctionInfo.h"
#include "NVPTXSubtarget.h"
#include "NVPTXTargetMachine.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
@ -142,8 +143,9 @@ findIndexForHandle(MachineOperand &Op, MachineFunction &MF, unsigned &Idx) {
case NVPTX::LD_i64_avar: {
// The handle is a parameter value being loaded, replace with the
// parameter symbol
const NVPTXSubtarget &ST = MF.getTarget().getSubtarget<NVPTXSubtarget>();
if (ST.getDrvInterface() == NVPTX::CUDA) {
const NVPTXTargetMachine &TM =
static_cast<const NVPTXTargetMachine &>(MF.getTarget());
if (TM.getDrvInterface() == NVPTX::CUDA) {
// For CUDA, we preserve the param loads coming from function arguments
return false;
}

View File

@ -51,6 +51,12 @@ NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
TSInfo(TM.getDataLayout()), FrameLowering(*this) {}
NVPTX::DrvInterface NVPTXSubtarget::getDrvInterface() const {
return TM.getDrvInterface();
bool NVPTXSubtarget::hasImageHandles() const {
// Enable handles for Kepler+, where CUDA supports indirect surfaces and
// textures
if (TM.getDrvInterface() == NVPTX::CUDA)
return (SmVersion >= 30);
// Disabled, otherwise
return false;
}

View File

@ -94,20 +94,10 @@ public:
}
inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
inline bool hasROT64() const { return SmVersion >= 20; }
bool hasImageHandles() const {
// Enable handles for Kepler+, where CUDA supports indirect surfaces and
// textures
if (getDrvInterface() == NVPTX::CUDA)
return (SmVersion >= 30);
// Disabled, otherwise
return false;
}
bool hasImageHandles() const;
bool is64Bit() const { return Is64Bit; }
unsigned int getSmVersion() const { return SmVersion; }
NVPTX::DrvInterface getDrvInterface() const;
std::string getTargetName() const { return TargetName; }
unsigned getPTXVersion() const { return PTXVersion; }