+/// MI-level Statepoint operands
+///
+/// Statepoint operands take the form:
+/// <id>, <num patch bytes >, <num call arguments>, <call target>,
+/// [call arguments], <StackMaps::ConstantOp>, <calling convention>,
+/// <StackMaps::ConstantOp>, <statepoint flags>,
+/// <StackMaps::ConstantOp>, <num other args>, [other args],
+/// [gc values]
+class StatepointOpers {
+private:
+ // These values are aboolute offsets into the operands of the statepoint
+ // instruction.
+ enum { IDPos, NBytesPos, NCallArgsPos, CallTargetPos, MetaEnd };
+
+ // These values are relative offests from the start of the statepoint meta
+ // arguments (i.e. the end of the call arguments).
+ enum { CCOffset = 1, FlagsOffset = 3, NumVMSArgsOffset = 5 };
+
+public:
+ explicit StatepointOpers(const MachineInstr *MI) : MI(MI) {}
+
+ /// Get starting index of non call related arguments
+ /// (calling convention, statepoint flags, vm state and gc state).
+ unsigned getVarIdx() const {
+ return MI->getOperand(NCallArgsPos).getImm() + MetaEnd;
+ }
+
+ /// Return the ID for the given statepoint.
+ uint64_t getID() const { return MI->getOperand(IDPos).getImm(); }
+
+ /// Return the number of patchable bytes the given statepoint should emit.
+ uint32_t getNumPatchBytes() const {
+ return MI->getOperand(NBytesPos).getImm();
+ }
+
+ /// Returns the target of the underlying call.
+ const MachineOperand &getCallTarget() const {
+ return MI->getOperand(CallTargetPos);
+ }
+
+private:
+ const MachineInstr *MI;
+};
+