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
This commit is contained in:
Devang Patel 2008-09-24 00:06:15 +00:00
parent da43bcf624
commit 20bcaff6a7
12 changed files with 40 additions and 38 deletions

View 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.

View 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:

View 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;
}

View 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;
}

View 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!");

View 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!");

View 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;

View 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

View 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;
}

View 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.

View 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

View 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 {