1//==- RegAllocFast.h ----------- fast register allocator ----------*-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#ifndef LLVM_CODEGEN_REGALLOCFAST_H
10#define LLVM_CODEGEN_REGALLOCFAST_H
11
12#include "llvm/CodeGen/MachinePassManager.h"
13#include "llvm/CodeGen/RegAllocCommon.h"
14
15namespace llvm {
16
17class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
18public:
19 struct Options {
20 RegAllocFilterFunc Filter;
21 StringRef FilterName;
22 bool ClearVRegs;
23 Options(RegAllocFilterFunc F = nullptr, StringRef FN = "all",
24 bool CV = true)
25 : Filter(std::move(F)), FilterName(FN), ClearVRegs(CV) {}
26 };
27
28 RegAllocFastPass(Options Opts = Options()) : Opts(std::move(Opts)) {}
29
30 MachineFunctionProperties getRequiredProperties() const {
31 return MachineFunctionProperties().setNoPHIs();
32 }
33
34 MachineFunctionProperties getSetProperties() const {
35 if (Opts.ClearVRegs) {
36 return MachineFunctionProperties().setNoVRegs();
37 }
38
39 return MachineFunctionProperties();
40 }
41
42 MachineFunctionProperties getClearedProperties() const {
43 return MachineFunctionProperties().setIsSSA();
44 }
45
46 PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
47
48 void printPipeline(raw_ostream &OS,
49 function_ref<StringRef(StringRef)> MapClassName2PassName);
50
51 static bool isRequired() { return true; }
52
53private:
54 Options Opts;
55};
56
57} // namespace llvm
58
59#endif // LLVM_CODEGEN_REGALLOCFAST_H
60