PTX: Start fixing function calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140378 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/PTX/PTXAsmPrinter.cpp b/lib/Target/PTX/PTXAsmPrinter.cpp
index 06cab0b..77164ca 100644
--- a/lib/Target/PTX/PTXAsmPrinter.cpp
+++ b/lib/Target/PTX/PTXAsmPrinter.cpp
@@ -222,6 +222,7 @@
OutStreamer.EmitRawText(Twine("{"));
const PTXMachineFunctionInfo *MFI = MF->getInfo<PTXMachineFunctionInfo>();
+ const PTXParamManager &PM = MFI->getParamManager();
// Print register definitions
std::string regDefs;
@@ -275,6 +276,16 @@
regDefs += ">;\n";
}
+ // Local params
+ for (PTXParamManager::param_iterator i = PM.local_begin(), e = PM.local_end();
+ i != e; ++i) {
+ regDefs += "\t.param .b";
+ regDefs += utostr(PM.getParamSize(*i));
+ regDefs += " ";
+ regDefs += PM.getParamName(*i);
+ regDefs += ";\n";
+ }
+
OutStreamer.EmitRawText(Twine(regDefs));
@@ -677,7 +688,7 @@
for (unsigned i = 3; i < MI->getNumOperands(); ++i) {
//const MachineOperand& MO = MI->getOperand(i);
- printReturnOperand(MI, i, O);
+ printParamOperand(MI, i, O);
if (i < MI->getNumOperands()-1) {
O << ", ";
}
diff --git a/lib/Target/PTX/PTXISelLowering.cpp b/lib/Target/PTX/PTXISelLowering.cpp
index 7996728..3fdfcdf 100644
--- a/lib/Target/PTX/PTXISelLowering.cpp
+++ b/lib/Target/PTX/PTXISelLowering.cpp
@@ -435,6 +435,7 @@
MachineFunction& MF = DAG.getMachineFunction();
PTXMachineFunctionInfo *MFI = MF.getInfo<PTXMachineFunctionInfo>();
+ PTXParamManager &PM = MFI->getParamManager();
assert(getTargetMachine().getSubtarget<PTXSubtarget>().callsAreHandled() &&
"Calls are not handled for the target device");
@@ -454,7 +455,8 @@
for (unsigned i = 0; i != OutVals.size(); ++i) {
unsigned Size = OutVals[i].getValueType().getSizeInBits();
- SDValue Index = DAG.getTargetConstant(MFI->getNextParam(Size), MVT::i32);
+ unsigned Param = PM.addLocalParam(Size);
+ SDValue Index = DAG.getTargetConstant(Param, MVT::i32);
Chain = DAG.getNode(PTXISD::STORE_PARAM, dl, MVT::Other, Chain,
Index, OutVals[i]);
ops[i+2] = Index;