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.
This commit is contained in:
Philip Reames 2020-05-27 18:02:49 -07:00
parent a70edc2b16
commit 74671d5c14
1 changed files with 39 additions and 30 deletions

View File

@ -83,6 +83,38 @@ public:
static bool classof(const Value *V) {
return isa<CallBase>(V) && classof(cast<CallBase>(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<ConstantInt>(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<ConstantInt>(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<ConstantInt>(getArgOperand(NumCallArgsPos))->getZExtValue();
}
uint64_t getFlags() const {
return cast<ConstantInt>(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<ConstantInt>(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<ConstantInt>(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<ConstantInt>(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<ConstantInt>(NumCallArgsVal)->getZExtValue();
}
size_t arg_size() const { return getNumCallArgs(); }
arg_iterator arg_begin() const {
assert(CallArgsBeginPos <= (int)getCall()->arg_size());