mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
[Statepoints 2/4] Statepoint infrastructure for garbage collection: MI & x86-64 Backend
This is the second patch in a small series. This patch contains the MachineInstruction and x86-64 backend pieces required to lower Statepoints. It does not include the code to actually generate the STATEPOINT machine instruction and as a result, the entire patch is currently dead code. I will be submitting the SelectionDAG parts within the next 24-48 hours. Since those pieces are by far the most complicated, I wanted to minimize the size of that patch. That patch will include the tests which exercise the functionality in this patch. The entire series can be seen as one combined whole in http://reviews.llvm.org/D5683. The STATEPOINT psuedo node is generated after all gc values are explicitly spilled to stack slots. The purpose of this node is to wrap an actual call instruction while recording the spill locations of the meta arguments used for garbage collection and other purposes. The STATEPOINT is modeled as modifing all of those locations to prevent backend optimizations from forwarding the value from before the STATEPOINT to after the STATEPOINT. (Doing so would break relocation semantics for collectors which wish to relocate roots.) The implementation of STATEPOINT is closely modeled on PATCHPOINT. Eventually, much of the code in this patch will be removed. The long term plan is to merge the functionality provided by statepoints and patchpoints. Merging their implementations in the backend is likely to be a good starting point. Reviewed by: atrick, ributzka git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223085 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -81,6 +81,52 @@ public:
|
||||
unsigned getNextScratchIdx(unsigned StartIdx = 0) const;
|
||||
};
|
||||
|
||||
/// MI-level Statepoint operands
|
||||
///
|
||||
/// Statepoint operands take the form:
|
||||
/// <num call arguments>, <call target>, [call arguments],
|
||||
/// <StackMaps::ConstantOp>, <flags>,
|
||||
/// <StackMaps::ConstantOp>, <num other args>, [other args],
|
||||
/// [gc values]
|
||||
class StatepointOpers {
|
||||
private:
|
||||
enum {
|
||||
NCallArgsPos = 0,
|
||||
CallTargetPos = 1
|
||||
};
|
||||
|
||||
public:
|
||||
explicit StatepointOpers(const MachineInstr *MI):
|
||||
MI(MI) { }
|
||||
|
||||
/// Get starting index of non call related arguments
|
||||
/// (statepoint flags, vm state and gc state).
|
||||
unsigned getVarIdx() const {
|
||||
return MI->getOperand(NCallArgsPos).getImm() + 2;
|
||||
}
|
||||
|
||||
/// Returns the index of the operand containing the number of non-gc non-call
|
||||
/// arguments.
|
||||
unsigned getNumVMSArgsIdx() const {
|
||||
return getVarIdx() + 3;
|
||||
}
|
||||
|
||||
/// Returns the number of non-gc non-call arguments attached to the
|
||||
/// statepoint. Note that this is the number of arguments, not the number of
|
||||
/// operands required to represent those arguments.
|
||||
unsigned getNumVMSArgs() const {
|
||||
return MI->getOperand(getNumVMSArgsIdx()).getImm();
|
||||
}
|
||||
|
||||
/// Returns the target of the underlying call.
|
||||
const MachineOperand &getCallTarget() const {
|
||||
return MI->getOperand(CallTargetPos);
|
||||
}
|
||||
|
||||
private:
|
||||
const MachineInstr *MI;
|
||||
};
|
||||
|
||||
class StackMaps {
|
||||
public:
|
||||
struct Location {
|
||||
@@ -132,6 +178,9 @@ public:
|
||||
/// \brief Generate a stackmap record for a patchpoint instruction.
|
||||
void recordPatchPoint(const MachineInstr &MI);
|
||||
|
||||
/// \brief Generate a stackmap record for a statepoint instruction.
|
||||
void recordStatepoint(const MachineInstr &MI);
|
||||
|
||||
/// If there is any stack map data, create a stack map section and serialize
|
||||
/// the map info into it. This clears the stack map data structures
|
||||
/// afterwards.
|
||||
@@ -139,7 +188,6 @@ public:
|
||||
|
||||
private:
|
||||
static const char *WSMP;
|
||||
|
||||
typedef SmallVector<Location, 8> LocationVec;
|
||||
typedef SmallVector<LiveOutReg, 8> LiveOutVec;
|
||||
typedef MapVector<uint64_t, uint64_t> ConstantPool;
|
||||
|
Reference in New Issue
Block a user