1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[stackmaps] Extract out magic constants [NFCI]

This is a first step towards clarifying the exact MI semantics of stackmap's "live values".  

llvm-svn: 279574
This commit is contained in:
Philip Reames 2016-08-23 21:21:43 +00:00
parent c10c0e4ef4
commit 4d9558b08e
3 changed files with 40 additions and 6 deletions

View File

@ -22,6 +22,29 @@ class AsmPrinter;
class MCExpr; class MCExpr;
class MCStreamer; class MCStreamer;
/// \brief MI-level stackmap operands.
///
/// MI slackmap operations take the form:
/// <id>, <numBytes>, live args...
class StackMapOpers {
public:
/// Enumerate the meta operands.
enum { IDPos, NBytesPos };
private:
const MachineInstr *MI;
public:
explicit StackMapOpers(const MachineInstr *MI);
/// Get the operand index of the variable list of non-argument operands.
/// These hold the "live state".
unsigned getVarIdx() const {
// Skip ID, nShadowBytes.
return 2;
}
};
/// \brief MI-level patchpoint operands. /// \brief MI-level patchpoint operands.
/// ///
/// MI patchpoint operations take the form: /// MI patchpoint operations take the form:

View File

@ -35,6 +35,12 @@ static cl::opt<int> StackMapVersion(
const char *StackMaps::WSMP = "Stack Maps: "; const char *StackMaps::WSMP = "Stack Maps: ";
StackMapOpers::StackMapOpers(const MachineInstr *MI)
: MI(MI) {
assert(getVarIdx() <= MI->getNumOperands() &&
"invalid stackmap definition");
}
PatchPointOpers::PatchPointOpers(const MachineInstr *MI) PatchPointOpers::PatchPointOpers(const MachineInstr *MI)
: MI(MI), HasDef(MI->getOperand(0).isReg() && MI->getOperand(0).isDef() && : MI(MI), HasDef(MI->getOperand(0).isReg() && MI->getOperand(0).isDef() &&
!MI->getOperand(0).isImplicit()), !MI->getOperand(0).isImplicit()),
@ -343,8 +349,9 @@ void StackMaps::recordStackMapOpers(const MachineInstr &MI, uint64_t ID,
void StackMaps::recordStackMap(const MachineInstr &MI) { void StackMaps::recordStackMap(const MachineInstr &MI) {
assert(MI.getOpcode() == TargetOpcode::STACKMAP && "expected stackmap"); assert(MI.getOpcode() == TargetOpcode::STACKMAP && "expected stackmap");
int64_t ID = MI.getOperand(0).getImm(); StackMapOpers opers(&MI);
recordStackMapOpers(MI, ID, std::next(MI.operands_begin(), 2), const int64_t ID = MI.getOperand(PatchPointOpers::IDPos).getImm();
recordStackMapOpers(MI, ID, std::next(MI.operands_begin(), opers.getVarIdx()),
MI.operands_end()); MI.operands_end());
} }
@ -352,7 +359,7 @@ void StackMaps::recordPatchPoint(const MachineInstr &MI) {
assert(MI.getOpcode() == TargetOpcode::PATCHPOINT && "expected patchpoint"); assert(MI.getOpcode() == TargetOpcode::PATCHPOINT && "expected patchpoint");
PatchPointOpers opers(&MI); PatchPointOpers opers(&MI);
int64_t ID = opers.getMetaOper(PatchPointOpers::IDPos).getImm(); const int64_t ID = opers.getMetaOper(PatchPointOpers::IDPos).getImm();
auto MOI = std::next(MI.operands_begin(), opers.getStackMapStartIdx()); auto MOI = std::next(MI.operands_begin(), opers.getStackMapStartIdx());
recordStackMapOpers(MI, ID, MOI, MI.operands_end(), recordStackMapOpers(MI, ID, MOI, MI.operands_end(),

View File

@ -437,11 +437,15 @@ static MachineInstr *foldPatchpoint(MachineFunction &MF, MachineInstr &MI,
const TargetInstrInfo &TII) { const TargetInstrInfo &TII) {
unsigned StartIdx = 0; unsigned StartIdx = 0;
switch (MI.getOpcode()) { switch (MI.getOpcode()) {
case TargetOpcode::STACKMAP: case TargetOpcode::STACKMAP: {
StartIdx = 2; // Skip ID, nShadowBytes. // StackMapLiveValues are foldable
StackMapOpers opers(&MI);
StartIdx = opers.getVarIdx();
break; break;
}
case TargetOpcode::PATCHPOINT: { case TargetOpcode::PATCHPOINT: {
// For PatchPoint, the call args are not foldable. // For PatchPoint, the call args are not foldable (even if reported in the
// stackmap e.g. via anyregcc).
PatchPointOpers opers(&MI); PatchPointOpers opers(&MI);
StartIdx = opers.getVarIdx(); StartIdx = opers.getVarIdx();
break; break;