diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-12-30 10:32:01 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-12-30 10:32:01 +0000 |
commit | 831737d329a727f53a1fb0572f7b7a8127208881 (patch) | |
tree | 38691f7c03365912f11d41ee01ceaafd5aae99a6 /lib/VMCore | |
parent | 377660355ccdde389eb4f473bbb24125f160ea23 (diff) |
Remove the Function::getFnAttributes method in favor of using the AttributeSet
directly.
This is in preparation for removing the use of the 'Attribute' class as a
collection of attributes. That will shift to the AttributeSet class instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171253 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 13 | ||||
-rw-r--r-- | lib/VMCore/AttributeImpl.h | 2 | ||||
-rw-r--r-- | lib/VMCore/Attributes.cpp | 21 | ||||
-rw-r--r-- | lib/VMCore/Core.cpp | 3 |
4 files changed, 29 insertions, 10 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index da92c85381..08aa73cfa9 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1601,9 +1601,8 @@ void AssemblyWriter::printFunction(const Function *F) { Out << ')'; if (F->hasUnnamedAddr()) Out << " unnamed_addr"; - Attribute FnAttrs = Attrs.getFnAttributes(); - if (FnAttrs.hasAttributes()) - Out << ' ' << Attrs.getFnAttributes().getAsString(); + if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) + Out << ' ' << Attrs.getAsString(AttributeSet::FunctionIndex); if (F->hasSection()) { Out << " section \""; PrintEscapedString(F->getSection(), Out); @@ -1875,8 +1874,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) { writeParamOperand(CI->getArgOperand(op), PAL.getParamAttributes(op + 1)); } Out << ')'; - if (PAL.getFnAttributes().hasAttributes()) - Out << ' ' << PAL.getFnAttributes().getAsString(); + if (PAL.hasAttributes(AttributeSet::FunctionIndex)) + Out << ' ' << PAL.getAsString(AttributeSet::FunctionIndex); } else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) { Operand = II->getCalledValue(); PointerType *PTy = cast<PointerType>(Operand->getType()); @@ -1915,8 +1914,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) { } Out << ')'; - if (PAL.getFnAttributes().hasAttributes()) - Out << ' ' << PAL.getFnAttributes().getAsString(); + if (PAL.hasAttributes(AttributeSet::FunctionIndex)) + Out << ' ' << PAL.getAsString(AttributeSet::FunctionIndex); Out << "\n to "; writeOperand(II->getNormalDest(), true); diff --git a/lib/VMCore/AttributeImpl.h b/lib/VMCore/AttributeImpl.h index cab1c94255..2726e0edf6 100644 --- a/lib/VMCore/AttributeImpl.h +++ b/lib/VMCore/AttributeImpl.h @@ -87,7 +87,7 @@ public: /// \class /// \brief This class represents a set of attributes. class AttributeSetImpl : public FoldingSetNode { - // AttributesList is uniqued, these should not be publicly available. + // AttributesSet is uniqued, these should not be publicly available. void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION; AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION; public: diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index b32358708d..de83deb2e9 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -451,6 +451,27 @@ const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const { return AttrList->Attrs[Slot]; } +bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{ + return getAttributes(Index).hasAttribute(Kind); +} + +bool AttributeSet::hasAttributes(unsigned Index) const { + return getAttributes(Index).hasAttributes(); +} + +std::string AttributeSet::getAsString(unsigned Index) const { + return getAttributes(Index).getAsString(); +} + +unsigned AttributeSet::getStackAlignment(unsigned Index) const { + return getAttributes(Index).getStackAlignment(); +} + +uint64_t AttributeSet::getBitMask(unsigned Index) const { + // FIXME: Remove this. + return getAttributes(Index).getBitMask(); +} + /// getAttributes - The attributes for the specified index are returned. /// Attribute for the result are denoted with Idx = 0. Function notes are /// denoted with idx = ~0. diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index 1fb8528568..60a8483aba 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -1401,8 +1401,7 @@ void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn) { Function *Func = unwrap<Function>(Fn); const AttributeSet PAL = Func->getAttributes(); - Attribute attr = PAL.getFnAttributes(); - return (LLVMAttribute)attr.getBitMask(); + return (LLVMAttribute)PAL.getBitMask(AttributeSet::FunctionIndex); } /*--.. Operations on parameters ............................................--*/ |