[llvm] r229786 - Remove all use of getDrvInterface off of NVPTXSubtarget and clean
Eric Christopher
echristo at gmail.com
Wed Feb 18 16:08:23 PST 2015
Author: echristo
Date: Wed Feb 18 18:08:23 2015
New Revision: 229786
URL: http://llvm.org/viewvc/llvm-project?rev=229786&view=rev
Log:
Remove all use of getDrvInterface off of NVPTXSubtarget and clean
up code accordingly. Delete code that was checking for all cases
of an enum.
Modified:
llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.h
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp?rev=229786&r1=229785&r2=229786&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Wed Feb 18 18:08:23 2015
@@ -164,7 +164,7 @@ void NVPTXAsmPrinter::emitLineNumberAsDo
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
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
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(Mod
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(c
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::emitFunctionParamL
// 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) {
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp?rev=229786&r1=229785&r2=229786&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp Wed Feb 18 18:08:23 2015
@@ -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, M
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;
}
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.cpp?rev=229786&r1=229785&r2=229786&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.cpp Wed Feb 18 18:08:23 2015
@@ -51,6 +51,12 @@ NVPTXSubtarget::NVPTXSubtarget(const std
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;
}
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.h?rev=229786&r1=229785&r2=229786&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.h (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXSubtarget.h Wed Feb 18 18:08:23 2015
@@ -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; }
More information about the llvm-commits
mailing list