[PBQP] Add support for graph-level metadata to the PBQP graph. This will be used
authorLang Hames <lhames@gmail.com>
Thu, 2 Oct 2014 04:17:36 +0000 (04:17 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 2 Oct 2014 04:17:36 +0000 (04:17 +0000)
in the future to attach useful information about the PBQP graph (e.g. the
associated MachineFunction, pointers to regalloc passes) to the graph itself,
making that information accessible to the solver. This should also allow the
PBQPBuilder interface to be simplified.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218848 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/PBQP/Graph.h
include/llvm/CodeGen/PBQP/RegAllocSolver.h

index a55f0ea96c0aa8607ff2d9ae632699ff981fa3b9..f4294e713e6f30b537affb7f6ba443a97f084bec 100644 (file)
@@ -56,6 +56,7 @@ namespace PBQP {
     typedef typename CostAllocator::MatrixPtr MatrixPtr;
     typedef typename SolverT::NodeMetadata NodeMetadata;
     typedef typename SolverT::EdgeMetadata EdgeMetadata;
     typedef typename CostAllocator::MatrixPtr MatrixPtr;
     typedef typename SolverT::NodeMetadata NodeMetadata;
     typedef typename SolverT::EdgeMetadata EdgeMetadata;
+    typedef typename SolverT::GraphMetadata GraphMetadata;
 
   private:
 
 
   private:
 
@@ -172,6 +173,7 @@ namespace PBQP {
 
     // ----- MEMBERS -----
 
 
     // ----- MEMBERS -----
 
+    GraphMetadata Metadata;
     CostAllocator CostAlloc;
     SolverT *Solver;
 
     CostAllocator CostAlloc;
     SolverT *Solver;
 
@@ -331,6 +333,12 @@ namespace PBQP {
     /// \brief Construct an empty PBQP graph.
     Graph() : Solver(nullptr) { }
 
     /// \brief Construct an empty PBQP graph.
     Graph() : Solver(nullptr) { }
 
+    /// \brief Get a reference to the graph metadata.
+    GraphMetadata& getMetadata() { return Metadata; }
+
+    /// \brief Get a const-reference to the graph metadata.
+    const GraphMetadata& getMetadata() const { return Metadata; }
+
     /// \brief Lock this graph to the given solver instance in preparation
     /// for running the solver. This method will call solver.handleAddNode for
     /// each node in the graph, and handleAddEdge for each edge, to give the
     /// \brief Lock this graph to the given solver instance in preparation
     /// for running the solver. This method will call solver.handleAddNode for
     /// each node in the graph, and handleAddEdge for each edge, to give the
index 977c34843bbdd93f5d7ff21de9fa96071e7ac662..4b6bf0e6c0082ac2a2df2841686ea058a29458cb 100644 (file)
@@ -144,6 +144,7 @@ namespace PBQP {
       typedef RegAlloc::NodeMetadata NodeMetadata;
 
       struct EdgeMetadata { };
       typedef RegAlloc::NodeMetadata NodeMetadata;
 
       struct EdgeMetadata { };
+      struct GraphMetadata { };
 
       typedef PBQP::Graph<RegAllocSolverImpl> Graph;
 
 
       typedef PBQP::Graph<RegAllocSolverImpl> Graph;