2002-12-28 21:03:01 +01:00
|
|
|
//===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
|
2005-04-21 22:39:54 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:39:54 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-12-28 21:03:01 +01:00
|
|
|
//
|
|
|
|
// This file defines the MachineFunctionPass class. MachineFunctionPass's are
|
|
|
|
// just FunctionPass's, except they operate on machine code as part of a code
|
|
|
|
// generator. Because they operate on machine code, not the LLVM
|
|
|
|
// representation, MachineFunctionPass's are not allowed to modify the LLVM
|
|
|
|
// representation. Due to this limitation, the MachineFunctionPass class takes
|
|
|
|
// care of declaring that no LLVM passes are invalidated.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 01:45:19 +01:00
|
|
|
#ifndef LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
|
|
|
|
#define LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
|
2002-12-28 21:03:01 +01:00
|
|
|
|
2016-03-28 19:05:30 +02:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2017-06-06 13:49:48 +02:00
|
|
|
#include "llvm/Pass.h"
|
2002-12-28 21:03:01 +01:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2009-07-31 20:16:33 +02:00
|
|
|
/// MachineFunctionPass - This class adapts the FunctionPass interface to
|
|
|
|
/// allow convenient creation of passes that operate on the MachineFunction
|
|
|
|
/// representation. Instead of overriding runOnFunction, subclasses
|
|
|
|
/// override runOnMachineFunction.
|
|
|
|
class MachineFunctionPass : public FunctionPass {
|
2016-03-28 19:05:30 +02:00
|
|
|
public:
|
|
|
|
bool doInitialization(Module&) override {
|
|
|
|
// Cache the properties info at module-init time so we don't have to
|
|
|
|
// construct them for every function.
|
|
|
|
RequiredProperties = getRequiredProperties();
|
|
|
|
SetProperties = getSetProperties();
|
|
|
|
ClearedProperties = getClearedProperties();
|
|
|
|
return false;
|
|
|
|
}
|
2009-07-31 20:16:33 +02:00
|
|
|
protected:
|
2010-08-06 20:33:48 +02:00
|
|
|
explicit MachineFunctionPass(char &ID) : FunctionPass(ID) {}
|
2007-05-01 23:15:47 +02:00
|
|
|
|
2002-12-28 21:03:01 +01:00
|
|
|
/// runOnMachineFunction - This method must be overloaded to perform the
|
|
|
|
/// desired machine code transformation or analysis.
|
|
|
|
///
|
|
|
|
virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
|
|
|
|
|
2009-07-31 20:16:33 +02:00
|
|
|
/// getAnalysisUsage - Subclasses that override getAnalysisUsage
|
|
|
|
/// must call this.
|
2009-08-11 17:50:56 +02:00
|
|
|
///
|
|
|
|
/// For MachineFunctionPasses, calling AU.preservesCFG() indicates that
|
|
|
|
/// the pass does not modify the MachineBasicBlock CFG.
|
|
|
|
///
|
2014-03-07 10:26:03 +01:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
2009-07-31 20:16:33 +02:00
|
|
|
|
2016-03-28 19:05:30 +02:00
|
|
|
virtual MachineFunctionProperties getRequiredProperties() const {
|
|
|
|
return MachineFunctionProperties();
|
|
|
|
}
|
|
|
|
virtual MachineFunctionProperties getSetProperties() const {
|
|
|
|
return MachineFunctionProperties();
|
|
|
|
}
|
|
|
|
virtual MachineFunctionProperties getClearedProperties() const {
|
|
|
|
return MachineFunctionProperties();
|
|
|
|
}
|
|
|
|
|
2009-07-31 20:16:33 +02:00
|
|
|
private:
|
2016-03-28 19:05:30 +02:00
|
|
|
MachineFunctionProperties RequiredProperties;
|
|
|
|
MachineFunctionProperties SetProperties;
|
|
|
|
MachineFunctionProperties ClearedProperties;
|
|
|
|
|
2010-06-05 03:19:12 +02:00
|
|
|
/// createPrinterPass - Get a machine function printer pass.
|
2014-03-07 10:26:03 +01:00
|
|
|
Pass *createPrinterPass(raw_ostream &O,
|
|
|
|
const std::string &Banner) const override;
|
2010-06-05 03:19:12 +02:00
|
|
|
|
2014-03-07 10:26:03 +01:00
|
|
|
bool runOnFunction(Function &F) override;
|
2002-12-28 21:03:01 +01:00
|
|
|
};
|
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
} // End llvm namespace
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2002-12-28 21:03:01 +01:00
|
|
|
#endif
|