mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
This re-applies r336929 with a fix to accomodate for the Mips target scheduling multiple SelectionDAG instances into the pass pipeline. PrologEpilogInserter and StackColoring depend on the StackProtector analysis being alive from the point it is run until PEI, which requires that they are all scheduled in the same FunctionPassManager. Inserting a (machine) ModulePass between StackProtector and PEI results in these passes being in separate FunctionPassManagers and the StackProtector is not available for PEI. PEI and StackColoring don't use much information from the StackProtector pass, so transfering the required information to MachineFrameInfo is cleaner than keeping the StackProtector pass around. This commit moves the SSP layout information to MFI instead of keeping it in the pass. This patch set (D37580, D37581, D37582, D37583, D37584, D37585, D37586, D37587) is a first draft of the pagerando implementation described in http://lists.llvm.org/pipermail/llvm-dev/2017-June/113794.html. Patch by Stephen Crane <sjc@immunant.com> Differential Revision: https://reviews.llvm.org/D49256 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336964 91177308-0d34-0410-b5e6-96231b3b80d8
81 lines
3.0 KiB
C++
81 lines
3.0 KiB
C++
//== llvm/CodeGen/GlobalISel/Localizer.h - Localizer -------------*- C++ -*-==//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
/// \file This file describes the interface of the Localizer pass.
|
|
/// This pass moves/duplicates constant-like instructions close to their uses.
|
|
/// Its primarily goal is to workaround the deficiencies of the fast register
|
|
/// allocator.
|
|
/// With GlobalISel constants are all materialized in the entry block of
|
|
/// a function. However, the fast allocator cannot rematerialize constants and
|
|
/// has a lot more live-ranges to deal with and will most likely end up
|
|
/// spilling a lot.
|
|
/// By pushing the constants close to their use, we only create small
|
|
/// live-ranges.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CODEGEN_GLOBALISEL_LOCALIZER_H
|
|
#define LLVM_CODEGEN_GLOBALISEL_LOCALIZER_H
|
|
|
|
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
namespace llvm {
|
|
// Forward declarations.
|
|
class MachineRegisterInfo;
|
|
|
|
/// This pass implements the localization mechanism described at the
|
|
/// top of this file. One specificity of the implementation is that
|
|
/// it will materialize one and only one instance of a constant per
|
|
/// basic block, thus enabling reuse of that constant within that block.
|
|
/// Moreover, it only materializes constants in blocks where they
|
|
/// are used. PHI uses are considered happening at the end of the
|
|
/// related predecessor.
|
|
class Localizer : public MachineFunctionPass {
|
|
public:
|
|
static char ID;
|
|
|
|
private:
|
|
/// MRI contains all the register class/bank information that this
|
|
/// pass uses and updates.
|
|
MachineRegisterInfo *MRI;
|
|
|
|
/// Check whether or not \p MI needs to be moved close to its uses.
|
|
static bool shouldLocalize(const MachineInstr &MI);
|
|
|
|
/// Check if \p MOUse is used in the same basic block as \p Def.
|
|
/// If the use is in the same block, we say it is local.
|
|
/// When the use is not local, \p InsertMBB will contain the basic
|
|
/// block when to insert \p Def to have a local use.
|
|
static bool isLocalUse(MachineOperand &MOUse, const MachineInstr &Def,
|
|
MachineBasicBlock *&InsertMBB);
|
|
|
|
/// Initialize the field members using \p MF.
|
|
void init(MachineFunction &MF);
|
|
|
|
public:
|
|
Localizer();
|
|
|
|
StringRef getPassName() const override { return "Localizer"; }
|
|
|
|
MachineFunctionProperties getRequiredProperties() const override {
|
|
return MachineFunctionProperties()
|
|
.set(MachineFunctionProperties::Property::IsSSA)
|
|
.set(MachineFunctionProperties::Property::Legalized)
|
|
.set(MachineFunctionProperties::Property::RegBankSelected);
|
|
}
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
|
};
|
|
|
|
} // End namespace llvm.
|
|
|
|
#endif
|