Put FN_NOTE_AlwaysInline and others in FnAttr namespace.
authorDevang Patel <dpatel@apple.com>
Wed, 24 Sep 2008 00:06:15 +0000 (00:06 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 24 Sep 2008 00:06:15 +0000 (00:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56527 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
include/llvm/Attributes.h
lib/AsmParser/llvmAsmParser.cpp.cvs
lib/AsmParser/llvmAsmParser.y
lib/AsmParser/llvmAsmParser.y.cvs
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
lib/Transforms/IPO/InlineAlways.cpp
lib/Transforms/IPO/InlineSimple.cpp
lib/Transforms/IPO/Inliner.cpp
lib/Transforms/Scalar/LoopUnswitch.cpp
lib/Transforms/Utils/InlineCost.cpp
lib/VMCore/AsmWriter.cpp

index a503354567c47a9dec71bf5a1a2576ad58e73ca4..0e416944694ca8f92ac83a5e52bcb77af39e3c8f 100644 (file)
@@ -78,12 +78,14 @@ inline Attributes constructAlignmentFromInt(unsigned i) {
 std::string getAsString(Attributes Attrs);
 } // end namespace ParamAttr
 
+namespace FnAttr {
 /// Function notes are implemented as attributes stored at index ~0 in 
 /// parameter attribute list.
-const Attributes FN_NOTE_None            = 0;    
-const Attributes FN_NOTE_NoInline        = 1<<0; // inline=never 
-const Attributes FN_NOTE_AlwaysInline    = 1<<1; // inline=always
-const Attributes FN_NOTE_OptimizeForSize = 1<<2; // opt_size
+const Attributes None            = 0;    
+const Attributes NoInline        = 1<<0; // inline=never 
+const Attributes AlwaysInline    = 1<<1; // inline=always
+const Attributes OptimizeForSize = 1<<2; // opt_size
+} // end namespace FnAttr
 
 /// This is just a pair of values to associate a set of parameter attributes
 /// with a parameter index. 
index 4d8ab7445caf7223b9e9f7f44348c24f77ed53bc..9fb6134ee28bd8d7c46dcac84628ee6ebfb9cdd3 100644 (file)
@@ -4125,11 +4125,11 @@ yyreduce:
 #line 1298 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
     { 
                 unsigned tmp = (yyvsp[(1) - (3)].ParamAttrs) | (yyvsp[(3) - (3)].ParamAttrs);
-                if ((yyvsp[(3) - (3)].ParamAttrs) == FN_NOTE_NoInline 
-                    && ((yyvsp[(1) - (3)].ParamAttrs) & FN_NOTE_AlwaysInline))
+                if ((yyvsp[(3) - (3)].ParamAttrs) == FnAttr::NoInline 
+                    && ((yyvsp[(1) - (3)].ParamAttrs) & FnAttr::AlwaysInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
-                    if ((yyvsp[(3) - (3)].ParamAttrs) == FN_NOTE_AlwaysInline 
-                        && ((yyvsp[(1) - (3)].ParamAttrs) & FN_NOTE_NoInline))
+                    if ((yyvsp[(3) - (3)].ParamAttrs) == FnAttr::AlwaysInline 
+                        && ((yyvsp[(1) - (3)].ParamAttrs) & FnAttr::NoInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 (yyval.ParamAttrs) = tmp;
                 CHECK_FOR_ERROR 
@@ -4138,22 +4138,22 @@ yyreduce:
 
   case 131:
 #line 1311 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = FN_NOTE_NoInline; ;}
+    { (yyval.ParamAttrs) = FnAttr::NoInline; ;}
     break;
 
   case 132:
 #line 1312 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = FN_NOTE_AlwaysInline; ;}
+    { (yyval.ParamAttrs) = FnAttr::AlwaysInline; ;}
     break;
 
   case 133:
 #line 1313 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = FN_NOTE_OptimizeForSize; ;}
+    { (yyval.ParamAttrs) = FnAttr::OptimizeForSize; ;}
     break;
 
   case 134:
 #line 1316 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = FN_NOTE_None; ;}
+    { (yyval.ParamAttrs) = FnAttr::None; ;}
     break;
 
   case 135:
index 5de34a722c7b8e793da8b2a0393e049a868bb4d5..224177855e43fa7dc3a0490b202a8272936d6782 100644 (file)
@@ -1297,23 +1297,23 @@ OptFuncAttrs  : /* empty */ { $$ = ParamAttr::None; }
 FuncNoteList  : FuncNote { $$ = $1; }
               | FuncNoteList ',' FuncNote { 
                 unsigned tmp = $1 | $3;
-                if ($3 == FN_NOTE_NoInline 
-                    && ($1 & FN_NOTE_AlwaysInline))
+                if ($3 == FnAttr::NoInline 
+                    && ($1 & FnAttr::AlwaysInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
-                    if ($3 == FN_NOTE_AlwaysInline 
-                        && ($1 & FN_NOTE_NoInline))
+                    if ($3 == FnAttr::AlwaysInline 
+                        && ($1 & FnAttr::NoInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 $$ = tmp;
                 CHECK_FOR_ERROR 
               }
               ;
 
-FuncNote      : INLINE '=' NEVER { $$ = FN_NOTE_NoInline; }
-              | INLINE '=' ALWAYS { $$ = FN_NOTE_AlwaysInline; }
-              | OPTIMIZEFORSIZE { $$ = FN_NOTE_OptimizeForSize; }
+FuncNote      : INLINE '=' NEVER { $$ = FnAttr::NoInline; }
+              | INLINE '=' ALWAYS { $$ = FnAttr::AlwaysInline; }
+              | OPTIMIZEFORSIZE { $$ = FnAttr::OptimizeForSize; }
               ;
 
-OptFuncNotes  : /* empty */ { $$ = FN_NOTE_None; }
+OptFuncNotes  : /* empty */ { $$ = FnAttr::None; }
               | FNNOTE '(' FuncNoteList  ')' {
                 $$ =  $3;
               }
index 5de34a722c7b8e793da8b2a0393e049a868bb4d5..224177855e43fa7dc3a0490b202a8272936d6782 100644 (file)
@@ -1297,23 +1297,23 @@ OptFuncAttrs  : /* empty */ { $$ = ParamAttr::None; }
 FuncNoteList  : FuncNote { $$ = $1; }
               | FuncNoteList ',' FuncNote { 
                 unsigned tmp = $1 | $3;
-                if ($3 == FN_NOTE_NoInline 
-                    && ($1 & FN_NOTE_AlwaysInline))
+                if ($3 == FnAttr::NoInline 
+                    && ($1 & FnAttr::AlwaysInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
-                    if ($3 == FN_NOTE_AlwaysInline 
-                        && ($1 & FN_NOTE_NoInline))
+                    if ($3 == FnAttr::AlwaysInline 
+                        && ($1 & FnAttr::NoInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 $$ = tmp;
                 CHECK_FOR_ERROR 
               }
               ;
 
-FuncNote      : INLINE '=' NEVER { $$ = FN_NOTE_NoInline; }
-              | INLINE '=' ALWAYS { $$ = FN_NOTE_AlwaysInline; }
-              | OPTIMIZEFORSIZE { $$ = FN_NOTE_OptimizeForSize; }
+FuncNote      : INLINE '=' NEVER { $$ = FnAttr::NoInline; }
+              | INLINE '=' ALWAYS { $$ = FnAttr::AlwaysInline; }
+              | OPTIMIZEFORSIZE { $$ = FnAttr::OptimizeForSize; }
               ;
 
-OptFuncNotes  : /* empty */ { $$ = FN_NOTE_None; }
+OptFuncNotes  : /* empty */ { $$ = FnAttr::None; }
               | FNNOTE '(' FuncNoteList  ')' {
                 $$ =  $3;
               }
index 2c9975eb73b379af1475dea7c9bc692dab00bfd3..cada75027d0c519be0f7292fbccfe5f362e74bfe 100644 (file)
@@ -160,7 +160,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
   SwitchToTextSection(SectionName.c_str());
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (!F->isDeclaration() && F->hasNote(FN_NOTE_OptimizeForSize))
+  if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
index 7c2713cf1169e4844f4b4226b1656afa7526e9fd..3c4612b1e2d4995511381ab634fcd8de3361bd4b 100644 (file)
@@ -147,7 +147,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (!F->isDeclaration() && F->hasNote(FN_NOTE_OptimizeForSize))
+  if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unsupported linkage type!");
index ddcc79cf59be994e2dfb4d52ac60ac653867f0e8..6d95ffd2d5212eaf5590c0b17bdb1fe567549344 100644 (file)
@@ -63,7 +63,7 @@ bool AlwaysInliner::doInitialization(CallGraph &CG) {
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
-    if (!I->isDeclaration() && !I->hasNote(FN_NOTE_AlwaysInline))
+    if (!I->isDeclaration() && !I->hasNote(FnAttr::AlwaysInline))
       NeverInline.insert(I);
 
   return false;
index 42897676418fa9d1803f89ebf5bcaa63d91dcd7f..1cf6c9ec6c5694cf1df3297d17fd51b483591d48 100644 (file)
@@ -65,7 +65,7 @@ bool SimpleInliner::doInitialization(CallGraph &CG) {
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
-    if (!I->isDeclaration() && I->hasNote(FN_NOTE_NoInline))
+    if (!I->isDeclaration() && I->hasNote(FnAttr::NoInline))
       NeverInline.insert(I);
 
   // Get llvm.noinline
index 7922d6e7a9453f9aced49f10332c62d2cdf1c56f..5718835995616e65ef72d47f64e3d537a62ca44f 100644 (file)
@@ -141,7 +141,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
         
         int CurrentThreshold = InlineThreshold;
         Function *Fn = CS.getCaller();
-        if (Fn && !Fn->isDeclaration() && Fn->hasNote(FN_NOTE_OptimizeForSize)
+        if (Fn && !Fn->isDeclaration() && Fn->hasNote(FnAttr::OptimizeForSize)
             && InlineThreshold != 50) {
           CurrentThreshold = 50;
         }
index 4fd3d031a1a2a66d031ed07e307e87a00c77cb95..a6f6bd73a581ed24aeacaa269a638949f1ef5700 100644 (file)
@@ -430,7 +430,7 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){
   Function *F = loopHeader->getParent();
 
   // Do not unswitch if the function is optimized for size.
-  if (!F->isDeclaration() && F->hasNote(FN_NOTE_OptimizeForSize))
+  if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
     return false;
 
   // Check to see if it would be profitable to unswitch current loop.
index 6ecd060991238c9f46ff137f400a09ef0db616aa..c35af251b24d2852f90a33bd6b565635c4aa06cf 100644 (file)
@@ -222,7 +222,7 @@ int InlineCostAnalyzer::getInlineCost(CallSite CS,
   if (CalleeFI.NeverInline)
     return 2000000000;
 
-  if (!Callee->isDeclaration() && Callee->hasNote(FN_NOTE_AlwaysInline))
+  if (!Callee->isDeclaration() && Callee->hasNote(FnAttr::AlwaysInline))
     return -2000000000;
     
   // Add to the inline quality for properties that make the call valuable to
index 3b9b6690fe94b3352a981bd1203f62a451cec6c7..6cdf72527bfb3df22e6dc55938c718d95fad38a8 100644 (file)
@@ -1412,12 +1412,12 @@ void AssemblyWriter::printFunction(const Function *F) {
   } else {
 
     bool insideNotes = false;
-    if (F->hasNote(FN_NOTE_AlwaysInline)) {
+    if (F->hasNote(FnAttr::AlwaysInline)) {
       Out << "notes(";
       insideNotes = true;
       Out << "inline=always";
     }
-    if (F->hasNote(FN_NOTE_NoInline)) {
+    if (F->hasNote(FnAttr::NoInline)) {
       if (insideNotes) 
         Out << ",";
       else {
@@ -1426,7 +1426,7 @@ void AssemblyWriter::printFunction(const Function *F) {
       }
       Out << "inline=never";
     }
-    if (F->hasNote(FN_NOTE_OptimizeForSize)) {
+    if (F->hasNote(FnAttr::OptimizeForSize)) {
       if (insideNotes) 
         Out << ",";
       else {