ARM: Assign "actuals" at call site to the appropriate GPR/stack slot.

Actually assign arguments to r0-r3 at the call site. Previously
this was left unhandled. There was only logic for pulling
formal parameters out of r0-r3.

Refactor the GPR counter and move it into a class so that the
rounding up for i64 arguments is in one place for callsites
and for pulling out of parameters. We might be able to use a
similar pattern to count the FP/SIMD registers later.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1187513006.
diff --git a/src/IceInstARM32.cpp b/src/IceInstARM32.cpp
index 5131ecc..4ba27e9 100644
--- a/src/IceInstARM32.cpp
+++ b/src/IceInstARM32.cpp
@@ -198,6 +198,13 @@
     Vars[1] = ShiftVar;
 }
 
+InstARM32AdjustStack::InstARM32AdjustStack(Cfg *Func, Variable *SP,
+                                           SizeT Amount, Operand *SrcAmount)
+    : InstARM32(Func, InstARM32::Adjuststack, 2, SP), Amount(Amount) {
+  addSource(SP);
+  addSource(SrcAmount);
+}
+
 InstARM32Br::InstARM32Br(Cfg *Func, const CfgNode *TargetTrue,
                          const CfgNode *TargetFalse, CondARM32::Cond Pred)
     : InstARM32Pred(Func, InstARM32::Br, 0, nullptr, Pred),
@@ -631,6 +638,39 @@
   }
 }
 
+void InstARM32AdjustStack::emit(const Cfg *Func) const {
+  if (!ALLOW_DUMP)
+    return;
+  Ostream &Str = Func->getContext()->getStrEmit();
+  assert(getSrcSize() == 2);
+  Str << "\t"
+      << "sub"
+      << "\t";
+  getDest()->emit(Func);
+  Str << ", ";
+  getSrc(0)->emit(Func);
+  Str << ", ";
+  getSrc(1)->emit(Func);
+  Func->getTarget()->updateStackAdjustment(Amount);
+}
+
+void InstARM32AdjustStack::emitIAS(const Cfg *Func) const {
+  (void)Func;
+  llvm_unreachable("Not yet implemented");
+  Func->getTarget()->updateStackAdjustment(Amount);
+}
+
+void InstARM32AdjustStack::dump(const Cfg *Func) const {
+  if (!ALLOW_DUMP)
+    return;
+  Ostream &Str = Func->getContext()->getStrDump();
+  getDest()->dump(Func);
+  Str << " = sub.i32 ";
+  getSrc(0)->dump(Func);
+  Str << ", " << Amount << " ; ";
+  getSrc(1)->dump(Func);
+}
+
 void InstARM32Push::emit(const Cfg *Func) const {
   if (!ALLOW_DUMP)
     return;