mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 02:25:19 +00:00
blockfreq: Use a pointer for ContainingLoop too
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206858 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -958,16 +958,25 @@ public:
|
|||||||
/// \brief Index of loop information.
|
/// \brief Index of loop information.
|
||||||
struct WorkingData {
|
struct WorkingData {
|
||||||
LoopData *Loop; ///< The loop this block is the header of.
|
LoopData *Loop; ///< The loop this block is the header of.
|
||||||
BlockNode ContainingLoop; ///< The block whose loop this block is inside.
|
LoopData *ContainingLoop; ///< The block whose loop this block is inside.
|
||||||
bool IsPackaged; ///< Has ContainingLoop been packaged up?
|
|
||||||
BlockMass Mass; ///< Mass distribution from the entry block.
|
BlockMass Mass; ///< Mass distribution from the entry block.
|
||||||
|
|
||||||
WorkingData() : Loop(nullptr), IsPackaged(false) {}
|
WorkingData() : Loop(nullptr), ContainingLoop(nullptr) {}
|
||||||
|
|
||||||
bool hasLoopHeader() const { return ContainingLoop.isValid(); }
|
bool hasLoopHeader() const { return ContainingLoop; }
|
||||||
bool isLoopHeader() const { return Loop; }
|
bool isLoopHeader() const { return Loop; }
|
||||||
|
|
||||||
/// \brief Has this block's loop been packaged up?
|
BlockNode getContainingHeader() const {
|
||||||
|
if (ContainingLoop)
|
||||||
|
return ContainingLoop->Header;
|
||||||
|
return BlockNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Has ContainingLoop been packaged up?
|
||||||
|
bool isPackaged() const {
|
||||||
|
return ContainingLoop && ContainingLoop->IsPackaged;
|
||||||
|
}
|
||||||
|
/// \brief Has Loop been packaged up?
|
||||||
bool isAPackage() const { return Loop && Loop->IsPackaged; }
|
bool isAPackage() const { return Loop && Loop->IsPackaged; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1041,7 +1050,7 @@ public:
|
|||||||
/// \brief Loop data: see initializeLoops().
|
/// \brief Loop data: see initializeLoops().
|
||||||
std::vector<WorkingData> Working;
|
std::vector<WorkingData> Working;
|
||||||
|
|
||||||
/// \brief Indexed information about packaged loops.
|
/// \brief Indexed information about loops.
|
||||||
std::vector<std::unique_ptr<LoopData>> PackagedLoops;
|
std::vector<std::unique_ptr<LoopData>> PackagedLoops;
|
||||||
|
|
||||||
/// \brief Add all edges out of a packaged loop to the distribution.
|
/// \brief Add all edges out of a packaged loop to the distribution.
|
||||||
@@ -1452,7 +1461,7 @@ template <class BT> void BlockFrequencyInfoImpl<BT>::initializeLoops() {
|
|||||||
const auto &HeaderData = Working[Header.Index];
|
const auto &HeaderData = Working[Header.Index];
|
||||||
assert(HeaderData.isLoopHeader());
|
assert(HeaderData.isLoopHeader());
|
||||||
|
|
||||||
Working[Index].ContainingLoop = Header;
|
Working[Index].ContainingLoop = HeaderData.Loop;
|
||||||
HeaderData.Loop->Members.push_back(Index);
|
HeaderData.Loop->Members.push_back(Index);
|
||||||
DEBUG(dbgs() << " - loop = " << getBlockName(Header)
|
DEBUG(dbgs() << " - loop = " << getBlockName(Header)
|
||||||
<< ": member = " << getBlockName(Index) << "\n");
|
<< ": member = " << getBlockName(Index) << "\n");
|
||||||
|
@@ -630,11 +630,11 @@ static void cleanup(BlockFrequencyInfoImplBase &BFI) {
|
|||||||
static BlockNode getPackagedNode(const BlockFrequencyInfoImplBase &BFI,
|
static BlockNode getPackagedNode(const BlockFrequencyInfoImplBase &BFI,
|
||||||
const BlockNode &Node) {
|
const BlockNode &Node) {
|
||||||
assert(Node.isValid());
|
assert(Node.isValid());
|
||||||
if (!BFI.Working[Node.Index].IsPackaged)
|
if (!BFI.Working[Node.Index].isPackaged())
|
||||||
return Node;
|
return Node;
|
||||||
if (!BFI.Working[Node.Index].ContainingLoop.isValid())
|
if (!BFI.Working[Node.Index].isAPackage())
|
||||||
return Node;
|
return Node;
|
||||||
return getPackagedNode(BFI, BFI.Working[Node.Index].ContainingLoop);
|
return getPackagedNode(BFI, BFI.Working[Node.Index].getContainingHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Get the appropriate mass for a possible pseudo-node loop package.
|
/// \brief Get the appropriate mass for a possible pseudo-node loop package.
|
||||||
@@ -645,7 +645,7 @@ static BlockNode getPackagedNode(const BlockFrequencyInfoImplBase &BFI,
|
|||||||
static BlockMass &getPackageMass(BlockFrequencyInfoImplBase &BFI,
|
static BlockMass &getPackageMass(BlockFrequencyInfoImplBase &BFI,
|
||||||
const BlockNode &Node) {
|
const BlockNode &Node) {
|
||||||
assert(Node.isValid());
|
assert(Node.isValid());
|
||||||
assert(!BFI.Working[Node.Index].IsPackaged);
|
assert(!BFI.Working[Node.Index].isPackaged());
|
||||||
if (!BFI.Working[Node.Index].isAPackage())
|
if (!BFI.Working[Node.Index].isAPackage())
|
||||||
return BFI.Working[Node.Index].Mass;
|
return BFI.Working[Node.Index].Mass;
|
||||||
|
|
||||||
@@ -681,7 +681,7 @@ void BlockFrequencyInfoImplBase::addToDist(Distribution &Dist,
|
|||||||
BlockNode Resolved = getPackagedNode(*this, Succ);
|
BlockNode Resolved = getPackagedNode(*this, Succ);
|
||||||
assert(Resolved != LoopHead);
|
assert(Resolved != LoopHead);
|
||||||
|
|
||||||
if (Working[Resolved.Index].ContainingLoop != LoopHead) {
|
if (Working[Resolved.Index].getContainingHeader() != LoopHead) {
|
||||||
DEBUG(debugSuccessor(" exit ", Resolved));
|
DEBUG(debugSuccessor(" exit ", Resolved));
|
||||||
Dist.addExit(Resolved, Weight);
|
Dist.addExit(Resolved, Weight);
|
||||||
return;
|
return;
|
||||||
@@ -746,10 +746,10 @@ void BlockFrequencyInfoImplBase::packageLoop(const BlockNode &LoopHead) {
|
|||||||
DEBUG(dbgs() << "packaging-loop: " << getBlockName(LoopHead) << "\n");
|
DEBUG(dbgs() << "packaging-loop: " << getBlockName(LoopHead) << "\n");
|
||||||
auto &PackagedLoop = getLoopPackage(LoopHead);
|
auto &PackagedLoop = getLoopPackage(LoopHead);
|
||||||
PackagedLoop.IsPackaged = true;
|
PackagedLoop.IsPackaged = true;
|
||||||
for (const BlockNode &M : PackagedLoop.Members) {
|
DEBUG(for (const BlockNode &M
|
||||||
DEBUG(dbgs() << " - node: " << getBlockName(M.Index) << "\n");
|
: PackagedLoop.Members) {
|
||||||
Working[M.Index].IsPackaged = true;
|
dbgs() << " - node: " << getBlockName(M.Index) << "\n";
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockFrequencyInfoImplBase::distributeMass(const BlockNode &Source,
|
void BlockFrequencyInfoImplBase::distributeMass(const BlockNode &Source,
|
||||||
|
Reference in New Issue
Block a user