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

Side by Side Diff: src/IceInst.cpp

Issue 1182603004: Subzero: Transform suitable Load/Arith/Store sequences into RMW ops. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 5 years, 6 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/IceInst.h ('k') | src/IceInstX8632.h » ('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/IceInst.cpp - High-level instruction implementation ----===// 1 //===- subzero/src/IceInst.cpp - High-level 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 Inst class, primarily the various 10 // This file implements the Inst class, primarily the various
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 InstSelect::InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, 415 InstSelect::InstSelect(Cfg *Func, Variable *Dest, Operand *Condition,
416 Operand *SourceTrue, Operand *SourceFalse) 416 Operand *SourceTrue, Operand *SourceFalse)
417 : InstHighLevel(Func, Inst::Select, 3, Dest) { 417 : InstHighLevel(Func, Inst::Select, 3, Dest) {
418 assert(typeElementType(Condition->getType()) == IceType_i1); 418 assert(typeElementType(Condition->getType()) == IceType_i1);
419 addSource(Condition); 419 addSource(Condition);
420 addSource(SourceTrue); 420 addSource(SourceTrue);
421 addSource(SourceFalse); 421 addSource(SourceFalse);
422 } 422 }
423 423
424 InstStore::InstStore(Cfg *Func, Operand *Data, Operand *Addr) 424 InstStore::InstStore(Cfg *Func, Operand *Data, Operand *Addr)
425 : InstHighLevel(Func, Inst::Store, 2, nullptr) { 425 : InstHighLevel(Func, Inst::Store, 3, nullptr) {
426 addSource(Data); 426 addSource(Data);
427 addSource(Addr); 427 addSource(Addr);
428 // The 3rd operand is a dummy placeholder for the RMW beacon.
429 addSource(Data);
430 }
431
432 void InstStore::setRmwBeacon(Variable *Beacon) {
433 Dest = llvm::dyn_cast<Variable>(getData());
434 Srcs[2] = Beacon;
428 } 435 }
429 436
430 InstSwitch::InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source, 437 InstSwitch::InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source,
431 CfgNode *LabelDefault) 438 CfgNode *LabelDefault)
432 : InstHighLevel(Func, Inst::Switch, 1, nullptr), LabelDefault(LabelDefault), 439 : InstHighLevel(Func, Inst::Switch, 1, nullptr), LabelDefault(LabelDefault),
433 NumCases(NumCases) { 440 NumCases(NumCases) {
434 addSource(Source); 441 addSource(Source);
435 Values = Func->allocateArrayOf<uint64_t>(NumCases); 442 Values = Func->allocateArrayOf<uint64_t>(NumCases);
436 Labels = Func->allocateArrayOf<CfgNode *>(NumCases); 443 Labels = Func->allocateArrayOf<CfgNode *>(NumCases);
437 // Initialize in case buggy code doesn't set all entries 444 // Initialize in case buggy code doesn't set all entries
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 Str << " = load " << Ty << ", " << Ty << "* "; 747 Str << " = load " << Ty << ", " << Ty << "* ";
741 dumpSources(Func); 748 dumpSources(Func);
742 Str << ", align " << typeAlignInBytes(Ty); 749 Str << ", align " << typeAlignInBytes(Ty);
743 } 750 }
744 751
745 void InstStore::dump(const Cfg *Func) const { 752 void InstStore::dump(const Cfg *Func) const {
746 if (!ALLOW_DUMP) 753 if (!ALLOW_DUMP)
747 return; 754 return;
748 Ostream &Str = Func->getContext()->getStrDump(); 755 Ostream &Str = Func->getContext()->getStrDump();
749 Type Ty = getData()->getType(); 756 Type Ty = getData()->getType();
757 dumpDest(Func);
758 if (Dest)
759 Str << " = ";
750 Str << "store " << Ty << " "; 760 Str << "store " << Ty << " ";
751 getData()->dump(Func); 761 getData()->dump(Func);
752 Str << ", " << Ty << "* "; 762 Str << ", " << Ty << "* ";
753 getAddr()->dump(Func); 763 getAddr()->dump(Func);
754 Str << ", align " << typeAlignInBytes(Ty); 764 Str << ", align " << typeAlignInBytes(Ty);
765 if (getRmwBeacon()) {
766 Str << ", beacon ";
767 getRmwBeacon()->dump(Func);
768 }
755 } 769 }
756 770
757 void InstSwitch::dump(const Cfg *Func) const { 771 void InstSwitch::dump(const Cfg *Func) const {
758 if (!ALLOW_DUMP) 772 if (!ALLOW_DUMP)
759 return; 773 return;
760 Ostream &Str = Func->getContext()->getStrDump(); 774 Ostream &Str = Func->getContext()->getStrDump();
761 Type Ty = getComparison()->getType(); 775 Type Ty = getComparison()->getType();
762 Str << "switch " << Ty << " "; 776 Str << "switch " << Ty << " ";
763 getSrc(0)->dump(Func); 777 getSrc(0)->dump(Func);
764 Str << ", label %" << getLabelDefault()->getName() << " [\n"; 778 Str << ", label %" << getLabelDefault()->getName() << " [\n";
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 // preserve these. 935 // preserve these.
922 return true; 936 return true;
923 } 937 }
924 if (!Dest->hasReg() && !SrcVar->hasReg() && 938 if (!Dest->hasReg() && !SrcVar->hasReg() &&
925 Dest->getStackOffset() == SrcVar->getStackOffset()) 939 Dest->getStackOffset() == SrcVar->getStackOffset())
926 return true; 940 return true;
927 return false; 941 return false;
928 } 942 }
929 943
930 } // end of namespace Ice 944 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInst.h ('k') | src/IceInstX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698