| 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 Str << "jmp "; | 519 Str << "jmp "; |
| 520 getJmpTarget()->dump(Func); | 520 getJmpTarget()->dump(Func); |
| 521 } | 521 } |
| 522 | 522 |
| 523 void InstX8632Call::emit(const Cfg *Func) const { | 523 void InstX8632Call::emit(const Cfg *Func) const { |
| 524 if (!ALLOW_DUMP) | 524 if (!ALLOW_DUMP) |
| 525 return; | 525 return; |
| 526 Ostream &Str = Func->getContext()->getStrEmit(); | 526 Ostream &Str = Func->getContext()->getStrEmit(); |
| 527 assert(getSrcSize() == 1); | 527 assert(getSrcSize() == 1); |
| 528 Str << "\tcall\t"; | 528 Str << "\tcall\t"; |
| 529 if (const auto CallTarget = llvm::dyn_cast<Constant>(getCallTarget())) { | 529 if (const auto CI = llvm::dyn_cast<ConstantInteger32>(getCallTarget())) { |
| 530 CallTarget->emitWithoutDollar(Func->getContext()); | 530 // Emit without a leading '$'. |
| 531 Str << CI->getValue(); |
| 532 } else if (const auto CallTarget = |
| 533 llvm::dyn_cast<ConstantRelocatable>(getCallTarget())) { |
| 534 CallTarget->emitWithoutPrefix(Func->getTarget()); |
| 531 } else { | 535 } else { |
| 532 Str << "*"; | 536 Str << "*"; |
| 533 getCallTarget()->emit(Func); | 537 getCallTarget()->emit(Func); |
| 534 } | 538 } |
| 535 Func->getTarget()->resetStackAdjustment(); | 539 Func->getTarget()->resetStackAdjustment(); |
| 536 } | 540 } |
| 537 | 541 |
| 538 void InstX8632Call::emitIAS(const Cfg *Func) const { | 542 void InstX8632Call::emitIAS(const Cfg *Func) const { |
| 539 X8632::AssemblerX8632 *Asm = Func->getAssembler<X8632::AssemblerX8632>(); | 543 X8632::AssemblerX8632 *Asm = Func->getAssembler<X8632::AssemblerX8632>(); |
| 540 Operand *Target = getCallTarget(); | 544 Operand *Target = getCallTarget(); |
| (...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2841 // Emit as Offset(Base,Index,1<<Shift). | 2845 // Emit as Offset(Base,Index,1<<Shift). |
| 2842 // Offset is emitted without the leading '$'. | 2846 // Offset is emitted without the leading '$'. |
| 2843 // Omit the (Base,Index,1<<Shift) part if Base==nullptr. | 2847 // Omit the (Base,Index,1<<Shift) part if Base==nullptr. |
| 2844 if (!Offset) { | 2848 if (!Offset) { |
| 2845 // No offset, emit nothing. | 2849 // No offset, emit nothing. |
| 2846 } else if (const auto CI = llvm::dyn_cast<ConstantInteger32>(Offset)) { | 2850 } else if (const auto CI = llvm::dyn_cast<ConstantInteger32>(Offset)) { |
| 2847 if (Base == nullptr || CI->getValue()) | 2851 if (Base == nullptr || CI->getValue()) |
| 2848 // Emit a non-zero offset without a leading '$'. | 2852 // Emit a non-zero offset without a leading '$'. |
| 2849 Str << CI->getValue(); | 2853 Str << CI->getValue(); |
| 2850 } else if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(Offset)) { | 2854 } else if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(Offset)) { |
| 2851 CR->emitWithoutDollar(Func->getContext()); | 2855 CR->emitWithoutPrefix(Func->getTarget()); |
| 2852 } else { | 2856 } else { |
| 2853 llvm_unreachable("Invalid offset type for x86 mem operand"); | 2857 llvm_unreachable("Invalid offset type for x86 mem operand"); |
| 2854 } | 2858 } |
| 2855 | 2859 |
| 2856 if (Base) { | 2860 if (Base) { |
| 2857 Str << "("; | 2861 Str << "("; |
| 2858 Base->emit(Func); | 2862 Base->emit(Func); |
| 2859 if (Index) { | 2863 if (Index) { |
| 2860 Str << ","; | 2864 Str << ","; |
| 2861 Index->emit(Func); | 2865 Index->emit(Func); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2995 } | 2999 } |
| 2996 Str << "("; | 3000 Str << "("; |
| 2997 if (Func) | 3001 if (Func) |
| 2998 Var->dump(Func); | 3002 Var->dump(Func); |
| 2999 else | 3003 else |
| 3000 Var->dump(Str); | 3004 Var->dump(Str); |
| 3001 Str << ")"; | 3005 Str << ")"; |
| 3002 } | 3006 } |
| 3003 | 3007 |
| 3004 } // end of namespace Ice | 3008 } // end of namespace Ice |
| OLD | NEW |