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 /// @brief This just makes any name given to it unique, up to MAX_UINT times.
944 static std::string makeNameUnique(const std::string& Name) {
945 static unsigned UniqueNameCounter = 1;
946 std::string Result(Name);
947 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
951 /// This is the implementation portion of TypeHasInteger. It traverses the
952 /// type given, avoiding recursive types, and returns true as soon as it finds
953 /// an integer type. If no integer type is found, it returns false.
954 static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
955 // Handle some easy cases
956 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
960 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
961 return STy->getElementType()->isInteger();
963 // Avoid type structure recursion
964 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
969 // Push us on the type stack
972 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
973 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
975 FunctionType::param_iterator I = FTy->param_begin();
976 FunctionType::param_iterator E = FTy->param_end();
978 if (TypeHasIntegerI(*I, Stack))
981 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
982 StructType::element_iterator I = STy->element_begin();
983 StructType::element_iterator E = STy->element_end();
984 for (; I != E; ++I) {
985 if (TypeHasIntegerI(*I, Stack))
990 // There shouldn't be anything else, but its definitely not integer
991 assert(0 && "What type is this?");
995 /// This is the interface to TypeHasIntegerI. It just provides the type stack,
996 /// to avoid recursion, and then calls TypeHasIntegerI.
997 static inline bool TypeHasInteger(const Type *Ty) {
998 std::vector<const Type*> TyStack;
999 return TypeHasIntegerI(Ty, TyStack);
1002 // setValueName - Set the specified value to the name given. The name may be
1003 // null potentially, in which case this is a noop. The string passed in is
1004 // assumed to be a malloc'd string buffer, and is free'd by this function.
1006 static void setValueName(Value *V, char *NameStr) {
1008 std::string Name(NameStr); // Copy string
1009 free(NameStr); // Free old string
1011 if (V->getType() == Type::VoidTy) {
1012 error("Can't assign name '" + Name + "' to value with void type");
1016 assert(inFunctionScope() && "Must be in function scope");
1018 // Search the function's symbol table for an existing value of this name
1019 Value* Existing = 0;
1020 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1021 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
1022 for ( ; PI != PE; ++PI) {
1023 SymbolTable::value_const_iterator VI = PI->second.find(Name);
1024 if (VI != PI->second.end()) {
1025 Existing = VI->second;
1030 // An existing value of the same name was found. This might have happened
1031 // because of the integer type planes collapsing in LLVM 2.0.
1032 if (Existing->getType() == V->getType() &&
1033 !TypeHasInteger(Existing->getType())) {
1034 // If the type does not contain any integers in them then this can't be
1035 // a type plane collapsing issue. It truly is a redefinition and we
1036 // should error out as the assembly is invalid.
1037 error("Redefinition of value named '" + Name + "' of type '" +
1038 V->getType()->getDescription() + "'");
1041 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1042 // function, regardless of Type. Previously re-use of names was okay as
1043 // long as they were distinct types. With type planes collapsing because
1044 // of the signedness change and because of PR411, this can no longer be
1045 // supported. We must search the entire symbol table for a conflicting
1046 // name and make the name unique. No warning is needed as this can't
1048 std::string NewName = makeNameUnique(Name);
1049 // We're changing the name but it will probably be used by other
1050 // instructions as operands later on. Consequently we have to retain
1051 // a mapping of the renaming that we're doing.
1052 RenameMapKey Key = std::make_pair(Name,V->getType());
1053 CurFun.RenameMap[Key] = NewName;
1062 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1063 /// this is a declaration, otherwise it is a definition.
1064 static GlobalVariable *
1065 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1066 bool isConstantGlobal, const Type *Ty,
1067 Constant *Initializer) {
1068 if (isa<FunctionType>(Ty))
1069 error("Cannot declare global vars of function type");
1071 const PointerType *PTy = PointerType::get(Ty);
1075 Name = NameStr; // Copy string
1076 free(NameStr); // Free old string
1079 // See if this global value was forward referenced. If so, recycle the
1082 if (!Name.empty()) {
1083 ID = ValID::create((char*)Name.c_str());
1085 ID = ValID::create((int)CurModule.Values[PTy].size());
1088 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1089 // Move the global to the end of the list, from whereever it was
1090 // previously inserted.
1091 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1092 CurModule.CurrentModule->getGlobalList().remove(GV);
1093 CurModule.CurrentModule->getGlobalList().push_back(GV);
1094 GV->setInitializer(Initializer);
1095 GV->setLinkage(Linkage);
1096 GV->setConstant(isConstantGlobal);
1097 InsertValue(GV, CurModule.Values);
1101 // If this global has a name, check to see if there is already a definition
1102 // of this global in the module and emit warnings if there are conflicts.
1103 if (!Name.empty()) {
1104 // The global has a name. See if there's an existing one of the same name.
1105 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1106 // We found an existing global ov the same name. This isn't allowed
1107 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1108 // can at least compile. This can happen because of type planes
1109 // There is alread a global of the same name which means there is a
1110 // conflict. Let's see what we can do about it.
1111 std::string NewName(makeNameUnique(Name));
1112 if (Linkage == GlobalValue::InternalLinkage) {
1113 // The linkage type is internal so just warn about the rename without
1114 // invoking "scarey language" about linkage failures. GVars with
1115 // InternalLinkage can be renamed at will.
1116 warning("Global variable '" + Name + "' was renamed to '"+
1119 // The linkage of this gval is external so we can't reliably rename
1120 // it because it could potentially create a linking problem.
1121 // However, we can't leave the name conflict in the output either or
1122 // it won't assemble with LLVM 2.0. So, all we can do is rename
1123 // this one to something unique and emit a warning about the problem.
1124 warning("Renaming global variable '" + Name + "' to '" + NewName +
1125 "' may cause linkage errors");
1128 // Put the renaming in the global rename map
1129 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1130 CurModule.RenameMap[Key] = NewName;
1137 // Otherwise there is no existing GV to use, create one now.
1138 GlobalVariable *GV =
1139 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1140 CurModule.CurrentModule);
1141 InsertValue(GV, CurModule.Values);
1145 // setTypeName - Set the specified type to the name given. The name may be
1146 // null potentially, in which case this is a noop. The string passed in is
1147 // assumed to be a malloc'd string buffer, and is freed by this function.
1149 // This function returns true if the type has already been defined, but is
1150 // allowed to be redefined in the specified context. If the name is a new name
1151 // for the type plane, it is inserted and false is returned.
1152 static bool setTypeName(const Type *T, char *NameStr) {
1153 assert(!inFunctionScope() && "Can't give types function-local names");
1154 if (NameStr == 0) return false;
1156 std::string Name(NameStr); // Copy string
1157 free(NameStr); // Free old string
1159 // We don't allow assigning names to void type
1160 if (T == Type::VoidTy) {
1161 error("Can't assign name '" + Name + "' to the void type");
1165 // Set the type name, checking for conflicts as we do so.
1166 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1168 if (AlreadyExists) { // Inserting a name that is already defined???
1169 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1170 assert(Existing && "Conflict but no matching type?");
1172 // There is only one case where this is allowed: when we are refining an
1173 // opaque type. In this case, Existing will be an opaque type.
1174 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1175 // We ARE replacing an opaque type!
1176 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1180 // Otherwise, this is an attempt to redefine a type. That's okay if
1181 // the redefinition is identical to the original. This will be so if
1182 // Existing and T point to the same Type object. In this one case we
1183 // allow the equivalent redefinition.
1184 if (Existing == T) return true; // Yes, it's equal.
1186 // Any other kind of (non-equivalent) redefinition is an error.
1187 error("Redefinition of type named '" + Name + "' in the '" +
1188 T->getDescription() + "' type plane");
1194 //===----------------------------------------------------------------------===//
1195 // Code for handling upreferences in type names...
1198 // TypeContains - Returns true if Ty directly contains E in it.
1200 static bool TypeContains(const Type *Ty, const Type *E) {
1201 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1202 E) != Ty->subtype_end();
1206 struct UpRefRecord {
1207 // NestingLevel - The number of nesting levels that need to be popped before
1208 // this type is resolved.
1209 unsigned NestingLevel;
1211 // LastContainedTy - This is the type at the current binding level for the
1212 // type. Every time we reduce the nesting level, this gets updated.
1213 const Type *LastContainedTy;
1215 // UpRefTy - This is the actual opaque type that the upreference is
1216 // represented with.
1217 OpaqueType *UpRefTy;
1219 UpRefRecord(unsigned NL, OpaqueType *URTy)
1220 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1224 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1225 static std::vector<UpRefRecord> UpRefs;
1227 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1228 /// called. It loops through the UpRefs vector, which is a list of the
1229 /// currently active types. For each type, if the up reference is contained in
1230 /// the newly completed type, we decrement the level count. When the level
1231 /// count reaches zero, the upreferenced type is the type that is passed in:
1232 /// thus we can complete the cycle.
1234 static PATypeHolder HandleUpRefs(const Type *ty) {
1235 // If Ty isn't abstract, or if there are no up-references in it, then there is
1236 // nothing to resolve here.
1237 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1239 PATypeHolder Ty(ty);
1240 UR_OUT("Type '" << Ty->getDescription() <<
1241 "' newly formed. Resolving upreferences.\n" <<
1242 UpRefs.size() << " upreferences active!\n");
1244 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1245 // to zero), we resolve them all together before we resolve them to Ty. At
1246 // the end of the loop, if there is anything to resolve to Ty, it will be in
1248 OpaqueType *TypeToResolve = 0;
1250 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1251 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1252 << UpRefs[i].second->getDescription() << ") = "
1253 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1254 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1255 // Decrement level of upreference
1256 unsigned Level = --UpRefs[i].NestingLevel;
1257 UpRefs[i].LastContainedTy = Ty;
1258 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1259 if (Level == 0) { // Upreference should be resolved!
1260 if (!TypeToResolve) {
1261 TypeToResolve = UpRefs[i].UpRefTy;
1263 UR_OUT(" * Resolving upreference for "
1264 << UpRefs[i].second->getDescription() << "\n";
1265 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1266 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1267 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1268 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1270 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1271 --i; // Do not skip the next element...
1276 if (TypeToResolve) {
1277 UR_OUT(" * Resolving upreference for "
1278 << UpRefs[i].second->getDescription() << "\n";
1279 std::string OldName = TypeToResolve->getDescription());
1280 TypeToResolve->refineAbstractTypeTo(Ty);
1286 static inline Instruction::TermOps
1287 getTermOp(TermOps op) {
1289 default : assert(0 && "Invalid OldTermOp");
1290 case RetOp : return Instruction::Ret;
1291 case BrOp : return Instruction::Br;
1292 case SwitchOp : return Instruction::Switch;
1293 case InvokeOp : return Instruction::Invoke;
1294 case UnwindOp : return Instruction::Unwind;
1295 case UnreachableOp: return Instruction::Unreachable;
1299 static inline Instruction::BinaryOps
1300 getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1302 default : assert(0 && "Invalid OldBinaryOps");
1308 case SetGT : assert(0 && "Should use getCompareOp");
1309 case AddOp : return Instruction::Add;
1310 case SubOp : return Instruction::Sub;
1311 case MulOp : return Instruction::Mul;
1313 // This is an obsolete instruction so we must upgrade it based on the
1314 // types of its operands.
1315 bool isFP = Ty->isFloatingPoint();
1316 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1317 // If its a packed type we want to use the element type
1318 isFP = PTy->getElementType()->isFloatingPoint();
1320 return Instruction::FDiv;
1321 else if (Sign == Signed)
1322 return Instruction::SDiv;
1323 return Instruction::UDiv;
1325 case UDivOp : return Instruction::UDiv;
1326 case SDivOp : return Instruction::SDiv;
1327 case FDivOp : return Instruction::FDiv;
1329 // This is an obsolete instruction so we must upgrade it based on the
1330 // types of its operands.
1331 bool isFP = Ty->isFloatingPoint();
1332 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1333 // If its a packed type we want to use the element type
1334 isFP = PTy->getElementType()->isFloatingPoint();
1335 // Select correct opcode
1337 return Instruction::FRem;
1338 else if (Sign == Signed)
1339 return Instruction::SRem;
1340 return Instruction::URem;
1342 case URemOp : return Instruction::URem;
1343 case SRemOp : return Instruction::SRem;
1344 case FRemOp : return Instruction::FRem;
1345 case AndOp : return Instruction::And;
1346 case OrOp : return Instruction::Or;
1347 case XorOp : return Instruction::Xor;
1351 static inline Instruction::OtherOps
1352 getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1354 bool isSigned = Sign == Signed;
1355 bool isFP = Ty->isFloatingPoint();
1357 default : assert(0 && "Invalid OldSetCC");
1360 predicate = FCmpInst::FCMP_OEQ;
1361 return Instruction::FCmp;
1363 predicate = ICmpInst::ICMP_EQ;
1364 return Instruction::ICmp;
1368 predicate = FCmpInst::FCMP_UNE;
1369 return Instruction::FCmp;
1371 predicate = ICmpInst::ICMP_NE;
1372 return Instruction::ICmp;
1376 predicate = FCmpInst::FCMP_OLE;
1377 return Instruction::FCmp;
1380 predicate = ICmpInst::ICMP_SLE;
1382 predicate = ICmpInst::ICMP_ULE;
1383 return Instruction::ICmp;
1387 predicate = FCmpInst::FCMP_OGE;
1388 return Instruction::FCmp;
1391 predicate = ICmpInst::ICMP_SGE;
1393 predicate = ICmpInst::ICMP_UGE;
1394 return Instruction::ICmp;
1398 predicate = FCmpInst::FCMP_OLT;
1399 return Instruction::FCmp;
1402 predicate = ICmpInst::ICMP_SLT;
1404 predicate = ICmpInst::ICMP_ULT;
1405 return Instruction::ICmp;
1409 predicate = FCmpInst::FCMP_OGT;
1410 return Instruction::FCmp;
1413 predicate = ICmpInst::ICMP_SGT;
1415 predicate = ICmpInst::ICMP_UGT;
1416 return Instruction::ICmp;
1421 static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1423 default : assert(0 && "Invalid OldMemoryOps");
1424 case MallocOp : return Instruction::Malloc;
1425 case FreeOp : return Instruction::Free;
1426 case AllocaOp : return Instruction::Alloca;
1427 case LoadOp : return Instruction::Load;
1428 case StoreOp : return Instruction::Store;
1429 case GetElementPtrOp : return Instruction::GetElementPtr;
1433 static inline Instruction::OtherOps
1434 getOtherOp(OtherOps op, Signedness Sign) {
1436 default : assert(0 && "Invalid OldOtherOps");
1437 case PHIOp : return Instruction::PHI;
1438 case CallOp : return Instruction::Call;
1439 case ShlOp : return Instruction::Shl;
1442 return Instruction::AShr;
1443 return Instruction::LShr;
1444 case SelectOp : return Instruction::Select;
1445 case UserOp1 : return Instruction::UserOp1;
1446 case UserOp2 : return Instruction::UserOp2;
1447 case VAArg : return Instruction::VAArg;
1448 case ExtractElementOp : return Instruction::ExtractElement;
1449 case InsertElementOp : return Instruction::InsertElement;
1450 case ShuffleVectorOp : return Instruction::ShuffleVector;
1451 case ICmpOp : return Instruction::ICmp;
1452 case FCmpOp : return Instruction::FCmp;
1453 case LShrOp : return Instruction::LShr;
1454 case AShrOp : return Instruction::AShr;
1458 static inline Value*
1459 getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1460 Signedness DstSign, bool ForceInstruction = false) {
1461 Instruction::CastOps Opcode;
1462 const Type* SrcTy = Src->getType();
1464 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1465 // fp -> ptr cast is no longer supported but we must upgrade this
1466 // by doing a double cast: fp -> int -> ptr
1467 SrcTy = Type::Int64Ty;
1468 Opcode = Instruction::IntToPtr;
1469 if (isa<Constant>(Src)) {
1470 Src = ConstantExpr::getCast(Instruction::FPToUI,
1471 cast<Constant>(Src), SrcTy);
1473 std::string NewName(makeNameUnique(Src->getName()));
1474 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1476 } else if (isa<IntegerType>(DstTy) &&
1477 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1478 // cast type %x to bool was previously defined as setne type %x, null
1479 // The cast semantic is now to truncate, not compare so we must retain
1480 // the original intent by replacing the cast with a setne
1481 Constant* Null = Constant::getNullValue(SrcTy);
1482 Instruction::OtherOps Opcode = Instruction::ICmp;
1483 unsigned short predicate = ICmpInst::ICMP_NE;
1484 if (SrcTy->isFloatingPoint()) {
1485 Opcode = Instruction::FCmp;
1486 predicate = FCmpInst::FCMP_ONE;
1487 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1488 error("Invalid cast to bool");
1490 if (isa<Constant>(Src) && !ForceInstruction)
1491 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1493 return CmpInst::create(Opcode, predicate, Src, Null);
1495 // Determine the opcode to use by calling CastInst::getCastOpcode
1497 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1499 } else switch (op) {
1500 default: assert(0 && "Invalid cast token");
1501 case TruncOp: Opcode = Instruction::Trunc; break;
1502 case ZExtOp: Opcode = Instruction::ZExt; break;
1503 case SExtOp: Opcode = Instruction::SExt; break;
1504 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1505 case FPExtOp: Opcode = Instruction::FPExt; break;
1506 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1507 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1508 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1509 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1510 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1511 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1512 case BitCastOp: Opcode = Instruction::BitCast; break;
1515 if (isa<Constant>(Src) && !ForceInstruction)
1516 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1517 return CastInst::create(Opcode, Src, DstTy);
1520 static Instruction *
1521 upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1522 std::vector<Value*>& Args) {
1524 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1525 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1526 if (Args.size() != 2)
1527 error("Invalid prototype for " + Name + " prototype");
1528 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1530 static unsigned upgradeCount = 1;
1531 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1532 std::vector<const Type*> Params;
1533 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1534 if (Args.size() != 1)
1535 error("Invalid prototype for " + Name + " prototype");
1536 Params.push_back(PtrTy);
1537 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1538 const PointerType *PFTy = PointerType::get(FTy);
1539 Value* Func = getVal(PFTy, ID);
1540 std::string InstName("va_upgrade");
1541 InstName += llvm::utostr(upgradeCount++);
1542 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1543 return new CallInst(Func, Args);
1544 } else if (Name == "llvm.va_copy") {
1545 if (Args.size() != 2)
1546 error("Invalid prototype for " + Name + " prototype");
1547 Params.push_back(PtrTy);
1548 Params.push_back(PtrTy);
1549 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1550 const PointerType *PFTy = PointerType::get(FTy);
1551 Value* Func = getVal(PFTy, ID);
1552 std::string InstName0("va_upgrade");
1553 InstName0 += llvm::utostr(upgradeCount++);
1554 std::string InstName1("va_upgrade");
1555 InstName1 += llvm::utostr(upgradeCount++);
1556 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1557 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1558 return new CallInst(Func, Args);
1564 const Type* upgradeGEPIndices(const Type* PTy,
1565 std::vector<ValueInfo> *Indices,
1566 std::vector<Value*> &VIndices,
1567 std::vector<Constant*> *CIndices = 0) {
1568 // Traverse the indices with a gep_type_iterator so we can build the list
1569 // of constant and value indices for use later. Also perform upgrades
1571 if (CIndices) CIndices->clear();
1572 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1573 VIndices.push_back((*Indices)[i].V);
1574 generic_gep_type_iterator<std::vector<Value*>::iterator>
1575 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1576 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1577 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1578 Value *Index = VIndices[i];
1579 if (CIndices && !isa<Constant>(Index))
1580 error("Indices to constant getelementptr must be constants");
1581 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1582 // struct indices to i32 struct indices with ZExt for compatibility.
1583 else if (isa<StructType>(*GTI)) { // Only change struct indices
1584 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1585 if (CUI->getType()->getBitWidth() == 8)
1587 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1589 // Make sure that unsigned SequentialType indices are zext'd to
1590 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1591 // all indices for SequentialType elements. We must retain the same
1592 // semantic (zext) for unsigned types.
1593 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
1594 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
1596 Index = ConstantExpr::getCast(Instruction::ZExt,
1597 cast<Constant>(Index), Type::Int64Ty);
1599 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1600 makeNameUnique("gep_upgrade"), CurBB);
1601 VIndices[i] = Index;
1604 // Add to the CIndices list, if requested.
1606 CIndices->push_back(cast<Constant>(Index));
1610 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1612 error("Index list invalid for constant getelementptr");
1616 Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1617 bool debug, bool addAttrs)
1620 CurFilename = infile;
1623 AddAttributes = addAttrs;
1624 ObsoleteVarArgs = false;
1627 CurModule.CurrentModule = new Module(CurFilename);
1629 // Check to make sure the parser succeeded
1632 delete ParserResult;
1633 std::cerr << "llvm-upgrade: parse failed.\n";
1637 // Check to make sure that parsing produced a result
1638 if (!ParserResult) {
1639 std::cerr << "llvm-upgrade: no parse result.\n";
1643 // Reset ParserResult variable while saving its value for the result.
1644 Module *Result = ParserResult;
1647 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1650 if ((F = Result->getNamedFunction("llvm.va_start"))
1651 && F->getFunctionType()->getNumParams() == 0)
1652 ObsoleteVarArgs = true;
1653 if((F = Result->getNamedFunction("llvm.va_copy"))
1654 && F->getFunctionType()->getNumParams() == 1)
1655 ObsoleteVarArgs = true;
1658 if (ObsoleteVarArgs && NewVarArgs) {
1659 error("This file is corrupt: it uses both new and old style varargs");
1663 if(ObsoleteVarArgs) {
1664 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1665 if (F->arg_size() != 0) {
1666 error("Obsolete va_start takes 0 argument");
1672 //bar = alloca typeof(foo)
1676 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1677 const Type* ArgTy = F->getFunctionType()->getReturnType();
1678 const Type* ArgTyPtr = PointerType::get(ArgTy);
1679 Function* NF = cast<Function>(Result->getOrInsertFunction(
1680 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1682 while (!F->use_empty()) {
1683 CallInst* CI = cast<CallInst>(F->use_back());
1684 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1685 new CallInst(NF, bar, "", CI);
1686 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1687 CI->replaceAllUsesWith(foo);
1688 CI->getParent()->getInstList().erase(CI);
1690 Result->getFunctionList().erase(F);
1693 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1694 if(F->arg_size() != 1) {
1695 error("Obsolete va_end takes 1 argument");
1701 //bar = alloca 1 of typeof(foo)
1703 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1704 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1705 const Type* ArgTyPtr = PointerType::get(ArgTy);
1706 Function* NF = cast<Function>(Result->getOrInsertFunction(
1707 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
1709 while (!F->use_empty()) {
1710 CallInst* CI = cast<CallInst>(F->use_back());
1711 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1712 new StoreInst(CI->getOperand(1), bar, CI);
1713 new CallInst(NF, bar, "", CI);
1714 CI->getParent()->getInstList().erase(CI);
1716 Result->getFunctionList().erase(F);
1719 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1720 if(F->arg_size() != 1) {
1721 error("Obsolete va_copy takes 1 argument");
1726 //a = alloca 1 of typeof(foo)
1727 //b = alloca 1 of typeof(foo)
1732 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1733 const Type* ArgTy = F->getFunctionType()->getReturnType();
1734 const Type* ArgTyPtr = PointerType::get(ArgTy);
1735 Function* NF = cast<Function>(Result->getOrInsertFunction(
1736 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
1738 while (!F->use_empty()) {
1739 CallInst* CI = cast<CallInst>(F->use_back());
1740 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1741 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1742 new StoreInst(CI->getOperand(1), b, CI);
1743 new CallInst(NF, a, b, "", CI);
1744 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1745 CI->replaceAllUsesWith(foo);
1746 CI->getParent()->getInstList().erase(CI);
1748 Result->getFunctionList().erase(F);
1755 } // end llvm namespace
1757 using namespace llvm;
1761 /* Enabling traces. */
1766 /* Enabling verbose error messages. */
1767 #ifdef YYERROR_VERBOSE
1768 # undef YYERROR_VERBOSE
1769 # define YYERROR_VERBOSE 1
1771 # define YYERROR_VERBOSE 0
1774 /* Enabling the token table. */
1775 #ifndef YYTOKEN_TABLE
1776 # define YYTOKEN_TABLE 0
1779 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1780 typedef union YYSTYPE
1781 #line 1391 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
1783 llvm::Module *ModuleVal;
1784 llvm::Function *FunctionVal;
1785 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1786 llvm::BasicBlock *BasicBlockVal;
1787 llvm::TerminatorInst *TermInstVal;
1788 llvm::InstrInfo InstVal;
1789 llvm::ConstInfo ConstVal;
1790 llvm::ValueInfo ValueVal;
1791 llvm::PATypeInfo TypeVal;
1792 llvm::TypeInfo PrimType;
1793 llvm::PHIListInfo PHIList;
1794 std::list<llvm::PATypeInfo> *TypeList;
1795 std::vector<llvm::ValueInfo> *ValueList;
1796 std::vector<llvm::ConstInfo> *ConstVector;
1799 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1800 // Represent the RHS of PHI node
1801 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1803 llvm::GlobalValue::LinkageTypes Linkage;
1811 char *StrVal; // This memory is strdup'd!
1812 llvm::ValID ValIDVal; // strdup'd memory maybe!
1814 llvm::BinaryOps BinaryOpVal;
1815 llvm::TermOps TermOpVal;
1816 llvm::MemoryOps MemOpVal;
1817 llvm::OtherOps OtherOpVal;
1818 llvm::CastOps CastOpVal;
1819 llvm::ICmpInst::Predicate IPred;
1820 llvm::FCmpInst::Predicate FPred;
1821 llvm::Module::Endianness Endianness;
1823 /* Line 187 of yacc.c. */
1824 #line 1825 "UpgradeParser.tab.c"
1826 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1827 # define YYSTYPE_IS_DECLARED 1
1828 # define YYSTYPE_IS_TRIVIAL 1
1833 /* Copy the second part of user declarations. */
1836 /* Line 216 of yacc.c. */
1837 #line 1838 "UpgradeParser.tab.c"
1844 typedef YYTYPE_UINT8 yytype_uint8;
1846 typedef unsigned char yytype_uint8;
1850 typedef YYTYPE_INT8 yytype_int8;
1851 #elif (defined __STDC__ || defined __C99__FUNC__ \
1852 || defined __cplusplus || defined _MSC_VER)
1853 typedef signed char yytype_int8;
1855 typedef short int yytype_int8;
1858 #ifdef YYTYPE_UINT16
1859 typedef YYTYPE_UINT16 yytype_uint16;
1861 typedef unsigned short int yytype_uint16;
1865 typedef YYTYPE_INT16 yytype_int16;
1867 typedef short int yytype_int16;
1871 # ifdef __SIZE_TYPE__
1872 # define YYSIZE_T __SIZE_TYPE__
1873 # elif defined size_t
1874 # define YYSIZE_T size_t
1875 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1876 || defined __cplusplus || defined _MSC_VER)
1877 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1878 # define YYSIZE_T size_t
1880 # define YYSIZE_T unsigned int
1884 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1889 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1890 # define YY_(msgid) dgettext ("bison-runtime", msgid)
1894 # define YY_(msgid) msgid
1898 /* Suppress unused-variable warnings by "using" E. */
1899 #if ! defined lint || defined __GNUC__
1900 # define YYUSE(e) ((void) (e))
1902 # define YYUSE(e) /* empty */
1905 /* Identity function, used to suppress warnings about constant conditions. */
1907 # define YYID(n) (n)
1909 #if (defined __STDC__ || defined __C99__FUNC__ \
1910 || defined __cplusplus || defined _MSC_VER)
1923 #if ! defined yyoverflow || YYERROR_VERBOSE
1925 /* The parser invokes alloca or malloc; define the necessary symbols. */
1927 # ifdef YYSTACK_USE_ALLOCA
1928 # if YYSTACK_USE_ALLOCA
1930 # define YYSTACK_ALLOC __builtin_alloca
1931 # elif defined __BUILTIN_VA_ARG_INCR
1932 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1934 # define YYSTACK_ALLOC __alloca
1935 # elif defined _MSC_VER
1936 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1937 # define alloca _alloca
1939 # define YYSTACK_ALLOC alloca
1940 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1941 || defined __cplusplus || defined _MSC_VER)
1942 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1944 # define _STDLIB_H 1
1951 # ifdef YYSTACK_ALLOC
1952 /* Pacify GCC's `empty if-body' warning. */
1953 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1954 # ifndef YYSTACK_ALLOC_MAXIMUM
1955 /* The OS might guarantee only one guard page at the bottom of the stack,
1956 and a page size can be as small as 4096 bytes. So we cannot safely
1957 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1958 to allow for a few compiler-allocated temporary stack slots. */
1959 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1962 # define YYSTACK_ALLOC YYMALLOC
1963 # define YYSTACK_FREE YYFREE
1964 # ifndef YYSTACK_ALLOC_MAXIMUM
1965 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1967 # if (defined __cplusplus && ! defined _STDLIB_H \
1968 && ! ((defined YYMALLOC || defined malloc) \
1969 && (defined YYFREE || defined free)))
1970 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1972 # define _STDLIB_H 1
1976 # define YYMALLOC malloc
1977 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1978 || defined __cplusplus || defined _MSC_VER)
1979 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1983 # define YYFREE free
1984 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1985 || defined __cplusplus || defined _MSC_VER)
1986 void free (void *); /* INFRINGES ON USER NAME SPACE */
1990 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1993 #if (! defined yyoverflow \
1994 && (! defined __cplusplus \
1995 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1997 /* A type that is properly aligned for any stack member. */
2004 /* The size of the maximum gap between one aligned stack and the next. */
2005 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2007 /* The size of an array large to enough to hold all stacks, each with
2009 # define YYSTACK_BYTES(N) \
2010 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
2011 + YYSTACK_GAP_MAXIMUM)
2013 /* Copy COUNT objects from FROM to TO. The source and destination do
2016 # if defined __GNUC__ && 1 < __GNUC__
2017 # define YYCOPY(To, From, Count) \
2018 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2020 # define YYCOPY(To, From, Count) \
2024 for (yyi = 0; yyi < (Count); yyi++) \
2025 (To)[yyi] = (From)[yyi]; \
2031 /* Relocate STACK from its old location to the new one. The
2032 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2033 elements in the stack, and YYPTR gives the new location of the
2034 stack. Advance YYPTR to a properly aligned location for the next
2036 # define YYSTACK_RELOCATE(Stack) \
2039 YYSIZE_T yynewbytes; \
2040 YYCOPY (&yyptr->Stack, Stack, yysize); \
2041 Stack = &yyptr->Stack; \
2042 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2043 yyptr += yynewbytes / sizeof (*yyptr); \
2049 /* YYFINAL -- State number of the termination state. */
2051 /* YYLAST -- Last index in YYTABLE. */
2054 /* YYNTOKENS -- Number of terminals. */
2055 #define YYNTOKENS 166
2056 /* YYNNTS -- Number of nonterminals. */
2058 /* YYNRULES -- Number of rules. */
2059 #define YYNRULES 308
2060 /* YYNRULES -- Number of states. */
2061 #define YYNSTATES 604
2063 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2064 #define YYUNDEFTOK 2
2065 #define YYMAXUTOK 406
2067 #define YYTRANSLATE(YYX) \
2068 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2070 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2071 static const yytype_uint8 yytranslate[] =
2073 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2074 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2075 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2077 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2079 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2080 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2081 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2082 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2084 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2085 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2086 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2087 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2088 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2089 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2090 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2091 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2092 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2093 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2094 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2095 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2096 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2097 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2098 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2099 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2100 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2101 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2102 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2103 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2104 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2105 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2106 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2107 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2108 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2109 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2110 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2111 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2112 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2113 145, 146, 147, 148, 149, 150, 151
2117 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2119 static const yytype_uint16 yyprhs[] =
2121 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2122 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2123 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2124 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2125 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2126 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2127 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2128 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2129 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2130 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2131 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2132 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2133 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2134 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2135 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2136 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2137 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2138 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2139 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2140 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2141 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2142 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2143 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2144 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2145 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2146 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2147 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2148 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2149 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2150 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2151 927, 928, 932, 939, 943, 950, 953, 958, 965
2154 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
2155 static const yytype_int16 yyrhs[] =
2157 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2158 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2159 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2160 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2161 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
2162 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2163 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2164 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2165 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2166 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2167 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2168 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2169 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2170 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2171 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2172 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2173 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2174 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2175 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2176 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2177 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2178 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2179 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2180 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2181 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2182 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2183 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2184 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2185 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2186 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2187 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2188 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2189 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2190 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2191 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2192 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2193 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2194 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2195 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2196 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2197 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2198 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2199 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2200 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2201 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2202 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2203 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2204 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2205 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2206 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2207 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2208 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2209 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2210 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2211 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2212 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2213 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2214 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2215 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2216 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2217 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2218 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2219 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2220 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2221 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2222 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2223 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2224 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2225 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2226 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2227 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2228 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2229 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2230 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2231 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2232 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2233 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2234 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2235 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2236 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2237 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2238 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2239 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2240 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2241 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2242 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2243 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2244 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2245 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2246 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2247 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2248 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2249 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2250 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2251 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2252 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2253 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
2256 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2257 static const yytype_uint16 yyrline[] =
2259 0, 1531, 1531, 1532, 1540, 1541, 1551, 1551, 1551, 1551,
2260 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1555, 1555, 1555,
2261 1559, 1559, 1559, 1559, 1559, 1559, 1563, 1563, 1564, 1564,
2262 1565, 1565, 1566, 1566, 1567, 1567, 1571, 1571, 1572, 1572,
2263 1573, 1573, 1574, 1574, 1575, 1575, 1576, 1576, 1577, 1577,
2264 1578, 1579, 1582, 1582, 1582, 1582, 1586, 1586, 1586, 1586,
2265 1586, 1586, 1586, 1587, 1587, 1587, 1587, 1587, 1587, 1593,
2266 1593, 1593, 1593, 1597, 1597, 1597, 1597, 1601, 1601, 1605,
2267 1605, 1610, 1613, 1618, 1619, 1620, 1621, 1622, 1623, 1624,
2268 1625, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1646,
2269 1647, 1655, 1656, 1664, 1673, 1674, 1681, 1682, 1686, 1690,
2270 1706, 1707, 1714, 1715, 1722, 1730, 1730, 1730, 1730, 1730,
2271 1730, 1730, 1731, 1731, 1731, 1731, 1731, 1736, 1740, 1744,
2272 1749, 1758, 1774, 1780, 1793, 1802, 1806, 1817, 1821, 1834,
2273 1838, 1845, 1846, 1852, 1859, 1871, 1901, 1914, 1937, 1965,
2274 1987, 1998, 2020, 2031, 2040, 2045, 2103, 2110, 2118, 2125,
2275 2132, 2136, 2140, 2149, 2164, 2177, 2186, 2214, 2227, 2236,
2276 2242, 2248, 2257, 2263, 2269, 2280, 2281, 2290, 2291, 2303,
2277 2312, 2313, 2314, 2315, 2316, 2332, 2352, 2354, 2356, 2356,
2278 2363, 2363, 2370, 2370, 2377, 2377, 2385, 2387, 2389, 2394,
2279 2408, 2409, 2413, 2416, 2424, 2428, 2435, 2439, 2443, 2447,
2280 2455, 2455, 2459, 2460, 2464, 2472, 2477, 2485, 2486, 2493,
2281 2500, 2504, 2610, 2610, 2614, 2624, 2624, 2628, 2632, 2634,
2282 2635, 2639, 2639, 2651, 2652, 2657, 2658, 2659, 2660, 2661,
2283 2662, 2663, 2664, 2665, 2686, 2689, 2704, 2705, 2710, 2710,
2284 2718, 2727, 2730, 2739, 2749, 2754, 2763, 2774, 2774, 2777,
2285 2780, 2783, 2787, 2793, 2808, 2814, 2865, 2868, 2874, 2884,
2286 2897, 2926, 2934, 2942, 2946, 2953, 2954, 2958, 2961, 2967,
2287 2984, 3000, 3014, 3026, 3038, 3049, 3058, 3067, 3076, 3083,
2288 3104, 3128, 3134, 3140, 3146, 3162, 3235, 3243, 3244, 3248,
2289 3249, 3253, 3259, 3265, 3271, 3277, 3284, 3296, 3310
2293 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2294 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2295 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2296 static const char *const yytname[] =
2298 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2299 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2300 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2301 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2302 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2303 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2304 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2305 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2306 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2307 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2308 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2309 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2310 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2311 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2312 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2313 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2314 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2315 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2316 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2317 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2318 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2319 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2320 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2321 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2322 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2323 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2324 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2325 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2326 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2327 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2328 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2329 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2330 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2331 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2332 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2333 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2334 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2335 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2336 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2337 "OptVolatile", "MemoryInst", 0
2342 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2344 static const yytype_uint16 yytoknum[] =
2346 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2347 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2348 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2349 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2350 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2351 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2352 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2353 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2354 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2355 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2356 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2357 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2358 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2359 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2360 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2361 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2362 60, 62, 123, 125, 42, 99
2366 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2367 static const yytype_uint8 yyr1[] =
2369 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2370 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2371 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2372 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2373 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2374 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2375 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2376 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2377 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2378 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2379 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2380 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2381 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2382 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2383 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2384 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2385 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2386 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2387 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2388 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2389 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2390 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2391 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2392 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2393 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2394 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2395 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2396 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2397 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2398 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2399 243, 244, 244, 244, 244, 244, 244, 244, 244
2402 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2403 static const yytype_uint8 yyr2[] =
2405 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2413 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2414 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2415 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2418 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2419 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2420 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2421 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2422 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2423 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2424 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2425 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2426 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2427 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2428 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2429 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2430 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2431 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2432 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2433 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2434 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2435 0, 3, 6, 3, 6, 2, 4, 6, 4
2438 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2439 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2440 means the default is an error. */
2441 static const yytype_uint16 yydefact[] =
2443 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2444 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2445 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2446 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2447 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2448 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2449 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2450 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2451 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2452 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2453 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2454 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2455 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2456 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2457 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2458 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2459 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2460 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2461 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2462 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2463 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2464 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2465 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2466 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2467 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2468 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2469 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2470 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2471 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
2472 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2473 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2474 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
2475 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2476 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2477 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2478 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2479 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2480 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2481 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2482 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2483 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2484 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2485 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2486 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2487 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2488 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2489 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2490 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2491 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2492 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2493 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2494 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2495 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2496 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2497 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2498 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2499 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2500 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2501 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2502 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2506 /* YYDEFGOTO[NTERM-NUM]. */
2507 static const yytype_int16 yydefgoto[] =
2509 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2510 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2511 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2512 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2513 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2514 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2515 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2516 97, 286, 526, 527, 193, 194, 436, 195, 196
2519 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2521 #define YYPACT_NINF -508
2522 static const yytype_int16 yypact[] =
2524 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2525 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2526 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2527 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2528 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2529 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2530 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2531 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2532 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2533 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2534 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2535 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2536 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2537 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2538 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2539 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2540 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2541 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2542 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2543 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2544 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2545 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2546 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2547 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2548 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2549 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2550 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2551 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2552 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2553 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2554 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2555 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2556 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2557 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2558 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2559 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2560 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2561 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2562 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2563 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2564 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2565 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2566 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2567 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2568 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2569 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2570 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2571 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2572 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2573 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2574 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2575 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2576 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2577 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2578 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2579 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2580 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2581 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2582 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2583 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2584 898, 898, -508, -508
2587 /* YYPGOTO[NTERM-NUM]. */
2588 static const yytype_int16 yypgoto[] =
2590 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2591 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2592 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2593 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2594 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2595 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2596 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2597 -508, -508, 43, -22, -508, -508, 21, -508, -508
2600 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2601 positive, shift that token. If negative, reduce the rule which
2602 number is the opposite. If zero, do what YYDEFACT says.
2603 If YYTABLE_NINF, syntax error. */
2604 #define YYTABLE_NINF -180
2605 static const yytype_int16 yytable[] =
2607 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2608 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2609 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2610 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2611 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2612 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2613 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2614 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2615 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2616 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2617 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2618 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2619 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2620 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2621 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2622 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2623 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2624 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2625 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2626 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2627 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2628 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2629 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2630 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2631 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2632 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2633 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2634 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2635 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2636 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2637 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2638 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2639 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2640 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2641 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2642 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2643 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2644 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2645 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2646 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2647 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2648 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2649 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2650 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2651 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2652 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2653 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2654 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2655 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2656 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2657 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2658 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2659 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2660 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2661 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2662 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2663 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2664 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2665 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2666 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2667 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2668 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2669 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2670 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2671 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2672 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2673 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2674 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2675 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2676 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2677 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2678 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2679 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2680 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2681 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2682 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2683 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2684 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2685 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2686 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2687 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2688 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2689 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2690 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2691 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2692 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2693 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2694 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
2695 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2696 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2697 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2698 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2699 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2700 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2701 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2702 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2703 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2704 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2705 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2706 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2707 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2708 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2709 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2710 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2711 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2712 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2713 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2714 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2715 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2716 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2717 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2718 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2719 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2720 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2721 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2722 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2723 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2724 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2725 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2726 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2727 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2728 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2729 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2730 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2731 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2732 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2733 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2734 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2735 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2736 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2737 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2738 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2739 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2740 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2741 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2742 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2743 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2744 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2745 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2746 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2747 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2748 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2749 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2750 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2751 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2752 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2753 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2754 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2755 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2756 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2757 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2758 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2759 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2760 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2761 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2762 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2763 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2764 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2765 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2766 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
2767 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2768 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2769 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2770 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2771 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2772 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2773 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2774 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2775 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2776 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2777 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2781 static const yytype_int16 yycheck[] =
2783 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2784 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2785 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2786 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2787 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2788 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2789 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2790 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2791 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2792 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2793 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2794 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2795 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2796 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2797 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2798 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2799 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2800 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2801 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2802 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2803 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2804 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2805 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2806 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2807 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2808 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2809 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2810 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2811 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2812 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2813 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2814 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2815 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2816 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2817 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2818 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2819 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2820 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2821 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2822 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2823 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2824 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2825 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2826 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2827 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2828 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2829 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2830 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2831 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2832 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2833 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2834 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
2835 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
2836 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2837 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2838 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2839 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2840 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2841 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2842 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2843 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2844 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2845 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2846 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2847 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2848 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2849 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2850 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2851 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2852 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2853 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2854 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2855 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2856 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2857 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2858 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2859 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2860 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2861 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2862 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2863 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2864 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2865 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2866 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2867 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2868 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2869 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2870 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2871 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2872 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2873 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2874 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2875 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2876 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2877 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2878 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2879 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2880 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2881 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2882 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2883 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2884 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2885 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2886 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2887 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2888 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2889 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2890 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2891 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2892 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2893 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2894 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2895 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2896 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2897 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2898 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2899 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2900 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2901 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2902 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2903 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2904 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2905 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2906 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2907 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2908 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2909 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2910 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2911 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2912 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2913 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2914 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2915 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2916 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2917 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2918 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2919 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2920 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2921 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2922 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2923 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2924 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2925 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2926 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2927 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2928 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2929 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2930 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2931 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2932 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2933 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2934 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2935 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2936 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2937 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2938 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2939 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2940 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2941 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2942 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2943 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2944 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2945 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2946 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2947 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2948 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2949 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2950 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2951 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2952 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2953 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2957 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2958 symbol of state STATE-NUM. */
2959 static const yytype_uint8 yystos[] =
2961 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2962 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2963 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2964 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2965 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2966 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2967 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2968 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2969 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2970 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2971 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2972 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2973 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2974 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2975 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2976 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2977 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2978 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2979 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2980 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2981 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2982 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2983 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2984 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2985 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2986 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2987 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2988 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2989 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2990 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2991 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2992 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2993 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2994 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2995 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2996 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2997 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2998 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2999 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
3000 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
3001 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
3002 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
3003 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
3004 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
3005 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
3006 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
3007 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
3008 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
3009 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
3010 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
3011 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
3012 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
3013 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
3014 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
3015 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3016 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
3017 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
3018 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
3019 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
3020 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
3024 #define yyerrok (yyerrstatus = 0)
3025 #define yyclearin (yychar = YYEMPTY)
3026 #define YYEMPTY (-2)
3029 #define YYACCEPT goto yyacceptlab
3030 #define YYABORT goto yyabortlab
3031 #define YYERROR goto yyerrorlab
3034 /* Like YYERROR except do call yyerror. This remains here temporarily
3035 to ease the transition to the new meaning of YYERROR, for GCC.
3036 Once GCC version 2 has supplanted version 1, this can go. */
3038 #define YYFAIL goto yyerrlab
3040 #define YYRECOVERING() (!!yyerrstatus)
3042 #define YYBACKUP(Token, Value) \
3044 if (yychar == YYEMPTY && yylen == 1) \
3048 yytoken = YYTRANSLATE (yychar); \
3054 yyerror (YY_("syntax error: cannot back up")); \
3061 #define YYERRCODE 256
3064 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3065 If N is 0, then set CURRENT to the empty location which ends
3066 the previous symbol: RHS[0] (always defined). */
3068 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
3069 #ifndef YYLLOC_DEFAULT
3070 # define YYLLOC_DEFAULT(Current, Rhs, N) \
3074 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3075 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3076 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3077 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3081 (Current).first_line = (Current).last_line = \
3082 YYRHSLOC (Rhs, 0).last_line; \
3083 (Current).first_column = (Current).last_column = \
3084 YYRHSLOC (Rhs, 0).last_column; \
3090 /* YY_LOCATION_PRINT -- Print the location on the stream.
3091 This macro was not mandated originally: define only if we know
3092 we won't break user code: when these are the locations we know. */
3094 #ifndef YY_LOCATION_PRINT
3095 # if YYLTYPE_IS_TRIVIAL
3096 # define YY_LOCATION_PRINT(File, Loc) \
3097 fprintf (File, "%d.%d-%d.%d", \
3098 (Loc).first_line, (Loc).first_column, \
3099 (Loc).last_line, (Loc).last_column)
3101 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3106 /* YYLEX -- calling `yylex' with the right arguments. */
3109 # define YYLEX yylex (YYLEX_PARAM)
3111 # define YYLEX yylex ()
3114 /* Enable debugging if requested. */
3118 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3119 # define YYFPRINTF fprintf
3122 # define YYDPRINTF(Args) \
3128 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3132 YYFPRINTF (stderr, "%s ", Title); \
3133 yy_symbol_print (stderr, \
3135 YYFPRINTF (stderr, "\n"); \
3140 /*--------------------------------.
3141 | Print this symbol on YYOUTPUT. |
3142 `--------------------------------*/
3145 #if (defined __STDC__ || defined __C99__FUNC__ \
3146 || defined __cplusplus || defined _MSC_VER)
3148 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3151 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
3154 YYSTYPE const * const yyvaluep;
3160 if (yytype < YYNTOKENS)
3161 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3173 /*--------------------------------.
3174 | Print this symbol on YYOUTPUT. |
3175 `--------------------------------*/
3177 #if (defined __STDC__ || defined __C99__FUNC__ \
3178 || defined __cplusplus || defined _MSC_VER)
3180 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3183 yy_symbol_print (yyoutput, yytype, yyvaluep)
3186 YYSTYPE const * const yyvaluep;
3189 if (yytype < YYNTOKENS)
3190 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3192 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3194 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3195 YYFPRINTF (yyoutput, ")");
3198 /*------------------------------------------------------------------.
3199 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
3201 `------------------------------------------------------------------*/
3203 #if (defined __STDC__ || defined __C99__FUNC__ \
3204 || defined __cplusplus || defined _MSC_VER)
3206 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3209 yy_stack_print (bottom, top)
3210 yytype_int16 *bottom;
3214 YYFPRINTF (stderr, "Stack now");
3215 for (; bottom <= top; ++bottom)
3216 YYFPRINTF (stderr, " %d", *bottom);
3217 YYFPRINTF (stderr, "\n");
3220 # define YY_STACK_PRINT(Bottom, Top) \
3223 yy_stack_print ((Bottom), (Top)); \
3227 /*------------------------------------------------.
3228 | Report that the YYRULE is going to be reduced. |
3229 `------------------------------------------------*/
3231 #if (defined __STDC__ || defined __C99__FUNC__ \
3232 || defined __cplusplus || defined _MSC_VER)
3234 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3237 yy_reduce_print (yyvsp, yyrule)
3242 int yynrhs = yyr2[yyrule];
3244 unsigned long int yylno = yyrline[yyrule];
3245 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3247 /* The symbols being reduced. */
3248 for (yyi = 0; yyi < yynrhs; yyi++)
3250 fprintf (stderr, " $%d = ", yyi + 1);
3251 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3252 &(yyvsp[(yyi + 1) - (yynrhs)])
3254 fprintf (stderr, "\n");
3258 # define YY_REDUCE_PRINT(Rule) \
3261 yy_reduce_print (yyvsp, Rule); \
3264 /* Nonzero means print parse trace. It is left uninitialized so that
3265 multiple parsers can coexist. */
3267 #else /* !YYDEBUG */
3268 # define YYDPRINTF(Args)
3269 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3270 # define YY_STACK_PRINT(Bottom, Top)
3271 # define YY_REDUCE_PRINT(Rule)
3272 #endif /* !YYDEBUG */
3275 /* YYINITDEPTH -- initial size of the parser's stacks. */
3277 # define YYINITDEPTH 200
3280 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3281 if the built-in stack extension method is used).
3283 Do not make this value too large; the results are undefined if
3284 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3285 evaluated with infinite-precision integer arithmetic. */
3288 # define YYMAXDEPTH 10000
3296 # if defined __GLIBC__ && defined _STRING_H
3297 # define yystrlen strlen
3299 /* Return the length of YYSTR. */
3300 #if (defined __STDC__ || defined __C99__FUNC__ \
3301 || defined __cplusplus || defined _MSC_VER)
3303 yystrlen (const char *yystr)
3311 for (yylen = 0; yystr[yylen]; yylen++)
3319 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3320 # define yystpcpy stpcpy
3322 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3324 #if (defined __STDC__ || defined __C99__FUNC__ \
3325 || defined __cplusplus || defined _MSC_VER)
3327 yystpcpy (char *yydest, const char *yysrc)
3330 yystpcpy (yydest, yysrc)
3336 const char *yys = yysrc;
3338 while ((*yyd++ = *yys++) != '\0')
3347 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3348 quotes and backslashes, so that it's suitable for yyerror. The
3349 heuristic is that double-quoting is unnecessary unless the string
3350 contains an apostrophe, a comma, or backslash (other than
3351 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3352 null, do not copy; instead, return the length of what the result
3355 yytnamerr (char *yyres, const char *yystr)
3360 char const *yyp = yystr;
3367 goto do_not_strip_quotes;
3371 goto do_not_strip_quotes;
3384 do_not_strip_quotes: ;
3388 return yystrlen (yystr);
3390 return yystpcpy (yyres, yystr) - yyres;
3394 /* Copy into YYRESULT an error message about the unexpected token
3395 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3396 including the terminating null byte. If YYRESULT is null, do not
3397 copy anything; just return the number of bytes that would be
3398 copied. As a special case, return 0 if an ordinary "syntax error"
3399 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3400 size calculation. */
3402 yysyntax_error (char *yyresult, int yystate, int yychar)
3404 int yyn = yypact[yystate];
3406 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3410 int yytype = YYTRANSLATE (yychar);
3411 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3412 YYSIZE_T yysize = yysize0;
3414 int yysize_overflow = 0;
3415 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3416 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3420 /* This is so xgettext sees the translatable formats that are
3421 constructed on the fly. */
3422 YY_("syntax error, unexpected %s");
3423 YY_("syntax error, unexpected %s, expecting %s");
3424 YY_("syntax error, unexpected %s, expecting %s or %s");
3425 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3426 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3430 static char const yyunexpected[] = "syntax error, unexpected %s";
3431 static char const yyexpecting[] = ", expecting %s";
3432 static char const yyor[] = " or %s";
3433 char yyformat[sizeof yyunexpected
3434 + sizeof yyexpecting - 1
3435 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3436 * (sizeof yyor - 1))];
3437 char const *yyprefix = yyexpecting;
3439 /* Start YYX at -YYN if negative to avoid negative indexes in
3441 int yyxbegin = yyn < 0 ? -yyn : 0;
3443 /* Stay within bounds of both yycheck and yytname. */
3444 int yychecklim = YYLAST - yyn + 1;
3445 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3448 yyarg[0] = yytname[yytype];
3449 yyfmt = yystpcpy (yyformat, yyunexpected);
3451 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3452 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3454 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3458 yyformat[sizeof yyunexpected - 1] = '\0';
3461 yyarg[yycount++] = yytname[yyx];
3462 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3463 yysize_overflow |= (yysize1 < yysize);
3465 yyfmt = yystpcpy (yyfmt, yyprefix);
3469 yyf = YY_(yyformat);
3470 yysize1 = yysize + yystrlen (yyf);
3471 yysize_overflow |= (yysize1 < yysize);
3474 if (yysize_overflow)
3475 return YYSIZE_MAXIMUM;
3479 /* Avoid sprintf, as that infringes on the user's name space.
3480 Don't have undefined behavior even if the translation
3481 produced a string with the wrong number of "%s"s. */
3482 char *yyp = yyresult;
3484 while ((*yyp = *yyf) != '\0')
3486 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3488 yyp += yytnamerr (yyp, yyarg[yyi++]);
3501 #endif /* YYERROR_VERBOSE */
3504 /*-----------------------------------------------.
3505 | Release the memory associated to this symbol. |
3506 `-----------------------------------------------*/
3509 #if (defined __STDC__ || defined __C99__FUNC__ \
3510 || defined __cplusplus || defined _MSC_VER)
3512 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3515 yydestruct (yymsg, yytype, yyvaluep)
3525 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3536 /* Prevent warnings from -Wmissing-prototypes. */
3538 #ifdef YYPARSE_PARAM
3539 #if defined __STDC__ || defined __cplusplus
3540 int yyparse (void *YYPARSE_PARAM);
3544 #else /* ! YYPARSE_PARAM */
3545 #if defined __STDC__ || defined __cplusplus
3550 #endif /* ! YYPARSE_PARAM */
3554 /* The look-ahead symbol. */
3557 /* The semantic value of the look-ahead symbol. */
3560 /* Number of syntax errors so far. */
3569 #ifdef YYPARSE_PARAM
3570 #if (defined __STDC__ || defined __C99__FUNC__ \
3571 || defined __cplusplus || defined _MSC_VER)
3573 yyparse (void *YYPARSE_PARAM)
3576 yyparse (YYPARSE_PARAM)
3577 void *YYPARSE_PARAM;
3579 #else /* ! YYPARSE_PARAM */
3580 #if (defined __STDC__ || defined __C99__FUNC__ \
3581 || defined __cplusplus || defined _MSC_VER)
3595 /* Number of tokens to shift before error messages enabled. */
3597 /* Look-ahead token as an internal (translated) token number. */
3600 /* Buffer for error messages, and its allocated size. */
3602 char *yymsg = yymsgbuf;
3603 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3606 /* Three stacks and their tools:
3607 `yyss': related to states,
3608 `yyvs': related to semantic values,
3609 `yyls': related to locations.
3611 Refer to the stacks thru separate pointers, to allow yyoverflow
3612 to reallocate them elsewhere. */
3614 /* The state stack. */
3615 yytype_int16 yyssa[YYINITDEPTH];
3616 yytype_int16 *yyss = yyssa;
3617 yytype_int16 *yyssp;
3619 /* The semantic value stack. */
3620 YYSTYPE yyvsa[YYINITDEPTH];
3621 YYSTYPE *yyvs = yyvsa;
3626 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3628 YYSIZE_T yystacksize = YYINITDEPTH;
3630 /* The variables used to return semantic value and location from the
3635 /* The number of symbols on the RHS of the reduced rule.
3636 Keep to zero when no symbol should be popped. */
3639 YYDPRINTF ((stderr, "Starting parse\n"));
3644 yychar = YYEMPTY; /* Cause a token to be read. */
3646 /* Initialize stack pointers.
3647 Waste one element of value and location stack
3648 so that they stay on the same level as the state stack.
3649 The wasted elements are never initialized. */
3656 /*------------------------------------------------------------.
3657 | yynewstate -- Push a new state, which is found in yystate. |
3658 `------------------------------------------------------------*/
3660 /* In all cases, when you get here, the value and location stacks
3661 have just been pushed. So pushing a state here evens the stacks. */
3667 if (yyss + yystacksize - 1 <= yyssp)
3669 /* Get the current used size of the three stacks, in elements. */
3670 YYSIZE_T yysize = yyssp - yyss + 1;
3674 /* Give user a chance to reallocate the stack. Use copies of
3675 these so that the &'s don't force the real ones into
3677 YYSTYPE *yyvs1 = yyvs;
3678 yytype_int16 *yyss1 = yyss;
3681 /* Each stack pointer address is followed by the size of the
3682 data in use in that stack, in bytes. This used to be a
3683 conditional around just the two extra args, but that might
3684 be undefined if yyoverflow is a macro. */
3685 yyoverflow (YY_("memory exhausted"),
3686 &yyss1, yysize * sizeof (*yyssp),
3687 &yyvs1, yysize * sizeof (*yyvsp),
3694 #else /* no yyoverflow */
3695 # ifndef YYSTACK_RELOCATE
3696 goto yyexhaustedlab;
3698 /* Extend the stack our own way. */
3699 if (YYMAXDEPTH <= yystacksize)
3700 goto yyexhaustedlab;
3702 if (YYMAXDEPTH < yystacksize)
3703 yystacksize = YYMAXDEPTH;
3706 yytype_int16 *yyss1 = yyss;
3707 union yyalloc *yyptr =
3708 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3710 goto yyexhaustedlab;
3711 YYSTACK_RELOCATE (yyss);
3712 YYSTACK_RELOCATE (yyvs);
3714 # undef YYSTACK_RELOCATE
3716 YYSTACK_FREE (yyss1);
3719 #endif /* no yyoverflow */
3721 yyssp = yyss + yysize - 1;
3722 yyvsp = yyvs + yysize - 1;
3725 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3726 (unsigned long int) yystacksize));
3728 if (yyss + yystacksize - 1 <= yyssp)
3732 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
3741 /* Do appropriate processing given the current state. Read a
3742 look-ahead token if we need one and don't already have one. */
3744 /* First try to decide what to do without reference to look-ahead token. */
3745 yyn = yypact[yystate];
3746 if (yyn == YYPACT_NINF)
3749 /* Not known => get a look-ahead token if don't already have one. */
3751 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
3752 if (yychar == YYEMPTY)
3754 YYDPRINTF ((stderr, "Reading a token: "));
3758 if (yychar <= YYEOF)
3760 yychar = yytoken = YYEOF;
3761 YYDPRINTF ((stderr, "Now at end of input.\n"));
3765 yytoken = YYTRANSLATE (yychar);
3766 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
3769 /* If the proper action on seeing token YYTOKEN is to reduce or to
3770 detect an error, take that action. */
3772 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
3777 if (yyn == 0 || yyn == YYTABLE_NINF)
3786 /* Count tokens shifted since error; after three, turn off error
3791 /* Shift the look-ahead token. */
3792 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3794 /* Discard the shifted token unless it is eof. */
3795 if (yychar != YYEOF)
3804 /*-----------------------------------------------------------.
3805 | yydefault -- do the default action for the current state. |
3806 `-----------------------------------------------------------*/
3808 yyn = yydefact[yystate];
3814 /*-----------------------------.
3815 | yyreduce -- Do a reduction. |
3816 `-----------------------------*/
3818 /* yyn is the number of a rule to reduce with. */
3821 /* If YYLEN is nonzero, implement the default value of the action:
3824 Otherwise, the following line sets YYVAL to garbage.
3825 This behavior is undocumented and Bison
3826 users should not rely upon it. Assigning to YYVAL
3827 unconditionally makes the parser a bit smaller, and it avoids a
3828 GCC warning that YYVAL may be used uninitialized. */
3829 yyval = yyvsp[1-yylen];
3832 YY_REDUCE_PRINT (yyn);
3836 #line 1532 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3838 if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
3839 error("Value too large for type");
3840 (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
3845 #line 1541 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3847 if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
3848 error("Value too large for type");
3849 (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
3854 #line 1563 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3855 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3859 #line 1563 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3860 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3864 #line 1564 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3865 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3869 #line 1564 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3870 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3874 #line 1565 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3875 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3879 #line 1565 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3880 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3884 #line 1566 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3885 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3889 #line 1566 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3890 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3894 #line 1567 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3895 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3899 #line 1567 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3900 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3904 #line 1571 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3905 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3909 #line 1571 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3910 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3914 #line 1572 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3915 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3919 #line 1572 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3920 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3924 #line 1573 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3925 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3929 #line 1573 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3930 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3934 #line 1574 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3935 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3939 #line 1574 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3940 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3944 #line 1575 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3945 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3949 #line 1575 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3950 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3954 #line 1576 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3955 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3959 #line 1576 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3960 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3964 #line 1577 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3965 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3969 #line 1577 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3970 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3974 #line 1578 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3975 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3979 #line 1579 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3980 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3984 #line 1610 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3986 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
3991 #line 1613 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3998 #line 1618 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3999 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
4003 #line 1619 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4004 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
4008 #line 1620 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4009 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
4013 #line 1621 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4014 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
4018 #line 1622 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4019 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
4023 #line 1623 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4024 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
4028 #line 1624 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4029 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
4033 #line 1625 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4034 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
4038 #line 1629 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4039 { (yyval.UIntVal) = CallingConv::C; ;}
4043 #line 1630 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4044 { (yyval.UIntVal) = CallingConv::C; ;}
4048 #line 1631 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4049 { (yyval.UIntVal) = CallingConv::C; ;}
4053 #line 1632 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4054 { (yyval.UIntVal) = CallingConv::Fast; ;}
4058 #line 1633 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4059 { (yyval.UIntVal) = CallingConv::Cold; ;}
4063 #line 1634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4064 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
4068 #line 1635 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4069 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
4073 #line 1636 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4075 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
4076 error("Calling conv too large");
4077 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4082 #line 1646 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4083 { (yyval.UIntVal) = 0; ;}
4087 #line 1647 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4089 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4090 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4091 error("Alignment must be a power of two");
4096 #line 1655 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4097 { (yyval.UIntVal) = 0; ;}
4101 #line 1656 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4103 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4104 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4105 error("Alignment must be a power of two");
4110 #line 1664 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4112 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
4113 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
4114 error("Invalid character in section name");
4115 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4120 #line 1673 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4121 { (yyval.StrVal) = 0; ;}
4125 #line 1674 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4126 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4130 #line 1681 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4135 #line 1682 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4140 #line 1686 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4142 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
4143 free((yyvsp[(1) - (1)].StrVal));
4148 #line 1690 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4150 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
4151 error("Alignment must be a power of two");
4152 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
4158 #line 1707 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4160 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4161 (yyval.TypeVal).S = Signless;
4166 #line 1715 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4168 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4169 (yyval.TypeVal).S = Signless;
4174 #line 1722 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4176 if (!UpRefs.empty())
4177 error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).T)->getDescription());
4178 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4183 #line 1736 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4185 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4186 (yyval.TypeVal).S = (yyvsp[(1) - (1)].PrimType).S;
4191 #line 1740 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4193 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4194 (yyval.TypeVal).S = Signless;
4199 #line 1744 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4200 { // Named types are also simple types...
4201 const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
4202 (yyval.TypeVal).T = new PATypeHolder(tmp);
4203 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4208 #line 1749 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4209 { // Type UpReference
4210 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U)
4211 error("Value out of range");
4212 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
4213 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4214 (yyval.TypeVal).T = new PATypeHolder(OT);
4215 (yyval.TypeVal).S = Signless;
4216 UR_OUT("New Upreference!\n");
4221 #line 1758 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4222 { // Function derived type?
4223 std::vector<const Type*> Params;
4224 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
4225 E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
4226 Params.push_back(I->T->get());
4229 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4230 if (isVarArg) Params.pop_back();
4232 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
4233 FunctionType::get((yyvsp[(1) - (4)].TypeVal).T->get(),Params,isVarArg)));
4234 (yyval.TypeVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4235 delete (yyvsp[(1) - (4)].TypeVal).T; // Delete the return type handle
4236 delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list
4241 #line 1774 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4242 { // Sized array type?
4243 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).T->get(),
4244 (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4245 (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4246 delete (yyvsp[(4) - (5)].TypeVal).T;
4251 #line 1780 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4252 { // Packed array type?
4253 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).T->get();
4254 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
4255 error("Unsigned result not equal to signed result");
4256 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4257 error("Elements of a PackedType must be integer or floating point");
4258 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
4259 error("PackedType length should be a power of 2");
4260 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
4261 (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4262 (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4263 delete (yyvsp[(4) - (5)].TypeVal).T;
4268 #line 1793 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4269 { // Structure type?
4270 std::vector<const Type*> Elements;
4271 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4272 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
4273 Elements.push_back(I->T->get());
4274 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4275 (yyval.TypeVal).S = Signless;
4276 delete (yyvsp[(2) - (3)].TypeList);
4281 #line 1802 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4282 { // Empty structure type?
4283 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4284 (yyval.TypeVal).S = Signless;
4289 #line 1806 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4290 { // Packed Structure type?
4291 std::vector<const Type*> Elements;
4292 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4293 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
4294 Elements.push_back(I->T->get());
4297 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4298 (yyval.TypeVal).S = Signless;
4299 delete (yyvsp[(3) - (5)].TypeList);
4304 #line 1817 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4305 { // Empty packed structure type?
4306 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4307 (yyval.TypeVal).S = Signless;
4312 #line 1821 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4314 if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::LabelTy)
4315 error("Cannot form a pointer to a basic block");
4316 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).T->get())));
4317 (yyval.TypeVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4318 delete (yyvsp[(1) - (2)].TypeVal).T;
4323 #line 1834 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4325 (yyval.TypeList) = new std::list<PATypeInfo>();
4326 (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal));
4331 #line 1838 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4333 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
4338 #line 1846 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4341 VoidTI.T = new PATypeHolder(Type::VoidTy);
4342 VoidTI.S = Signless;
4343 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
4348 #line 1852 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4350 (yyval.TypeList) = new std::list<PATypeInfo>();
4352 VoidTI.T = new PATypeHolder(Type::VoidTy);
4353 VoidTI.S = Signless;
4354 (yyval.TypeList)->push_back(VoidTI);
4359 #line 1859 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4361 (yyval.TypeList) = new std::list<PATypeInfo>();
4366 #line 1871 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4367 { // Nonempty unsized arr
4368 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).T->get());
4370 error("Cannot make array constant with type: '" +
4371 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4372 const Type *ETy = ATy->getElementType();
4373 int NumElements = ATy->getNumElements();
4375 // Verify that we have the correct size...
4376 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4377 error("Type mismatch: constant sized array initialized with " +
4378 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
4379 itostr(NumElements) + "");
4381 // Verify all elements are correct type!
4382 std::vector<Constant*> Elems;
4383 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4384 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4385 const Type* ValTy = C->getType();
4387 error("Element #" + utostr(i) + " is not of type '" +
4388 ETy->getDescription() +"' as required!\nIt is of type '"+
4389 ValTy->getDescription() + "'");
4392 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4393 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4394 delete (yyvsp[(1) - (4)].TypeVal).T;
4395 delete (yyvsp[(3) - (4)].ConstVector);
4400 #line 1901 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4402 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
4404 error("Cannot make array constant with type: '" +
4405 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4406 int NumElements = ATy->getNumElements();
4407 if (NumElements != -1 && NumElements != 0)
4408 error("Type mismatch: constant sized array initialized with 0"
4409 " arguments, but has size of " + itostr(NumElements) +"");
4410 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4411 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4412 delete (yyvsp[(1) - (3)].TypeVal).T;
4417 #line 1914 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4419 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
4421 error("Cannot make array constant with type: '" +
4422 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4423 int NumElements = ATy->getNumElements();
4424 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4425 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4426 error("String arrays require type i8, not '" + ETy->getDescription() +
4428 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4429 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
4430 error("Can't build string constant of size " +
4431 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " +
4432 itostr(NumElements) + "");
4433 std::vector<Constant*> Vals;
4434 for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
4435 Vals.push_back(ConstantInt::get(ETy, *C));
4436 free((yyvsp[(3) - (3)].StrVal));
4437 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4438 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4439 delete (yyvsp[(1) - (3)].TypeVal).T;
4444 #line 1937 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4445 { // Nonempty unsized arr
4446 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[(1) - (4)].TypeVal).T->get());
4448 error("Cannot make packed constant with type: '" +
4449 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4450 const Type *ETy = PTy->getElementType();
4451 int NumElements = PTy->getNumElements();
4452 // Verify that we have the correct size...
4453 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4454 error("Type mismatch: constant sized packed initialized with " +
4455 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
4456 itostr(NumElements) + "");
4457 // Verify all elements are correct type!
4458 std::vector<Constant*> Elems;
4459 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4460 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4461 const Type* ValTy = C->getType();
4463 error("Element #" + utostr(i) + " is not of type '" +
4464 ETy->getDescription() +"' as required!\nIt is of type '"+
4465 ValTy->getDescription() + "'");
4468 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
4469 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4470 delete (yyvsp[(1) - (4)].TypeVal).T;
4471 delete (yyvsp[(3) - (4)].ConstVector);
4476 #line 1965 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4478 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).T->get());
4480 error("Cannot make struct constant with type: '" +
4481 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4482 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
4483 error("Illegal number of initializers for structure type");
4485 // Check to ensure that constants are compatible with the type initializer!
4486 std::vector<Constant*> Fields;
4487 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
4488 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4489 if (C->getType() != STy->getElementType(i))
4490 error("Expected type '" + STy->getElementType(i)->getDescription() +
4491 "' for element #" + utostr(i) + " of structure initializer");
4492 Fields.push_back(C);
4494 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4495 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4496 delete (yyvsp[(1) - (4)].TypeVal).T;
4497 delete (yyvsp[(3) - (4)].ConstVector);
4502 #line 1987 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4504 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).T->get());
4506 error("Cannot make struct constant with type: '" +
4507 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4508 if (STy->getNumContainedTypes() != 0)
4509 error("Illegal number of initializers for structure type");
4510 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4511 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4512 delete (yyvsp[(1) - (3)].TypeVal).T;
4517 #line 1998 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4519 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).T->get());
4521 error("Cannot make packed struct constant with type: '" +
4522 (yyvsp[(1) - (6)].TypeVal).T->get()->getDescription() + "'");
4523 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
4524 error("Illegal number of initializers for packed structure type");
4526 // Check to ensure that constants are compatible with the type initializer!
4527 std::vector<Constant*> Fields;
4528 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
4529 Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
4530 if (C->getType() != STy->getElementType(i))
4531 error("Expected type '" + STy->getElementType(i)->getDescription() +
4532 "' for element #" + utostr(i) + " of packed struct initializer");
4533 Fields.push_back(C);
4535 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4536 (yyval.ConstVal).S = (yyvsp[(1) - (6)].TypeVal).S;
4537 delete (yyvsp[(1) - (6)].TypeVal).T;
4538 delete (yyvsp[(4) - (6)].ConstVector);
4543 #line 2020 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4545 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).T->get());
4547 error("Cannot make packed struct constant with type: '" +
4548 (yyvsp[(1) - (5)].TypeVal).T->get()->getDescription() + "'");
4549 if (STy->getNumContainedTypes() != 0)
4550 error("Illegal number of initializers for packed structure type");
4551 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4552 (yyval.ConstVal).S = (yyvsp[(1) - (5)].TypeVal).S;
4553 delete (yyvsp[(1) - (5)].TypeVal).T;
4558 #line 2031 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4560 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
4562 error("Cannot make null pointer constant with type: '" +
4563 (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription() + "'");
4564 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4565 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4566 delete (yyvsp[(1) - (2)].TypeVal).T;
4571 #line 2040 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4573 (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).T->get());
4574 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4575 delete (yyvsp[(1) - (2)].TypeVal).T;
4580 #line 2045 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4582 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
4584 error("Global const reference must be a pointer type, not" +
4585 (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription());
4587 // ConstExprs can exist in the body of a function, thus creating
4588 // GlobalValues whenever they refer to a variable. Because we are in
4589 // the context of a function, getExistingValue will search the functions
4590 // symbol table instead of the module symbol table for the global symbol,
4591 // which throws things all off. To get around this, we just tell
4592 // getExistingValue that we are at global scope here.
4594 Function *SavedCurFn = CurFun.CurrentFunction;
4595 CurFun.CurrentFunction = 0;
4596 Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
4597 CurFun.CurrentFunction = SavedCurFn;
4599 // If this is an initializer for a constant pointer, which is referencing a
4600 // (currently) undefined variable, create a stub now that shall be replaced
4601 // in the future with the right type of variable.
4604 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4605 const PointerType *PT = cast<PointerType>(Ty);
4607 // First check to see if the forward references value is already created!
4608 PerModuleInfo::GlobalRefsType::iterator I =
4609 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
4611 if (I != CurModule.GlobalRefs.end()) {
4612 V = I->second; // Placeholder already exists, use it...
4613 (yyvsp[(2) - (2)].ValIDVal).destroy();
4616 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4618 // Create the forward referenced global.
4620 if (const FunctionType *FTy =
4621 dyn_cast<FunctionType>(PT->getElementType())) {
4622 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4623 CurModule.CurrentModule);
4625 GV = new GlobalVariable(PT->getElementType(), false,
4626 GlobalValue::ExternalLinkage, 0,
4627 Name, CurModule.CurrentModule);
4630 // Keep track of the fact that we have a forward ref to recycle it
4631 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
4635 (yyval.ConstVal).C = cast<GlobalValue>(V);
4636 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4637 delete (yyvsp[(1) - (2)].TypeVal).T; // Free the type handle
4642 #line 2103 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4644 if ((yyvsp[(1) - (2)].TypeVal).T->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
4645 error("Mismatched types for constant expression");
4646 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4647 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4648 delete (yyvsp[(1) - (2)].TypeVal).T;
4653 #line 2110 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4655 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
4656 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4657 error("Cannot create a null initialized value of this type");
4658 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4659 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4660 delete (yyvsp[(1) - (2)].TypeVal).T;
4665 #line 2118 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4666 { // integral constants
4667 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4668 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
4669 error("Constant value doesn't fit in type");
4670 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
4671 (yyval.ConstVal).S = Signed;
4676 #line 2125 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4677 { // integral constants
4678 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4679 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
4680 error("Constant value doesn't fit in type");
4681 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
4682 (yyval.ConstVal).S = Unsigned;
4687 #line 2132 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4688 { // Boolean constants
4689 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4690 (yyval.ConstVal).S = Unsigned;
4695 #line 2136 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4696 { // Boolean constants
4697 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4698 (yyval.ConstVal).S = Unsigned;
4703 #line 2140 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4704 { // Float & Double constants
4705 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal)))
4706 error("Floating point constant invalid for type");
4707 (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal));
4708 (yyval.ConstVal).S = Signless;
4713 #line 2149 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4715 const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
4716 const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).T->get();
4717 Signedness SrcSign = (yyvsp[(3) - (6)].ConstVal).S;
4718 Signedness DstSign = (yyvsp[(5) - (6)].TypeVal).S;
4719 if (!SrcTy->isFirstClassType())
4720 error("cast constant expression from a non-primitive type: '" +
4721 SrcTy->getDescription() + "'");
4722 if (!DstTy->isFirstClassType())
4723 error("cast constant expression to a non-primitive type: '" +
4724 DstTy->getDescription() + "'");
4725 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign));
4726 (yyval.ConstVal).S = DstSign;
4727 delete (yyvsp[(5) - (6)].TypeVal).T;
4732 #line 2164 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4734 const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
4735 if (!isa<PointerType>(Ty))
4736 error("GetElementPtr requires a pointer operand");
4738 std::vector<Value*> VIndices;
4739 std::vector<Constant*> CIndices;
4740 upgradeGEPIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), VIndices, &CIndices);
4742 delete (yyvsp[(4) - (5)].ValueList);
4743 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, CIndices);
4744 (yyval.ConstVal).S = Signless;
4749 #line 2177 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4751 if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
4752 cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
4753 error("Select condition must be bool type");
4754 if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
4755 error("Select operand types must match");
4756 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4757 (yyval.ConstVal).S = Unsigned;
4762 #line 2186 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4764 const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4765 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4766 error("Binary operator types must match");
4767 // First, make sure we're dealing with the right opcode by upgrading from
4768 // obsolete versions.
4769 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
4771 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4772 // To retain backward compatibility with these early compilers, we emit a
4773 // cast to the appropriate integer type automatically if we are in the
4774 // broken case. See PR424 for more information.
4775 if (!isa<PointerType>(Ty)) {
4776 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4778 const Type *IntPtrTy = 0;
4779 switch (CurModule.CurrentModule->getPointerSize()) {
4780 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4781 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4782 default: error("invalid pointer binary constant expr");
4784 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4785 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
4786 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
4787 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4789 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4794 #line 2214 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4796 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4797 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4798 error("Logical operator types must match");
4799 if (!Ty->isInteger()) {
4800 if (!isa<PackedType>(Ty) ||
4801 !cast<PackedType>(Ty)->getElementType()->isInteger())
4802 error("Logical operator requires integer operands");
4804 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
4805 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4806 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4811 #line 2227 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4813 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4814 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4815 error("setcc operand types must match");
4816 unsigned short pred;
4817 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
4818 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4819 (yyval.ConstVal).S = Unsigned;
4824 #line 2236 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4826 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
4827 error("icmp operand types must match");
4828 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
4829 (yyval.ConstVal).S = Unsigned;
4834 #line 2242 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4836 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
4837 error("fcmp operand types must match");
4838 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
4839 (yyval.ConstVal).S = Unsigned;
4844 #line 2248 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4846 if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
4847 cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
4848 error("Shift count for shift constant must be unsigned byte");
4849 if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
4850 error("Shift constant expression requires integer operand");
4851 (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);
4852 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4857 #line 2257 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4859 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
4860 error("Invalid extractelement operands");
4861 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4862 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4867 #line 2263 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4869 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
4870 error("Invalid insertelement operands");
4871 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4872 (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
4877 #line 2269 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4879 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
4880 error("Invalid shufflevector operands");
4881 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4882 (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
4887 #line 2280 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4888 { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
4892 #line 2281 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4894 (yyval.ConstVector) = new std::vector<ConstInfo>();
4895 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
4900 #line 2290 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4901 { (yyval.BoolVal) = false; ;}
4905 #line 2291 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4906 { (yyval.BoolVal) = true; ;}
4910 #line 2303 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4912 (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
4913 CurModule.ModuleDone();
4918 #line 2312 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4919 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
4923 #line 2313 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4924 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
4928 #line 2314 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4929 { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
4933 #line 2315 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4934 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
4938 #line 2316 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4940 (yyval.ModuleVal) = CurModule.CurrentModule;
4941 // Emit an error if there are any unresolved types left.
4942 if (!CurModule.LateResolveTypes.empty()) {
4943 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4944 if (DID.Type == ValID::NameVal) {
4945 error("Reference to an undefined type: '"+DID.getName() + "'");
4947 error("Reference to an undefined type: #" + itostr(DID.Num));
4954 #line 2332 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4956 // Eagerly resolve types. This is not an optimization, this is a
4957 // requirement that is due to the fact that we could have this:
4959 // %list = type { %list * }
4960 // %list = type { %list * } ; repeated type decl
4962 // If types are not resolved eagerly, then the two types will not be
4963 // determined to be the same type!
4965 const Type* Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
4966 ResolveTypeTo((yyvsp[(2) - (4)].StrVal), Ty);
4968 if (!setTypeName(Ty, (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
4969 // If this is a named type that is not a redefinition, add it to the slot
4971 CurModule.Types.push_back(Ty);
4973 delete (yyvsp[(4) - (4)].TypeVal).T;
4978 #line 2352 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4979 { // Function prototypes can be in const pool
4984 #line 2354 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4985 { // Asm blocks can be in the const pool
4990 #line 2356 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4992 if ((yyvsp[(5) - (5)].ConstVal).C == 0)
4993 error("Global value initializer is not a constant");
4994 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);
4999 #line 2360 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5006 #line 2363 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5008 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
5009 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
5010 delete (yyvsp[(5) - (5)].TypeVal).T;
5015 #line 2367 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5022 #line 2370 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5024 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
5025 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
5026 delete (yyvsp[(5) - (5)].TypeVal).T;
5031 #line 2374 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5038 #line 2377 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5040 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
5042 ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
5043 delete (yyvsp[(5) - (5)].TypeVal).T;
5048 #line 2382 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5055 #line 2385 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5061 #line 2387 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5067 #line 2389 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5073 #line 2394 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5075 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5076 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
5077 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
5078 free((yyvsp[(1) - (1)].StrVal));
5080 if (AsmSoFar.empty())
5081 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5083 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
5088 #line 2408 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5089 { (yyval.Endianness) = Module::BigEndian; ;}
5093 #line 2409 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5094 { (yyval.Endianness) = Module::LittleEndian; ;}
5098 #line 2413 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5100 CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
5105 #line 2416 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5107 if ((yyvsp[(3) - (3)].UInt64Val) == 32)
5108 CurModule.setPointerSize(Module::Pointer32);
5109 else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
5110 CurModule.setPointerSize(Module::Pointer64);
5112 error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
5117 #line 2424 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5119 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
5120 free((yyvsp[(3) - (3)].StrVal));
5125 #line 2428 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5127 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
5128 free((yyvsp[(3) - (3)].StrVal));
5133 #line 2439 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5135 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
5136 free((yyvsp[(3) - (3)].StrVal));
5141 #line 2443 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5143 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
5144 free((yyvsp[(1) - (1)].StrVal));
5149 #line 2447 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5154 #line 2460 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5155 { (yyval.StrVal) = 0; ;}
5159 #line 2464 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5161 if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::VoidTy)
5162 error("void typed arguments are invalid");
5163 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
5168 #line 2472 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5170 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5171 (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
5172 delete (yyvsp[(3) - (3)].ArgVal);
5177 #line 2477 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5179 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5180 (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
5181 delete (yyvsp[(1) - (1)].ArgVal);
5186 #line 2485 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5187 { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
5191 #line 2486 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5193 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5195 VoidTI.T = new PATypeHolder(Type::VoidTy);
5196 VoidTI.S = Signless;
5197 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5202 #line 2493 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5204 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5206 VoidTI.T = new PATypeHolder(Type::VoidTy);
5207 VoidTI.S = Signless;
5208 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5213 #line 2500 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5214 { (yyval.ArgList) = 0; ;}
5218 #line 2504 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5220 UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
5221 std::string FunctionName((yyvsp[(3) - (8)].StrVal));
5222 free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory!
5224 const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).T->get();
5226 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5227 error("LLVM functions cannot return aggregate types");
5229 std::vector<const Type*> ParamTypeList;
5231 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5232 // i8*. We check here for those names and override the parameter list
5233 // types to ensure the prototype is correct.
5234 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5235 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5236 } else if (FunctionName == "llvm.va_copy") {
5237 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5238 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5239 } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments...
5240 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5241 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
5242 const Type *Ty = I->first.T->get();
5243 ParamTypeList.push_back(Ty);
5248 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5249 if (isVarArg) ParamTypeList.pop_back();
5251 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
5252 const PointerType *PFT = PointerType::get(FT);
5253 delete (yyvsp[(2) - (8)].TypeVal).T;
5256 if (!FunctionName.empty()) {
5257 ID = ValID::create((char*)FunctionName.c_str());
5259 ID = ValID::create((int)CurModule.Values[PFT].size());
5263 // See if this function was forward referenced. If so, recycle the object.
5264 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5265 // Move the function to the end of the list, from whereever it was
5266 // previously inserted.
5267 Fn = cast<Function>(FWRef);
5268 CurModule.CurrentModule->getFunctionList().remove(Fn);
5269 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5270 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5271 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5272 // If this is the case, either we need to be a forward decl, or it needs
5274 if (!CurFun.isDeclare && !Fn->isExternal())
5275 error("Redefinition of function '" + FunctionName + "'");
5277 // Make sure to strip off any argument names so we can't get conflicts.
5278 if (Fn->isExternal())
5279 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5282 } else { // Not already defined?
5283 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5284 CurModule.CurrentModule);
5286 InsertValue(Fn, CurModule.Values);
5289 CurFun.FunctionStart(Fn);
5291 if (CurFun.isDeclare) {
5292 // If we have declaration, always overwrite linkage. This will allow us
5293 // to correctly handle cases, when pointer to function is passed as
5294 // argument to another function.
5295 Fn->setLinkage(CurFun.Linkage);
5297 Fn->setCallingConv((yyvsp[(1) - (8)].UIntVal));
5298 Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
5299 if ((yyvsp[(7) - (8)].StrVal)) {
5300 Fn->setSection((yyvsp[(7) - (8)].StrVal));
5301 free((yyvsp[(7) - (8)].StrVal));
5304 // Add all of the arguments we parsed to the function...
5305 if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty...
5306 if (isVarArg) { // Nuke the last entry
5307 assert((yyvsp[(5) - (8)].ArgList)->back().first.T->get() == Type::VoidTy &&
5308 (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
5309 delete (yyvsp[(5) - (8)].ArgList)->back().first.T;
5310 (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry
5312 Function::arg_iterator ArgIt = Fn->arg_begin();
5313 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5314 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I, ++ArgIt) {
5315 delete I->first.T; // Delete the typeholder...
5316 setValueName(ArgIt, I->second); // Insert arg into symtab...
5319 delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list
5325 #line 2614 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5327 (yyval.FunctionVal) = CurFun.CurrentFunction;
5329 // Make sure that we keep track of the linkage type even if there was a
5330 // previous "declare".
5331 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (3)].Linkage));
5336 #line 2628 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5338 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5343 #line 2634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5344 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5348 #line 2635 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5349 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5353 #line 2639 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5354 { CurFun.isDeclare = true; ;}
5358 #line 2639 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5360 (yyval.FunctionVal) = CurFun.CurrentFunction;
5361 CurFun.FunctionDone();
5367 #line 2651 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5368 { (yyval.BoolVal) = false; ;}
5372 #line 2652 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5373 { (yyval.BoolVal) = true; ;}
5377 #line 2657 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5378 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
5382 #line 2658 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5383 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
5387 #line 2659 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5388 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
5392 #line 2660 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5393 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
5397 #line 2661 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5398 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5402 #line 2662 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5403 { (yyval.ValIDVal) = ValID::createNull(); ;}
5407 #line 2663 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5408 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5412 #line 2664 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5413 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5417 #line 2665 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5418 { // Nonempty unsized packed vector
5419 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
5420 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
5421 PackedType* pt = PackedType::get(ETy, NumElements);
5422 PATypeHolder* PTy = new PATypeHolder(
5423 HandleUpRefs(PackedType::get(ETy, NumElements)));
5425 // Verify all elements are correct type!
5426 std::vector<Constant*> Elems;
5427 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5428 Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
5429 const Type *CTy = C->getType();
5431 error("Element #" + utostr(i) + " is not of type '" +
5432 ETy->getDescription() +"' as required!\nIt is of type '" +
5433 CTy->getDescription() + "'");
5436 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
5437 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5442 #line 2686 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5444 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
5449 #line 2689 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5451 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5452 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5453 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5454 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5455 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5456 free((yyvsp[(3) - (5)].StrVal));
5457 free((yyvsp[(5) - (5)].StrVal));
5462 #line 2704 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5463 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); ;}
5467 #line 2705 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5468 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); ;}
5472 #line 2718 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5474 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
5475 (yyval.ValueVal).S = (yyvsp[(1) - (2)].TypeVal).S;
5476 (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
5477 delete (yyvsp[(1) - (2)].TypeVal).T;
5482 #line 2727 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5484 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5489 #line 2730 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5490 { // Do not allow functions with 0 basic blocks
5491 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5496 #line 2739 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5498 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
5499 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5500 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5501 InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5502 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5507 #line 2749 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5509 if ((yyvsp[(2) - (2)].InstVal).I)
5510 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
5511 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
5516 #line 2754 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5518 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5519 // Make sure to move the basic block to the correct location in the
5520 // function, instead of leaving it inserted wherever it was first
5522 Function::BasicBlockListType &BBL =
5523 CurFun.CurrentFunction->getBasicBlockList();
5524 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5529 #line 2763 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5531 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
5532 // Make sure to move the basic block to the correct location in the
5533 // function, instead of leaving it inserted wherever it was first
5535 Function::BasicBlockListType &BBL =
5536 CurFun.CurrentFunction->getBasicBlockList();
5537 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5542 #line 2777 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5543 { // Return with a result...
5544 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
5549 #line 2780 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5550 { // Return with no result...
5551 (yyval.TermInstVal) = new ReturnInst();
5556 #line 2783 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5557 { // Unconditional Branch...
5558 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5559 (yyval.TermInstVal) = new BranchInst(tmpBB);
5564 #line 2787 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5566 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5567 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5568 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5569 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5574 #line 2793 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5576 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
5577 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5578 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5579 (yyval.TermInstVal) = S;
5580 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5581 E = (yyvsp[(8) - (9)].JumpTable)->end();
5582 for (; I != E; ++I) {
5583 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5584 S->addCase(CI, I->second);
5586 error("Switch case is constant, but not a simple integer");
5588 delete (yyvsp[(8) - (9)].JumpTable);
5593 #line 2808 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5595 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
5596 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
5597 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5598 (yyval.TermInstVal) = S;
5603 #line 2815 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5605 const PointerType *PFTy;
5606 const FunctionType *Ty;
5608 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).T->get())) ||
5609 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5610 // Pull out the types of all of the arguments...
5611 std::vector<const Type*> ParamTypes;
5612 if ((yyvsp[(6) - (13)].ValueList)) {
5613 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
5615 ParamTypes.push_back((*I).V->getType());
5617 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5618 if (isVarArg) ParamTypes.pop_back();
5619 Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).T->get(), ParamTypes, isVarArg);
5620 PFTy = PointerType::get(Ty);
5622 Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling...
5623 BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
5624 BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
5626 // Create the call node...
5627 if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments?
5628 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5629 } else { // Has arguments?
5630 // Loop through FunctionType's arguments and ensure they are specified
5633 FunctionType::param_iterator I = Ty->param_begin();
5634 FunctionType::param_iterator E = Ty->param_end();
5635 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
5637 std::vector<Value*> Args;
5638 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5639 if ((*ArgI).V->getType() != *I)
5640 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5641 (*I)->getDescription() + "'");
5642 Args.push_back((*ArgI).V);
5645 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5646 error("Invalid number of parameters detected");
5648 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5650 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[(2) - (13)].UIntVal));
5651 delete (yyvsp[(3) - (13)].TypeVal).T;
5652 delete (yyvsp[(6) - (13)].ValueList);
5657 #line 2865 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5659 (yyval.TermInstVal) = new UnwindInst();
5664 #line 2868 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5666 (yyval.TermInstVal) = new UnreachableInst();
5671 #line 2874 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5673 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5674 Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
5677 error("May only switch on a constant pool value");
5679 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
5680 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5685 #line 2884 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5687 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5688 Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
5691 error("May only switch on a constant pool value");
5693 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
5694 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5699 #line 2897 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5702 if ((yyvsp[(1) - (2)].StrVal))
5703 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
5704 if (BCI->getSrcTy() == BCI->getDestTy() &&
5705 BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
5706 // This is a useless bit cast causing a name redefinition. It is
5707 // a bit cast from a type to the same type of an operand with the
5708 // same name as the name we would give this instruction. Since this
5709 // instruction results in no code generation, it is safe to omit
5710 // the instruction. This situation can occur because of collapsed
5711 // type planes. For example:
5712 // %X = add int %Y, %Z
5713 // %X = cast int %Y to uint
5714 // After upgrade, this looks like:
5715 // %X = add i32 %Y, %Z
5716 // %X = bitcast i32 to i32
5717 // The bitcast is clearly useless so we omit it.
5720 (yyval.InstVal).I = 0;
5721 (yyval.InstVal).S = Signless;
5723 setValueName((yyvsp[(2) - (2)].InstVal).I, (yyvsp[(1) - (2)].StrVal));
5724 InsertValue((yyvsp[(2) - (2)].InstVal).I);
5725 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
5731 #line 2926 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5732 { // Used for PHI nodes
5733 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5734 (yyval.PHIList).S = (yyvsp[(1) - (6)].TypeVal).S;
5735 Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).T->get(), (yyvsp[(3) - (6)].ValIDVal));
5736 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5737 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5738 delete (yyvsp[(1) - (6)].TypeVal).T;
5743 #line 2934 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5745 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5746 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
5747 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
5748 (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5753 #line 2942 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5754 { // Used for call statements, and memory insts...
5755 (yyval.ValueList) = new std::vector<ValueInfo>();
5756 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
5761 #line 2946 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5763 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5764 (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
5769 #line 2954 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5770 { (yyval.ValueList) = 0; ;}
5774 #line 2958 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5776 (yyval.BoolVal) = true;
5781 #line 2961 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5783 (yyval.BoolVal) = false;
5788 #line 2967 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5790 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5791 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5792 error("Arithmetic operator requires integer, FP, or packed operands");
5793 if (isa<PackedType>(Ty) &&
5794 ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp))
5795 error("Remainder not supported on packed types");
5796 // Upgrade the opcode from obsolete versions before we do anything with it.
5797 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5798 Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5799 Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5800 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5801 if ((yyval.InstVal).I == 0)
5802 error("binary operator returned null");
5803 (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5804 delete (yyvsp[(2) - (5)].TypeVal).T;
5809 #line 2984 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5811 const Type *Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5812 if (!Ty->isInteger()) {
5813 if (!isa<PackedType>(Ty) ||
5814 !cast<PackedType>(Ty)->getElementType()->isInteger())
5815 error("Logical operator requires integral operands");
5817 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5818 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5819 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5820 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5821 if ((yyval.InstVal).I == 0)
5822 error("binary operator returned null");
5823 (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5824 delete (yyvsp[(2) - (5)].TypeVal).T;
5829 #line 3000 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5831 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5832 if(isa<PackedType>(Ty))
5833 error("PackedTypes currently not supported in setcc instructions");
5834 unsigned short pred;
5835 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
5836 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5837 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5838 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5839 if ((yyval.InstVal).I == 0)
5840 error("binary operator returned null");
5841 (yyval.InstVal).S = Unsigned;
5842 delete (yyvsp[(2) - (5)].TypeVal).T;
5847 #line 3014 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5849 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
5850 if (isa<PackedType>(Ty))
5851 error("PackedTypes currently not supported in icmp instructions");
5852 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5853 error("icmp requires integer or pointer typed operands");
5854 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5855 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5856 (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
5857 (yyval.InstVal).S = Unsigned;
5858 delete (yyvsp[(3) - (6)].TypeVal).T;
5863 #line 3026 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5865 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
5866 if (isa<PackedType>(Ty))
5867 error("PackedTypes currently not supported in fcmp instructions");
5868 else if (!Ty->isFloatingPoint())
5869 error("fcmp instruction requires floating point operands");
5870 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5871 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5872 (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
5873 (yyval.InstVal).S = Unsigned;
5874 delete (yyvsp[(3) - (6)].TypeVal).T;
5879 #line 3038 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5881 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5882 const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
5883 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5885 error("Expected integral type for not instruction");
5886 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
5887 if ((yyval.InstVal).I == 0)
5888 error("Could not create a xor instruction");
5889 (yyval.InstVal).S = (yyvsp[(2) - (2)].ValueVal).S
5894 #line 3049 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5896 if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
5897 cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
5898 error("Shift amount must be int8");
5899 if (!(yyvsp[(2) - (4)].ValueVal).V->getType()->isInteger())
5900 error("Shift constant expression requires integer operand");
5901 (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);
5902 (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
5907 #line 3058 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5909 const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5910 if (!DstTy->isFirstClassType())
5911 error("cast instruction to a non-primitive type: '" +
5912 DstTy->getDescription() + "'");
5913 (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));
5914 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5915 delete (yyvsp[(4) - (4)].TypeVal).T;
5920 #line 3067 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5922 if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
5923 cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
5924 error("select condition must be bool");
5925 if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
5926 error("select value types should match");
5927 (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5928 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
5933 #line 3076 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5935 const Type *Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
5937 (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
5938 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5939 delete (yyvsp[(4) - (4)].TypeVal).T;
5944 #line 3083 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5946 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5947 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5948 ObsoleteVarArgs = true;
5949 Function* NF = cast<Function>(CurModule.CurrentModule->
5950 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5953 //foo = alloca 1 of t
5957 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5958 CurBB->getInstList().push_back(foo);
5959 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
5960 CurBB->getInstList().push_back(bar);
5961 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5962 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5963 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5964 delete (yyvsp[(4) - (4)].TypeVal).T;
5969 #line 3104 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5971 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5972 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5973 ObsoleteVarArgs = true;
5974 Function* NF = cast<Function>(CurModule.CurrentModule->
5975 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5977 //b = vanext a, t ->
5978 //foo = alloca 1 of t
5981 //tmp = vaarg foo, t
5983 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5984 CurBB->getInstList().push_back(foo);
5985 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
5986 CurBB->getInstList().push_back(bar);
5987 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5988 Instruction* tmp = new VAArgInst(foo, DstTy);
5989 CurBB->getInstList().push_back(tmp);
5990 (yyval.InstVal).I = new LoadInst(foo);
5991 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5992 delete (yyvsp[(4) - (4)].TypeVal).T;
5997 #line 3128 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5999 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
6000 error("Invalid extractelement operands");
6001 (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
6002 (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
6007 #line 3134 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6009 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
6010 error("Invalid insertelement operands");
6011 (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6012 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
6017 #line 3140 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6019 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
6020 error("Invalid shufflevector operands");
6021 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6022 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
6027 #line 3146 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6029 const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
6030 if (!Ty->isFirstClassType())
6031 error("PHI node operands must be of first class type");
6032 PHINode *PHI = new PHINode(Ty);
6033 PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
6034 while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
6035 if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty)
6036 error("All elements of a PHI node must be of the same type");
6037 PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
6038 (yyvsp[(2) - (2)].PHIList).P->pop_front();
6040 (yyval.InstVal).I = PHI;
6041 (yyval.InstVal).S = (yyvsp[(2) - (2)].PHIList).S;
6042 delete (yyvsp[(2) - (2)].PHIList).P; // Free the list...
6047 #line 3162 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6050 // Handle the short call syntax
6051 const PointerType *PFTy;
6052 const FunctionType *FTy;
6053 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).T->get())) ||
6054 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6055 // Pull out the types of all of the arguments...
6056 std::vector<const Type*> ParamTypes;
6057 if ((yyvsp[(6) - (7)].ValueList)) {
6058 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
6060 ParamTypes.push_back((*I).V->getType());
6063 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6064 if (isVarArg) ParamTypes.pop_back();
6066 const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).T->get();
6067 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6068 error("Functions cannot return aggregate types");
6070 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
6071 PFTy = PointerType::get(FTy);
6074 // First upgrade any intrinsic calls.
6075 std::vector<Value*> Args;
6076 if ((yyvsp[(6) - (7)].ValueList))
6077 for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i)
6078 Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
6079 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[(4) - (7)].ValIDVal), Args);
6081 // If we got an upgraded intrinsic
6083 (yyval.InstVal).I = Inst;
6084 (yyval.InstVal).S = Signless;
6086 // Get the function we're calling
6087 Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
6089 // Check the argument values match
6090 if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments?
6091 // Make sure no arguments is a good thing!
6092 if (FTy->getNumParams() != 0)
6093 error("No arguments passed to a function that expects arguments");
6094 } else { // Has arguments?
6095 // Loop through FunctionType's arguments and ensure they are specified
6098 FunctionType::param_iterator I = FTy->param_begin();
6099 FunctionType::param_iterator E = FTy->param_end();
6100 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
6102 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6103 if ((*ArgI).V->getType() != *I)
6104 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6105 (*I)->getDescription() + "'");
6107 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6108 error("Invalid number of parameters detected");
6111 // Create the call instruction
6112 CallInst *CI = new CallInst(V, Args);
6113 CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
6114 CI->setCallingConv((yyvsp[(2) - (7)].UIntVal));
6115 (yyval.InstVal).I = CI;
6116 (yyval.InstVal).S = (yyvsp[(3) - (7)].TypeVal).S;
6118 delete (yyvsp[(3) - (7)].TypeVal).T;
6119 delete (yyvsp[(6) - (7)].ValueList);
6124 #line 3235 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6126 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
6131 #line 3243 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6132 { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
6136 #line 3244 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6137 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6141 #line 3248 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6142 { (yyval.BoolVal) = true; ;}
6146 #line 3249 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6147 { (yyval.BoolVal) = false; ;}
6151 #line 3253 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6153 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6154 (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6155 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6156 delete (yyvsp[(2) - (3)].TypeVal).T;
6161 #line 3259 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6163 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6164 (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6165 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6166 delete (yyvsp[(2) - (6)].TypeVal).T;
6171 #line 3265 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6173 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6174 (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6175 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6176 delete (yyvsp[(2) - (3)].TypeVal).T;
6181 #line 3271 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6183 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6184 (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6185 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6186 delete (yyvsp[(2) - (6)].TypeVal).T;
6191 #line 3277 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6193 const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
6194 if (!isa<PointerType>(PTy))
6195 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
6196 (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
6197 (yyval.InstVal).S = Signless;
6202 #line 3284 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6204 const Type* Ty = (yyvsp[(3) - (4)].TypeVal).T->get();
6205 (yyval.InstVal).S = (yyvsp[(3) - (4)].TypeVal).S;
6206 if (!isa<PointerType>(Ty))
6207 error("Can't load from nonpointer type: " + Ty->getDescription());
6208 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6209 error("Can't load from pointer of non-first-class type: " +
6210 Ty->getDescription());
6211 Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
6212 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
6213 delete (yyvsp[(3) - (4)].TypeVal).T;
6218 #line 3296 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6220 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).T->get());
6222 error("Can't store to a nonpointer type: " +
6223 (yyvsp[(5) - (6)].TypeVal).T->get()->getDescription());
6224 const Type *ElTy = PTy->getElementType();
6225 if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType())
6226 error("Can't store '" + (yyvsp[(3) - (6)].ValueVal).V->getType()->getDescription() +
6227 "' into space of type '" + ElTy->getDescription() + "'");
6228 Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
6229 (yyval.InstVal).I = new StoreInst((yyvsp[(3) - (6)].ValueVal).V, tmpVal, (yyvsp[(1) - (6)].BoolVal));
6230 (yyval.InstVal).S = Signless;
6231 delete (yyvsp[(5) - (6)].TypeVal).T;
6236 #line 3310 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6238 const Type* Ty = (yyvsp[(2) - (4)].TypeVal).T->get();
6239 if (!isa<PointerType>(Ty))
6240 error("getelementptr insn requires pointer operand");
6242 std::vector<Value*> VIndices;
6243 upgradeGEPIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
6245 Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
6246 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6247 (yyval.InstVal).S = Signless;
6248 delete (yyvsp[(2) - (4)].TypeVal).T;
6249 delete (yyvsp[(4) - (4)].ValueList);
6254 /* Line 1267 of yacc.c. */
6255 #line 6256 "UpgradeParser.tab.c"
6258 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6262 YY_STACK_PRINT (yyss, yyssp);
6267 /* Now `shift' the result of the reduction. Determine what state
6268 that goes to, based on the state we popped back to and the rule
6269 number reduced by. */
6273 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6274 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
6275 yystate = yytable[yystate];
6277 yystate = yydefgoto[yyn - YYNTOKENS];
6282 /*------------------------------------.
6283 | yyerrlab -- here on detecting error |
6284 `------------------------------------*/
6286 /* If not already recovering from an error, report this error. */
6290 #if ! YYERROR_VERBOSE
6291 yyerror (YY_("syntax error"));
6294 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6295 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6297 YYSIZE_T yyalloc = 2 * yysize;
6298 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6299 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6300 if (yymsg != yymsgbuf)
6301 YYSTACK_FREE (yymsg);
6302 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6304 yymsg_alloc = yyalloc;
6308 yymsg_alloc = sizeof yymsgbuf;
6312 if (0 < yysize && yysize <= yymsg_alloc)
6314 (void) yysyntax_error (yymsg, yystate, yychar);
6319 yyerror (YY_("syntax error"));
6321 goto yyexhaustedlab;
6329 if (yyerrstatus == 3)
6331 /* If just tried and failed to reuse look-ahead token after an
6332 error, discard it. */
6334 if (yychar <= YYEOF)
6336 /* Return failure if at end of input. */
6337 if (yychar == YYEOF)
6342 yydestruct ("Error: discarding",
6348 /* Else will try to reuse look-ahead token after shifting the error
6353 /*---------------------------------------------------.
6354 | yyerrorlab -- error raised explicitly by YYERROR. |
6355 `---------------------------------------------------*/
6358 /* Pacify compilers like GCC when the user code never invokes
6359 YYERROR and the label yyerrorlab therefore never appears in user
6361 if (/*CONSTCOND*/ 0)
6364 /* Do not reclaim the symbols of the rule which action triggered
6368 YY_STACK_PRINT (yyss, yyssp);
6373 /*-------------------------------------------------------------.
6374 | yyerrlab1 -- common code for both syntax error and YYERROR. |
6375 `-------------------------------------------------------------*/
6377 yyerrstatus = 3; /* Each real token shifted decrements this. */
6381 yyn = yypact[yystate];
6382 if (yyn != YYPACT_NINF)
6385 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6393 /* Pop the current state because it cannot handle the error token. */
6398 yydestruct ("Error: popping",
6399 yystos[yystate], yyvsp);
6402 YY_STACK_PRINT (yyss, yyssp);
6411 /* Shift the error token. */
6412 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6418 /*-------------------------------------.
6419 | yyacceptlab -- YYACCEPT comes here. |
6420 `-------------------------------------*/
6425 /*-----------------------------------.
6426 | yyabortlab -- YYABORT comes here. |
6427 `-----------------------------------*/
6433 /*-------------------------------------------------.
6434 | yyexhaustedlab -- memory exhaustion comes here. |
6435 `-------------------------------------------------*/
6437 yyerror (YY_("memory exhausted"));
6443 if (yychar != YYEOF && yychar != YYEMPTY)
6444 yydestruct ("Cleanup: discarding lookahead",
6446 /* Do not reclaim the symbols of the rule which action triggered
6447 this YYABORT or YYACCEPT. */
6449 YY_STACK_PRINT (yyss, yyssp);
6450 while (yyssp != yyss)
6452 yydestruct ("Cleanup: popping",
6453 yystos[*yyssp], yyvsp);
6458 YYSTACK_FREE (yyss);
6461 if (yymsg != yymsgbuf)
6462 YYSTACK_FREE (yymsg);
6464 /* Make sure YYID is used. */
6465 return YYID (yyresult);
6469 #line 3326 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6472 int yyerror(const char *ErrorMsg) {
6474 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6475 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6476 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6477 if (yychar != YYEMPTY && yychar != 0)
6478 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6480 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6481 std::cout << "llvm-upgrade: parse failed.\n";
6485 void warning(const std::string& ErrorMsg) {
6487 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6488 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6489 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6490 if (yychar != YYEMPTY && yychar != 0)
6491 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6493 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6496 void error(const std::string& ErrorMsg, int LineNo) {
6497 if (LineNo == -1) LineNo = Upgradelineno;
6498 Upgradelineno = LineNo;
6499 yyerror(ErrorMsg.c_str());