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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/IceInst.cpp
diff --git a/src/IceInst.cpp b/src/IceInst.cpp
index f6e8974fa1d1382dca082fe83b93bf50c1e0130f..655c2707bb785a9abeb1ee5dd36968f153691753 100644
--- a/src/IceInst.cpp
+++ b/src/IceInst.cpp
@@ -551,12 +551,26 @@ InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src, uint32_t Weight)
InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked)
: InstHighLevel(Func, Inst::FakeKill, 0, nullptr), Linked(Linked) {}
+namespace {
+GlobalString makeName(Cfg *Func, const SizeT Id) {
+ const auto FuncName = Func->getFunctionName();
+ auto *Ctx = Func->getContext();
+ if (FuncName.hasStdString())
+ return GlobalString::createWithString(
+ Ctx, ".L" + FuncName.toString() + "$jumptable$__" + std::to_string(Id));
+ return GlobalString::createWithString(
+ Ctx, ".L" + std::to_string(FuncName.getID()) + "_" + std::to_string(Id));
+}
+} // end of anonymous namespace
+
InstJumpTable::InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default)
: InstHighLevel(Func, Inst::JumpTable, 1, nullptr),
- Id(Func->getTarget()->makeNextJumpTableNumber()), NumTargets(NumTargets) {
+ Id(Func->getTarget()->makeNextJumpTableNumber()), NumTargets(NumTargets),
+ Name(makeName(Func, Id)), FuncName(Func->getFunctionName()) {
Targets = Func->allocateArrayOf<CfgNode *>(NumTargets);
- for (SizeT I = 0; I < NumTargets; ++I)
+ for (SizeT I = 0; I < NumTargets; ++I) {
Targets[I] = Default;
+ }
}
bool InstJumpTable::repointEdges(CfgNode *OldNode, CfgNode *NewNode) {
@@ -570,6 +584,15 @@ bool InstJumpTable::repointEdges(CfgNode *OldNode, CfgNode *NewNode) {
return Found;
}
+JumpTableData InstJumpTable::toJumpTableData(Assembler *Asm) const {
+ JumpTableData::TargetList TargetList(NumTargets);
+ for (SizeT i = 0; i < NumTargets; ++i) {
+ const SizeT Index = Targets[i]->getIndex();
+ TargetList[i] = Asm->getCfgNodeLabel(Index)->getPosition();
+ }
+ return JumpTableData(Name, FuncName, Id, TargetList);
+}
+
Type InstCall::getReturnType() const {
if (Dest == nullptr)
return IceType_void;
« 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