LLVM 22.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
19#include <algorithm>
20#include <memory>
21#include <vector>
22
23namespace llvm {
24
25namespace PBQP {
26namespace RegAlloc {
27
28// Forward declare PBQP graph class.
29class PBQPRAGraph;
30
31} // end namespace RegAlloc
32} // end namespace PBQP
33
35
36/// Abstract base for classes implementing PBQP register allocation
37/// constraints (e.g. Spill-costs, interference, coalescing).
39public:
40 virtual ~PBQPRAConstraint() = 0;
41 virtual void apply(PBQPRAGraph &G) = 0;
42
43private:
44 virtual void anchor();
45};
46
47/// 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.
52public:
53 // Explicitly non-copyable.
57
58 void apply(PBQPRAGraph &G) override {
59 for (auto &C : Constraints)
60 C->apply(G);
61 }
62
63 void addConstraint(std::unique_ptr<PBQPRAConstraint> C) {
64 if (C)
65 Constraints.push_back(std::move(C));
66 }
67
68private:
69 std::vector<std::unique_ptr<PBQPRAConstraint>> Constraints;
70
71 void anchor() override;
72};
73
74} // end namespace llvm
75
76#endif // LLVM_CODEGEN_PBQPRACONSTRAINT_H
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ABI
Definition: Compiler.h:213
#define G(x, y, z)
Definition: MD5.cpp:56
static cl::opt< RegisterRegAlloc::FunctionPassCtor, false, RegisterPassParser< RegisterRegAlloc > > RegAlloc("regalloc", cl::Hidden, cl::init(&useDefaultRegisterAllocator), cl::desc("Register allocator to use"))
PBQP register allocation constraint composer.
PBQPRAConstraintList & operator=(const PBQPRAConstraintList &)=delete
void addConstraint(std::unique_ptr< PBQPRAConstraint > C)
void apply(PBQPRAGraph &G) override
PBQPRAConstraintList(const PBQPRAConstraintList &)=delete
Abstract base for classes implementing PBQP register allocation constraints (e.g.
virtual ~PBQPRAConstraint()=0
virtual void apply(PBQPRAGraph &G)=0
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18