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

Unified Diff: src/IceTargetLoweringMIPS32.cpp

Issue 2425673002: [Subzero][MIPS32] Account for variable alloca alignment bytes in addProlog (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addressed review comments Created 4 years, 2 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') | tests_lit/llvm2ice_tests/alloc.ll » ('j') | 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 b7d36a61809128836e91b6d23d133e3f54c25708..27d7f318a4a121ada2d0d61f4864aa19997b1105 100644
--- a/src/IceTargetLoweringMIPS32.cpp
+++ b/src/IceTargetLoweringMIPS32.cpp
@@ -1378,11 +1378,9 @@ void TargetMIPS32::addProlog(CfgNode *Node) {
if (!NeedsStackAlignment) {
SpillAreaSizeBytes += MaxOutArgsSizeBytes * (VariableAllocaUsed ? 0 : 1);
} else {
- uint32_t StackOffset = PreservedRegsSizeBytes;
- uint32_t StackSize = applyStackAlignment(StackOffset + SpillAreaSizeBytes);
- if (!VariableAllocaUsed)
- StackSize = applyStackAlignment(StackSize + MaxOutArgsSizeBytes);
- SpillAreaSizeBytes = StackSize - StackOffset;
+ SpillAreaSizeBytes = applyStackAlignment(
+ SpillAreaSizeBytes +
+ (VariableAllocaUsed ? VariableAllocaAlignBytes : MaxOutArgsSizeBytes));
}
// Combine fixed alloca with SpillAreaSize.
@@ -1790,6 +1788,24 @@ TargetMIPS32::PostLoweringLegalizer::legalizeMemOperand(OperandMIPS32Mem *Mem) {
llvm::cast<ConstantInteger32>(Target->Ctx->getConstantInt32(Offset)));
}
+Variable *TargetMIPS32::PostLoweringLegalizer::legalizeImmediate(int32_t Imm) {
+ Variable *Reg = nullptr;
+ if (!((std::numeric_limits<int16_t>::min() <= Imm) &&
+ (Imm <= std::numeric_limits<int16_t>::max()))) {
+ const uint32_t UpperBits = (Imm >> 16) & 0xFFFF;
+ const uint32_t LowerBits = Imm & 0xFFFF;
+ Variable *TReg = Target->makeReg(IceType_i32, Target->getReservedTmpReg());
+ Reg = Target->makeReg(IceType_i32, Target->getReservedTmpReg());
+ if (LowerBits) {
+ Target->_lui(TReg, Target->Ctx->getConstantInt32(UpperBits));
+ Target->_ori(Reg, TReg, LowerBits);
+ } else {
+ Target->_lui(Reg, Target->Ctx->getConstantInt32(UpperBits));
+ }
+ }
+ return Reg;
+}
+
void TargetMIPS32::postLowerLegalization() {
Func->dump("Before postLowerLegalization");
assert(hasComputedFrame());
@@ -1852,6 +1868,14 @@ void TargetMIPS32::postLowerLegalization() {
}
continue;
}
+ if (auto *AddiuInstr = llvm::dyn_cast<InstMIPS32Addiu>(CurInstr)) {
+ if (auto *LegalImm = Legalizer.legalizeImmediate(
+ static_cast<int32_t>(AddiuInstr->getImmediateValue()))) {
+ _addu(Dst, Src0V, LegalImm);
+ CurInstr->setDeleted();
+ }
+ continue;
+ }
}
}
}
@@ -2043,6 +2067,7 @@ void TargetMIPS32::lowerAlloca(const InstAlloca *Instr) {
// Non-constant sizes need to be adjusted to the next highest multiple of
// the required alignment at runtime.
VariableAllocaUsed = true;
+ VariableAllocaAlignBytes = AlignmentParam;
Variable *AlignAmount;
auto *TotalSizeR = legalizeToReg(TotalSize, Legal_Reg);
auto *T1 = I32Reg();
« no previous file with comments | « src/IceTargetLoweringMIPS32.h ('k') | tests_lit/llvm2ice_tests/alloc.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698