#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"
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.
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 UsesMetadata; ///< If set, backend must emit metadata tables.
/// 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.
/// True if safe points of any kind are required. By default, none are
/// recorded.
bool needsSafePoints() const {
- return CustomSafePoints || NeededSafePoints != 0;
+ return NeededSafePoints != 0;
}
/// True if the given kind of safe point is required. By default, none are
/// stack map. If true, then performCustomLowering must delete them.
bool customRoots() const { return CustomRoots; }
- /// By default, the GC analysis will find safe points according to
- /// NeededSafePoints. If true, then findCustomSafePoints must create them.
- bool customSafePoints() const { return CustomSafePoints; }
-
/// If set, gcroot intrinsics should initialize their allocas to null
/// before the first use. This is necessary for most GCs and is enabled by
/// default.
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; }
///@}
llvm_unreachable("GCStrategy subclass specified a configuration which"
"requires a custom lowering without providing one");
}
- ///@}
- /// Called if customSafepoints returns true, used only by gc.root
- /// implementations.
- virtual bool findCustomSafePoints(GCFunctionInfo& FI, MachineFunction& MF) {
- llvm_unreachable("GCStrategy subclass specified a configuration which"
- "requests custom safepoint identification without"
- "providing an implementation for such");
- }
};
/// Subclasses of GCStrategy are made available for use during compilation by