From ad154c837e4428842cfe5c0f9dbfcc42ba7a1454 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Mon, 28 Mar 2016 17:05:30 +0000 Subject: Introduce MachineFunctionProperties and the AllVRegsAllocated property 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 llvm-svn: 264593 --- llvm/lib/CodeGen/MachineFunctionPass.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/MachineFunctionPass.cpp') diff --git a/llvm/lib/CodeGen/MachineFunctionPass.cpp b/llvm/lib/CodeGen/MachineFunctionPass.cpp index 1913d99a781..bd0b11a8cb5 100644 --- a/llvm/lib/CodeGen/MachineFunctionPass.cpp +++ b/llvm/lib/CodeGen/MachineFunctionPass.cpp @@ -21,11 +21,13 @@ #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, @@ -40,7 +42,16 @@ bool MachineFunctionPass::runOnFunction(Function &F) { return false; MachineFunction &MF = getAnalysis().getMF(); - return runOnMachineFunction(MF); + 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 { -- cgit v1.2.3