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 18 matching lines...) Expand all Loading... |
29 } InstX8632BrAttributes[] = { | 29 } InstX8632BrAttributes[] = { |
30 #define X(tag, dump, emit) \ | 30 #define X(tag, dump, emit) \ |
31 { dump, emit } \ | 31 { dump, emit } \ |
32 , | 32 , |
33 ICEINSTX8632BR_TABLE | 33 ICEINSTX8632BR_TABLE |
34 #undef X | 34 #undef X |
35 }; | 35 }; |
36 const size_t InstX8632BrAttributesSize = | 36 const size_t InstX8632BrAttributesSize = |
37 llvm::array_lengthof(InstX8632BrAttributes); | 37 llvm::array_lengthof(InstX8632BrAttributes); |
38 | 38 |
| 39 const struct InstX8632CmppsAttributes_ { |
| 40 const char *EmitString; |
| 41 } InstX8632CmppsAttributes[] = { |
| 42 #define X(tag, emit) \ |
| 43 { emit } \ |
| 44 , |
| 45 ICEINSTX8632CMPPS_TABLE |
| 46 #undef X |
| 47 }; |
| 48 const size_t InstX8632CmppsAttributesSize = |
| 49 llvm::array_lengthof(InstX8632CmppsAttributes); |
| 50 |
39 const struct TypeX8632Attributes_ { | 51 const struct TypeX8632Attributes_ { |
40 const char *CvtString; // i (integer), s (single FP), d (double FP) | 52 const char *CvtString; // i (integer), s (single FP), d (double FP) |
41 const char *SdSsString; // ss, sd, or <blank> | 53 const char *SdSsString; // ss, sd, or <blank> |
42 const char *PackString; // b, w, d, or <blank> | 54 const char *PackString; // b, w, d, or <blank> |
43 const char *WidthString; // {byte,word,dword,qword} ptr | 55 const char *WidthString; // {byte,word,dword,qword} ptr |
44 } TypeX8632Attributes[] = { | 56 } TypeX8632Attributes[] = { |
45 #define X(tag, elementty, cvt, sdss, pack, width) \ | 57 #define X(tag, elementty, cvt, sdss, pack, width) \ |
46 { cvt, "" sdss, pack, width } \ | 58 { cvt, "" sdss, pack, width } \ |
47 , | 59 , |
48 ICETYPEX8632_TABLE | 60 ICETYPEX8632_TABLE |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 154 |
143 InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, | 155 InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, |
144 InstX8632::BrCond Condition) | 156 InstX8632::BrCond Condition) |
145 : InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) { | 157 : InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) { |
146 // The final result is either the original Dest, or Source, so mark | 158 // The final result is either the original Dest, or Source, so mark |
147 // both as sources. | 159 // both as sources. |
148 addSource(Dest); | 160 addSource(Dest); |
149 addSource(Source); | 161 addSource(Source); |
150 } | 162 } |
151 | 163 |
| 164 InstX8632Cmpps::InstX8632Cmpps(Cfg *Func, Variable *Dest, Operand *Source, |
| 165 InstX8632Cmpps::CmppsCond Condition) |
| 166 : InstX8632(Func, InstX8632::Cmpps, 2, Dest), Condition(Condition) { |
| 167 addSource(Dest); |
| 168 addSource(Source); |
| 169 } |
| 170 |
152 InstX8632Cmpxchg::InstX8632Cmpxchg(Cfg *Func, Operand *DestOrAddr, | 171 InstX8632Cmpxchg::InstX8632Cmpxchg(Cfg *Func, Operand *DestOrAddr, |
153 Variable *Eax, Variable *Desired, | 172 Variable *Eax, Variable *Desired, |
154 bool Locked) | 173 bool Locked) |
155 : InstX8632Lockable(Func, InstX8632::Cmpxchg, 3, | 174 : InstX8632Lockable(Func, InstX8632::Cmpxchg, 3, |
156 llvm::dyn_cast<Variable>(DestOrAddr), Locked) { | 175 llvm::dyn_cast<Variable>(DestOrAddr), Locked) { |
157 assert(Eax->getRegNum() == TargetX8632::Reg_eax); | 176 assert(Eax->getRegNum() == TargetX8632::Reg_eax); |
158 addSource(DestOrAddr); | 177 addSource(DestOrAddr); |
159 addSource(Eax); | 178 addSource(Eax); |
160 addSource(Desired); | 179 addSource(Desired); |
161 } | 180 } |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 706 |
688 void InstX8632Cmov::dump(const Cfg *Func) const { | 707 void InstX8632Cmov::dump(const Cfg *Func) const { |
689 Ostream &Str = Func->getContext()->getStrDump(); | 708 Ostream &Str = Func->getContext()->getStrDump(); |
690 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "."; | 709 Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "."; |
691 Str << getDest()->getType() << " "; | 710 Str << getDest()->getType() << " "; |
692 dumpDest(Func); | 711 dumpDest(Func); |
693 Str << ", "; | 712 Str << ", "; |
694 dumpSources(Func); | 713 dumpSources(Func); |
695 } | 714 } |
696 | 715 |
| 716 void InstX8632Cmpps::emit(const Cfg *Func) const { |
| 717 Ostream &Str = Func->getContext()->getStrEmit(); |
| 718 assert(getSrcSize() == 2); |
| 719 assert(Condition < InstX8632CmppsAttributesSize); |
| 720 Str << "\t"; |
| 721 Str << "cmp" << InstX8632CmppsAttributes[Condition].EmitString << "ps" |
| 722 << "\t"; |
| 723 getDest()->emit(Func); |
| 724 Str << ", "; |
| 725 getSrc(1)->emit(Func); |
| 726 Str << "\n"; |
| 727 } |
| 728 |
| 729 void InstX8632Cmpps::dump(const Cfg *Func) const { |
| 730 Ostream &Str = Func->getContext()->getStrDump(); |
| 731 assert(Condition < InstX8632CmppsAttributesSize); |
| 732 dumpDest(Func); |
| 733 Str << " = cmp" << InstX8632CmppsAttributes[Condition].EmitString << "ps" |
| 734 << "\t"; |
| 735 dumpSources(Func); |
| 736 } |
| 737 |
697 void InstX8632Cmpxchg::emit(const Cfg *Func) const { | 738 void InstX8632Cmpxchg::emit(const Cfg *Func) const { |
698 Ostream &Str = Func->getContext()->getStrEmit(); | 739 Ostream &Str = Func->getContext()->getStrEmit(); |
699 assert(getSrcSize() == 3); | 740 assert(getSrcSize() == 3); |
700 if (Locked) { | 741 if (Locked) { |
701 Str << "\tlock"; | 742 Str << "\tlock"; |
702 } | 743 } |
703 Str << "\tcmpxchg\t"; | 744 Str << "\tcmpxchg\t"; |
704 getSrc(0)->emit(Func); | 745 getSrc(0)->emit(Func); |
705 Str << ", "; | 746 Str << ", "; |
706 getSrc(2)->emit(Func); | 747 getSrc(2)->emit(Func); |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 default: | 1407 default: |
1367 Str << "???"; | 1408 Str << "???"; |
1368 break; | 1409 break; |
1369 } | 1410 } |
1370 Str << "("; | 1411 Str << "("; |
1371 Var->dump(Func); | 1412 Var->dump(Func); |
1372 Str << ")"; | 1413 Str << ")"; |
1373 } | 1414 } |
1374 | 1415 |
1375 } // end of namespace Ice | 1416 } // end of namespace Ice |
OLD | NEW |