emitIAS for push -- simplify push since it's not used for args passing anymore

Since push isn't used for args passing anymore, the cases of handling
push for vectors and floats/doubles isn't needed anymore. Passing
vectors requires a bit more care of alignment, so that was changed.

I can imagine push needing to handle addresses later (at least on
x86-64 to push the lower 32-bits of return address), but for now,
this means only handling GPRs. The XMM registers are not callee saved.

BUG=none
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/633553003
diff --git a/src/IceInstX8632.cpp b/src/IceInstX8632.cpp
index 7150fa9..e2d39c3 100644
--- a/src/IceInstX8632.cpp
+++ b/src/IceInstX8632.cpp
@@ -305,10 +305,8 @@
 InstX8632Pop::InstX8632Pop(Cfg *Func, Variable *Dest)
     : InstX8632(Func, InstX8632::Pop, 0, Dest) {}
 
-InstX8632Push::InstX8632Push(Cfg *Func, Operand *Source,
-                             bool SuppressStackAdjustment)
-    : InstX8632(Func, InstX8632::Push, 1, NULL),
-      SuppressStackAdjustment(SuppressStackAdjustment) {
+InstX8632Push::InstX8632Push(Cfg *Func, Variable *Source)
+    : InstX8632(Func, InstX8632::Push, 1, NULL) {
   addSource(Source);
 }
 
@@ -2074,34 +2072,24 @@
 void InstX8632Push::emit(const Cfg *Func) const {
   Ostream &Str = Func->getContext()->getStrEmit();
   assert(getSrcSize() == 1);
-  Type Ty = getSrc(0)->getType();
-  Variable *Var = llvm::dyn_cast<Variable>(getSrc(0));
-  if ((isVectorType(Ty) || isScalarFloatingType(Ty)) && Var && Var->hasReg()) {
-    // The xmm registers can't be directly pushed, so we fake it by
-    // decrementing esp and then storing to [esp].
-    Str << "\tsub\tesp, " << typeWidthInBytes(Ty) << "\n";
-    if (!SuppressStackAdjustment)
-      Func->getTarget()->updateStackAdjustment(typeWidthInBytes(Ty));
-    if (isVectorType(Ty)) {
-      Str << "\tmovups\txmmword ptr [esp], ";
-    } else {
-      Str << "\tmov" << TypeX8632Attributes[Ty].SdSsString << "\t"
-          << TypeX8632Attributes[Ty].WidthString << " [esp], ";
-    }
-    getSrc(0)->emit(Func);
-    Str << "\n";
-  } else if (Ty == IceType_f64 && (!Var || !Var->hasReg())) {
-    // A double on the stack has to be pushed as two halves.  Push the
-    // upper half followed by the lower half for little-endian.  TODO:
-    // implement.
-    llvm_unreachable("Missing support for pushing doubles from memory");
-  } else {
-    Str << "\tpush\t";
-    getSrc(0)->emit(Func);
-    Str << "\n";
-    if (!SuppressStackAdjustment)
-      Func->getTarget()->updateStackAdjustment(4);
-  }
+  // Push is currently only used for saving GPRs.
+  Variable *Var = llvm::cast<Variable>(getSrc(0));
+  assert(Var->hasReg());
+  Str << "\tpush\t";
+  Var->emit(Func);
+  Str << "\n";
+}
+
+void InstX8632Push::emitIAS(const Cfg *Func) const {
+  Ostream &Str = Func->getContext()->getStrEmit();
+  assert(getSrcSize() == 1);
+  // Push is currently only used for saving GPRs.
+  Variable *Var = llvm::cast<Variable>(getSrc(0));
+  assert(Var->hasReg());
+  x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
+  intptr_t StartPosition = Asm->GetPosition();
+  Asm->pushl(RegX8632::getEncodedGPR(Var->getRegNum()));
+  emitIASBytes(Str, Asm, StartPosition);
 }
 
 void InstX8632Push::dump(const Cfg *Func) const {
diff --git a/src/IceInstX8632.h b/src/IceInstX8632.h
index 5449c78..eb133c2 100644
--- a/src/IceInstX8632.h
+++ b/src/IceInstX8632.h
@@ -1395,20 +1395,19 @@
 
 class InstX8632Push : public InstX8632 {
 public:
-  static InstX8632Push *create(Cfg *Func, Operand *Source,
-                               bool SuppressStackAdjustment) {
+  static InstX8632Push *create(Cfg *Func, Variable *Source) {
     return new (Func->allocate<InstX8632Push>())
-        InstX8632Push(Func, Source, SuppressStackAdjustment);
+        InstX8632Push(Func, Source);
   }
   void emit(const Cfg *Func) const override;
+  void emitIAS(const Cfg *Func) const override;
   void dump(const Cfg *Func) const override;
   static bool classof(const Inst *Inst) { return isClassof(Inst, Push); }
 
 private:
-  InstX8632Push(Cfg *Func, Operand *Source, bool SuppressStackAdjustment);
+  InstX8632Push(Cfg *Func, Variable *Source);
   InstX8632Push(const InstX8632Push &) = delete;
   InstX8632Push &operator=(const InstX8632Push &) = delete;
-  bool SuppressStackAdjustment;
   ~InstX8632Push() override {}
 };
 
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index e837710..6829eee 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -748,8 +748,7 @@
     if (CalleeSaves[i] && RegsUsed[i]) {
       ++NumCallee;
       PreservedRegsSizeBytes += 4;
-      const bool SuppressStackAdjustment = true;
-      _push(getPhysicalRegister(i), SuppressStackAdjustment);
+      _push(getPhysicalRegister(i));
     }
   }
   Ctx->statsUpdateRegistersSaved(NumCallee);
@@ -761,8 +760,7 @@
     PreservedRegsSizeBytes += 4;
     Variable *ebp = getPhysicalRegister(RegX8632::Reg_ebp);
     Variable *esp = getPhysicalRegister(RegX8632::Reg_esp);
-    const bool SuppressStackAdjustment = true;
-    _push(ebp, SuppressStackAdjustment);
+    _push(ebp);
     _mov(ebp, esp);
   }
 
diff --git a/src/IceTargetLoweringX8632.h b/src/IceTargetLoweringX8632.h
index da79c85..271d4a2 100644
--- a/src/IceTargetLoweringX8632.h
+++ b/src/IceTargetLoweringX8632.h
@@ -383,8 +383,8 @@
   void _psub(Variable *Dest, Operand *Src0) {
     Context.insert(InstX8632Psub::create(Func, Dest, Src0));
   }
-  void _push(Operand *Src0, bool SuppressStackAdjustment = false) {
-    Context.insert(InstX8632Push::create(Func, Src0, SuppressStackAdjustment));
+  void _push(Variable *Src0) {
+    Context.insert(InstX8632Push::create(Func, Src0));
   }
   void _pxor(Variable *Dest, Operand *Src0) {
     Context.insert(InstX8632Pxor::create(Func, Dest, Src0));
diff --git a/src/assembler_ia32.cpp b/src/assembler_ia32.cpp
index 8a2b449..6bcbb9a 100644
--- a/src/assembler_ia32.cpp
+++ b/src/assembler_ia32.cpp
@@ -99,18 +99,6 @@
   EmitUint8(0x50 + reg);
 }
 
-void AssemblerX86::pushl(const Address &address) {
-  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
-  EmitUint8(0xFF);
-  EmitOperand(6, address);
-}
-
-void AssemblerX86::pushl(const Immediate &imm) {
-  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
-  EmitUint8(0x68);
-  EmitImmediate(BrokenType, imm);
-}
-
 void AssemblerX86::popl(GPRRegister reg) {
   AssemblerBuffer::EnsureCapacity ensured(&buffer_);
   EmitUint8(0x58 + reg);
diff --git a/src/assembler_ia32.h b/src/assembler_ia32.h
index fe03134..0080f33 100644
--- a/src/assembler_ia32.h
+++ b/src/assembler_ia32.h
@@ -408,8 +408,6 @@
   static const intptr_t kCallExternalLabelSize = 5;
 
   void pushl(GPRRegister reg);
-  void pushl(const Address &address);
-  void pushl(const Immediate &imm);
 
   void popl(GPRRegister reg);
   void popl(const Address &address);