Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: src/IceTargetLoweringMIPS32.cpp

Issue 2096563004: [Subzero][MIPS32] Implements addEpilog for MIPS32 (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTargetLoweringMIPS32.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringMIPS32.cpp
diff --git a/src/IceTargetLoweringMIPS32.cpp b/src/IceTargetLoweringMIPS32.cpp
index 430820eff63985477dc81ebe22995bec2e2c45fe..0da1d2813935c3f2876e724ca93894a6ad2b6443 100644
--- a/src/IceTargetLoweringMIPS32.cpp
+++ b/src/IceTargetLoweringMIPS32.cpp
@@ -790,7 +790,6 @@ void TargetMIPS32::addProlog(CfgNode *Node) {
}
uint32_t NumCallee = 0;
- size_t PreservedRegsSizeBytes = 0;
// RegClasses is a tuple of
//
@@ -835,8 +834,8 @@ void TargetMIPS32::addProlog(CfgNode *Node) {
GlobalsSize + LocalsSlotsPaddingBytes;
// Adds the out args space to the stack, and align SP if necessary.
- uint32_t TotalStackSizeBytes = PreservedRegsSizeBytes + SpillAreaSizeBytes +
- FixedAllocaSizeBytes + MaxOutArgsSizeBytes;
+ TotalStackSizeBytes = PreservedRegsSizeBytes + SpillAreaSizeBytes +
+ FixedAllocaSizeBytes + MaxOutArgsSizeBytes;
// Generate "addiu sp, sp, -TotalStackSizeBytes"
if (TotalStackSizeBytes) {
@@ -926,9 +925,53 @@ void TargetMIPS32::addProlog(CfgNode *Node) {
}
void TargetMIPS32::addEpilog(CfgNode *Node) {
- (void)Node;
+ InstList &Insts = Node->getInsts();
+ InstList::reverse_iterator RI, E;
+ for (RI = Insts.rbegin(), E = Insts.rend(); RI != E; ++RI) {
+ if (llvm::isa<InstMIPS32Ret>(*RI))
+ break;
+ }
+ if (RI == E)
+ return;
+
+ // Convert the reverse_iterator position into its corresponding (forward)
+ // iterator position.
+ InstList::iterator InsertPoint = RI.base();
+ --InsertPoint;
+ Context.init(Node);
+ Context.setInsertPoint(InsertPoint);
+
+ Variable *SP = getPhysicalRegister(RegMIPS32::Reg_SP);
+ if (UsesFramePointer) {
+ Variable *FP = getPhysicalRegister(RegMIPS32::Reg_FP);
+ // For late-stage liveness analysis (e.g. asm-verbose mode), adding a fake
+ // use of SP before the assignment of SP=FP keeps previous SP adjustments
+ // from being dead-code eliminated.
+ Context.insert<InstFakeUse>(SP);
+ _mov(SP, FP);
+ }
+
+ VarList::reverse_iterator RIter, END;
+
+ if (!PreservedGPRs.empty()) {
+ uint32_t StackOffset = TotalStackSizeBytes - PreservedRegsSizeBytes;
+ for (RIter = PreservedGPRs.rbegin(), END = PreservedGPRs.rend();
+ RIter != END; ++RIter) {
+ Variable *PhysicalRegister = getPhysicalRegister((*RIter)->getRegNum());
+ Variable *SP = getPhysicalRegister(RegMIPS32::Reg_SP);
+ OperandMIPS32Mem *MemoryLocation = OperandMIPS32Mem::create(
+ Func, IceType_i32, SP,
+ llvm::cast<ConstantInteger32>(Ctx->getConstantInt32(StackOffset)));
+ _lw(PhysicalRegister, MemoryLocation);
+ StackOffset += typeWidthInBytesOnStack(PhysicalRegister->getType());
+ }
+ }
+
+ if (TotalStackSizeBytes) {
+ _addiu(SP, SP, TotalStackSizeBytes);
+ }
+
return;
- UnimplementedError(getFlags());
}
Operand *TargetMIPS32::loOperand(Operand *Operand) {
« no previous file with comments | « src/IceTargetLoweringMIPS32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698