LLVM  14.0.0git
PBQPRAConstraint.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/PBQPRAConstraint.h --------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the PBQPBuilder interface, for classes which build PBQP
10 // instances to represent register allocation problems, and the RegAllocPBQP
11 // interface.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CODEGEN_PBQPRACONSTRAINT_H
16 #define LLVM_CODEGEN_PBQPRACONSTRAINT_H
17 
18 #include <algorithm>
19 #include <memory>
20 #include <vector>
21 
22 namespace llvm {
23 
24 namespace PBQP {
25 namespace RegAlloc {
26 
27 // Forward declare PBQP graph class.
28 class PBQPRAGraph;
29 
30 } // end namespace RegAlloc
31 } // end namespace PBQP
32 
34 
35 /// Abstract base for classes implementing PBQP register allocation
36 /// constraints (e.g. Spill-costs, interference, coalescing).
38 public:
39  virtual ~PBQPRAConstraint() = 0;
40  virtual void apply(PBQPRAGraph &G) = 0;
41 
42 private:
43  virtual void anchor();
44 };
45 
46 /// PBQP register allocation constraint composer.
47 ///
48 /// Constraints added to this list will be applied, in the order that they are
49 /// added, to the PBQP graph.
51 public:
52  void apply(PBQPRAGraph &G) override {
53  for (auto &C : Constraints)
54  C->apply(G);
55  }
56 
57  void addConstraint(std::unique_ptr<PBQPRAConstraint> C) {
58  if (C)
59  Constraints.push_back(std::move(C));
60  }
61 
62 private:
63  std::vector<std::unique_ptr<PBQPRAConstraint>> Constraints;
64 
65  void anchor() override;
66 };
67 
68 } // end namespace llvm
69 
70 #endif // LLVM_CODEGEN_PBQPRACONSTRAINT_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::RegAllocType::PBQP
@ PBQP
llvm::PBQPRAConstraint
Abstract base for classes implementing PBQP register allocation constraints (e.g.
Definition: PBQPRAConstraint.h:37
llvm::PBQPRAConstraint::~PBQPRAConstraint
virtual ~PBQPRAConstraint()=0
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::PBQP::RegAlloc::PBQPRAGraph
Definition: RegAllocPBQP.h:502
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::PBQPRAConstraint::apply
virtual void apply(PBQPRAGraph &G)=0
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::PBQPRAConstraintList
PBQP register allocation constraint composer.
Definition: PBQPRAConstraint.h:50
llvm::PBQPRAConstraintList::apply
void apply(PBQPRAGraph &G) override
Definition: PBQPRAConstraint.h:52
llvm::PBQPRAGraph
PBQP::RegAlloc::PBQPRAGraph PBQPRAGraph
Definition: PBQPRAConstraint.h:33
RegAlloc
static cl::opt< RegisterRegAlloc::FunctionPassCtor, false, RegisterPassParser< RegisterRegAlloc > > RegAlloc("regalloc", cl::Hidden, cl::init(&useDefaultRegisterAllocator), cl::desc("Register allocator to use"))
llvm::PBQPRAConstraintList::addConstraint
void addConstraint(std::unique_ptr< PBQPRAConstraint > C)
Definition: PBQPRAConstraint.h:57