mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-10 01:51:57 +00:00

MachineFunctionProperties represents a set of properties that a MachineFunction can have at particular points in time. Existing examples of this idea are MachineRegisterInfo::isSSA() and MachineRegisterInfo::tracksLiveness() which will eventually be switched to use this mechanism. This change introduces the AllVRegsAllocated property; i.e. the property that all virtual registers have been allocated and there are no VReg operands left. With this mechanism, passes can declare that they require a particular property to be set, or that they set or clear properties by implementing e.g. MachineFunctionPass::getRequiredProperties(). The MachineFunctionPass base class verifies that the requirements are met, and handles the setting and clearing based on the delcarations. Passes can also directly query and update the current properties of the MF if they want to have conditional behavior. This change annotates the target-independent post-regalloc passes; future changes will also annotate target-specific ones. Reviewers: qcolombet, hfinkel Differential Revision: http://reviews.llvm.org/D18421 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264593 91177308-0d34-0410-b5e6-96231b3b80d8
80 lines
2.9 KiB
C++
80 lines
2.9 KiB
C++
//===-- MachineFunctionPass.cpp -------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains the definitions of the MachineFunctionPass members.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
|
#include "llvm/Analysis/BasicAliasAnalysis.h"
|
|
#include "llvm/Analysis/DominanceFrontier.h"
|
|
#include "llvm/Analysis/GlobalsModRef.h"
|
|
#include "llvm/Analysis/IVUsers.h"
|
|
#include "llvm/Analysis/LoopInfo.h"
|
|
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
|
#include "llvm/Analysis/ScalarEvolution.h"
|
|
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
|
#include "llvm/CodeGen/Passes.h"
|
|
#include "llvm/CodeGen/StackProtector.h"
|
|
#include "llvm/IR/Dominators.h"
|
|
#include "llvm/IR/Function.h"
|
|
|
|
using namespace llvm;
|
|
|
|
Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O,
|
|
const std::string &Banner) const {
|
|
return createMachineFunctionPrinterPass(O, Banner);
|
|
}
|
|
|
|
bool MachineFunctionPass::runOnFunction(Function &F) {
|
|
// Do not codegen any 'available_externally' functions at all, they have
|
|
// definitions outside the translation unit.
|
|
if (F.hasAvailableExternallyLinkage())
|
|
return false;
|
|
|
|
MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF();
|
|
MachineFunctionProperties &MFProps = MF.getProperties();
|
|
|
|
assert(MFProps.verifyRequiredProperties(RequiredProperties) &&
|
|
"Properties required by the pass are not met by the function");
|
|
|
|
bool RV = runOnMachineFunction(MF);
|
|
|
|
MFProps.set(SetProperties);
|
|
MFProps.clear(ClearedProperties);
|
|
return RV;
|
|
}
|
|
|
|
void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
AU.addRequired<MachineFunctionAnalysis>();
|
|
AU.addPreserved<MachineFunctionAnalysis>();
|
|
|
|
// MachineFunctionPass preserves all LLVM IR passes, but there's no
|
|
// high-level way to express this. Instead, just list a bunch of
|
|
// passes explicitly. This does not include setPreservesCFG,
|
|
// because CodeGen overloads that to mean preserving the MachineBasicBlock
|
|
// CFG in addition to the LLVM IR CFG.
|
|
AU.addPreserved<BasicAAWrapperPass>();
|
|
AU.addPreserved<DominanceFrontierWrapperPass>();
|
|
AU.addPreserved<DominatorTreeWrapperPass>();
|
|
AU.addPreserved<AAResultsWrapperPass>();
|
|
AU.addPreserved<GlobalsAAWrapperPass>();
|
|
AU.addPreserved<IVUsers>();
|
|
AU.addPreserved<LoopInfoWrapperPass>();
|
|
AU.addPreserved<MemoryDependenceWrapperPass>();
|
|
AU.addPreserved<ScalarEvolutionWrapperPass>();
|
|
AU.addPreserved<SCEVAAWrapperPass>();
|
|
AU.addPreserved<StackProtector>();
|
|
|
|
FunctionPass::getAnalysisUsage(AU);
|
|
}
|