diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-25 14:29:12 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-25 14:29:12 +0000 |
commit | 77d0f970b32d0eb62ca06dda19be42f2ffd341cd (patch) | |
tree | ef6fd0db186ee4daacd0c7b69e14191f86b93b32 /lib/AsmParser/llvmAsmParser.y.cvs | |
parent | 8b0a8c84da2030ee8f4440d5b60a8033de691222 (diff) |
Regenerate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/llvmAsmParser.y.cvs')
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y.cvs | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs index 2b08d3afa1..21aa30b332 100644 --- a/lib/AsmParser/llvmAsmParser.y.cvs +++ b/lib/AsmParser/llvmAsmParser.y.cvs @@ -1004,6 +1004,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { %type <BoolVal> OptSideEffect // 'sideeffect' or not. %type <Linkage> GVInternalLinkage GVExternalLinkage %type <Linkage> FunctionDefineLinkage FunctionDeclareLinkage +%type <Linkage> AliasLinkage %type <Visibility> GVVisibilityStyle // ValueRef - Unresolved reference to a definition or BB @@ -1035,12 +1036,12 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { %token<StrVal> LOCALVAR GLOBALVAR LABELSTR STRINGCONSTANT ATSTRINGCONSTANT %type <StrVal> LocalName OptLocalName OptLocalAssign -%type <StrVal> GlobalName OptGlobalAssign +%type <StrVal> GlobalName OptGlobalAssign GlobalAssign %type <UIntVal> OptAlign OptCAlign %type <StrVal> OptSection SectionString %token ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK -%token DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE THREAD_LOCAL +%token DECLARE DEFINE GLOBAL CONSTANT SECTION ALIAS VOLATILE THREAD_LOCAL %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING %token DLLIMPORT DLLEXPORT EXTERN_WEAK %token OPAQUE EXTERNAL TARGET TRIPLE ALIGN @@ -1136,15 +1137,17 @@ OptLocalAssign : LocalName '=' { GlobalName : GLOBALVAR | ATSTRINGCONSTANT; -OptGlobalAssign : GlobalName '=' { - $$ = $1; - CHECK_FOR_ERROR - } +OptGlobalAssign : GlobalAssign | /*empty*/ { $$ = 0; CHECK_FOR_ERROR }; +GlobalAssign : GlobalName '=' { + $$ = $1; + CHECK_FOR_ERROR + } + GVInternalLinkage : INTERNAL { $$ = GlobalValue::InternalLinkage; } | WEAK { $$ = GlobalValue::WeakLinkage; } @@ -1161,6 +1164,7 @@ GVExternalLinkage GVVisibilityStyle : /*empty*/ { $$ = GlobalValue::DefaultVisibility; } + | DEFAULT { $$ = GlobalValue::DefaultVisibility; } | HIDDEN { $$ = GlobalValue::HiddenVisibility; } ; @@ -1170,7 +1174,7 @@ FunctionDeclareLinkage | EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; } ; -FunctionDefineLinkage +FunctionDefineLinkage : /*empty*/ { $$ = GlobalValue::ExternalLinkage; } | INTERNAL { $$ = GlobalValue::InternalLinkage; } | LINKONCE { $$ = GlobalValue::LinkOnceLinkage; } @@ -1178,6 +1182,12 @@ FunctionDefineLinkage | DLLEXPORT { $$ = GlobalValue::DLLExportLinkage; } ; +AliasLinkage + : /*empty*/ { $$ = GlobalValue::ExternalLinkage; } + | WEAK { $$ = GlobalValue::WeakLinkage; } + | INTERNAL { $$ = GlobalValue::InternalLinkage; } + ; + OptCallingConv : /*empty*/ { $$ = CallingConv::C; } | CCC_TOK { $$ = CallingConv::C; } | FASTCC_TOK { $$ = CallingConv::Fast; } | @@ -2031,6 +2041,34 @@ Definition CurGV = 0; CHECK_FOR_ERROR } + | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage ResultTypes SymbolicValueRef { + std::string Name($1); + if (Name.empty()) + GEN_ERROR("Alias name cannot be empty") + const PointerType *PFTy = 0; + const FunctionType *Ty = 0; + Value* V = 0; + const Type* VTy = 0; + if (!(PFTy = dyn_cast<PointerType>($5->get())) || + !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { + VTy = $5->get(); + V = getExistingVal(VTy, $6); + } else { + VTy = PFTy; + V = getExistingVal(PFTy, $6); + } + if (V == 0) + GEN_ERROR(std::string("Invalid aliasee for alias: ") + $1); + GlobalValue* Aliasee; + if (Aliasee = dyn_cast<GlobalValue>(V)) { + GlobalAlias* GA = new GlobalAlias(VTy, $4, Name, Aliasee, CurModule.CurrentModule); + GA->setVisibility($2); + InsertValue(GA, CurModule.Values); + } else + GEN_ERROR("Aliases can be created only to global values"); + CHECK_FOR_ERROR + delete $5; + } | TARGET TargetDefinition { CHECK_FOR_ERROR } @@ -2196,9 +2234,9 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')' // error. GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { - // Neither the existing or the current function is a declaration and they - // have the same name and same type. Clearly this is a redefinition. - GEN_ERROR("Redefinition of function '" + FunctionName + "'"); + // Neither the existing or the current function is a declaration and they + // have the same name and same type. Clearly this is a redefinition. + GEN_ERROR("Redefinition of function '" + FunctionName + "'"); } if (Fn->isDeclaration()) { // Make sure to strip off any argument names so we can't get conflicts. for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); @@ -2836,10 +2874,10 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { Ty = FunctionType::get($3->get(), ParamTypes, false, PAL); PFTy = PointerType::get(Ty); } - + Value *V = getVal(PFTy, $4); // Get the function we're calling... CHECK_FOR_ERROR - + // Check for call to invalid intrinsic to avoid crashing later. if (Function *theF = dyn_cast<Function>(V)) { if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && |