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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 InstX8632Label *Label, InstX8632::BrCond Condition) | 129 InstX8632Label *Label, InstX8632::BrCond Condition) |
130 : InstX8632(Func, InstX8632::Br, 0, NULL), Condition(Condition), | 130 : InstX8632(Func, InstX8632::Br, 0, NULL), Condition(Condition), |
131 TargetTrue(TargetTrue), TargetFalse(TargetFalse), Label(Label) {} | 131 TargetTrue(TargetTrue), TargetFalse(TargetFalse), Label(Label) {} |
132 | 132 |
133 InstX8632Call::InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget) | 133 InstX8632Call::InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget) |
134 : InstX8632(Func, InstX8632::Call, 1, Dest) { | 134 : InstX8632(Func, InstX8632::Call, 1, Dest) { |
135 HasSideEffects = true; | 135 HasSideEffects = true; |
136 addSource(CallTarget); | 136 addSource(CallTarget); |
137 } | 137 } |
138 | 138 |
139 InstX8632Cdq::InstX8632Cdq(Cfg *Func, Variable *Dest, Operand *Source) | 139 InstX8632Cbwdq::InstX8632Cbwdq(Cfg *Func, Variable *Dest, Operand *Source) |
140 : InstX8632(Func, InstX8632::Cdq, 1, Dest) { | 140 : InstX8632(Func, InstX8632::Cbwdq, 1, Dest) { |
141 assert(Dest->getRegNum() == TargetX8632::Reg_edx); | |
142 assert(llvm::isa<Variable>(Source)); | |
143 assert(llvm::dyn_cast<Variable>(Source)->getRegNum() == TargetX8632::Reg_eax); | |
144 addSource(Source); | 141 addSource(Source); |
145 } | 142 } |
146 | 143 |
147 InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, | 144 InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, |
148 InstX8632::BrCond Condition) | 145 InstX8632::BrCond Condition) |
149 : InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) { | 146 : InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) { |
150 // The final result is either the original Dest, or Source, so mark | 147 // The final result is either the original Dest, or Source, so mark |
151 // both as sources. | 148 // both as sources. |
152 addSource(Dest); | 149 addSource(Dest); |
153 addSource(Source); | 150 addSource(Source); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 Str << "\n"; | 711 Str << "\n"; |
715 } | 712 } |
716 | 713 |
717 void InstX8632Shrd::dump(const Cfg *Func) const { | 714 void InstX8632Shrd::dump(const Cfg *Func) const { |
718 Ostream &Str = Func->getContext()->getStrDump(); | 715 Ostream &Str = Func->getContext()->getStrDump(); |
719 dumpDest(Func); | 716 dumpDest(Func); |
720 Str << " = shrd." << getDest()->getType() << " "; | 717 Str << " = shrd." << getDest()->getType() << " "; |
721 dumpSources(Func); | 718 dumpSources(Func); |
722 } | 719 } |
723 | 720 |
724 void InstX8632Cdq::emit(const Cfg *Func) const { | 721 void InstX8632Cbwdq::emit(const Cfg *Func) const { |
725 Ostream &Str = Func->getContext()->getStrEmit(); | 722 Ostream &Str = Func->getContext()->getStrEmit(); |
726 assert(getSrcSize() == 1); | 723 assert(getSrcSize() == 1); |
727 Str << "\tcdq\n"; | 724 Operand *Src0 = getSrc(0); |
| 725 assert(llvm::isa<Variable>(Src0)); |
| 726 assert(llvm::cast<Variable>(Src0)->getRegNum() == TargetX8632::Reg_eax); |
| 727 switch (Src0->getType()) { |
| 728 default: |
| 729 llvm_unreachable("unexpected source type!"); |
| 730 break; |
| 731 case IceType_i8: |
| 732 assert(getDest()->getRegNum() == TargetX8632::Reg_eax); |
| 733 Str << "\tcbw\n"; |
| 734 break; |
| 735 case IceType_i16: |
| 736 assert(getDest()->getRegNum() == TargetX8632::Reg_edx); |
| 737 Str << "\tcwd\n"; |
| 738 break; |
| 739 case IceType_i32: |
| 740 assert(getDest()->getRegNum() == TargetX8632::Reg_edx); |
| 741 Str << "\tcdq\n"; |
| 742 break; |
| 743 } |
728 } | 744 } |
729 | 745 |
730 void InstX8632Cdq::dump(const Cfg *Func) const { | 746 void InstX8632Cbwdq::dump(const Cfg *Func) const { |
731 Ostream &Str = Func->getContext()->getStrDump(); | 747 Ostream &Str = Func->getContext()->getStrDump(); |
732 dumpDest(Func); | 748 dumpDest(Func); |
733 Str << " = cdq." << getSrc(0)->getType() << " "; | 749 Str << " = cbw/cwd/cdq." << getSrc(0)->getType() << " "; |
734 dumpSources(Func); | 750 dumpSources(Func); |
735 } | 751 } |
736 | 752 |
737 void InstX8632Cmov::emit(const Cfg *Func) const { | 753 void InstX8632Cmov::emit(const Cfg *Func) const { |
738 Ostream &Str = Func->getContext()->getStrEmit(); | 754 Ostream &Str = Func->getContext()->getStrEmit(); |
739 Str << "\t"; | 755 Str << "\t"; |
740 assert(Condition != Br_None); | 756 assert(Condition != Br_None); |
741 assert(getDest()->hasReg()); | 757 assert(getDest()->hasReg()); |
742 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "\t"; | 758 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "\t"; |
743 getDest()->emit(Func); | 759 getDest()->emit(Func); |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 default: | 1483 default: |
1468 Str << "???"; | 1484 Str << "???"; |
1469 break; | 1485 break; |
1470 } | 1486 } |
1471 Str << "("; | 1487 Str << "("; |
1472 Var->dump(Func); | 1488 Var->dump(Func); |
1473 Str << ")"; | 1489 Str << ")"; |
1474 } | 1490 } |
1475 | 1491 |
1476 } // end of namespace Ice | 1492 } // end of namespace Ice |
OLD | NEW |