OLD | NEW |
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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src, uint32_t Weight) | 562 InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src, uint32_t Weight) |
563 : InstHighLevel(Func, Inst::FakeUse, Weight, nullptr) { | 563 : InstHighLevel(Func, Inst::FakeUse, Weight, nullptr) { |
564 assert(Src); | 564 assert(Src); |
565 for (uint32_t i = 0; i < Weight; ++i) | 565 for (uint32_t i = 0; i < Weight; ++i) |
566 addSource(Src); | 566 addSource(Src); |
567 } | 567 } |
568 | 568 |
569 InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked) | 569 InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked) |
570 : InstHighLevel(Func, Inst::FakeKill, 0, nullptr), Linked(Linked) {} | 570 : InstHighLevel(Func, Inst::FakeKill, 0, nullptr), Linked(Linked) {} |
571 | 571 |
| 572 namespace { |
| 573 GlobalString makeName(Cfg *Func, const SizeT Id) { |
| 574 const auto FuncName = Func->getFunctionName(); |
| 575 auto *Ctx = Func->getContext(); |
| 576 if (FuncName.hasStdString()) |
| 577 return GlobalString::createWithString( |
| 578 Ctx, ".L" + FuncName.toString() + "$jumptable$__" + std::to_string(Id)); |
| 579 return GlobalString::createWithString( |
| 580 Ctx, ".L" + std::to_string(FuncName.getID()) + "_" + std::to_string(Id)); |
| 581 } |
| 582 } // end of anonymous namespace |
| 583 |
572 InstJumpTable::InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default) | 584 InstJumpTable::InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default) |
573 : InstHighLevel(Func, Inst::JumpTable, 1, nullptr), | 585 : InstHighLevel(Func, Inst::JumpTable, 1, nullptr), |
574 Id(Func->getTarget()->makeNextJumpTableNumber()), NumTargets(NumTargets) { | 586 Id(Func->getTarget()->makeNextJumpTableNumber()), NumTargets(NumTargets), |
| 587 Name(makeName(Func, Id)), FuncName(Func->getFunctionName()) { |
575 Targets = Func->allocateArrayOf<CfgNode *>(NumTargets); | 588 Targets = Func->allocateArrayOf<CfgNode *>(NumTargets); |
576 for (SizeT I = 0; I < NumTargets; ++I) | 589 for (SizeT I = 0; I < NumTargets; ++I) { |
577 Targets[I] = Default; | 590 Targets[I] = Default; |
| 591 } |
578 } | 592 } |
579 | 593 |
580 bool InstJumpTable::repointEdges(CfgNode *OldNode, CfgNode *NewNode) { | 594 bool InstJumpTable::repointEdges(CfgNode *OldNode, CfgNode *NewNode) { |
581 bool Found = false; | 595 bool Found = false; |
582 for (SizeT I = 0; I < NumTargets; ++I) { | 596 for (SizeT I = 0; I < NumTargets; ++I) { |
583 if (Targets[I] == OldNode) { | 597 if (Targets[I] == OldNode) { |
584 Targets[I] = NewNode; | 598 Targets[I] = NewNode; |
585 Found = true; | 599 Found = true; |
586 } | 600 } |
587 } | 601 } |
588 return Found; | 602 return Found; |
589 } | 603 } |
590 | 604 |
| 605 JumpTableData InstJumpTable::toJumpTableData(Assembler *Asm) const { |
| 606 JumpTableData::TargetList TargetList(NumTargets); |
| 607 for (SizeT i = 0; i < NumTargets; ++i) { |
| 608 const SizeT Index = Targets[i]->getIndex(); |
| 609 TargetList[i] = Asm->getCfgNodeLabel(Index)->getPosition(); |
| 610 } |
| 611 return JumpTableData(Name, FuncName, Id, TargetList); |
| 612 } |
| 613 |
591 Type InstCall::getReturnType() const { | 614 Type InstCall::getReturnType() const { |
592 if (Dest == nullptr) | 615 if (Dest == nullptr) |
593 return IceType_void; | 616 return IceType_void; |
594 return Dest->getType(); | 617 return Dest->getType(); |
595 } | 618 } |
596 | 619 |
597 // ======================== Dump routines ======================== // | 620 // ======================== Dump routines ======================== // |
598 | 621 |
599 void Inst::dumpDecorated(const Cfg *Func) const { | 622 void Inst::dumpDecorated(const Cfg *Func) const { |
600 if (!BuildDefs::dump()) | 623 if (!BuildDefs::dump()) |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 // upper 32 bits of rax. We need to recognize and preserve these. | 1056 // upper 32 bits of rax. We need to recognize and preserve these. |
1034 return true; | 1057 return true; |
1035 } | 1058 } |
1036 if (!Dest->hasReg() && !SrcVar->hasReg() && | 1059 if (!Dest->hasReg() && !SrcVar->hasReg() && |
1037 Dest->getStackOffset() == SrcVar->getStackOffset()) | 1060 Dest->getStackOffset() == SrcVar->getStackOffset()) |
1038 return true; | 1061 return true; |
1039 return false; | 1062 return false; |
1040 } | 1063 } |
1041 | 1064 |
1042 } // end of namespace Ice | 1065 } // end of namespace Ice |
OLD | NEW |