[llvm-commits] [llvm] r164305 - in /llvm/trunk: include/llvm/Attributes.h lib/VMCore/AsmWriter.cpp lib/VMCore/Attributes.cpp lib/VMCore/Verifier.cpp

Bill Wendling isanbard at gmail.com
Thu Sep 20 07:44:42 PDT 2012


Author: void
Date: Thu Sep 20 09:44:42 2012
New Revision: 164305

URL: http://llvm.org/viewvc/llvm-project?rev=164305&view=rev
Log:
Make the 'getAsString' function a method of the Attributes class.

Modified:
    llvm/trunk/include/llvm/Attributes.h
    llvm/trunk/lib/VMCore/AsmWriter.cpp
    llvm/trunk/lib/VMCore/Attributes.cpp
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=164305&r1=164304&r2=164305&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Thu Sep 20 09:44:42 2012
@@ -215,6 +215,12 @@
   }
   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 @@
   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

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=164305&r1=164304&r2=164305&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Sep 20 09:44:42 2012
@@ -1244,7 +1244,7 @@
   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 @@
   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 @@
 
       Attributes ArgAttrs = Attrs.getParamAttributes(i+1);
       if (ArgAttrs != Attribute::None)
-        Out << ' ' << Attribute::getAsString(ArgAttrs);
+        Out << ' ' << ArgAttrs.getAsString();
     }
   }
 
@@ -1601,7 +1601,7 @@
     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 @@
 
   // 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 @@
     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 @@
     }
     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 @@
     }
 
     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 @@
 
     Out << ')';
     if (PAL.getFnAttributes() != Attribute::None)
-      Out << ' ' << Attribute::getAsString(PAL.getFnAttributes());
+      Out << ' ' << PAL.getFnAttributes().getAsString();
 
     Out << "\n          to ";
     writeOperand(II->getNormalDest(), true);

Modified: llvm/trunk/lib/VMCore/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=164305&r1=164304&r2=164305&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Attributes.cpp (original)
+++ llvm/trunk/lib/VMCore/Attributes.cpp Thu Sep 20 09:44:42 2012
@@ -26,66 +26,66 @@
 // 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.

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=164305&r1=164304&r2=164305&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Thu Sep 20 09:44:42 2012
@@ -530,12 +530,12 @@
     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 @@
        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 @@
 
   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 @@
       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);
     }
 





More information about the llvm-commits mailing list