Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: src/IceInstX8632.cpp

Issue 362463002: Subzero: lower the rest of the atomic operations. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: revert register alloc workarounds Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #define X(tag, cvt, sdss, width) \ 44 #define X(tag, cvt, sdss, width) \
45 { cvt, "" sdss, width } \ 45 { cvt, "" sdss, width } \
46 , 46 ,
47 ICETYPEX8632_TABLE 47 ICETYPEX8632_TABLE
48 #undef X 48 #undef X
49 }; 49 };
50 const size_t TypeX8632AttributesSize = 50 const size_t TypeX8632AttributesSize =
51 llvm::array_lengthof(TypeX8632Attributes); 51 llvm::array_lengthof(TypeX8632Attributes);
52 52
53 const char *InstX8632SegmentRegNames[] = { 53 const char *InstX8632SegmentRegNames[] = {
54 #define X(val, name) \ 54 #define X(val, name) name,
55 name, 55 SEG_REGX8632_TABLE
56 SEG_REGX8632_TABLE
57 #undef X 56 #undef X
58 }; 57 };
59 const size_t InstX8632SegmentRegNamesSize = 58 const size_t InstX8632SegmentRegNamesSize =
60 llvm::array_lengthof(InstX8632SegmentRegNames); 59 llvm::array_lengthof(InstX8632SegmentRegNames);
61 60
62 } // end of anonymous namespace 61 } // end of anonymous namespace
63 62
64 const char *InstX8632::getWidthString(Type Ty) { 63 const char *InstX8632::getWidthString(Type Ty) {
65 return TypeX8632Attributes[Ty].WidthString; 64 return TypeX8632Attributes[Ty].WidthString;
66 } 65 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 132 }
134 133
135 InstX8632Cdq::InstX8632Cdq(Cfg *Func, Variable *Dest, Operand *Source) 134 InstX8632Cdq::InstX8632Cdq(Cfg *Func, Variable *Dest, Operand *Source)
136 : InstX8632(Func, InstX8632::Cdq, 1, Dest) { 135 : InstX8632(Func, InstX8632::Cdq, 1, Dest) {
137 assert(Dest->getRegNum() == TargetX8632::Reg_edx); 136 assert(Dest->getRegNum() == TargetX8632::Reg_edx);
138 assert(llvm::isa<Variable>(Source)); 137 assert(llvm::isa<Variable>(Source));
139 assert(llvm::dyn_cast<Variable>(Source)->getRegNum() == TargetX8632::Reg_eax); 138 assert(llvm::dyn_cast<Variable>(Source)->getRegNum() == TargetX8632::Reg_eax);
140 addSource(Source); 139 addSource(Source);
141 } 140 }
142 141
142 InstX8632Cmpxchg::InstX8632Cmpxchg(Cfg *Func, Operand *DestOrAddr,
143 Variable *Eax, Variable *Desired,
144 bool Locked)
145 : InstX8632Lockable(Func, InstX8632::Cmpxchg, 3,
146 llvm::dyn_cast<Variable>(DestOrAddr), Locked) {
147 assert(Eax->getRegNum() == TargetX8632::Reg_eax);
148 addSource(DestOrAddr);
149 addSource(Eax);
150 addSource(Desired);
151 }
152
153 InstX8632Cmpxchg8b::InstX8632Cmpxchg8b(Cfg *Func, OperandX8632 *Addr,
154 Variable *Edx, Variable *Eax,
155 Variable *Ecx, Variable *Ebx,
156 bool Locked)
157 : InstX8632Lockable(Func, InstX8632::Cmpxchg, 5, NULL, Locked) {
158 assert(Edx->getRegNum() == TargetX8632::Reg_edx);
159 assert(Eax->getRegNum() == TargetX8632::Reg_eax);
160 assert(Ecx->getRegNum() == TargetX8632::Reg_ecx);
161 assert(Ebx->getRegNum() == TargetX8632::Reg_ebx);
162 addSource(Addr);
163 addSource(Edx);
164 addSource(Eax);
165 addSource(Ecx);
166 addSource(Ebx);
167 }
168
143 InstX8632Cvt::InstX8632Cvt(Cfg *Func, Variable *Dest, Operand *Source) 169 InstX8632Cvt::InstX8632Cvt(Cfg *Func, Variable *Dest, Operand *Source)
144 : InstX8632(Func, InstX8632::Cvt, 1, Dest) { 170 : InstX8632(Func, InstX8632::Cvt, 1, Dest) {
145 addSource(Source); 171 addSource(Source);
146 } 172 }
147 173
148 InstX8632Icmp::InstX8632Icmp(Cfg *Func, Operand *Src0, Operand *Src1) 174 InstX8632Icmp::InstX8632Icmp(Cfg *Func, Operand *Src0, Operand *Src1)
149 : InstX8632(Func, InstX8632::Icmp, 2, NULL) { 175 : InstX8632(Func, InstX8632::Icmp, 2, NULL) {
150 addSource(Src0); 176 addSource(Src0);
151 addSource(Src1); 177 addSource(Src1);
152 } 178 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 303 }
278 304
279 InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source) 305 InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source)
280 : InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) { 306 : InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) {
281 if (Source) 307 if (Source)
282 addSource(Source); 308 addSource(Source);
283 } 309 }
284 310
285 InstX8632Xadd::InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source, 311 InstX8632Xadd::InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source,
286 bool Locked) 312 bool Locked)
287 : InstX8632(Func, InstX8632::Xadd, 2, llvm::dyn_cast<Variable>(Dest)), 313 : InstX8632Lockable(Func, InstX8632::Xadd, 2,
288 Locked(Locked) { 314 llvm::dyn_cast<Variable>(Dest), Locked) {
289 HasSideEffects = Locked;
290 addSource(Dest); 315 addSource(Dest);
291 addSource(Source); 316 addSource(Source);
292 } 317 }
318
319 InstX8632Xchg::InstX8632Xchg(Cfg *Func, Operand *Dest, Variable *Source)
320 : InstX8632(Func, InstX8632::Xchg, 2, llvm::dyn_cast<Variable>(Dest)) {
321 addSource(Dest);
322 addSource(Source);
323 }
293 324
294 // ======================== Dump routines ======================== // 325 // ======================== Dump routines ======================== //
295 326
296 void InstX8632::dump(const Cfg *Func) const { 327 void InstX8632::dump(const Cfg *Func) const {
297 Ostream &Str = Func->getContext()->getStrDump(); 328 Ostream &Str = Func->getContext()->getStrDump();
298 Str << "[X8632] "; 329 Str << "[X8632] ";
299 Inst::dump(Func); 330 Inst::dump(Func);
300 } 331 }
301 332
302 void InstX8632Label::emit(const Cfg *Func) const { 333 void InstX8632Label::emit(const Cfg *Func) const {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (ShiftReg && ShiftReg->getRegNum() == TargetX8632::Reg_ecx) { 422 if (ShiftReg && ShiftReg->getRegNum() == TargetX8632::Reg_ecx) {
392 Str << "cl"; 423 Str << "cl";
393 EmittedSrc1 = true; 424 EmittedSrc1 = true;
394 } 425 }
395 } 426 }
396 if (!EmittedSrc1) 427 if (!EmittedSrc1)
397 Inst->getSrc(1)->emit(Func); 428 Inst->getSrc(1)->emit(Func);
398 Str << "\n"; 429 Str << "\n";
399 } 430 }
400 431
432 template <> const char *InstX8632Neg::Opcode = "neg";
401 template <> const char *InstX8632Add::Opcode = "add"; 433 template <> const char *InstX8632Add::Opcode = "add";
402 template <> const char *InstX8632Adc::Opcode = "adc"; 434 template <> const char *InstX8632Adc::Opcode = "adc";
403 template <> const char *InstX8632Addss::Opcode = "addss"; 435 template <> const char *InstX8632Addss::Opcode = "addss";
404 template <> const char *InstX8632Sub::Opcode = "sub"; 436 template <> const char *InstX8632Sub::Opcode = "sub";
405 template <> const char *InstX8632Subss::Opcode = "subss"; 437 template <> const char *InstX8632Subss::Opcode = "subss";
406 template <> const char *InstX8632Sbb::Opcode = "sbb"; 438 template <> const char *InstX8632Sbb::Opcode = "sbb";
407 template <> const char *InstX8632And::Opcode = "and"; 439 template <> const char *InstX8632And::Opcode = "and";
408 template <> const char *InstX8632Or::Opcode = "or"; 440 template <> const char *InstX8632Or::Opcode = "or";
409 template <> const char *InstX8632Xor::Opcode = "xor"; 441 template <> const char *InstX8632Xor::Opcode = "xor";
410 template <> const char *InstX8632Pxor::Opcode = "pxor"; 442 template <> const char *InstX8632Pxor::Opcode = "pxor";
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 Str << "\tcdq\n"; 575 Str << "\tcdq\n";
544 } 576 }
545 577
546 void InstX8632Cdq::dump(const Cfg *Func) const { 578 void InstX8632Cdq::dump(const Cfg *Func) const {
547 Ostream &Str = Func->getContext()->getStrDump(); 579 Ostream &Str = Func->getContext()->getStrDump();
548 dumpDest(Func); 580 dumpDest(Func);
549 Str << " = cdq." << getSrc(0)->getType() << " "; 581 Str << " = cdq." << getSrc(0)->getType() << " ";
550 dumpSources(Func); 582 dumpSources(Func);
551 } 583 }
552 584
585 void InstX8632Cmpxchg::emit(const Cfg *Func) const {
586 Ostream &Str = Func->getContext()->getStrEmit();
587 assert(getSrcSize() == 3);
588 if (Locked) {
589 Str << "\tlock";
590 }
591 Str << "\tcmpxchg\t";
592 getSrc(0)->emit(Func);
593 Str << ", ";
594 getSrc(2)->emit(Func);
595 Str << "\n";
596 }
597
598 void InstX8632Cmpxchg::dump(const Cfg *Func) const {
599 Ostream &Str = Func->getContext()->getStrDump();
600 if (Locked) {
601 Str << "lock ";
602 }
603 Str << "cmpxchg." << getSrc(0)->getType() << " ";
604 dumpSources(Func);
605 }
606
607 void InstX8632Cmpxchg8b::emit(const Cfg *Func) const {
608 Ostream &Str = Func->getContext()->getStrEmit();
609 assert(getSrcSize() == 5);
610 if (Locked) {
611 Str << "\tlock";
612 }
613 Str << "\tcmpxchg8b\t";
614 getSrc(0)->emit(Func);
615 Str << "\n";
616 }
617
618 void InstX8632Cmpxchg8b::dump(const Cfg *Func) const {
619 Ostream &Str = Func->getContext()->getStrDump();
620 if (Locked) {
621 Str << "lock ";
622 }
623 Str << "cmpxchg8b ";
624 dumpSources(Func);
625 }
626
553 void InstX8632Cvt::emit(const Cfg *Func) const { 627 void InstX8632Cvt::emit(const Cfg *Func) const {
554 Ostream &Str = Func->getContext()->getStrEmit(); 628 Ostream &Str = Func->getContext()->getStrEmit();
555 assert(getSrcSize() == 1); 629 assert(getSrcSize() == 1);
556 Str << "\tcvts" << TypeX8632Attributes[getSrc(0)->getType()].CvtString << "2s" 630 Str << "\tcvts" << TypeX8632Attributes[getSrc(0)->getType()].CvtString << "2s"
557 << TypeX8632Attributes[getDest()->getType()].CvtString << "\t"; 631 << TypeX8632Attributes[getDest()->getType()].CvtString << "\t";
558 getDest()->emit(Func); 632 getDest()->emit(Func);
559 Str << ", "; 633 Str << ", ";
560 getSrc(0)->emit(Func); 634 getSrc(0)->emit(Func);
561 Str << "\n"; 635 Str << "\n";
562 } 636 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 void InstX8632Sqrtss::dump(const Cfg *Func) const { 1018 void InstX8632Sqrtss::dump(const Cfg *Func) const {
945 Ostream &Str = Func->getContext()->getStrDump(); 1019 Ostream &Str = Func->getContext()->getStrDump();
946 dumpDest(Func); 1020 dumpDest(Func);
947 Str << " = sqrt." << getDest()->getType() << " "; 1021 Str << " = sqrt." << getDest()->getType() << " ";
948 dumpSources(Func); 1022 dumpSources(Func);
949 } 1023 }
950 1024
951 void InstX8632Xadd::emit(const Cfg *Func) const { 1025 void InstX8632Xadd::emit(const Cfg *Func) const {
952 Ostream &Str = Func->getContext()->getStrEmit(); 1026 Ostream &Str = Func->getContext()->getStrEmit();
953 if (Locked) { 1027 if (Locked) {
954 Str << "\tlock xadd "; 1028 Str << "\tlock";
955 } else {
956 Str << "\txadd\t";
957 } 1029 }
1030 Str << "\txadd\t";
958 getSrc(0)->emit(Func); 1031 getSrc(0)->emit(Func);
959 Str << ", "; 1032 Str << ", ";
960 getSrc(1)->emit(Func); 1033 getSrc(1)->emit(Func);
961 Str << "\n"; 1034 Str << "\n";
962 } 1035 }
963 1036
964 void InstX8632Xadd::dump(const Cfg *Func) const { 1037 void InstX8632Xadd::dump(const Cfg *Func) const {
965 Ostream &Str = Func->getContext()->getStrDump(); 1038 Ostream &Str = Func->getContext()->getStrDump();
966 if (Locked) { 1039 if (Locked) {
967 Str << "lock "; 1040 Str << "lock ";
968 } 1041 }
969 Type Ty = getSrc(0)->getType(); 1042 Type Ty = getSrc(0)->getType();
970 Str << "xadd." << Ty << " "; 1043 Str << "xadd." << Ty << " ";
971 dumpSources(Func); 1044 dumpSources(Func);
972 } 1045 }
973 1046
1047 void InstX8632Xchg::emit(const Cfg *Func) const {
1048 Ostream &Str = Func->getContext()->getStrEmit();
1049 Str << "\txchg\t";
1050 getSrc(0)->emit(Func);
1051 Str << ", ";
1052 getSrc(1)->emit(Func);
1053 Str << "\n";
1054 }
1055
1056 void InstX8632Xchg::dump(const Cfg *Func) const {
1057 Ostream &Str = Func->getContext()->getStrDump();
1058 Type Ty = getSrc(0)->getType();
1059 Str << "xchg." << Ty << " ";
1060 dumpSources(Func);
1061 }
1062
974 void OperandX8632::dump(const Cfg *Func) const { 1063 void OperandX8632::dump(const Cfg *Func) const {
975 Ostream &Str = Func->getContext()->getStrDump(); 1064 Ostream &Str = Func->getContext()->getStrDump();
976 Str << "<OperandX8632>"; 1065 Str << "<OperandX8632>";
977 } 1066 }
978 1067
979 void OperandX8632Mem::emit(const Cfg *Func) const { 1068 void OperandX8632Mem::emit(const Cfg *Func) const {
980 Ostream &Str = Func->getContext()->getStrEmit(); 1069 Ostream &Str = Func->getContext()->getStrEmit();
981 Str << TypeX8632Attributes[getType()].WidthString << " "; 1070 Str << TypeX8632Attributes[getType()].WidthString << " ";
982 if (SegmentReg != DefaultSegment) { 1071 if (SegmentReg != DefaultSegment) {
983 assert(SegmentReg >= 0 && 1072 assert(SegmentReg >= 0 &&
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 default: 1186 default:
1098 Str << "???"; 1187 Str << "???";
1099 break; 1188 break;
1100 } 1189 }
1101 Str << "("; 1190 Str << "(";
1102 Var->dump(Func); 1191 Var->dump(Func);
1103 Str << ")"; 1192 Str << ")";
1104 } 1193 }
1105 1194
1106 } // end of namespace Ice 1195 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698