1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

Use a Factory Method for MachineFunctionInfo Creation

The goal is to allows MachineFunctionInfo to override this create
function to customize the creation.
No change intended in existing backend in this patch.

llvm-svn: 225292
This commit is contained in:
Mehdi Amini 2015-01-06 20:05:02 +00:00
parent 5dbfa1b1a1
commit c87fbe6ada

View File

@ -72,6 +72,15 @@ private:
/// MachineFunction is destroyed.
struct MachineFunctionInfo {
virtual ~MachineFunctionInfo();
/// \brief Factory function: default behavior is to call new using the
/// supplied allocator.
///
/// This function can be overridden in a derive class.
template<typename Ty>
static Ty *create(BumpPtrAllocator &Allocator, MachineFunction &MF) {
return new (Allocator.Allocate<Ty>()) Ty(MF);
}
};
class MachineFunction {
@ -239,7 +248,7 @@ public:
template<typename Ty>
Ty *getInfo() {
if (!MFInfo)
MFInfo = new (Allocator.Allocate<Ty>()) Ty(*this);
MFInfo = Ty::template create<Ty>(Allocator, *this);
return static_cast<Ty*>(MFInfo);
}