| Index: src/IceInstX86BaseImpl.h
|
| diff --git a/src/IceInstX86BaseImpl.h b/src/IceInstX86BaseImpl.h
|
| index 84ff8dc89263156b4d273c42fec0c0eec8b1f8ea..4be8c6bf4151c2b843ed04fbbd9dcd77414730f1 100644
|
| --- a/src/IceInstX86BaseImpl.h
|
| +++ b/src/IceInstX86BaseImpl.h
|
| @@ -436,7 +436,8 @@ template <class Machine> void InstX86Br<Machine>::emit(const Cfg *Func) const {
|
| } else {
|
| Str << "\t" << getTargetTrue()->getAsmName();
|
| if (getTargetFalse()) {
|
| - Str << "\n\tjmp\t" << getTargetFalse()->getAsmName();
|
| + Str << "\n\t"
|
| + "jmp\t" << getTargetFalse()->getAsmName();
|
| }
|
| }
|
| }
|
| @@ -503,7 +504,8 @@ template <class Machine> void InstX86Jmp<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 1);
|
| - Str << "\tjmp\t*";
|
| + Str << "\t"
|
| + "jmp\t*";
|
| getJmpTarget()->emit(Func);
|
| }
|
|
|
| @@ -560,7 +562,8 @@ void InstX86Call<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 1);
|
| - Str << "\tcall\t";
|
| + Str << "\t"
|
| + "call\t";
|
| Operand *CallTarget = getCallTarget();
|
| auto *Target = InstX86Base<Machine>::getTarget(Func);
|
| if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(CallTarget)) {
|
| @@ -997,7 +1000,8 @@ void InstX86Sqrtss<Machine>::emit(const Cfg *Func) const {
|
| assert(this->getSrcSize() == 1);
|
| Type Ty = this->getSrc(0)->getType();
|
| assert(isScalarFloatingType(Ty));
|
| - Str << "\tsqrt" << InstX86Base<Machine>::Traits::TypeAttributes[Ty].SdSsString
|
| + Str << "\t"
|
| + "sqrt" << InstX86Base<Machine>::Traits::TypeAttributes[Ty].SdSsString
|
| << "\t";
|
| this->getSrc(0)->emit(Func);
|
| Str << ", ";
|
| @@ -1248,10 +1252,12 @@ void InstX86Imul<Machine>::emit(const Cfg *Func) const {
|
| (void)Src0Var;
|
| assert(Src0Var->getRegNum() ==
|
| InstX86Base<Machine>::Traits::RegisterSet::Reg_al);
|
| - Str << "\timulb\t";
|
| + Str << "\t"
|
| + "imulb\t";
|
| this->getSrc(1)->emit(Func);
|
| } else if (llvm::isa<Constant>(this->getSrc(1))) {
|
| - Str << "\timul" << this->getWidthString(Dest->getType()) << "\t";
|
| + Str << "\t"
|
| + "imul" << this->getWidthString(Dest->getType()) << "\t";
|
| this->getSrc(1)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(0)->emit(Func);
|
| @@ -1301,7 +1307,8 @@ void InstX86ImulImm<Machine>::emit(const Cfg *Func) const {
|
| Variable *Dest = this->getDest();
|
| assert(Dest->getType() == IceType_i16 || Dest->getType() == IceType_i32);
|
| assert(llvm::isa<Constant>(this->getSrc(1)));
|
| - Str << "\timul" << this->getWidthString(Dest->getType()) << "\t";
|
| + Str << "\t"
|
| + "imul" << this->getWidthString(Dest->getType()) << "\t";
|
| this->getSrc(1)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(0)->emit(Func);
|
| @@ -1371,24 +1378,24 @@ void InstX86Cbwdq<Machine>::emit(const Cfg *Func) const {
|
| assert(DestReg == InstX86Base<Machine>::Traits::RegisterSet::Reg_ax ||
|
| DestReg == InstX86Base<Machine>::Traits::RegisterSet::Reg_ah);
|
| Str << "\t"
|
| - << "cbtw";
|
| + "cbtw";
|
| break;
|
| case IceType_i16:
|
| assert(SrcReg == InstX86Base<Machine>::Traits::RegisterSet::Reg_ax);
|
| assert(DestReg == InstX86Base<Machine>::Traits::RegisterSet::Reg_dx);
|
| Str << "\t"
|
| - << "cwtd";
|
| + "cwtd";
|
| break;
|
| case IceType_i32:
|
| assert(SrcReg == InstX86Base<Machine>::Traits::RegisterSet::Reg_eax);
|
| assert(DestReg == InstX86Base<Machine>::Traits::RegisterSet::Reg_edx);
|
| Str << "\t"
|
| - << "cltd";
|
| + "cltd";
|
| break;
|
| case IceType_i64:
|
| assert(DestReg == InstX86Base<Machine>::Traits::RegisterSet::Reg_edx);
|
| Str << "\t"
|
| - << "cdto";
|
| + "cdto";
|
| break;
|
| }
|
| }
|
| @@ -1441,7 +1448,8 @@ template <class Machine> void InstX86Mul<Machine>::emit(const Cfg *Func) const {
|
| assert(
|
| this->getDest()->getRegNum() ==
|
| InstX86Base<Machine>::Traits::RegisterSet::Reg_eax); // TODO: allow edx?
|
| - Str << "\tmul" << this->getWidthString(this->getDest()->getType()) << "\t";
|
| + Str << "\t"
|
| + "mul" << this->getWidthString(this->getDest()->getType()) << "\t";
|
| this->getSrc(1)->emit(Func);
|
| }
|
|
|
| @@ -1479,7 +1487,8 @@ void InstX86Shld<Machine>::emit(const Cfg *Func) const {
|
| Variable *Dest = this->getDest();
|
| assert(this->getSrcSize() == 3);
|
| assert(Dest == this->getSrc(0));
|
| - Str << "\tshld" << this->getWidthString(Dest->getType()) << "\t";
|
| + Str << "\t"
|
| + "shld" << this->getWidthString(Dest->getType()) << "\t";
|
| this->getSrc(2)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(1)->emit(Func);
|
| @@ -1519,7 +1528,8 @@ void InstX86Shrd<Machine>::emit(const Cfg *Func) const {
|
| Variable *Dest = this->getDest();
|
| assert(this->getSrcSize() == 3);
|
| assert(Dest == this->getSrc(0));
|
| - Str << "\tshrd" << this->getWidthString(Dest->getType()) << "\t";
|
| + Str << "\t"
|
| + "shrd" << this->getWidthString(Dest->getType()) << "\t";
|
| this->getSrc(2)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(1)->emit(Func);
|
| @@ -1624,11 +1634,11 @@ void InstX86Cmpps<Machine>::emit(const Cfg *Func) const {
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 2);
|
| assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid);
|
| - Str << "\t";
|
| - Str << "cmp"
|
| + Str << "\t"
|
| + "cmp"
|
| << InstX86Base<Machine>::Traits::InstCmppsAttributes[Condition].EmitString
|
| << "ps"
|
| - << "\t";
|
| + "\t";
|
| this->getSrc(1)->emit(Func);
|
| Str << ", ";
|
| this->getDest()->emit(Func);
|
| @@ -1669,7 +1679,7 @@ void InstX86Cmpps<Machine>::dump(const Cfg *Func) const {
|
| Str << " = cmp"
|
| << InstX86Base<Machine>::Traits::InstCmppsAttributes[Condition].EmitString
|
| << "ps"
|
| - << "\t";
|
| + "\t";
|
| this->dumpSources(Func);
|
| }
|
|
|
| @@ -1680,10 +1690,11 @@ void InstX86Cmpxchg<Machine>::emit(const Cfg *Func) const {
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 3);
|
| if (this->Locked) {
|
| - Str << "\tlock";
|
| + Str << "\t"
|
| + "lock";
|
| }
|
| - Str << "\tcmpxchg" << this->getWidthString(this->getSrc(0)->getType())
|
| - << "\t";
|
| + Str << "\t"
|
| + "cmpxchg" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| this->getSrc(2)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(0)->emit(Func);
|
| @@ -1729,9 +1740,11 @@ void InstX86Cmpxchg8b<Machine>::emit(const Cfg *Func) const {
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 5);
|
| if (this->Locked) {
|
| - Str << "\tlock";
|
| + Str << "\t"
|
| + "lock";
|
| }
|
| - Str << "\tcmpxchg8b\t";
|
| + Str << "\t"
|
| + "cmpxchg8b\t";
|
| this->getSrc(0)->emit(Func);
|
| }
|
|
|
| @@ -1768,7 +1781,8 @@ template <class Machine> void InstX86Cvt<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 1);
|
| - Str << "\tcvt";
|
| + Str << "\t"
|
| + "cvt";
|
| if (isTruncating())
|
| Str << "t";
|
| Str << InstX86Base<Machine>::Traits::TypeAttributes[this->getSrc(0)
|
| @@ -1893,7 +1907,8 @@ void InstX86Icmp<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 2);
|
| - Str << "\tcmp" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| + Str << "\t"
|
| + "cmp" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| this->getSrc(1)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(0)->emit(Func);
|
| @@ -1937,7 +1952,8 @@ void InstX86Ucomiss<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 2);
|
| - Str << "\tucomi"
|
| + Str << "\t"
|
| + "ucomi"
|
| << InstX86Base<Machine>::Traits::TypeAttributes[this->getSrc(0)
|
| ->getType()]
|
| .SdSsString << "\t";
|
| @@ -1974,7 +1990,8 @@ template <class Machine> void InstX86UD2<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 0);
|
| - Str << "\tud2";
|
| + Str << "\t"
|
| + "ud2";
|
| }
|
|
|
| template <class Machine>
|
| @@ -1997,7 +2014,8 @@ void InstX86Test<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 2);
|
| - Str << "\ttest" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| + Str << "\t"
|
| + "test" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| this->getSrc(1)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(0)->emit(Func);
|
| @@ -2041,7 +2059,8 @@ void InstX86Mfence<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 0);
|
| - Str << "\tmfence";
|
| + Str << "\t"
|
| + "mfence";
|
| }
|
|
|
| template <class Machine>
|
| @@ -2066,7 +2085,8 @@ void InstX86Store<Machine>::emit(const Cfg *Func) const {
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 2);
|
| Type Ty = this->getSrc(0)->getType();
|
| - Str << "\tmov" << this->getWidthString(Ty)
|
| + Str << "\t"
|
| + "mov" << this->getWidthString(Ty)
|
| << InstX86Base<Machine>::Traits::TypeAttributes[Ty].SdSsString << "\t";
|
| this->getSrc(0)->emit(Func);
|
| Str << ", ";
|
| @@ -2130,7 +2150,8 @@ void InstX86StoreP<Machine>::emit(const Cfg *Func) const {
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 2);
|
| assert(isVectorType(this->getSrc(1)->getType()));
|
| - Str << "\tmovups\t";
|
| + Str << "\t"
|
| + "movups\t";
|
| this->getSrc(0)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(1)->emit(Func);
|
| @@ -2173,7 +2194,8 @@ void InstX86StoreQ<Machine>::emit(const Cfg *Func) const {
|
| assert(this->getSrc(1)->getType() == IceType_i64 ||
|
| this->getSrc(1)->getType() == IceType_f64 ||
|
| isVectorType(this->getSrc(1)->getType()));
|
| - Str << "\tmovq\t";
|
| + Str << "\t"
|
| + "movq\t";
|
| this->getSrc(0)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(1)->emit(Func);
|
| @@ -2213,7 +2235,8 @@ template <class Machine> void InstX86Lea<Machine>::emit(const Cfg *Func) const {
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 1);
|
| assert(this->getDest()->hasReg());
|
| - Str << "\tleal\t";
|
| + Str << "\t"
|
| + "leal\t";
|
| Operand *Src0 = this->getSrc(0);
|
| if (const auto *Src0Var = llvm::dyn_cast<Variable>(Src0)) {
|
| Type Ty = Src0Var->getType();
|
| @@ -2242,13 +2265,14 @@ template <class Machine> void InstX86Mov<Machine>::emit(const Cfg *Func) const {
|
| Type DestTy = this->getDest()->getType();
|
| if (InstX86Base<Machine>::Traits::Is64Bit && DestTy == IceType_i64 &&
|
| isIntegerConstant(Src)) {
|
| - Str << "\tmovabs\t";
|
| + Str << "\t"
|
| + "movabs\t";
|
| } else {
|
| - Str << "\tmov"
|
| - << (!isScalarFloatingType(DestTy)
|
| - ? this->getWidthString(DestTy)
|
| - : InstX86Base<Machine>::Traits::TypeAttributes[DestTy]
|
| - .SdSsString) << "\t";
|
| + Str << "\t"
|
| + "mov" << (!isScalarFloatingType(DestTy)
|
| + ? this->getWidthString(DestTy)
|
| + : InstX86Base<Machine>::Traits::TypeAttributes[DestTy]
|
| + .SdSsString) << "\t";
|
| }
|
| // For an integer truncation operation, src is wider than dest. In this case,
|
| // we use a mov instruction whose data width matches the narrower dest.
|
| @@ -2418,7 +2442,8 @@ void InstX86Movp<Machine>::emit(const Cfg *Func) const {
|
| // depending on the data type and alignment of the operands.
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 1);
|
| - Str << "\tmovups\t";
|
| + Str << "\t"
|
| + "movups\t";
|
| this->getSrc(0)->emit(Func);
|
| Str << ", ";
|
| this->getDest()->emit(Func);
|
| @@ -2446,7 +2471,8 @@ void InstX86Movq<Machine>::emit(const Cfg *Func) const {
|
| assert(this->getSrcSize() == 1);
|
| assert(this->getDest()->getType() == IceType_i64 ||
|
| this->getDest()->getType() == IceType_f64);
|
| - Str << "\tmovq\t";
|
| + Str << "\t"
|
| + "movq\t";
|
| this->getSrc(0)->emit(Func);
|
| Str << ", ";
|
| this->getDest()->emit(Func);
|
| @@ -2515,7 +2541,8 @@ template <class Machine> void InstX86Nop<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| // TODO: Emit the right code for each variant.
|
| - Str << "\tnop\t# variant = " << Variant;
|
| + Str << "\t"
|
| + "nop\t# variant = " << Variant;
|
| }
|
|
|
| template <class Machine>
|
| @@ -2544,15 +2571,18 @@ template <class Machine> void InstX86Fld<Machine>::emit(const Cfg *Func) const {
|
| // This is a physical xmm register, so we need to spill it to a temporary
|
| // stack slot. Function prolog emission guarantees that there is sufficient
|
| // space to do this.
|
| - Str << "\tmov"
|
| - << InstX86Base<Machine>::Traits::TypeAttributes[Ty].SdSsString << "\t";
|
| + Str << "\t"
|
| + "mov" << InstX86Base<Machine>::Traits::TypeAttributes[Ty].SdSsString
|
| + << "\t";
|
| Var->emit(Func);
|
| - Str << ", (%esp)\n";
|
| - Str << "\tfld" << this->getFldString(Ty) << "\t"
|
| - << "(%esp)";
|
| + Str << ", (%esp)\n"
|
| + "\t"
|
| + "fld" << this->getFldString(Ty) << "\t"
|
| + "(%esp)";
|
| return;
|
| }
|
| - Str << "\tfld" << this->getFldString(Ty) << "\t";
|
| + Str << "\t"
|
| + "fld" << this->getFldString(Ty) << "\t";
|
| this->getSrc(0)->emit(Func);
|
| }
|
|
|
| @@ -2611,23 +2641,28 @@ void InstX86Fstp<Machine>::emit(const Cfg *Func) const {
|
| // "partially" delete the fstp if the Dest is unused. Even if Dest is unused,
|
| // the fstp should be kept for the SideEffects of popping the stack.
|
| if (!this->getDest()) {
|
| - Str << "\tfstp\tst(0)";
|
| + Str << "\t"
|
| + "fstp\t"
|
| + "st(0)";
|
| return;
|
| }
|
| Type Ty = this->getDest()->getType();
|
| if (!this->getDest()->hasReg()) {
|
| - Str << "\tfstp" << this->getFldString(Ty) << "\t";
|
| + Str << "\t"
|
| + "fstp" << this->getFldString(Ty) << "\t";
|
| this->getDest()->emit(Func);
|
| return;
|
| }
|
| // Dest is a physical (xmm) register, so st(0) needs to go through memory.
|
| // Hack this by using caller-reserved memory at the top of stack, spilling
|
| // st(0) there, and loading it into the xmm register.
|
| - Str << "\tfstp" << this->getFldString(Ty) << "\t"
|
| - << "(%esp)\n";
|
| - Str << "\tmov" << InstX86Base<Machine>::Traits::TypeAttributes[Ty].SdSsString
|
| + Str << "\t"
|
| + "fstp" << this->getFldString(Ty) << "\t"
|
| + "(%esp)\n";
|
| + Str << "\t"
|
| + "mov" << InstX86Base<Machine>::Traits::TypeAttributes[Ty].SdSsString
|
| << "\t"
|
| - << "(%esp), ";
|
| + "(%esp), ";
|
| this->getDest()->emit(Func);
|
| }
|
|
|
| @@ -2872,7 +2907,8 @@ template <class Machine> void InstX86Pop<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| assert(this->getSrcSize() == 0);
|
| - Str << "\tpop\t";
|
| + Str << "\t"
|
| + "pop\t";
|
| this->getDest()->emit(Func);
|
| }
|
|
|
| @@ -2907,7 +2943,8 @@ void InstX86Push<Machine>::emit(const Cfg *Func) const {
|
| // Push is currently only used for saving GPRs.
|
| const auto *Var = llvm::cast<Variable>(this->getSrc(0));
|
| assert(Var->hasReg());
|
| - Str << "\tpush\t";
|
| + Str << "\t"
|
| + "push\t";
|
| Var->emit(Func);
|
| }
|
|
|
| @@ -2979,7 +3016,8 @@ template <class Machine> void InstX86Ret<Machine>::emit(const Cfg *Func) const {
|
| if (!BuildDefs::dump())
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| - Str << "\tret";
|
| + Str << "\t"
|
| + "ret";
|
| }
|
|
|
| template <class Machine>
|
| @@ -3004,7 +3042,8 @@ void InstX86Setcc<Machine>::emit(const Cfg *Func) const {
|
| if (!BuildDefs::dump())
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| - Str << "\tset"
|
| + Str << "\t"
|
| + "set"
|
| << InstX86Base<Machine>::Traits::InstBrAttributes[Condition].DisplayString
|
| << "\t";
|
| this->Dest->emit(Func);
|
| @@ -3043,9 +3082,11 @@ void InstX86Xadd<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| if (this->Locked) {
|
| - Str << "\tlock";
|
| + Str << "\t"
|
| + "lock";
|
| }
|
| - Str << "\txadd" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| + Str << "\t"
|
| + "xadd" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| this->getSrc(1)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(0)->emit(Func);
|
| @@ -3090,7 +3131,8 @@ void InstX86Xchg<Machine>::emit(const Cfg *Func) const {
|
| if (!BuildDefs::dump())
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| - Str << "\txchg" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| + Str << "\t"
|
| + "xchg" << this->getWidthString(this->getSrc(0)->getType()) << "\t";
|
| this->getSrc(1)->emit(Func);
|
| Str << ", ";
|
| this->getSrc(0)->emit(Func);
|
| @@ -3142,9 +3184,10 @@ void InstX86IacaStart<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| Str << "\t# IACA_START\n"
|
| - << "\t.byte 0x0F, 0x0B\n"
|
| - << "\tmovl\t$111, %ebx\n"
|
| - << "\t.byte 0x64, 0x67, 0x90";
|
| + "\t.byte 0x0F, 0x0B\n"
|
| + "\t"
|
| + "movl\t$111, %ebx\n"
|
| + "\t.byte 0x64, 0x67, 0x90";
|
| }
|
|
|
| template <class Machine>
|
| @@ -3168,9 +3211,10 @@ void InstX86IacaEnd<Machine>::emit(const Cfg *Func) const {
|
| return;
|
| Ostream &Str = Func->getContext()->getStrEmit();
|
| Str << "\t# IACA_END\n"
|
| - << "\tmovl\t$222, %ebx\n"
|
| - << "\t.byte 0x64, 0x67, 0x90\n"
|
| - << "\t.byte 0x0F, 0x0B";
|
| + "\t"
|
| + "movl\t$222, %ebx\n"
|
| + "\t.byte 0x64, 0x67, 0x90\n"
|
| + "\t.byte 0x0F, 0x0B";
|
| }
|
|
|
| template <class Machine>
|
|
|