Parse function notes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2008-09-02 20:52:40 +00:00
parent 81b2ab8a24
commit d49808184f
5 changed files with 1584 additions and 1426 deletions

View File

@ -497,6 +497,12 @@ int LLLexer::LexIdentifier() {
KEYWORD("readnone", READNONE);
KEYWORD("readonly", READONLY);
KEYWORD("notes", FNNOTE);
KEYWORD("inline", INLINE);
KEYWORD("always", ALWAYS);
KEYWORD("never", NEVER);
KEYWORD("optimizeforsize", OPTIMIZEFORSIZE);
KEYWORD("type", TYPE);
KEYWORD("opaque", OPAQUE);

File diff suppressed because it is too large Load Diff

View File

@ -190,9 +190,14 @@
READNONE = 406,
READONLY = 407,
GC = 408,
DEFAULT = 409,
HIDDEN = 410,
PROTECTED = 411
FNNOTE = 409,
INLINE = 410,
ALWAYS = 411,
NEVER = 412,
OPTIMIZEFORSIZE = 413,
DEFAULT = 414,
HIDDEN = 415,
PROTECTED = 416
};
#endif
/* Tokens. */
@ -347,16 +352,21 @@
#define READNONE 406
#define READONLY 407
#define GC 408
#define DEFAULT 409
#define HIDDEN 410
#define PROTECTED 411
#define FNNOTE 409
#define INLINE 410
#define ALWAYS 411
#define NEVER 412
#define OPTIMIZEFORSIZE 413
#define DEFAULT 414
#define HIDDEN 415
#define PROTECTED 416
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 970 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
#line 970 "/Volumes/Nanpura/fn_prop/llvm/lib/AsmParser/llvmAsmParser.y"
{
llvm::Module *ModuleVal;
llvm::Function *FunctionVal;
@ -385,6 +395,7 @@ typedef union YYSTYPE
llvm::GlobalValue::LinkageTypes Linkage;
llvm::GlobalValue::VisibilityTypes Visibility;
llvm::ParameterAttributes ParamAttrs;
llvm::FunctionNotes FunctionNotes;
llvm::APInt *APIntVal;
int64_t SInt64Val;
uint64_t UInt64Val;
@ -405,7 +416,7 @@ typedef union YYSTYPE
llvm::FCmpInst::Predicate FPredicate;
}
/* Line 1529 of yacc.c. */
#line 409 "llvmAsmParser.tab.h"
#line 420 "llvmAsmParser.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1

View File

@ -995,6 +995,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
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 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
%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 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
%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 @@ OptFuncAttrs : /* empty */ { $$ = ParamAttr::None; }
}
;
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 @@ ArgList : ArgListH {
};
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 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
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...

View File

@ -995,6 +995,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
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 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
%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 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
%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 @@ OptFuncAttrs : /* empty */ { $$ = ParamAttr::None; }
}
;
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 @@ ArgList : ArgListH {
};
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 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
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...