| OLD | NEW |
| 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// | 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file implements the InstX8632 and OperandX8632 classes, | 10 // This file implements the InstX8632 and OperandX8632 classes, |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 Ostream &Str = Func->getContext()->getStrDump(); | 648 Ostream &Str = Func->getContext()->getStrDump(); |
| 649 Str << "storeq." << getSrc(0)->getType() << " "; | 649 Str << "storeq." << getSrc(0)->getType() << " "; |
| 650 getSrc(1)->dump(Func); | 650 getSrc(1)->dump(Func); |
| 651 Str << ", "; | 651 Str << ", "; |
| 652 getSrc(0)->dump(Func); | 652 getSrc(0)->dump(Func); |
| 653 } | 653 } |
| 654 | 654 |
| 655 void InstX8632Mov::emit(const Cfg *Func) const { | 655 void InstX8632Mov::emit(const Cfg *Func) const { |
| 656 Ostream &Str = Func->getContext()->getStrEmit(); | 656 Ostream &Str = Func->getContext()->getStrEmit(); |
| 657 assert(getSrcSize() == 1); | 657 assert(getSrcSize() == 1); |
| 658 Str << "\tmov" << TypeX8632Attributes[getDest()->getType()].SdSsString | 658 Operand *Src = getSrc(0); |
| 659 << "\t"; | 659 // The llvm-mc assembler using Intel syntax has a bug in which "mov |
| 660 // reg, RelocatableConstant" does not generate the right instruction |
| 661 // with a relocation. To work around, we emit "lea reg, |
| 662 // [RelocatableConstant]". Also, the lowering and legalization is |
| 663 // changed to allow relocatable constants only in Assign and Call |
| 664 // instructions or in Mem operands. TODO(stichnot): remove LEAHACK |
| 665 // once a proper emitter is used. |
| 666 bool UseLeaHack = llvm::isa<ConstantRelocatable>(Src); |
| 667 Str << "\t"; |
| 668 if (UseLeaHack) |
| 669 Str << "lea"; |
| 670 else |
| 671 Str << "mov" << TypeX8632Attributes[getDest()->getType()].SdSsString; |
| 672 Str << "\t"; |
| 660 // For an integer truncation operation, src is wider than dest. | 673 // For an integer truncation operation, src is wider than dest. |
| 661 // Ideally, we use a mov instruction whose data width matches the | 674 // Ideally, we use a mov instruction whose data width matches the |
| 662 // narrower dest. This is a problem if e.g. src is a register like | 675 // narrower dest. This is a problem if e.g. src is a register like |
| 663 // esi or si where there is no 8-bit version of the register. To be | 676 // esi or si where there is no 8-bit version of the register. To be |
| 664 // safe, we instead widen the dest to match src. This works even | 677 // safe, we instead widen the dest to match src. This works even |
| 665 // for stack-allocated dest variables because typeWidthOnStack() | 678 // for stack-allocated dest variables because typeWidthOnStack() |
| 666 // pads to a 4-byte boundary even if only a lower portion is used. | 679 // pads to a 4-byte boundary even if only a lower portion is used. |
| 667 assert(Func->getTarget()->typeWidthInBytesOnStack(getDest()->getType()) == | 680 assert(Func->getTarget()->typeWidthInBytesOnStack(getDest()->getType()) == |
| 668 Func->getTarget()->typeWidthInBytesOnStack(getSrc(0)->getType())); | 681 Func->getTarget()->typeWidthInBytesOnStack(Src->getType())); |
| 669 getDest()->asType(getSrc(0)->getType()).emit(Func); | 682 getDest()->asType(Src->getType()).emit(Func); |
| 670 Str << ", "; | 683 Str << ", "; |
| 671 getSrc(0)->emit(Func); | 684 Src->emit(Func); |
| 672 Str << "\n"; | 685 Str << "\n"; |
| 673 } | 686 } |
| 674 | 687 |
| 675 void InstX8632Mov::dump(const Cfg *Func) const { | 688 void InstX8632Mov::dump(const Cfg *Func) const { |
| 676 Ostream &Str = Func->getContext()->getStrDump(); | 689 Ostream &Str = Func->getContext()->getStrDump(); |
| 677 Str << "mov." << getDest()->getType() << " "; | 690 Str << "mov." << getDest()->getType() << " "; |
| 678 dumpDest(Func); | 691 dumpDest(Func); |
| 679 Str << ", "; | 692 Str << ", "; |
| 680 dumpSources(Func); | 693 dumpSources(Func); |
| 681 } | 694 } |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 default: | 1024 default: |
| 1012 Str << "???"; | 1025 Str << "???"; |
| 1013 break; | 1026 break; |
| 1014 } | 1027 } |
| 1015 Str << "("; | 1028 Str << "("; |
| 1016 Var->dump(Func); | 1029 Var->dump(Func); |
| 1017 Str << ")"; | 1030 Str << ")"; |
| 1018 } | 1031 } |
| 1019 | 1032 |
| 1020 } // end of namespace Ice | 1033 } // end of namespace Ice |
| OLD | NEW |