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 
15 namespace llvm {
16 
17 struct RegAllocFastPassOptions {
18   RegAllocFilterFunc Filter = nullptr;
19   StringRef FilterName = "all";
20   bool ClearVRegs = true;
21 };
22 
23 class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
24   RegAllocFastPassOptions Opts;
25 
26 public:
27   RegAllocFastPass(RegAllocFastPassOptions Opts = RegAllocFastPassOptions())
Opts(Opts)28       : Opts(Opts) {}
29 
getRequiredProperties()30   MachineFunctionProperties getRequiredProperties() {
31     return MachineFunctionProperties().set(
32         MachineFunctionProperties::Property::NoPHIs);
33   }
34 
getSetProperties()35   MachineFunctionProperties getSetProperties() {
36     if (Opts.ClearVRegs) {
37       return MachineFunctionProperties().set(
38           MachineFunctionProperties::Property::NoVRegs);
39     }
40 
41     return MachineFunctionProperties();
42   }
43 
getClearedProperties()44   MachineFunctionProperties getClearedProperties() {
45     return MachineFunctionProperties().set(
46         MachineFunctionProperties::Property::IsSSA);
47   }
48 
49   PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
50 
51   void printPipeline(raw_ostream &OS,
52                      function_ref<StringRef(StringRef)> MapClassName2PassName);
53 };
54 
55 } // namespace llvm
56 
57 #endif // LLVM_CODEGEN_REGALLOCFAST_H
58