本文整理汇总了C++中AttributeSet类的典型用法代码示例。如果您正苦于以下问题:C++ AttributeSet类的具体用法?C++ AttributeSet怎么用?C++ AttributeSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AttributeSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resetTargetOptions
const HexagonSubtarget *
HexagonTargetMachine::getSubtargetImpl(const Function &F) const {
AttributeSet FnAttrs = F.getAttributes();
Attribute CPUAttr =
FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-cpu");
Attribute FSAttr =
FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-features");
std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
? CPUAttr.getValueAsString().str()
: TargetCPU;
std::string FS = !FSAttr.hasAttribute(Attribute::None)
? FSAttr.getValueAsString().str()
: TargetFS;
auto &I = SubtargetMap[CPU + FS];
if (!I) {
// This needs to be done before we create a new subtarget since any
// creation will depend on the TM and the code generation flags on the
// function that reside in TargetOptions.
resetTargetOptions(F);
I = llvm::make_unique<HexagonSubtarget>(TargetTriple, CPU, FS, *this);
}
return I.get();
}
示例2: RemoveAttrs
// removeAttribute() currently does not work on Attribute::Alignment
// (it fails with an assertion error), so we have to take a more
// convoluted route to removing this attribute by recreating the
// AttributeSet.
AttributeSet RemoveAttrs(LLVMContext &Context, AttributeSet Attrs) {
SmallVector<AttributeSet, 8> AttrList;
for (unsigned Slot = 0; Slot < Attrs.getNumSlots(); ++Slot) {
unsigned Index = Attrs.getSlotIndex(Slot);
AttrBuilder AB;
for (AttributeSet::iterator Attr = Attrs.begin(Slot), E = Attrs.end(Slot);
Attr != E; ++Attr) {
if (Attr->isEnumAttribute() &&
Attr->getKindAsEnum() != Attribute::ByVal &&
Attr->getKindAsEnum() != Attribute::StructRet) {
AB.addAttribute(*Attr);
}
// IR semantics require that ByVal implies NoAlias. However, IR
// semantics do not require StructRet to imply NoAlias. For
// example, a global variable address can be passed as a
// StructRet argument, although Clang does not do so and Clang
// explicitly adds NoAlias to StructRet arguments.
if (Attr->isEnumAttribute() &&
Attr->getKindAsEnum() == Attribute::ByVal) {
AB.addAttribute(Attribute::get(Context, Attribute::NoAlias));
}
}
AttrList.push_back(AttributeSet::get(Context, Index, AB));
}
return AttributeSet::get(Context, AttrList);
}
示例3: produceCompactUnwindFrame
static bool produceCompactUnwindFrame(MachineFunction &MF) {
const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>();
AttributeSet Attrs = MF.getFunction()->getAttributes();
return Subtarget.isTargetMachO() &&
!(Subtarget.getTargetLowering()->supportSwiftError() &&
Attrs.hasAttrSomewhere(Attribute::SwiftError));
}
示例4: processCallSite
/// Infer nonnull attributes for the arguments at the specified callsite.
static bool processCallSite(CallSite CS, LazyValueInfo *LVI) {
SmallVector<unsigned, 4> Indices;
unsigned ArgNo = 0;
for (Value *V : CS.args()) {
PointerType *Type = dyn_cast<PointerType>(V->getType());
// Try to mark pointer typed parameters as non-null. We skip the
// relatively expensive analysis for constants which are obviously either
// null or non-null to start with.
if (Type && !CS.paramHasAttr(ArgNo + 1, Attribute::NonNull) &&
!isa<Constant>(V) &&
LVI->getPredicateAt(ICmpInst::ICMP_EQ, V,
ConstantPointerNull::get(Type),
CS.getInstruction()) == LazyValueInfo::False)
Indices.push_back(ArgNo + 1);
ArgNo++;
}
assert(ArgNo == CS.arg_size() && "sanity check");
if (Indices.empty())
return false;
AttributeSet AS = CS.getAttributes();
LLVMContext &Ctx = CS.getInstruction()->getContext();
AS = AS.addAttribute(Ctx, Indices, Attribute::get(Ctx, Attribute::NonNull));
CS.setAttributes(AS);
return true;
}
示例5: printError
Value* ARMIREmitter::visitCALL(const SDNode *N) {
const ConstantSDNode *DestNode = dyn_cast<ConstantSDNode>(N->getOperand(0));
if (!DestNode) {
printError("visitCALL: Not a constant integer for call!");
return NULL;
}
int64_t DestInt = DestNode->getSExtValue();
int64_t PC = Dec->getDisassembler()->getDebugOffset(N->getDebugLoc());
unsigned InstrSize = 8; // Note: ARM defaults to 4; should be 8.
int64_t Tgt = PC + InstrSize + DestInt;
// TODO: Look up address in symbol table.
std::string FName = Dec->getDisassembler()->getFunctionName(Tgt);
Module *Mod = IRB->GetInsertBlock()->getParent()->getParent();
FunctionType *FT =
FunctionType::get(Type::getPrimitiveType(Mod->getContext(),
Type::VoidTyID), false);
Twine TgtAddr(Tgt);
AttributeSet AS;
AS = AS.addAttribute(Mod->getContext(), AttributeSet::FunctionIndex,
"Address", TgtAddr.str());
Value* Proto = Mod->getOrInsertFunction(FName, FT, AS);
// CallInst* Call =
IRB->CreateCall(dyn_cast<Value>(Proto));
// TODO: Technically visitCall sets the LR to IP+8. We should return that.
VisitMap[N] = NULL;
return NULL;
}
示例6: AdjustCallerSSPLevel
/// \brief If the inlined function had a higher stack protection level than the
/// calling function, then bump up the caller's stack protection level.
static void AdjustCallerSSPLevel(Function *Caller, Function *Callee) {
// If upgrading the SSP attribute, clear out the old SSP Attributes first.
// Having multiple SSP attributes doesn't actually hurt, but it adds useless
// clutter to the IR.
AttrBuilder B;
B.addAttribute(Attribute::StackProtect)
.addAttribute(Attribute::StackProtectStrong);
AttributeSet OldSSPAttr = AttributeSet::get(Caller->getContext(),
AttributeSet::FunctionIndex,
B);
AttributeSet CallerAttr = Caller->getAttributes(),
CalleeAttr = Callee->getAttributes();
if (CalleeAttr.hasAttribute(AttributeSet::FunctionIndex,
Attribute::StackProtectReq)) {
Caller->removeAttributes(AttributeSet::FunctionIndex, OldSSPAttr);
Caller->addFnAttr(Attribute::StackProtectReq);
} else if (CalleeAttr.hasAttribute(AttributeSet::FunctionIndex,
Attribute::StackProtectStrong) &&
!CallerAttr.hasAttribute(AttributeSet::FunctionIndex,
Attribute::StackProtectReq)) {
Caller->removeAttributes(AttributeSet::FunctionIndex, OldSSPAttr);
Caller->addFnAttr(Attribute::StackProtectStrong);
} else if (CalleeAttr.hasAttribute(AttributeSet::FunctionIndex,
Attribute::StackProtect) &&
!CallerAttr.hasAttribute(AttributeSet::FunctionIndex,
Attribute::StackProtectReq) &&
!CallerAttr.hasAttribute(AttributeSet::FunctionIndex,
Attribute::StackProtectStrong))
Caller->addFnAttr(Attribute::StackProtect);
}
示例7: whichFPReturnVariant
//
// Returns of float, double and complex need to be handled with a helper
// function.
//
static bool fixupFPReturnAndCall
(Function &F, Module *M, const MipsSubtarget &Subtarget) {
bool Modified = false;
LLVMContext &C = M->getContext();
Type *MyVoid = Type::getVoidTy(C);
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
for (BasicBlock::iterator I = BB->begin(), E = BB->end();
I != E; ++I) {
Instruction &Inst = *I;
if (const ReturnInst *RI = dyn_cast<ReturnInst>(I)) {
Value *RVal = RI->getReturnValue();
if (!RVal) continue;
//
// If there is a return value and it needs a helper function,
// figure out which one and add a call before the actual
// return to this helper. The purpose of the helper is to move
// floating point values from their soft float return mapping to
// where they would have been mapped to in floating point registers.
//
Type *T = RVal->getType();
FPReturnVariant RV = whichFPReturnVariant(T);
if (RV == NoFPRet) continue;
static const char* Helper[NoFPRet] =
{"__mips16_ret_sf", "__mips16_ret_df", "__mips16_ret_sc",
"__mips16_ret_dc"};
const char *Name = Helper[RV];
AttributeSet A;
Value *Params[] = {RVal};
Modified = true;
//
// These helper functions have a different calling ABI so
// this __Mips16RetHelper indicates that so that later
// during call setup, the proper call lowering to the helper
// functions will take place.
//
A = A.addAttribute(C, AttributeSet::FunctionIndex,
"__Mips16RetHelper");
A = A.addAttribute(C, AttributeSet::FunctionIndex,
Attribute::ReadNone);
A = A.addAttribute(C, AttributeSet::FunctionIndex,
Attribute::NoInline);
Value *F = (M->getOrInsertFunction(Name, A, MyVoid, T, NULL));
CallInst::Create(F, Params, "", &Inst );
} else if (const CallInst *CI = dyn_cast<CallInst>(I)) {
// pic mode calls are handled by already defined
// helper functions
if (Subtarget.getRelocationModel() != Reloc::PIC_ ) {
Function *F_ = CI->getCalledFunction();
if (F_ && !isIntrinsicInline(F_) && needsFPHelperFromSig(*F_)) {
assureFPCallStub(*F_, M, Subtarget);
Modified=true;
}
}
}
}
return Modified;
}
示例8: LLVMRemoveFunctionAttributes
extern "C" void LLVMRemoveFunctionAttributes(LLVMValueRef Fn, unsigned index, uint64_t Val) {
Function *A = unwrap<Function>(Fn);
const AttributeSet PAL = A->getAttributes();
AttrBuilder B(Val);
const AttributeSet PALnew =
PAL.removeAttributes(A->getContext(), index,
AttributeSet::get(A->getContext(), index, B));
A->setAttributes(PALnew);
}
示例9: EnumerateAttributes
void ValueEnumerator::EnumerateAttributes(const AttributeSet &PAL) {
if (PAL.isEmpty()) return; // null is always 0.
// Do a lookup.
unsigned &Entry = AttributeMap[PAL.getRawPointer()];
if (Entry == 0) {
// Never saw this before, add it.
Attribute.push_back(PAL);
Entry = Attribute.size();
}
}
示例10: LLVMRemoveFunctionAttr2
void LLVMRemoveFunctionAttr2(LLVMValueRef Fn, uint64_t PA) {
Function *Func = unwrap<Function>(Fn);
const AttributeSet PAL = Func->getAttributes();
AttrBuilder B(PA);
const AttributeSet PALnew =
PAL.removeAttributes(Func->getContext(), AttributeSet::FunctionIndex,
AttributeSet::get(Func->getContext(),
AttributeSet::FunctionIndex, B));
Func->setAttributes(PALnew);
}
示例11: getAttributesAsString
static std::string getAttributesAsString(AttributeSet Attrs) {
std::string AttrsAsString;
for (unsigned Slot = 0; Slot < Attrs.getNumSlots(); ++Slot) {
for (AttributeSet::iterator Attr = Attrs.begin(Slot),
E = Attrs.end(Slot); Attr != E; ++Attr) {
AttrsAsString += " ";
AttrsAsString += Attr->getAsString();
}
}
return AttrsAsString;
}
示例12: LLVMRustRemoveFunctionAttributes
extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
unsigned Index,
LLVMRustAttribute RustAttr) {
Function *F = unwrap<Function>(Fn);
const AttributeSet PAL = F->getAttributes();
Attribute Attr = Attribute::get(F->getContext(), fromRust(RustAttr));
AttrBuilder B(Attr);
const AttributeSet PALNew = PAL.removeAttributes(
F->getContext(), Index, AttributeSet::get(F->getContext(), Index, B));
F->setAttributes(PALNew);
}
示例13: removeUseSoftFloat
//
// remove the use-soft-float attribute
//
static void removeUseSoftFloat(Function &F) {
AttributeSet A;
DEBUG(errs() << "removing -use-soft-float\n");
A = A.addAttribute(F.getContext(), AttributeSet::FunctionIndex,
"use-soft-float", "false");
F.removeAttributes(AttributeSet::FunctionIndex, A);
if (F.hasFnAttribute("use-soft-float")) {
DEBUG(errs() << "still has -use-soft-float\n");
}
F.addAttributes(AttributeSet::FunctionIndex, A);
}
示例14: LLVMRustRemoveFunctionAttributes
extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
unsigned index,
LLVMAttributeRef attr)
{
Function *F = unwrap<Function>(Fn);
const AttributeSet PAL = F->getAttributes();
AttrBuilder B(unwrap(attr));
const AttributeSet PALnew =
PAL.removeAttributes(F->getContext(), index,
AttributeSet::get(F->getContext(), index, B));
F->setAttributes(PALnew);
}
示例15: ReplaceOrRecord
static inline void ReplaceOrRecord(AttributeSet& pParent,
const Attribute*& pBase,
Attribute*& pCopy) {
Attribute* result = pParent.exists(*pCopy);
if (result == NULL) { // can not find
pParent.record(*pCopy);
pBase = pCopy;
} else { // find
delete pCopy;
pBase = result;
}
}