Use the predicate methods off of AttributeSet instead of Attribute.
authorBill Wendling <isanbard@gmail.com>
Sun, 30 Dec 2012 13:50:49 +0000 (13:50 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 30 Dec 2012 13:50:49 +0000 (13:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171257 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Attributes.h
include/llvm/Function.h
lib/AsmParser/LLParser.cpp
lib/Target/NVPTX/NVPTXAsmPrinter.cpp
lib/Target/NVPTX/NVPTXISelLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/VMCore/AsmWriter.cpp
lib/VMCore/Core.cpp
lib/VMCore/Instructions.cpp

index 8ce7651ae9449b9db9f9f6f2b21fd8a796cf46b3..08063c15ed580f1424f906e582c1d2fd42e96a1f 100644 (file)
@@ -143,9 +143,8 @@ public:
   static Attribute decodeLLVMAttributesForBitcode(LLVMContext &C,
                                                    uint64_t EncodedAttrs);
 
-  /// \brief The set of attributes set in Attribute is converted to a string of
-  /// equivalent mnemonics. This is, presumably, for writing out the mnemonics
-  /// for the assembly writer.
+  /// \brief The Attribute is converted to a string of equivalent mnemonic. This
+  /// is, presumably, for writing out the mnemonics for the assembly writer.
   std::string getAsString() const;
 };
 
index db61250a60975f6ec08b64e88c399ae80470960d..d551caec9083b443e8fbfa7ff63344671508dde4 100644 (file)
@@ -264,15 +264,13 @@ public:
   /// @brief Determine if the function returns a structure through first
   /// pointer argument.
   bool hasStructRetAttr() const {
-    return AttributeList.getParamAttributes(1).
-      hasAttribute(Attribute::StructRet);
+    return AttributeList.hasAttribute(1, Attribute::StructRet);
   }
 
   /// @brief Determine if the parameter does not alias other parameters.
   /// @param n The parameter to check. 1 is the first parameter, 0 is the return
   bool doesNotAlias(unsigned n) const {
-    return AttributeList.getParamAttributes(n).
-      hasAttribute(Attribute::NoAlias);
+    return AttributeList.hasAttribute(n, Attribute::NoAlias);
   }
   void setDoesNotAlias(unsigned n) {
     addAttribute(n, Attribute::get(getContext(), Attribute::NoAlias));
@@ -281,8 +279,7 @@ public:
   /// @brief Determine if the parameter can be captured.
   /// @param n The parameter to check. 1 is the first parameter, 0 is the return
   bool doesNotCapture(unsigned n) const {
-    return AttributeList.getParamAttributes(n).
-      hasAttribute(Attribute::NoCapture);
+    return AttributeList.hasAttribute(n, Attribute::NoCapture);
   }
   void setDoesNotCapture(unsigned n) {
     addAttribute(n, Attribute::get(getContext(), Attribute::NoCapture));
index c45ad0a083e2a529f303b7434229aeff594ef412..ffa0ace596a39d0894f9226b7e6a21926fe5147b 100644 (file)
@@ -2834,8 +2834,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
 
   AttributeSet PAL = AttributeSet::get(Context, Attrs);
 
-  if (PAL.getParamAttributes(1).hasAttribute(Attribute::StructRet) &&
-      !RetType->isVoidTy())
+  if (PAL.hasAttribute(1, Attribute::StructRet) && !RetType->isVoidTy())
     return Error(RetTypeLoc, "functions with 'sret' argument must return void");
 
   FunctionType *FT =
index c1b1e25085cf7635533a1b8ae127fc00a8c1fb18..14c6a60acf54df451ef5d8dcc5b63c20d18c432d 100644 (file)
@@ -1521,8 +1521,7 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F,
       continue;
     }
 
-    if (PAL.getParamAttributes(paramIndex+1).
-          hasAttribute(Attribute::ByVal) == false) {
+    if (PAL.hasAttribute(paramIndex+1, Attribute::ByVal) == false) {
       // Just a scalar
       const PointerType *PTy = dyn_cast<PointerType>(Ty);
       if (isKernelFunc) {
index 82db0886c755d17c32277bd1a0266b5531d578e9..ba02c448eb2626bdcbb876bb538619e0cc4b5628 100644 (file)
@@ -1022,7 +1022,7 @@ NVPTXTargetLowering::LowerFormalArguments(SDValue Chain,
     // to newly created nodes. The SDNOdes for params have to
     // appear in the same order as their order of appearance
     // in the original function. "idx+1" holds that order.
-    if (PAL.getParamAttributes(i+1).hasAttribute(Attribute::ByVal) == false) {
+    if (PAL.hasAttribute(i+1, Attribute::ByVal) == false) {
       // A plain scalar.
       if (isABI || isKernel) {
         // If ABI, load from the param symbol
index 09006030927b07659a1625248609119d5b907c6a..401b9b0346d8010b90cb8c01aa8967b792e82e98 100644 (file)
@@ -11056,7 +11056,7 @@ SDValue X86TargetLowering::LowerINIT_TRAMPOLINE(SDValue Op,
 
         for (FunctionType::param_iterator I = FTy->param_begin(),
              E = FTy->param_end(); I != E; ++I, ++Idx)
-          if (Attrs.getParamAttributes(Idx).hasAttribute(Attribute::InReg))
+          if (Attrs.hasAttribute(Idx, Attribute::InReg))
             // FIXME: should only count parameters that are lowered to integers.
             InRegCount += (TD->getTypeSizeInBits(*I) + 31) / 32;
 
index 08aa73cfa9fe39ee3cee0aecb88fd667d3b0a283..7e80322cc63a7d7c0cfb0e87017fe1f4410ba135 100644 (file)
@@ -1197,7 +1197,7 @@ public:
   void printModule(const Module *M);
 
   void writeOperand(const Value *Op, bool PrintType);
-  void writeParamOperand(const Value *Operand, Attribute Attrs);
+  void writeParamOperand(const Value *Operand, AttributeSet Attrs,unsigned Idx);
   void writeAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope);
 
   void writeAllMDNodes();
@@ -1206,7 +1206,7 @@ public:
   void printGlobal(const GlobalVariable *GV);
   void printAlias(const GlobalAlias *GV);
   void printFunction(const Function *F);
-  void printArgument(const Argument *FA, Attribute Attrs);
+  void printArgument(const Argument *FA, AttributeSet Attrs, unsigned Idx);
   void printBasicBlock(const BasicBlock *BB);
   void printInstruction(const Instruction &I);
 
@@ -1251,7 +1251,7 @@ void AssemblyWriter::writeAtomic(AtomicOrdering Ordering,
 }
 
 void AssemblyWriter::writeParamOperand(const Value *Operand,
-                                       Attribute Attrs) {
+                                       AttributeSet Attrs, unsigned Idx) {
   if (Operand == 0) {
     Out << "<null operand!>";
     return;
@@ -1260,8 +1260,8 @@ void AssemblyWriter::writeParamOperand(const Value *Operand,
   // Print the type
   TypePrinter.print(Operand->getType(), Out);
   // Print parameter attributes list
-  if (Attrs.hasAttributes())
-    Out << ' ' << Attrs.getAsString();
+  if (Attrs.hasAttributes(Idx))
+    Out << ' ' << Attrs.getAsString(Idx);
   Out << ' ';
   // Print the operand
   WriteAsOperandInternal(Out, Operand, &TypePrinter, &Machine, TheModule);
@@ -1575,7 +1575,7 @@ void AssemblyWriter::printFunction(const Function *F) {
          I != E; ++I) {
       // Insert commas as we go... the first arg doesn't get a comma
       if (I != F->arg_begin()) Out << ", ";
-      printArgument(I, Attrs.getParamAttributes(Idx));
+      printArgument(I, Attrs, Idx);
       Idx++;
     }
   } else {
@@ -1587,9 +1587,8 @@ void AssemblyWriter::printFunction(const Function *F) {
       // Output type...
       TypePrinter.print(FT->getParamType(i), Out);
 
-      Attribute ArgAttrs = Attrs.getParamAttributes(i+1);
-      if (ArgAttrs.hasAttributes())
-        Out << ' ' << ArgAttrs.getAsString();
+      if (Attrs.hasAttributes(i+1))
+        Out << ' ' << Attrs.getAsString(i+1);
     }
   }
 
@@ -1630,13 +1629,13 @@ void AssemblyWriter::printFunction(const Function *F) {
 /// the function.  Simply print it out
 ///
 void AssemblyWriter::printArgument(const Argument *Arg,
-                                   Attribute Attrs) {
+                                   AttributeSet Attrs, unsigned Idx) {
   // Output type...
   TypePrinter.print(Arg->getType(), Out);
 
   // Output parameter attributes list
-  if (Attrs.hasAttributes())
-    Out << ' ' << Attrs.getAsString();
+  if (Attrs.hasAttributes(Idx))
+    Out << ' ' << Attrs.getAsString(Idx);
 
   // Output name, if available...
   if (Arg->hasName()) {
@@ -1871,7 +1870,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
     for (unsigned op = 0, Eop = CI->getNumArgOperands(); op < Eop; ++op) {
       if (op > 0)
         Out << ", ";
-      writeParamOperand(CI->getArgOperand(op), PAL.getParamAttributes(op + 1));
+      writeParamOperand(CI->getArgOperand(op), PAL, op + 1);
     }
     Out << ')';
     if (PAL.hasAttributes(AttributeSet::FunctionIndex))
@@ -1910,7 +1909,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
     for (unsigned op = 0, Eop = II->getNumArgOperands(); op < Eop; ++op) {
       if (op)
         Out << ", ";
-      writeParamOperand(II->getArgOperand(op), PAL.getParamAttributes(op + 1));
+      writeParamOperand(II->getArgOperand(op), PAL, op + 1);
     }
 
     Out << ')';
index 60a8483aba5a8f85ac4fadeb107fdb198fe35498..a1e9cf3f3596da59296376accd7c1a1e28d53cc6 100644 (file)
@@ -1476,9 +1476,8 @@ void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
 
 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
   Argument *A = unwrap<Argument>(Arg);
-  Attribute attr = A->getParent()->getAttributes().getParamAttributes(
-    A->getArgNo()+1);
-  return (LLVMAttribute)attr.getBitMask();
+  return (LLVMAttribute)A->getParent()->getAttributes().
+    getBitMask(A->getArgNo()+1);
 }
   
 
index 23db33646e58235f3ed5523d3714cd519108e4a8..dffd13c0ee414de6142846930f7e187d1c573140 100644 (file)
@@ -344,8 +344,7 @@ void CallInst::removeAttribute(unsigned i, Attribute attr) {
 }
 
 bool CallInst::hasFnAttr(Attribute::AttrKind A) const {
-  if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex)
-      .hasAttribute(A))
+  if (AttributeList.hasAttribute(AttributeSet::FunctionIndex, A))
     return true;
   if (const Function *F = getCalledFunction())
     return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
@@ -353,7 +352,7 @@ bool CallInst::hasFnAttr(Attribute::AttrKind A) const {
 }
 
 bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
-  if (AttributeList.getParamAttributes(i).hasAttribute(A))
+  if (AttributeList.hasAttribute(i, A))
     return true;
   if (const Function *F = getCalledFunction())
     return F->getAttributes().hasAttribute(i, A);
@@ -573,8 +572,7 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
 }
 
 bool InvokeInst::hasFnAttr(Attribute::AttrKind A) const {
-  if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex).
-      hasAttribute(A))
+  if (AttributeList.hasAttribute(AttributeSet::FunctionIndex, A))
     return true;
   if (const Function *F = getCalledFunction())
     return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
@@ -582,7 +580,7 @@ bool InvokeInst::hasFnAttr(Attribute::AttrKind A) const {
 }
 
 bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
-  if (AttributeList.getParamAttributes(i).hasAttribute(A))
+  if (AttributeList.hasAttribute(i, A))
     return true;
   if (const Function *F = getCalledFunction())
     return F->getAttributes().hasAttribute(i, A);