LCOV - code coverage report
Current view: top level - include/llvm/CodeGen - PBQPRAConstraint.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 8 8 100.0 %
Date: 2017-09-14 15:23:50 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- RegAllocPBQP.h -------------------------------------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file defines the PBQPBuilder interface, for classes which build PBQP
      11             : // instances to represent register allocation problems, and the RegAllocPBQP
      12             : // interface.
      13             : //
      14             : //===----------------------------------------------------------------------===//
      15             : 
      16             : #ifndef LLVM_CODEGEN_PBQPRACONSTRAINT_H
      17             : #define LLVM_CODEGEN_PBQPRACONSTRAINT_H
      18             : 
      19             : #include <algorithm>
      20             : #include <memory>
      21             : #include <vector>
      22             : 
      23             : namespace llvm {
      24             : 
      25             : namespace PBQP {
      26             : namespace RegAlloc {
      27             : 
      28             : // Forward declare PBQP graph class.
      29             : class PBQPRAGraph;
      30             : 
      31             : } // end namespace RegAlloc
      32             : } // end namespace PBQP
      33             : 
      34             : using PBQPRAGraph = PBQP::RegAlloc::PBQPRAGraph;
      35             : 
      36             : /// @brief Abstract base for classes implementing PBQP register allocation
      37             : ///        constraints (e.g. Spill-costs, interference, coalescing).
      38          31 : class PBQPRAConstraint {
      39             : public:
      40             :   virtual ~PBQPRAConstraint() = 0;
      41             :   virtual void apply(PBQPRAGraph &G) = 0;
      42             : 
      43             : private:
      44             :   virtual void anchor();
      45             : };
      46             : 
      47             : /// @brief PBQP register allocation constraint composer.
      48             : ///
      49             : ///   Constraints added to this list will be applied, in the order that they are
      50             : /// added, to the PBQP graph.
      51          21 : class PBQPRAConstraintList : public PBQPRAConstraint {
      52             : public:
      53           8 :   void apply(PBQPRAGraph &G) override {
      54          58 :     for (auto &C : Constraints)
      55          26 :       C->apply(G);
      56           8 :   }
      57             : 
      58             :   void addConstraint(std::unique_ptr<PBQPRAConstraint> C) {
      59          26 :     if (C)
      60          24 :       Constraints.push_back(std::move(C));
      61             :   }
      62             : 
      63             : private:
      64             :   std::vector<std::unique_ptr<PBQPRAConstraint>> Constraints;
      65             : 
      66             :   void anchor() override;
      67             : };
      68             : 
      69             : } // end namespace llvm
      70             : 
      71             : #endif // LLVM_CODEGEN_PBQPRACONSTRAINT_H

Generated by: LCOV version 1.13