diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-09-20 14:44:42 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-09-20 14:44:42 +0000 |
commit | 8ce1e432d1c942d101617b3c623970a4f763f93d (patch) | |
tree | fcdf2ec41ce4f7e27ab421aaa942fb479e2b2d2e | |
parent | 6dfabb6cc72118e046d2a466aa6adcec4c4923db (diff) | |
download | external_llvm-8ce1e432d1c942d101617b3c623970a4f763f93d.zip external_llvm-8ce1e432d1c942d101617b3c623970a4f763f93d.tar.gz external_llvm-8ce1e432d1c942d101617b3c623970a4f763f93d.tar.bz2 |
Make the 'getAsString' function a method of the Attributes class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164305 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Attributes.h | 12 | ||||
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 18 | ||||
-rw-r--r-- | lib/VMCore/Attributes.cpp | 60 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 18 |
4 files changed, 54 insertions, 54 deletions
diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h index cf37e93..fe0cc35 100644 --- a/include/llvm/Attributes.h +++ b/include/llvm/Attributes.h @@ -215,6 +215,12 @@ public: } Attributes operator ~ () const { return Attributes(~Bits); } uint64_t Raw() const { return Bits; } + + /// The set of Attributes set in Attributes is converted to a string of + /// equivalent mnemonics. This is, presumably, for writing out the mnemonics + /// for the assembly writer. + /// @brief Convert attribute bits to text + std::string getAsString() const; }; namespace Attribute { @@ -345,12 +351,6 @@ inline Attributes decodeLLVMAttributesForBitcode(uint64_t EncodedAttrs) { return Attrs; } - -/// The set of Attributes set in Attributes is converted to a -/// string of equivalent mnemonics. This is, presumably, for writing out -/// the mnemonics for the assembly writer. -/// @brief Convert attribute bits to text -std::string getAsString(Attributes Attrs); } // end namespace Attribute /// This is just a pair of values to associate a set of attributes diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 7626818..19fe156 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1244,7 +1244,7 @@ void AssemblyWriter::writeParamOperand(const Value *Operand, TypePrinter.print(Operand->getType(), Out); // Print parameter attributes list if (Attrs != Attribute::None) - Out << ' ' << Attribute::getAsString(Attrs); + Out << ' ' << Attrs.getAsString(); Out << ' '; // Print the operand WriteAsOperandInternal(Out, Operand, &TypePrinter, &Machine, TheModule); @@ -1557,7 +1557,7 @@ void AssemblyWriter::printFunction(const Function *F) { const AttrListPtr &Attrs = F->getAttributes(); Attributes RetAttrs = Attrs.getRetAttributes(); if (RetAttrs != Attribute::None) - Out << Attribute::getAsString(Attrs.getRetAttributes()) << ' '; + Out << Attrs.getRetAttributes().getAsString() << ' '; TypePrinter.print(F->getReturnType(), Out); Out << ' '; WriteAsOperandInternal(Out, F, &TypePrinter, &Machine, F->getParent()); @@ -1587,7 +1587,7 @@ void AssemblyWriter::printFunction(const Function *F) { Attributes ArgAttrs = Attrs.getParamAttributes(i+1); if (ArgAttrs != Attribute::None) - Out << ' ' << Attribute::getAsString(ArgAttrs); + Out << ' ' << ArgAttrs.getAsString(); } } @@ -1601,7 +1601,7 @@ void AssemblyWriter::printFunction(const Function *F) { Out << " unnamed_addr"; Attributes FnAttrs = Attrs.getFnAttributes(); if (FnAttrs != Attribute::None) - Out << ' ' << Attribute::getAsString(Attrs.getFnAttributes()); + Out << ' ' << Attrs.getFnAttributes().getAsString(); if (F->hasSection()) { Out << " section \""; PrintEscapedString(F->getSection(), Out); @@ -1635,7 +1635,7 @@ void AssemblyWriter::printArgument(const Argument *Arg, // Output parameter attributes list if (Attrs != Attribute::None) - Out << ' ' << Attribute::getAsString(Attrs); + Out << ' ' << Attrs.getAsString(); // Output name, if available... if (Arg->hasName()) { @@ -1850,7 +1850,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { const AttrListPtr &PAL = CI->getAttributes(); if (PAL.getRetAttributes() != Attribute::None) - Out << ' ' << Attribute::getAsString(PAL.getRetAttributes()); + Out << ' ' << PAL.getRetAttributes().getAsString(); // If possible, print out the short form of the call instruction. We can // only do this if the first argument is a pointer to a nonvararg function, @@ -1874,7 +1874,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { } Out << ')'; if (PAL.getFnAttributes() != Attribute::None) - Out << ' ' << Attribute::getAsString(PAL.getFnAttributes()); + Out << ' ' << PAL.getFnAttributes().getAsString(); } else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) { Operand = II->getCalledValue(); PointerType *PTy = cast<PointerType>(Operand->getType()); @@ -1889,7 +1889,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { } if (PAL.getRetAttributes() != Attribute::None) - Out << ' ' << Attribute::getAsString(PAL.getRetAttributes()); + Out << ' ' << PAL.getRetAttributes().getAsString(); // If possible, print out the short form of the invoke instruction. We can // only do this if the first argument is a pointer to a nonvararg function, @@ -1914,7 +1914,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) { Out << ')'; if (PAL.getFnAttributes() != Attribute::None) - Out << ' ' << Attribute::getAsString(PAL.getFnAttributes()); + Out << ' ' << PAL.getFnAttributes().getAsString(); Out << "\n to "; writeOperand(II->getNormalDest(), true); diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index 7d85ecb..6047d4b 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -26,66 +26,66 @@ using namespace llvm; // Attribute Function Definitions //===----------------------------------------------------------------------===// -std::string Attribute::getAsString(Attributes Attrs) { +std::string Attributes::getAsString() const { std::string Result; - if (Attrs.hasZExtAttr()) + if (hasZExtAttr()) Result += "zeroext "; - if (Attrs.hasSExtAttr()) + if (hasSExtAttr()) Result += "signext "; - if (Attrs.hasNoReturnAttr()) + if (hasNoReturnAttr()) Result += "noreturn "; - if (Attrs.hasNoUnwindAttr()) + if (hasNoUnwindAttr()) Result += "nounwind "; - if (Attrs.hasUWTableAttr()) + if (hasUWTableAttr()) Result += "uwtable "; - if (Attrs.hasReturnsTwiceAttr()) + if (hasReturnsTwiceAttr()) Result += "returns_twice "; - if (Attrs.hasInRegAttr()) + if (hasInRegAttr()) Result += "inreg "; - if (Attrs.hasNoAliasAttr()) + if (hasNoAliasAttr()) Result += "noalias "; - if (Attrs.hasNoCaptureAttr()) + if (hasNoCaptureAttr()) Result += "nocapture "; - if (Attrs.hasStructRetAttr()) + if (hasStructRetAttr()) Result += "sret "; - if (Attrs.hasByValAttr()) + if (hasByValAttr()) Result += "byval "; - if (Attrs.hasNestAttr()) + if (hasNestAttr()) Result += "nest "; - if (Attrs.hasReadNoneAttr()) + if (hasReadNoneAttr()) Result += "readnone "; - if (Attrs.hasReadOnlyAttr()) + if (hasReadOnlyAttr()) Result += "readonly "; - if (Attrs.hasOptimizeForSizeAttr()) + if (hasOptimizeForSizeAttr()) Result += "optsize "; - if (Attrs.hasNoInlineAttr()) + if (hasNoInlineAttr()) Result += "noinline "; - if (Attrs.hasInlineHintAttr()) + if (hasInlineHintAttr()) Result += "inlinehint "; - if (Attrs.hasAlwaysInlineAttr()) + if (hasAlwaysInlineAttr()) Result += "alwaysinline "; - if (Attrs.hasStackProtectAttr()) + if (hasStackProtectAttr()) Result += "ssp "; - if (Attrs.hasStackProtectReqAttr()) + if (hasStackProtectReqAttr()) Result += "sspreq "; - if (Attrs.hasNoRedZoneAttr()) + if (hasNoRedZoneAttr()) Result += "noredzone "; - if (Attrs.hasNoImplicitFloatAttr()) + if (hasNoImplicitFloatAttr()) Result += "noimplicitfloat "; - if (Attrs.hasNakedAttr()) + if (hasNakedAttr()) Result += "naked "; - if (Attrs.hasNonLazyBindAttr()) + if (hasNonLazyBindAttr()) Result += "nonlazybind "; - if (Attrs.hasAddressSafetyAttr()) + if (hasAddressSafetyAttr()) Result += "address_safety "; - if (Attrs & Attribute::StackAlignment) { + if (*this & Attribute::StackAlignment) { // FIXME Result += "alignstack("; - Result += utostr(Attribute::getStackAlignmentFromAttrs(Attrs)); + Result += utostr(Attribute::getStackAlignmentFromAttrs(*this)); Result += ") "; } - if (Attrs & Attribute::Alignment) { + if (*this & Attribute::Alignment) { // FIXME Result += "align "; - Result += utostr(Attribute::getAlignmentFromAttrs(Attrs)); + Result += utostr(Attribute::getAlignmentFromAttrs(*this)); Result += " "; } // Trim the trailing space. diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 83c900a..647a52f 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -530,12 +530,12 @@ void Verifier::VerifyParameterAttrs(Attributes Attrs, Type *Ty, return; Attributes FnCheckAttr = Attrs & Attribute::FunctionOnly; - Assert1(!FnCheckAttr, "Attribute " + Attribute::getAsString(FnCheckAttr) + + Assert1(!FnCheckAttr, "Attribute " + FnCheckAttr.getAsString() + " only applies to the function!", V); if (isReturnValue) { Attributes RetI = Attrs & Attribute::ParameterOnly; - Assert1(!RetI, "Attribute " + Attribute::getAsString(RetI) + + Assert1(!RetI, "Attribute " + RetI.getAsString() + " does not apply to return values!", V); } @@ -543,21 +543,21 @@ void Verifier::VerifyParameterAttrs(Attributes Attrs, Type *Ty, i < array_lengthof(Attribute::MutuallyIncompatible); ++i) { Attributes MutI = Attrs & Attribute::MutuallyIncompatible[i]; Assert1(MutI.isEmptyOrSingleton(), "Attributes " + - Attribute::getAsString(MutI) + " are incompatible!", V); + MutI.getAsString() + " are incompatible!", V); } Attributes TypeI = Attrs & Attribute::typeIncompatible(Ty); Assert1(!TypeI, "Wrong type for attribute " + - Attribute::getAsString(TypeI), V); + TypeI.getAsString(), V); Attributes ByValI = Attrs & Attribute::ByVal; if (PointerType *PTy = dyn_cast<PointerType>(Ty)) { Assert1(!ByValI || PTy->getElementType()->isSized(), - "Attribute " + Attribute::getAsString(ByValI) + + "Attribute " + ByValI.getAsString() + " does not support unsized types!", V); } else { Assert1(!ByValI, - "Attribute " + Attribute::getAsString(ByValI) + + "Attribute " + ByValI.getAsString() + " only applies to parameters with pointer type!", V); } } @@ -596,14 +596,14 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT, Attributes FAttrs = Attrs.getFnAttributes(); Attributes NotFn = FAttrs & (~Attribute::FunctionOnly); - Assert1(!NotFn, "Attribute " + Attribute::getAsString(NotFn) + + Assert1(!NotFn, "Attribute " + NotFn.getAsString() + " does not apply to the function!", V); for (unsigned i = 0; i < array_lengthof(Attribute::MutuallyIncompatible); ++i) { Attributes MutI = FAttrs & Attribute::MutuallyIncompatible[i]; Assert1(MutI.isEmptyOrSingleton(), "Attributes " + - Attribute::getAsString(MutI) + " are incompatible!", V); + MutI.getAsString() + " are incompatible!", V); } } @@ -1171,7 +1171,7 @@ void Verifier::VerifyCallSite(CallSite CS) { VerifyParameterAttrs(Attr, CS.getArgument(Idx-1)->getType(), false, I); Attributes VArgI = Attr & Attribute::VarArgsIncompatible; - Assert1(!VArgI, "Attribute " + Attribute::getAsString(VArgI) + + Assert1(!VArgI, "Attribute " + VArgI.getAsString() + " cannot be used for vararg call arguments!", I); } |