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

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: formatted source code 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
Index: src/IceTargetLoweringMIPS32.cpp
diff --git a/src/IceTargetLoweringMIPS32.cpp b/src/IceTargetLoweringMIPS32.cpp
index b7d36a61809128836e91b6d23d133e3f54c25708..882bdb8eec38384191afe574c26fc2544aff586f 100644
--- a/src/IceTargetLoweringMIPS32.cpp
+++ b/src/IceTargetLoweringMIPS32.cpp
@@ -1378,11 +1378,12 @@ 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)
Jim Stichnoth 2016/10/17 14:20:46 Maybe this could be simplified/refactored slightly
sagar.thakur 2016/10/18 07:02:21 Done.
- StackSize = applyStackAlignment(StackSize + MaxOutArgsSizeBytes);
- SpillAreaSizeBytes = StackSize - StackOffset;
+ SpillAreaSizeBytes =
+ applyStackAlignment(SpillAreaSizeBytes + MaxOutArgsSizeBytes);
+ else
+ SpillAreaSizeBytes =
+ applyStackAlignment(SpillAreaSizeBytes + VariableAllocaAlignBytes);
}
// Combine fixed alloca with SpillAreaSize.
@@ -1790,6 +1791,25 @@ TargetMIPS32::PostLoweringLegalizer::legalizeMemOperand(OperandMIPS32Mem *Mem) {
llvm::cast<ConstantInteger32>(Target->Ctx->getConstantInt32(Offset)));
}
+Variable *TargetMIPS32::PostLoweringLegalizer::legalizeImmidiate(int32_t Imm) {
Jim Stichnoth 2016/10/17 14:20:46 legalizeImmediate
sagar.thakur 2016/10/18 07:02:21 Done.
+ if ((std::numeric_limits<int16_t>::min() <= Imm) &&
+ (Imm <= std::numeric_limits<int16_t>::max())) {
+ return nullptr;
+ } else {
Jim Stichnoth 2016/10/17 14:20:45 http://llvm.org/docs/CodingStandards.html#don-t-us
sagar.thakur 2016/10/18 07:02:21 Done.
+ uint32_t UpperBits = (Imm >> 16) & 0xFFFF;
Jim Stichnoth 2016/10/17 14:20:46 const ?
sagar.thakur 2016/10/18 07:02:21 Done.
+ uint32_t LowerBits = Imm & 0xFFFF;
+ Variable *TReg = Target->makeReg(IceType_i32, Target->getReservedTmpReg());
+ Variable *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 +1872,14 @@ void TargetMIPS32::postLowerLegalization() {
}
continue;
}
+ if (auto *AddiuInstr = llvm::dyn_cast<InstMIPS32Addiu>(CurInstr)) {
+ if (auto *LegalImm = Legalizer.legalizeImmidiate(
+ int32_t(AddiuInstr->getImmidiateValue()))) {
Jim Stichnoth 2016/10/17 14:20:46 Use reinterpret_cast<> instead of int32_t() ?
sagar.thakur 2016/10/18 07:02:21 Done. Used static cast because reinterpret cast do
+ _addu(Dst, Src0V, LegalImm);
+ CurInstr->setDeleted();
+ }
+ continue;
+ }
}
}
}
@@ -2043,6 +2071,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();

Powered by Google App Engine
This is Rietveld 408576698