aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PIC16/PIC16AsmPrinter.cpp
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-04-02 17:42:00 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-04-02 17:42:00 +0000
commitb84d5a476a8e678dbdeef848b22ea22c24632e11 (patch)
treefd84b914b67bc3534e7402c1579ca077602e3f6d /lib/Target/PIC16/PIC16AsmPrinter.cpp
parentd0dfbe096dd71ca4d652784705584876f8b18250 (diff)
Params are not being generated as static globals now. The caller passes them onto the callee's stack directly and the callee loads the argvals from its own stack. Clang generated frameindexes validatd by recalculating the stack as if all frameindexes represent 1-byte slots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PIC16/PIC16AsmPrinter.cpp')
-rw-r--r--lib/Target/PIC16/PIC16AsmPrinter.cpp59
1 files changed, 28 insertions, 31 deletions
diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp
index 3696d5afeb..6a5c2e0371 100644
--- a/lib/Target/PIC16/PIC16AsmPrinter.cpp
+++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp
@@ -335,6 +335,7 @@ bool PIC16AsmPrinter::doFinalization(Module &M) {
void PIC16AsmPrinter::emitFunctionData(MachineFunction &MF) {
const Function *F = MF.getFunction();
std::string FuncName = Mang->getValueName(F);
+ MachineFrameInfo *MFI= MF.getFrameInfo();
Module *M = const_cast<Module *>(F->getParent());
const TargetData *TD = TM.getTargetData();
unsigned FrameSize = 0;
@@ -346,15 +347,30 @@ void PIC16AsmPrinter::emitFunctionData(MachineFunction &MF) {
SectionFlags::Writeable);
SwitchToSection(fDataSection);
- //Emit function return value.
- O << CurrentFnName << ".retval:\n";
+
+ // Emit function frame label
+ O << CurrentFnName << ".frame:\n";
+
const Type *RetType = F->getReturnType();
unsigned RetSize = 0;
if (RetType->getTypeID() != Type::VoidTyID)
RetSize = TD->getTypePaddedSize(RetType);
- // Emit function arguments.
- O << CurrentFnName << ".args:\n";
+ //Emit function return value space
+ if(RetSize > 0)
+ O << CurrentFnName << ".retval RES " << RetSize << "\n";
+ else
+ O << CurrentFnName << ".retval:\n";
+
+ // Emit variable to hold the space for function arguments
+ unsigned ArgSize = 0;
+ for (Function::const_arg_iterator argi = F->arg_begin(),
+ arge = F->arg_end(); argi != arge ; ++argi) {
+ const Type *Ty = argi->getType();
+ ArgSize += TD->getTypePaddedSize(Ty);
+ }
+ O << CurrentFnName << ".args RES " << ArgSize << "\n";
+
// Emit the function variables.
// In PIC16 all the function arguments and local variables are global.
@@ -382,34 +398,15 @@ void PIC16AsmPrinter::emitFunctionData(MachineFunction &MF) {
O << VarName << " RES " << Size << "\n";
}
- // Return value can not overlap with temp data, becasue a temp slot
- // may be read/written after a return value is calculated and saved
- // within the function.
- if (RetSize > FrameSize)
- O << CurrentFnName << ".dummy" << " RES " << (RetSize - FrameSize) << "\n";
-
- emitFunctionTempData(MF, FrameSize);
-}
-void PIC16AsmPrinter::emitFunctionTempData(MachineFunction &MF,
- unsigned &FrameSize) {
- // Emit temporary variables.
- MachineFrameInfo *FrameInfo = MF.getFrameInfo();
- if (FrameInfo->hasStackObjects()) {
- int indexBegin = FrameInfo->getObjectIndexBegin();
- int indexEnd = FrameInfo->getObjectIndexEnd();
-
- if (indexBegin < indexEnd) {
- FrameSize += indexEnd - indexBegin;
- O << CurrentFnName << ".tmp RES"<< " "
- <<indexEnd - indexBegin <<"\n";
- }
- /*
- while (indexBegin < indexEnd) {
- O << CurrentFnName << "_tmp_" << indexBegin << " " << "RES"<< " "
- << 1 << "\n" ;
- indexBegin++;
+ // Emit the variable to hold the space for temporary locations
+ // in function frame.
+ if (MFI->hasStackObjects()) {
+ int indexBegin = MFI->getObjectIndexBegin();
+ int indexEnd = MFI->getObjectIndexEnd();
+ if (indexBegin < indexEnd) {
+ int TempSize = indexEnd - indexBegin;
+ O << CurrentFnName << ".tmp RES " << TempSize <<"\n";
}
- */
}
}