mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
[Statepoint] Clean up StatepointLowering: symbolic constants.
For accessors in the `Statepoint` class, use symbolic constants for offsets into the argument vector instead of literals. This makes the code intent clearer and simpler to change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236566 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b9a2e8271f
commit
93a4a7fe0d
@ -63,11 +63,19 @@ protected:
|
||||
public:
|
||||
typedef typename CallSiteTy::arg_iterator arg_iterator;
|
||||
|
||||
enum {
|
||||
ActualCalleePos = 0,
|
||||
NumCallArgsPos = 1,
|
||||
CallArgsBeginPos = 3,
|
||||
};
|
||||
|
||||
/// Return the underlying CallSite.
|
||||
CallSiteTy getCallSite() { return StatepointCS; }
|
||||
|
||||
/// Return the value actually being called or invoked.
|
||||
ValueTy *getActualCallee() { return StatepointCS.getArgument(0); }
|
||||
ValueTy *getActualCallee() {
|
||||
return StatepointCS.getArgument(ActualCalleePos);
|
||||
}
|
||||
|
||||
/// Return the type of the value returned by the call underlying the
|
||||
/// statepoint.
|
||||
@ -79,26 +87,16 @@ public:
|
||||
|
||||
/// Number of arguments to be passed to the actual callee.
|
||||
int getNumCallArgs() {
|
||||
return cast<ConstantInt>(StatepointCS.getArgument(1))->getZExtValue();
|
||||
const Value *NumCallArgsVal = StatepointCS.getArgument(NumCallArgsPos);
|
||||
return cast<ConstantInt>(NumCallArgsVal)->getZExtValue();
|
||||
}
|
||||
|
||||
/// Number of additional arguments excluding those intended
|
||||
/// for garbage collection.
|
||||
int getNumTotalVMSArgs() {
|
||||
const Value *NumVMSArgs = StatepointCS.getArgument(3 + getNumCallArgs());
|
||||
return cast<ConstantInt>(NumVMSArgs)->getZExtValue();
|
||||
}
|
||||
|
||||
int callArgsBeginOffset() { return 3; }
|
||||
|
||||
typename CallSiteTy::arg_iterator call_args_begin() {
|
||||
// 3 = callTarget, #callArgs, flag
|
||||
int Offset = callArgsBeginOffset();
|
||||
assert(Offset <= (int)StatepointCS.arg_size());
|
||||
return StatepointCS.arg_begin() + Offset;
|
||||
assert(CallArgsBeginPos <= (int)StatepointCS.arg_size());
|
||||
return StatepointCS.arg_begin() + CallArgsBeginPos;
|
||||
}
|
||||
typename CallSiteTy::arg_iterator call_args_end() {
|
||||
int Offset = callArgsBeginOffset() + getNumCallArgs();
|
||||
int Offset = CallArgsBeginPos + getNumCallArgs();
|
||||
assert(Offset <= (int)StatepointCS.arg_size());
|
||||
return StatepointCS.arg_begin() + Offset;
|
||||
}
|
||||
@ -108,9 +106,16 @@ public:
|
||||
return iterator_range<arg_iterator>(call_args_begin(), call_args_end());
|
||||
}
|
||||
|
||||
/// Number of additional arguments excluding those intended
|
||||
/// for garbage collection.
|
||||
int getNumTotalVMSArgs() {
|
||||
Value *NumVMSArgs = *call_args_end();
|
||||
return cast<ConstantInt>(NumVMSArgs)->getZExtValue();
|
||||
}
|
||||
|
||||
typename CallSiteTy::arg_iterator vm_state_begin() { return call_args_end(); }
|
||||
typename CallSiteTy::arg_iterator vm_state_end() {
|
||||
int Offset = 3 + getNumCallArgs() + 1 + getNumTotalVMSArgs();
|
||||
int Offset = CallArgsBeginPos + getNumCallArgs() + 1 + getNumTotalVMSArgs();
|
||||
assert(Offset <= (int)StatepointCS.arg_size());
|
||||
return StatepointCS.arg_begin() + Offset;
|
||||
}
|
||||
@ -120,12 +125,6 @@ public:
|
||||
return iterator_range<arg_iterator>(vm_state_begin(), vm_state_end());
|
||||
}
|
||||
|
||||
typename CallSiteTy::arg_iterator first_vm_state_stack_begin() {
|
||||
// 6 = numTotalVMSArgs, 1st_objectID, 1st_bci,
|
||||
// 1st_#stack, 1st_#local, 1st_#monitor
|
||||
return vm_state_begin() + 6;
|
||||
}
|
||||
|
||||
typename CallSiteTy::arg_iterator gc_args_begin() { return vm_state_end(); }
|
||||
typename CallSiteTy::arg_iterator gc_args_end() {
|
||||
return StatepointCS.arg_end();
|
||||
|
@ -250,8 +250,9 @@ lowerCallFromStatepoint(ImmutableStatepoint ISP, MachineBasicBlock *LandingPad,
|
||||
|
||||
SDValue ReturnValue, CallEndVal;
|
||||
std::tie(ReturnValue, CallEndVal) = Builder.lowerCallOperands(
|
||||
ISP.getCallSite(), ISP.callArgsBeginOffset(), ISP.getNumCallArgs(),
|
||||
ActualCallee, DefTy, LandingPad, false /* IsPatchPoint */);
|
||||
ISP.getCallSite(), ImmutableStatepoint::CallArgsBeginPos,
|
||||
ISP.getNumCallArgs(), ActualCallee, DefTy, LandingPad,
|
||||
false /* IsPatchPoint */);
|
||||
|
||||
SDNode *CallEnd = CallEndVal.getNode();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user