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

Unified Diff: src/IceTargetLoweringMIPS32.cpp

Issue 2101093003: Subzero: Fix Calling Convention for MIPS O32 abi (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 0da1d2813935c3f2876e724ca93894a6ad2b6443..5fd0901ffbd405b21db5da17fcc2fa7ee72ce9bd 100644
--- a/src/IceTargetLoweringMIPS32.cpp
+++ b/src/IceTargetLoweringMIPS32.cpp
@@ -559,6 +559,11 @@ inline void TargetMIPS32::CallingConv::discardNextGPRAndItsAliases(
Regs->pop_back();
}
+inline void TargetMIPS32::CallingConv::alignGPR(CfgVector<RegNumT> *Regs) {
+ if (Regs->back() == RegMIPS32::Reg_A1 || Regs->back() == RegMIPS32::Reg_A3)
+ discardNextGPRAndItsAliases(Regs);
+}
+
// GPR are not packed when passing parameters. Thus, a function foo(i32, i64,
// i32) will have the first argument in a0, the second in a2-a3, and the third
// on the stack. To model this behavior, whenever we pop a register from Regs,
@@ -603,10 +608,18 @@ bool TargetMIPS32::CallingConv::argInVFP(Type Ty, RegNumT *Reg) {
// in reg_a3 and a0, a1 are not used.
Source = &GPRArgs;
// Discard one GPR reg for f32(4 bytes), two for f64(4 + 4 bytes)
- discardNextGPRAndItsAliases(Source);
- if (Ty == IceType_f64)
+ if (Ty == IceType_f64) {
+ // In MIPS o32 abi, when we use GPR argument pairs to store F64 values, pair
+ // must be aligned at even register. Similarly when we discard GPR registers
+ // when some arguments from starting 16 bytes goes in FPR, we must take care
+ // of alignment. For example if fun args are (f32, f64, f32), for first f32
+ // we discard a0, now for f64 argument, which will go in F14F15, we must
+ // first align GPR vector to even register by discarding a1, then discard
+ // two GPRs a2 and a3. Now last f32 argument will go on stack.
+ alignGPR(Source);
discardNextGPRAndItsAliases(Source);
-
+ }
+ discardNextGPRAndItsAliases(Source);
return true;
}
« 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