From 74671d5c1491dc9e252a8a10c9065b2f8cc99fba Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Wed, 27 May 2020 18:02:49 -0700 Subject: [PATCH] Sink first bit of functionality from Statepoint to GCStatepointInst Starting with the obvious stuff. I initially tried to include the inline operand sequences too, but managed to get code which confused *me*. Since several parts of those are being entirely removed in the near future, I may defer that portion until the cleanup is done. --- llvm/include/llvm/IR/Statepoint.h | 69 ++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/llvm/include/llvm/IR/Statepoint.h b/llvm/include/llvm/IR/Statepoint.h index f9eeddba778..34eb1126b37 100644 --- a/llvm/include/llvm/IR/Statepoint.h +++ b/llvm/include/llvm/IR/Statepoint.h @@ -83,6 +83,38 @@ public: static bool classof(const Value *V) { return isa(V) && classof(cast(V)); } + + enum { + IDPos = 0, + NumPatchBytesPos = 1, + CalledFunctionPos = 2, + NumCallArgsPos = 3, + FlagsPos = 4, + CallArgsBeginPos = 5, + }; + + /// Return the ID associated with this statepoint. + uint64_t getID() const { + return cast(getArgOperand(IDPos))->getZExtValue(); + } + + /// Return the number of patchable bytes associated with this statepoint. + uint32_t getNumPatchBytes() const { + const Value *NumPatchBytesVal = getArgOperand(NumPatchBytesPos); + uint64_t NumPatchBytes = + cast(NumPatchBytesVal)->getZExtValue(); + assert(isInt<32>(NumPatchBytes) && "should fit in 32 bits!"); + return NumPatchBytes; + } + + /// Number of arguments to be passed to the actual callee. + int getNumCallArgs() const { + return cast(getArgOperand(NumCallArgsPos))->getZExtValue(); + } + + uint64_t getFlags() const { + return cast(getArgOperand(FlagsPos))->getZExtValue(); + } }; /// A wrapper around a GC intrinsic call, this provides most of the actual @@ -107,12 +139,8 @@ public: using arg_iterator = typename CallTy::const_op_iterator; enum { - IDPos = 0, - NumPatchBytesPos = 1, - CalledFunctionPos = 2, - NumCallArgsPos = 3, - FlagsPos = 4, - CallArgsBeginPos = 5, + CalledFunctionPos = GCStatepointInst::CalledFunctionPos, + CallArgsBeginPos = GCStatepointInst::CallArgsBeginPos, }; void *operator new(size_t, unsigned) = delete; @@ -129,25 +157,12 @@ public: return StatepointCall; } - uint64_t getFlags() const { - return cast(getCall()->getArgOperand(FlagsPos)) - ->getZExtValue(); - } + // Deprecated shims (update all callers to remove) + uint64_t getFlags() const { return getCall()->getFlags(); } + uint64_t getID() const { return getCall()->getID(); } + uint32_t getNumPatchBytes() const { return getCall()->getNumPatchBytes(); } + int getNumCallArgs() const { return getCall()->getNumCallArgs(); } - /// Return the ID associated with this statepoint. - uint64_t getID() const { - const Value *IDVal = getCall()->getArgOperand(IDPos); - return cast(IDVal)->getZExtValue(); - } - - /// Return the number of patchable bytes associated with this statepoint. - uint32_t getNumPatchBytes() const { - const Value *NumPatchBytesVal = getCall()->getArgOperand(NumPatchBytesPos); - uint64_t NumPatchBytes = - cast(NumPatchBytesVal)->getZExtValue(); - assert(isInt<32>(NumPatchBytes) && "should fit in 32 bits!"); - return NumPatchBytes; - } /// Return the value actually being called or invoked. ValueTy *getCalledValue() const { @@ -180,12 +195,6 @@ public: return FTy->getReturnType(); } - /// Number of arguments to be passed to the actual callee. - int getNumCallArgs() const { - const Value *NumCallArgsVal = getCall()->getArgOperand(NumCallArgsPos); - return cast(NumCallArgsVal)->getZExtValue(); - } - size_t arg_size() const { return getNumCallArgs(); } arg_iterator arg_begin() const { assert(CallArgsBeginPos <= (int)getCall()->arg_size()); -- 2.11.0