xref: /llvm-project/llvm/include/llvm/CodeGen/RegAllocFast.h (revision fe6366928201b7500ee7e903c01bf4bbd661ee2d)
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())
28       : Opts(Opts) {}
29 
30   MachineFunctionProperties getRequiredProperties() const {
31     return MachineFunctionProperties().set(
32         MachineFunctionProperties::Property::NoPHIs);
33   }
34 
35   MachineFunctionProperties getSetProperties() const {
36     if (Opts.ClearVRegs) {
37       return MachineFunctionProperties().set(
38           MachineFunctionProperties::Property::NoVRegs);
39     }
40 
41     return MachineFunctionProperties();
42   }
43 
44   MachineFunctionProperties getClearedProperties() const {
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   static bool isRequired() { return true; }
55 };
56 
57 } // namespace llvm
58 
59 #endif // LLVM_CODEGEN_REGALLOCFAST_H
60