mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
[Statepoint] Clean up Statepoint.h: accessor names.
Use getFoo() as accessors consistently and some other naming changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236564 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d77522093e
commit
1df2d64d55
@ -69,24 +69,26 @@ class StatepointBase {
|
||||
}
|
||||
|
||||
/// Return the value actually being called or invoked.
|
||||
ValueTy *actualCallee() {
|
||||
return StatepointCS.getArgument(0);
|
||||
}
|
||||
ValueTy *getActualCallee() { return StatepointCS.getArgument(0); }
|
||||
|
||||
/// Return the type of the value returned by the call underlying the
|
||||
/// statepoint.
|
||||
Type *actualReturnType() {
|
||||
Type *getActualReturnType() {
|
||||
auto *FTy = cast<FunctionType>(
|
||||
cast<PointerType>(actualCallee()->getType())->getElementType());
|
||||
cast<PointerType>(getActualCallee()->getType())->getElementType());
|
||||
return FTy->getReturnType();
|
||||
}
|
||||
|
||||
/// Number of arguments to be passed to the actual callee.
|
||||
int numCallArgs() {
|
||||
int getNumCallArgs() {
|
||||
return cast<ConstantInt>(StatepointCS.getArgument(1))->getZExtValue();
|
||||
}
|
||||
|
||||
/// Number of additional arguments excluding those intended
|
||||
/// for garbage collection.
|
||||
int numTotalVMSArgs() {
|
||||
return cast<ConstantInt>(StatepointCS.getArgument(3 + numCallArgs()))->getZExtValue();
|
||||
int getNumTotalVMSArgs() {
|
||||
const Value *NumVMSArgs = StatepointCS.getArgument(3 + getNumCallArgs());
|
||||
return cast<ConstantInt>(NumVMSArgs)->getZExtValue();
|
||||
}
|
||||
|
||||
int callArgsBeginOffset() { return 3; }
|
||||
@ -98,7 +100,7 @@ class StatepointBase {
|
||||
return StatepointCS.arg_begin() + Offset;
|
||||
}
|
||||
typename CallSiteTy::arg_iterator call_args_end() {
|
||||
int Offset = callArgsBeginOffset() + numCallArgs();
|
||||
int Offset = callArgsBeginOffset() + getNumCallArgs();
|
||||
assert(Offset <= (int)StatepointCS.arg_size());
|
||||
return StatepointCS.arg_begin() + Offset;
|
||||
}
|
||||
@ -112,7 +114,7 @@ class StatepointBase {
|
||||
return call_args_end();
|
||||
}
|
||||
typename CallSiteTy::arg_iterator vm_state_end() {
|
||||
int Offset = 3 + numCallArgs() + 1 + numTotalVMSArgs();
|
||||
int Offset = 3 + getNumCallArgs() + 1 + getNumTotalVMSArgs();
|
||||
assert(Offset <= (int)StatepointCS.arg_size());
|
||||
return StatepointCS.arg_begin() + Offset;
|
||||
}
|
||||
@ -151,7 +153,7 @@ class StatepointBase {
|
||||
/// include incorrect length prefixes for variable length sections or
|
||||
/// illegal values for parameters.
|
||||
void verify() {
|
||||
assert(numCallArgs() >= 0 &&
|
||||
assert(getNumCallArgs() >= 0 &&
|
||||
"number of arguments to actually callee can't be negative");
|
||||
|
||||
// The internal asserts in the iterator accessors do the rest.
|
||||
@ -220,43 +222,48 @@ class GCRelocateOperands {
|
||||
}
|
||||
|
||||
/// The statepoint with which this gc.relocate is associated.
|
||||
const Instruction *statepoint() {
|
||||
const Value *token = RelocateCS.getArgument(0);
|
||||
const Instruction *getStatepoint() {
|
||||
const Value *Token = RelocateCS.getArgument(0);
|
||||
|
||||
// This takes care both of relocates for call statepoints and relocates
|
||||
// on normal path of invoke statepoint.
|
||||
if (!isa<ExtractValueInst>(token)) {
|
||||
return cast<Instruction>(token);
|
||||
if (!isa<ExtractValueInst>(Token)) {
|
||||
return cast<Instruction>(Token);
|
||||
}
|
||||
|
||||
// This relocate is on exceptional path of an invoke statepoint
|
||||
const BasicBlock *invokeBB =
|
||||
cast<Instruction>(token)->getParent()->getUniquePredecessor();
|
||||
const BasicBlock *InvokeBB =
|
||||
cast<Instruction>(Token)->getParent()->getUniquePredecessor();
|
||||
|
||||
assert(invokeBB && "safepoints should have unique landingpads");
|
||||
assert(invokeBB->getTerminator() && "safepoint block should be well formed");
|
||||
assert(isStatepoint(invokeBB->getTerminator()));
|
||||
assert(InvokeBB && "safepoints should have unique landingpads");
|
||||
assert(InvokeBB->getTerminator() &&
|
||||
"safepoint block should be well formed");
|
||||
assert(isStatepoint(InvokeBB->getTerminator()));
|
||||
|
||||
return invokeBB->getTerminator();
|
||||
return InvokeBB->getTerminator();
|
||||
}
|
||||
|
||||
/// The index into the associate statepoint's argument list
|
||||
/// which contains the base pointer of the pointer whose
|
||||
/// relocation this gc.relocate describes.
|
||||
unsigned basePtrIndex() {
|
||||
unsigned getBasePtrIndex() {
|
||||
return cast<ConstantInt>(RelocateCS.getArgument(1))->getZExtValue();
|
||||
}
|
||||
|
||||
/// The index into the associate statepoint's argument list which
|
||||
/// contains the pointer whose relocation this gc.relocate describes.
|
||||
unsigned derivedPtrIndex() {
|
||||
unsigned getDerivedPtrIndex() {
|
||||
return cast<ConstantInt>(RelocateCS.getArgument(2))->getZExtValue();
|
||||
}
|
||||
Value *basePtr() {
|
||||
ImmutableCallSite CS(statepoint());
|
||||
return *(CS.arg_begin() + basePtrIndex());
|
||||
|
||||
Value *getBasePtr() {
|
||||
ImmutableCallSite CS(getStatepoint());
|
||||
return *(CS.arg_begin() + getBasePtrIndex());
|
||||
}
|
||||
Value *derivedPtr() {
|
||||
ImmutableCallSite CS(statepoint());
|
||||
return *(CS.arg_begin() + derivedPtrIndex());
|
||||
|
||||
Value *getDerivedPtr() {
|
||||
ImmutableCallSite CS(getStatepoint());
|
||||
return *(CS.arg_begin() + getDerivedPtrIndex());
|
||||
}
|
||||
};
|
||||
|
||||
@ -265,22 +272,19 @@ std::vector<GCRelocateOperands>
|
||||
StatepointBase<InstructionTy, ValueTy, CallSiteTy>::
|
||||
getRelocates(ImmutableStatepoint &IS) {
|
||||
|
||||
std::vector<GCRelocateOperands> res;
|
||||
std::vector<GCRelocateOperands> Result;
|
||||
|
||||
ImmutableCallSite StatepointCS = IS.getCallSite();
|
||||
|
||||
// Search for relocated pointers. Note that working backwards from the
|
||||
// gc_relocates ensures that we only get pairs which are actually relocated
|
||||
// and used after the statepoint.
|
||||
for (const User *U : StatepointCS.getInstruction()->users()) {
|
||||
if (isGCRelocate(U)) {
|
||||
res.push_back(GCRelocateOperands(U));
|
||||
}
|
||||
}
|
||||
for (const User *U : StatepointCS.getInstruction()->users())
|
||||
if (isGCRelocate(U))
|
||||
Result.push_back(GCRelocateOperands(U));
|
||||
|
||||
if (!StatepointCS.isInvoke()) {
|
||||
return res;
|
||||
}
|
||||
if (!StatepointCS.isInvoke())
|
||||
return Result;
|
||||
|
||||
// We need to scan thorough exceptional relocations if it is invoke statepoint
|
||||
LandingPadInst *LandingPad =
|
||||
@ -289,19 +293,17 @@ std::vector<GCRelocateOperands>
|
||||
// Search for extract value from landingpad instruction to which
|
||||
// gc relocates will be attached
|
||||
for (const User *LandingPadUser : LandingPad->users()) {
|
||||
if (!isa<ExtractValueInst>(LandingPadUser)) {
|
||||
if (!isa<ExtractValueInst>(LandingPadUser))
|
||||
continue;
|
||||
}
|
||||
|
||||
// gc relocates should be attached to this extract value
|
||||
for (const User *U : LandingPadUser->users()) {
|
||||
if (isGCRelocate(U)) {
|
||||
res.push_back(GCRelocateOperands(U));
|
||||
}
|
||||
}
|
||||
for (const User *U : LandingPadUser->users())
|
||||
if (isGCRelocate(U))
|
||||
Result.push_back(GCRelocateOperands(U));
|
||||
}
|
||||
return res;
|
||||
return Result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -2957,7 +2957,8 @@ static bool isDereferenceablePointer(const Value *V, const DataLayout &DL,
|
||||
if (const IntrinsicInst *I = dyn_cast<IntrinsicInst>(V))
|
||||
if (I->getIntrinsicID() == Intrinsic::experimental_gc_relocate) {
|
||||
GCRelocateOperands RelocateInst(I);
|
||||
return isDereferenceablePointer(RelocateInst.derivedPtr(), DL, Visited);
|
||||
return isDereferenceablePointer(RelocateInst.getDerivedPtr(), DL,
|
||||
Visited);
|
||||
}
|
||||
|
||||
if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
|
||||
|
@ -531,8 +531,8 @@ static void computeBaseDerivedRelocateMap(
|
||||
for (auto &U : AllRelocateCalls) {
|
||||
GCRelocateOperands ThisRelocate(U);
|
||||
IntrinsicInst *I = cast<IntrinsicInst>(U);
|
||||
auto K = std::make_pair(ThisRelocate.basePtrIndex(),
|
||||
ThisRelocate.derivedPtrIndex());
|
||||
auto K = std::make_pair(ThisRelocate.getBasePtrIndex(),
|
||||
ThisRelocate.getDerivedPtrIndex());
|
||||
RelocateIdxMap.insert(std::make_pair(K, I));
|
||||
}
|
||||
for (auto &Item : RelocateIdxMap) {
|
||||
@ -581,15 +581,15 @@ simplifyRelocatesOffABase(IntrinsicInst *RelocatedBase,
|
||||
GCRelocateOperands MasterRelocate(RelocatedBase);
|
||||
GCRelocateOperands ThisRelocate(ToReplace);
|
||||
|
||||
assert(ThisRelocate.basePtrIndex() == MasterRelocate.basePtrIndex() &&
|
||||
assert(ThisRelocate.getBasePtrIndex() == MasterRelocate.getBasePtrIndex() &&
|
||||
"Not relocating a derived object of the original base object");
|
||||
if (ThisRelocate.basePtrIndex() == ThisRelocate.derivedPtrIndex()) {
|
||||
if (ThisRelocate.getBasePtrIndex() == ThisRelocate.getDerivedPtrIndex()) {
|
||||
// A duplicate relocate call. TODO: coalesce duplicates.
|
||||
continue;
|
||||
}
|
||||
|
||||
Value *Base = ThisRelocate.basePtr();
|
||||
auto Derived = dyn_cast<GetElementPtrInst>(ThisRelocate.derivedPtr());
|
||||
Value *Base = ThisRelocate.getBasePtr();
|
||||
auto Derived = dyn_cast<GetElementPtrInst>(ThisRelocate.getDerivedPtr());
|
||||
if (!Derived || Derived->getPointerOperand() != Base)
|
||||
continue;
|
||||
|
||||
|
@ -229,7 +229,7 @@ lowerCallFromStatepoint(ImmutableStatepoint ISP, MachineBasicBlock *LandingPad,
|
||||
|
||||
ImmutableCallSite CS(ISP.getCallSite());
|
||||
|
||||
SDValue ActualCallee = Builder.getValue(ISP.actualCallee());
|
||||
SDValue ActualCallee = Builder.getValue(ISP.getActualCallee());
|
||||
|
||||
// Handle immediate and symbolic callees.
|
||||
if (auto *ConstCallee = dyn_cast<ConstantSDNode>(ActualCallee.getNode()))
|
||||
@ -245,12 +245,12 @@ lowerCallFromStatepoint(ImmutableStatepoint ISP, MachineBasicBlock *LandingPad,
|
||||
assert(CS.getCallingConv() != CallingConv::AnyReg &&
|
||||
"anyregcc is not supported on statepoints!");
|
||||
|
||||
Type *DefTy = ISP.actualReturnType();
|
||||
Type *DefTy = ISP.getActualReturnType();
|
||||
bool HasDef = !DefTy->isVoidTy();
|
||||
|
||||
SDValue ReturnValue, CallEndVal;
|
||||
std::tie(ReturnValue, CallEndVal) = Builder.lowerCallOperands(
|
||||
ISP.getCallSite(), ISP.callArgsBeginOffset(), ISP.numCallArgs(),
|
||||
ISP.getCallSite(), ISP.callArgsBeginOffset(), ISP.getNumCallArgs(),
|
||||
ActualCallee, DefTy, LandingPad, false /* IsPatchPoint */);
|
||||
|
||||
SDNode *CallEnd = CallEndVal.getNode();
|
||||
@ -286,10 +286,10 @@ lowerCallFromStatepoint(ImmutableStatepoint ISP, MachineBasicBlock *LandingPad,
|
||||
// register with correct type and save value into it manually.
|
||||
// TODO: To eliminate this problem we can remove gc.result intrinsics
|
||||
// completelly and make statepoint call to return a tuple.
|
||||
unsigned Reg = Builder.FuncInfo.CreateRegs(ISP.actualReturnType());
|
||||
unsigned Reg = Builder.FuncInfo.CreateRegs(ISP.getActualReturnType());
|
||||
RegsForValue RFV(*Builder.DAG.getContext(),
|
||||
Builder.DAG.getTargetLoweringInfo(), Reg,
|
||||
ISP.actualReturnType());
|
||||
ISP.getActualReturnType());
|
||||
SDValue Chain = Builder.DAG.getEntryNode();
|
||||
|
||||
RFV.getCopyToRegs(ReturnValue, Builder.DAG, Builder.getCurSDLoc(), Chain,
|
||||
@ -325,8 +325,8 @@ static void getIncomingStatepointGCValues(
|
||||
for (GCRelocateOperands relocateOpers :
|
||||
StatepointSite.getRelocates(StatepointSite)) {
|
||||
Relocs.push_back(relocateOpers.getUnderlyingCallSite().getInstruction());
|
||||
Bases.push_back(relocateOpers.basePtr());
|
||||
Ptrs.push_back(relocateOpers.derivedPtr());
|
||||
Bases.push_back(relocateOpers.getBasePtr());
|
||||
Ptrs.push_back(relocateOpers.getDerivedPtr());
|
||||
}
|
||||
|
||||
// Remove any redundant llvm::Values which map to the same SDValue as another
|
||||
@ -482,7 +482,7 @@ static void lowerStatepointMetaArgs(SmallVectorImpl<SDValue> &Ops,
|
||||
// First, prefix the list with the number of unique values to be
|
||||
// lowered. Note that this is the number of *Values* not the
|
||||
// number of SDValues required to lower them.
|
||||
const int NumVMSArgs = StatepointSite.numTotalVMSArgs();
|
||||
const int NumVMSArgs = StatepointSite.getNumTotalVMSArgs();
|
||||
Ops.push_back( Builder.DAG.getTargetConstant(StackMaps::ConstantOp,
|
||||
Builder.getCurSDLoc(),
|
||||
MVT::i64));
|
||||
@ -675,7 +675,7 @@ void SelectionDAGBuilder::visitGCResult(const CallInst &CI) {
|
||||
// different, and getValue() will use CopyFromReg of the wrong type,
|
||||
// which is always i32 in our case.
|
||||
PointerType *CalleeType =
|
||||
cast<PointerType>(ImmutableStatepoint(I).actualCallee()->getType());
|
||||
cast<PointerType>(ImmutableStatepoint(I).getActualCallee()->getType());
|
||||
Type *RetTy =
|
||||
cast<FunctionType>(CalleeType->getElementType())->getReturnType();
|
||||
SDValue CopyFromReg = getCopyFromRegs(I, RetTy);
|
||||
@ -694,7 +694,7 @@ void SelectionDAGBuilder::visitGCRelocate(const CallInst &CI) {
|
||||
#endif
|
||||
|
||||
GCRelocateOperands relocateOpers(&CI);
|
||||
SDValue SD = getValue(relocateOpers.derivedPtr());
|
||||
SDValue SD = getValue(relocateOpers.getDerivedPtr());
|
||||
|
||||
if (isa<ConstantSDNode>(SD) || isa<FrameIndexSDNode>(SD)) {
|
||||
// We didn't need to spill these special cases (constants and allocas).
|
||||
|
@ -2654,9 +2654,9 @@ void AssemblyWriter::printGCRelocateComment(const Value &V) {
|
||||
GCRelocateOperands GCOps(cast<Instruction>(&V));
|
||||
|
||||
Out << " ; (";
|
||||
writeOperand(GCOps.basePtr(), false);
|
||||
writeOperand(GCOps.getBasePtr(), false);
|
||||
Out << ", ";
|
||||
writeOperand(GCOps.derivedPtr(), false);
|
||||
writeOperand(GCOps.getDerivedPtr(), false);
|
||||
Out << ")";
|
||||
}
|
||||
|
||||
|
@ -3315,7 +3315,7 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
|
||||
// Verify rest of the relocate arguments
|
||||
|
||||
GCRelocateOperands ops(&CI);
|
||||
ImmutableCallSite StatepointCS(ops.statepoint());
|
||||
ImmutableCallSite StatepointCS(ops.getStatepoint());
|
||||
|
||||
// Both the base and derived must be piped through the safepoint
|
||||
Value* Base = CI.getArgOperand(1);
|
||||
@ -3362,7 +3362,7 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
|
||||
|
||||
// Assert that the result type matches the type of the relocated pointer
|
||||
GCRelocateOperands Operands(&CI);
|
||||
Assert(Operands.derivedPtr()->getType() == CI.getType(),
|
||||
Assert(Operands.getDerivedPtr()->getType() == CI.getType(),
|
||||
"gc.relocate: relocating a pointer shouldn't change its type", &CI);
|
||||
break;
|
||||
}
|
||||
|
@ -1196,7 +1196,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
// facts about the relocate value, while being careful to
|
||||
// preserve relocation semantics.
|
||||
GCRelocateOperands Operands(II);
|
||||
Value *DerivedPtr = Operands.derivedPtr();
|
||||
Value *DerivedPtr = Operands.getDerivedPtr();
|
||||
|
||||
// Remove the relocation if unused, note that this check is required
|
||||
// to prevent the cases below from looping forever.
|
||||
|
@ -1336,7 +1336,8 @@ insertRelocationStores(iterator_range<Value::user_iterator> gcRelocs,
|
||||
}
|
||||
|
||||
GCRelocateOperands relocateOperands(relocatedValue);
|
||||
Value *originalValue = const_cast<Value *>(relocateOperands.derivedPtr());
|
||||
Value *originalValue =
|
||||
const_cast<Value *>(relocateOperands.getDerivedPtr());
|
||||
assert(allocaMap.count(originalValue));
|
||||
Value *alloca = allocaMap[originalValue];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user