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

Side by Side Diff: src/IceInst.cpp

Issue 1257283004: Iasm and obj lowering for advanced switch lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 5 years, 4 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/IceInstX86Base.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 /// \file 10 /// \file
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 : InstHighLevel(Func, Inst::FakeUse, 1, nullptr) { 509 : InstHighLevel(Func, Inst::FakeUse, 1, nullptr) {
510 assert(Src); 510 assert(Src);
511 addSource(Src); 511 addSource(Src);
512 } 512 }
513 513
514 InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked) 514 InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked)
515 : InstHighLevel(Func, Inst::FakeKill, 0, nullptr), Linked(Linked) {} 515 : InstHighLevel(Func, Inst::FakeKill, 0, nullptr), Linked(Linked) {}
516 516
517 InstJumpTable::InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default) 517 InstJumpTable::InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default)
518 : InstHighLevel(Func, Inst::JumpTable, 1, nullptr), 518 : InstHighLevel(Func, Inst::JumpTable, 1, nullptr),
519 LabelNumber(Func->getTarget()->makeNextLabelNumber()), 519 Id(Func->getTarget()->makeNextJumpTableNumber()), NumTargets(NumTargets) {
520 NumTargets(NumTargets) {
521 Targets = Func->allocateArrayOf<CfgNode *>(NumTargets); 520 Targets = Func->allocateArrayOf<CfgNode *>(NumTargets);
522 for (SizeT I = 0; I < NumTargets; ++I) 521 for (SizeT I = 0; I < NumTargets; ++I)
523 Targets[I] = Default; 522 Targets[I] = Default;
524 } 523 }
525 524
526 bool InstJumpTable::repointEdges(CfgNode *OldNode, CfgNode *NewNode) { 525 bool InstJumpTable::repointEdges(CfgNode *OldNode, CfgNode *NewNode) {
527 bool Found = false; 526 bool Found = false;
528 for (SizeT I = 0; I < NumTargets; ++I) { 527 for (SizeT I = 0; I < NumTargets; ++I) {
529 if (Targets[I] == OldNode) { 528 if (Targets[I] == OldNode) {
530 Targets[I] = NewNode; 529 Targets[I] = NewNode;
531 Found = true; 530 Found = true;
532 } 531 }
533 } 532 }
534 return Found; 533 return Found;
535 } 534 }
536 535
537 IceString InstJumpTable::getName(const Cfg *Func) const {
538 return ".L" + Func->getFunctionName() + "$jumptable$__" +
539 std::to_string(LabelNumber);
540 }
541
542 Type InstCall::getReturnType() const { 536 Type InstCall::getReturnType() const {
543 if (Dest == nullptr) 537 if (Dest == nullptr)
544 return IceType_void; 538 return IceType_void;
545 return Dest->getType(); 539 return Dest->getType();
546 } 540 }
547 541
548 // ======================== Dump routines ======================== // 542 // ======================== Dump routines ======================== //
549 543
550 void Inst::dumpDecorated(const Cfg *Func) const { 544 void Inst::dumpDecorated(const Cfg *Func) const {
551 if (!BuildDefs::dump()) 545 if (!BuildDefs::dump())
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 939
946 void InstFakeKill::dump(const Cfg *Func) const { 940 void InstFakeKill::dump(const Cfg *Func) const {
947 if (!BuildDefs::dump()) 941 if (!BuildDefs::dump())
948 return; 942 return;
949 Ostream &Str = Func->getContext()->getStrDump(); 943 Ostream &Str = Func->getContext()->getStrDump();
950 if (Linked->isDeleted()) 944 if (Linked->isDeleted())
951 Str << "// "; 945 Str << "// ";
952 Str << "kill.pseudo scratch_regs"; 946 Str << "kill.pseudo scratch_regs";
953 } 947 }
954 948
955 void InstJumpTable::emit(const Cfg *Func) const {
956 // TODO(ascull): should this be a target specific lowering (with access built
957 // in?) and just have InstJumpTable as a high level, similar to br? or should
958 // this follow the same path as emitIAS i.e. put it in global context and
959 // produce this code later?
960 if (!BuildDefs::dump())
961 return;
962 Ostream &Str = Func->getContext()->getStrEmit();
963 // TODO(ascull): softcode pointer size of 4
964 // TODO(ascull): is .long portable?
965 Str << "\n\t.section\t.rodata." << Func->getFunctionName()
966 << "$jumptable,\"a\",@progbits\n"
967 << "\t.align 4\n" << getName(Func) << ":";
968 for (SizeT I = 0; I < NumTargets; ++I)
969 Str << "\n\t.long\t" << Targets[I]->getAsmName();
970 Str << "\n\n\t.text";
971 }
972
973 void InstJumpTable::emitIAS(const Cfg *Func) const {
974 // TODO(ascull): put jump table in the global context for emission later
975 (void)Func;
976 }
977
978 void InstJumpTable::dump(const Cfg *Func) const { 949 void InstJumpTable::dump(const Cfg *Func) const {
979 if (!BuildDefs::dump()) 950 if (!BuildDefs::dump())
980 return; 951 return;
981 Ostream &Str = Func->getContext()->getStrDump(); 952 Ostream &Str = Func->getContext()->getStrDump();
982 Str << "jump table ["; 953 Str << "jump table [";
983 for (SizeT I = 0; I < NumTargets; ++I) 954 for (SizeT I = 0; I < NumTargets; ++I)
984 Str << "\n " << Targets[I]->getName(); 955 Str << "\n " << Targets[I]->getName();
985 Str << "\n ]"; 956 Str << "\n ]";
986 } 957 }
987 958
(...skipping 15 matching lines...) Expand all
1003 // preserve these. 974 // preserve these.
1004 return true; 975 return true;
1005 } 976 }
1006 if (!Dest->hasReg() && !SrcVar->hasReg() && 977 if (!Dest->hasReg() && !SrcVar->hasReg() &&
1007 Dest->getStackOffset() == SrcVar->getStackOffset()) 978 Dest->getStackOffset() == SrcVar->getStackOffset())
1008 return true; 979 return true;
1009 return false; 980 return false;
1010 } 981 }
1011 982
1012 } // end of namespace Ice 983 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInst.h ('k') | src/IceInstX86Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698