diff options
author | Justin Holewinski <justin.holewinski@gmail.com> | 2011-06-23 18:10:05 +0000 |
---|---|---|
committer | Justin Holewinski <justin.holewinski@gmail.com> | 2011-06-23 18:10:05 +0000 |
commit | a5ccb4e9745bd77d877f4735683a9ae31668b61b (patch) | |
tree | fcafeed2efebc84af6a791490ed374c713eb2a2a /lib/Target/PTX/PTXAsmPrinter.cpp | |
parent | 67a918486132309f224d152188747ca5e7f224ca (diff) | |
download | external_llvm-a5ccb4e9745bd77d877f4735683a9ae31668b61b.zip external_llvm-a5ccb4e9745bd77d877f4735683a9ae31668b61b.tar.gz external_llvm-a5ccb4e9745bd77d877f4735683a9ae31668b61b.tar.bz2 |
PTX: Prevent DCE from eliminating st.param calls, and unify the handling of
st.param and ld.param
FIXME: Test cases still need to be updated
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PTX/PTXAsmPrinter.cpp')
-rw-r--r-- | lib/Target/PTX/PTXAsmPrinter.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/Target/PTX/PTXAsmPrinter.cpp b/lib/Target/PTX/PTXAsmPrinter.cpp index 0b055c2..87b3903 100644 --- a/lib/Target/PTX/PTXAsmPrinter.cpp +++ b/lib/Target/PTX/PTXAsmPrinter.cpp @@ -63,6 +63,8 @@ public: const char *Modifier = 0); void printParamOperand(const MachineInstr *MI, int opNum, raw_ostream &OS, const char *Modifier = 0); + void printReturnOperand(const MachineInstr *MI, int opNum, raw_ostream &OS, + const char *Modifier = 0); void printPredicateOperand(const MachineInstr *MI, raw_ostream &O); // autogen'd. @@ -76,6 +78,7 @@ private: } // namespace static const char PARAM_PREFIX[] = "__param_"; +static const char RETURN_PREFIX[] = "__ret_"; static const char *getRegisterTypeName(unsigned RegNo) { #define TEST_REGCLS(cls, clsstr) \ @@ -298,6 +301,11 @@ void PTXAsmPrinter::printParamOperand(const MachineInstr *MI, int opNum, OS << PARAM_PREFIX << (int) MI->getOperand(opNum).getImm() + 1; } +void PTXAsmPrinter::printReturnOperand(const MachineInstr *MI, int opNum, + raw_ostream &OS, const char *Modifier) { + OS << RETURN_PREFIX << (int) MI->getOperand(opNum).getImm() + 1; +} + void PTXAsmPrinter::EmitVariableDeclaration(const GlobalVariable *gv) { // Check to see if this is a special global used by LLVM, if so, emit it. if (EmitSpecialLLVMGlobal(gv)) @@ -421,6 +429,8 @@ void PTXAsmPrinter::EmitFunctionDeclaration() { std::string decl = isKernel ? ".entry" : ".func"; + unsigned cnt = 0; + if (!isKernel) { decl += " ("; @@ -430,10 +440,18 @@ void PTXAsmPrinter::EmitFunctionDeclaration() { if (i != b) { decl += ", "; } - decl += ".reg ."; - decl += getRegisterTypeName(*i); - decl += " "; - decl += getRegisterName(*i); + if (ST.getShaderModel() >= PTXSubtarget::PTX_SM_2_0) { + decl += ".param .b"; + decl += utostr(*i); + decl += " "; + decl += RETURN_PREFIX; + decl += utostr(++cnt); + } else { + decl += ".reg ."; + decl += getRegisterTypeName(*i); + decl += " "; + decl += getRegisterName(*i); + } } decl += ")"; } @@ -444,7 +462,7 @@ void PTXAsmPrinter::EmitFunctionDeclaration() { decl += " ("; - unsigned cnt = 0; + cnt = 0; // Print parameters for (PTXMachineFunctionInfo::reg_iterator |