本文整理汇总了C++中mangle::Mangler::mangleGlobalGetterEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ Mangler::mangleGlobalGetterEntity方法的具体用法?C++ Mangler::mangleGlobalGetterEntity怎么用?C++ Mangler::mangleGlobalGetterEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mangle::Mangler
的用法示例。
在下文中一共展示了Mangler::mangleGlobalGetterEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResultInfo
/// Create a getter function from the initializer function.
static SILFunction *genGetterFromInit(SILFunction *InitF, VarDecl *varDecl) {
// Generate a getter from the global init function without side-effects.
Mangle::Mangler getterMangler;
getterMangler.mangleGlobalGetterEntity(varDecl);
auto getterName = getterMangler.finalize();
// Check if a getter was generated already.
if (auto *F = InitF->getModule().lookUpFunction(getterName))
return F;
auto refType = varDecl->getType().getCanonicalTypeOrNull();
// Function takes no arguments and returns refType
SILResultInfo ResultInfo(refType, ResultConvention::Owned);
SILFunctionType::ExtInfo EInfo;
EInfo = EInfo.withRepresentation(SILFunctionType::Representation::Thin);
auto LoweredType = SILFunctionType::get(nullptr, EInfo,
ParameterConvention::Direct_Owned, { }, ResultInfo, None,
InitF->getASTContext());
auto *GetterF = InitF->getModule().getOrCreateFunction(InitF->getLocation(),
getterName, SILLinkage::PrivateExternal, LoweredType,
IsBare_t::IsBare, IsTransparent_t::IsNotTransparent,
IsFragile_t::IsFragile);
auto *EntryBB = GetterF->createBasicBlock();
// Copy InitF into GetterF
BasicBlockCloner Cloner(&*InitF->begin(), EntryBB, /*WithinFunction=*/false);
Cloner.clone();
GetterF->setInlined();
// Find the store instruction
auto BB = EntryBB;
SILValue Val;
SILInstruction *Store;
for (auto II = BB->begin(), E = BB->end(); II != E;) {
auto &I = *II++;
if (isa<AllocGlobalInst>(&I)) {
I.eraseFromParent();
continue;
}
if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
Val = SI->getSrc();
Store = SI;
continue;
}
if (ReturnInst *RI = dyn_cast<ReturnInst>(&I)) {
SILBuilderWithScope B(RI);
B.createReturn(RI->getLoc(), Val);
eraseUsesOfInstruction(RI);
recursivelyDeleteTriviallyDeadInstructions(RI, true);
recursivelyDeleteTriviallyDeadInstructions(Store, true);
return GetterF;
}
}
InitF->getModule().getFunctionList().addNodeToList(GetterF);
return GetterF;
}
示例2: selectMangling
static std::string mangleGetter(VarDecl *varDecl) {
Mangle::Mangler getterMangler;
getterMangler.append("_T");
getterMangler.mangleGlobalGetterEntity(varDecl);
std::string Old = getterMangler.finalize();
NewMangling::ASTMangler NewMangler;
std::string New = NewMangler.mangleGlobalGetterEntity(varDecl);
return NewMangling::selectMangling(Old, New);
}
示例3: ResultInfo
/// Generate getter from the initialization code whose
/// result is stored by a given store instruction.
static SILFunction *genGetterFromInit(StoreInst *Store,
SILGlobalVariable *SILG) {
auto *varDecl = SILG->getDecl();
Mangle::Mangler getterMangler;
getterMangler.mangleGlobalGetterEntity(varDecl);
auto getterName = getterMangler.finalize();
// Check if a getter was generated already.
if (auto *F = Store->getModule().lookUpFunction(getterName))
return F;
// Find the code that performs the initialization first.
// Recursively walk the SIL value being assigned to the SILG.
auto V = Store->getSrc();
SmallVector<SILInstruction *, 8> ReverseInsns;
SmallVector<SILInstruction *, 8> Insns;
ReverseInsns.push_back(Store);
ReverseInsns.push_back(dyn_cast<SILInstruction>(Store->getDest()));
if (!analyzeStaticInitializer(V, ReverseInsns))
return nullptr;
// Produce a correct order of instructions.
while (!ReverseInsns.empty()) {
Insns.push_back(ReverseInsns.pop_back_val());
}
// Generate a getter from the global init function without side-effects.
auto refType = varDecl->getType().getCanonicalTypeOrNull();
// Function takes no arguments and returns refType
SILResultInfo ResultInfo(refType, ResultConvention::Owned);
SILFunctionType::ExtInfo EInfo;
EInfo = EInfo.withRepresentation(SILFunctionType::Representation::Thin);
auto LoweredType = SILFunctionType::get(nullptr, EInfo,
ParameterConvention::Direct_Owned, { }, ResultInfo, None,
Store->getModule().getASTContext());
auto *GetterF = Store->getModule().getOrCreateFunction(Store->getLoc(),
getterName, SILLinkage::PrivateExternal, LoweredType,
IsBare_t::IsBare, IsTransparent_t::IsNotTransparent,
IsFragile_t::IsFragile);
GetterF->setDebugScope(Store->getFunction()->getDebugScope());
auto *EntryBB = GetterF->createBasicBlock();
// Copy instructions into GetterF
InstructionsCloner Cloner(*GetterF, Insns, EntryBB);
Cloner.clone();
GetterF->setInlined();
// Find the store instruction
auto BB = EntryBB;
SILValue Val;
for (auto &I : *BB) {
if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
Val = SI->getSrc();
SILBuilderWithScope B(SI);
B.createReturn(SI->getLoc(), Val);
eraseUsesOfInstruction(SI);
recursivelyDeleteTriviallyDeadInstructions(SI, true);
return GetterF;
}
}
Store->getModule().getFunctionList().addNodeToList(GetterF);
return GetterF;
}