LLVM 24.0.0git
Localizer.h
Go to the documentation of this file.
1//== llvm/CodeGen/GlobalISel/Localizer.h - Localizer -------------*- 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/// \file This file describes the interface of the Localizer pass.
10/// This pass moves/duplicates constant-like instructions close to their uses.
11/// Its primarily goal is to workaround the deficiencies of the fast register
12/// allocator.
13/// With GlobalISel constants are all materialized in the entry block of
14/// a function. However, the fast allocator cannot rematerialize constants and
15/// has a lot more live-ranges to deal with and will most likely end up
16/// spilling a lot.
17/// By pushing the constants close to their use, we only create small
18/// live-ranges.
19//===----------------------------------------------------------------------===//
20
21#ifndef LLVM_CODEGEN_GLOBALISEL_LOCALIZER_H
22#define LLVM_CODEGEN_GLOBALISEL_LOCALIZER_H
23
26#include "llvm/IR/Analysis.h"
27#include "llvm/IR/PassManager.h"
28
29namespace llvm {
30// Forward declarations.
31class AnalysisUsage;
32
33/// This pass implements the localization mechanism described at the
34/// top of this file. One specificity of the implementation is that
35/// it will materialize one and only one instance of a constant per
36/// basic block, thus enabling reuse of that constant within that block.
37/// Moreover, it only materializes constants in blocks where they
38/// are used. PHI uses are considered happening at the end of the
39/// related predecessor.
41public:
42 static char ID;
43
45
46 StringRef getPassName() const override { return "Localizer"; }
47
49 return MachineFunctionProperties().setIsSSA();
50 }
51
52 void getAnalysisUsage(AnalysisUsage &AU) const override;
53
54 bool runOnMachineFunction(MachineFunction &MF) override;
55};
56
66
67} // End namespace llvm.
68
69#endif
#define LLVM_ABI
Definition Compiler.h:215
This header defines various interfaces for pass management in LLVM.
Represent the analysis usage information of a pass.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
Definition Localizer.h:46
MachineFunctionProperties getRequiredProperties() const override
Definition Localizer.h:48
MachineFunctionProperties getRequiredProperties() const
Definition Localizer.h:62
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Properties which a MachineFunction may have at a given point in time.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
A CRTP mix-in for passes that should not be skipped.