Subzero: Align the stack at the point of function calls.

Be compatible with the x86-32 calling convention by ensuring that the
stack is aligned to 16 bytes at the point of the call
instruction. Also ensure that vector arguments passed on the stack are
16 byte aligned.

Also, make alloca instructions respect alignment.

BUG=none
R=jvoung@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/444443002
diff --git a/src/IceInstX8632.h b/src/IceInstX8632.h
index bc9ac53..a2fd7dc 100644
--- a/src/IceInstX8632.h
+++ b/src/IceInstX8632.h
@@ -137,6 +137,7 @@
     Add,
     Addps,
     Addss,
+    Adjuststack,
     And,
     Blendvps,
     Br,
@@ -204,6 +205,7 @@
     Shufps,
     Sqrtss,
     Store,
+    StoreP,
     StoreQ,
     Sub,
     Subps,
@@ -340,6 +342,26 @@
   InstX8632Label *Label; // Intra-block branch target
 };
 
+// AdjustStack instruction - subtracts esp by the given amount and
+// updates the stack offset during code emission.
+class InstX8632AdjustStack : public InstX8632 {
+public:
+  static InstX8632AdjustStack *create(Cfg *Func, SizeT Amount) {
+    return new (Func->allocate<InstX8632AdjustStack>())
+        InstX8632AdjustStack(Func, Amount);
+  }
+  virtual void emit(const Cfg *Func) const;
+  virtual void dump(const Cfg *Func) const;
+  static bool classof(const Inst *Inst) { return isClassof(Inst, Adjuststack); }
+
+private:
+  InstX8632AdjustStack(Cfg *Func, SizeT Amount);
+  InstX8632AdjustStack(const InstX8632AdjustStack &) LLVM_DELETED_FUNCTION;
+  InstX8632AdjustStack &operator=(const InstX8632AdjustStack &)
+      LLVM_DELETED_FUNCTION;
+  SizeT Amount;
+};
+
 // Call instruction.  Arguments should have already been pushed.
 class InstX8632Call : public InstX8632 {
 public:
@@ -960,6 +982,23 @@
   virtual ~InstX8632Movp() {}
 };
 
+class InstX8632StoreP : public InstX8632 {
+public:
+  static InstX8632StoreP *create(Cfg *Func, Operand *Value, OperandX8632 *Mem) {
+    return new (Func->allocate<InstX8632StoreP>())
+        InstX8632StoreP(Func, Value, Mem);
+  }
+  virtual void emit(const Cfg *Func) const;
+  virtual void dump(const Cfg *Func) const;
+  static bool classof(const Inst *Inst) { return isClassof(Inst, StoreP); }
+
+private:
+  InstX8632StoreP(Cfg *Func, Operand *Value, OperandX8632 *Mem);
+  InstX8632StoreP(const InstX8632StoreP &) LLVM_DELETED_FUNCTION;
+  InstX8632StoreP &operator=(const InstX8632StoreP &) LLVM_DELETED_FUNCTION;
+  virtual ~InstX8632StoreP() {}
+};
+
 // This is essentially a "movq" instruction with an OperandX8632Mem
 // operand instead of Variable as the destination.  It's important
 // for liveness that there is no Dest operand.