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

Side by Side Diff: src/IceInst.cpp

Issue 1860473002: Subzero. Refactors Switch Lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fixes pre-review issues. Created 4 years, 8 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/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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src, uint32_t Weight) 544 InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src, uint32_t Weight)
545 : InstHighLevel(Func, Inst::FakeUse, Weight, nullptr) { 545 : InstHighLevel(Func, Inst::FakeUse, Weight, nullptr) {
546 assert(Src); 546 assert(Src);
547 for (uint32_t i = 0; i < Weight; ++i) 547 for (uint32_t i = 0; i < Weight; ++i)
548 addSource(Src); 548 addSource(Src);
549 } 549 }
550 550
551 InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked) 551 InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked)
552 : InstHighLevel(Func, Inst::FakeKill, 0, nullptr), Linked(Linked) {} 552 : InstHighLevel(Func, Inst::FakeKill, 0, nullptr), Linked(Linked) {}
553 553
554 namespace {
555 GlobalString makeName(Cfg *Func, const SizeT Id) {
556 const auto FuncName = Func->getFunctionName();
557 auto *Ctx = Func->getContext();
558 if (FuncName.hasStdString())
559 return GlobalString::createWithString(
560 Ctx, ".L" + FuncName.toString() + "$jumptable$__" + std::to_string(Id));
561 return GlobalString::createWithString(
562 Ctx, ".L" + std::to_string(FuncName.getID()) + "_" + std::to_string(Id));
563 }
564 } // end of anonymous namespace
565
554 InstJumpTable::InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default) 566 InstJumpTable::InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default)
555 : InstHighLevel(Func, Inst::JumpTable, 1, nullptr), 567 : InstHighLevel(Func, Inst::JumpTable, 1, nullptr),
556 Id(Func->getTarget()->makeNextJumpTableNumber()), NumTargets(NumTargets) { 568 Id(Func->getTarget()->makeNextJumpTableNumber()), NumTargets(NumTargets),
569 Name(makeName(Func, Id)), FuncName(Func->getFunctionName()) {
557 Targets = Func->allocateArrayOf<CfgNode *>(NumTargets); 570 Targets = Func->allocateArrayOf<CfgNode *>(NumTargets);
558 for (SizeT I = 0; I < NumTargets; ++I) 571 for (SizeT I = 0; I < NumTargets; ++I) {
559 Targets[I] = Default; 572 Targets[I] = Default;
573 }
560 } 574 }
561 575
562 bool InstJumpTable::repointEdges(CfgNode *OldNode, CfgNode *NewNode) { 576 bool InstJumpTable::repointEdges(CfgNode *OldNode, CfgNode *NewNode) {
563 bool Found = false; 577 bool Found = false;
564 for (SizeT I = 0; I < NumTargets; ++I) { 578 for (SizeT I = 0; I < NumTargets; ++I) {
565 if (Targets[I] == OldNode) { 579 if (Targets[I] == OldNode) {
566 Targets[I] = NewNode; 580 Targets[I] = NewNode;
567 Found = true; 581 Found = true;
568 } 582 }
569 } 583 }
570 return Found; 584 return Found;
571 } 585 }
572 586
587 JumpTableData InstJumpTable::toJumpTableData(Assembler *Asm) const {
588 JumpTableData::TargetList TargetList(NumTargets);
589 for (SizeT i = 0; i < NumTargets; ++i) {
590 const SizeT Index = Targets[i]->getIndex();
591 TargetList[i] = Asm->getCfgNodeLabel(Index)->getPosition();
592 }
593 return JumpTableData(Name, FuncName, Id, TargetList);
594 }
595
573 Type InstCall::getReturnType() const { 596 Type InstCall::getReturnType() const {
574 if (Dest == nullptr) 597 if (Dest == nullptr)
575 return IceType_void; 598 return IceType_void;
576 return Dest->getType(); 599 return Dest->getType();
577 } 600 }
578 601
579 // ======================== Dump routines ======================== // 602 // ======================== Dump routines ======================== //
580 603
581 void Inst::dumpDecorated(const Cfg *Func) const { 604 void Inst::dumpDecorated(const Cfg *Func) const {
582 if (!BuildDefs::dump()) 605 if (!BuildDefs::dump())
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 // upper 32 bits of rax. We need to recognize and preserve these. 1038 // upper 32 bits of rax. We need to recognize and preserve these.
1016 return true; 1039 return true;
1017 } 1040 }
1018 if (!Dest->hasReg() && !SrcVar->hasReg() && 1041 if (!Dest->hasReg() && !SrcVar->hasReg() &&
1019 Dest->getStackOffset() == SrcVar->getStackOffset()) 1042 Dest->getStackOffset() == SrcVar->getStackOffset())
1020 return true; 1043 return true;
1021 return false; 1044 return false;
1022 } 1045 }
1023 1046
1024 } // end of namespace Ice 1047 } // end of namespace Ice
OLDNEW
« src/IceGlobalContext.h ('K') | « src/IceInst.h ('k') | src/IceSwitchLowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698