1 //===-- RegAllocPBQP.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the PBQPBuilder interface, for classes which build PBQP
11 // instances to represent register allocation problems, and the RegAllocPBQP
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CODEGEN_PBQPRACONSTRAINT_H
17 #define LLVM_CODEGEN_PBQPRACONSTRAINT_H
25 // Forward declare PBQP graph class.
31 class MachineBlockFrequencyInfo;
32 class MachineFunction;
33 class TargetRegisterInfo;
35 typedef PBQP::RegAlloc::PBQPRAGraph PBQPRAGraph;
37 /// @brief Abstract base for classes implementing PBQP register allocation
38 /// constraints (e.g. Spill-costs, interference, coalescing).
39 class PBQPRAConstraint {
41 virtual ~PBQPRAConstraint() = 0;
42 virtual void apply(PBQPRAGraph &G) = 0;
44 virtual void anchor();
47 /// @brief PBQP register allocation constraint composer.
49 /// Constraints added to this list will be applied, in the order that they are
50 /// added, to the PBQP graph.
51 class PBQPRAConstraintList : public PBQPRAConstraint {
53 void apply(PBQPRAGraph &G) override {
54 for (auto &C : Constraints)
58 void addConstraint(std::unique_ptr<PBQPRAConstraint> C) {
60 Constraints.push_back(std::move(C));
63 std::vector<std::unique_ptr<PBQPRAConstraint>> Constraints;
64 void anchor() override;
69 #endif /* LLVM_CODEGEN_PBQPRACONSTRAINT_H */