From 9e7919785ee375540a67622fa19f7d10592c3351 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 18 Apr 2007 05:25:09 +0000 Subject: [PATCH] Add accessor to get the blocks immediately dominated by a given block to ETForest. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36251 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/Dominators.h | 14 ++++++++++++++ include/llvm/Analysis/ET-Forest.h | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index c8e753c1495..778b4eab759 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -327,6 +327,20 @@ public: const ETNode *idom = NodeA->getFather(); return idom ? idom->getData() : 0; } + + void getChildren(BasicBlock *A, std::vector& children) { + ETNode *NodeA = getNode(A); + const ETNode* son = NodeA->getSon(); + + if (!son) return; + children.push_back(son->getData()); + + const ETNode* brother = son->getBrother(); + while (brother != son) { + children.push_back(brother->getData()); + brother = brother->getBrother(); + } + } virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); diff --git a/include/llvm/Analysis/ET-Forest.h b/include/llvm/Analysis/ET-Forest.h index f41e1f59c9b..8bd5e447bca 100644 --- a/include/llvm/Analysis/ET-Forest.h +++ b/include/llvm/Analysis/ET-Forest.h @@ -275,6 +275,14 @@ public: return DFSNumOut; } + const ETNode *getSon() const { + return Son; + } + + const ETNode *getBrother() const { + return Left; + } + private: // Data represented by the node void *data;