LLVM  4.0.0
PBQPRAConstraint.h
Go to the documentation of this file.
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 <memory>
20 #include <vector>
21 
22 namespace llvm {
23 namespace PBQP {
24 namespace RegAlloc {
25 // Forward declare PBQP graph class.
26 class PBQPRAGraph;
27 }
28 }
29 
30 class LiveIntervals;
32 class MachineFunction;
34 
36 
37 /// @brief Abstract base for classes implementing PBQP register allocation
38 /// constraints (e.g. Spill-costs, interference, coalescing).
40 public:
41  virtual ~PBQPRAConstraint() = 0;
42  virtual void apply(PBQPRAGraph &G) = 0;
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.
52 public:
53  void apply(PBQPRAGraph &G) override {
54  for (auto &C : Constraints)
55  C->apply(G);
56  }
57 
58  void addConstraint(std::unique_ptr<PBQPRAConstraint> C) {
59  if (C)
60  Constraints.push_back(std::move(C));
61  }
62 private:
63  std::vector<std::unique_ptr<PBQPRAConstraint>> Constraints;
64  void anchor() override;
65 };
66 
67 }
68 
69 #endif /* LLVM_CODEGEN_PBQPRACONSTRAINT_H */
PBQP register allocation constraint composer.
Abstract base for classes implementing PBQP register allocation constraints (e.g. ...
virtual void apply(PBQPRAGraph &G)=0
virtual ~PBQPRAConstraint()=0
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
void addConstraint(std::unique_ptr< PBQPRAConstraint > C)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const DataFlowGraph & G
Definition: RDFGraph.cpp:206
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
PBQP::RegAlloc::PBQPRAGraph PBQPRAGraph
static cl::opt< RegisterRegAlloc::FunctionPassCtor, false, RegisterPassParser< RegisterRegAlloc > > RegAlloc("regalloc", cl::init(&useDefaultRegisterAllocator), cl::desc("Register allocator to use"))
-regalloc=... command line option.
void apply(PBQPRAGraph &G) override