From 20bcaff6a7f93a9894f7233c449b016bafe93b26 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 24 Sep 2008 00:06:15 +0000 Subject: [PATCH] Put FN_NOTE_AlwaysInline and others in FnAttr namespace. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56527 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Attributes.h | 10 ++++++---- lib/AsmParser/llvmAsmParser.cpp.cvs | 16 ++++++++-------- lib/AsmParser/llvmAsmParser.y | 16 ++++++++-------- lib/AsmParser/llvmAsmParser.y.cvs | 16 ++++++++-------- lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 2 +- lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp | 2 +- lib/Transforms/IPO/InlineAlways.cpp | 2 +- lib/Transforms/IPO/InlineSimple.cpp | 2 +- lib/Transforms/IPO/Inliner.cpp | 2 +- lib/Transforms/Scalar/LoopUnswitch.cpp | 2 +- lib/Transforms/Utils/InlineCost.cpp | 2 +- lib/VMCore/AsmWriter.cpp | 6 +++--- 12 files changed, 40 insertions(+), 38 deletions(-) diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h index a503354567c..0e416944694 100644 --- a/include/llvm/Attributes.h +++ b/include/llvm/Attributes.h @@ -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. diff --git a/lib/AsmParser/llvmAsmParser.cpp.cvs b/lib/AsmParser/llvmAsmParser.cpp.cvs index 4d8ab7445ca..9fb6134ee28 100644 --- a/lib/AsmParser/llvmAsmParser.cpp.cvs +++ b/lib/AsmParser/llvmAsmParser.cpp.cvs @@ -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: diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 5de34a722c7..224177855e4 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -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; } diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs index 5de34a722c7..224177855e4 100644 --- a/lib/AsmParser/llvmAsmParser.y.cvs +++ b/lib/AsmParser/llvmAsmParser.y.cvs @@ -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; } diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 2c9975eb73b..cada75027d0 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -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!"); diff --git a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp index 7c2713cf116..3c4612b1e2d 100644 --- a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp @@ -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!"); diff --git a/lib/Transforms/IPO/InlineAlways.cpp b/lib/Transforms/IPO/InlineAlways.cpp index ddcc79cf59b..6d95ffd2d52 100644 --- a/lib/Transforms/IPO/InlineAlways.cpp +++ b/lib/Transforms/IPO/InlineAlways.cpp @@ -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; diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 42897676418..1cf6c9ec6c5 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -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 diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 7922d6e7a94..57188359956 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -141,7 +141,7 @@ bool Inliner::runOnSCC(const std::vector &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; } diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 4fd3d031a1a..a6f6bd73a58 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -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. diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp index 6ecd0609912..c35af251b24 100644 --- a/lib/Transforms/Utils/InlineCost.cpp +++ b/lib/Transforms/Utils/InlineCost.cpp @@ -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 diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 3b9b6690fe9..6cdf72527bf 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -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 {