mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Introduce an example statepoint GC strategy
This change includes the most basic possible GCStrategy for a GC which is using the statepoint lowering code. At the moment, this GCStrategy doesn't really do much - aside from actually generate correct stackmaps that is - but I went ahead and added a few extra correctness checks as proof of concept. It's mostly here to provide documentation on how to do one, and to provide a point for various optimization legality hooks I'd like to add going forward. (For context, see the TODOs in InstCombine around gc.relocate.) Most of the validation logic added here as proof of concept will soon move in to the Verifier. That move is dependent on http://reviews.llvm.org/D6811 There was discussion in the review thread about addrspace(1) being reserved for something. I'm going to follow up on a seperate llvmdev thread. If needed, I'll update all the code at once. Note that I am deliberately not making a GCStrategy required to use gc.statepoints with this change. I want to give folks out of tree - including myself - a chance to migrate. In a week or two, I'll make having a GCStrategy be required for gc.statepoints. To this end, I added the gc tag to one of the test cases but not others. Differential Revision: http://reviews.llvm.org/D6808 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225365 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#ifndef LLVM_CODEGEN_GCSTRATEGY_H
|
||||
#define LLVM_CODEGEN_GCSTRATEGY_H
|
||||
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/CodeGen/GCMetadata.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/Support/Registry.h"
|
||||
@@ -67,6 +68,10 @@ namespace llvm {
|
||||
friend class GCModuleInfo;
|
||||
|
||||
protected:
|
||||
bool UseStatepoints; /// Uses gc.statepoints as opposed to gc.roots,
|
||||
/// if set, none of the other options can be
|
||||
/// anything but their default values.
|
||||
|
||||
unsigned NeededSafePoints; ///< Bitmask of required safe points.
|
||||
bool CustomReadBarriers; ///< Default is to insert loads.
|
||||
bool CustomWriteBarriers; ///< Default is to insert stores.
|
||||
@@ -94,6 +99,22 @@ namespace llvm {
|
||||
/// them.
|
||||
bool customReadBarrier() const { return CustomReadBarriers; }
|
||||
|
||||
/// Returns true if this strategy is expecting the use of gc.statepoints,
|
||||
/// and false otherwise.
|
||||
bool useStatepoints() const { return UseStatepoints; }
|
||||
|
||||
/** @name Statepoint Specific Properties */
|
||||
///@{
|
||||
|
||||
/// If the value specified can be reliably distinguished, returns true for
|
||||
/// pointers to GC managed locations and false for pointers to non-GC
|
||||
/// managed locations. Note a GCStrategy can always return 'None' (i.e. an
|
||||
/// empty optional indicating it can't reliably distinguish.
|
||||
virtual Optional<bool> isGCManagedPointer(const Value *V) const {
|
||||
return None;
|
||||
}
|
||||
///@}
|
||||
|
||||
/** @name GCRoot Specific Properties
|
||||
* These properties and overrides only apply to collector strategies using
|
||||
* GCRoot.
|
||||
@@ -126,7 +147,9 @@ namespace llvm {
|
||||
bool initializeRoots() const { return InitRoots; }
|
||||
|
||||
/// If set, appropriate metadata tables must be emitted by the back-end
|
||||
/// (assembler, JIT, or otherwise).
|
||||
/// (assembler, JIT, or otherwise). For statepoint, this method is
|
||||
/// currently unsupported. The stackmap information can be found in the
|
||||
/// StackMap section as described in the documentation.
|
||||
bool usesMetadata() const { return UsesMetadata; }
|
||||
|
||||
///@}
|
||||
|
Reference in New Issue
Block a user