mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Add a custom safepoint method, in order for language implementers to decide which machine instruction gets to be a safepoint.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144399 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
#define LLVM_CODEGEN_GCSTRATEGY_H
|
#define LLVM_CODEGEN_GCSTRATEGY_H
|
||||||
|
|
||||||
#include "llvm/CodeGen/GCMetadata.h"
|
#include "llvm/CodeGen/GCMetadata.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/Support/Registry.h"
|
#include "llvm/Support/Registry.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -68,6 +69,8 @@ namespace llvm {
|
|||||||
bool CustomReadBarriers; //< Default is to insert loads.
|
bool CustomReadBarriers; //< Default is to insert loads.
|
||||||
bool CustomWriteBarriers; //< Default is to insert stores.
|
bool CustomWriteBarriers; //< Default is to insert stores.
|
||||||
bool CustomRoots; //< Default is to pass through to backend.
|
bool CustomRoots; //< Default is to pass through to backend.
|
||||||
|
bool CustomSafePoints; //< Default is to use NeededSafePoints
|
||||||
|
// to find safe points.
|
||||||
bool InitRoots; //< If set, roots are nulled during lowering.
|
bool InitRoots; //< If set, roots are nulled during lowering.
|
||||||
bool UsesMetadata; //< If set, backend must emit metadata tables.
|
bool UsesMetadata; //< If set, backend must emit metadata tables.
|
||||||
|
|
||||||
@@ -87,7 +90,9 @@ namespace llvm {
|
|||||||
|
|
||||||
/// needsSafePoitns - True if safe points of any kind are required. By
|
/// needsSafePoitns - True if safe points of any kind are required. By
|
||||||
// default, none are recorded.
|
// default, none are recorded.
|
||||||
bool needsSafePoints() const { return NeededSafePoints != 0; }
|
bool needsSafePoints() const {
|
||||||
|
return CustomSafePoints || NeededSafePoints != 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// needsSafePoint(Kind) - True if the given kind of safe point is
|
/// needsSafePoint(Kind) - True if the given kind of safe point is
|
||||||
// required. By default, none are recorded.
|
// required. By default, none are recorded.
|
||||||
@@ -109,6 +114,11 @@ namespace llvm {
|
|||||||
/// can generate a stack map. If true, then
|
/// can generate a stack map. If true, then
|
||||||
// performCustomLowering must delete them.
|
// performCustomLowering must delete them.
|
||||||
bool customRoots() const { return CustomRoots; }
|
bool customRoots() const { return CustomRoots; }
|
||||||
|
|
||||||
|
/// customSafePoints - By default, the GC analysis will find safe
|
||||||
|
/// points according to NeededSafePoints. If true,
|
||||||
|
/// then findCustomSafePoints must create them.
|
||||||
|
bool customSafePoints() const { return CustomSafePoints; }
|
||||||
|
|
||||||
/// initializeRoots - If set, gcroot intrinsics should initialize their
|
/// initializeRoots - If set, gcroot intrinsics should initialize their
|
||||||
// allocas to null before the first use. This is
|
// allocas to null before the first use. This is
|
||||||
@@ -135,6 +145,7 @@ namespace llvm {
|
|||||||
/// which the LLVM IR can be modified.
|
/// which the LLVM IR can be modified.
|
||||||
virtual bool initializeCustomLowering(Module &F);
|
virtual bool initializeCustomLowering(Module &F);
|
||||||
virtual bool performCustomLowering(Function &F);
|
virtual bool performCustomLowering(Function &F);
|
||||||
|
virtual bool findCustomSafePoints(GCFunctionInfo& FI, MachineFunction& MF);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -97,6 +97,7 @@ GCStrategy::GCStrategy() :
|
|||||||
CustomReadBarriers(false),
|
CustomReadBarriers(false),
|
||||||
CustomWriteBarriers(false),
|
CustomWriteBarriers(false),
|
||||||
CustomRoots(false),
|
CustomRoots(false),
|
||||||
|
CustomSafePoints(false),
|
||||||
InitRoots(true),
|
InitRoots(true),
|
||||||
UsesMetadata(false)
|
UsesMetadata(false)
|
||||||
{}
|
{}
|
||||||
@@ -116,6 +117,14 @@ bool GCStrategy::performCustomLowering(Function &F) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GCStrategy::findCustomSafePoints(GCFunctionInfo& FI, MachineFunction &F) {
|
||||||
|
dbgs() << "gc " << getName() << " must override findCustomSafePoints.\n";
|
||||||
|
llvm_unreachable(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GCFunctionInfo *GCStrategy::insertFunctionInfo(const Function &F) {
|
GCFunctionInfo *GCStrategy::insertFunctionInfo(const Function &F) {
|
||||||
GCFunctionInfo *FI = new GCFunctionInfo(F, *this);
|
GCFunctionInfo *FI = new GCFunctionInfo(F, *this);
|
||||||
Functions.push_back(FI);
|
Functions.push_back(FI);
|
||||||
@@ -405,9 +414,13 @@ bool MachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
|
|
||||||
// Find the size of the stack frame.
|
// Find the size of the stack frame.
|
||||||
FI->setFrameSize(MF.getFrameInfo()->getStackSize());
|
FI->setFrameSize(MF.getFrameInfo()->getStackSize());
|
||||||
|
|
||||||
// Find all safe points.
|
// Find all safe points.
|
||||||
FindSafePoints(MF);
|
if (FI->getStrategy().customSafePoints()) {
|
||||||
|
FI->getStrategy().findCustomSafePoints(*FI, MF);
|
||||||
|
} else {
|
||||||
|
FindSafePoints(MF);
|
||||||
|
}
|
||||||
|
|
||||||
// Find the stack offsets for all roots.
|
// Find the stack offsets for all roots.
|
||||||
FindStackOffsets(MF);
|
FindStackOffsets(MF);
|
||||||
|
Reference in New Issue
Block a user