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

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: rebase 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
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceIntrinsics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 *InstX8632Addps::Opcode = "addps"; 434 template <> const char *InstX8632Addps::Opcode = "addps";
403 template <> const char *InstX8632Adc::Opcode = "adc"; 435 template <> const char *InstX8632Adc::Opcode = "adc";
404 template <> const char *InstX8632Addss::Opcode = "addss"; 436 template <> const char *InstX8632Addss::Opcode = "addss";
405 template <> const char *InstX8632Sub::Opcode = "sub"; 437 template <> const char *InstX8632Sub::Opcode = "sub";
406 template <> const char *InstX8632Subps::Opcode = "subps"; 438 template <> const char *InstX8632Subps::Opcode = "subps";
407 template <> const char *InstX8632Subss::Opcode = "subss"; 439 template <> const char *InstX8632Subss::Opcode = "subss";
408 template <> const char *InstX8632Sbb::Opcode = "sbb"; 440 template <> const char *InstX8632Sbb::Opcode = "sbb";
409 template <> const char *InstX8632And::Opcode = "and"; 441 template <> const char *InstX8632And::Opcode = "and";
410 template <> const char *InstX8632Or::Opcode = "or"; 442 template <> const char *InstX8632Or::Opcode = "or";
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 Str << "\tcdq\n"; 579 Str << "\tcdq\n";
548 } 580 }
549 581
550 void InstX8632Cdq::dump(const Cfg *Func) const { 582 void InstX8632Cdq::dump(const Cfg *Func) const {
551 Ostream &Str = Func->getContext()->getStrDump(); 583 Ostream &Str = Func->getContext()->getStrDump();
552 dumpDest(Func); 584 dumpDest(Func);
553 Str << " = cdq." << getSrc(0)->getType() << " "; 585 Str << " = cdq." << getSrc(0)->getType() << " ";
554 dumpSources(Func); 586 dumpSources(Func);
555 } 587 }
556 588
589 void InstX8632Cmpxchg::emit(const Cfg *Func) const {
590 Ostream &Str = Func->getContext()->getStrEmit();
591 assert(getSrcSize() == 3);
592 if (Locked) {
593 Str << "\tlock";
594 }
595 Str << "\tcmpxchg\t";
596 getSrc(0)->emit(Func);
597 Str << ", ";
598 getSrc(2)->emit(Func);
599 Str << "\n";
600 }
601
602 void InstX8632Cmpxchg::dump(const Cfg *Func) const {
603 Ostream &Str = Func->getContext()->getStrDump();
604 if (Locked) {
605 Str << "lock ";
606 }
607 Str << "cmpxchg." << getSrc(0)->getType() << " ";
608 dumpSources(Func);
609 }
610
611 void InstX8632Cmpxchg8b::emit(const Cfg *Func) const {
612 Ostream &Str = Func->getContext()->getStrEmit();
613 assert(getSrcSize() == 5);
614 if (Locked) {
615 Str << "\tlock";
616 }
617 Str << "\tcmpxchg8b\t";
618 getSrc(0)->emit(Func);
619 Str << "\n";
620 }
621
622 void InstX8632Cmpxchg8b::dump(const Cfg *Func) const {
623 Ostream &Str = Func->getContext()->getStrDump();
624 if (Locked) {
625 Str << "lock ";
626 }
627 Str << "cmpxchg8b ";
628 dumpSources(Func);
629 }
630
557 void InstX8632Cvt::emit(const Cfg *Func) const { 631 void InstX8632Cvt::emit(const Cfg *Func) const {
558 Ostream &Str = Func->getContext()->getStrEmit(); 632 Ostream &Str = Func->getContext()->getStrEmit();
559 assert(getSrcSize() == 1); 633 assert(getSrcSize() == 1);
560 Str << "\tcvts" << TypeX8632Attributes[getSrc(0)->getType()].CvtString << "2s" 634 Str << "\tcvts" << TypeX8632Attributes[getSrc(0)->getType()].CvtString << "2s"
561 << TypeX8632Attributes[getDest()->getType()].CvtString << "\t"; 635 << TypeX8632Attributes[getDest()->getType()].CvtString << "\t";
562 getDest()->emit(Func); 636 getDest()->emit(Func);
563 Str << ", "; 637 Str << ", ";
564 getSrc(0)->emit(Func); 638 getSrc(0)->emit(Func);
565 Str << "\n"; 639 Str << "\n";
566 } 640 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 void InstX8632Sqrtss::dump(const Cfg *Func) const { 1022 void InstX8632Sqrtss::dump(const Cfg *Func) const {
949 Ostream &Str = Func->getContext()->getStrDump(); 1023 Ostream &Str = Func->getContext()->getStrDump();
950 dumpDest(Func); 1024 dumpDest(Func);
951 Str << " = sqrt." << getDest()->getType() << " "; 1025 Str << " = sqrt." << getDest()->getType() << " ";
952 dumpSources(Func); 1026 dumpSources(Func);
953 } 1027 }
954 1028
955 void InstX8632Xadd::emit(const Cfg *Func) const { 1029 void InstX8632Xadd::emit(const Cfg *Func) const {
956 Ostream &Str = Func->getContext()->getStrEmit(); 1030 Ostream &Str = Func->getContext()->getStrEmit();
957 if (Locked) { 1031 if (Locked) {
958 Str << "\tlock xadd "; 1032 Str << "\tlock";
959 } else {
960 Str << "\txadd\t";
961 } 1033 }
1034 Str << "\txadd\t";
962 getSrc(0)->emit(Func); 1035 getSrc(0)->emit(Func);
963 Str << ", "; 1036 Str << ", ";
964 getSrc(1)->emit(Func); 1037 getSrc(1)->emit(Func);
965 Str << "\n"; 1038 Str << "\n";
966 } 1039 }
967 1040
968 void InstX8632Xadd::dump(const Cfg *Func) const { 1041 void InstX8632Xadd::dump(const Cfg *Func) const {
969 Ostream &Str = Func->getContext()->getStrDump(); 1042 Ostream &Str = Func->getContext()->getStrDump();
970 if (Locked) { 1043 if (Locked) {
971 Str << "lock "; 1044 Str << "lock ";
972 } 1045 }
973 Type Ty = getSrc(0)->getType(); 1046 Type Ty = getSrc(0)->getType();
974 Str << "xadd." << Ty << " "; 1047 Str << "xadd." << Ty << " ";
975 dumpSources(Func); 1048 dumpSources(Func);
976 } 1049 }
977 1050
1051 void InstX8632Xchg::emit(const Cfg *Func) const {
1052 Ostream &Str = Func->getContext()->getStrEmit();
1053 Str << "\txchg\t";
1054 getSrc(0)->emit(Func);
1055 Str << ", ";
1056 getSrc(1)->emit(Func);
1057 Str << "\n";
1058 }
1059
1060 void InstX8632Xchg::dump(const Cfg *Func) const {
1061 Ostream &Str = Func->getContext()->getStrDump();
1062 Type Ty = getSrc(0)->getType();
1063 Str << "xchg." << Ty << " ";
1064 dumpSources(Func);
1065 }
1066
978 void OperandX8632::dump(const Cfg *Func) const { 1067 void OperandX8632::dump(const Cfg *Func) const {
979 Ostream &Str = Func->getContext()->getStrDump(); 1068 Ostream &Str = Func->getContext()->getStrDump();
980 Str << "<OperandX8632>"; 1069 Str << "<OperandX8632>";
981 } 1070 }
982 1071
983 void OperandX8632Mem::emit(const Cfg *Func) const { 1072 void OperandX8632Mem::emit(const Cfg *Func) const {
984 Ostream &Str = Func->getContext()->getStrEmit(); 1073 Ostream &Str = Func->getContext()->getStrEmit();
985 Str << TypeX8632Attributes[getType()].WidthString << " "; 1074 Str << TypeX8632Attributes[getType()].WidthString << " ";
986 if (SegmentReg != DefaultSegment) { 1075 if (SegmentReg != DefaultSegment) {
987 assert(SegmentReg >= 0 && 1076 assert(SegmentReg >= 0 &&
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 default: 1190 default:
1102 Str << "???"; 1191 Str << "???";
1103 break; 1192 break;
1104 } 1193 }
1105 Str << "("; 1194 Str << "(";
1106 Var->dump(Func); 1195 Var->dump(Func);
1107 Str << ")"; 1196 Str << ")";
1108 } 1197 }
1109 1198
1110 } // end of namespace Ice 1199 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceIntrinsics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698