PBQPRAConstraint.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef LLVM_CODEGEN_PBQPRACONSTRAINT_H
  16. #define LLVM_CODEGEN_PBQPRACONSTRAINT_H
  17. #include <memory>
  18. #include <vector>
  19. namespace llvm {
  20. namespace PBQP {
  21. namespace RegAlloc {
  22. // Forward declare PBQP graph class.
  23. class PBQPRAGraph;
  24. }
  25. }
  26. class LiveIntervals;
  27. class MachineBlockFrequencyInfo;
  28. class MachineFunction;
  29. class TargetRegisterInfo;
  30. typedef PBQP::RegAlloc::PBQPRAGraph PBQPRAGraph;
  31. /// @brief Abstract base for classes implementing PBQP register allocation
  32. /// constraints (e.g. Spill-costs, interference, coalescing).
  33. class PBQPRAConstraint {
  34. public:
  35. virtual ~PBQPRAConstraint() = 0;
  36. virtual void apply(PBQPRAGraph &G) = 0;
  37. private:
  38. virtual void anchor();
  39. };
  40. /// @brief PBQP register allocation constraint composer.
  41. ///
  42. /// Constraints added to this list will be applied, in the order that they are
  43. /// added, to the PBQP graph.
  44. class PBQPRAConstraintList : public PBQPRAConstraint {
  45. public:
  46. void apply(PBQPRAGraph &G) override {
  47. for (auto &C : Constraints)
  48. C->apply(G);
  49. }
  50. void addConstraint(std::unique_ptr<PBQPRAConstraint> C) {
  51. if (C)
  52. Constraints.push_back(std::move(C));
  53. }
  54. private:
  55. std::vector<std::unique_ptr<PBQPRAConstraint>> Constraints;
  56. void anchor() override;
  57. };
  58. }
  59. #endif /* LLVM_CODEGEN_PBQPRACONSTRAINT_H */