+//===-- HeuristicSolver.h - Heuristic PBQP Solver --------------*- C++ --*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Heuristic PBQP solver. This solver is able to perform optimal reductions for
+// nodes of degree 0, 1 or 2. For nodes of degree >2 a plugable heuristic is
+// used to to select a node for reduction.
+//
+//===----------------------------------------------------------------------===//
+
#ifndef LLVM_CODEGEN_PBQP_HEURISTICSOLVER_H
#define LLVM_CODEGEN_PBQP_HEURISTICSOLVER_H
typedef std::vector<GraphNodeIterator> NodeStack;
typedef typename NodeStack::iterator NodeStackIterator;
- /*!
- * \brief Constructor, which performs all the actual solver work.
- */
+ /// \brief Constructor, which performs all the actual solver work.
HeuristicSolverImpl(const SimpleGraph &orig) :
solution(orig.getNumNodes(), true)
{
computeSolutionCost(orig);
}
- /*!
- * \brief Returns the graph for this solver.
- */
+ /// \brief Returns the graph for this solver.
SolverGraph& getGraph() { return g; }
- /*!
- * \brief Return the solution found by this solver.
- */
+ /// \brief Return the solution found by this solver.
const Solution& getSolution() const { return solution; }
private:
- /*!
- * \brief Add the given node to the appropriate bucket for its link
- * degree.
- */
+ /// \brief Add the given node to the appropriate bucket for its link
+ /// degree.
void addToBucket(const GraphNodeIterator &nodeItr) {
NodeData &nodeData = g.getNodeData(nodeItr);
}
}
- /*!
- * \brief Remove the given node from the appropriate bucket for its link
- * degree.
- */
+ /// \brief Remove the given node from the appropriate bucket for its link
+ /// degree.
void removeFromBucket(const GraphNodeIterator &nodeItr) {
NodeData &nodeData = g.getNodeData(nodeItr);
public:
- /*!
- * \brief Add a link.
- */
+ /// \brief Add a link.
void addLink(const GraphEdgeIterator &edgeItr) {
g.getEdgeData(edgeItr).setup(edgeItr);
}
}
- /*!
- * \brief Remove link, update info for node.
- *
- * Only updates information for the given node, since usually the other
- * is about to be removed.
- */
+ /// \brief Remove link, update info for node.
+ ///
+ /// Only updates information for the given node, since usually the other
+ /// is about to be removed.
void removeLink(const GraphEdgeIterator &edgeItr,
const GraphNodeIterator &nodeItr) {
g.getEdgeData(edgeItr).unlink();
}
- /*!
- * \brief Remove link, update info for both nodes. Useful for R2 only.
- */
+ /// \brief Remove link, update info for both nodes. Useful for R2 only.
void removeLinkR2(const GraphEdgeIterator &edgeItr) {
GraphNodeIterator node1Itr = g.getEdgeNode1Itr(edgeItr);
removeLink(edgeItr, g.getEdgeNode2Itr(edgeItr));
}
- /*!
- * \brief Removes all links connected to the given node.
- */
+ /// \brief Removes all links connected to the given node.
void unlinkNode(const GraphNodeIterator &nodeItr) {
NodeData &nodeData = g.getNodeData(nodeItr);
}
}
- /*!
- * \brief Push the given node onto the stack to be solved with
- * backpropagation.
- */
+ /// \brief Push the given node onto the stack to be solved with
+ /// backpropagation.
void pushStack(const GraphNodeIterator &nodeItr) {
stack.push_back(nodeItr);
}
- /*!
- * \brief Set the solution of the given node.
- */
+ /// \brief Set the solution of the given node.
void setSolution(const GraphNodeIterator &nodeItr, unsigned solIndex) {
solution.setSelection(g.getNodeID(nodeItr), solIndex);