Chromium Code Reviews| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 : InstX8632(Func, InstX8632::Label, 0, NULL), | 114 : InstX8632(Func, InstX8632::Label, 0, NULL), |
| 115 Number(Target->makeNextLabelNumber()) {} | 115 Number(Target->makeNextLabelNumber()) {} |
| 116 | 116 |
| 117 IceString InstX8632Label::getName(const Cfg *Func) const { | 117 IceString InstX8632Label::getName(const Cfg *Func) const { |
| 118 char buf[30]; | 118 char buf[30]; |
| 119 snprintf(buf, llvm::array_lengthof(buf), "%u", Number); | 119 snprintf(buf, llvm::array_lengthof(buf), "%u", Number); |
| 120 return ".L" + Func->getFunctionName() + "$__" + buf; | 120 return ".L" + Func->getFunctionName() + "$__" + buf; |
| 121 } | 121 } |
| 122 | 122 |
| 123 InstX8632Br::InstX8632Br(Cfg *Func, CfgNode *TargetTrue, CfgNode *TargetFalse, | 123 InstX8632Br::InstX8632Br(Cfg *Func, CfgNode *TargetTrue, CfgNode *TargetFalse, |
| 124 InstX8632Label *Label, InstX8632Br::BrCond Condition) | 124 InstX8632Label *Label, InstX8632::BrCond Condition) |
| 125 : InstX8632(Func, InstX8632::Br, 0, NULL), Condition(Condition), | 125 : InstX8632(Func, InstX8632::Br, 0, NULL), Condition(Condition), |
| 126 TargetTrue(TargetTrue), TargetFalse(TargetFalse), Label(Label) {} | 126 TargetTrue(TargetTrue), TargetFalse(TargetFalse), Label(Label) {} |
| 127 | 127 |
| 128 InstX8632Call::InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget) | 128 InstX8632Call::InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget) |
| 129 : InstX8632(Func, InstX8632::Call, 1, Dest) { | 129 : InstX8632(Func, InstX8632::Call, 1, Dest) { |
| 130 HasSideEffects = true; | 130 HasSideEffects = true; |
| 131 addSource(CallTarget); | 131 addSource(CallTarget); |
| 132 } | 132 } |
| 133 | 133 |
| 134 InstX8632Cdq::InstX8632Cdq(Cfg *Func, Variable *Dest, Operand *Source) | 134 InstX8632Cdq::InstX8632Cdq(Cfg *Func, Variable *Dest, Operand *Source) |
| 135 : InstX8632(Func, InstX8632::Cdq, 1, Dest) { | 135 : InstX8632(Func, InstX8632::Cdq, 1, Dest) { |
| 136 assert(Dest->getRegNum() == TargetX8632::Reg_edx); | 136 assert(Dest->getRegNum() == TargetX8632::Reg_edx); |
| 137 assert(llvm::isa<Variable>(Source)); | 137 assert(llvm::isa<Variable>(Source)); |
| 138 assert(llvm::dyn_cast<Variable>(Source)->getRegNum() == TargetX8632::Reg_eax); | 138 assert(llvm::dyn_cast<Variable>(Source)->getRegNum() == TargetX8632::Reg_eax); |
| 139 addSource(Source); | 139 addSource(Source); |
| 140 } | 140 } |
| 141 | 141 |
| 142 InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, | |
| 143 InstX8632::BrCond Condition) | |
| 144 : InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) { | |
| 145 // The final result is either the original Dest, or Source, so mark | |
| 146 // both as sources. | |
| 147 addSource(Dest); | |
| 148 addSource(Source); | |
| 149 } | |
| 150 | |
| 142 InstX8632Cmpxchg::InstX8632Cmpxchg(Cfg *Func, Operand *DestOrAddr, | 151 InstX8632Cmpxchg::InstX8632Cmpxchg(Cfg *Func, Operand *DestOrAddr, |
| 143 Variable *Eax, Variable *Desired, | 152 Variable *Eax, Variable *Desired, |
| 144 bool Locked) | 153 bool Locked) |
| 145 : InstX8632Lockable(Func, InstX8632::Cmpxchg, 3, | 154 : InstX8632Lockable(Func, InstX8632::Cmpxchg, 3, |
| 146 llvm::dyn_cast<Variable>(DestOrAddr), Locked) { | 155 llvm::dyn_cast<Variable>(DestOrAddr), Locked) { |
| 147 assert(Eax->getRegNum() == TargetX8632::Reg_eax); | 156 assert(Eax->getRegNum() == TargetX8632::Reg_eax); |
| 148 addSource(DestOrAddr); | 157 addSource(DestOrAddr); |
| 149 addSource(Eax); | 158 addSource(Eax); |
| 150 addSource(Desired); | 159 addSource(Desired); |
| 151 } | 160 } |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 template <> const char *InstX8632Imul::Opcode = "imul"; | 454 template <> const char *InstX8632Imul::Opcode = "imul"; |
| 446 template <> const char *InstX8632Mulps::Opcode = "mulps"; | 455 template <> const char *InstX8632Mulps::Opcode = "mulps"; |
| 447 template <> const char *InstX8632Mulss::Opcode = "mulss"; | 456 template <> const char *InstX8632Mulss::Opcode = "mulss"; |
| 448 template <> const char *InstX8632Div::Opcode = "div"; | 457 template <> const char *InstX8632Div::Opcode = "div"; |
| 449 template <> const char *InstX8632Divps::Opcode = "divps"; | 458 template <> const char *InstX8632Divps::Opcode = "divps"; |
| 450 template <> const char *InstX8632Idiv::Opcode = "idiv"; | 459 template <> const char *InstX8632Idiv::Opcode = "idiv"; |
| 451 template <> const char *InstX8632Divss::Opcode = "divss"; | 460 template <> const char *InstX8632Divss::Opcode = "divss"; |
| 452 template <> const char *InstX8632Shl::Opcode = "shl"; | 461 template <> const char *InstX8632Shl::Opcode = "shl"; |
| 453 template <> const char *InstX8632Shr::Opcode = "shr"; | 462 template <> const char *InstX8632Shr::Opcode = "shr"; |
| 454 template <> const char *InstX8632Sar::Opcode = "sar"; | 463 template <> const char *InstX8632Sar::Opcode = "sar"; |
| 464 template <> const char *InstX8632Bsf::Opcode = "bsf"; | |
| 465 template <> const char *InstX8632Bsr::Opcode = "bsr"; | |
| 455 | 466 |
| 456 template <> void InstX8632Addss::emit(const Cfg *Func) const { | 467 template <> void InstX8632Addss::emit(const Cfg *Func) const { |
| 457 char buf[30]; | 468 char buf[30]; |
| 458 snprintf(buf, llvm::array_lengthof(buf), "add%s", | 469 snprintf(buf, llvm::array_lengthof(buf), "add%s", |
| 459 TypeX8632Attributes[getDest()->getType()].SdSsString); | 470 TypeX8632Attributes[getDest()->getType()].SdSsString); |
| 460 emitTwoAddress(buf, this, Func); | 471 emitTwoAddress(buf, this, Func); |
| 461 } | 472 } |
| 462 | 473 |
| 463 template <> void InstX8632Subss::emit(const Cfg *Func) const { | 474 template <> void InstX8632Subss::emit(const Cfg *Func) const { |
| 464 char buf[30]; | 475 char buf[30]; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 Str << "\tcdq\n"; | 590 Str << "\tcdq\n"; |
| 580 } | 591 } |
| 581 | 592 |
| 582 void InstX8632Cdq::dump(const Cfg *Func) const { | 593 void InstX8632Cdq::dump(const Cfg *Func) const { |
| 583 Ostream &Str = Func->getContext()->getStrDump(); | 594 Ostream &Str = Func->getContext()->getStrDump(); |
| 584 dumpDest(Func); | 595 dumpDest(Func); |
| 585 Str << " = cdq." << getSrc(0)->getType() << " "; | 596 Str << " = cdq." << getSrc(0)->getType() << " "; |
| 586 dumpSources(Func); | 597 dumpSources(Func); |
| 587 } | 598 } |
| 588 | 599 |
| 600 void InstX8632Cmov::emit(const Cfg *Func) const { | |
| 601 Ostream &Str = Func->getContext()->getStrEmit(); | |
| 602 Str << "\t"; | |
| 603 assert(Condition != Br_None); | |
|
Jim Stichnoth
2014/07/14 23:20:45
Add an assert that Dest is a physical register.
jvoung (off chromium)
2014/07/15 21:30:23
Done.
| |
| 604 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "\t"; | |
| 605 getDest()->emit(Func); | |
| 606 Str << ", "; | |
| 607 getSrc(1)->emit(Func); | |
| 608 Str << "\n"; | |
| 609 } | |
| 610 | |
| 611 void InstX8632Cmov::dump(const Cfg *Func) const { | |
| 612 Ostream &Str = Func->getContext()->getStrDump(); | |
| 613 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "."; | |
| 614 Str << getDest()->getType() << " "; | |
| 615 dumpDest(Func); | |
| 616 Str << ", "; | |
| 617 dumpSources(Func); | |
| 618 } | |
| 619 | |
| 589 void InstX8632Cmpxchg::emit(const Cfg *Func) const { | 620 void InstX8632Cmpxchg::emit(const Cfg *Func) const { |
| 590 Ostream &Str = Func->getContext()->getStrEmit(); | 621 Ostream &Str = Func->getContext()->getStrEmit(); |
| 591 assert(getSrcSize() == 3); | 622 assert(getSrcSize() == 3); |
| 592 if (Locked) { | 623 if (Locked) { |
| 593 Str << "\tlock"; | 624 Str << "\tlock"; |
| 594 } | 625 } |
| 595 Str << "\tcmpxchg\t"; | 626 Str << "\tcmpxchg\t"; |
| 596 getSrc(0)->emit(Func); | 627 getSrc(0)->emit(Func); |
| 597 Str << ", "; | 628 Str << ", "; |
| 598 getSrc(2)->emit(Func); | 629 getSrc(2)->emit(Func); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 default: | 1221 default: |
| 1191 Str << "???"; | 1222 Str << "???"; |
| 1192 break; | 1223 break; |
| 1193 } | 1224 } |
| 1194 Str << "("; | 1225 Str << "("; |
| 1195 Var->dump(Func); | 1226 Var->dump(Func); |
| 1196 Str << ")"; | 1227 Str << ")"; |
| 1197 } | 1228 } |
| 1198 | 1229 |
| 1199 } // end of namespace Ice | 1230 } // end of namespace Ice |
| OLD | NEW |