mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00: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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225292 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a602a7f199
commit
193f586fd2
@ -72,6 +72,15 @@ private:
|
|||||||
/// MachineFunction is destroyed.
|
/// MachineFunction is destroyed.
|
||||||
struct MachineFunctionInfo {
|
struct MachineFunctionInfo {
|
||||||
virtual ~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 {
|
class MachineFunction {
|
||||||
@ -239,7 +248,7 @@ public:
|
|||||||
template<typename Ty>
|
template<typename Ty>
|
||||||
Ty *getInfo() {
|
Ty *getInfo() {
|
||||||
if (!MFInfo)
|
if (!MFInfo)
|
||||||
MFInfo = new (Allocator.Allocate<Ty>()) Ty(*this);
|
MFInfo = Ty::template create<Ty>(Allocator, *this);
|
||||||
return static_cast<Ty*>(MFInfo);
|
return static_cast<Ty*>(MFInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user