[llvm] r225292 - Use a Factory Method for MachineFunctionInfo Creation
Mehdi Amini
mehdi.amini at apple.com
Tue Jan 6 12:05:03 PST 2015
Author: mehdi_amini
Date: Tue Jan 6 14:05:02 2015
New Revision: 225292
URL: http://llvm.org/viewvc/llvm-project?rev=225292&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineFunction.h
Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=225292&r1=225291&r2=225292&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Tue Jan 6 14:05:02 2015
@@ -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);
}
More information about the llvm-commits
mailing list