PTX: Print .ptr kernel attributes if PTX version >= 2.2

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141508 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Holewinski 2011-10-09 15:42:02 +00:00
parent da394041c4
commit 68226a4d46
4 changed files with 49 additions and 1 deletions

View File

@ -20,7 +20,9 @@
#include "PTXParamManager.h"
#include "PTXRegisterInfo.h"
#include "PTXTargetMachine.h"
#include "llvm/Argument.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Module.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
@ -445,9 +447,11 @@ void PTXAsmPrinter::EmitFunctionEntryLabel() {
decl += " (";
const Function *F = MF->getFunction();
// Print parameters
if (isKernel || ST.useParamSpaceForDeviceArgs()) {
for (PTXParamManager::param_iterator i = PM.arg_begin(), e = PM.arg_end(),
/*for (PTXParamManager::param_iterator i = PM.arg_begin(), e = PM.arg_end(),
b = i; i != e; ++i) {
if (i != b) {
decl += ", ";
@ -457,6 +461,38 @@ void PTXAsmPrinter::EmitFunctionEntryLabel() {
decl += utostr(PM.getParamSize(*i));
decl += " ";
decl += PM.getParamName(*i);
}*/
int Counter = 1;
for (Function::const_arg_iterator i = F->arg_begin(), e = F->arg_end(),
b = i; i != e; ++i) {
if (i != b)
decl += ", ";
const Type *ArgType = (*i).getType();
decl += ".param .b";
if (ArgType->isPointerTy()) {
if (ST.is64Bit())
decl += "64";
else
decl += "32";
} else {
decl += utostr(ArgType->getPrimitiveSizeInBits());
}
if (ArgType->isPointerTy() && ST.emitPtrAttribute()) {
const PointerType *PtrType = dyn_cast<const PointerType>(ArgType);
decl += " .ptr";
switch (PtrType->getAddressSpace()) {
default:
llvm_unreachable("Unknown address space in argument");
case PTXStateSpace::Global:
decl += " .global";
break;
case PTXStateSpace::Shared:
decl += " .shared";
break;
}
}
decl += " __param_";
decl += utostr(Counter++);
}
} else {
for (PTXMachineFunctionInfo::reg_iterator

View File

@ -414,3 +414,9 @@ PTXTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
return Chain;
}
unsigned PTXTargetLowering::getNumRegisters(LLVMContext &Context, EVT VT) {
// All arguments consist of one "register," regardless of the type.
return 1;
}

View File

@ -75,6 +75,8 @@ class PTXTargetLowering : public TargetLowering {
virtual EVT getSetCCResultType(EVT VT) const;
virtual unsigned getNumRegisters(LLVMContext &Context, EVT VT);
private:
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
}; // class PTXTargetLowering

View File

@ -119,6 +119,10 @@ class StringRef;
(PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE);
}
bool emitPtrAttribute() const {
return PTXVersion >= PTX_VERSION_2_2;
}
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
}; // class PTXSubtarget
} // namespace llvm