1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
61 /* Substitute the variable and function names. */
62 #define yyparse Upgradeparse
63 #define yylex Upgradelex
64 #define yyerror Upgradeerror
65 #define yylval Upgradelval
66 #define yychar Upgradechar
67 #define yydebug Upgradedebug
68 #define yynerrs Upgradenerrs
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
100 ZEROINITIALIZER = 281,
143 X86_STDCALLCC_TOK = 324,
144 X86_FASTCALLCC_TOK = 325,
188 EXTRACTELEMENT = 369,
229 #define ESINT64VAL 258
230 #define EUINT64VAL 259
250 #define STRINGCONSTANT 279
251 #define IMPLEMENTATION 280
252 #define ZEROINITIALIZER 281
263 #define DOTDOTDOT 292
270 #define APPENDING 299
271 #define DLLIMPORT 300
272 #define DLLEXPORT 301
273 #define EXTERN_WEAK 302
280 #define POINTERSIZE 309
289 #define SIDEEFFECT 318
292 #define CSRETCC_TOK 321
293 #define FASTCC_TOK 322
294 #define COLDCC_TOK 323
295 #define X86_STDCALLCC_TOK 324
296 #define X86_FASTCALLCC_TOK 325
297 #define DATALAYOUT 326
302 #define UNREACHABLE 331
332 #define GETELEMENTPTR 361
340 #define EXTRACTELEMENT 369
341 #define INSERTELEMENT 370
342 #define SHUFFLEVECTOR 371
343 #define VAARG_old 372
344 #define VANEXT_old 373
382 /* Copy the first part of user declarations. */
383 #line 14 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
385 #include "UpgradeInternals.h"
386 #include "llvm/CallingConv.h"
387 #include "llvm/InlineAsm.h"
388 #include "llvm/Instructions.h"
389 #include "llvm/Module.h"
390 #include "llvm/SymbolTable.h"
391 #include "llvm/Support/GetElementPtrTypeIterator.h"
392 #include "llvm/ADT/STLExtras.h"
393 #include "llvm/Support/MathExtras.h"
399 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
400 // relating to upreferences in the input stream.
402 //#define DEBUG_UPREFS 1
404 #define UR_OUT(X) std::cerr << X
409 #define YYERROR_VERBOSE 1
410 #define YYINCLUDED_STDLIB_H
416 int yyerror(const char*);
417 static void warning(const std::string& WarningMsg);
421 std::istream* LexInput;
422 static std::string CurFilename;
424 // This bool controls whether attributes are ever added to function declarations
425 // definitions and calls.
426 static bool AddAttributes = false;
428 static Module *ParserResult;
429 static bool ObsoleteVarArgs;
430 static bool NewVarArgs;
431 static BasicBlock *CurBB;
432 static GlobalVariable *CurGV;
434 // This contains info used when building the body of a function. It is
435 // destroyed when the function is completed.
437 typedef std::vector<Value *> ValueList; // Numbered defs
439 typedef std::pair<std::string,const Type*> RenameMapKey;
440 typedef std::map<RenameMapKey,std::string> RenameMapType;
443 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
444 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
446 static struct PerModuleInfo {
447 Module *CurrentModule;
448 std::map<const Type *, ValueList> Values; // Module level numbered definitions
449 std::map<const Type *,ValueList> LateResolveValues;
450 std::vector<PATypeHolder> Types;
451 std::map<ValID, PATypeHolder> LateResolveTypes;
452 static Module::Endianness Endian;
453 static Module::PointerSize PointerSize;
454 RenameMapType RenameMap;
456 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
457 /// how they were referenced and on which line of the input they came from so
458 /// that we can resolve them later and print error messages as appropriate.
459 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
461 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
462 // references to global values. Global values may be referenced before they
463 // are defined, and if so, the temporary object that they represent is held
464 // here. This is used for forward references of GlobalValues.
466 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
468 GlobalRefsType GlobalRefs;
471 // If we could not resolve some functions at function compilation time
472 // (calls to functions before they are defined), resolve them now... Types
473 // are resolved when the constant pool has been completely parsed.
475 ResolveDefinitions(LateResolveValues);
477 // Check to make sure that all global value forward references have been
480 if (!GlobalRefs.empty()) {
481 std::string UndefinedReferences = "Unresolved global references exist:\n";
483 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
485 UndefinedReferences += " " + I->first.first->getDescription() + " " +
486 I->first.second.getName() + "\n";
488 error(UndefinedReferences);
492 if (CurrentModule->getDataLayout().empty()) {
493 std::string dataLayout;
494 if (Endian != Module::AnyEndianness)
495 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
496 if (PointerSize != Module::AnyPointerSize) {
497 if (!dataLayout.empty())
499 dataLayout.append(PointerSize == Module::Pointer64 ?
500 "p:64:64" : "p:32:32");
502 CurrentModule->setDataLayout(dataLayout);
505 Values.clear(); // Clear out function local definitions
510 // GetForwardRefForGlobal - Check to see if there is a forward reference
511 // for this global. If so, remove it from the GlobalRefs map and return it.
512 // If not, just return null.
513 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
514 // Check to see if there is a forward reference to this global variable...
515 // if there is, eliminate it and patch the reference to use the new def'n.
516 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
517 GlobalValue *Ret = 0;
518 if (I != GlobalRefs.end()) {
524 void setEndianness(Module::Endianness E) { Endian = E; }
525 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
528 Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
529 Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
531 static struct PerFunctionInfo {
532 Function *CurrentFunction; // Pointer to current function being created
534 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
535 std::map<const Type*, ValueList> LateResolveValues;
536 bool isDeclare; // Is this function a forward declararation?
537 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
539 /// BBForwardRefs - When we see forward references to basic blocks, keep
540 /// track of them here.
541 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
542 std::vector<BasicBlock*> NumberedBlocks;
543 RenameMapType RenameMap;
546 inline PerFunctionInfo() {
549 Linkage = GlobalValue::ExternalLinkage;
552 inline void FunctionStart(Function *M) {
557 void FunctionDone() {
558 NumberedBlocks.clear();
560 // Any forward referenced blocks left?
561 if (!BBForwardRefs.empty()) {
562 error("Undefined reference to label " +
563 BBForwardRefs.begin()->first->getName());
567 // Resolve all forward references now.
568 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
570 Values.clear(); // Clear out function local definitions
574 Linkage = GlobalValue::ExternalLinkage;
576 } CurFun; // Info for the current function...
578 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
581 //===----------------------------------------------------------------------===//
582 // Code to handle definitions of all the types
583 //===----------------------------------------------------------------------===//
585 static int InsertValue(Value *V,
586 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
587 if (V->hasName()) return -1; // Is this a numbered definition?
589 // Yes, insert the value into the value table...
590 ValueList &List = ValueTab[V->getType()];
592 return List.size()-1;
595 static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
597 case ValID::NumberVal: // Is it a numbered definition?
598 // Module constants occupy the lowest numbered slots...
599 if ((unsigned)D.Num < CurModule.Types.size()) {
600 return CurModule.Types[(unsigned)D.Num];
603 case ValID::NameVal: // Is it a named definition?
604 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
605 D.destroy(); // Free old strdup'd memory...
610 error("Internal parser error: Invalid symbol type reference");
614 // If we reached here, we referenced either a symbol that we don't know about
615 // or an id number that hasn't been read yet. We may be referencing something
616 // forward, so just create an entry to be resolved later and get to it...
618 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
621 if (inFunctionScope()) {
622 if (D.Type == ValID::NameVal) {
623 error("Reference to an undefined type: '" + D.getName() + "'");
626 error("Reference to an undefined type: #" + itostr(D.Num));
631 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
632 if (I != CurModule.LateResolveTypes.end())
635 Type *Typ = OpaqueType::get();
636 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
640 // getExistingValue - Look up the value specified by the provided type and
641 // the provided ValID. If the value exists and has already been defined, return
642 // it. Otherwise return null.
644 static Value *getExistingValue(const Type *Ty, const ValID &D) {
645 if (isa<FunctionType>(Ty)) {
646 error("Functions are not values and must be referenced as pointers");
650 case ValID::NumberVal: { // Is it a numbered definition?
651 unsigned Num = (unsigned)D.Num;
653 // Module constants occupy the lowest numbered slots...
654 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
655 if (VI != CurModule.Values.end()) {
656 if (Num < VI->second.size())
657 return VI->second[Num];
658 Num -= VI->second.size();
661 // Make sure that our type is within bounds
662 VI = CurFun.Values.find(Ty);
663 if (VI == CurFun.Values.end()) return 0;
665 // Check that the number is within bounds...
666 if (VI->second.size() <= Num) return 0;
668 return VI->second[Num];
671 case ValID::NameVal: { // Is it a named definition?
672 // Get the name out of the ID
673 std::string Name(D.Name);
675 RenameMapKey Key = std::make_pair(Name, Ty);
676 if (inFunctionScope()) {
677 // See if the name was renamed
678 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
679 std::string LookupName;
680 if (I != CurFun.RenameMap.end())
681 LookupName = I->second;
684 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
685 V = SymTab.lookup(Ty, LookupName);
688 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
689 std::string LookupName;
690 if (I != CurModule.RenameMap.end())
691 LookupName = I->second;
694 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
699 D.destroy(); // Free old strdup'd memory...
703 // Check to make sure that "Ty" is an integral type, and that our
704 // value will fit into the specified type...
705 case ValID::ConstSIntVal: // Is it a constant pool reference??
706 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
707 error("Signed integral constant '" + itostr(D.ConstPool64) +
708 "' is invalid for type '" + Ty->getDescription() + "'");
710 return ConstantInt::get(Ty, D.ConstPool64);
712 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
713 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
714 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
715 error("Integral constant '" + utostr(D.UConstPool64) +
716 "' is invalid or out of range");
717 else // This is really a signed reference. Transmogrify.
718 return ConstantInt::get(Ty, D.ConstPool64);
720 return ConstantInt::get(Ty, D.UConstPool64);
722 case ValID::ConstFPVal: // Is it a floating point const pool reference?
723 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
724 error("FP constant invalid for type");
725 return ConstantFP::get(Ty, D.ConstPoolFP);
727 case ValID::ConstNullVal: // Is it a null value?
728 if (!isa<PointerType>(Ty))
729 error("Cannot create a a non pointer null");
730 return ConstantPointerNull::get(cast<PointerType>(Ty));
732 case ValID::ConstUndefVal: // Is it an undef value?
733 return UndefValue::get(Ty);
735 case ValID::ConstZeroVal: // Is it a zero value?
736 return Constant::getNullValue(Ty);
738 case ValID::ConstantVal: // Fully resolved constant?
739 if (D.ConstantValue->getType() != Ty)
740 error("Constant expression type different from required type");
741 return D.ConstantValue;
743 case ValID::InlineAsmVal: { // Inline asm expression
744 const PointerType *PTy = dyn_cast<PointerType>(Ty);
745 const FunctionType *FTy =
746 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
747 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
748 error("Invalid type for asm constraint string");
749 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
750 D.IAD->HasSideEffects);
751 D.destroy(); // Free InlineAsmDescriptor.
755 assert(0 && "Unhandled case");
759 assert(0 && "Unhandled case");
763 // getVal - This function is identical to getExistingValue, except that if a
764 // value is not already defined, it "improvises" by creating a placeholder var
765 // that looks and acts just like the requested variable. When the value is
766 // defined later, all uses of the placeholder variable are replaced with the
769 static Value *getVal(const Type *Ty, const ValID &ID) {
770 if (Ty == Type::LabelTy)
771 error("Cannot use a basic block here");
773 // See if the value has already been defined.
774 Value *V = getExistingValue(Ty, ID);
777 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
778 error("Invalid use of a composite type");
780 // If we reached here, we referenced either a symbol that we don't know about
781 // or an id number that hasn't been read yet. We may be referencing something
782 // forward, so just create an entry to be resolved later and get to it...
783 V = new Argument(Ty);
785 // Remember where this forward reference came from. FIXME, shouldn't we try
786 // to recycle these things??
787 CurModule.PlaceHolderInfo.insert(
788 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
790 if (inFunctionScope())
791 InsertValue(V, CurFun.LateResolveValues);
793 InsertValue(V, CurModule.LateResolveValues);
797 /// getBBVal - This is used for two purposes:
798 /// * If isDefinition is true, a new basic block with the specified ID is being
800 /// * If isDefinition is true, this is a reference to a basic block, which may
801 /// or may not be a forward reference.
803 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
804 assert(inFunctionScope() && "Can't get basic block at global scope");
810 error("Illegal label reference " + ID.getName());
812 case ValID::NumberVal: // Is it a numbered definition?
813 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
814 CurFun.NumberedBlocks.resize(ID.Num+1);
815 BB = CurFun.NumberedBlocks[ID.Num];
817 case ValID::NameVal: // Is it a named definition?
819 if (Value *N = CurFun.CurrentFunction->
820 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
821 if (N->getType() != Type::LabelTy)
822 error("Name '" + Name + "' does not refer to a BasicBlock");
823 BB = cast<BasicBlock>(N);
828 // See if the block has already been defined.
830 // If this is the definition of the block, make sure the existing value was
831 // just a forward reference. If it was a forward reference, there will be
832 // an entry for it in the PlaceHolderInfo map.
833 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
834 // The existing value was a definition, not a forward reference.
835 error("Redefinition of label " + ID.getName());
837 ID.destroy(); // Free strdup'd memory.
841 // Otherwise this block has not been seen before.
842 BB = new BasicBlock("", CurFun.CurrentFunction);
843 if (ID.Type == ValID::NameVal) {
844 BB->setName(ID.Name);
846 CurFun.NumberedBlocks[ID.Num] = BB;
849 // If this is not a definition, keep track of it so we can use it as a forward
852 // Remember where this forward reference came from.
853 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
855 // The forward declaration could have been inserted anywhere in the
856 // function: insert it into the correct place now.
857 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
858 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
865 //===----------------------------------------------------------------------===//
866 // Code to handle forward references in instructions
867 //===----------------------------------------------------------------------===//
869 // This code handles the late binding needed with statements that reference
870 // values not defined yet... for example, a forward branch, or the PHI node for
873 // This keeps a table (CurFun.LateResolveValues) of all such forward references
874 // and back patchs after we are done.
877 // ResolveDefinitions - If we could not resolve some defs at parsing
878 // time (forward branches, phi functions for loops, etc...) resolve the
882 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
883 std::map<const Type*,ValueList> *FutureLateResolvers) {
884 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
885 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
886 E = LateResolvers.end(); LRI != E; ++LRI) {
887 ValueList &List = LRI->second;
888 while (!List.empty()) {
889 Value *V = List.back();
892 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
893 CurModule.PlaceHolderInfo.find(V);
894 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
896 ValID &DID = PHI->second.first;
898 Value *TheRealValue = getExistingValue(LRI->first, DID);
900 V->replaceAllUsesWith(TheRealValue);
902 CurModule.PlaceHolderInfo.erase(PHI);
903 } else if (FutureLateResolvers) {
904 // Functions have their unresolved items forwarded to the module late
906 InsertValue(V, *FutureLateResolvers);
908 if (DID.Type == ValID::NameVal) {
909 error("Reference to an invalid definition: '" +DID.getName()+
910 "' of type '" + V->getType()->getDescription() + "'",
914 error("Reference to an invalid definition: #" +
915 itostr(DID.Num) + " of type '" +
916 V->getType()->getDescription() + "'", PHI->second.second);
923 LateResolvers.clear();
926 // ResolveTypeTo - A brand new type was just declared. This means that (if
927 // name is not null) things referencing Name can be resolved. Otherwise, things
928 // refering to the number can be resolved. Do this now.
930 static void ResolveTypeTo(char *Name, const Type *ToTy) {
932 if (Name) D = ValID::create(Name);
933 else D = ValID::create((int)CurModule.Types.size());
935 std::map<ValID, PATypeHolder>::iterator I =
936 CurModule.LateResolveTypes.find(D);
937 if (I != CurModule.LateResolveTypes.end()) {
938 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
939 CurModule.LateResolveTypes.erase(I);
943 static std::string makeNameUnique(const std::string& Name) {
944 static unsigned UniqueNameCounter = 1;
945 std::string Result(Name);
946 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
950 // setValueName - Set the specified value to the name given. The name may be
951 // null potentially, in which case this is a noop. The string passed in is
952 // assumed to be a malloc'd string buffer, and is free'd by this function.
954 static void setValueName(Value *V, char *NameStr) {
956 std::string Name(NameStr); // Copy string
957 free(NameStr); // Free old string
959 if (V->getType() == Type::VoidTy) {
960 error("Can't assign name '" + Name + "' to value with void type");
964 assert(inFunctionScope() && "Must be in function scope");
966 // Search the function's symbol table for an existing value of this name
968 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
969 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
970 for ( ; PI != PE; ++PI) {
971 SymbolTable::value_const_iterator VI = PI->second.find(Name);
972 if (VI != PI->second.end()) {
973 Existing = VI->second;
978 if (Existing->getType() == V->getType()) {
979 // The type of the Existing value and the new one are the same. This
980 // is probably a type plane collapsing error. If the types involved
981 // are both integer, just rename it. Otherwise it
982 // is a redefinition error.
983 if (!Existing->getType()->isInteger()) {
984 error("Redefinition of value named '" + Name + "' in the '" +
985 V->getType()->getDescription() + "' type plane");
989 // In LLVM 2.0 we don't allow names to be re-used for any values in a
990 // function, regardless of Type. Previously re-use of names was okay as
991 // long as they were distinct types. With type planes collapsing because
992 // of the signedness change and because of PR411, this can no longer be
993 // supported. We must search the entire symbol table for a conflicting
994 // name and make the name unique. No warning is needed as this can't
996 std::string NewName = makeNameUnique(Name);
997 // We're changing the name but it will probably be used by other
998 // instructions as operands later on. Consequently we have to retain
999 // a mapping of the renaming that we're doing.
1000 RenameMapKey Key = std::make_pair(Name,V->getType());
1001 CurFun.RenameMap[Key] = NewName;
1010 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1011 /// this is a declaration, otherwise it is a definition.
1012 static GlobalVariable *
1013 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1014 bool isConstantGlobal, const Type *Ty,
1015 Constant *Initializer) {
1016 if (isa<FunctionType>(Ty))
1017 error("Cannot declare global vars of function type");
1019 const PointerType *PTy = PointerType::get(Ty);
1023 Name = NameStr; // Copy string
1024 free(NameStr); // Free old string
1027 // See if this global value was forward referenced. If so, recycle the
1030 if (!Name.empty()) {
1031 ID = ValID::create((char*)Name.c_str());
1033 ID = ValID::create((int)CurModule.Values[PTy].size());
1036 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1037 // Move the global to the end of the list, from whereever it was
1038 // previously inserted.
1039 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1040 CurModule.CurrentModule->getGlobalList().remove(GV);
1041 CurModule.CurrentModule->getGlobalList().push_back(GV);
1042 GV->setInitializer(Initializer);
1043 GV->setLinkage(Linkage);
1044 GV->setConstant(isConstantGlobal);
1045 InsertValue(GV, CurModule.Values);
1049 // If this global has a name, check to see if there is already a definition
1050 // of this global in the module and emit warnings if there are conflicts.
1051 if (!Name.empty()) {
1052 // The global has a name. See if there's an existing one of the same name.
1053 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1054 // We found an existing global ov the same name. This isn't allowed
1055 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1056 // can at least compile. This can happen because of type planes
1057 // There is alread a global of the same name which means there is a
1058 // conflict. Let's see what we can do about it.
1059 std::string NewName(makeNameUnique(Name));
1060 if (Linkage == GlobalValue::InternalLinkage) {
1061 // The linkage type is internal so just warn about the rename without
1062 // invoking "scarey language" about linkage failures. GVars with
1063 // InternalLinkage can be renamed at will.
1064 warning("Global variable '" + Name + "' was renamed to '"+
1067 // The linkage of this gval is external so we can't reliably rename
1068 // it because it could potentially create a linking problem.
1069 // However, we can't leave the name conflict in the output either or
1070 // it won't assemble with LLVM 2.0. So, all we can do is rename
1071 // this one to something unique and emit a warning about the problem.
1072 warning("Renaming global variable '" + Name + "' to '" + NewName +
1073 "' may cause linkage errors");
1076 // Put the renaming in the global rename map
1077 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1078 CurModule.RenameMap[Key] = NewName;
1085 // Otherwise there is no existing GV to use, create one now.
1086 GlobalVariable *GV =
1087 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1088 CurModule.CurrentModule);
1089 InsertValue(GV, CurModule.Values);
1093 // setTypeName - Set the specified type to the name given. The name may be
1094 // null potentially, in which case this is a noop. The string passed in is
1095 // assumed to be a malloc'd string buffer, and is freed by this function.
1097 // This function returns true if the type has already been defined, but is
1098 // allowed to be redefined in the specified context. If the name is a new name
1099 // for the type plane, it is inserted and false is returned.
1100 static bool setTypeName(const Type *T, char *NameStr) {
1101 assert(!inFunctionScope() && "Can't give types function-local names");
1102 if (NameStr == 0) return false;
1104 std::string Name(NameStr); // Copy string
1105 free(NameStr); // Free old string
1107 // We don't allow assigning names to void type
1108 if (T == Type::VoidTy) {
1109 error("Can't assign name '" + Name + "' to the void type");
1113 // Set the type name, checking for conflicts as we do so.
1114 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1116 if (AlreadyExists) { // Inserting a name that is already defined???
1117 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1118 assert(Existing && "Conflict but no matching type?");
1120 // There is only one case where this is allowed: when we are refining an
1121 // opaque type. In this case, Existing will be an opaque type.
1122 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1123 // We ARE replacing an opaque type!
1124 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1128 // Otherwise, this is an attempt to redefine a type. That's okay if
1129 // the redefinition is identical to the original. This will be so if
1130 // Existing and T point to the same Type object. In this one case we
1131 // allow the equivalent redefinition.
1132 if (Existing == T) return true; // Yes, it's equal.
1134 // Any other kind of (non-equivalent) redefinition is an error.
1135 error("Redefinition of type named '" + Name + "' in the '" +
1136 T->getDescription() + "' type plane");
1142 //===----------------------------------------------------------------------===//
1143 // Code for handling upreferences in type names...
1146 // TypeContains - Returns true if Ty directly contains E in it.
1148 static bool TypeContains(const Type *Ty, const Type *E) {
1149 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1150 E) != Ty->subtype_end();
1154 struct UpRefRecord {
1155 // NestingLevel - The number of nesting levels that need to be popped before
1156 // this type is resolved.
1157 unsigned NestingLevel;
1159 // LastContainedTy - This is the type at the current binding level for the
1160 // type. Every time we reduce the nesting level, this gets updated.
1161 const Type *LastContainedTy;
1163 // UpRefTy - This is the actual opaque type that the upreference is
1164 // represented with.
1165 OpaqueType *UpRefTy;
1167 UpRefRecord(unsigned NL, OpaqueType *URTy)
1168 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1172 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1173 static std::vector<UpRefRecord> UpRefs;
1175 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1176 /// called. It loops through the UpRefs vector, which is a list of the
1177 /// currently active types. For each type, if the up reference is contained in
1178 /// the newly completed type, we decrement the level count. When the level
1179 /// count reaches zero, the upreferenced type is the type that is passed in:
1180 /// thus we can complete the cycle.
1182 static PATypeHolder HandleUpRefs(const Type *ty) {
1183 // If Ty isn't abstract, or if there are no up-references in it, then there is
1184 // nothing to resolve here.
1185 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1187 PATypeHolder Ty(ty);
1188 UR_OUT("Type '" << Ty->getDescription() <<
1189 "' newly formed. Resolving upreferences.\n" <<
1190 UpRefs.size() << " upreferences active!\n");
1192 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1193 // to zero), we resolve them all together before we resolve them to Ty. At
1194 // the end of the loop, if there is anything to resolve to Ty, it will be in
1196 OpaqueType *TypeToResolve = 0;
1198 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1199 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1200 << UpRefs[i].second->getDescription() << ") = "
1201 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1202 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1203 // Decrement level of upreference
1204 unsigned Level = --UpRefs[i].NestingLevel;
1205 UpRefs[i].LastContainedTy = Ty;
1206 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1207 if (Level == 0) { // Upreference should be resolved!
1208 if (!TypeToResolve) {
1209 TypeToResolve = UpRefs[i].UpRefTy;
1211 UR_OUT(" * Resolving upreference for "
1212 << UpRefs[i].second->getDescription() << "\n";
1213 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1214 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1215 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1216 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1218 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1219 --i; // Do not skip the next element...
1224 if (TypeToResolve) {
1225 UR_OUT(" * Resolving upreference for "
1226 << UpRefs[i].second->getDescription() << "\n";
1227 std::string OldName = TypeToResolve->getDescription());
1228 TypeToResolve->refineAbstractTypeTo(Ty);
1234 static inline Instruction::TermOps
1235 getTermOp(TermOps op) {
1237 default : assert(0 && "Invalid OldTermOp");
1238 case RetOp : return Instruction::Ret;
1239 case BrOp : return Instruction::Br;
1240 case SwitchOp : return Instruction::Switch;
1241 case InvokeOp : return Instruction::Invoke;
1242 case UnwindOp : return Instruction::Unwind;
1243 case UnreachableOp: return Instruction::Unreachable;
1247 static inline Instruction::BinaryOps
1248 getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1250 default : assert(0 && "Invalid OldBinaryOps");
1256 case SetGT : assert(0 && "Should use getCompareOp");
1257 case AddOp : return Instruction::Add;
1258 case SubOp : return Instruction::Sub;
1259 case MulOp : return Instruction::Mul;
1261 // This is an obsolete instruction so we must upgrade it based on the
1262 // types of its operands.
1263 bool isFP = Ty->isFloatingPoint();
1264 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1265 // If its a packed type we want to use the element type
1266 isFP = PTy->getElementType()->isFloatingPoint();
1268 return Instruction::FDiv;
1269 else if (Sign == Signed)
1270 return Instruction::SDiv;
1271 return Instruction::UDiv;
1273 case UDivOp : return Instruction::UDiv;
1274 case SDivOp : return Instruction::SDiv;
1275 case FDivOp : return Instruction::FDiv;
1277 // This is an obsolete instruction so we must upgrade it based on the
1278 // types of its operands.
1279 bool isFP = Ty->isFloatingPoint();
1280 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1281 // If its a packed type we want to use the element type
1282 isFP = PTy->getElementType()->isFloatingPoint();
1283 // Select correct opcode
1285 return Instruction::FRem;
1286 else if (Sign == Signed)
1287 return Instruction::SRem;
1288 return Instruction::URem;
1290 case URemOp : return Instruction::URem;
1291 case SRemOp : return Instruction::SRem;
1292 case FRemOp : return Instruction::FRem;
1293 case AndOp : return Instruction::And;
1294 case OrOp : return Instruction::Or;
1295 case XorOp : return Instruction::Xor;
1299 static inline Instruction::OtherOps
1300 getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1302 bool isSigned = Sign == Signed;
1303 bool isFP = Ty->isFloatingPoint();
1305 default : assert(0 && "Invalid OldSetCC");
1308 predicate = FCmpInst::FCMP_OEQ;
1309 return Instruction::FCmp;
1311 predicate = ICmpInst::ICMP_EQ;
1312 return Instruction::ICmp;
1316 predicate = FCmpInst::FCMP_UNE;
1317 return Instruction::FCmp;
1319 predicate = ICmpInst::ICMP_NE;
1320 return Instruction::ICmp;
1324 predicate = FCmpInst::FCMP_OLE;
1325 return Instruction::FCmp;
1328 predicate = ICmpInst::ICMP_SLE;
1330 predicate = ICmpInst::ICMP_ULE;
1331 return Instruction::ICmp;
1335 predicate = FCmpInst::FCMP_OGE;
1336 return Instruction::FCmp;
1339 predicate = ICmpInst::ICMP_SGE;
1341 predicate = ICmpInst::ICMP_UGE;
1342 return Instruction::ICmp;
1346 predicate = FCmpInst::FCMP_OLT;
1347 return Instruction::FCmp;
1350 predicate = ICmpInst::ICMP_SLT;
1352 predicate = ICmpInst::ICMP_ULT;
1353 return Instruction::ICmp;
1357 predicate = FCmpInst::FCMP_OGT;
1358 return Instruction::FCmp;
1361 predicate = ICmpInst::ICMP_SGT;
1363 predicate = ICmpInst::ICMP_UGT;
1364 return Instruction::ICmp;
1369 static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1371 default : assert(0 && "Invalid OldMemoryOps");
1372 case MallocOp : return Instruction::Malloc;
1373 case FreeOp : return Instruction::Free;
1374 case AllocaOp : return Instruction::Alloca;
1375 case LoadOp : return Instruction::Load;
1376 case StoreOp : return Instruction::Store;
1377 case GetElementPtrOp : return Instruction::GetElementPtr;
1381 static inline Instruction::OtherOps
1382 getOtherOp(OtherOps op, Signedness Sign) {
1384 default : assert(0 && "Invalid OldOtherOps");
1385 case PHIOp : return Instruction::PHI;
1386 case CallOp : return Instruction::Call;
1387 case ShlOp : return Instruction::Shl;
1390 return Instruction::AShr;
1391 return Instruction::LShr;
1392 case SelectOp : return Instruction::Select;
1393 case UserOp1 : return Instruction::UserOp1;
1394 case UserOp2 : return Instruction::UserOp2;
1395 case VAArg : return Instruction::VAArg;
1396 case ExtractElementOp : return Instruction::ExtractElement;
1397 case InsertElementOp : return Instruction::InsertElement;
1398 case ShuffleVectorOp : return Instruction::ShuffleVector;
1399 case ICmpOp : return Instruction::ICmp;
1400 case FCmpOp : return Instruction::FCmp;
1401 case LShrOp : return Instruction::LShr;
1402 case AShrOp : return Instruction::AShr;
1406 static inline Value*
1407 getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1408 Signedness DstSign, bool ForceInstruction = false) {
1409 Instruction::CastOps Opcode;
1410 const Type* SrcTy = Src->getType();
1412 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1413 // fp -> ptr cast is no longer supported but we must upgrade this
1414 // by doing a double cast: fp -> int -> ptr
1415 SrcTy = Type::Int64Ty;
1416 Opcode = Instruction::IntToPtr;
1417 if (isa<Constant>(Src)) {
1418 Src = ConstantExpr::getCast(Instruction::FPToUI,
1419 cast<Constant>(Src), SrcTy);
1421 std::string NewName(makeNameUnique(Src->getName()));
1422 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1424 } else if (isa<IntegerType>(DstTy) &&
1425 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1426 // cast type %x to bool was previously defined as setne type %x, null
1427 // The cast semantic is now to truncate, not compare so we must retain
1428 // the original intent by replacing the cast with a setne
1429 Constant* Null = Constant::getNullValue(SrcTy);
1430 Instruction::OtherOps Opcode = Instruction::ICmp;
1431 unsigned short predicate = ICmpInst::ICMP_NE;
1432 if (SrcTy->isFloatingPoint()) {
1433 Opcode = Instruction::FCmp;
1434 predicate = FCmpInst::FCMP_ONE;
1435 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1436 error("Invalid cast to bool");
1438 if (isa<Constant>(Src) && !ForceInstruction)
1439 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1441 return CmpInst::create(Opcode, predicate, Src, Null);
1443 // Determine the opcode to use by calling CastInst::getCastOpcode
1445 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1447 } else switch (op) {
1448 default: assert(0 && "Invalid cast token");
1449 case TruncOp: Opcode = Instruction::Trunc; break;
1450 case ZExtOp: Opcode = Instruction::ZExt; break;
1451 case SExtOp: Opcode = Instruction::SExt; break;
1452 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1453 case FPExtOp: Opcode = Instruction::FPExt; break;
1454 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1455 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1456 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1457 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1458 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1459 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1460 case BitCastOp: Opcode = Instruction::BitCast; break;
1463 if (isa<Constant>(Src) && !ForceInstruction)
1464 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1465 return CastInst::create(Opcode, Src, DstTy);
1468 static Instruction *
1469 upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1470 std::vector<Value*>& Args) {
1472 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1473 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1474 if (Args.size() != 2)
1475 error("Invalid prototype for " + Name + " prototype");
1476 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1478 static unsigned upgradeCount = 1;
1479 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1480 std::vector<const Type*> Params;
1481 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1482 if (Args.size() != 1)
1483 error("Invalid prototype for " + Name + " prototype");
1484 Params.push_back(PtrTy);
1485 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1486 const PointerType *PFTy = PointerType::get(FTy);
1487 Value* Func = getVal(PFTy, ID);
1488 std::string InstName("va_upgrade");
1489 InstName += llvm::utostr(upgradeCount++);
1490 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1491 return new CallInst(Func, Args);
1492 } else if (Name == "llvm.va_copy") {
1493 if (Args.size() != 2)
1494 error("Invalid prototype for " + Name + " prototype");
1495 Params.push_back(PtrTy);
1496 Params.push_back(PtrTy);
1497 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1498 const PointerType *PFTy = PointerType::get(FTy);
1499 Value* Func = getVal(PFTy, ID);
1500 std::string InstName0("va_upgrade");
1501 InstName0 += llvm::utostr(upgradeCount++);
1502 std::string InstName1("va_upgrade");
1503 InstName1 += llvm::utostr(upgradeCount++);
1504 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1505 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1506 return new CallInst(Func, Args);
1512 const Type* upgradeGEPIndices(const Type* PTy,
1513 std::vector<ValueInfo> *Indices,
1514 std::vector<Value*> &VIndices,
1515 std::vector<Constant*> *CIndices = 0) {
1516 // Traverse the indices with a gep_type_iterator so we can build the list
1517 // of constant and value indices for use later. Also perform upgrades
1519 if (CIndices) CIndices->clear();
1520 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1521 VIndices.push_back((*Indices)[i].V);
1522 generic_gep_type_iterator<std::vector<Value*>::iterator>
1523 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1524 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1525 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1526 Value *Index = VIndices[i];
1527 if (CIndices && !isa<Constant>(Index))
1528 error("Indices to constant getelementptr must be constants");
1529 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1530 // struct indices to i32 struct indices with ZExt for compatibility.
1531 else if (isa<StructType>(*GTI)) { // Only change struct indices
1532 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1533 if (CUI->getType()->getBitWidth() == 8)
1535 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1537 // Make sure that unsigned SequentialType indices are zext'd to
1538 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1539 // all indices for SequentialType elements. We must retain the same
1540 // semantic (zext) for unsigned types.
1541 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
1542 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
1544 Index = ConstantExpr::getCast(Instruction::ZExt,
1545 cast<Constant>(Index), Type::Int64Ty);
1547 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1548 makeNameUnique("gep_upgrade"), CurBB);
1549 VIndices[i] = Index;
1552 // Add to the CIndices list, if requested.
1554 CIndices->push_back(cast<Constant>(Index));
1558 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1560 error("Index list invalid for constant getelementptr");
1564 Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1565 bool debug, bool addAttrs)
1568 CurFilename = infile;
1571 AddAttributes = addAttrs;
1572 ObsoleteVarArgs = false;
1575 CurModule.CurrentModule = new Module(CurFilename);
1577 // Check to make sure the parser succeeded
1580 delete ParserResult;
1581 std::cerr << "llvm-upgrade: parse failed.\n";
1585 // Check to make sure that parsing produced a result
1586 if (!ParserResult) {
1587 std::cerr << "llvm-upgrade: no parse result.\n";
1591 // Reset ParserResult variable while saving its value for the result.
1592 Module *Result = ParserResult;
1595 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1598 if ((F = Result->getNamedFunction("llvm.va_start"))
1599 && F->getFunctionType()->getNumParams() == 0)
1600 ObsoleteVarArgs = true;
1601 if((F = Result->getNamedFunction("llvm.va_copy"))
1602 && F->getFunctionType()->getNumParams() == 1)
1603 ObsoleteVarArgs = true;
1606 if (ObsoleteVarArgs && NewVarArgs) {
1607 error("This file is corrupt: it uses both new and old style varargs");
1611 if(ObsoleteVarArgs) {
1612 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1613 if (F->arg_size() != 0) {
1614 error("Obsolete va_start takes 0 argument");
1620 //bar = alloca typeof(foo)
1624 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1625 const Type* ArgTy = F->getFunctionType()->getReturnType();
1626 const Type* ArgTyPtr = PointerType::get(ArgTy);
1627 Function* NF = cast<Function>(Result->getOrInsertFunction(
1628 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1630 while (!F->use_empty()) {
1631 CallInst* CI = cast<CallInst>(F->use_back());
1632 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1633 new CallInst(NF, bar, "", CI);
1634 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1635 CI->replaceAllUsesWith(foo);
1636 CI->getParent()->getInstList().erase(CI);
1638 Result->getFunctionList().erase(F);
1641 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1642 if(F->arg_size() != 1) {
1643 error("Obsolete va_end takes 1 argument");
1649 //bar = alloca 1 of typeof(foo)
1651 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1652 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1653 const Type* ArgTyPtr = PointerType::get(ArgTy);
1654 Function* NF = cast<Function>(Result->getOrInsertFunction(
1655 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
1657 while (!F->use_empty()) {
1658 CallInst* CI = cast<CallInst>(F->use_back());
1659 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1660 new StoreInst(CI->getOperand(1), bar, CI);
1661 new CallInst(NF, bar, "", CI);
1662 CI->getParent()->getInstList().erase(CI);
1664 Result->getFunctionList().erase(F);
1667 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1668 if(F->arg_size() != 1) {
1669 error("Obsolete va_copy takes 1 argument");
1674 //a = alloca 1 of typeof(foo)
1675 //b = alloca 1 of typeof(foo)
1680 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1681 const Type* ArgTy = F->getFunctionType()->getReturnType();
1682 const Type* ArgTyPtr = PointerType::get(ArgTy);
1683 Function* NF = cast<Function>(Result->getOrInsertFunction(
1684 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
1686 while (!F->use_empty()) {
1687 CallInst* CI = cast<CallInst>(F->use_back());
1688 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1689 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1690 new StoreInst(CI->getOperand(1), b, CI);
1691 new CallInst(NF, a, b, "", CI);
1692 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1693 CI->replaceAllUsesWith(foo);
1694 CI->getParent()->getInstList().erase(CI);
1696 Result->getFunctionList().erase(F);
1703 } // end llvm namespace
1705 using namespace llvm;
1709 /* Enabling traces. */
1714 /* Enabling verbose error messages. */
1715 #ifdef YYERROR_VERBOSE
1716 # undef YYERROR_VERBOSE
1717 # define YYERROR_VERBOSE 1
1719 # define YYERROR_VERBOSE 0
1722 /* Enabling the token table. */
1723 #ifndef YYTOKEN_TABLE
1724 # define YYTOKEN_TABLE 0
1727 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1728 typedef union YYSTYPE
1729 #line 1339 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
1731 llvm::Module *ModuleVal;
1732 llvm::Function *FunctionVal;
1733 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1734 llvm::BasicBlock *BasicBlockVal;
1735 llvm::TerminatorInst *TermInstVal;
1736 llvm::InstrInfo InstVal;
1737 llvm::ConstInfo ConstVal;
1738 llvm::ValueInfo ValueVal;
1739 llvm::PATypeInfo TypeVal;
1740 llvm::TypeInfo PrimType;
1741 llvm::PHIListInfo PHIList;
1742 std::list<llvm::PATypeInfo> *TypeList;
1743 std::vector<llvm::ValueInfo> *ValueList;
1744 std::vector<llvm::ConstInfo> *ConstVector;
1747 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1748 // Represent the RHS of PHI node
1749 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1751 llvm::GlobalValue::LinkageTypes Linkage;
1759 char *StrVal; // This memory is strdup'd!
1760 llvm::ValID ValIDVal; // strdup'd memory maybe!
1762 llvm::BinaryOps BinaryOpVal;
1763 llvm::TermOps TermOpVal;
1764 llvm::MemoryOps MemOpVal;
1765 llvm::OtherOps OtherOpVal;
1766 llvm::CastOps CastOpVal;
1767 llvm::ICmpInst::Predicate IPred;
1768 llvm::FCmpInst::Predicate FPred;
1769 llvm::Module::Endianness Endianness;
1771 /* Line 187 of yacc.c. */
1772 #line 1773 "UpgradeParser.tab.c"
1774 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1775 # define YYSTYPE_IS_DECLARED 1
1776 # define YYSTYPE_IS_TRIVIAL 1
1781 /* Copy the second part of user declarations. */
1784 /* Line 216 of yacc.c. */
1785 #line 1786 "UpgradeParser.tab.c"
1792 typedef YYTYPE_UINT8 yytype_uint8;
1794 typedef unsigned char yytype_uint8;
1798 typedef YYTYPE_INT8 yytype_int8;
1799 #elif (defined __STDC__ || defined __C99__FUNC__ \
1800 || defined __cplusplus || defined _MSC_VER)
1801 typedef signed char yytype_int8;
1803 typedef short int yytype_int8;
1806 #ifdef YYTYPE_UINT16
1807 typedef YYTYPE_UINT16 yytype_uint16;
1809 typedef unsigned short int yytype_uint16;
1813 typedef YYTYPE_INT16 yytype_int16;
1815 typedef short int yytype_int16;
1819 # ifdef __SIZE_TYPE__
1820 # define YYSIZE_T __SIZE_TYPE__
1821 # elif defined size_t
1822 # define YYSIZE_T size_t
1823 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1824 || defined __cplusplus || defined _MSC_VER)
1825 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1826 # define YYSIZE_T size_t
1828 # define YYSIZE_T unsigned int
1832 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1837 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1838 # define YY_(msgid) dgettext ("bison-runtime", msgid)
1842 # define YY_(msgid) msgid
1846 /* Suppress unused-variable warnings by "using" E. */
1847 #if ! defined lint || defined __GNUC__
1848 # define YYUSE(e) ((void) (e))
1850 # define YYUSE(e) /* empty */
1853 /* Identity function, used to suppress warnings about constant conditions. */
1855 # define YYID(n) (n)
1857 #if (defined __STDC__ || defined __C99__FUNC__ \
1858 || defined __cplusplus || defined _MSC_VER)
1871 #if ! defined yyoverflow || YYERROR_VERBOSE
1873 /* The parser invokes alloca or malloc; define the necessary symbols. */
1875 # ifdef YYSTACK_USE_ALLOCA
1876 # if YYSTACK_USE_ALLOCA
1878 # define YYSTACK_ALLOC __builtin_alloca
1879 # elif defined __BUILTIN_VA_ARG_INCR
1880 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1882 # define YYSTACK_ALLOC __alloca
1883 # elif defined _MSC_VER
1884 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1885 # define alloca _alloca
1887 # define YYSTACK_ALLOC alloca
1888 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1889 || defined __cplusplus || defined _MSC_VER)
1890 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1892 # define _STDLIB_H 1
1899 # ifdef YYSTACK_ALLOC
1900 /* Pacify GCC's `empty if-body' warning. */
1901 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1902 # ifndef YYSTACK_ALLOC_MAXIMUM
1903 /* The OS might guarantee only one guard page at the bottom of the stack,
1904 and a page size can be as small as 4096 bytes. So we cannot safely
1905 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1906 to allow for a few compiler-allocated temporary stack slots. */
1907 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1910 # define YYSTACK_ALLOC YYMALLOC
1911 # define YYSTACK_FREE YYFREE
1912 # ifndef YYSTACK_ALLOC_MAXIMUM
1913 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1915 # if (defined __cplusplus && ! defined _STDLIB_H \
1916 && ! ((defined YYMALLOC || defined malloc) \
1917 && (defined YYFREE || defined free)))
1918 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1920 # define _STDLIB_H 1
1924 # define YYMALLOC malloc
1925 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1926 || defined __cplusplus || defined _MSC_VER)
1927 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1931 # define YYFREE free
1932 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1933 || defined __cplusplus || defined _MSC_VER)
1934 void free (void *); /* INFRINGES ON USER NAME SPACE */
1938 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1941 #if (! defined yyoverflow \
1942 && (! defined __cplusplus \
1943 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1945 /* A type that is properly aligned for any stack member. */
1952 /* The size of the maximum gap between one aligned stack and the next. */
1953 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1955 /* The size of an array large to enough to hold all stacks, each with
1957 # define YYSTACK_BYTES(N) \
1958 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1959 + YYSTACK_GAP_MAXIMUM)
1961 /* Copy COUNT objects from FROM to TO. The source and destination do
1964 # if defined __GNUC__ && 1 < __GNUC__
1965 # define YYCOPY(To, From, Count) \
1966 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1968 # define YYCOPY(To, From, Count) \
1972 for (yyi = 0; yyi < (Count); yyi++) \
1973 (To)[yyi] = (From)[yyi]; \
1979 /* Relocate STACK from its old location to the new one. The
1980 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1981 elements in the stack, and YYPTR gives the new location of the
1982 stack. Advance YYPTR to a properly aligned location for the next
1984 # define YYSTACK_RELOCATE(Stack) \
1987 YYSIZE_T yynewbytes; \
1988 YYCOPY (&yyptr->Stack, Stack, yysize); \
1989 Stack = &yyptr->Stack; \
1990 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1991 yyptr += yynewbytes / sizeof (*yyptr); \
1997 /* YYFINAL -- State number of the termination state. */
1999 /* YYLAST -- Last index in YYTABLE. */
2002 /* YYNTOKENS -- Number of terminals. */
2003 #define YYNTOKENS 166
2004 /* YYNNTS -- Number of nonterminals. */
2006 /* YYNRULES -- Number of rules. */
2007 #define YYNRULES 308
2008 /* YYNRULES -- Number of states. */
2009 #define YYNSTATES 604
2011 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2012 #define YYUNDEFTOK 2
2013 #define YYMAXUTOK 406
2015 #define YYTRANSLATE(YYX) \
2016 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2018 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2019 static const yytype_uint8 yytranslate[] =
2021 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2022 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2023 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2024 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2025 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2026 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2027 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2028 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2029 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2030 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2031 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2033 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2034 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2035 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2036 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2037 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2038 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2039 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2041 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2042 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2043 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2044 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2045 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2046 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2047 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2048 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2049 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2050 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2051 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2052 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2053 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2054 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2055 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2056 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2057 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2058 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2059 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2060 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2061 145, 146, 147, 148, 149, 150, 151
2065 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2067 static const yytype_uint16 yyprhs[] =
2069 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2070 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2071 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2072 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2073 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2074 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2075 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2076 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2077 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2078 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2079 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2080 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2081 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2082 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2083 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2084 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2085 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2086 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2087 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2088 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2089 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2090 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2091 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2092 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2093 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2094 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2095 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2096 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2097 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2098 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2099 927, 928, 932, 939, 943, 950, 953, 958, 965
2102 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
2103 static const yytype_int16 yyrhs[] =
2105 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2106 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2107 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2108 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2109 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
2110 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2111 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2112 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2113 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2114 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2115 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2116 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2117 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2118 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2119 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2120 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2121 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2122 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2123 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2124 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2125 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2126 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2127 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2128 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2129 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2130 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2131 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2132 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2133 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2134 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2135 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2136 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2137 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2138 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2139 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2140 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2141 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2142 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2143 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2144 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2145 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2146 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2147 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2148 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2149 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2150 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2151 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2152 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2153 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2154 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2155 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2156 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2157 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2158 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2159 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2160 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2161 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2162 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2163 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2164 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2165 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2166 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2167 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2168 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2169 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2170 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2171 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2172 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2173 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2174 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2175 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2176 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2177 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2178 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2179 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2180 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2181 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2182 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2183 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2184 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2185 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2186 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2187 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2188 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2189 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2190 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2191 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2192 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2193 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2194 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2195 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2196 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2197 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2198 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2199 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2200 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2201 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
2204 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2205 static const yytype_uint16 yyrline[] =
2207 0, 1479, 1479, 1480, 1488, 1489, 1499, 1499, 1499, 1499,
2208 1499, 1499, 1499, 1499, 1499, 1499, 1499, 1503, 1503, 1503,
2209 1507, 1507, 1507, 1507, 1507, 1507, 1511, 1511, 1512, 1512,
2210 1513, 1513, 1514, 1514, 1515, 1515, 1519, 1519, 1520, 1520,
2211 1521, 1521, 1522, 1522, 1523, 1523, 1524, 1524, 1525, 1525,
2212 1526, 1527, 1530, 1530, 1530, 1530, 1534, 1534, 1534, 1534,
2213 1534, 1534, 1534, 1535, 1535, 1535, 1535, 1535, 1535, 1541,
2214 1541, 1541, 1541, 1545, 1545, 1545, 1545, 1549, 1549, 1553,
2215 1553, 1558, 1561, 1566, 1567, 1568, 1569, 1570, 1571, 1572,
2216 1573, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1594,
2217 1595, 1603, 1604, 1612, 1621, 1622, 1629, 1630, 1634, 1638,
2218 1654, 1655, 1662, 1663, 1670, 1678, 1678, 1678, 1678, 1678,
2219 1678, 1678, 1679, 1679, 1679, 1679, 1679, 1684, 1688, 1692,
2220 1697, 1706, 1722, 1728, 1741, 1750, 1754, 1765, 1769, 1782,
2221 1786, 1793, 1794, 1800, 1807, 1819, 1849, 1862, 1885, 1913,
2222 1935, 1946, 1968, 1979, 1988, 1993, 2051, 2058, 2066, 2073,
2223 2080, 2084, 2088, 2097, 2112, 2125, 2134, 2162, 2175, 2184,
2224 2190, 2196, 2205, 2211, 2217, 2228, 2229, 2238, 2239, 2251,
2225 2260, 2261, 2262, 2263, 2264, 2280, 2300, 2302, 2304, 2304,
2226 2311, 2311, 2318, 2318, 2325, 2325, 2333, 2335, 2337, 2342,
2227 2356, 2357, 2361, 2364, 2372, 2376, 2383, 2387, 2391, 2395,
2228 2403, 2403, 2407, 2408, 2412, 2420, 2425, 2433, 2434, 2441,
2229 2448, 2452, 2558, 2558, 2562, 2572, 2572, 2576, 2580, 2582,
2230 2583, 2587, 2587, 2599, 2600, 2605, 2606, 2607, 2608, 2609,
2231 2610, 2611, 2612, 2613, 2634, 2637, 2652, 2653, 2658, 2658,
2232 2666, 2675, 2678, 2687, 2697, 2702, 2711, 2722, 2722, 2725,
2233 2728, 2731, 2735, 2741, 2756, 2762, 2813, 2816, 2822, 2832,
2234 2845, 2874, 2882, 2890, 2894, 2901, 2902, 2906, 2909, 2915,
2235 2932, 2948, 2962, 2974, 2986, 2997, 3006, 3015, 3024, 3031,
2236 3052, 3076, 3082, 3088, 3094, 3110, 3183, 3191, 3192, 3196,
2237 3197, 3201, 3207, 3213, 3219, 3225, 3232, 3244, 3258
2241 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2242 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2243 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2244 static const char *const yytname[] =
2246 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2247 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2248 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2249 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2250 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2251 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2252 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2253 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2254 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2255 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2256 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2257 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2258 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2259 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2260 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2261 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2262 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2263 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2264 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2265 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2266 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2267 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2268 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2269 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2270 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2271 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2272 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2273 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2274 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2275 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2276 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2277 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2278 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2279 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2280 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2281 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2282 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2283 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2284 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2285 "OptVolatile", "MemoryInst", 0
2290 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2292 static const yytype_uint16 yytoknum[] =
2294 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2295 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2296 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2297 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2298 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2299 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2300 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2301 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2302 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2303 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2304 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2305 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2306 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2307 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2308 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2309 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2310 60, 62, 123, 125, 42, 99
2314 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2315 static const yytype_uint8 yyr1[] =
2317 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2318 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2319 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2320 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2321 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2322 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2323 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2324 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2325 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2326 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2327 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2328 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2329 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2330 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2331 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2332 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2333 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2334 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2335 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2336 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2337 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2338 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2339 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2340 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2341 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2342 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2343 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2344 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2345 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2346 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2347 243, 244, 244, 244, 244, 244, 244, 244, 244
2350 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2351 static const yytype_uint8 yyr2[] =
2353 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2356 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2357 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2358 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2359 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2360 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2361 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2362 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2363 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2364 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2365 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2366 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2367 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2368 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2369 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2370 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2371 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2372 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2373 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2374 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2375 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2376 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2377 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2378 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2379 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2380 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2381 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2382 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2383 0, 3, 6, 3, 6, 2, 4, 6, 4
2386 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2387 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2388 means the default is an error. */
2389 static const yytype_uint16 yydefact[] =
2391 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2392 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2393 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2394 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2395 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2396 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2397 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2398 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2399 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2400 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2401 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2402 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2403 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2404 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2405 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2406 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2407 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2408 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2409 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2410 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2411 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2412 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2413 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2414 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2415 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2416 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2417 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2418 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2419 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
2420 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2421 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2422 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
2423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2424 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2425 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2426 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2427 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2428 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2429 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2430 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2431 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2432 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2433 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2434 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2435 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2436 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2437 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2438 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2439 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2440 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2441 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2442 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2443 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2444 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2445 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2446 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2447 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2448 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2449 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2450 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2454 /* YYDEFGOTO[NTERM-NUM]. */
2455 static const yytype_int16 yydefgoto[] =
2457 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2458 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2459 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2460 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2461 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2462 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2463 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2464 97, 286, 526, 527, 193, 194, 436, 195, 196
2467 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2469 #define YYPACT_NINF -508
2470 static const yytype_int16 yypact[] =
2472 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2473 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2474 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2475 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2476 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2477 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2478 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2479 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2480 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2481 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2482 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2483 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2484 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2485 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2486 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2487 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2488 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2489 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2490 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2491 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2492 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2493 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2494 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2495 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2496 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2497 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2498 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2499 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2500 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2501 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2502 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2503 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2504 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2505 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2506 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2507 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2508 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2509 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2510 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2511 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2512 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2513 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2514 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2515 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2516 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2517 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2518 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2519 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2520 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2521 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2522 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2523 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2524 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2525 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2526 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2527 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2528 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2529 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2530 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2531 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2532 898, 898, -508, -508
2535 /* YYPGOTO[NTERM-NUM]. */
2536 static const yytype_int16 yypgoto[] =
2538 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2539 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2540 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2541 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2542 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2543 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2544 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2545 -508, -508, 43, -22, -508, -508, 21, -508, -508
2548 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2549 positive, shift that token. If negative, reduce the rule which
2550 number is the opposite. If zero, do what YYDEFACT says.
2551 If YYTABLE_NINF, syntax error. */
2552 #define YYTABLE_NINF -180
2553 static const yytype_int16 yytable[] =
2555 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2556 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2557 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2558 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2559 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2560 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2561 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2562 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2563 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2564 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2565 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2566 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2567 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2568 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2569 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2570 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2571 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2572 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2573 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2574 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2575 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2576 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2577 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2578 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2579 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2580 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2581 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2582 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2583 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2584 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2585 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2586 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2587 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2588 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2589 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2590 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2591 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2592 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2593 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2594 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2595 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2596 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2597 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2598 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2599 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2600 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2601 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2602 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2603 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2604 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2605 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2606 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2607 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2608 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2609 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2610 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2611 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2612 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2613 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2614 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2615 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2616 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2617 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2618 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2619 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2620 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2621 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2622 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2623 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2624 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2625 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2626 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2627 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2628 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2629 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2630 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2631 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2632 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2633 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2634 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2635 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2636 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2637 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2638 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2639 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2640 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2641 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2642 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
2643 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2644 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2645 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2646 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2647 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2648 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2649 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2650 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2651 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2652 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2653 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2654 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2655 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2656 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2657 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2658 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2659 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2660 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2661 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2662 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2663 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2664 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2665 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2666 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2667 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2668 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2669 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2670 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2671 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2672 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2673 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2674 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2675 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2676 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2677 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2678 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2679 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2680 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2681 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2682 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2683 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2684 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2685 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2686 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2687 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2688 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2689 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2690 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2691 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2692 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2693 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2694 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2695 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2696 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2697 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2698 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2699 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2700 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2701 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2702 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2703 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2704 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2706 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2707 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2708 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2709 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2710 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2711 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2712 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2713 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2714 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
2715 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2716 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2717 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2718 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2719 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2720 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2721 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2722 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2723 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2724 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2725 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2729 static const yytype_int16 yycheck[] =
2731 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2732 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2733 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2734 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2735 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2736 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2737 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2738 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2739 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2740 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2741 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2742 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2743 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2744 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2745 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2746 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2747 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2748 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2749 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2750 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2751 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2752 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2753 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2754 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2755 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2756 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2757 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2758 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2759 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2760 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2761 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2762 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2763 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2764 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2765 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2766 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2767 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2768 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2769 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2770 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2771 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2772 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2773 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2774 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2775 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2776 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2777 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2778 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2779 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2780 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2781 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2782 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
2783 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
2784 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2785 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2786 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2787 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2788 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2789 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2790 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2791 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2792 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2793 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2794 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2795 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2796 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2797 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2798 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2799 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2800 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2801 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2802 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2803 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2804 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2805 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2806 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2807 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2808 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2809 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2810 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2811 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2812 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2813 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2814 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2815 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2816 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2817 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2818 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2819 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2820 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2821 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2822 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2823 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2824 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2825 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2826 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2827 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2828 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2829 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2830 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2831 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2832 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2833 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2834 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2835 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2836 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2837 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2838 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2839 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2840 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2841 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2842 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2843 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2844 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2845 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2846 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2847 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2848 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2849 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2850 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2851 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2852 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2853 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2854 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2855 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2856 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2857 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2858 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2859 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2860 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2861 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2862 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2863 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2864 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2865 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2866 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2867 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2868 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2869 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2870 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2871 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2872 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2873 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2874 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2875 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2876 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2877 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2878 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2879 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2880 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2881 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2882 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2883 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2884 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2885 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2886 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2887 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2888 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2889 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2890 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2891 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2892 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2893 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2894 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2895 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2896 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2897 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2898 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2899 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2900 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2901 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2905 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2906 symbol of state STATE-NUM. */
2907 static const yytype_uint8 yystos[] =
2909 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2910 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2911 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2912 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2913 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2914 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2915 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2916 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2917 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2918 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2919 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2920 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2921 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2922 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2923 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2924 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2925 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2926 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2927 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2928 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2929 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2930 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2931 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2932 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2933 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2934 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2935 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2936 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2937 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2938 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2939 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2940 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2941 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2942 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2943 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2944 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2945 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2946 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2947 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2948 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2949 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2950 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2951 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2952 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2953 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2954 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2955 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2956 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2957 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2958 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2959 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2960 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2961 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2962 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2963 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2964 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2965 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2966 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2967 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2968 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2972 #define yyerrok (yyerrstatus = 0)
2973 #define yyclearin (yychar = YYEMPTY)
2974 #define YYEMPTY (-2)
2977 #define YYACCEPT goto yyacceptlab
2978 #define YYABORT goto yyabortlab
2979 #define YYERROR goto yyerrorlab
2982 /* Like YYERROR except do call yyerror. This remains here temporarily
2983 to ease the transition to the new meaning of YYERROR, for GCC.
2984 Once GCC version 2 has supplanted version 1, this can go. */
2986 #define YYFAIL goto yyerrlab
2988 #define YYRECOVERING() (!!yyerrstatus)
2990 #define YYBACKUP(Token, Value) \
2992 if (yychar == YYEMPTY && yylen == 1) \
2996 yytoken = YYTRANSLATE (yychar); \
3002 yyerror (YY_("syntax error: cannot back up")); \
3009 #define YYERRCODE 256
3012 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3013 If N is 0, then set CURRENT to the empty location which ends
3014 the previous symbol: RHS[0] (always defined). */
3016 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
3017 #ifndef YYLLOC_DEFAULT
3018 # define YYLLOC_DEFAULT(Current, Rhs, N) \
3022 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3023 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3024 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3025 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3029 (Current).first_line = (Current).last_line = \
3030 YYRHSLOC (Rhs, 0).last_line; \
3031 (Current).first_column = (Current).last_column = \
3032 YYRHSLOC (Rhs, 0).last_column; \
3038 /* YY_LOCATION_PRINT -- Print the location on the stream.
3039 This macro was not mandated originally: define only if we know
3040 we won't break user code: when these are the locations we know. */
3042 #ifndef YY_LOCATION_PRINT
3043 # if YYLTYPE_IS_TRIVIAL
3044 # define YY_LOCATION_PRINT(File, Loc) \
3045 fprintf (File, "%d.%d-%d.%d", \
3046 (Loc).first_line, (Loc).first_column, \
3047 (Loc).last_line, (Loc).last_column)
3049 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3054 /* YYLEX -- calling `yylex' with the right arguments. */
3057 # define YYLEX yylex (YYLEX_PARAM)
3059 # define YYLEX yylex ()
3062 /* Enable debugging if requested. */
3066 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3067 # define YYFPRINTF fprintf
3070 # define YYDPRINTF(Args) \
3076 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3080 YYFPRINTF (stderr, "%s ", Title); \
3081 yy_symbol_print (stderr, \
3083 YYFPRINTF (stderr, "\n"); \
3088 /*--------------------------------.
3089 | Print this symbol on YYOUTPUT. |
3090 `--------------------------------*/
3093 #if (defined __STDC__ || defined __C99__FUNC__ \
3094 || defined __cplusplus || defined _MSC_VER)
3096 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3099 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
3102 YYSTYPE const * const yyvaluep;
3108 if (yytype < YYNTOKENS)
3109 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3121 /*--------------------------------.
3122 | Print this symbol on YYOUTPUT. |
3123 `--------------------------------*/
3125 #if (defined __STDC__ || defined __C99__FUNC__ \
3126 || defined __cplusplus || defined _MSC_VER)
3128 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3131 yy_symbol_print (yyoutput, yytype, yyvaluep)
3134 YYSTYPE const * const yyvaluep;
3137 if (yytype < YYNTOKENS)
3138 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3140 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3142 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3143 YYFPRINTF (yyoutput, ")");
3146 /*------------------------------------------------------------------.
3147 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
3149 `------------------------------------------------------------------*/
3151 #if (defined __STDC__ || defined __C99__FUNC__ \
3152 || defined __cplusplus || defined _MSC_VER)
3154 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3157 yy_stack_print (bottom, top)
3158 yytype_int16 *bottom;
3162 YYFPRINTF (stderr, "Stack now");
3163 for (; bottom <= top; ++bottom)
3164 YYFPRINTF (stderr, " %d", *bottom);
3165 YYFPRINTF (stderr, "\n");
3168 # define YY_STACK_PRINT(Bottom, Top) \
3171 yy_stack_print ((Bottom), (Top)); \
3175 /*------------------------------------------------.
3176 | Report that the YYRULE is going to be reduced. |
3177 `------------------------------------------------*/
3179 #if (defined __STDC__ || defined __C99__FUNC__ \
3180 || defined __cplusplus || defined _MSC_VER)
3182 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3185 yy_reduce_print (yyvsp, yyrule)
3190 int yynrhs = yyr2[yyrule];
3192 unsigned long int yylno = yyrline[yyrule];
3193 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3195 /* The symbols being reduced. */
3196 for (yyi = 0; yyi < yynrhs; yyi++)
3198 fprintf (stderr, " $%d = ", yyi + 1);
3199 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3200 &(yyvsp[(yyi + 1) - (yynrhs)])
3202 fprintf (stderr, "\n");
3206 # define YY_REDUCE_PRINT(Rule) \
3209 yy_reduce_print (yyvsp, Rule); \
3212 /* Nonzero means print parse trace. It is left uninitialized so that
3213 multiple parsers can coexist. */
3215 #else /* !YYDEBUG */
3216 # define YYDPRINTF(Args)
3217 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3218 # define YY_STACK_PRINT(Bottom, Top)
3219 # define YY_REDUCE_PRINT(Rule)
3220 #endif /* !YYDEBUG */
3223 /* YYINITDEPTH -- initial size of the parser's stacks. */
3225 # define YYINITDEPTH 200
3228 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3229 if the built-in stack extension method is used).
3231 Do not make this value too large; the results are undefined if
3232 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3233 evaluated with infinite-precision integer arithmetic. */
3236 # define YYMAXDEPTH 10000
3244 # if defined __GLIBC__ && defined _STRING_H
3245 # define yystrlen strlen
3247 /* Return the length of YYSTR. */
3248 #if (defined __STDC__ || defined __C99__FUNC__ \
3249 || defined __cplusplus || defined _MSC_VER)
3251 yystrlen (const char *yystr)
3259 for (yylen = 0; yystr[yylen]; yylen++)
3267 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3268 # define yystpcpy stpcpy
3270 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3272 #if (defined __STDC__ || defined __C99__FUNC__ \
3273 || defined __cplusplus || defined _MSC_VER)
3275 yystpcpy (char *yydest, const char *yysrc)
3278 yystpcpy (yydest, yysrc)
3284 const char *yys = yysrc;
3286 while ((*yyd++ = *yys++) != '\0')
3295 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3296 quotes and backslashes, so that it's suitable for yyerror. The
3297 heuristic is that double-quoting is unnecessary unless the string
3298 contains an apostrophe, a comma, or backslash (other than
3299 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3300 null, do not copy; instead, return the length of what the result
3303 yytnamerr (char *yyres, const char *yystr)
3308 char const *yyp = yystr;
3315 goto do_not_strip_quotes;
3319 goto do_not_strip_quotes;
3332 do_not_strip_quotes: ;
3336 return yystrlen (yystr);
3338 return yystpcpy (yyres, yystr) - yyres;
3342 /* Copy into YYRESULT an error message about the unexpected token
3343 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3344 including the terminating null byte. If YYRESULT is null, do not
3345 copy anything; just return the number of bytes that would be
3346 copied. As a special case, return 0 if an ordinary "syntax error"
3347 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3348 size calculation. */
3350 yysyntax_error (char *yyresult, int yystate, int yychar)
3352 int yyn = yypact[yystate];
3354 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3358 int yytype = YYTRANSLATE (yychar);
3359 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3360 YYSIZE_T yysize = yysize0;
3362 int yysize_overflow = 0;
3363 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3364 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3368 /* This is so xgettext sees the translatable formats that are
3369 constructed on the fly. */
3370 YY_("syntax error, unexpected %s");
3371 YY_("syntax error, unexpected %s, expecting %s");
3372 YY_("syntax error, unexpected %s, expecting %s or %s");
3373 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3374 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3378 static char const yyunexpected[] = "syntax error, unexpected %s";
3379 static char const yyexpecting[] = ", expecting %s";
3380 static char const yyor[] = " or %s";
3381 char yyformat[sizeof yyunexpected
3382 + sizeof yyexpecting - 1
3383 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3384 * (sizeof yyor - 1))];
3385 char const *yyprefix = yyexpecting;
3387 /* Start YYX at -YYN if negative to avoid negative indexes in
3389 int yyxbegin = yyn < 0 ? -yyn : 0;
3391 /* Stay within bounds of both yycheck and yytname. */
3392 int yychecklim = YYLAST - yyn + 1;
3393 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3396 yyarg[0] = yytname[yytype];
3397 yyfmt = yystpcpy (yyformat, yyunexpected);
3399 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3400 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3402 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3406 yyformat[sizeof yyunexpected - 1] = '\0';
3409 yyarg[yycount++] = yytname[yyx];
3410 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3411 yysize_overflow |= (yysize1 < yysize);
3413 yyfmt = yystpcpy (yyfmt, yyprefix);
3417 yyf = YY_(yyformat);
3418 yysize1 = yysize + yystrlen (yyf);
3419 yysize_overflow |= (yysize1 < yysize);
3422 if (yysize_overflow)
3423 return YYSIZE_MAXIMUM;
3427 /* Avoid sprintf, as that infringes on the user's name space.
3428 Don't have undefined behavior even if the translation
3429 produced a string with the wrong number of "%s"s. */
3430 char *yyp = yyresult;
3432 while ((*yyp = *yyf) != '\0')
3434 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3436 yyp += yytnamerr (yyp, yyarg[yyi++]);
3449 #endif /* YYERROR_VERBOSE */
3452 /*-----------------------------------------------.
3453 | Release the memory associated to this symbol. |
3454 `-----------------------------------------------*/
3457 #if (defined __STDC__ || defined __C99__FUNC__ \
3458 || defined __cplusplus || defined _MSC_VER)
3460 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3463 yydestruct (yymsg, yytype, yyvaluep)
3473 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3484 /* Prevent warnings from -Wmissing-prototypes. */
3486 #ifdef YYPARSE_PARAM
3487 #if defined __STDC__ || defined __cplusplus
3488 int yyparse (void *YYPARSE_PARAM);
3492 #else /* ! YYPARSE_PARAM */
3493 #if defined __STDC__ || defined __cplusplus
3498 #endif /* ! YYPARSE_PARAM */
3502 /* The look-ahead symbol. */
3505 /* The semantic value of the look-ahead symbol. */
3508 /* Number of syntax errors so far. */
3517 #ifdef YYPARSE_PARAM
3518 #if (defined __STDC__ || defined __C99__FUNC__ \
3519 || defined __cplusplus || defined _MSC_VER)
3521 yyparse (void *YYPARSE_PARAM)
3524 yyparse (YYPARSE_PARAM)
3525 void *YYPARSE_PARAM;
3527 #else /* ! YYPARSE_PARAM */
3528 #if (defined __STDC__ || defined __C99__FUNC__ \
3529 || defined __cplusplus || defined _MSC_VER)
3543 /* Number of tokens to shift before error messages enabled. */
3545 /* Look-ahead token as an internal (translated) token number. */
3548 /* Buffer for error messages, and its allocated size. */
3550 char *yymsg = yymsgbuf;
3551 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3554 /* Three stacks and their tools:
3555 `yyss': related to states,
3556 `yyvs': related to semantic values,
3557 `yyls': related to locations.
3559 Refer to the stacks thru separate pointers, to allow yyoverflow
3560 to reallocate them elsewhere. */
3562 /* The state stack. */
3563 yytype_int16 yyssa[YYINITDEPTH];
3564 yytype_int16 *yyss = yyssa;
3565 yytype_int16 *yyssp;
3567 /* The semantic value stack. */
3568 YYSTYPE yyvsa[YYINITDEPTH];
3569 YYSTYPE *yyvs = yyvsa;
3574 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3576 YYSIZE_T yystacksize = YYINITDEPTH;
3578 /* The variables used to return semantic value and location from the
3583 /* The number of symbols on the RHS of the reduced rule.
3584 Keep to zero when no symbol should be popped. */
3587 YYDPRINTF ((stderr, "Starting parse\n"));
3592 yychar = YYEMPTY; /* Cause a token to be read. */
3594 /* Initialize stack pointers.
3595 Waste one element of value and location stack
3596 so that they stay on the same level as the state stack.
3597 The wasted elements are never initialized. */
3604 /*------------------------------------------------------------.
3605 | yynewstate -- Push a new state, which is found in yystate. |
3606 `------------------------------------------------------------*/
3608 /* In all cases, when you get here, the value and location stacks
3609 have just been pushed. So pushing a state here evens the stacks. */
3615 if (yyss + yystacksize - 1 <= yyssp)
3617 /* Get the current used size of the three stacks, in elements. */
3618 YYSIZE_T yysize = yyssp - yyss + 1;
3622 /* Give user a chance to reallocate the stack. Use copies of
3623 these so that the &'s don't force the real ones into
3625 YYSTYPE *yyvs1 = yyvs;
3626 yytype_int16 *yyss1 = yyss;
3629 /* Each stack pointer address is followed by the size of the
3630 data in use in that stack, in bytes. This used to be a
3631 conditional around just the two extra args, but that might
3632 be undefined if yyoverflow is a macro. */
3633 yyoverflow (YY_("memory exhausted"),
3634 &yyss1, yysize * sizeof (*yyssp),
3635 &yyvs1, yysize * sizeof (*yyvsp),
3642 #else /* no yyoverflow */
3643 # ifndef YYSTACK_RELOCATE
3644 goto yyexhaustedlab;
3646 /* Extend the stack our own way. */
3647 if (YYMAXDEPTH <= yystacksize)
3648 goto yyexhaustedlab;
3650 if (YYMAXDEPTH < yystacksize)
3651 yystacksize = YYMAXDEPTH;
3654 yytype_int16 *yyss1 = yyss;
3655 union yyalloc *yyptr =
3656 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3658 goto yyexhaustedlab;
3659 YYSTACK_RELOCATE (yyss);
3660 YYSTACK_RELOCATE (yyvs);
3662 # undef YYSTACK_RELOCATE
3664 YYSTACK_FREE (yyss1);
3667 #endif /* no yyoverflow */
3669 yyssp = yyss + yysize - 1;
3670 yyvsp = yyvs + yysize - 1;
3673 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3674 (unsigned long int) yystacksize));
3676 if (yyss + yystacksize - 1 <= yyssp)
3680 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
3689 /* Do appropriate processing given the current state. Read a
3690 look-ahead token if we need one and don't already have one. */
3692 /* First try to decide what to do without reference to look-ahead token. */
3693 yyn = yypact[yystate];
3694 if (yyn == YYPACT_NINF)
3697 /* Not known => get a look-ahead token if don't already have one. */
3699 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
3700 if (yychar == YYEMPTY)
3702 YYDPRINTF ((stderr, "Reading a token: "));
3706 if (yychar <= YYEOF)
3708 yychar = yytoken = YYEOF;
3709 YYDPRINTF ((stderr, "Now at end of input.\n"));
3713 yytoken = YYTRANSLATE (yychar);
3714 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
3717 /* If the proper action on seeing token YYTOKEN is to reduce or to
3718 detect an error, take that action. */
3720 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
3725 if (yyn == 0 || yyn == YYTABLE_NINF)
3734 /* Count tokens shifted since error; after three, turn off error
3739 /* Shift the look-ahead token. */
3740 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3742 /* Discard the shifted token unless it is eof. */
3743 if (yychar != YYEOF)
3752 /*-----------------------------------------------------------.
3753 | yydefault -- do the default action for the current state. |
3754 `-----------------------------------------------------------*/
3756 yyn = yydefact[yystate];
3762 /*-----------------------------.
3763 | yyreduce -- Do a reduction. |
3764 `-----------------------------*/
3766 /* yyn is the number of a rule to reduce with. */
3769 /* If YYLEN is nonzero, implement the default value of the action:
3772 Otherwise, the following line sets YYVAL to garbage.
3773 This behavior is undocumented and Bison
3774 users should not rely upon it. Assigning to YYVAL
3775 unconditionally makes the parser a bit smaller, and it avoids a
3776 GCC warning that YYVAL may be used uninitialized. */
3777 yyval = yyvsp[1-yylen];
3780 YY_REDUCE_PRINT (yyn);
3784 #line 1480 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3786 if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
3787 error("Value too large for type");
3788 (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
3793 #line 1489 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3795 if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
3796 error("Value too large for type");
3797 (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
3802 #line 1511 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3803 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3807 #line 1511 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3808 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3812 #line 1512 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3813 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3817 #line 1512 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3818 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3822 #line 1513 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3823 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3827 #line 1513 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3828 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3832 #line 1514 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3833 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3837 #line 1514 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3838 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3842 #line 1515 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3843 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3847 #line 1515 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3848 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3852 #line 1519 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3853 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3857 #line 1519 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3858 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3862 #line 1520 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3863 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3867 #line 1520 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3868 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3872 #line 1521 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3873 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3877 #line 1521 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3878 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3882 #line 1522 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3883 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3887 #line 1522 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3888 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3892 #line 1523 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3893 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3897 #line 1523 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3898 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3902 #line 1524 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3903 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3907 #line 1524 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3908 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3912 #line 1525 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3913 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3917 #line 1525 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3918 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3922 #line 1526 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3923 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3927 #line 1527 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3928 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3932 #line 1558 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3934 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
3939 #line 1561 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3946 #line 1566 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3947 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3951 #line 1567 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3952 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3956 #line 1568 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3957 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3961 #line 1569 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3962 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3966 #line 1570 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3967 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3971 #line 1571 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3972 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3976 #line 1572 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3977 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3981 #line 1573 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3982 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3986 #line 1577 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3987 { (yyval.UIntVal) = CallingConv::C; ;}
3991 #line 1578 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3992 { (yyval.UIntVal) = CallingConv::C; ;}
3996 #line 1579 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3997 { (yyval.UIntVal) = CallingConv::C; ;}
4001 #line 1580 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4002 { (yyval.UIntVal) = CallingConv::Fast; ;}
4006 #line 1581 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4007 { (yyval.UIntVal) = CallingConv::Cold; ;}
4011 #line 1582 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4012 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
4016 #line 1583 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4017 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
4021 #line 1584 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4023 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
4024 error("Calling conv too large");
4025 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4030 #line 1594 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4031 { (yyval.UIntVal) = 0; ;}
4035 #line 1595 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4037 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4038 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4039 error("Alignment must be a power of two");
4044 #line 1603 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4045 { (yyval.UIntVal) = 0; ;}
4049 #line 1604 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4051 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4052 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4053 error("Alignment must be a power of two");
4058 #line 1612 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4060 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
4061 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
4062 error("Invalid character in section name");
4063 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4068 #line 1621 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4069 { (yyval.StrVal) = 0; ;}
4073 #line 1622 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4074 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4078 #line 1629 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4083 #line 1630 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4088 #line 1634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4090 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
4091 free((yyvsp[(1) - (1)].StrVal));
4096 #line 1638 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4098 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
4099 error("Alignment must be a power of two");
4100 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
4106 #line 1655 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4108 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4109 (yyval.TypeVal).S = Signless;
4114 #line 1663 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4116 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4117 (yyval.TypeVal).S = Signless;
4122 #line 1670 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4124 if (!UpRefs.empty())
4125 error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).T)->getDescription());
4126 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4131 #line 1684 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4133 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4134 (yyval.TypeVal).S = (yyvsp[(1) - (1)].PrimType).S;
4139 #line 1688 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4141 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4142 (yyval.TypeVal).S = Signless;
4147 #line 1692 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4148 { // Named types are also simple types...
4149 const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
4150 (yyval.TypeVal).T = new PATypeHolder(tmp);
4151 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4156 #line 1697 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4157 { // Type UpReference
4158 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U)
4159 error("Value out of range");
4160 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
4161 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4162 (yyval.TypeVal).T = new PATypeHolder(OT);
4163 (yyval.TypeVal).S = Signless;
4164 UR_OUT("New Upreference!\n");
4169 #line 1706 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4170 { // Function derived type?
4171 std::vector<const Type*> Params;
4172 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
4173 E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
4174 Params.push_back(I->T->get());
4177 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4178 if (isVarArg) Params.pop_back();
4180 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
4181 FunctionType::get((yyvsp[(1) - (4)].TypeVal).T->get(),Params,isVarArg)));
4182 (yyval.TypeVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4183 delete (yyvsp[(1) - (4)].TypeVal).T; // Delete the return type handle
4184 delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list
4189 #line 1722 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4190 { // Sized array type?
4191 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).T->get(),
4192 (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4193 (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4194 delete (yyvsp[(4) - (5)].TypeVal).T;
4199 #line 1728 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4200 { // Packed array type?
4201 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).T->get();
4202 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
4203 error("Unsigned result not equal to signed result");
4204 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4205 error("Elements of a PackedType must be integer or floating point");
4206 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
4207 error("PackedType length should be a power of 2");
4208 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
4209 (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4210 (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4211 delete (yyvsp[(4) - (5)].TypeVal).T;
4216 #line 1741 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4217 { // Structure type?
4218 std::vector<const Type*> Elements;
4219 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4220 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
4221 Elements.push_back(I->T->get());
4222 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4223 (yyval.TypeVal).S = Signless;
4224 delete (yyvsp[(2) - (3)].TypeList);
4229 #line 1750 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4230 { // Empty structure type?
4231 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4232 (yyval.TypeVal).S = Signless;
4237 #line 1754 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4238 { // Packed Structure type?
4239 std::vector<const Type*> Elements;
4240 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4241 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
4242 Elements.push_back(I->T->get());
4245 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4246 (yyval.TypeVal).S = Signless;
4247 delete (yyvsp[(3) - (5)].TypeList);
4252 #line 1765 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4253 { // Empty packed structure type?
4254 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4255 (yyval.TypeVal).S = Signless;
4260 #line 1769 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4262 if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::LabelTy)
4263 error("Cannot form a pointer to a basic block");
4264 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).T->get())));
4265 (yyval.TypeVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4266 delete (yyvsp[(1) - (2)].TypeVal).T;
4271 #line 1782 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4273 (yyval.TypeList) = new std::list<PATypeInfo>();
4274 (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal));
4279 #line 1786 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4281 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
4286 #line 1794 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4289 VoidTI.T = new PATypeHolder(Type::VoidTy);
4290 VoidTI.S = Signless;
4291 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
4296 #line 1800 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4298 (yyval.TypeList) = new std::list<PATypeInfo>();
4300 VoidTI.T = new PATypeHolder(Type::VoidTy);
4301 VoidTI.S = Signless;
4302 (yyval.TypeList)->push_back(VoidTI);
4307 #line 1807 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4309 (yyval.TypeList) = new std::list<PATypeInfo>();
4314 #line 1819 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4315 { // Nonempty unsized arr
4316 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).T->get());
4318 error("Cannot make array constant with type: '" +
4319 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4320 const Type *ETy = ATy->getElementType();
4321 int NumElements = ATy->getNumElements();
4323 // Verify that we have the correct size...
4324 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4325 error("Type mismatch: constant sized array initialized with " +
4326 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
4327 itostr(NumElements) + "");
4329 // Verify all elements are correct type!
4330 std::vector<Constant*> Elems;
4331 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4332 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4333 const Type* ValTy = C->getType();
4335 error("Element #" + utostr(i) + " is not of type '" +
4336 ETy->getDescription() +"' as required!\nIt is of type '"+
4337 ValTy->getDescription() + "'");
4340 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4341 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4342 delete (yyvsp[(1) - (4)].TypeVal).T;
4343 delete (yyvsp[(3) - (4)].ConstVector);
4348 #line 1849 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4350 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
4352 error("Cannot make array constant with type: '" +
4353 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4354 int NumElements = ATy->getNumElements();
4355 if (NumElements != -1 && NumElements != 0)
4356 error("Type mismatch: constant sized array initialized with 0"
4357 " arguments, but has size of " + itostr(NumElements) +"");
4358 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4359 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4360 delete (yyvsp[(1) - (3)].TypeVal).T;
4365 #line 1862 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4367 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
4369 error("Cannot make array constant with type: '" +
4370 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4371 int NumElements = ATy->getNumElements();
4372 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4373 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4374 error("String arrays require type i8, not '" + ETy->getDescription() +
4376 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4377 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
4378 error("Can't build string constant of size " +
4379 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " +
4380 itostr(NumElements) + "");
4381 std::vector<Constant*> Vals;
4382 for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
4383 Vals.push_back(ConstantInt::get(ETy, *C));
4384 free((yyvsp[(3) - (3)].StrVal));
4385 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4386 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4387 delete (yyvsp[(1) - (3)].TypeVal).T;
4392 #line 1885 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4393 { // Nonempty unsized arr
4394 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[(1) - (4)].TypeVal).T->get());
4396 error("Cannot make packed constant with type: '" +
4397 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4398 const Type *ETy = PTy->getElementType();
4399 int NumElements = PTy->getNumElements();
4400 // Verify that we have the correct size...
4401 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4402 error("Type mismatch: constant sized packed initialized with " +
4403 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
4404 itostr(NumElements) + "");
4405 // Verify all elements are correct type!
4406 std::vector<Constant*> Elems;
4407 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4408 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4409 const Type* ValTy = C->getType();
4411 error("Element #" + utostr(i) + " is not of type '" +
4412 ETy->getDescription() +"' as required!\nIt is of type '"+
4413 ValTy->getDescription() + "'");
4416 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
4417 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4418 delete (yyvsp[(1) - (4)].TypeVal).T;
4419 delete (yyvsp[(3) - (4)].ConstVector);
4424 #line 1913 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4426 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).T->get());
4428 error("Cannot make struct constant with type: '" +
4429 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4430 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
4431 error("Illegal number of initializers for structure type");
4433 // Check to ensure that constants are compatible with the type initializer!
4434 std::vector<Constant*> Fields;
4435 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
4436 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4437 if (C->getType() != STy->getElementType(i))
4438 error("Expected type '" + STy->getElementType(i)->getDescription() +
4439 "' for element #" + utostr(i) + " of structure initializer");
4440 Fields.push_back(C);
4442 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4443 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4444 delete (yyvsp[(1) - (4)].TypeVal).T;
4445 delete (yyvsp[(3) - (4)].ConstVector);
4450 #line 1935 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4452 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).T->get());
4454 error("Cannot make struct constant with type: '" +
4455 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4456 if (STy->getNumContainedTypes() != 0)
4457 error("Illegal number of initializers for structure type");
4458 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4459 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4460 delete (yyvsp[(1) - (3)].TypeVal).T;
4465 #line 1946 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4467 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).T->get());
4469 error("Cannot make packed struct constant with type: '" +
4470 (yyvsp[(1) - (6)].TypeVal).T->get()->getDescription() + "'");
4471 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
4472 error("Illegal number of initializers for packed structure type");
4474 // Check to ensure that constants are compatible with the type initializer!
4475 std::vector<Constant*> Fields;
4476 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
4477 Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
4478 if (C->getType() != STy->getElementType(i))
4479 error("Expected type '" + STy->getElementType(i)->getDescription() +
4480 "' for element #" + utostr(i) + " of packed struct initializer");
4481 Fields.push_back(C);
4483 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4484 (yyval.ConstVal).S = (yyvsp[(1) - (6)].TypeVal).S;
4485 delete (yyvsp[(1) - (6)].TypeVal).T;
4486 delete (yyvsp[(4) - (6)].ConstVector);
4491 #line 1968 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4493 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).T->get());
4495 error("Cannot make packed struct constant with type: '" +
4496 (yyvsp[(1) - (5)].TypeVal).T->get()->getDescription() + "'");
4497 if (STy->getNumContainedTypes() != 0)
4498 error("Illegal number of initializers for packed structure type");
4499 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4500 (yyval.ConstVal).S = (yyvsp[(1) - (5)].TypeVal).S;
4501 delete (yyvsp[(1) - (5)].TypeVal).T;
4506 #line 1979 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4508 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
4510 error("Cannot make null pointer constant with type: '" +
4511 (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription() + "'");
4512 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4513 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4514 delete (yyvsp[(1) - (2)].TypeVal).T;
4519 #line 1988 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4521 (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).T->get());
4522 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4523 delete (yyvsp[(1) - (2)].TypeVal).T;
4528 #line 1993 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4530 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
4532 error("Global const reference must be a pointer type, not" +
4533 (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription());
4535 // ConstExprs can exist in the body of a function, thus creating
4536 // GlobalValues whenever they refer to a variable. Because we are in
4537 // the context of a function, getExistingValue will search the functions
4538 // symbol table instead of the module symbol table for the global symbol,
4539 // which throws things all off. To get around this, we just tell
4540 // getExistingValue that we are at global scope here.
4542 Function *SavedCurFn = CurFun.CurrentFunction;
4543 CurFun.CurrentFunction = 0;
4544 Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
4545 CurFun.CurrentFunction = SavedCurFn;
4547 // If this is an initializer for a constant pointer, which is referencing a
4548 // (currently) undefined variable, create a stub now that shall be replaced
4549 // in the future with the right type of variable.
4552 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4553 const PointerType *PT = cast<PointerType>(Ty);
4555 // First check to see if the forward references value is already created!
4556 PerModuleInfo::GlobalRefsType::iterator I =
4557 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
4559 if (I != CurModule.GlobalRefs.end()) {
4560 V = I->second; // Placeholder already exists, use it...
4561 (yyvsp[(2) - (2)].ValIDVal).destroy();
4564 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4566 // Create the forward referenced global.
4568 if (const FunctionType *FTy =
4569 dyn_cast<FunctionType>(PT->getElementType())) {
4570 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4571 CurModule.CurrentModule);
4573 GV = new GlobalVariable(PT->getElementType(), false,
4574 GlobalValue::ExternalLinkage, 0,
4575 Name, CurModule.CurrentModule);
4578 // Keep track of the fact that we have a forward ref to recycle it
4579 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
4583 (yyval.ConstVal).C = cast<GlobalValue>(V);
4584 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4585 delete (yyvsp[(1) - (2)].TypeVal).T; // Free the type handle
4590 #line 2051 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4592 if ((yyvsp[(1) - (2)].TypeVal).T->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
4593 error("Mismatched types for constant expression");
4594 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4595 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4596 delete (yyvsp[(1) - (2)].TypeVal).T;
4601 #line 2058 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4603 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
4604 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4605 error("Cannot create a null initialized value of this type");
4606 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4607 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4608 delete (yyvsp[(1) - (2)].TypeVal).T;
4613 #line 2066 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4614 { // integral constants
4615 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4616 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
4617 error("Constant value doesn't fit in type");
4618 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
4619 (yyval.ConstVal).S = Signed;
4624 #line 2073 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4625 { // integral constants
4626 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4627 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
4628 error("Constant value doesn't fit in type");
4629 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
4630 (yyval.ConstVal).S = Unsigned;
4635 #line 2080 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4636 { // Boolean constants
4637 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4638 (yyval.ConstVal).S = Unsigned;
4643 #line 2084 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4644 { // Boolean constants
4645 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4646 (yyval.ConstVal).S = Unsigned;
4651 #line 2088 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4652 { // Float & Double constants
4653 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal)))
4654 error("Floating point constant invalid for type");
4655 (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal));
4656 (yyval.ConstVal).S = Signless;
4661 #line 2097 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4663 const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
4664 const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).T->get();
4665 Signedness SrcSign = (yyvsp[(3) - (6)].ConstVal).S;
4666 Signedness DstSign = (yyvsp[(5) - (6)].TypeVal).S;
4667 if (!SrcTy->isFirstClassType())
4668 error("cast constant expression from a non-primitive type: '" +
4669 SrcTy->getDescription() + "'");
4670 if (!DstTy->isFirstClassType())
4671 error("cast constant expression to a non-primitive type: '" +
4672 DstTy->getDescription() + "'");
4673 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign));
4674 (yyval.ConstVal).S = DstSign;
4675 delete (yyvsp[(5) - (6)].TypeVal).T;
4680 #line 2112 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4682 const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
4683 if (!isa<PointerType>(Ty))
4684 error("GetElementPtr requires a pointer operand");
4686 std::vector<Value*> VIndices;
4687 std::vector<Constant*> CIndices;
4688 upgradeGEPIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), VIndices, &CIndices);
4690 delete (yyvsp[(4) - (5)].ValueList);
4691 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, CIndices);
4692 (yyval.ConstVal).S = Signless;
4697 #line 2125 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4699 if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
4700 cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
4701 error("Select condition must be bool type");
4702 if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
4703 error("Select operand types must match");
4704 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4705 (yyval.ConstVal).S = Unsigned;
4710 #line 2134 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4712 const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4713 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4714 error("Binary operator types must match");
4715 // First, make sure we're dealing with the right opcode by upgrading from
4716 // obsolete versions.
4717 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
4719 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4720 // To retain backward compatibility with these early compilers, we emit a
4721 // cast to the appropriate integer type automatically if we are in the
4722 // broken case. See PR424 for more information.
4723 if (!isa<PointerType>(Ty)) {
4724 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4726 const Type *IntPtrTy = 0;
4727 switch (CurModule.CurrentModule->getPointerSize()) {
4728 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4729 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4730 default: error("invalid pointer binary constant expr");
4732 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4733 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
4734 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
4735 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4737 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4742 #line 2162 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4744 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4745 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4746 error("Logical operator types must match");
4747 if (!Ty->isInteger()) {
4748 if (!isa<PackedType>(Ty) ||
4749 !cast<PackedType>(Ty)->getElementType()->isInteger())
4750 error("Logical operator requires integer operands");
4752 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
4753 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4754 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4759 #line 2175 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4761 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4762 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4763 error("setcc operand types must match");
4764 unsigned short pred;
4765 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
4766 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4767 (yyval.ConstVal).S = Unsigned;
4772 #line 2184 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4774 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
4775 error("icmp operand types must match");
4776 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
4777 (yyval.ConstVal).S = Unsigned;
4782 #line 2190 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4784 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
4785 error("fcmp operand types must match");
4786 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
4787 (yyval.ConstVal).S = Unsigned;
4792 #line 2196 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4794 if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
4795 cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
4796 error("Shift count for shift constant must be unsigned byte");
4797 if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
4798 error("Shift constant expression requires integer operand");
4799 (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(3) - (6)].ConstVal).S), (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4800 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4805 #line 2205 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4807 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
4808 error("Invalid extractelement operands");
4809 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4810 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4815 #line 2211 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4817 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
4818 error("Invalid insertelement operands");
4819 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4820 (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
4825 #line 2217 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4827 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
4828 error("Invalid shufflevector operands");
4829 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4830 (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
4835 #line 2228 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4836 { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
4840 #line 2229 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4842 (yyval.ConstVector) = new std::vector<ConstInfo>();
4843 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
4848 #line 2238 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4849 { (yyval.BoolVal) = false; ;}
4853 #line 2239 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4854 { (yyval.BoolVal) = true; ;}
4858 #line 2251 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4860 (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
4861 CurModule.ModuleDone();
4866 #line 2260 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4867 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
4871 #line 2261 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4872 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
4876 #line 2262 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4877 { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
4881 #line 2263 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4882 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
4886 #line 2264 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4888 (yyval.ModuleVal) = CurModule.CurrentModule;
4889 // Emit an error if there are any unresolved types left.
4890 if (!CurModule.LateResolveTypes.empty()) {
4891 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4892 if (DID.Type == ValID::NameVal) {
4893 error("Reference to an undefined type: '"+DID.getName() + "'");
4895 error("Reference to an undefined type: #" + itostr(DID.Num));
4902 #line 2280 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4904 // Eagerly resolve types. This is not an optimization, this is a
4905 // requirement that is due to the fact that we could have this:
4907 // %list = type { %list * }
4908 // %list = type { %list * } ; repeated type decl
4910 // If types are not resolved eagerly, then the two types will not be
4911 // determined to be the same type!
4913 const Type* Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
4914 ResolveTypeTo((yyvsp[(2) - (4)].StrVal), Ty);
4916 if (!setTypeName(Ty, (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
4917 // If this is a named type that is not a redefinition, add it to the slot
4919 CurModule.Types.push_back(Ty);
4921 delete (yyvsp[(4) - (4)].TypeVal).T;
4926 #line 2300 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4927 { // Function prototypes can be in const pool
4932 #line 2302 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4933 { // Asm blocks can be in the const pool
4938 #line 2304 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4940 if ((yyvsp[(5) - (5)].ConstVal).C == 0)
4941 error("Global value initializer is not a constant");
4942 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), (yyvsp[(3) - (5)].Linkage), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal).C->getType(), (yyvsp[(5) - (5)].ConstVal).C);
4947 #line 2308 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4954 #line 2311 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4956 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
4957 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4958 delete (yyvsp[(5) - (5)].TypeVal).T;
4963 #line 2315 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4970 #line 2318 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4972 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
4973 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4974 delete (yyvsp[(5) - (5)].TypeVal).T;
4979 #line 2322 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4986 #line 2325 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4988 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
4990 ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4991 delete (yyvsp[(5) - (5)].TypeVal).T;
4996 #line 2330 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5003 #line 2333 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5009 #line 2335 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5015 #line 2337 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5021 #line 2342 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5023 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5024 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
5025 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
5026 free((yyvsp[(1) - (1)].StrVal));
5028 if (AsmSoFar.empty())
5029 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5031 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
5036 #line 2356 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5037 { (yyval.Endianness) = Module::BigEndian; ;}
5041 #line 2357 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5042 { (yyval.Endianness) = Module::LittleEndian; ;}
5046 #line 2361 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5048 CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
5053 #line 2364 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5055 if ((yyvsp[(3) - (3)].UInt64Val) == 32)
5056 CurModule.setPointerSize(Module::Pointer32);
5057 else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
5058 CurModule.setPointerSize(Module::Pointer64);
5060 error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
5065 #line 2372 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5067 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
5068 free((yyvsp[(3) - (3)].StrVal));
5073 #line 2376 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5075 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
5076 free((yyvsp[(3) - (3)].StrVal));
5081 #line 2387 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5083 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
5084 free((yyvsp[(3) - (3)].StrVal));
5089 #line 2391 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5091 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
5092 free((yyvsp[(1) - (1)].StrVal));
5097 #line 2395 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5102 #line 2408 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5103 { (yyval.StrVal) = 0; ;}
5107 #line 2412 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5109 if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::VoidTy)
5110 error("void typed arguments are invalid");
5111 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
5116 #line 2420 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5118 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5119 (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
5120 delete (yyvsp[(3) - (3)].ArgVal);
5125 #line 2425 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5127 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5128 (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
5129 delete (yyvsp[(1) - (1)].ArgVal);
5134 #line 2433 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5135 { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
5139 #line 2434 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5141 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5143 VoidTI.T = new PATypeHolder(Type::VoidTy);
5144 VoidTI.S = Signless;
5145 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5150 #line 2441 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5152 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5154 VoidTI.T = new PATypeHolder(Type::VoidTy);
5155 VoidTI.S = Signless;
5156 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5161 #line 2448 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5162 { (yyval.ArgList) = 0; ;}
5166 #line 2452 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5168 UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
5169 std::string FunctionName((yyvsp[(3) - (8)].StrVal));
5170 free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory!
5172 const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).T->get();
5174 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5175 error("LLVM functions cannot return aggregate types");
5177 std::vector<const Type*> ParamTypeList;
5179 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5180 // i8*. We check here for those names and override the parameter list
5181 // types to ensure the prototype is correct.
5182 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5183 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5184 } else if (FunctionName == "llvm.va_copy") {
5185 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5186 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5187 } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments...
5188 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5189 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
5190 const Type *Ty = I->first.T->get();
5191 ParamTypeList.push_back(Ty);
5196 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5197 if (isVarArg) ParamTypeList.pop_back();
5199 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
5200 const PointerType *PFT = PointerType::get(FT);
5201 delete (yyvsp[(2) - (8)].TypeVal).T;
5204 if (!FunctionName.empty()) {
5205 ID = ValID::create((char*)FunctionName.c_str());
5207 ID = ValID::create((int)CurModule.Values[PFT].size());
5211 // See if this function was forward referenced. If so, recycle the object.
5212 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5213 // Move the function to the end of the list, from whereever it was
5214 // previously inserted.
5215 Fn = cast<Function>(FWRef);
5216 CurModule.CurrentModule->getFunctionList().remove(Fn);
5217 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5218 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5219 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5220 // If this is the case, either we need to be a forward decl, or it needs
5222 if (!CurFun.isDeclare && !Fn->isExternal())
5223 error("Redefinition of function '" + FunctionName + "'");
5225 // Make sure to strip off any argument names so we can't get conflicts.
5226 if (Fn->isExternal())
5227 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5230 } else { // Not already defined?
5231 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5232 CurModule.CurrentModule);
5234 InsertValue(Fn, CurModule.Values);
5237 CurFun.FunctionStart(Fn);
5239 if (CurFun.isDeclare) {
5240 // If we have declaration, always overwrite linkage. This will allow us
5241 // to correctly handle cases, when pointer to function is passed as
5242 // argument to another function.
5243 Fn->setLinkage(CurFun.Linkage);
5245 Fn->setCallingConv((yyvsp[(1) - (8)].UIntVal));
5246 Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
5247 if ((yyvsp[(7) - (8)].StrVal)) {
5248 Fn->setSection((yyvsp[(7) - (8)].StrVal));
5249 free((yyvsp[(7) - (8)].StrVal));
5252 // Add all of the arguments we parsed to the function...
5253 if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty...
5254 if (isVarArg) { // Nuke the last entry
5255 assert((yyvsp[(5) - (8)].ArgList)->back().first.T->get() == Type::VoidTy &&
5256 (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
5257 delete (yyvsp[(5) - (8)].ArgList)->back().first.T;
5258 (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry
5260 Function::arg_iterator ArgIt = Fn->arg_begin();
5261 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5262 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I, ++ArgIt) {
5263 delete I->first.T; // Delete the typeholder...
5264 setValueName(ArgIt, I->second); // Insert arg into symtab...
5267 delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list
5273 #line 2562 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5275 (yyval.FunctionVal) = CurFun.CurrentFunction;
5277 // Make sure that we keep track of the linkage type even if there was a
5278 // previous "declare".
5279 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (3)].Linkage));
5284 #line 2576 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5286 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5291 #line 2582 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5292 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5296 #line 2583 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5297 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5301 #line 2587 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5302 { CurFun.isDeclare = true; ;}
5306 #line 2587 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5308 (yyval.FunctionVal) = CurFun.CurrentFunction;
5309 CurFun.FunctionDone();
5315 #line 2599 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5316 { (yyval.BoolVal) = false; ;}
5320 #line 2600 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5321 { (yyval.BoolVal) = true; ;}
5325 #line 2605 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5326 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
5330 #line 2606 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5331 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
5335 #line 2607 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5336 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
5340 #line 2608 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5341 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
5345 #line 2609 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5346 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5350 #line 2610 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5351 { (yyval.ValIDVal) = ValID::createNull(); ;}
5355 #line 2611 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5356 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5360 #line 2612 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5361 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5365 #line 2613 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5366 { // Nonempty unsized packed vector
5367 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
5368 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
5369 PackedType* pt = PackedType::get(ETy, NumElements);
5370 PATypeHolder* PTy = new PATypeHolder(
5371 HandleUpRefs(PackedType::get(ETy, NumElements)));
5373 // Verify all elements are correct type!
5374 std::vector<Constant*> Elems;
5375 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5376 Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
5377 const Type *CTy = C->getType();
5379 error("Element #" + utostr(i) + " is not of type '" +
5380 ETy->getDescription() +"' as required!\nIt is of type '" +
5381 CTy->getDescription() + "'");
5384 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
5385 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5390 #line 2634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5392 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
5397 #line 2637 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5399 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5400 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5401 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5402 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5403 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5404 free((yyvsp[(3) - (5)].StrVal));
5405 free((yyvsp[(5) - (5)].StrVal));
5410 #line 2652 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5411 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); ;}
5415 #line 2653 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5416 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); ;}
5420 #line 2666 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5422 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
5423 (yyval.ValueVal).S = (yyvsp[(1) - (2)].TypeVal).S;
5424 (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
5425 delete (yyvsp[(1) - (2)].TypeVal).T;
5430 #line 2675 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5432 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5437 #line 2678 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5438 { // Do not allow functions with 0 basic blocks
5439 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5444 #line 2687 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5446 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
5447 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5448 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5449 InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5450 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5455 #line 2697 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5457 if ((yyvsp[(2) - (2)].InstVal).I)
5458 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
5459 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
5464 #line 2702 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5466 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5467 // Make sure to move the basic block to the correct location in the
5468 // function, instead of leaving it inserted wherever it was first
5470 Function::BasicBlockListType &BBL =
5471 CurFun.CurrentFunction->getBasicBlockList();
5472 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5477 #line 2711 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5479 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
5480 // Make sure to move the basic block to the correct location in the
5481 // function, instead of leaving it inserted wherever it was first
5483 Function::BasicBlockListType &BBL =
5484 CurFun.CurrentFunction->getBasicBlockList();
5485 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5490 #line 2725 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5491 { // Return with a result...
5492 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
5497 #line 2728 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5498 { // Return with no result...
5499 (yyval.TermInstVal) = new ReturnInst();
5504 #line 2731 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5505 { // Unconditional Branch...
5506 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5507 (yyval.TermInstVal) = new BranchInst(tmpBB);
5512 #line 2735 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5514 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5515 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5516 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5517 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5522 #line 2741 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5524 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
5525 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5526 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5527 (yyval.TermInstVal) = S;
5528 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5529 E = (yyvsp[(8) - (9)].JumpTable)->end();
5530 for (; I != E; ++I) {
5531 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5532 S->addCase(CI, I->second);
5534 error("Switch case is constant, but not a simple integer");
5536 delete (yyvsp[(8) - (9)].JumpTable);
5541 #line 2756 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5543 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
5544 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
5545 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5546 (yyval.TermInstVal) = S;
5551 #line 2763 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5553 const PointerType *PFTy;
5554 const FunctionType *Ty;
5556 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).T->get())) ||
5557 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5558 // Pull out the types of all of the arguments...
5559 std::vector<const Type*> ParamTypes;
5560 if ((yyvsp[(6) - (13)].ValueList)) {
5561 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
5563 ParamTypes.push_back((*I).V->getType());
5565 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5566 if (isVarArg) ParamTypes.pop_back();
5567 Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).T->get(), ParamTypes, isVarArg);
5568 PFTy = PointerType::get(Ty);
5570 Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling...
5571 BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
5572 BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
5574 // Create the call node...
5575 if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments?
5576 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5577 } else { // Has arguments?
5578 // Loop through FunctionType's arguments and ensure they are specified
5581 FunctionType::param_iterator I = Ty->param_begin();
5582 FunctionType::param_iterator E = Ty->param_end();
5583 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
5585 std::vector<Value*> Args;
5586 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5587 if ((*ArgI).V->getType() != *I)
5588 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5589 (*I)->getDescription() + "'");
5590 Args.push_back((*ArgI).V);
5593 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5594 error("Invalid number of parameters detected");
5596 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5598 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[(2) - (13)].UIntVal));
5599 delete (yyvsp[(3) - (13)].TypeVal).T;
5600 delete (yyvsp[(6) - (13)].ValueList);
5605 #line 2813 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5607 (yyval.TermInstVal) = new UnwindInst();
5612 #line 2816 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5614 (yyval.TermInstVal) = new UnreachableInst();
5619 #line 2822 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5621 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5622 Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
5625 error("May only switch on a constant pool value");
5627 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
5628 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5633 #line 2832 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5635 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5636 Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
5639 error("May only switch on a constant pool value");
5641 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
5642 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5647 #line 2845 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5650 if ((yyvsp[(1) - (2)].StrVal))
5651 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
5652 if (BCI->getSrcTy() == BCI->getDestTy() &&
5653 BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
5654 // This is a useless bit cast causing a name redefinition. It is
5655 // a bit cast from a type to the same type of an operand with the
5656 // same name as the name we would give this instruction. Since this
5657 // instruction results in no code generation, it is safe to omit
5658 // the instruction. This situation can occur because of collapsed
5659 // type planes. For example:
5660 // %X = add int %Y, %Z
5661 // %X = cast int %Y to uint
5662 // After upgrade, this looks like:
5663 // %X = add i32 %Y, %Z
5664 // %X = bitcast i32 to i32
5665 // The bitcast is clearly useless so we omit it.
5668 (yyval.InstVal).I = 0;
5669 (yyval.InstVal).S = Signless;
5671 setValueName((yyvsp[(2) - (2)].InstVal).I, (yyvsp[(1) - (2)].StrVal));
5672 InsertValue((yyvsp[(2) - (2)].InstVal).I);
5673 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
5679 #line 2874 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5680 { // Used for PHI nodes
5681 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5682 (yyval.PHIList).S = (yyvsp[(1) - (6)].TypeVal).S;
5683 Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).T->get(), (yyvsp[(3) - (6)].ValIDVal));
5684 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5685 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5686 delete (yyvsp[(1) - (6)].TypeVal).T;
5691 #line 2882 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5693 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5694 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
5695 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
5696 (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5701 #line 2890 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5702 { // Used for call statements, and memory insts...
5703 (yyval.ValueList) = new std::vector<ValueInfo>();
5704 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
5709 #line 2894 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5711 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5712 (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
5717 #line 2902 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5718 { (yyval.ValueList) = 0; ;}
5722 #line 2906 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5724 (yyval.BoolVal) = true;
5729 #line 2909 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5731 (yyval.BoolVal) = false;
5736 #line 2915 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5738 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5739 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5740 error("Arithmetic operator requires integer, FP, or packed operands");
5741 if (isa<PackedType>(Ty) &&
5742 ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp))
5743 error("Remainder not supported on packed types");
5744 // Upgrade the opcode from obsolete versions before we do anything with it.
5745 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5746 Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5747 Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5748 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5749 if ((yyval.InstVal).I == 0)
5750 error("binary operator returned null");
5751 (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5752 delete (yyvsp[(2) - (5)].TypeVal).T;
5757 #line 2932 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5759 const Type *Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5760 if (!Ty->isInteger()) {
5761 if (!isa<PackedType>(Ty) ||
5762 !cast<PackedType>(Ty)->getElementType()->isInteger())
5763 error("Logical operator requires integral operands");
5765 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5766 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5767 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5768 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5769 if ((yyval.InstVal).I == 0)
5770 error("binary operator returned null");
5771 (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5772 delete (yyvsp[(2) - (5)].TypeVal).T;
5777 #line 2948 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5779 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5780 if(isa<PackedType>(Ty))
5781 error("PackedTypes currently not supported in setcc instructions");
5782 unsigned short pred;
5783 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
5784 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5785 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5786 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5787 if ((yyval.InstVal).I == 0)
5788 error("binary operator returned null");
5789 (yyval.InstVal).S = Unsigned;
5790 delete (yyvsp[(2) - (5)].TypeVal).T;
5795 #line 2962 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5797 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
5798 if (isa<PackedType>(Ty))
5799 error("PackedTypes currently not supported in icmp instructions");
5800 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5801 error("icmp requires integer or pointer typed operands");
5802 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5803 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5804 (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
5805 (yyval.InstVal).S = Unsigned;
5806 delete (yyvsp[(3) - (6)].TypeVal).T;
5811 #line 2974 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5813 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
5814 if (isa<PackedType>(Ty))
5815 error("PackedTypes currently not supported in fcmp instructions");
5816 else if (!Ty->isFloatingPoint())
5817 error("fcmp instruction requires floating point operands");
5818 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5819 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5820 (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
5821 (yyval.InstVal).S = Unsigned;
5822 delete (yyvsp[(3) - (6)].TypeVal).T;
5827 #line 2986 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5829 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5830 const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
5831 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5833 error("Expected integral type for not instruction");
5834 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
5835 if ((yyval.InstVal).I == 0)
5836 error("Could not create a xor instruction");
5837 (yyval.InstVal).S = (yyvsp[(2) - (2)].ValueVal).S
5842 #line 2997 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5844 if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
5845 cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
5846 error("Shift amount must be int8");
5847 if (!(yyvsp[(2) - (4)].ValueVal).V->getType()->isInteger())
5848 error("Shift constant expression requires integer operand");
5849 (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[(1) - (4)].OtherOpVal), (yyvsp[(2) - (4)].ValueVal).S), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
5850 (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
5855 #line 3006 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5857 const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5858 if (!DstTy->isFirstClassType())
5859 error("cast instruction to a non-primitive type: '" +
5860 DstTy->getDescription() + "'");
5861 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[(1) - (4)].CastOpVal), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(2) - (4)].ValueVal).S, DstTy, (yyvsp[(4) - (4)].TypeVal).S, true));
5862 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5863 delete (yyvsp[(4) - (4)].TypeVal).T;
5868 #line 3015 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5870 if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
5871 cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
5872 error("select condition must be bool");
5873 if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
5874 error("select value types should match");
5875 (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5876 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
5881 #line 3024 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5883 const Type *Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
5885 (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
5886 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5887 delete (yyvsp[(4) - (4)].TypeVal).T;
5892 #line 3031 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5894 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5895 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5896 ObsoleteVarArgs = true;
5897 Function* NF = cast<Function>(CurModule.CurrentModule->
5898 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5901 //foo = alloca 1 of t
5905 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5906 CurBB->getInstList().push_back(foo);
5907 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
5908 CurBB->getInstList().push_back(bar);
5909 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5910 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5911 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5912 delete (yyvsp[(4) - (4)].TypeVal).T;
5917 #line 3052 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5919 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5920 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5921 ObsoleteVarArgs = true;
5922 Function* NF = cast<Function>(CurModule.CurrentModule->
5923 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5925 //b = vanext a, t ->
5926 //foo = alloca 1 of t
5929 //tmp = vaarg foo, t
5931 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5932 CurBB->getInstList().push_back(foo);
5933 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
5934 CurBB->getInstList().push_back(bar);
5935 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5936 Instruction* tmp = new VAArgInst(foo, DstTy);
5937 CurBB->getInstList().push_back(tmp);
5938 (yyval.InstVal).I = new LoadInst(foo);
5939 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5940 delete (yyvsp[(4) - (4)].TypeVal).T;
5945 #line 3076 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5947 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
5948 error("Invalid extractelement operands");
5949 (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
5950 (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
5955 #line 3082 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5957 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
5958 error("Invalid insertelement operands");
5959 (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5960 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
5965 #line 3088 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5967 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
5968 error("Invalid shufflevector operands");
5969 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5970 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
5975 #line 3094 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5977 const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
5978 if (!Ty->isFirstClassType())
5979 error("PHI node operands must be of first class type");
5980 PHINode *PHI = new PHINode(Ty);
5981 PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
5982 while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
5983 if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty)
5984 error("All elements of a PHI node must be of the same type");
5985 PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
5986 (yyvsp[(2) - (2)].PHIList).P->pop_front();
5988 (yyval.InstVal).I = PHI;
5989 (yyval.InstVal).S = (yyvsp[(2) - (2)].PHIList).S;
5990 delete (yyvsp[(2) - (2)].PHIList).P; // Free the list...
5995 #line 3110 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5998 // Handle the short call syntax
5999 const PointerType *PFTy;
6000 const FunctionType *FTy;
6001 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).T->get())) ||
6002 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6003 // Pull out the types of all of the arguments...
6004 std::vector<const Type*> ParamTypes;
6005 if ((yyvsp[(6) - (7)].ValueList)) {
6006 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
6008 ParamTypes.push_back((*I).V->getType());
6011 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6012 if (isVarArg) ParamTypes.pop_back();
6014 const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).T->get();
6015 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6016 error("Functions cannot return aggregate types");
6018 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
6019 PFTy = PointerType::get(FTy);
6022 // First upgrade any intrinsic calls.
6023 std::vector<Value*> Args;
6024 if ((yyvsp[(6) - (7)].ValueList))
6025 for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i)
6026 Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
6027 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[(4) - (7)].ValIDVal), Args);
6029 // If we got an upgraded intrinsic
6031 (yyval.InstVal).I = Inst;
6032 (yyval.InstVal).S = Signless;
6034 // Get the function we're calling
6035 Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
6037 // Check the argument values match
6038 if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments?
6039 // Make sure no arguments is a good thing!
6040 if (FTy->getNumParams() != 0)
6041 error("No arguments passed to a function that expects arguments");
6042 } else { // Has arguments?
6043 // Loop through FunctionType's arguments and ensure they are specified
6046 FunctionType::param_iterator I = FTy->param_begin();
6047 FunctionType::param_iterator E = FTy->param_end();
6048 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
6050 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6051 if ((*ArgI).V->getType() != *I)
6052 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6053 (*I)->getDescription() + "'");
6055 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6056 error("Invalid number of parameters detected");
6059 // Create the call instruction
6060 CallInst *CI = new CallInst(V, Args);
6061 CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
6062 CI->setCallingConv((yyvsp[(2) - (7)].UIntVal));
6063 (yyval.InstVal).I = CI;
6064 (yyval.InstVal).S = (yyvsp[(3) - (7)].TypeVal).S;
6066 delete (yyvsp[(3) - (7)].TypeVal).T;
6067 delete (yyvsp[(6) - (7)].ValueList);
6072 #line 3183 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6074 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
6079 #line 3191 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6080 { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
6084 #line 3192 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6085 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6089 #line 3196 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6090 { (yyval.BoolVal) = true; ;}
6094 #line 3197 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6095 { (yyval.BoolVal) = false; ;}
6099 #line 3201 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6101 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6102 (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6103 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6104 delete (yyvsp[(2) - (3)].TypeVal).T;
6109 #line 3207 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6111 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6112 (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6113 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6114 delete (yyvsp[(2) - (6)].TypeVal).T;
6119 #line 3213 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6121 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6122 (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6123 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6124 delete (yyvsp[(2) - (3)].TypeVal).T;
6129 #line 3219 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6131 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6132 (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6133 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6134 delete (yyvsp[(2) - (6)].TypeVal).T;
6139 #line 3225 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6141 const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
6142 if (!isa<PointerType>(PTy))
6143 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
6144 (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
6145 (yyval.InstVal).S = Signless;
6150 #line 3232 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6152 const Type* Ty = (yyvsp[(3) - (4)].TypeVal).T->get();
6153 (yyval.InstVal).S = (yyvsp[(3) - (4)].TypeVal).S;
6154 if (!isa<PointerType>(Ty))
6155 error("Can't load from nonpointer type: " + Ty->getDescription());
6156 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6157 error("Can't load from pointer of non-first-class type: " +
6158 Ty->getDescription());
6159 Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
6160 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
6161 delete (yyvsp[(3) - (4)].TypeVal).T;
6166 #line 3244 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6168 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).T->get());
6170 error("Can't store to a nonpointer type: " +
6171 (yyvsp[(5) - (6)].TypeVal).T->get()->getDescription());
6172 const Type *ElTy = PTy->getElementType();
6173 if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType())
6174 error("Can't store '" + (yyvsp[(3) - (6)].ValueVal).V->getType()->getDescription() +
6175 "' into space of type '" + ElTy->getDescription() + "'");
6176 Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
6177 (yyval.InstVal).I = new StoreInst((yyvsp[(3) - (6)].ValueVal).V, tmpVal, (yyvsp[(1) - (6)].BoolVal));
6178 (yyval.InstVal).S = Signless;
6179 delete (yyvsp[(5) - (6)].TypeVal).T;
6184 #line 3258 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6186 const Type* Ty = (yyvsp[(2) - (4)].TypeVal).T->get();
6187 if (!isa<PointerType>(Ty))
6188 error("getelementptr insn requires pointer operand");
6190 std::vector<Value*> VIndices;
6191 upgradeGEPIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
6193 Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
6194 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6195 (yyval.InstVal).S = Signless;
6196 delete (yyvsp[(2) - (4)].TypeVal).T;
6197 delete (yyvsp[(4) - (4)].ValueList);
6202 /* Line 1267 of yacc.c. */
6203 #line 6204 "UpgradeParser.tab.c"
6206 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6210 YY_STACK_PRINT (yyss, yyssp);
6215 /* Now `shift' the result of the reduction. Determine what state
6216 that goes to, based on the state we popped back to and the rule
6217 number reduced by. */
6221 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6222 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
6223 yystate = yytable[yystate];
6225 yystate = yydefgoto[yyn - YYNTOKENS];
6230 /*------------------------------------.
6231 | yyerrlab -- here on detecting error |
6232 `------------------------------------*/
6234 /* If not already recovering from an error, report this error. */
6238 #if ! YYERROR_VERBOSE
6239 yyerror (YY_("syntax error"));
6242 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6243 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6245 YYSIZE_T yyalloc = 2 * yysize;
6246 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6247 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6248 if (yymsg != yymsgbuf)
6249 YYSTACK_FREE (yymsg);
6250 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6252 yymsg_alloc = yyalloc;
6256 yymsg_alloc = sizeof yymsgbuf;
6260 if (0 < yysize && yysize <= yymsg_alloc)
6262 (void) yysyntax_error (yymsg, yystate, yychar);
6267 yyerror (YY_("syntax error"));
6269 goto yyexhaustedlab;
6277 if (yyerrstatus == 3)
6279 /* If just tried and failed to reuse look-ahead token after an
6280 error, discard it. */
6282 if (yychar <= YYEOF)
6284 /* Return failure if at end of input. */
6285 if (yychar == YYEOF)
6290 yydestruct ("Error: discarding",
6296 /* Else will try to reuse look-ahead token after shifting the error
6301 /*---------------------------------------------------.
6302 | yyerrorlab -- error raised explicitly by YYERROR. |
6303 `---------------------------------------------------*/
6306 /* Pacify compilers like GCC when the user code never invokes
6307 YYERROR and the label yyerrorlab therefore never appears in user
6309 if (/*CONSTCOND*/ 0)
6312 /* Do not reclaim the symbols of the rule which action triggered
6316 YY_STACK_PRINT (yyss, yyssp);
6321 /*-------------------------------------------------------------.
6322 | yyerrlab1 -- common code for both syntax error and YYERROR. |
6323 `-------------------------------------------------------------*/
6325 yyerrstatus = 3; /* Each real token shifted decrements this. */
6329 yyn = yypact[yystate];
6330 if (yyn != YYPACT_NINF)
6333 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6341 /* Pop the current state because it cannot handle the error token. */
6346 yydestruct ("Error: popping",
6347 yystos[yystate], yyvsp);
6350 YY_STACK_PRINT (yyss, yyssp);
6359 /* Shift the error token. */
6360 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6366 /*-------------------------------------.
6367 | yyacceptlab -- YYACCEPT comes here. |
6368 `-------------------------------------*/
6373 /*-----------------------------------.
6374 | yyabortlab -- YYABORT comes here. |
6375 `-----------------------------------*/
6381 /*-------------------------------------------------.
6382 | yyexhaustedlab -- memory exhaustion comes here. |
6383 `-------------------------------------------------*/
6385 yyerror (YY_("memory exhausted"));
6391 if (yychar != YYEOF && yychar != YYEMPTY)
6392 yydestruct ("Cleanup: discarding lookahead",
6394 /* Do not reclaim the symbols of the rule which action triggered
6395 this YYABORT or YYACCEPT. */
6397 YY_STACK_PRINT (yyss, yyssp);
6398 while (yyssp != yyss)
6400 yydestruct ("Cleanup: popping",
6401 yystos[*yyssp], yyvsp);
6406 YYSTACK_FREE (yyss);
6409 if (yymsg != yymsgbuf)
6410 YYSTACK_FREE (yymsg);
6412 /* Make sure YYID is used. */
6413 return YYID (yyresult);
6417 #line 3274 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6420 int yyerror(const char *ErrorMsg) {
6422 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6423 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6424 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6425 if (yychar != YYEMPTY && yychar != 0)
6426 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6428 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6429 std::cout << "llvm-upgrade: parse failed.\n";
6433 void warning(const std::string& ErrorMsg) {
6435 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6436 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6437 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6438 if (yychar != YYEMPTY && yychar != 0)
6439 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6441 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6444 void error(const std::string& ErrorMsg, int LineNo) {
6445 if (LineNo == -1) LineNo = Upgradelineno;
6446 Upgradelineno = LineNo;
6447 yyerror(ErrorMsg.c_str());