Parse function notes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55646 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs
index 36b56ea..d004a4e 100644
--- a/lib/AsmParser/llvmAsmParser.y.cvs
+++ b/lib/AsmParser/llvmAsmParser.y.cvs
@@ -995,6 +995,7 @@
   llvm::GlobalValue::LinkageTypes         Linkage;
   llvm::GlobalValue::VisibilityTypes      Visibility;
   llvm::ParameterAttributes         ParamAttrs;
+  llvm::FunctionNotes               FunctionNotes;
   llvm::APInt                       *APIntVal;
   int64_t                           SInt64Val;
   uint64_t                          UInt64Val;
@@ -1090,6 +1091,8 @@
 %type <UIntVal> OptCallingConv LocalNumber
 %type <ParamAttrs> OptParamAttrs ParamAttr 
 %type <ParamAttrs> OptFuncAttrs  FuncAttr
+%type <FunctionNotes> OptFuncNotes FuncNote 
+%type <FunctionNotes> FuncNoteList
 
 // Basic Block Terminating Operators
 %token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
@@ -1123,6 +1126,9 @@
 %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
 %token READNONE READONLY GC
 
+// Function Notes
+%token FNNOTE INLINE ALWAYS NEVER OPTIMIZEFORSIZE
+
 // Visibility Styles
 %token DEFAULT HIDDEN PROTECTED
 
@@ -1288,6 +1294,29 @@
               }
               ;
 
+FuncNoteList  : FuncNote { $$ = $1; }
+              | FuncNoteList ',' FuncNote { 
+                FunctionNotes tmp = $1 | $3;
+                if ($3 == FP_NoInline && ($1 & FP_AlwaysInline))
+                  GEN_ERROR("Function Notes may include only one inline notes!")
+                if ($3 == FP_AlwaysInline && ($1 & FP_NoInline))
+                  GEN_ERROR("Function Notes may include only one inline notes!")
+                $$ = tmp;
+                CHECK_FOR_ERROR 
+              }
+              ;
+
+FuncNote      : INLINE '=' NEVER { $$ = FP_NoInline; }
+              | INLINE '=' ALWAYS { $$ = FP_AlwaysInline; }
+              | OPTIMIZEFORSIZE { $$ = FP_OptimizeForSize; }
+              ;
+
+OptFuncNotes  : /* empty */ { $$ = FP_None; }
+              | FNNOTE '(' FuncNoteList  ')' {
+                $$ =  $3;
+              }
+              ;
+
 OptGC         : /* empty */ { $$ = 0; }
               | GC STRINGCONSTANT {
                 $$ = $2;
@@ -2303,7 +2332,7 @@
   };
 
 FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')' 
-                  OptFuncAttrs OptSection OptAlign OptGC {
+                  OptFuncAttrs OptSection OptAlign OptGC OptFuncNotes {
   std::string FunctionName(*$3);
   delete $3;  // Free strdup'd memory!
   
@@ -2405,6 +2434,9 @@
     Fn->setGC($10->c_str());
     delete $10;
   }
+  if ($11) {
+    Fn->setNotes($11);
+  }
 
   // Add all of the arguments we parsed to the function...
   if ($5) {                     // Is null if empty...