[llvm-commits] [llvm] r45333 - /llvm/trunk/include/llvm/CodeGen/MachineDominators.h
Chris Lattner
clattner at apple.com
Sun Dec 23 10:57:37 PST 2007
> URL: http://llvm.org/viewvc/llvm-project?rev=45333&view=rev
> Log:
> Add GraphTraits specializations for machine dominators.
Nifty.
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/include/llvm/CodeGen/MachineDominators.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/MachineDominators.h Sun Dec 23
> 09:16:46 2007
> @@ -21,6 +21,7 @@
> #include "llvm/CodeGen/MachineInstr.h"
> #include "llvm/Analysis/Dominators.h"
> #include "llvm/Analysis/DominatorInternals.h"
> +#include "llvm/ADT/GraphTraits.h"
You should be able to just forward declare GraphTraits, instead of
#including it.
Thanks Owen,
-Chris
>
> namespace llvm {
>
> @@ -182,6 +183,32 @@
> }
> };
>
> +//===-------------------------------------
> +/// DominatorTree GraphTraits specialization so the DominatorTree
> can be
> +/// iterable by generic graph iterators.
> +///
> +template <> struct GraphTraits<MachineDomTreeNode *> {
> + typedef MachineDomTreeNode NodeType;
> + typedef NodeType::iterator ChildIteratorType;
> +
> + static NodeType *getEntryNode(NodeType *N) {
> + return N;
> + }
> + static inline ChildIteratorType child_begin(NodeType* N) {
> + return N->begin();
> + }
> + static inline ChildIteratorType child_end(NodeType* N) {
> + return N->end();
> + }
> +};
> +
> +template <> struct GraphTraits<MachineDominatorTree*>
> + : public GraphTraits<MachineDomTreeNode *> {
> + static NodeType *getEntryNode(MachineDominatorTree *DT) {
> + return DT->getRootNode();
> + }
> +};
> +
> }
>
> #endif
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list