Large mechanical patch.

s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage 
- to implement function notes as function attributes and 
- to distinguish between function attributes and return value attributes.

This requires corresponding changes in llvm-gcc and clang.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56622 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index a1222da..1700c1e 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -131,12 +131,12 @@
                             bool isSigned = false,
                             const std::string &VariableName = "",
                             bool IgnoreName = false,
-                            const PAListPtr &PAL = PAListPtr());
+                            const AttrListPtr &PAL = AttrListPtr());
     std::ostream &printType(std::ostream &Out, const Type *Ty, 
                            bool isSigned = false,
                            const std::string &VariableName = "",
                            bool IgnoreName = false,
-                           const PAListPtr &PAL = PAListPtr());
+                           const AttrListPtr &PAL = AttrListPtr());
     raw_ostream &printSimpleType(raw_ostream &Out, const Type *Ty, 
                                   bool isSigned, 
                                   const std::string &NameSoFar = "");
@@ -145,7 +145,7 @@
                                  const std::string &NameSoFar = "");
 
     void printStructReturnPointerFunctionType(raw_ostream &Out,
-                                              const PAListPtr &PAL,
+                                              const AttrListPtr &PAL,
                                               const PointerType *Ty);
 
     /// writeOperandDeref - Print the result of dereferencing the specified
@@ -408,7 +408,7 @@
 /// return type, except, instead of printing the type as void (*)(Struct*, ...)
 /// print it as "Struct (*)(...)", for struct return functions.
 void CWriter::printStructReturnPointerFunctionType(raw_ostream &Out,
-                                                   const PAListPtr &PAL,
+                                                   const AttrListPtr &PAL,
                                                    const PointerType *TheTy) {
   const FunctionType *FTy = cast<FunctionType>(TheTy->getElementType());
   std::stringstream FunctionInnards;
@@ -422,12 +422,12 @@
     if (PrintedType)
       FunctionInnards << ", ";
     const Type *ArgTy = *I;
-    if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
+    if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
       assert(isa<PointerType>(ArgTy));
       ArgTy = cast<PointerType>(ArgTy)->getElementType();
     }
     printType(FunctionInnards, ArgTy,
-        /*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt), "");
+        /*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt), "");
     PrintedType = true;
   }
   if (FTy->isVarArg()) {
@@ -439,7 +439,7 @@
   FunctionInnards << ')';
   std::string tstr = FunctionInnards.str();
   printType(Out, RetTy, 
-      /*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
+      /*isSigned=*/PAL.paramHasAttr(0, Attribute::SExt), tstr);
 }
 
 raw_ostream &
@@ -537,7 +537,7 @@
 //
 raw_ostream &CWriter::printType(raw_ostream &Out, const Type *Ty,
                                  bool isSigned, const std::string &NameSoFar,
-                                 bool IgnoreName, const PAListPtr &PAL) {
+                                 bool IgnoreName, const AttrListPtr &PAL) {
   if (Ty->isPrimitiveType() || Ty->isInteger() || isa<VectorType>(Ty)) {
     printSimpleType(Out, Ty, isSigned, NameSoFar);
     return Out;
@@ -558,14 +558,14 @@
     for (FunctionType::param_iterator I = FTy->param_begin(),
            E = FTy->param_end(); I != E; ++I) {
       const Type *ArgTy = *I;
-      if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
+      if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
         assert(isa<PointerType>(ArgTy));
         ArgTy = cast<PointerType>(ArgTy)->getElementType();
       }
       if (I != FTy->param_begin())
         FunctionInnards << ", ";
       printType(FunctionInnards, ArgTy,
-        /*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt), "");
+        /*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt), "");
       ++Idx;
     }
     if (FTy->isVarArg()) {
@@ -577,7 +577,7 @@
     FunctionInnards << ')';
     std::string tstr = FunctionInnards.str();
     printType(Out, FTy->getReturnType(), 
-      /*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
+      /*isSigned=*/PAL.paramHasAttr(0, Attribute::SExt), tstr);
     return Out;
   }
   case Type::StructTyID: {
@@ -642,7 +642,7 @@
 //
 std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
                                  bool isSigned, const std::string &NameSoFar,
-                                 bool IgnoreName, const PAListPtr &PAL) {
+                                 bool IgnoreName, const AttrListPtr &PAL) {
   if (Ty->isPrimitiveType() || Ty->isInteger() || isa<VectorType>(Ty)) {
     printSimpleType(Out, Ty, isSigned, NameSoFar);
     return Out;
@@ -663,14 +663,14 @@
     for (FunctionType::param_iterator I = FTy->param_begin(),
            E = FTy->param_end(); I != E; ++I) {
       const Type *ArgTy = *I;
-      if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
+      if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
         assert(isa<PointerType>(ArgTy));
         ArgTy = cast<PointerType>(ArgTy)->getElementType();
       }
       if (I != FTy->param_begin())
         FunctionInnards << ", ";
       printType(FunctionInnards, ArgTy,
-        /*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt), "");
+        /*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt), "");
       ++Idx;
     }
     if (FTy->isVarArg()) {
@@ -682,7 +682,7 @@
     FunctionInnards << ')';
     std::string tstr = FunctionInnards.str();
     printType(Out, FTy->getReturnType(), 
-      /*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
+      /*isSigned=*/PAL.paramHasAttr(0, Attribute::SExt), tstr);
     return Out;
   }
   case Type::StructTyID: {
@@ -2162,7 +2162,7 @@
   
   // Loop over the arguments, printing them...
   const FunctionType *FT = cast<FunctionType>(F->getFunctionType());
-  const PAListPtr &PAL = F->getParamAttrs();
+  const AttrListPtr &PAL = F->getAttributes();
 
   std::stringstream FunctionInnards;
 
@@ -2191,12 +2191,12 @@
         else
           ArgName = "";
         const Type *ArgTy = I->getType();
-        if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
+        if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
           ArgTy = cast<PointerType>(ArgTy)->getElementType();
           ByValParams.insert(I);
         }
         printType(FunctionInnards, ArgTy,
-            /*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt),
+            /*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt),
             ArgName);
         PrintedArg = true;
         ++Idx;
@@ -2218,12 +2218,12 @@
     for (; I != E; ++I) {
       if (PrintedArg) FunctionInnards << ", ";
       const Type *ArgTy = *I;
-      if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
+      if (PAL.paramHasAttr(Idx, Attribute::ByVal)) {
         assert(isa<PointerType>(ArgTy));
         ArgTy = cast<PointerType>(ArgTy)->getElementType();
       }
       printType(FunctionInnards, ArgTy,
-             /*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt));
+             /*isSigned=*/PAL.paramHasAttr(Idx, Attribute::SExt));
       PrintedArg = true;
       ++Idx;
     }
@@ -2251,7 +2251,7 @@
     
   // Print out the return type and the signature built above.
   printType(Out, RetTy, 
-            /*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt),
+            /*isSigned=*/PAL.paramHasAttr(0, Attribute::SExt),
             FunctionInnards.str());
 }
 
@@ -2844,7 +2844,7 @@
 
   // If this is a call to a struct-return function, assign to the first
   // parameter instead of passing it to the call.
-  const PAListPtr &PAL = I.getParamAttrs();
+  const AttrListPtr &PAL = I.getAttributes();
   bool hasByVal = I.hasByValArgument();
   bool isStructRet = I.hasStructRetAttr();
   if (isStructRet) {
@@ -2912,11 +2912,11 @@
         (*AI)->getType() != FTy->getParamType(ArgNo)) {
       Out << '(';
       printType(Out, FTy->getParamType(ArgNo), 
-            /*isSigned=*/PAL.paramHasAttr(ArgNo+1, ParamAttr::SExt));
+            /*isSigned=*/PAL.paramHasAttr(ArgNo+1, Attribute::SExt));
       Out << ')';
     }
     // Check if the argument is expected to be passed by value.
-    if (I.paramHasAttr(ArgNo+1, ParamAttr::ByVal))
+    if (I.paramHasAttr(ArgNo+1, Attribute::ByVal))
       writeOperandDeref(*AI);
     else
       writeOperand(*AI);
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index 25ed4e0..e435f16 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -133,7 +133,7 @@
     std::string getCppName(const Value* val);
     inline void printCppName(const Value* val);
 
-    void printParamAttrs(const PAListPtr &PAL, const std::string &name);
+    void printAttributes(const AttrListPtr &PAL, const std::string &name);
     bool printTypeInternal(const Type* Ty);
     inline void printType(const Type* Ty);
     void printTypes(const Module* M);
@@ -428,46 +428,46 @@
     printEscapedString(getCppName(val));
   }
 
-  void CppWriter::printParamAttrs(const PAListPtr &PAL,
+  void CppWriter::printAttributes(const AttrListPtr &PAL,
                                   const std::string &name) {
-    Out << "PAListPtr " << name << "_PAL;";
+    Out << "AttrListPtr " << name << "_PAL;";
     nl(Out);
     if (!PAL.isEmpty()) {
       Out << '{'; in(); nl(Out);
-      Out << "SmallVector<FnAttributeWithIndex, 4> Attrs;"; nl(Out);
-      Out << "FnAttributeWithIndex PAWI;"; nl(Out);
+      Out << "SmallVector<AttributeWithIndex, 4> Attrs;"; nl(Out);
+      Out << "AttributeWithIndex PAWI;"; nl(Out);
       for (unsigned i = 0; i < PAL.getNumSlots(); ++i) {
         uint16_t index = PAL.getSlot(i).Index;
         Attributes attrs = PAL.getSlot(i).Attrs;
         Out << "PAWI.Index = " << index << "; PAWI.Attrs = 0 ";
-        if (attrs & ParamAttr::SExt)
-          Out << " | ParamAttr::SExt";
-        if (attrs & ParamAttr::ZExt)
-          Out << " | ParamAttr::ZExt";
-        if (attrs & ParamAttr::StructRet)
-          Out << " | ParamAttr::StructRet";
-        if (attrs & ParamAttr::InReg)
-          Out << " | ParamAttr::InReg";
-        if (attrs & ParamAttr::NoReturn)
-          Out << " | ParamAttr::NoReturn";
-        if (attrs & ParamAttr::NoUnwind)
-          Out << " | ParamAttr::NoUnwind";
-        if (attrs & ParamAttr::ByVal)
-          Out << " | ParamAttr::ByVal";
-        if (attrs & ParamAttr::NoAlias)
-          Out << " | ParamAttr::NoAlias";
-        if (attrs & ParamAttr::Nest)
-          Out << " | ParamAttr::Nest";
-        if (attrs & ParamAttr::ReadNone)
-          Out << " | ParamAttr::ReadNone";
-        if (attrs & ParamAttr::ReadOnly)
-          Out << " | ParamAttr::ReadOnly";
+        if (attrs & Attribute::SExt)
+          Out << " | Attribute::SExt";
+        if (attrs & Attribute::ZExt)
+          Out << " | Attribute::ZExt";
+        if (attrs & Attribute::StructRet)
+          Out << " | Attribute::StructRet";
+        if (attrs & Attribute::InReg)
+          Out << " | Attribute::InReg";
+        if (attrs & Attribute::NoReturn)
+          Out << " | Attribute::NoReturn";
+        if (attrs & Attribute::NoUnwind)
+          Out << " | Attribute::NoUnwind";
+        if (attrs & Attribute::ByVal)
+          Out << " | Attribute::ByVal";
+        if (attrs & Attribute::NoAlias)
+          Out << " | Attribute::NoAlias";
+        if (attrs & Attribute::Nest)
+          Out << " | Attribute::Nest";
+        if (attrs & Attribute::ReadNone)
+          Out << " | Attribute::ReadNone";
+        if (attrs & Attribute::ReadOnly)
+          Out << " | Attribute::ReadOnly";
         Out << ";";
         nl(Out);
         Out << "Attrs.push_back(PAWI);";
         nl(Out);
       }
-      Out << name << "_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());";
+      Out << name << "_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());";
       nl(Out);
       out(); nl(Out);
       Out << '}'; nl(Out);
@@ -1127,8 +1127,8 @@
       nl(Out) << iName << "->setCallingConv(";
       printCallingConv(inv->getCallingConv());
       Out << ");";
-      printParamAttrs(inv->getParamAttrs(), iName);
-      Out << iName << "->setParamAttrs(" << iName << "_PAL);";
+      printAttributes(inv->getAttributes(), iName);
+      Out << iName << "->setAttributes(" << iName << "_PAL);";
       nl(Out);
       break;
     }
@@ -1390,8 +1390,8 @@
       nl(Out) << iName << "->setTailCall("
           << (call->isTailCall() ? "true":"false");
       Out << ");";
-      printParamAttrs(call->getParamAttrs(), iName);
-      Out << iName << "->setParamAttrs(" << iName << "_PAL);";
+      printAttributes(call->getAttributes(), iName);
+      Out << iName << "->setAttributes(" << iName << "_PAL);";
       nl(Out);
       break;
     }
@@ -1614,9 +1614,9 @@
       Out << "}";
       nl(Out);
     }
-    printParamAttrs(F->getParamAttrs(), getCppName(F));
+    printAttributes(F->getAttributes(), getCppName(F));
     printCppName(F);
-    Out << "->setParamAttrs(" << getCppName(F) << "_PAL);";
+    Out << "->setAttributes(" << getCppName(F) << "_PAL);";
     nl(Out);
   }
 
diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp
index 79661b0..cef8da2 100644
--- a/lib/Target/MSIL/MSILWriter.cpp
+++ b/lib/Target/MSIL/MSILWriter.cpp
@@ -1392,7 +1392,7 @@
 
 
 void MSILWriter::printFunction(const Function& F) {
-  bool isSigned = F.paramHasAttr(0, ParamAttr::SExt);
+  bool isSigned = F.paramHasAttr(0, Attribute::SExt);
   Out << "\n.method static ";
   Out << (F.hasInternalLinkage() ? "private " : "public ");
   if (F.isVarArg()) Out << "vararg ";
@@ -1403,7 +1403,7 @@
   unsigned ArgIdx = 1;
   for (Function::const_arg_iterator I = F.arg_begin(), E = F.arg_end(); I!=E;
        ++I, ++ArgIdx) {
-    isSigned = F.paramHasAttr(ArgIdx, ParamAttr::SExt);
+    isSigned = F.paramHasAttr(ArgIdx, Attribute::SExt);
     if (I!=F.arg_begin()) Out << ", ";
     Out << getTypeName(I->getType(),isSigned) << getValueName(I);
   }
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index 01fda9f..57db933 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -71,7 +71,7 @@
     const Type* Ty = AI->getType();
 
     // 'Dereference' type in case of byval parameter attribute
-    if (F->paramHasAttr(argNum, ParamAttr::ByVal))
+    if (F->paramHasAttr(argNum, Attribute::ByVal))
       Ty = cast<PointerType>(Ty)->getElementType();
 
     // Size should be aligned to DWORD boundary
@@ -154,7 +154,7 @@
   SwitchToSection(TAI->SectionForGlobal(F));
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
+  if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
diff --git a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
index 262e0f7..d2521d0 100644
--- a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
@@ -54,7 +54,7 @@
     const Type* Ty = AI->getType();
 
     // 'Dereference' type in case of byval parameter attribute
-    if (F->paramHasAttr(argNum, ParamAttr::ByVal))
+    if (F->paramHasAttr(argNum, Attribute::ByVal))
       Ty = cast<PointerType>(Ty)->getElementType();
 
     // Size should be aligned to DWORD boundary
@@ -141,7 +141,7 @@
   SwitchToTextSection("_text", F);
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
+  if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unsupported linkage type!");
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp
index a820c26..0554121 100644
--- a/lib/Target/X86/X86FastISel.cpp
+++ b/lib/Target/X86/X86FastISel.cpp
@@ -898,16 +898,16 @@
       return false;
     ISD::ArgFlagsTy Flags;
     unsigned AttrInd = i - CS.arg_begin() + 1;
-    if (CS.paramHasAttr(AttrInd, ParamAttr::SExt))
+    if (CS.paramHasAttr(AttrInd, Attribute::SExt))
       Flags.setSExt();
-    if (CS.paramHasAttr(AttrInd, ParamAttr::ZExt))
+    if (CS.paramHasAttr(AttrInd, Attribute::ZExt))
       Flags.setZExt();
 
     // FIXME: Only handle *easy* calls for now.
-    if (CS.paramHasAttr(AttrInd, ParamAttr::InReg) ||
-        CS.paramHasAttr(AttrInd, ParamAttr::StructRet) ||
-        CS.paramHasAttr(AttrInd, ParamAttr::Nest) ||
-        CS.paramHasAttr(AttrInd, ParamAttr::ByVal))
+    if (CS.paramHasAttr(AttrInd, Attribute::InReg) ||
+        CS.paramHasAttr(AttrInd, Attribute::StructRet) ||
+        CS.paramHasAttr(AttrInd, Attribute::Nest) ||
+        CS.paramHasAttr(AttrInd, Attribute::ByVal))
       return false;
 
     const Type *ArgTy = (*i)->getType();
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index d0b726f..fc97c4e 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -5757,7 +5757,7 @@
 
       // Check that ECX wasn't needed by an 'inreg' parameter.
       const FunctionType *FTy = Func->getFunctionType();
-      const PAListPtr &Attrs = Func->getParamAttrs();
+      const AttrListPtr &Attrs = Func->getAttributes();
 
       if (!Attrs.isEmpty() && !Func->isVarArg()) {
         unsigned InRegCount = 0;
@@ -5765,7 +5765,7 @@
 
         for (FunctionType::param_iterator I = FTy->param_begin(),
              E = FTy->param_end(); I != E; ++I, ++Idx)
-          if (Attrs.paramHasAttr(Idx, ParamAttr::InReg))
+          if (Attrs.paramHasAttr(Idx, Attribute::InReg))
             // FIXME: should only count parameters that are lowered to integers.
             InRegCount += (TD->getTypeSizeInBits(*I) + 31) / 32;