1 /* A Bison parser, made by GNU Bison 2.1. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
40 #define YYBISON_VERSION "2.1"
43 #define YYSKELETON_NAME "yacc.c"
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
51 /* Substitute the variable and function names. */
52 #define yyparse Upgradeparse
53 #define yylex Upgradelex
54 #define yyerror Upgradeerror
55 #define yylval Upgradelval
56 #define yychar Upgradechar
57 #define yydebug Upgradedebug
58 #define yynerrs Upgradenerrs
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
90 ZEROINITIALIZER = 281,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
178 EXTRACTELEMENT = 369,
219 #define ESINT64VAL 258
220 #define EUINT64VAL 259
240 #define STRINGCONSTANT 279
241 #define IMPLEMENTATION 280
242 #define ZEROINITIALIZER 281
253 #define DOTDOTDOT 292
260 #define APPENDING 299
261 #define DLLIMPORT 300
262 #define DLLEXPORT 301
263 #define EXTERN_WEAK 302
270 #define POINTERSIZE 309
279 #define SIDEEFFECT 318
282 #define CSRETCC_TOK 321
283 #define FASTCC_TOK 322
284 #define COLDCC_TOK 323
285 #define X86_STDCALLCC_TOK 324
286 #define X86_FASTCALLCC_TOK 325
287 #define DATALAYOUT 326
292 #define UNREACHABLE 331
326 #define GETELEMENTPTR 365
330 #define EXTRACTELEMENT 369
331 #define INSERTELEMENT 370
332 #define SHUFFLEVECTOR 371
333 #define VAARG_old 372
334 #define VANEXT_old 373
372 /* Copy the first part of user declarations. */
373 #line 14 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
375 #include "UpgradeInternals.h"
376 #include "llvm/CallingConv.h"
377 #include "llvm/InlineAsm.h"
378 #include "llvm/Instructions.h"
379 #include "llvm/Module.h"
380 #include "llvm/ValueSymbolTable.h"
381 #include "llvm/Support/GetElementPtrTypeIterator.h"
382 #include "llvm/ADT/STLExtras.h"
383 #include "llvm/Support/MathExtras.h"
390 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
391 // relating to upreferences in the input stream.
393 //#define DEBUG_UPREFS 1
395 #define UR_OUT(X) std::cerr << X
400 #define YYERROR_VERBOSE 1
401 #define YYINCLUDED_STDLIB_H
407 int yyerror(const char*);
408 static void warning(const std::string& WarningMsg);
412 std::istream* LexInput;
413 static std::string CurFilename;
415 // This bool controls whether attributes are ever added to function declarations
416 // definitions and calls.
417 static bool AddAttributes = false;
419 static Module *ParserResult;
420 static bool ObsoleteVarArgs;
421 static bool NewVarArgs;
422 static BasicBlock *CurBB;
423 static GlobalVariable *CurGV;
425 // This contains info used when building the body of a function. It is
426 // destroyed when the function is completed.
428 typedef std::vector<Value *> ValueList; // Numbered defs
430 typedef std::pair<std::string,TypeInfo> RenameMapKey;
431 typedef std::map<RenameMapKey,std::string> RenameMapType;
434 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
435 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
437 static struct PerModuleInfo {
438 Module *CurrentModule;
439 std::map<const Type *, ValueList> Values; // Module level numbered definitions
440 std::map<const Type *,ValueList> LateResolveValues;
441 std::vector<PATypeHolder> Types;
442 std::map<ValID, PATypeHolder> LateResolveTypes;
443 static Module::Endianness Endian;
444 static Module::PointerSize PointerSize;
445 RenameMapType RenameMap;
447 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
448 /// how they were referenced and on which line of the input they came from so
449 /// that we can resolve them later and print error messages as appropriate.
450 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
452 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
453 // references to global values. Global values may be referenced before they
454 // are defined, and if so, the temporary object that they represent is held
455 // here. This is used for forward references of GlobalValues.
457 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
459 GlobalRefsType GlobalRefs;
462 // If we could not resolve some functions at function compilation time
463 // (calls to functions before they are defined), resolve them now... Types
464 // are resolved when the constant pool has been completely parsed.
466 ResolveDefinitions(LateResolveValues);
468 // Check to make sure that all global value forward references have been
471 if (!GlobalRefs.empty()) {
472 std::string UndefinedReferences = "Unresolved global references exist:\n";
474 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
476 UndefinedReferences += " " + I->first.first->getDescription() + " " +
477 I->first.second.getName() + "\n";
479 error(UndefinedReferences);
483 if (CurrentModule->getDataLayout().empty()) {
484 std::string dataLayout;
485 if (Endian != Module::AnyEndianness)
486 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
487 if (PointerSize != Module::AnyPointerSize) {
488 if (!dataLayout.empty())
490 dataLayout.append(PointerSize == Module::Pointer64 ?
491 "p:64:64" : "p:32:32");
493 CurrentModule->setDataLayout(dataLayout);
496 Values.clear(); // Clear out function local definitions
501 // GetForwardRefForGlobal - Check to see if there is a forward reference
502 // for this global. If so, remove it from the GlobalRefs map and return it.
503 // If not, just return null.
504 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
505 // Check to see if there is a forward reference to this global variable...
506 // if there is, eliminate it and patch the reference to use the new def'n.
507 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
508 GlobalValue *Ret = 0;
509 if (I != GlobalRefs.end()) {
515 void setEndianness(Module::Endianness E) { Endian = E; }
516 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
519 Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
520 Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
522 static struct PerFunctionInfo {
523 Function *CurrentFunction; // Pointer to current function being created
525 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
526 std::map<const Type*, ValueList> LateResolveValues;
527 bool isDeclare; // Is this function a forward declararation?
528 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
530 /// BBForwardRefs - When we see forward references to basic blocks, keep
531 /// track of them here.
532 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
533 std::vector<BasicBlock*> NumberedBlocks;
534 RenameMapType RenameMap;
537 inline PerFunctionInfo() {
540 Linkage = GlobalValue::ExternalLinkage;
543 inline void FunctionStart(Function *M) {
548 void FunctionDone() {
549 NumberedBlocks.clear();
551 // Any forward referenced blocks left?
552 if (!BBForwardRefs.empty()) {
553 error("Undefined reference to label " +
554 BBForwardRefs.begin()->first->getName());
558 // Resolve all forward references now.
559 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
561 Values.clear(); // Clear out function local definitions
565 Linkage = GlobalValue::ExternalLinkage;
567 } CurFun; // Info for the current function...
569 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
572 //===----------------------------------------------------------------------===//
573 // Code to handle definitions of all the types
574 //===----------------------------------------------------------------------===//
576 static int InsertValue(Value *V,
577 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
578 if (V->hasName()) return -1; // Is this a numbered definition?
580 // Yes, insert the value into the value table...
581 ValueList &List = ValueTab[V->getType()];
583 return List.size()-1;
586 static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
588 case ValID::NumberVal: // Is it a numbered definition?
589 // Module constants occupy the lowest numbered slots...
590 if ((unsigned)D.Num < CurModule.Types.size()) {
591 return CurModule.Types[(unsigned)D.Num];
594 case ValID::NameVal: // Is it a named definition?
595 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
596 D.destroy(); // Free old strdup'd memory...
601 error("Internal parser error: Invalid symbol type reference");
605 // If we reached here, we referenced either a symbol that we don't know about
606 // or an id number that hasn't been read yet. We may be referencing something
607 // forward, so just create an entry to be resolved later and get to it...
609 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
612 if (inFunctionScope()) {
613 if (D.Type == ValID::NameVal) {
614 error("Reference to an undefined type: '" + D.getName() + "'");
617 error("Reference to an undefined type: #" + itostr(D.Num));
622 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
623 if (I != CurModule.LateResolveTypes.end())
626 Type *Typ = OpaqueType::get();
627 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
631 /// This function determines if two function types differ only in their use of
632 /// the sret parameter attribute in the first argument. If they are identical
633 /// in all other respects, it returns true. Otherwise, it returns false.
634 bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
635 const FunctionType *F2) {
636 if (F1->getReturnType() != F2->getReturnType() ||
637 F1->getNumParams() != F2->getNumParams() ||
638 F1->getParamAttrs(0) != F2->getParamAttrs(0))
640 unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute);
641 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
642 if (F1->getParamType(i) != F2->getParamType(i) ||
643 unsigned(F1->getParamAttrs(i+1)) & SRetMask !=
644 unsigned(F2->getParamAttrs(i+1)) & SRetMask)
649 bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) {
650 if (V->getType() == Ty)
652 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
653 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
655 const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType());
656 const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType());
658 return FuncTysDifferOnlyBySRet(FT1, FT2);
663 // The upgrade of csretcc to sret param attribute may have caused a function
664 // to not be found because the param attribute changed the type of the called
665 // function. This helper function, used in getExistingValue, detects that
666 // situation and bitcasts the function to the correct type.
667 static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
668 // Handle degenerate cases
671 if (V->getType() == Ty)
675 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
676 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
678 const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType());
679 const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType());
680 if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2))
681 if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute))
683 else if (Constant *C = dyn_cast<Constant>(V))
684 Result = ConstantExpr::getBitCast(C, PF1);
686 Result = new BitCastInst(V, PF1, "upgrd.cast", CurBB);
691 // getExistingValue - Look up the value specified by the provided type and
692 // the provided ValID. If the value exists and has already been defined, return
693 // it. Otherwise return null.
695 static Value *getExistingValue(const Type *Ty, const ValID &D) {
696 if (isa<FunctionType>(Ty)) {
697 error("Functions are not values and must be referenced as pointers");
701 case ValID::NumberVal: { // Is it a numbered definition?
702 unsigned Num = (unsigned)D.Num;
704 // Module constants occupy the lowest numbered slots...
705 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
706 if (VI != CurModule.Values.end()) {
707 if (Num < VI->second.size())
708 return VI->second[Num];
709 Num -= VI->second.size();
712 // Make sure that our type is within bounds
713 VI = CurFun.Values.find(Ty);
714 if (VI == CurFun.Values.end()) return 0;
716 // Check that the number is within bounds...
717 if (VI->second.size() <= Num) return 0;
719 return VI->second[Num];
722 case ValID::NameVal: { // Is it a named definition?
723 // Get the name out of the ID
724 std::string Name(D.Name);
726 TypeInfo TI; TI.T = Ty; TI.S = D.S;
727 RenameMapKey Key = std::make_pair(Name, TI);
728 if (inFunctionScope()) {
729 // See if the name was renamed
730 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
731 std::string LookupName;
732 if (I != CurFun.RenameMap.end())
733 LookupName = I->second;
736 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
737 V = SymTab.lookup(LookupName);
738 V = handleSRetFuncTypeMerge(V, Ty);
739 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type!");
742 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
743 std::string LookupName;
744 if (I != CurModule.RenameMap.end())
745 LookupName = I->second;
748 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
749 V = handleSRetFuncTypeMerge(V, Ty);
750 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type!");
755 D.destroy(); // Free old strdup'd memory...
759 // Check to make sure that "Ty" is an integral type, and that our
760 // value will fit into the specified type...
761 case ValID::ConstSIntVal: // Is it a constant pool reference??
762 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
763 error("Signed integral constant '" + itostr(D.ConstPool64) +
764 "' is invalid for type '" + Ty->getDescription() + "'");
766 return ConstantInt::get(Ty, D.ConstPool64);
768 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
769 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
770 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
771 error("Integral constant '" + utostr(D.UConstPool64) +
772 "' is invalid or out of range");
773 else // This is really a signed reference. Transmogrify.
774 return ConstantInt::get(Ty, D.ConstPool64);
776 return ConstantInt::get(Ty, D.UConstPool64);
778 case ValID::ConstFPVal: // Is it a floating point const pool reference?
779 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
780 error("FP constant invalid for type");
781 return ConstantFP::get(Ty, D.ConstPoolFP);
783 case ValID::ConstNullVal: // Is it a null value?
784 if (!isa<PointerType>(Ty))
785 error("Cannot create a a non pointer null");
786 return ConstantPointerNull::get(cast<PointerType>(Ty));
788 case ValID::ConstUndefVal: // Is it an undef value?
789 return UndefValue::get(Ty);
791 case ValID::ConstZeroVal: // Is it a zero value?
792 return Constant::getNullValue(Ty);
794 case ValID::ConstantVal: // Fully resolved constant?
795 if (D.ConstantValue->getType() != Ty)
796 error("Constant expression type different from required type");
797 return D.ConstantValue;
799 case ValID::InlineAsmVal: { // Inline asm expression
800 const PointerType *PTy = dyn_cast<PointerType>(Ty);
801 const FunctionType *FTy =
802 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
803 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
804 error("Invalid type for asm constraint string");
805 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
806 D.IAD->HasSideEffects);
807 D.destroy(); // Free InlineAsmDescriptor.
811 assert(0 && "Unhandled case");
815 assert(0 && "Unhandled case");
819 // getVal - This function is identical to getExistingValue, except that if a
820 // value is not already defined, it "improvises" by creating a placeholder var
821 // that looks and acts just like the requested variable. When the value is
822 // defined later, all uses of the placeholder variable are replaced with the
825 static Value *getVal(const Type *Ty, const ValID &ID) {
826 if (Ty == Type::LabelTy)
827 error("Cannot use a basic block here");
829 // See if the value has already been defined.
830 Value *V = getExistingValue(Ty, ID);
833 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
834 error("Invalid use of a composite type");
836 // If we reached here, we referenced either a symbol that we don't know about
837 // or an id number that hasn't been read yet. We may be referencing something
838 // forward, so just create an entry to be resolved later and get to it...
839 V = new Argument(Ty);
841 // Remember where this forward reference came from. FIXME, shouldn't we try
842 // to recycle these things??
843 CurModule.PlaceHolderInfo.insert(
844 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
846 if (inFunctionScope())
847 InsertValue(V, CurFun.LateResolveValues);
849 InsertValue(V, CurModule.LateResolveValues);
853 /// @brief This just makes any name given to it unique, up to MAX_UINT times.
854 static std::string makeNameUnique(const std::string& Name) {
855 static unsigned UniqueNameCounter = 1;
856 std::string Result(Name);
857 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
861 /// getBBVal - This is used for two purposes:
862 /// * If isDefinition is true, a new basic block with the specified ID is being
864 /// * If isDefinition is true, this is a reference to a basic block, which may
865 /// or may not be a forward reference.
867 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
868 assert(inFunctionScope() && "Can't get basic block at global scope");
874 error("Illegal label reference " + ID.getName());
876 case ValID::NumberVal: // Is it a numbered definition?
877 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
878 CurFun.NumberedBlocks.resize(ID.Num+1);
879 BB = CurFun.NumberedBlocks[ID.Num];
881 case ValID::NameVal: // Is it a named definition?
883 if (Value *N = CurFun.CurrentFunction->
884 getValueSymbolTable().lookup(Name)) {
885 if (N->getType() != Type::LabelTy) {
886 // Register names didn't use to conflict with basic block names
887 // because of type planes. Now they all have to be unique. So, we just
888 // rename the register and treat this name as if no basic block
890 TypeInfo TI; TI.T = N->getType(); TI.S = ID.S;
891 RenameMapKey Key = std::make_pair(N->getName(),TI);
892 N->setName(makeNameUnique(N->getName()));
893 CurModule.RenameMap[Key] = N->getName();
896 BB = cast<BasicBlock>(N);
902 // See if the block has already been defined.
904 // If this is the definition of the block, make sure the existing value was
905 // just a forward reference. If it was a forward reference, there will be
906 // an entry for it in the PlaceHolderInfo map.
907 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
908 // The existing value was a definition, not a forward reference.
909 error("Redefinition of label " + ID.getName());
911 ID.destroy(); // Free strdup'd memory.
915 // Otherwise this block has not been seen before.
916 BB = new BasicBlock("", CurFun.CurrentFunction);
917 if (ID.Type == ValID::NameVal) {
918 BB->setName(ID.Name);
920 CurFun.NumberedBlocks[ID.Num] = BB;
923 // If this is not a definition, keep track of it so we can use it as a forward
926 // Remember where this forward reference came from.
927 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
929 // The forward declaration could have been inserted anywhere in the
930 // function: insert it into the correct place now.
931 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
932 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
939 //===----------------------------------------------------------------------===//
940 // Code to handle forward references in instructions
941 //===----------------------------------------------------------------------===//
943 // This code handles the late binding needed with statements that reference
944 // values not defined yet... for example, a forward branch, or the PHI node for
947 // This keeps a table (CurFun.LateResolveValues) of all such forward references
948 // and back patchs after we are done.
951 // ResolveDefinitions - If we could not resolve some defs at parsing
952 // time (forward branches, phi functions for loops, etc...) resolve the
956 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
957 std::map<const Type*,ValueList> *FutureLateResolvers) {
959 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
960 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
961 E = LateResolvers.end(); LRI != E; ++LRI) {
962 const Type* Ty = LRI->first;
963 ValueList &List = LRI->second;
964 while (!List.empty()) {
965 Value *V = List.back();
968 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
969 CurModule.PlaceHolderInfo.find(V);
970 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
972 ValID &DID = PHI->second.first;
974 Value *TheRealValue = getExistingValue(Ty, DID);
976 V->replaceAllUsesWith(TheRealValue);
978 CurModule.PlaceHolderInfo.erase(PHI);
979 } else if (FutureLateResolvers) {
980 // Functions have their unresolved items forwarded to the module late
982 InsertValue(V, *FutureLateResolvers);
984 if (DID.Type == ValID::NameVal) {
985 error("Reference to an invalid definition: '" + DID.getName() +
986 "' of type '" + V->getType()->getDescription() + "'",
990 error("Reference to an invalid definition: #" +
991 itostr(DID.Num) + " of type '" +
992 V->getType()->getDescription() + "'", PHI->second.second);
999 LateResolvers.clear();
1002 // ResolveTypeTo - A brand new type was just declared. This means that (if
1003 // name is not null) things referencing Name can be resolved. Otherwise, things
1004 // refering to the number can be resolved. Do this now.
1006 static void ResolveTypeTo(char *Name, const Type *ToTy, Signedness Sign) {
1009 D = ValID::create(Name, Sign);
1011 D = ValID::create((int)CurModule.Types.size(), Sign);
1013 std::map<ValID, PATypeHolder>::iterator I =
1014 CurModule.LateResolveTypes.find(D);
1015 if (I != CurModule.LateResolveTypes.end()) {
1016 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1017 CurModule.LateResolveTypes.erase(I);
1021 /// This is the implementation portion of TypeHasInteger. It traverses the
1022 /// type given, avoiding recursive types, and returns true as soon as it finds
1023 /// an integer type. If no integer type is found, it returns false.
1024 static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
1025 // Handle some easy cases
1026 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
1028 if (Ty->isInteger())
1030 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
1031 return STy->getElementType()->isInteger();
1033 // Avoid type structure recursion
1034 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
1039 // Push us on the type stack
1040 Stack.push_back(Ty);
1042 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1043 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1045 FunctionType::param_iterator I = FTy->param_begin();
1046 FunctionType::param_iterator E = FTy->param_end();
1048 if (TypeHasIntegerI(*I, Stack))
1051 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1052 StructType::element_iterator I = STy->element_begin();
1053 StructType::element_iterator E = STy->element_end();
1054 for (; I != E; ++I) {
1055 if (TypeHasIntegerI(*I, Stack))
1060 // There shouldn't be anything else, but its definitely not integer
1061 assert(0 && "What type is this?");
1065 /// This is the interface to TypeHasIntegerI. It just provides the type stack,
1066 /// to avoid recursion, and then calls TypeHasIntegerI.
1067 static inline bool TypeHasInteger(const Type *Ty) {
1068 std::vector<const Type*> TyStack;
1069 return TypeHasIntegerI(Ty, TyStack);
1072 // setValueName - Set the specified value to the name given. The name may be
1073 // null potentially, in which case this is a noop. The string passed in is
1074 // assumed to be a malloc'd string buffer, and is free'd by this function.
1076 static void setValueName(const ValueInfo &V, char *NameStr) {
1078 std::string Name(NameStr); // Copy string
1079 free(NameStr); // Free old string
1081 if (V.V->getType() == Type::VoidTy) {
1082 error("Can't assign name '" + Name + "' to value with void type");
1086 assert(inFunctionScope() && "Must be in function scope");
1088 // Search the function's symbol table for an existing value of this name
1089 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1090 Value* Existing = ST.lookup(Name);
1092 // An existing value of the same name was found. This might have happened
1093 // because of the integer type planes collapsing in LLVM 2.0.
1094 if (Existing->getType() == V.V->getType() &&
1095 !TypeHasInteger(Existing->getType())) {
1096 // If the type does not contain any integers in them then this can't be
1097 // a type plane collapsing issue. It truly is a redefinition and we
1098 // should error out as the assembly is invalid.
1099 error("Redefinition of value named '" + Name + "' of type '" +
1100 V.V->getType()->getDescription() + "'");
1103 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1104 // function, regardless of Type. Previously re-use of names was okay as
1105 // long as they were distinct types. With type planes collapsing because
1106 // of the signedness change and because of PR411, this can no longer be
1107 // supported. We must search the entire symbol table for a conflicting
1108 // name and make the name unique. No warning is needed as this can't
1110 std::string NewName = makeNameUnique(Name);
1111 // We're changing the name but it will probably be used by other
1112 // instructions as operands later on. Consequently we have to retain
1113 // a mapping of the renaming that we're doing.
1115 TI.T = V.V->getType();
1117 RenameMapKey Key = std::make_pair(Name,TI);
1118 CurFun.RenameMap[Key] = NewName;
1127 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1128 /// this is a declaration, otherwise it is a definition.
1129 static GlobalVariable *
1130 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1131 bool isConstantGlobal, const Type *Ty,
1132 Constant *Initializer,
1134 if (isa<FunctionType>(Ty))
1135 error("Cannot declare global vars of function type");
1137 const PointerType *PTy = PointerType::get(Ty);
1141 Name = NameStr; // Copy string
1142 free(NameStr); // Free old string
1145 // See if this global value was forward referenced. If so, recycle the
1148 if (!Name.empty()) {
1149 ID = ValID::create((char*)Name.c_str(), Sign);
1151 ID = ValID::create((int)CurModule.Values[PTy].size(), Sign);
1154 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1155 // Move the global to the end of the list, from whereever it was
1156 // previously inserted.
1157 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1158 CurModule.CurrentModule->getGlobalList().remove(GV);
1159 CurModule.CurrentModule->getGlobalList().push_back(GV);
1160 GV->setInitializer(Initializer);
1161 GV->setLinkage(Linkage);
1162 GV->setConstant(isConstantGlobal);
1163 InsertValue(GV, CurModule.Values);
1167 // If this global has a name, check to see if there is already a definition
1168 // of this global in the module and emit warnings if there are conflicts.
1169 if (!Name.empty()) {
1170 // The global has a name. See if there's an existing one of the same name.
1171 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1172 // We found an existing global ov the same name. This isn't allowed
1173 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1174 // can at least compile. This can happen because of type planes
1175 // There is alread a global of the same name which means there is a
1176 // conflict. Let's see what we can do about it.
1177 std::string NewName(makeNameUnique(Name));
1178 if (Linkage == GlobalValue::InternalLinkage) {
1179 // The linkage type is internal so just warn about the rename without
1180 // invoking "scarey language" about linkage failures. GVars with
1181 // InternalLinkage can be renamed at will.
1182 warning("Global variable '" + Name + "' was renamed to '"+
1185 // The linkage of this gval is external so we can't reliably rename
1186 // it because it could potentially create a linking problem.
1187 // However, we can't leave the name conflict in the output either or
1188 // it won't assemble with LLVM 2.0. So, all we can do is rename
1189 // this one to something unique and emit a warning about the problem.
1190 warning("Renaming global variable '" + Name + "' to '" + NewName +
1191 "' may cause linkage errors");
1194 // Put the renaming in the global rename map
1195 TypeInfo TI; TI.T = PointerType::get(Ty); TI.S = Signless;
1196 RenameMapKey Key = std::make_pair(Name,TI);
1197 CurModule.RenameMap[Key] = NewName;
1204 // Otherwise there is no existing GV to use, create one now.
1205 GlobalVariable *GV =
1206 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1207 CurModule.CurrentModule);
1208 InsertValue(GV, CurModule.Values);
1212 // setTypeName - Set the specified type to the name given. The name may be
1213 // null potentially, in which case this is a noop. The string passed in is
1214 // assumed to be a malloc'd string buffer, and is freed by this function.
1216 // This function returns true if the type has already been defined, but is
1217 // allowed to be redefined in the specified context. If the name is a new name
1218 // for the type plane, it is inserted and false is returned.
1219 static bool setTypeName(const Type *T, char *NameStr) {
1220 assert(!inFunctionScope() && "Can't give types function-local names");
1221 if (NameStr == 0) return false;
1223 std::string Name(NameStr); // Copy string
1224 free(NameStr); // Free old string
1226 // We don't allow assigning names to void type
1227 if (T == Type::VoidTy) {
1228 error("Can't assign name '" + Name + "' to the void type");
1232 // Set the type name, checking for conflicts as we do so.
1233 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1235 if (AlreadyExists) { // Inserting a name that is already defined???
1236 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1237 assert(Existing && "Conflict but no matching type?");
1239 // There is only one case where this is allowed: when we are refining an
1240 // opaque type. In this case, Existing will be an opaque type.
1241 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1242 // We ARE replacing an opaque type!
1243 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1247 // Otherwise, this is an attempt to redefine a type. That's okay if
1248 // the redefinition is identical to the original. This will be so if
1249 // Existing and T point to the same Type object. In this one case we
1250 // allow the equivalent redefinition.
1251 if (Existing == T) return true; // Yes, it's equal.
1253 // Any other kind of (non-equivalent) redefinition is an error.
1254 error("Redefinition of type named '" + Name + "' in the '" +
1255 T->getDescription() + "' type plane");
1261 //===----------------------------------------------------------------------===//
1262 // Code for handling upreferences in type names...
1265 // TypeContains - Returns true if Ty directly contains E in it.
1267 static bool TypeContains(const Type *Ty, const Type *E) {
1268 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1269 E) != Ty->subtype_end();
1273 struct UpRefRecord {
1274 // NestingLevel - The number of nesting levels that need to be popped before
1275 // this type is resolved.
1276 unsigned NestingLevel;
1278 // LastContainedTy - This is the type at the current binding level for the
1279 // type. Every time we reduce the nesting level, this gets updated.
1280 const Type *LastContainedTy;
1282 // UpRefTy - This is the actual opaque type that the upreference is
1283 // represented with.
1284 OpaqueType *UpRefTy;
1286 UpRefRecord(unsigned NL, OpaqueType *URTy)
1287 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1291 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1292 static std::vector<UpRefRecord> UpRefs;
1294 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1295 /// called. It loops through the UpRefs vector, which is a list of the
1296 /// currently active types. For each type, if the up reference is contained in
1297 /// the newly completed type, we decrement the level count. When the level
1298 /// count reaches zero, the upreferenced type is the type that is passed in:
1299 /// thus we can complete the cycle.
1301 static PATypeHolder HandleUpRefs(const Type *ty) {
1302 // If Ty isn't abstract, or if there are no up-references in it, then there is
1303 // nothing to resolve here.
1304 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1306 PATypeHolder Ty(ty);
1307 UR_OUT("Type '" << Ty->getDescription() <<
1308 "' newly formed. Resolving upreferences.\n" <<
1309 UpRefs.size() << " upreferences active!\n");
1311 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1312 // to zero), we resolve them all together before we resolve them to Ty. At
1313 // the end of the loop, if there is anything to resolve to Ty, it will be in
1315 OpaqueType *TypeToResolve = 0;
1317 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1318 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1319 << UpRefs[i].second->getDescription() << ") = "
1320 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1321 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1322 // Decrement level of upreference
1323 unsigned Level = --UpRefs[i].NestingLevel;
1324 UpRefs[i].LastContainedTy = Ty;
1325 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1326 if (Level == 0) { // Upreference should be resolved!
1327 if (!TypeToResolve) {
1328 TypeToResolve = UpRefs[i].UpRefTy;
1330 UR_OUT(" * Resolving upreference for "
1331 << UpRefs[i].second->getDescription() << "\n";
1332 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1333 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1334 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1335 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1337 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1338 --i; // Do not skip the next element...
1343 if (TypeToResolve) {
1344 UR_OUT(" * Resolving upreference for "
1345 << UpRefs[i].second->getDescription() << "\n";
1346 std::string OldName = TypeToResolve->getDescription());
1347 TypeToResolve->refineAbstractTypeTo(Ty);
1353 static inline Instruction::TermOps
1354 getTermOp(TermOps op) {
1356 default : assert(0 && "Invalid OldTermOp");
1357 case RetOp : return Instruction::Ret;
1358 case BrOp : return Instruction::Br;
1359 case SwitchOp : return Instruction::Switch;
1360 case InvokeOp : return Instruction::Invoke;
1361 case UnwindOp : return Instruction::Unwind;
1362 case UnreachableOp: return Instruction::Unreachable;
1366 static inline Instruction::BinaryOps
1367 getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1369 default : assert(0 && "Invalid OldBinaryOps");
1375 case SetGT : assert(0 && "Should use getCompareOp");
1376 case AddOp : return Instruction::Add;
1377 case SubOp : return Instruction::Sub;
1378 case MulOp : return Instruction::Mul;
1380 // This is an obsolete instruction so we must upgrade it based on the
1381 // types of its operands.
1382 bool isFP = Ty->isFloatingPoint();
1383 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
1384 // If its a vector type we want to use the element type
1385 isFP = PTy->getElementType()->isFloatingPoint();
1387 return Instruction::FDiv;
1388 else if (Sign == Signed)
1389 return Instruction::SDiv;
1390 return Instruction::UDiv;
1392 case UDivOp : return Instruction::UDiv;
1393 case SDivOp : return Instruction::SDiv;
1394 case FDivOp : return Instruction::FDiv;
1396 // This is an obsolete instruction so we must upgrade it based on the
1397 // types of its operands.
1398 bool isFP = Ty->isFloatingPoint();
1399 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
1400 // If its a vector type we want to use the element type
1401 isFP = PTy->getElementType()->isFloatingPoint();
1402 // Select correct opcode
1404 return Instruction::FRem;
1405 else if (Sign == Signed)
1406 return Instruction::SRem;
1407 return Instruction::URem;
1409 case URemOp : return Instruction::URem;
1410 case SRemOp : return Instruction::SRem;
1411 case FRemOp : return Instruction::FRem;
1412 case LShrOp : return Instruction::LShr;
1413 case AShrOp : return Instruction::AShr;
1414 case ShlOp : return Instruction::Shl;
1417 return Instruction::AShr;
1418 return Instruction::LShr;
1419 case AndOp : return Instruction::And;
1420 case OrOp : return Instruction::Or;
1421 case XorOp : return Instruction::Xor;
1425 static inline Instruction::OtherOps
1426 getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1428 bool isSigned = Sign == Signed;
1429 bool isFP = Ty->isFloatingPoint();
1431 default : assert(0 && "Invalid OldSetCC");
1434 predicate = FCmpInst::FCMP_OEQ;
1435 return Instruction::FCmp;
1437 predicate = ICmpInst::ICMP_EQ;
1438 return Instruction::ICmp;
1442 predicate = FCmpInst::FCMP_UNE;
1443 return Instruction::FCmp;
1445 predicate = ICmpInst::ICMP_NE;
1446 return Instruction::ICmp;
1450 predicate = FCmpInst::FCMP_OLE;
1451 return Instruction::FCmp;
1454 predicate = ICmpInst::ICMP_SLE;
1456 predicate = ICmpInst::ICMP_ULE;
1457 return Instruction::ICmp;
1461 predicate = FCmpInst::FCMP_OGE;
1462 return Instruction::FCmp;
1465 predicate = ICmpInst::ICMP_SGE;
1467 predicate = ICmpInst::ICMP_UGE;
1468 return Instruction::ICmp;
1472 predicate = FCmpInst::FCMP_OLT;
1473 return Instruction::FCmp;
1476 predicate = ICmpInst::ICMP_SLT;
1478 predicate = ICmpInst::ICMP_ULT;
1479 return Instruction::ICmp;
1483 predicate = FCmpInst::FCMP_OGT;
1484 return Instruction::FCmp;
1487 predicate = ICmpInst::ICMP_SGT;
1489 predicate = ICmpInst::ICMP_UGT;
1490 return Instruction::ICmp;
1495 static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1497 default : assert(0 && "Invalid OldMemoryOps");
1498 case MallocOp : return Instruction::Malloc;
1499 case FreeOp : return Instruction::Free;
1500 case AllocaOp : return Instruction::Alloca;
1501 case LoadOp : return Instruction::Load;
1502 case StoreOp : return Instruction::Store;
1503 case GetElementPtrOp : return Instruction::GetElementPtr;
1507 static inline Instruction::OtherOps
1508 getOtherOp(OtherOps op, Signedness Sign) {
1510 default : assert(0 && "Invalid OldOtherOps");
1511 case PHIOp : return Instruction::PHI;
1512 case CallOp : return Instruction::Call;
1513 case SelectOp : return Instruction::Select;
1514 case UserOp1 : return Instruction::UserOp1;
1515 case UserOp2 : return Instruction::UserOp2;
1516 case VAArg : return Instruction::VAArg;
1517 case ExtractElementOp : return Instruction::ExtractElement;
1518 case InsertElementOp : return Instruction::InsertElement;
1519 case ShuffleVectorOp : return Instruction::ShuffleVector;
1520 case ICmpOp : return Instruction::ICmp;
1521 case FCmpOp : return Instruction::FCmp;
1525 static inline Value*
1526 getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1527 Signedness DstSign, bool ForceInstruction = false) {
1528 Instruction::CastOps Opcode;
1529 const Type* SrcTy = Src->getType();
1531 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1532 // fp -> ptr cast is no longer supported but we must upgrade this
1533 // by doing a double cast: fp -> int -> ptr
1534 SrcTy = Type::Int64Ty;
1535 Opcode = Instruction::IntToPtr;
1536 if (isa<Constant>(Src)) {
1537 Src = ConstantExpr::getCast(Instruction::FPToUI,
1538 cast<Constant>(Src), SrcTy);
1540 std::string NewName(makeNameUnique(Src->getName()));
1541 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1543 } else if (isa<IntegerType>(DstTy) &&
1544 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1545 // cast type %x to bool was previously defined as setne type %x, null
1546 // The cast semantic is now to truncate, not compare so we must retain
1547 // the original intent by replacing the cast with a setne
1548 Constant* Null = Constant::getNullValue(SrcTy);
1549 Instruction::OtherOps Opcode = Instruction::ICmp;
1550 unsigned short predicate = ICmpInst::ICMP_NE;
1551 if (SrcTy->isFloatingPoint()) {
1552 Opcode = Instruction::FCmp;
1553 predicate = FCmpInst::FCMP_ONE;
1554 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1555 error("Invalid cast to bool");
1557 if (isa<Constant>(Src) && !ForceInstruction)
1558 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1560 return CmpInst::create(Opcode, predicate, Src, Null);
1562 // Determine the opcode to use by calling CastInst::getCastOpcode
1564 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1566 } else switch (op) {
1567 default: assert(0 && "Invalid cast token");
1568 case TruncOp: Opcode = Instruction::Trunc; break;
1569 case ZExtOp: Opcode = Instruction::ZExt; break;
1570 case SExtOp: Opcode = Instruction::SExt; break;
1571 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1572 case FPExtOp: Opcode = Instruction::FPExt; break;
1573 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1574 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1575 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1576 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1577 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1578 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1579 case BitCastOp: Opcode = Instruction::BitCast; break;
1582 if (isa<Constant>(Src) && !ForceInstruction)
1583 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1584 return CastInst::create(Opcode, Src, DstTy);
1587 static Instruction *
1588 upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1589 std::vector<Value*>& Args) {
1591 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1592 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1593 if (Args.size() != 2)
1594 error("Invalid prototype for " + Name + " prototype");
1595 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1597 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1598 std::vector<const Type*> Params;
1599 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1600 if (Args.size() != 1)
1601 error("Invalid prototype for " + Name + " prototype");
1602 Params.push_back(PtrTy);
1603 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1604 const PointerType *PFTy = PointerType::get(FTy);
1605 Value* Func = getVal(PFTy, ID);
1606 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
1607 return new CallInst(Func, &Args[0], Args.size());
1608 } else if (Name == "llvm.va_copy") {
1609 if (Args.size() != 2)
1610 error("Invalid prototype for " + Name + " prototype");
1611 Params.push_back(PtrTy);
1612 Params.push_back(PtrTy);
1613 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1614 const PointerType *PFTy = PointerType::get(FTy);
1615 Value* Func = getVal(PFTy, ID);
1616 std::string InstName0(makeNameUnique("va0"));
1617 std::string InstName1(makeNameUnique("va1"));
1618 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1619 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1620 return new CallInst(Func, &Args[0], Args.size());
1626 const Type* upgradeGEPIndices(const Type* PTy,
1627 std::vector<ValueInfo> *Indices,
1628 std::vector<Value*> &VIndices,
1629 std::vector<Constant*> *CIndices = 0) {
1630 // Traverse the indices with a gep_type_iterator so we can build the list
1631 // of constant and value indices for use later. Also perform upgrades
1633 if (CIndices) CIndices->clear();
1634 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1635 VIndices.push_back((*Indices)[i].V);
1636 generic_gep_type_iterator<std::vector<Value*>::iterator>
1637 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1638 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1639 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1640 Value *Index = VIndices[i];
1641 if (CIndices && !isa<Constant>(Index))
1642 error("Indices to constant getelementptr must be constants");
1643 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1644 // struct indices to i32 struct indices with ZExt for compatibility.
1645 else if (isa<StructType>(*GTI)) { // Only change struct indices
1646 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1647 if (CUI->getType()->getBitWidth() == 8)
1649 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1651 // Make sure that unsigned SequentialType indices are zext'd to
1652 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1653 // all indices for SequentialType elements. We must retain the same
1654 // semantic (zext) for unsigned types.
1655 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
1656 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
1658 Index = ConstantExpr::getCast(Instruction::ZExt,
1659 cast<Constant>(Index), Type::Int64Ty);
1661 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1662 makeNameUnique("gep"), CurBB);
1663 VIndices[i] = Index;
1666 // Add to the CIndices list, if requested.
1668 CIndices->push_back(cast<Constant>(Index));
1672 GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true);
1674 error("Index list invalid for constant getelementptr");
1678 unsigned upgradeCallingConv(unsigned CC) {
1680 case OldCallingConv::C : return CallingConv::C;
1681 case OldCallingConv::CSRet : return CallingConv::C;
1682 case OldCallingConv::Fast : return CallingConv::Fast;
1683 case OldCallingConv::Cold : return CallingConv::Cold;
1684 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1685 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1691 Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1692 bool debug, bool addAttrs)
1695 CurFilename = infile;
1698 AddAttributes = addAttrs;
1699 ObsoleteVarArgs = false;
1702 CurModule.CurrentModule = new Module(CurFilename);
1704 // Check to make sure the parser succeeded
1707 delete ParserResult;
1708 std::cerr << "llvm-upgrade: parse failed.\n";
1712 // Check to make sure that parsing produced a result
1713 if (!ParserResult) {
1714 std::cerr << "llvm-upgrade: no parse result.\n";
1718 // Reset ParserResult variable while saving its value for the result.
1719 Module *Result = ParserResult;
1722 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1725 if ((F = Result->getFunction("llvm.va_start"))
1726 && F->getFunctionType()->getNumParams() == 0)
1727 ObsoleteVarArgs = true;
1728 if((F = Result->getFunction("llvm.va_copy"))
1729 && F->getFunctionType()->getNumParams() == 1)
1730 ObsoleteVarArgs = true;
1733 if (ObsoleteVarArgs && NewVarArgs) {
1734 error("This file is corrupt: it uses both new and old style varargs");
1738 if(ObsoleteVarArgs) {
1739 if(Function* F = Result->getFunction("llvm.va_start")) {
1740 if (F->arg_size() != 0) {
1741 error("Obsolete va_start takes 0 argument");
1747 //bar = alloca typeof(foo)
1751 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1752 const Type* ArgTy = F->getFunctionType()->getReturnType();
1753 const Type* ArgTyPtr = PointerType::get(ArgTy);
1754 Function* NF = cast<Function>(Result->getOrInsertFunction(
1755 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1757 while (!F->use_empty()) {
1758 CallInst* CI = cast<CallInst>(F->use_back());
1759 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1760 new CallInst(NF, bar, "", CI);
1761 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1762 CI->replaceAllUsesWith(foo);
1763 CI->getParent()->getInstList().erase(CI);
1765 Result->getFunctionList().erase(F);
1768 if(Function* F = Result->getFunction("llvm.va_end")) {
1769 if(F->arg_size() != 1) {
1770 error("Obsolete va_end takes 1 argument");
1776 //bar = alloca 1 of typeof(foo)
1778 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1779 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1780 const Type* ArgTyPtr = PointerType::get(ArgTy);
1781 Function* NF = cast<Function>(Result->getOrInsertFunction(
1782 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
1784 while (!F->use_empty()) {
1785 CallInst* CI = cast<CallInst>(F->use_back());
1786 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1787 new StoreInst(CI->getOperand(1), bar, CI);
1788 new CallInst(NF, bar, "", CI);
1789 CI->getParent()->getInstList().erase(CI);
1791 Result->getFunctionList().erase(F);
1794 if(Function* F = Result->getFunction("llvm.va_copy")) {
1795 if(F->arg_size() != 1) {
1796 error("Obsolete va_copy takes 1 argument");
1801 //a = alloca 1 of typeof(foo)
1802 //b = alloca 1 of typeof(foo)
1807 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1808 const Type* ArgTy = F->getFunctionType()->getReturnType();
1809 const Type* ArgTyPtr = PointerType::get(ArgTy);
1810 Function* NF = cast<Function>(Result->getOrInsertFunction(
1811 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
1813 while (!F->use_empty()) {
1814 CallInst* CI = cast<CallInst>(F->use_back());
1815 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1816 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1817 new StoreInst(CI->getOperand(1), b, CI);
1818 new CallInst(NF, a, b, "", CI);
1819 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1820 CI->replaceAllUsesWith(foo);
1821 CI->getParent()->getInstList().erase(CI);
1823 Result->getFunctionList().erase(F);
1830 } // end llvm namespace
1832 using namespace llvm;
1836 /* Enabling traces. */
1841 /* Enabling verbose error messages. */
1842 #ifdef YYERROR_VERBOSE
1843 # undef YYERROR_VERBOSE
1844 # define YYERROR_VERBOSE 1
1846 # define YYERROR_VERBOSE 0
1849 /* Enabling the token table. */
1850 #ifndef YYTOKEN_TABLE
1851 # define YYTOKEN_TABLE 0
1854 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1855 #line 1476 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
1856 typedef union YYSTYPE {
1857 llvm::Module *ModuleVal;
1858 llvm::Function *FunctionVal;
1859 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1860 llvm::BasicBlock *BasicBlockVal;
1861 llvm::TerminatorInst *TermInstVal;
1862 llvm::InstrInfo InstVal;
1863 llvm::ConstInfo ConstVal;
1864 llvm::ValueInfo ValueVal;
1865 llvm::PATypeInfo TypeVal;
1866 llvm::TypeInfo PrimType;
1867 llvm::PHIListInfo PHIList;
1868 std::list<llvm::PATypeInfo> *TypeList;
1869 std::vector<llvm::ValueInfo> *ValueList;
1870 std::vector<llvm::ConstInfo> *ConstVector;
1873 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1874 // Represent the RHS of PHI node
1875 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1877 llvm::GlobalValue::LinkageTypes Linkage;
1885 char *StrVal; // This memory is strdup'd!
1886 llvm::ValID ValIDVal; // strdup'd memory maybe!
1888 llvm::BinaryOps BinaryOpVal;
1889 llvm::TermOps TermOpVal;
1890 llvm::MemoryOps MemOpVal;
1891 llvm::OtherOps OtherOpVal;
1892 llvm::CastOps CastOpVal;
1893 llvm::ICmpInst::Predicate IPred;
1894 llvm::FCmpInst::Predicate FPred;
1895 llvm::Module::Endianness Endianness;
1897 /* Line 196 of yacc.c. */
1898 #line 1899 "UpgradeParser.tab.c"
1899 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1900 # define YYSTYPE_IS_DECLARED 1
1901 # define YYSTYPE_IS_TRIVIAL 1
1906 /* Copy the second part of user declarations. */
1909 /* Line 219 of yacc.c. */
1910 #line 1911 "UpgradeParser.tab.c"
1912 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1913 # define YYSIZE_T __SIZE_TYPE__
1915 #if ! defined (YYSIZE_T) && defined (size_t)
1916 # define YYSIZE_T size_t
1918 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1919 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1920 # define YYSIZE_T size_t
1922 #if ! defined (YYSIZE_T)
1923 # define YYSIZE_T unsigned int
1929 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1930 # define YY_(msgid) dgettext ("bison-runtime", msgid)
1934 # define YY_(msgid) msgid
1938 #if ! defined (yyoverflow) || YYERROR_VERBOSE
1940 /* The parser invokes alloca or malloc; define the necessary symbols. */
1942 # ifdef YYSTACK_USE_ALLOCA
1943 # if YYSTACK_USE_ALLOCA
1945 # define YYSTACK_ALLOC __builtin_alloca
1947 # define YYSTACK_ALLOC alloca
1948 # if defined (__STDC__) || defined (__cplusplus)
1949 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1950 # define YYINCLUDED_STDLIB_H
1956 # ifdef YYSTACK_ALLOC
1957 /* Pacify GCC's `empty if-body' warning. */
1958 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1959 # ifndef YYSTACK_ALLOC_MAXIMUM
1960 /* The OS might guarantee only one guard page at the bottom of the stack,
1961 and a page size can be as small as 4096 bytes. So we cannot safely
1962 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1963 to allow for a few compiler-allocated temporary stack slots. */
1964 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1967 # define YYSTACK_ALLOC YYMALLOC
1968 # define YYSTACK_FREE YYFREE
1969 # ifndef YYSTACK_ALLOC_MAXIMUM
1970 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1976 # define YYMALLOC malloc
1977 # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1978 && (defined (__STDC__) || defined (__cplusplus)))
1979 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1983 # define YYFREE free
1984 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1985 && (defined (__STDC__) || defined (__cplusplus)))
1986 void free (void *); /* INFRINGES ON USER NAME SPACE */
1993 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1996 #if (! defined (yyoverflow) \
1997 && (! defined (__cplusplus) \
1998 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
2000 /* A type that is properly aligned for any stack member. */
2007 /* The size of the maximum gap between one aligned stack and the next. */
2008 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2010 /* The size of an array large to enough to hold all stacks, each with
2012 # define YYSTACK_BYTES(N) \
2013 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
2014 + YYSTACK_GAP_MAXIMUM)
2016 /* Copy COUNT objects from FROM to TO. The source and destination do
2019 # if defined (__GNUC__) && 1 < __GNUC__
2020 # define YYCOPY(To, From, Count) \
2021 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2023 # define YYCOPY(To, From, Count) \
2027 for (yyi = 0; yyi < (Count); yyi++) \
2028 (To)[yyi] = (From)[yyi]; \
2034 /* Relocate STACK from its old location to the new one. The
2035 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2036 elements in the stack, and YYPTR gives the new location of the
2037 stack. Advance YYPTR to a properly aligned location for the next
2039 # define YYSTACK_RELOCATE(Stack) \
2042 YYSIZE_T yynewbytes; \
2043 YYCOPY (&yyptr->Stack, Stack, yysize); \
2044 Stack = &yyptr->Stack; \
2045 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2046 yyptr += yynewbytes / sizeof (*yyptr); \
2052 #if defined (__STDC__) || defined (__cplusplus)
2053 typedef signed char yysigned_char;
2055 typedef short int yysigned_char;
2058 /* YYFINAL -- State number of the termination state. */
2060 /* YYLAST -- Last index in YYTABLE. */
2063 /* YYNTOKENS -- Number of terminals. */
2064 #define YYNTOKENS 166
2065 /* YYNNTS -- Number of nonterminals. */
2067 /* YYNRULES -- Number of rules. */
2068 #define YYNRULES 309
2069 /* YYNRULES -- Number of states. */
2070 #define YYNSTATES 605
2072 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2073 #define YYUNDEFTOK 2
2074 #define YYMAXUTOK 406
2076 #define YYTRANSLATE(YYX) \
2077 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2079 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2080 static const unsigned char yytranslate[] =
2082 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2084 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2085 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2086 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2087 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2088 160, 152, 161, 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, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2092 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2093 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2094 158, 2, 2, 162, 2, 163, 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, 2, 2, 2, 2,
2099 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2103 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2104 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2105 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2106 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2107 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2108 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2109 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2110 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2111 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2112 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2113 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2114 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2115 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2116 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2117 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2118 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2119 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2120 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2121 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2122 145, 146, 147, 148, 149, 150, 151
2126 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2128 static const unsigned short int yyprhs[] =
2130 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2131 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2132 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2133 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2134 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2135 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2136 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2137 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2138 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2139 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2140 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2141 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2142 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2143 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2144 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2145 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2146 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2147 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2148 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2149 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2150 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2151 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2152 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2153 650, 652, 653, 654, 660, 661, 663, 665, 667, 669,
2154 671, 673, 675, 677, 679, 683, 685, 691, 693, 695,
2155 697, 699, 702, 705, 708, 712, 715, 716, 718, 720,
2156 722, 725, 728, 732, 742, 752, 761, 775, 777, 779,
2157 786, 792, 795, 802, 810, 812, 816, 818, 819, 822,
2158 824, 830, 836, 842, 849, 856, 859, 864, 869, 876,
2159 881, 886, 891, 896, 903, 910, 913, 921, 923, 926,
2160 927, 929, 930, 934, 941, 945, 952, 955, 960, 967
2163 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
2164 static const short int yyrhs[] =
2166 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2167 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2168 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2169 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2170 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2171 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2172 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2173 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2174 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2175 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2176 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2177 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2178 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2179 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2180 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2181 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2182 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2183 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2184 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2185 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2186 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2187 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2188 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2189 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2190 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2191 -1, 19, -1, 21, -1, 192, -1, 48, -1, 228,
2192 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2193 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2194 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2195 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2196 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2197 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2198 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2199 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2200 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2201 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2202 191, 39, -1, 191, 228, -1, 191, 197, -1, 191,
2203 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2204 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2205 36, 191, 156, -1, 110, 155, 196, 243, 156, -1,
2206 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2207 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2208 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2209 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2210 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2211 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2212 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2213 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2214 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2215 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2216 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2217 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2218 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2219 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2220 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2221 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2222 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2223 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2224 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2225 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2226 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2227 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2228 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2229 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2230 30, -1, 163, -1, 231, 220, -1, -1, 45, -1,
2231 47, -1, -1, -1, 31, 224, 222, 225, 217, -1,
2232 -1, 63, -1, 3, -1, 4, -1, 7, -1, 27,
2233 -1, 28, -1, 38, -1, 39, -1, 26, -1, 160,
2234 198, 161, -1, 197, -1, 61, 226, 24, 153, 24,
2235 -1, 167, -1, 212, -1, 228, -1, 227, -1, 191,
2236 229, -1, 231, 232, -1, 219, 232, -1, 233, 180,
2237 235, -1, 233, 237, -1, -1, 23, -1, 77, -1,
2238 78, -1, 72, 230, -1, 72, 8, -1, 73, 21,
2239 229, -1, 73, 9, 229, 153, 21, 229, 153, 21,
2240 229, -1, 74, 178, 229, 153, 21, 229, 157, 236,
2241 159, -1, 74, 178, 229, 153, 21, 229, 157, 159,
2242 -1, 75, 182, 189, 229, 155, 240, 156, 36, 21,
2243 229, 234, 21, 229, -1, 234, -1, 76, -1, 236,
2244 178, 227, 153, 21, 229, -1, 178, 227, 153, 21,
2245 229, -1, 180, 242, -1, 191, 157, 229, 153, 229,
2246 159, -1, 238, 153, 157, 229, 153, 229, 159, -1,
2247 230, -1, 239, 153, 230, -1, 239, -1, -1, 60,
2248 59, -1, 59, -1, 169, 191, 229, 153, 229, -1,
2249 170, 191, 229, 153, 229, -1, 171, 191, 229, 153,
2250 229, -1, 103, 172, 191, 229, 153, 229, -1, 104,
2251 173, 191, 229, 153, 229, -1, 49, 230, -1, 174,
2252 230, 153, 230, -1, 175, 230, 36, 191, -1, 112,
2253 230, 153, 230, 153, 230, -1, 113, 230, 153, 191,
2254 -1, 117, 230, 153, 191, -1, 118, 230, 153, 191,
2255 -1, 114, 230, 153, 230, -1, 115, 230, 153, 230,
2256 153, 230, -1, 116, 230, 153, 230, 153, 230, -1,
2257 111, 238, -1, 241, 182, 189, 229, 155, 240, 156,
2258 -1, 245, -1, 153, 239, -1, -1, 35, -1, -1,
2259 105, 191, 184, -1, 105, 191, 153, 15, 229, 184,
2260 -1, 106, 191, 184, -1, 106, 191, 153, 15, 229,
2261 184, -1, 107, 230, -1, 244, 108, 191, 229, -1,
2262 244, 109, 230, 153, 191, 229, -1, 110, 191, 229,
2266 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2267 static const unsigned short int yyrline[] =
2269 0, 1616, 1616, 1617, 1625, 1626, 1636, 1636, 1636, 1636,
2270 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1640, 1640, 1640,
2271 1644, 1644, 1644, 1644, 1644, 1644, 1648, 1648, 1649, 1649,
2272 1650, 1650, 1651, 1651, 1652, 1652, 1656, 1656, 1657, 1657,
2273 1658, 1658, 1659, 1659, 1660, 1660, 1661, 1661, 1662, 1662,
2274 1663, 1664, 1667, 1667, 1667, 1667, 1671, 1671, 1671, 1671,
2275 1671, 1671, 1671, 1672, 1672, 1672, 1672, 1672, 1672, 1678,
2276 1678, 1678, 1678, 1682, 1682, 1682, 1682, 1686, 1686, 1690,
2277 1690, 1695, 1698, 1703, 1704, 1705, 1706, 1707, 1708, 1709,
2278 1710, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1731,
2279 1732, 1740, 1741, 1749, 1758, 1759, 1766, 1767, 1771, 1775,
2280 1791, 1792, 1799, 1800, 1807, 1815, 1815, 1815, 1815, 1815,
2281 1815, 1815, 1816, 1816, 1816, 1816, 1816, 1821, 1825, 1829,
2282 1834, 1843, 1860, 1866, 1879, 1888, 1892, 1903, 1907, 1920,
2283 1924, 1931, 1932, 1938, 1945, 1957, 1987, 2000, 2023, 2051,
2284 2073, 2084, 2106, 2117, 2126, 2131, 2189, 2196, 2204, 2211,
2285 2218, 2222, 2226, 2235, 2250, 2263, 2272, 2300, 2313, 2322,
2286 2328, 2334, 2345, 2351, 2357, 2368, 2369, 2378, 2379, 2391,
2287 2400, 2401, 2402, 2403, 2404, 2420, 2440, 2442, 2444, 2444,
2288 2451, 2451, 2459, 2459, 2467, 2467, 2476, 2478, 2480, 2485,
2289 2499, 2500, 2504, 2507, 2515, 2519, 2526, 2530, 2534, 2538,
2290 2546, 2546, 2550, 2551, 2555, 2563, 2568, 2576, 2577, 2584,
2291 2591, 2595, 2777, 2777, 2781, 2791, 2791, 2795, 2800, 2801,
2292 2802, 2806, 2807, 2806, 2819, 2820, 2825, 2826, 2827, 2828,
2293 2831, 2834, 2835, 2836, 2837, 2858, 2861, 2875, 2876, 2881,
2294 2881, 2889, 2899, 2902, 2911, 2922, 2927, 2936, 2947, 2947,
2295 2950, 2953, 2956, 2960, 2966, 2982, 2989, 3045, 3048, 3054,
2296 3065, 3079, 3109, 3118, 3127, 3131, 3138, 3139, 3143, 3146,
2297 3152, 3170, 3187, 3202, 3215, 3228, 3239, 3257, 3266, 3275,
2298 3282, 3303, 3327, 3333, 3339, 3345, 3361, 3438, 3446, 3447,
2299 3451, 3452, 3456, 3462, 3469, 3475, 3482, 3489, 3502, 3528
2303 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2304 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2305 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2306 static const char *const yytname[] =
2308 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2309 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2310 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2311 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2312 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2313 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2314 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2315 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2316 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2317 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2318 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2319 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2320 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2321 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2322 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2323 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2324 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2325 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2326 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2327 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2328 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2329 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2330 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2331 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2332 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2333 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2334 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2335 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2336 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2337 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2338 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2339 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2340 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2341 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2342 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5", "@6",
2343 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2344 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2345 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2346 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2347 "OptVolatile", "MemoryInst", 0
2352 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2354 static const unsigned short int yytoknum[] =
2356 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2357 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2358 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2359 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2360 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2361 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2362 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2363 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2364 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2365 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2366 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2367 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2368 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2369 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2370 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2371 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2372 60, 62, 123, 125, 42, 99
2376 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2377 static const unsigned char yyr1[] =
2379 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2380 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2381 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2382 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2383 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2384 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2385 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2386 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2387 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2388 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2389 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2390 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2391 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2392 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2393 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2394 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2395 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2396 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2397 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2398 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2399 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2400 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2401 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2402 222, 224, 225, 223, 226, 226, 227, 227, 227, 227,
2403 227, 227, 227, 227, 227, 227, 227, 228, 228, 229,
2404 229, 230, 231, 231, 232, 233, 233, 233, 234, 234,
2405 235, 235, 235, 235, 235, 235, 235, 235, 235, 236,
2406 236, 237, 238, 238, 239, 239, 240, 240, 241, 241,
2407 242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
2408 242, 242, 242, 242, 242, 242, 242, 242, 243, 243,
2409 244, 244, 245, 245, 245, 245, 245, 245, 245, 245
2412 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2413 static const unsigned char yyr2[] =
2415 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2423 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2424 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2425 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2426 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2427 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2428 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2429 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2430 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2431 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2432 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2433 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2434 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2435 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2436 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2437 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2438 1, 0, 0, 5, 0, 1, 1, 1, 1, 1,
2439 1, 1, 1, 1, 3, 1, 5, 1, 1, 1,
2440 1, 2, 2, 2, 3, 2, 0, 1, 1, 1,
2441 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
2442 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
2443 5, 5, 5, 6, 6, 2, 4, 4, 6, 4,
2444 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
2445 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
2448 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2449 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2450 means the default is an error. */
2451 static const unsigned short int yydefact[] =
2453 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2454 86, 87, 88, 89, 0, 91, 256, 180, 181, 256,
2455 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2456 0, 92, 93, 94, 95, 96, 97, 0, 0, 257,
2457 253, 82, 225, 226, 227, 252, 0, 0, 0, 0,
2458 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2459 230, 232, 199, 182, 98, 2, 3, 111, 115, 116,
2460 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2461 128, 0, 0, 0, 0, 247, 0, 0, 110, 127,
2462 114, 248, 129, 222, 223, 224, 301, 255, 0, 0,
2463 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2464 0, 0, 91, 130, 0, 0, 0, 113, 135, 139,
2465 0, 0, 144, 138, 300, 0, 279, 0, 0, 0,
2466 0, 91, 268, 258, 259, 6, 7, 8, 9, 10,
2467 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2468 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2469 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2470 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2471 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2472 0, 267, 254, 91, 271, 0, 297, 204, 201, 200,
2473 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2474 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2475 0, 0, 0, 188, 233, 0, 0, 0, 0, 0,
2476 134, 220, 143, 141, 0, 0, 285, 278, 261, 260,
2477 0, 0, 72, 76, 71, 75, 70, 74, 69, 73,
2478 77, 78, 0, 0, 26, 27, 28, 29, 30, 31,
2479 32, 33, 34, 35, 0, 50, 51, 46, 47, 48,
2480 49, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2481 45, 0, 101, 101, 306, 0, 0, 295, 0, 0,
2482 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2483 0, 0, 0, 0, 206, 106, 106, 106, 160, 161,
2484 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2485 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2486 0, 0, 0, 0, 156, 155, 106, 112, 112, 137,
2487 0, 140, 219, 213, 216, 217, 0, 0, 131, 236,
2488 237, 238, 243, 239, 240, 241, 242, 234, 0, 245,
2489 250, 249, 251, 0, 262, 0, 0, 0, 0, 0,
2490 302, 0, 304, 299, 0, 0, 0, 0, 0, 0,
2491 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2492 0, 207, 0, 193, 195, 191, 0, 0, 0, 0,
2493 0, 0, 0, 146, 176, 0, 0, 0, 150, 0,
2494 147, 0, 0, 0, 0, 0, 189, 132, 133, 136,
2495 212, 214, 0, 104, 142, 235, 0, 0, 0, 0,
2496 0, 0, 0, 0, 0, 0, 0, 309, 0, 0,
2497 0, 289, 292, 0, 0, 290, 291, 0, 0, 0,
2498 286, 287, 0, 307, 0, 0, 0, 108, 106, 0,
2499 0, 299, 0, 0, 0, 0, 0, 145, 135, 114,
2500 0, 148, 149, 0, 0, 0, 0, 0, 218, 215,
2501 105, 99, 0, 244, 0, 0, 277, 0, 0, 101,
2502 102, 101, 274, 298, 0, 0, 0, 0, 0, 280,
2503 281, 282, 277, 0, 103, 109, 107, 0, 0, 0,
2504 0, 0, 0, 0, 175, 152, 0, 0, 0, 0,
2505 0, 0, 0, 221, 0, 0, 0, 276, 0, 283,
2506 284, 0, 303, 305, 0, 0, 0, 288, 293, 294,
2507 0, 308, 0, 0, 164, 0, 0, 0, 0, 151,
2508 0, 0, 0, 0, 0, 100, 246, 0, 0, 0,
2509 275, 272, 0, 296, 0, 0, 0, 172, 0, 0,
2510 166, 167, 168, 171, 163, 0, 265, 0, 0, 0,
2511 273, 169, 170, 0, 0, 0, 263, 0, 264, 0,
2512 0, 165, 173, 174, 0, 0, 0, 0, 0, 0,
2516 /* YYDEFGOTO[NTERM-NUM]. */
2517 static const short int yydefgoto[] =
2519 -1, 85, 312, 329, 330, 331, 264, 281, 332, 333,
2520 219, 220, 252, 221, 25, 15, 37, 523, 370, 457,
2521 481, 393, 458, 86, 87, 222, 89, 90, 120, 234,
2522 404, 359, 405, 108, 1, 2, 3, 336, 307, 305,
2523 306, 63, 200, 50, 103, 204, 91, 421, 344, 345,
2524 346, 38, 95, 16, 44, 17, 61, 18, 28, 112,
2525 426, 360, 92, 362, 492, 19, 40, 41, 191, 192,
2526 578, 97, 287, 527, 528, 193, 194, 437, 195, 196
2529 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2531 #define YYPACT_NINF -555
2532 static const short int yypact[] =
2534 -555, 136, 58, 247, -555, -555, -555, -555, -555, -555,
2535 -555, -555, -555, -555, 96, 181, 141, -555, -555, -9,
2536 -555, -555, 16, 7, 114, 65, 39, -555, 50, 188,
2537 210, -555, -555, -555, -555, -555, -555, 1357, -19, -555,
2538 -555, 134, -555, -555, -555, -555, 68, 69, 70, 73,
2539 -555, 60, 188, 1357, 4, 4, 4, 4, -555, -555,
2540 -555, -555, -555, -555, -555, -555, -555, 63, -555, -555,
2541 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2542 -555, 222, 224, 1, 171, -555, 134, 84, -555, -555,
2543 -103, -555, -555, -555, -555, -555, 1611, -555, 216, 66,
2544 238, 219, 233, -555, -555, -555, -555, -555, 1418, 1418,
2545 1418, 1459, 181, -555, 100, 101, 737, -555, -555, -103,
2546 -112, 105, 803, -555, -555, 1418, -555, 202, 1479, 13,
2547 221, 181, -555, -555, -555, -555, -555, -555, -555, -555,
2548 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2549 -555, -555, -555, -555, -555, -555, -555, -555, -555, 77,
2550 377, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418,
2551 1418, 1418, 1418, -555, -555, -555, -555, -555, -555, -555,
2552 -555, -555, -555, -555, -555, -555, 1418, 1418, 1418, 1418,
2553 1418, -555, -555, 181, -555, 33, -555, -555, -555, -555,
2554 -555, -555, -555, -555, -15, -555, -555, -555, 36, 158,
2555 262, 164, 264, 167, 266, 169, 268, 269, 270, 204,
2556 271, 274, 579, -555, -555, 1418, 1418, 121, -67, 1418,
2557 -555, 1199, -555, 120, 127, 920, -555, -555, 63, -555,
2558 920, 920, -555, -555, -555, -555, -555, -555, -555, -555,
2559 -555, -555, 920, 1357, -555, -555, -555, -555, -555, -555,
2560 -555, -555, -555, -555, 1418, -555, -555, -555, -555, -555,
2561 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2562 -555, 1418, 142, 143, -555, 920, 147, 153, 154, 155,
2563 157, 165, 166, 168, 170, 920, 920, 920, 173, 275,
2564 1357, 1418, 1418, 293, -555, 174, 174, 174, -555, -555,
2565 -555, -555, -555, -555, -555, -555, -555, -555, 77, 377,
2566 175, 177, 180, 182, 183, 1240, 1520, 757, 296, 192,
2567 193, 199, 203, 207, -555, -555, 174, -45, -71, -555,
2568 161, -103, -555, 134, -555, 176, 209, 1260, -555, -555,
2569 -555, -555, -555, -555, -555, -555, -555, 261, 1459, -555,
2570 -555, -555, -555, 206, -555, 213, 920, 920, 920, -2,
2571 -555, 0, -555, 215, 920, 179, 1418, 1418, 1418, 1418,
2572 1418, 1418, 1418, 217, 218, 223, 1418, 1418, 920, 920,
2573 226, -555, -17, -555, -555, -555, 214, 220, 1459, 1459,
2574 1459, 1459, 1459, -555, -555, -13, 778, -94, -555, -40,
2575 -555, 1459, 1459, 1459, 1459, 1459, -555, -555, -555, -555,
2576 -555, -555, 1301, 346, -555, -555, 357, -69, 361, 362,
2577 229, 234, 235, 920, 382, 920, 1418, -555, 236, 920,
2578 237, -555, -555, 239, 240, -555, -555, 920, 920, 920,
2579 -555, -555, 241, -555, 1418, 367, 390, -555, 174, 1459,
2580 1459, 215, 242, 245, 248, 249, 1459, -555, 254, -16,
2581 -8, -555, -555, 250, 253, 263, 272, 364, -555, -555,
2582 -555, 366, 273, -555, 920, 920, 1418, 920, 920, 276,
2583 -555, 276, -555, 279, 920, 280, 1418, 1418, 1418, -555,
2584 -555, -555, 1418, 920, -555, -555, -555, 281, 282, 283,
2585 1459, 1459, 1459, 1459, -555, -555, 284, 1459, 1459, 1459,
2586 1459, 1418, 423, -555, 416, 288, 285, 279, 290, -555,
2587 -555, 391, -555, -555, 1418, 294, 920, -555, -555, -555,
2588 291, -555, 1459, 1459, -555, 299, 298, 302, 303, -555,
2589 301, 306, 307, 308, 310, -555, -555, 437, 15, 432,
2590 -555, -555, 312, -555, 316, 319, 1459, -555, 1459, 1459,
2591 -555, -555, -555, -555, -555, 920, -555, 1046, 64, 460,
2592 -555, -555, -555, 326, 329, 331, -555, 335, -555, 1046,
2593 920, -555, -555, -555, 468, 337, 132, 920, 470, 472,
2594 -555, 920, 920, -555, -555
2597 /* YYPGOTO[NTERM-NUM]. */
2598 static const short int yypgoto[] =
2600 -555, -555, -555, 398, 399, 400, 198, 200, 402, 403,
2601 -128, -127, -525, -555, 476, 493, -111, -555, -276, 97,
2602 -555, -298, -555, -47, -555, -37, -555, -60, -62, -555,
2603 -99, 300, -308, 61, -555, -555, -555, -555, -555, -555,
2604 -555, 469, -555, -555, -555, -555, 8, -555, 102, -555,
2605 -555, 411, -555, -555, -555, -555, -555, 523, -555, -555,
2606 -555, -554, -11, 112, -124, -555, 508, -555, -68, -555,
2607 -555, -555, -555, 93, 28, -555, -555, 71, -555, -555
2610 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2611 positive, shift that token. If negative, reduce the rule which
2612 number is the opposite. If zero, do what YYDEFACT says.
2613 If YYTABLE_NINF, syntax error. */
2614 #define YYTABLE_NINF -180
2615 static const short int yytable[] =
2617 88, 236, 250, 251, 239, 115, 105, 372, 394, 395,
2618 93, 26, 223, 433, 39, 435, 88, 455, 407, 409,
2619 253, 42, 240, 587, 119, 242, 243, 244, 245, 246,
2620 247, 248, 249, 577, 241, 595, 106, 107, 416, 284,
2621 456, 229, 288, 289, 290, 291, 292, 293, 294, 26,
2622 427, 230, -112, 589, 228, 434, 119, 434, -179, 466,
2623 233, 123, 119, 308, 309, 298, 299, 471, 46, 47,
2624 48, 205, 206, 207, 242, 243, 244, 245, 246, 247,
2625 248, 249, 300, 5, 466, 53, 229, 49, 235, 6,
2626 418, 235, 483, 123, 121, 59, 340, 60, 470, 7,
2627 8, 9, 10, 11, 12, 13, 7, 8, 9, 10,
2628 54, 12, 55, 466, 417, 56, 109, 110, 111, 123,
2629 14, 198, 199, 472, 282, 283, 235, 285, 286, 235,
2630 235, 235, 235, 235, 235, 235, 4, -139, 303, -112,
2631 466, 301, 302, 94, 304, 466, 467, -139, 123, 295,
2632 296, 297, 235, 235, 43, 516, 20, 29, 21, 51,
2633 506, -72, -72, 116, 39, 337, 338, -71, -71, 341,
2634 -70, -70, -69, -69, 576, 52, 65, 66, 390, 117,
2635 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2636 78, 58, 79, 20, 343, 21, 254, 255, 256, 257,
2637 258, 259, 260, 261, 262, 263, 366, 310, 311, 133,
2638 134, 335, 62, 532, 64, 533, 88, 102, -113, 80,
2639 98, 99, 100, 588, 361, 101, 113, 367, 114, 361,
2640 361, 242, 243, 244, 245, 246, 247, 248, 249, 122,
2641 197, 361, 201, 202, 368, 30, 31, 32, 33, 34,
2642 35, 36, 440, 388, 442, 443, 444, 203, 225, 226,
2643 231, 237, 450, 88, 389, 235, -76, -82, -75, 20,
2644 -74, 21, -73, 347, 361, 313, -79, -80, 6, -82,
2645 -82, 314, 339, 348, 361, 361, 361, 341, -82, -82,
2646 -82, -82, -82, -82, -82, 369, 371, -82, 22, 461,
2647 462, 463, 464, 465, 374, 23, 375, 376, 377, 24,
2648 378, 387, 473, 474, 475, 476, 477, 391, 379, 380,
2649 410, 381, 419, 382, 425, 81, 386, 392, 82, 422,
2650 398, 83, 399, 84, 118, 400, 439, 401, 402, 235,
2651 441, 235, 235, 235, 445, 446, 469, 411, 412, 235,
2652 451, 420, 363, 364, 413, 361, 361, 361, 414, 428,
2653 507, 508, 415, 361, 365, 423, 429, 514, 436, 459,
2654 447, 448, 537, 538, 539, 460, 449, 361, 361, 454,
2655 455, 482, 484, 485, 486, 343, 490, 487, 488, 494,
2656 496, 504, 497, 498, 505, 510, 502, 373, 511, 235,
2657 521, 512, 513, 517, 265, 266, 518, 383, 384, 385,
2658 560, 545, 546, 547, 548, 515, 519, 503, 550, 551,
2659 552, 553, 361, 522, 361, 520, 524, 555, 361, 531,
2660 250, 251, 534, 536, 542, 543, 361, 361, 361, 544,
2661 556, 557, 558, 564, 565, 549, 559, 563, 434, 235,
2662 250, 251, 566, 561, 567, 568, 569, 570, 575, 235,
2663 235, 235, 571, 572, 573, 235, 574, 583, 579, 584,
2664 585, 580, 581, 361, 361, 582, 361, 361, 430, 431,
2665 432, 590, 591, 361, 554, 592, 438, 593, 594, 597,
2666 598, 601, 361, 602, 186, 187, 188, 235, 189, 190,
2667 452, 453, 267, 268, 269, 270, 271, 272, 273, 274,
2668 275, 276, 277, 278, 279, 280, 396, 96, 57, 397,
2669 480, 104, 334, 224, 479, 361, 27, 45, 599, 493,
2670 540, 0, 509, 0, 0, 0, 0, 0, 0, 0,
2671 0, 0, 0, 0, 0, 489, 0, 491, 0, 0,
2672 0, 495, 0, 0, 0, 0, 0, 0, 0, 499,
2673 500, 501, 0, 0, 361, 0, 0, 0, 0, 0,
2674 0, 0, 0, 0, 0, 0, 0, 0, 0, 361,
2675 0, 0, 0, 0, 65, 66, 361, 0, 0, 0,
2676 361, 361, 0, 0, 0, 0, 525, 526, 0, 529,
2677 530, 20, 0, 21, 0, 315, 535, 0, 0, 0,
2678 0, 0, 0, 0, 0, 541, 0, 316, 317, 0,
2679 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2680 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2681 0, 0, 0, 0, 0, 0, 0, 0, 562, 0,
2682 0, 0, 0, 0, 0, 0, 0, 0, 135, 136,
2683 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
2684 147, 148, 149, 150, 151, 152, 153, 154, 155, 156,
2685 157, 158, 318, 319, 0, 0, 0, 586, 0, 320,
2686 0, 321, 0, 322, 323, 324, 0, 0, 0, 0,
2687 0, 0, 596, 0, 0, 0, 0, 0, 0, 600,
2688 0, 0, 0, 603, 604, 0, 0, 0, 173, 174,
2689 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
2690 185, 0, 0, 0, 0, 0, 325, 0, 0, 326,
2691 0, 327, 65, 66, 328, 117, 68, 69, 70, 71,
2692 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2693 0, 21, 65, 66, 0, 117, 208, 209, 210, 211,
2694 212, 213, 214, 215, 216, 217, 218, 0, 79, 20,
2695 0, 21, 0, 65, 66, 80, 117, 208, 209, 210,
2696 211, 212, 213, 214, 215, 216, 217, 218, 0, 79,
2697 20, 0, 21, 0, 0, 80, 0, 0, 65, 66,
2698 0, 117, 68, 69, 70, 71, 72, 73, 74, 75,
2699 76, 77, 78, 0, 79, 20, 80, 21, 0, 0,
2700 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2701 232, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2702 0, 80, 0, 0, 0, 0, 0, 0, 0, 0,
2703 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2704 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2706 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2707 227, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2708 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2709 408, 0, 0, 349, 350, 65, 66, 351, 0, 0,
2710 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2711 84, 468, 20, 0, 21, 0, 352, 353, 354, 0,
2712 0, 0, 0, 0, 0, 0, 0, 81, 355, 356,
2713 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2714 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2715 0, 357, 0, 0, 0, 0, 0, 0, 0, 0,
2716 0, 0, 0, 0, 0, 0, 0, 0, 0, 135,
2717 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2718 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
2719 156, 157, 158, 318, 319, 0, 0, 0, 0, 0,
2720 320, 0, 321, 0, 322, 323, 324, 0, 0, 0,
2721 0, 0, 0, 0, 0, 0, 0, 0, 0, 349,
2722 350, 0, 0, 351, 0, 0, 0, 0, 0, 173,
2723 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2724 184, 185, 352, 353, 354, 0, 0, 0, 0, 0,
2725 358, 0, 0, 0, 355, 356, 0, 0, 0, 0,
2726 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2727 0, 0, 0, 0, 0, 0, 0, 357, 0, 0,
2728 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2729 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2730 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2731 150, 151, 152, 153, 154, 155, 156, 157, 158, 318,
2732 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
2733 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
2734 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2735 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2736 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2737 0, 0, 0, 0, 65, 66, 358, 117, 68, 69,
2738 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2739 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2740 0, 0, 0, 0, 0, 0, 342, 0, 0, 0,
2741 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2742 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2743 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2744 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2745 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2746 0, 0, 0, 0, 0, 0, 0, 424, 0, 0,
2747 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2748 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2749 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2750 0, 0, 0, 0, 0, 0, 0, 0, 478, 0,
2751 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2752 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2753 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2754 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2755 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2756 0, 0, 0, 0, 81, 0, 0, 82, 0, 403,
2757 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2758 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2759 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2760 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2761 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2762 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2763 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2764 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2765 79, 20, 0, 21, 65, 66, 0, 238, 68, 69,
2766 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2767 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2768 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2769 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2770 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2771 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2772 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2773 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2774 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2775 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2776 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2777 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2778 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2779 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2780 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2781 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
2782 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2783 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2784 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2785 83, 0, 406, 128, 129, 130, 131, 132, 133, 134,
2786 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2787 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2788 155, 156, 157, 158, 159, 160, 161, 162, 163, 0,
2789 0, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2790 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2791 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2792 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2796 static const short int yycheck[] =
2798 37, 125, 130, 130, 128, 4, 53, 283, 306, 307,
2799 29, 3, 111, 15, 23, 15, 53, 34, 326, 327,
2800 131, 30, 9, 577, 84, 10, 11, 12, 13, 14,
2801 15, 16, 17, 558, 21, 589, 32, 33, 336, 163,
2802 57, 153, 166, 167, 168, 169, 170, 171, 172, 41,
2803 358, 163, 155, 578, 116, 57, 116, 57, 0, 153,
2804 122, 164, 122, 27, 28, 189, 190, 161, 52, 53,
2805 54, 108, 109, 110, 10, 11, 12, 13, 14, 15,
2806 16, 17, 193, 25, 153, 20, 153, 71, 125, 31,
2807 161, 128, 161, 164, 86, 45, 163, 47, 406, 41,
2808 42, 43, 44, 45, 46, 47, 41, 42, 43, 44,
2809 45, 46, 47, 153, 159, 50, 55, 56, 57, 164,
2810 62, 55, 56, 163, 161, 162, 163, 164, 165, 166,
2811 167, 168, 169, 170, 171, 172, 0, 153, 153, 155,
2812 153, 108, 109, 162, 159, 153, 159, 163, 164, 186,
2813 187, 188, 189, 190, 163, 163, 22, 61, 24, 152,
2814 458, 3, 4, 162, 23, 225, 226, 3, 4, 229,
2815 3, 4, 3, 4, 159, 61, 5, 6, 302, 8,
2816 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2817 19, 152, 21, 22, 231, 24, 119, 120, 121, 122,
2818 123, 124, 125, 126, 127, 128, 253, 3, 4, 77,
2819 78, 222, 24, 489, 4, 491, 253, 157, 155, 48,
2820 152, 152, 152, 159, 235, 152, 4, 264, 4, 240,
2821 241, 10, 11, 12, 13, 14, 15, 16, 17, 155,
2822 24, 252, 4, 24, 281, 64, 65, 66, 67, 68,
2823 69, 70, 376, 300, 378, 379, 380, 24, 158, 158,
2824 155, 59, 386, 300, 301, 302, 4, 20, 4, 22,
2825 4, 24, 4, 153, 285, 4, 7, 7, 31, 32,
2826 33, 7, 161, 156, 295, 296, 297, 347, 41, 42,
2827 43, 44, 45, 46, 47, 153, 153, 50, 51, 398,
2828 399, 400, 401, 402, 157, 58, 153, 153, 153, 62,
2829 153, 36, 411, 412, 413, 414, 415, 24, 153, 153,
2830 24, 153, 161, 153, 63, 154, 153, 153, 157, 153,
2831 155, 160, 155, 162, 163, 155, 157, 155, 155, 376,
2832 377, 378, 379, 380, 381, 382, 406, 155, 155, 386,
2833 387, 343, 240, 241, 155, 366, 367, 368, 155, 153,
2834 459, 460, 155, 374, 252, 156, 153, 466, 153, 155,
2835 153, 153, 496, 497, 498, 155, 153, 388, 389, 153,
2836 34, 24, 21, 21, 155, 422, 4, 153, 153, 153,
2837 153, 24, 153, 153, 4, 153, 155, 285, 153, 436,
2838 36, 153, 153, 153, 27, 28, 153, 295, 296, 297,
2839 534, 510, 511, 512, 513, 161, 153, 454, 517, 518,
2840 519, 520, 433, 57, 435, 153, 153, 4, 439, 153,
2841 558, 558, 153, 153, 153, 153, 447, 448, 449, 156,
2842 24, 153, 157, 542, 543, 161, 156, 156, 57, 486,
2843 578, 578, 153, 159, 156, 153, 153, 156, 21, 496,
2844 497, 498, 156, 156, 156, 502, 156, 566, 36, 568,
2845 569, 159, 156, 484, 485, 156, 487, 488, 366, 367,
2846 368, 21, 156, 494, 521, 156, 374, 156, 153, 21,
2847 153, 21, 503, 21, 96, 96, 96, 534, 96, 96,
2848 388, 389, 125, 126, 127, 128, 129, 130, 131, 132,
2849 133, 134, 135, 136, 137, 138, 318, 41, 25, 319,
2850 423, 52, 222, 112, 422, 536, 3, 19, 596, 436,
2851 502, -1, 461, -1, -1, -1, -1, -1, -1, -1,
2852 -1, -1, -1, -1, -1, 433, -1, 435, -1, -1,
2853 -1, 439, -1, -1, -1, -1, -1, -1, -1, 447,
2854 448, 449, -1, -1, 575, -1, -1, -1, -1, -1,
2855 -1, -1, -1, -1, -1, -1, -1, -1, -1, 590,
2856 -1, -1, -1, -1, 5, 6, 597, -1, -1, -1,
2857 601, 602, -1, -1, -1, -1, 484, 485, -1, 487,
2858 488, 22, -1, 24, -1, 26, 494, -1, -1, -1,
2859 -1, -1, -1, -1, -1, 503, -1, 38, 39, -1,
2860 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2861 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2862 -1, -1, -1, -1, -1, -1, -1, -1, 536, -1,
2863 -1, -1, -1, -1, -1, -1, -1, -1, 79, 80,
2864 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2865 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
2866 101, 102, 103, 104, -1, -1, -1, 575, -1, 110,
2867 -1, 112, -1, 114, 115, 116, -1, -1, -1, -1,
2868 -1, -1, 590, -1, -1, -1, -1, -1, -1, 597,
2869 -1, -1, -1, 601, 602, -1, -1, -1, 139, 140,
2870 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
2871 151, -1, -1, -1, -1, -1, 157, -1, -1, 160,
2872 -1, 162, 5, 6, 165, 8, 9, 10, 11, 12,
2873 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2874 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
2875 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2876 -1, 24, -1, 5, 6, 48, 8, 9, 10, 11,
2877 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2878 22, -1, 24, -1, -1, 48, -1, -1, 5, 6,
2879 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2880 17, 18, 19, -1, 21, 22, 48, 24, -1, -1,
2881 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2882 37, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2883 -1, 48, -1, -1, -1, -1, -1, -1, -1, -1,
2884 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2885 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2886 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2887 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2888 163, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2889 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2890 163, -1, -1, 3, 4, 5, 6, 7, -1, -1,
2891 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2892 162, 163, 22, -1, 24, -1, 26, 27, 28, -1,
2893 -1, -1, -1, -1, -1, -1, -1, 154, 38, 39,
2894 157, -1, -1, 160, -1, 162, -1, -1, -1, -1,
2895 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2896 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
2897 -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
2898 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2899 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
2900 100, 101, 102, 103, 104, -1, -1, -1, -1, -1,
2901 110, -1, 112, -1, 114, 115, 116, -1, -1, -1,
2902 -1, -1, -1, -1, -1, -1, -1, -1, -1, 3,
2903 4, -1, -1, 7, -1, -1, -1, -1, -1, 139,
2904 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2905 150, 151, 26, 27, 28, -1, -1, -1, -1, -1,
2906 160, -1, -1, -1, 38, 39, -1, -1, -1, -1,
2907 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2908 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
2909 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2910 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2911 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2912 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2913 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
2914 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2915 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2916 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2917 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2918 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2919 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2920 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2921 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2922 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2923 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2924 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2925 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2926 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2927 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2928 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2929 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2930 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2931 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2932 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2933 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2934 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2935 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2936 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2937 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2938 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2939 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2940 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2941 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2942 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2943 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2944 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2945 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2946 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2947 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2948 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2949 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2950 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2951 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2952 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2953 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2954 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2955 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2956 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2957 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2958 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2959 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2960 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2961 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2962 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2963 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2964 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2965 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2966 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2967 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2968 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2969 99, 100, 101, 102, 103, 104, 105, 106, 107, -1,
2970 -1, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2971 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2972 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2973 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2977 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2978 symbol of state STATE-NUM. */
2979 static const unsigned char yystos[] =
2981 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2982 44, 45, 46, 47, 62, 181, 219, 221, 223, 231,
2983 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2984 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2985 232, 233, 30, 163, 220, 232, 52, 53, 54, 71,
2986 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2987 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2988 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2989 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2990 193, 212, 228, 29, 162, 218, 180, 237, 152, 152,
2991 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2992 199, 199, 225, 4, 4, 4, 162, 8, 163, 193,
2993 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2994 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2995 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2996 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2997 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
2998 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2999 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
3000 175, 234, 235, 241, 242, 244, 245, 24, 55, 56,
3001 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
3002 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
3003 177, 179, 191, 196, 217, 158, 158, 163, 194, 153,
3004 163, 155, 37, 194, 195, 191, 230, 59, 8, 230,
3005 9, 21, 10, 11, 12, 13, 14, 15, 16, 17,
3006 176, 177, 178, 182, 119, 120, 121, 122, 123, 124,
3007 125, 126, 127, 128, 172, 27, 28, 125, 126, 127,
3008 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
3009 138, 173, 191, 191, 230, 191, 191, 238, 230, 230,
3010 230, 230, 230, 230, 230, 191, 191, 191, 230, 230,
3011 182, 108, 109, 153, 159, 205, 206, 204, 27, 28,
3012 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
3013 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
3014 170, 171, 174, 175, 197, 228, 203, 193, 193, 161,
3015 163, 193, 37, 191, 214, 215, 216, 153, 156, 3,
3016 4, 7, 26, 27, 28, 38, 39, 61, 160, 197,
3017 227, 228, 229, 229, 229, 229, 189, 191, 191, 153,
3018 184, 153, 184, 229, 157, 153, 153, 153, 153, 153,
3019 153, 153, 153, 229, 229, 229, 153, 36, 189, 191,
3020 230, 24, 153, 187, 187, 187, 172, 173, 155, 155,
3021 155, 155, 155, 159, 196, 198, 162, 198, 163, 198,
3022 24, 155, 155, 155, 155, 155, 187, 159, 161, 161,
3023 212, 213, 153, 156, 37, 63, 226, 198, 153, 153,
3024 229, 229, 229, 15, 57, 15, 153, 243, 229, 157,
3025 230, 191, 230, 230, 230, 191, 191, 153, 153, 153,
3026 230, 191, 229, 229, 153, 34, 57, 185, 188, 155,
3027 155, 196, 196, 196, 196, 196, 153, 159, 163, 193,
3028 198, 161, 163, 196, 196, 196, 196, 196, 37, 214,
3029 185, 186, 24, 161, 21, 21, 155, 153, 153, 229,
3030 4, 229, 230, 239, 153, 229, 153, 153, 153, 229,
3031 229, 229, 155, 191, 24, 4, 187, 196, 196, 243,
3032 153, 153, 153, 153, 196, 161, 163, 153, 153, 153,
3033 153, 36, 57, 183, 153, 229, 229, 239, 240, 229,
3034 229, 153, 184, 184, 153, 229, 153, 230, 230, 230,
3035 240, 229, 153, 153, 156, 196, 196, 196, 196, 161,
3036 196, 196, 196, 196, 191, 4, 24, 153, 157, 156,
3037 230, 159, 229, 156, 196, 196, 153, 156, 153, 153,
3038 156, 156, 156, 156, 156, 21, 159, 178, 236, 36,
3039 159, 156, 156, 196, 196, 196, 229, 227, 159, 178,
3040 21, 156, 156, 156, 153, 227, 229, 21, 153, 234,
3041 229, 21, 21, 229, 229
3044 #define yyerrok (yyerrstatus = 0)
3045 #define yyclearin (yychar = YYEMPTY)
3046 #define YYEMPTY (-2)
3049 #define YYACCEPT goto yyacceptlab
3050 #define YYABORT goto yyabortlab
3051 #define YYERROR goto yyerrorlab
3054 /* Like YYERROR except do call yyerror. This remains here temporarily
3055 to ease the transition to the new meaning of YYERROR, for GCC.
3056 Once GCC version 2 has supplanted version 1, this can go. */
3058 #define YYFAIL goto yyerrlab
3060 #define YYRECOVERING() (!!yyerrstatus)
3062 #define YYBACKUP(Token, Value) \
3064 if (yychar == YYEMPTY && yylen == 1) \
3068 yytoken = YYTRANSLATE (yychar); \
3074 yyerror (YY_("syntax error: cannot back up")); \
3081 #define YYERRCODE 256
3084 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3085 If N is 0, then set CURRENT to the empty location which ends
3086 the previous symbol: RHS[0] (always defined). */
3088 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
3089 #ifndef YYLLOC_DEFAULT
3090 # define YYLLOC_DEFAULT(Current, Rhs, N) \
3094 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3095 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3096 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3097 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3101 (Current).first_line = (Current).last_line = \
3102 YYRHSLOC (Rhs, 0).last_line; \
3103 (Current).first_column = (Current).last_column = \
3104 YYRHSLOC (Rhs, 0).last_column; \
3110 /* YY_LOCATION_PRINT -- Print the location on the stream.
3111 This macro was not mandated originally: define only if we know
3112 we won't break user code: when these are the locations we know. */
3114 #ifndef YY_LOCATION_PRINT
3115 # if YYLTYPE_IS_TRIVIAL
3116 # define YY_LOCATION_PRINT(File, Loc) \
3117 fprintf (File, "%d.%d-%d.%d", \
3118 (Loc).first_line, (Loc).first_column, \
3119 (Loc).last_line, (Loc).last_column)
3121 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3126 /* YYLEX -- calling `yylex' with the right arguments. */
3129 # define YYLEX yylex (YYLEX_PARAM)
3131 # define YYLEX yylex ()
3134 /* Enable debugging if requested. */
3138 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3139 # define YYFPRINTF fprintf
3142 # define YYDPRINTF(Args) \
3148 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3152 YYFPRINTF (stderr, "%s ", Title); \
3153 yysymprint (stderr, \
3155 YYFPRINTF (stderr, "\n"); \
3159 /*------------------------------------------------------------------.
3160 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
3162 `------------------------------------------------------------------*/
3164 #if defined (__STDC__) || defined (__cplusplus)
3166 yy_stack_print (short int *bottom, short int *top)
3169 yy_stack_print (bottom, top)
3174 YYFPRINTF (stderr, "Stack now");
3175 for (/* Nothing. */; bottom <= top; ++bottom)
3176 YYFPRINTF (stderr, " %d", *bottom);
3177 YYFPRINTF (stderr, "\n");
3180 # define YY_STACK_PRINT(Bottom, Top) \
3183 yy_stack_print ((Bottom), (Top)); \
3187 /*------------------------------------------------.
3188 | Report that the YYRULE is going to be reduced. |
3189 `------------------------------------------------*/
3191 #if defined (__STDC__) || defined (__cplusplus)
3193 yy_reduce_print (int yyrule)
3196 yy_reduce_print (yyrule)
3201 unsigned long int yylno = yyrline[yyrule];
3202 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3204 /* Print the symbols being reduced, and their result. */
3205 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3206 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3207 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3210 # define YY_REDUCE_PRINT(Rule) \
3213 yy_reduce_print (Rule); \
3216 /* Nonzero means print parse trace. It is left uninitialized so that
3217 multiple parsers can coexist. */
3219 #else /* !YYDEBUG */
3220 # define YYDPRINTF(Args)
3221 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3222 # define YY_STACK_PRINT(Bottom, Top)
3223 # define YY_REDUCE_PRINT(Rule)
3224 #endif /* !YYDEBUG */
3227 /* YYINITDEPTH -- initial size of the parser's stacks. */
3229 # define YYINITDEPTH 200
3232 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3233 if the built-in stack extension method is used).
3235 Do not make this value too large; the results are undefined if
3236 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3237 evaluated with infinite-precision integer arithmetic. */
3240 # define YYMAXDEPTH 10000
3248 # if defined (__GLIBC__) && defined (_STRING_H)
3249 # define yystrlen strlen
3251 /* Return the length of YYSTR. */
3253 # if defined (__STDC__) || defined (__cplusplus)
3254 yystrlen (const char *yystr)
3260 const char *yys = yystr;
3262 while (*yys++ != '\0')
3265 return yys - yystr - 1;
3271 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3272 # define yystpcpy stpcpy
3274 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3277 # if defined (__STDC__) || defined (__cplusplus)
3278 yystpcpy (char *yydest, const char *yysrc)
3280 yystpcpy (yydest, yysrc)
3286 const char *yys = yysrc;
3288 while ((*yyd++ = *yys++) != '\0')
3297 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3298 quotes and backslashes, so that it's suitable for yyerror. The
3299 heuristic is that double-quoting is unnecessary unless the string
3300 contains an apostrophe, a comma, or backslash (other than
3301 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3302 null, do not copy; instead, return the length of what the result
3305 yytnamerr (char *yyres, const char *yystr)
3310 char const *yyp = yystr;
3317 goto do_not_strip_quotes;
3321 goto do_not_strip_quotes;
3334 do_not_strip_quotes: ;
3338 return yystrlen (yystr);
3340 return yystpcpy (yyres, yystr) - yyres;
3344 #endif /* YYERROR_VERBOSE */
3349 /*--------------------------------.
3350 | Print this symbol on YYOUTPUT. |
3351 `--------------------------------*/
3353 #if defined (__STDC__) || defined (__cplusplus)
3355 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
3358 yysymprint (yyoutput, yytype, yyvaluep)
3364 /* Pacify ``unused variable'' warnings. */
3367 if (yytype < YYNTOKENS)
3368 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3370 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3374 if (yytype < YYNTOKENS)
3375 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3382 YYFPRINTF (yyoutput, ")");
3385 #endif /* ! YYDEBUG */
3386 /*-----------------------------------------------.
3387 | Release the memory associated to this symbol. |
3388 `-----------------------------------------------*/
3390 #if defined (__STDC__) || defined (__cplusplus)
3392 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3395 yydestruct (yymsg, yytype, yyvaluep)
3401 /* Pacify ``unused variable'' warnings. */
3406 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3417 /* Prevent warnings from -Wmissing-prototypes. */
3419 #ifdef YYPARSE_PARAM
3420 # if defined (__STDC__) || defined (__cplusplus)
3421 int yyparse (void *YYPARSE_PARAM);
3425 #else /* ! YYPARSE_PARAM */
3426 #if defined (__STDC__) || defined (__cplusplus)
3431 #endif /* ! YYPARSE_PARAM */
3435 /* The look-ahead symbol. */
3438 /* The semantic value of the look-ahead symbol. */
3441 /* Number of syntax errors so far. */
3450 #ifdef YYPARSE_PARAM
3451 # if defined (__STDC__) || defined (__cplusplus)
3452 int yyparse (void *YYPARSE_PARAM)
3454 int yyparse (YYPARSE_PARAM)
3455 void *YYPARSE_PARAM;
3457 #else /* ! YYPARSE_PARAM */
3458 #if defined (__STDC__) || defined (__cplusplus)
3472 /* Number of tokens to shift before error messages enabled. */
3474 /* Look-ahead token as an internal (translated) token number. */
3477 /* Three stacks and their tools:
3478 `yyss': related to states,
3479 `yyvs': related to semantic values,
3480 `yyls': related to locations.
3482 Refer to the stacks thru separate pointers, to allow yyoverflow
3483 to reallocate them elsewhere. */
3485 /* The state stack. */
3486 short int yyssa[YYINITDEPTH];
3487 short int *yyss = yyssa;
3490 /* The semantic value stack. */
3491 YYSTYPE yyvsa[YYINITDEPTH];
3492 YYSTYPE *yyvs = yyvsa;
3497 #define YYPOPSTACK (yyvsp--, yyssp--)
3499 YYSIZE_T yystacksize = YYINITDEPTH;
3501 /* The variables used to return semantic value and location from the
3506 /* When reducing, the number of symbols on the RHS of the reduced
3510 YYDPRINTF ((stderr, "Starting parse\n"));
3515 yychar = YYEMPTY; /* Cause a token to be read. */
3517 /* Initialize stack pointers.
3518 Waste one element of value and location stack
3519 so that they stay on the same level as the state stack.
3520 The wasted elements are never initialized. */
3527 /*------------------------------------------------------------.
3528 | yynewstate -- Push a new state, which is found in yystate. |
3529 `------------------------------------------------------------*/
3531 /* In all cases, when you get here, the value and location stacks
3532 have just been pushed. so pushing a state here evens the stacks.
3539 if (yyss + yystacksize - 1 <= yyssp)
3541 /* Get the current used size of the three stacks, in elements. */
3542 YYSIZE_T yysize = yyssp - yyss + 1;
3546 /* Give user a chance to reallocate the stack. Use copies of
3547 these so that the &'s don't force the real ones into
3549 YYSTYPE *yyvs1 = yyvs;
3550 short int *yyss1 = yyss;
3553 /* Each stack pointer address is followed by the size of the
3554 data in use in that stack, in bytes. This used to be a
3555 conditional around just the two extra args, but that might
3556 be undefined if yyoverflow is a macro. */
3557 yyoverflow (YY_("memory exhausted"),
3558 &yyss1, yysize * sizeof (*yyssp),
3559 &yyvs1, yysize * sizeof (*yyvsp),
3566 #else /* no yyoverflow */
3567 # ifndef YYSTACK_RELOCATE
3568 goto yyexhaustedlab;
3570 /* Extend the stack our own way. */
3571 if (YYMAXDEPTH <= yystacksize)
3572 goto yyexhaustedlab;
3574 if (YYMAXDEPTH < yystacksize)
3575 yystacksize = YYMAXDEPTH;
3578 short int *yyss1 = yyss;
3579 union yyalloc *yyptr =
3580 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3582 goto yyexhaustedlab;
3583 YYSTACK_RELOCATE (yyss);
3584 YYSTACK_RELOCATE (yyvs);
3586 # undef YYSTACK_RELOCATE
3588 YYSTACK_FREE (yyss1);
3591 #endif /* no yyoverflow */
3593 yyssp = yyss + yysize - 1;
3594 yyvsp = yyvs + yysize - 1;
3597 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3598 (unsigned long int) yystacksize));
3600 if (yyss + yystacksize - 1 <= yyssp)
3604 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
3613 /* Do appropriate processing given the current state. */
3614 /* Read a look-ahead token if we need one and don't already have one. */
3617 /* First try to decide what to do without reference to look-ahead token. */
3619 yyn = yypact[yystate];
3620 if (yyn == YYPACT_NINF)
3623 /* Not known => get a look-ahead token if don't already have one. */
3625 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
3626 if (yychar == YYEMPTY)
3628 YYDPRINTF ((stderr, "Reading a token: "));
3632 if (yychar <= YYEOF)
3634 yychar = yytoken = YYEOF;
3635 YYDPRINTF ((stderr, "Now at end of input.\n"));
3639 yytoken = YYTRANSLATE (yychar);
3640 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
3643 /* If the proper action on seeing token YYTOKEN is to reduce or to
3644 detect an error, take that action. */
3646 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
3651 if (yyn == 0 || yyn == YYTABLE_NINF)
3660 /* Shift the look-ahead token. */
3661 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3663 /* Discard the token being shifted unless it is eof. */
3664 if (yychar != YYEOF)
3670 /* Count tokens shifted since error; after three, turn off error
3679 /*-----------------------------------------------------------.
3680 | yydefault -- do the default action for the current state. |
3681 `-----------------------------------------------------------*/
3683 yyn = yydefact[yystate];
3689 /*-----------------------------.
3690 | yyreduce -- Do a reduction. |
3691 `-----------------------------*/
3693 /* yyn is the number of a rule to reduce with. */
3696 /* If YYLEN is nonzero, implement the default value of the action:
3699 Otherwise, the following line sets YYVAL to garbage.
3700 This behavior is undocumented and Bison
3701 users should not rely upon it. Assigning to YYVAL
3702 unconditionally makes the parser a bit smaller, and it avoids a
3703 GCC warning that YYVAL may be used uninitialized. */
3704 yyval = yyvsp[1-yylen];
3707 YY_REDUCE_PRINT (yyn);
3711 #line 1617 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3713 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
3714 error("Value too large for type");
3715 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3720 #line 1626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3722 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
3723 error("Value too large for type");
3724 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3729 #line 1648 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3730 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3734 #line 1648 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3735 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3739 #line 1649 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3740 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3744 #line 1649 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3745 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3749 #line 1650 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3750 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3754 #line 1650 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3755 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3759 #line 1651 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3760 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3764 #line 1651 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3765 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3769 #line 1652 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3770 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3774 #line 1652 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3775 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3779 #line 1656 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3780 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3784 #line 1656 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3785 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3789 #line 1657 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3790 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3794 #line 1657 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3795 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3799 #line 1658 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3800 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3804 #line 1658 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3805 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3809 #line 1659 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3810 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3814 #line 1659 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3815 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3819 #line 1660 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3820 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3824 #line 1660 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3825 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3829 #line 1661 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3830 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3834 #line 1661 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3835 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3839 #line 1662 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3840 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3844 #line 1662 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3845 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3849 #line 1663 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3850 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3854 #line 1664 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3855 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3859 #line 1695 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3861 (yyval.StrVal) = (yyvsp[-1].StrVal);
3866 #line 1698 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3873 #line 1703 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3874 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3878 #line 1704 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3879 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3883 #line 1705 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3884 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3888 #line 1706 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3889 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3893 #line 1707 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3894 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3898 #line 1708 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3899 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3903 #line 1709 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3904 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3908 #line 1710 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3909 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3913 #line 1714 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3914 { (yyval.UIntVal) = OldCallingConv::C; ;}
3918 #line 1715 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3919 { (yyval.UIntVal) = OldCallingConv::C; ;}
3923 #line 1716 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3924 { (yyval.UIntVal) = OldCallingConv::CSRet; ;}
3928 #line 1717 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3929 { (yyval.UIntVal) = OldCallingConv::Fast; ;}
3933 #line 1718 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3934 { (yyval.UIntVal) = OldCallingConv::Cold; ;}
3938 #line 1719 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3939 { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
3943 #line 1720 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3944 { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
3948 #line 1721 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3950 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
3951 error("Calling conv too large");
3952 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3957 #line 1731 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3958 { (yyval.UIntVal) = 0; ;}
3962 #line 1732 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3964 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3965 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3966 error("Alignment must be a power of two");
3971 #line 1740 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3972 { (yyval.UIntVal) = 0; ;}
3976 #line 1741 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3978 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3979 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3980 error("Alignment must be a power of two");
3985 #line 1749 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3987 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3988 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
3989 error("Invalid character in section name");
3990 (yyval.StrVal) = (yyvsp[0].StrVal);
3995 #line 1758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3996 { (yyval.StrVal) = 0; ;}
4000 #line 1759 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4001 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
4005 #line 1766 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4010 #line 1767 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4015 #line 1771 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4017 CurGV->setSection((yyvsp[0].StrVal));
4018 free((yyvsp[0].StrVal));
4023 #line 1775 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4025 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
4026 error("Alignment must be a power of two");
4027 CurGV->setAlignment((yyvsp[0].UInt64Val));
4033 #line 1792 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4035 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
4036 (yyval.TypeVal).S = Signless;
4041 #line 1800 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4043 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
4044 (yyval.TypeVal).S = Signless;
4049 #line 1807 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4051 if (!UpRefs.empty())
4052 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription());
4053 (yyval.TypeVal) = (yyvsp[0].TypeVal);
4058 #line 1821 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4060 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
4061 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
4066 #line 1825 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4068 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
4069 (yyval.TypeVal).S = Signless;
4074 #line 1829 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4075 { // Named types are also simple types...
4076 const Type* tmp = getType((yyvsp[0].ValIDVal));
4077 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
4078 (yyval.TypeVal).S = (yyvsp[0].ValIDVal).S; // FIXME: what if its signed?
4083 #line 1834 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4084 { // Type UpReference
4085 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
4086 error("Value out of range");
4087 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
4088 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
4089 (yyval.TypeVal).PAT = new PATypeHolder(OT);
4090 (yyval.TypeVal).S = Signless;
4091 UR_OUT("New Upreference!\n");
4096 #line 1843 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4097 { // Function derived type?
4098 std::vector<const Type*> Params;
4099 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4100 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
4101 Params.push_back(I->PAT->get());
4103 FunctionType::ParamAttrsList ParamAttrs;
4104 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4105 if (isVarArg) Params.pop_back();
4107 (yyval.TypeVal).PAT = new PATypeHolder(
4108 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg,
4110 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
4111 delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle
4112 delete (yyvsp[-1].TypeList); // Delete the argument list
4117 #line 1860 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4118 { // Sized array type?
4119 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(),
4120 (unsigned)(yyvsp[-3].UInt64Val))));
4121 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4122 delete (yyvsp[-1].TypeVal).PAT;
4127 #line 1866 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4129 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get();
4130 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
4131 error("Unsigned result not equal to signed result");
4132 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4133 error("Elements of a VectorType must be integer or floating point");
4134 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
4135 error("VectorType length should be a power of 2");
4136 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4137 (unsigned)(yyvsp[-3].UInt64Val))));
4138 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4139 delete (yyvsp[-1].TypeVal).PAT;
4144 #line 1879 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4145 { // Structure type?
4146 std::vector<const Type*> Elements;
4147 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4148 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
4149 Elements.push_back(I->PAT->get());
4150 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4151 (yyval.TypeVal).S = Signless;
4152 delete (yyvsp[-1].TypeList);
4157 #line 1888 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4158 { // Empty structure type?
4159 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4160 (yyval.TypeVal).S = Signless;
4165 #line 1892 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4166 { // Packed Structure type?
4167 std::vector<const Type*> Elements;
4168 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4169 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
4170 Elements.push_back(I->PAT->get());
4173 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4174 (yyval.TypeVal).S = Signless;
4175 delete (yyvsp[-2].TypeList);
4180 #line 1903 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4181 { // Empty packed structure type?
4182 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4183 (yyval.TypeVal).S = Signless;
4188 #line 1907 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4190 if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy)
4191 error("Cannot form a pointer to a basic block");
4192 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get())));
4193 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4194 delete (yyvsp[-1].TypeVal).PAT;
4199 #line 1920 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4201 (yyval.TypeList) = new std::list<PATypeInfo>();
4202 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4207 #line 1924 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4209 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4214 #line 1932 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4217 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
4218 VoidTI.S = Signless;
4219 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4224 #line 1938 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4226 (yyval.TypeList) = new std::list<PATypeInfo>();
4228 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
4229 VoidTI.S = Signless;
4230 (yyval.TypeList)->push_back(VoidTI);
4235 #line 1945 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4237 (yyval.TypeList) = new std::list<PATypeInfo>();
4242 #line 1957 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4243 { // Nonempty unsized arr
4244 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get());
4246 error("Cannot make array constant with type: '" +
4247 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
4248 const Type *ETy = ATy->getElementType();
4249 int NumElements = ATy->getNumElements();
4251 // Verify that we have the correct size...
4252 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4253 error("Type mismatch: constant sized array initialized with " +
4254 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4255 itostr(NumElements) + "");
4257 // Verify all elements are correct type!
4258 std::vector<Constant*> Elems;
4259 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4260 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4261 const Type* ValTy = C->getType();
4263 error("Element #" + utostr(i) + " is not of type '" +
4264 ETy->getDescription() +"' as required!\nIt is of type '"+
4265 ValTy->getDescription() + "'");
4268 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4269 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4270 delete (yyvsp[-3].TypeVal).PAT;
4271 delete (yyvsp[-1].ConstVector);
4276 #line 1987 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4278 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
4280 error("Cannot make array constant with type: '" +
4281 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
4282 int NumElements = ATy->getNumElements();
4283 if (NumElements != -1 && NumElements != 0)
4284 error("Type mismatch: constant sized array initialized with 0"
4285 " arguments, but has size of " + itostr(NumElements) +"");
4286 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4287 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4288 delete (yyvsp[-2].TypeVal).PAT;
4293 #line 2000 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4295 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
4297 error("Cannot make array constant with type: '" +
4298 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
4299 int NumElements = ATy->getNumElements();
4300 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4301 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4302 error("String arrays require type i8, not '" + ETy->getDescription() +
4304 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4305 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
4306 error("Can't build string constant of size " +
4307 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
4308 itostr(NumElements) + "");
4309 std::vector<Constant*> Vals;
4310 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
4311 Vals.push_back(ConstantInt::get(ETy, *C));
4312 free((yyvsp[0].StrVal));
4313 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4314 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4315 delete (yyvsp[-2].TypeVal).PAT;
4320 #line 2023 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4321 { // Nonempty unsized arr
4322 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get());
4324 error("Cannot make packed constant with type: '" +
4325 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
4326 const Type *ETy = PTy->getElementType();
4327 int NumElements = PTy->getNumElements();
4328 // Verify that we have the correct size...
4329 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4330 error("Type mismatch: constant sized packed initialized with " +
4331 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4332 itostr(NumElements) + "");
4333 // Verify all elements are correct type!
4334 std::vector<Constant*> Elems;
4335 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4336 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4337 const Type* ValTy = C->getType();
4339 error("Element #" + utostr(i) + " is not of type '" +
4340 ETy->getDescription() +"' as required!\nIt is of type '"+
4341 ValTy->getDescription() + "'");
4344 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
4345 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4346 delete (yyvsp[-3].TypeVal).PAT;
4347 delete (yyvsp[-1].ConstVector);
4352 #line 2051 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4354 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get());
4356 error("Cannot make struct constant with type: '" +
4357 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
4358 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
4359 error("Illegal number of initializers for structure type");
4361 // Check to ensure that constants are compatible with the type initializer!
4362 std::vector<Constant*> Fields;
4363 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4364 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4365 if (C->getType() != STy->getElementType(i))
4366 error("Expected type '" + STy->getElementType(i)->getDescription() +
4367 "' for element #" + utostr(i) + " of structure initializer");
4368 Fields.push_back(C);
4370 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4371 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4372 delete (yyvsp[-3].TypeVal).PAT;
4373 delete (yyvsp[-1].ConstVector);
4378 #line 2073 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4380 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get());
4382 error("Cannot make struct constant with type: '" +
4383 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
4384 if (STy->getNumContainedTypes() != 0)
4385 error("Illegal number of initializers for structure type");
4386 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4387 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4388 delete (yyvsp[-2].TypeVal).PAT;
4393 #line 2084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4395 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get());
4397 error("Cannot make packed struct constant with type: '" +
4398 (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'");
4399 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
4400 error("Illegal number of initializers for packed structure type");
4402 // Check to ensure that constants are compatible with the type initializer!
4403 std::vector<Constant*> Fields;
4404 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4405 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
4406 if (C->getType() != STy->getElementType(i))
4407 error("Expected type '" + STy->getElementType(i)->getDescription() +
4408 "' for element #" + utostr(i) + " of packed struct initializer");
4409 Fields.push_back(C);
4411 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4412 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4413 delete (yyvsp[-5].TypeVal).PAT;
4414 delete (yyvsp[-2].ConstVector);
4419 #line 2106 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4421 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get());
4423 error("Cannot make packed struct constant with type: '" +
4424 (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'");
4425 if (STy->getNumContainedTypes() != 0)
4426 error("Illegal number of initializers for packed structure type");
4427 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4428 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4429 delete (yyvsp[-4].TypeVal).PAT;
4434 #line 2117 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4436 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
4438 error("Cannot make null pointer constant with type: '" +
4439 (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'");
4440 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4441 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4442 delete (yyvsp[-1].TypeVal).PAT;
4447 #line 2126 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4449 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get());
4450 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4451 delete (yyvsp[-1].TypeVal).PAT;
4456 #line 2131 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4458 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
4460 error("Global const reference must be a pointer type, not" +
4461 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
4463 // ConstExprs can exist in the body of a function, thus creating
4464 // GlobalValues whenever they refer to a variable. Because we are in
4465 // the context of a function, getExistingValue will search the functions
4466 // symbol table instead of the module symbol table for the global symbol,
4467 // which throws things all off. To get around this, we just tell
4468 // getExistingValue that we are at global scope here.
4470 Function *SavedCurFn = CurFun.CurrentFunction;
4471 CurFun.CurrentFunction = 0;
4472 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
4473 CurFun.CurrentFunction = SavedCurFn;
4475 // If this is an initializer for a constant pointer, which is referencing a
4476 // (currently) undefined variable, create a stub now that shall be replaced
4477 // in the future with the right type of variable.
4480 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4481 const PointerType *PT = cast<PointerType>(Ty);
4483 // First check to see if the forward references value is already created!
4484 PerModuleInfo::GlobalRefsType::iterator I =
4485 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
4487 if (I != CurModule.GlobalRefs.end()) {
4488 V = I->second; // Placeholder already exists, use it...
4489 (yyvsp[0].ValIDVal).destroy();
4492 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
4494 // Create the forward referenced global.
4496 if (const FunctionType *FTy =
4497 dyn_cast<FunctionType>(PT->getElementType())) {
4498 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4499 CurModule.CurrentModule);
4501 GV = new GlobalVariable(PT->getElementType(), false,
4502 GlobalValue::ExternalLinkage, 0,
4503 Name, CurModule.CurrentModule);
4506 // Keep track of the fact that we have a forward ref to recycle it
4507 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
4511 (yyval.ConstVal).C = cast<GlobalValue>(V);
4512 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4513 delete (yyvsp[-1].TypeVal).PAT; // Free the type handle
4518 #line 2189 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4520 if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType())
4521 error("Mismatched types for constant expression");
4522 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4523 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4524 delete (yyvsp[-1].TypeVal).PAT;
4529 #line 2196 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4531 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
4532 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4533 error("Cannot create a null initialized value of this type");
4534 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4535 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4536 delete (yyvsp[-1].TypeVal).PAT;
4541 #line 2204 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4542 { // integral constants
4543 const Type *Ty = (yyvsp[-1].PrimType).T;
4544 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
4545 error("Constant value doesn't fit in type");
4546 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
4547 (yyval.ConstVal).S = Signed;
4552 #line 2211 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4553 { // integral constants
4554 const Type *Ty = (yyvsp[-1].PrimType).T;
4555 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
4556 error("Constant value doesn't fit in type");
4557 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
4558 (yyval.ConstVal).S = Unsigned;
4563 #line 2218 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4564 { // Boolean constants
4565 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4566 (yyval.ConstVal).S = Unsigned;
4571 #line 2222 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4572 { // Boolean constants
4573 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4574 (yyval.ConstVal).S = Unsigned;
4579 #line 2226 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4580 { // Float & Double constants
4581 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
4582 error("Floating point constant invalid for type");
4583 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
4584 (yyval.ConstVal).S = Signless;
4589 #line 2235 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4591 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4592 const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get();
4593 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4594 Signedness DstSign = (yyvsp[-1].TypeVal).S;
4595 if (!SrcTy->isFirstClassType())
4596 error("cast constant expression from a non-primitive type: '" +
4597 SrcTy->getDescription() + "'");
4598 if (!DstTy->isFirstClassType())
4599 error("cast constant expression to a non-primitive type: '" +
4600 DstTy->getDescription() + "'");
4601 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
4602 (yyval.ConstVal).S = DstSign;
4603 delete (yyvsp[-1].TypeVal).PAT;
4608 #line 2250 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4610 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
4611 if (!isa<PointerType>(Ty))
4612 error("GetElementPtr requires a pointer operand");
4614 std::vector<Value*> VIndices;
4615 std::vector<Constant*> CIndices;
4616 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
4618 delete (yyvsp[-1].ValueList);
4619 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, &CIndices[0], CIndices.size());
4620 (yyval.ConstVal).S = Signless;
4625 #line 2263 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4627 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4628 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
4629 error("Select condition must be bool type");
4630 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4631 error("Select operand types must match");
4632 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4633 (yyval.ConstVal).S = Unsigned;
4638 #line 2272 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4640 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4641 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4642 error("Binary operator types must match");
4643 // First, make sure we're dealing with the right opcode by upgrading from
4644 // obsolete versions.
4645 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4647 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4648 // To retain backward compatibility with these early compilers, we emit a
4649 // cast to the appropriate integer type automatically if we are in the
4650 // broken case. See PR424 for more information.
4651 if (!isa<PointerType>(Ty)) {
4652 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4654 const Type *IntPtrTy = 0;
4655 switch (CurModule.CurrentModule->getPointerSize()) {
4656 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4657 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4658 default: error("invalid pointer binary constant expr");
4660 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4661 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4662 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4663 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4665 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4670 #line 2300 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4672 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4673 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4674 error("Logical operator types must match");
4675 if (!Ty->isInteger()) {
4676 if (!isa<VectorType>(Ty) ||
4677 !cast<VectorType>(Ty)->getElementType()->isInteger())
4678 error("Logical operator requires integer operands");
4680 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4681 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4682 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4687 #line 2313 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4689 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4690 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4691 error("setcc operand types must match");
4692 unsigned short pred;
4693 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4694 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4695 (yyval.ConstVal).S = Unsigned;
4700 #line 2322 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4702 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4703 error("icmp operand types must match");
4704 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4705 (yyval.ConstVal).S = Unsigned;
4710 #line 2328 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4712 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4713 error("fcmp operand types must match");
4714 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4715 (yyval.ConstVal).S = Unsigned;
4720 #line 2334 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4722 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4723 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
4724 error("Shift count for shift constant must be unsigned byte");
4725 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4726 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
4727 error("Shift constant expression requires integer operand");
4728 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4729 (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, ShiftAmt);
4730 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4735 #line 2345 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4737 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4738 error("Invalid extractelement operands");
4739 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4740 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4745 #line 2351 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4747 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4748 error("Invalid insertelement operands");
4749 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4750 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4755 #line 2357 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4757 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4758 error("Invalid shufflevector operands");
4759 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4760 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4765 #line 2368 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4766 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
4770 #line 2369 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4772 (yyval.ConstVector) = new std::vector<ConstInfo>();
4773 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4778 #line 2378 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4779 { (yyval.BoolVal) = false; ;}
4783 #line 2379 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4784 { (yyval.BoolVal) = true; ;}
4788 #line 2391 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4790 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
4791 CurModule.ModuleDone();
4796 #line 2400 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4797 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
4801 #line 2401 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4802 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
4806 #line 2402 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4807 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
4811 #line 2403 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4812 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
4816 #line 2404 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4818 (yyval.ModuleVal) = CurModule.CurrentModule;
4819 // Emit an error if there are any unresolved types left.
4820 if (!CurModule.LateResolveTypes.empty()) {
4821 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4822 if (DID.Type == ValID::NameVal) {
4823 error("Reference to an undefined type: '"+DID.getName() + "'");
4825 error("Reference to an undefined type: #" + itostr(DID.Num));
4832 #line 2420 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4834 // Eagerly resolve types. This is not an optimization, this is a
4835 // requirement that is due to the fact that we could have this:
4837 // %list = type { %list * }
4838 // %list = type { %list * } ; repeated type decl
4840 // If types are not resolved eagerly, then the two types will not be
4841 // determined to be the same type!
4843 const Type* Ty = (yyvsp[0].TypeVal).PAT->get();
4844 ResolveTypeTo((yyvsp[-2].StrVal), Ty, (yyvsp[0].TypeVal).S);
4846 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
4847 // If this is a named type that is not a redefinition, add it to the slot
4849 CurModule.Types.push_back(Ty);
4851 delete (yyvsp[0].TypeVal).PAT;
4856 #line 2440 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4857 { // Function prototypes can be in const pool
4862 #line 2442 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4863 { // Asm blocks can be in the const pool
4868 #line 2444 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4870 if ((yyvsp[0].ConstVal).C == 0)
4871 error("Global value initializer is not a constant");
4872 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C, (yyvsp[0].ConstVal).S);
4877 #line 2448 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4884 #line 2451 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4886 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
4887 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0,
4888 (yyvsp[0].TypeVal).S);
4889 delete (yyvsp[0].TypeVal).PAT;
4894 #line 2456 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4901 #line 2459 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4903 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
4904 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0,
4905 (yyvsp[0].TypeVal).S);
4906 delete (yyvsp[0].TypeVal).PAT;
4911 #line 2464 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4918 #line 2467 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4920 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
4922 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0,
4923 (yyvsp[0].TypeVal).S);
4924 delete (yyvsp[0].TypeVal).PAT;
4929 #line 2473 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4936 #line 2476 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4942 #line 2478 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4948 #line 2480 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4954 #line 2485 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4956 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4957 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4958 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4959 free((yyvsp[0].StrVal));
4961 if (AsmSoFar.empty())
4962 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4964 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4969 #line 2499 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4970 { (yyval.Endianness) = Module::BigEndian; ;}
4974 #line 2500 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4975 { (yyval.Endianness) = Module::LittleEndian; ;}
4979 #line 2504 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4981 CurModule.setEndianness((yyvsp[0].Endianness));
4986 #line 2507 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4988 if ((yyvsp[0].UInt64Val) == 32)
4989 CurModule.setPointerSize(Module::Pointer32);
4990 else if ((yyvsp[0].UInt64Val) == 64)
4991 CurModule.setPointerSize(Module::Pointer64);
4993 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
4998 #line 2515 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5000 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
5001 free((yyvsp[0].StrVal));
5006 #line 2519 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5008 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
5009 free((yyvsp[0].StrVal));
5014 #line 2530 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5016 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5017 free((yyvsp[0].StrVal));
5022 #line 2534 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5024 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5025 free((yyvsp[0].StrVal));
5030 #line 2538 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5035 #line 2551 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5036 { (yyval.StrVal) = 0; ;}
5040 #line 2555 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5042 if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy)
5043 error("void typed arguments are invalid");
5044 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
5049 #line 2563 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5051 (yyval.ArgList) = (yyvsp[-2].ArgList);
5052 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5053 delete (yyvsp[0].ArgVal);
5058 #line 2568 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5060 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5061 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5062 delete (yyvsp[0].ArgVal);
5067 #line 2576 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5068 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
5072 #line 2577 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5074 (yyval.ArgList) = (yyvsp[-2].ArgList);
5076 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
5077 VoidTI.S = Signless;
5078 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5083 #line 2584 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5085 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5087 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
5088 VoidTI.S = Signless;
5089 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5094 #line 2591 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5095 { (yyval.ArgList) = 0; ;}
5099 #line 2595 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5101 UnEscapeLexed((yyvsp[-5].StrVal));
5102 std::string FunctionName((yyvsp[-5].StrVal));
5103 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
5105 const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get();
5107 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5108 error("LLVM functions cannot return aggregate types");
5110 std::vector<const Type*> ParamTyList;
5112 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5113 // i8*. We check here for those names and override the parameter list
5114 // types to ensure the prototype is correct.
5115 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5116 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5117 } else if (FunctionName == "llvm.va_copy") {
5118 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5119 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5120 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
5121 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5122 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
5123 const Type *Ty = I->first.PAT->get();
5124 ParamTyList.push_back(Ty);
5128 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5130 ParamTyList.pop_back();
5132 // Convert the CSRet calling convention into the corresponding parameter
5134 FunctionType::ParamAttrsList ParamAttrs;
5135 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
5136 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5137 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5140 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
5142 const PointerType *PFT = PointerType::get(FT);
5143 delete (yyvsp[-6].TypeVal).PAT;
5146 if (!FunctionName.empty()) {
5147 ID = ValID::create((char*)FunctionName.c_str(), (yyvsp[-6].TypeVal).S);
5149 ID = ValID::create((int)CurModule.Values[PFT].size(), (yyvsp[-6].TypeVal).S);
5153 Module* M = CurModule.CurrentModule;
5155 // See if this function was forward referenced. If so, recycle the object.
5156 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5157 // Move the function to the end of the list, from whereever it was
5158 // previously inserted.
5159 Fn = cast<Function>(FWRef);
5160 M->getFunctionList().remove(Fn);
5161 M->getFunctionList().push_back(Fn);
5162 } else if (!FunctionName.empty()) {
5163 GlobalValue *Conflict = M->getFunction(FunctionName);
5165 Conflict = M->getNamedGlobal(FunctionName);
5166 if (Conflict && PFT == Conflict->getType()) {
5167 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5168 // We have two function definitions that conflict, same type, same
5169 // name. We should really check to make sure that this is the result
5170 // of integer type planes collapsing and generate an error if it is
5171 // not, but we'll just rename on the assumption that it is. However,
5172 // let's do it intelligently and rename the internal linkage one
5174 std::string NewName(makeNameUnique(FunctionName));
5175 if (Conflict->hasInternalLinkage()) {
5176 Conflict->setName(NewName);
5177 TypeInfo TI; TI.T = Conflict->getType(); TI.S = ID.S;
5178 RenameMapKey Key = std::make_pair(FunctionName,TI);
5179 CurModule.RenameMap[Key] = NewName;
5180 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5181 InsertValue(Fn, CurModule.Values);
5183 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5184 InsertValue(Fn, CurModule.Values);
5185 TypeInfo TI; TI.T = PFT; TI.S = ID.S;
5186 RenameMapKey Key = std::make_pair(FunctionName,TI);
5187 CurModule.RenameMap[Key] = NewName;
5190 // If they are not both definitions, then just use the function we
5191 // found since the types are the same.
5192 Fn = cast<Function>(Conflict);
5194 // Make sure to strip off any argument names so we can't get
5196 if (Fn->isDeclaration())
5197 for (Function::arg_iterator AI = Fn->arg_begin(),
5198 AE = Fn->arg_end(); AI != AE; ++AI)
5201 } else if (Conflict) {
5202 // We have two globals with the same name and different types.
5203 // Previously, this was permitted because the symbol table had
5204 // "type planes" and names only needed to be distinct within a
5205 // type plane. After PR411 was fixed, this is no loner the case.
5206 // To resolve this we must rename one of the two.
5207 if (Conflict->hasInternalLinkage()) {
5208 // We can safely renamed the Conflict.
5209 Conflict->setName(makeNameUnique(Conflict->getName()));
5210 TypeInfo TI; TI.T = Conflict->getType(); TI.S = ID.S;
5211 RenameMapKey Key = std::make_pair(FunctionName,TI);
5212 CurModule.RenameMap[Key] = Conflict->getName();
5213 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5214 InsertValue(Fn, CurModule.Values);
5215 } else if (CurFun.Linkage == GlobalValue::InternalLinkage) {
5216 // We can safely rename the function we're defining
5217 std::string NewName = makeNameUnique(FunctionName);
5218 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5219 InsertValue(Fn, CurModule.Values);
5220 TypeInfo TI; TI.T = PFT; TI.S = ID.S;
5221 RenameMapKey Key = std::make_pair(FunctionName,TI);
5222 CurModule.RenameMap[Key] = NewName;
5224 // We can't quietly rename either of these things, but we must
5225 // rename one of them. Generate a warning about the renaming and
5226 // elect to rename the thing we're now defining.
5227 std::string NewName = makeNameUnique(FunctionName);
5228 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5229 "' may cause linkage errors");
5230 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5231 InsertValue(Fn, CurModule.Values);
5232 TypeInfo TI; TI.T = PFT; TI.S = ID.S;
5233 RenameMapKey Key = std::make_pair(FunctionName,TI);
5234 CurModule.RenameMap[Key] = NewName;
5237 // There's no conflict, just define the function
5238 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5239 InsertValue(Fn, CurModule.Values);
5243 CurFun.FunctionStart(Fn);
5245 if (CurFun.isDeclare) {
5246 // If we have declaration, always overwrite linkage. This will allow us
5247 // to correctly handle cases, when pointer to function is passed as
5248 // argument to another function.
5249 Fn->setLinkage(CurFun.Linkage);
5251 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5252 Fn->setAlignment((yyvsp[0].UIntVal));
5253 if ((yyvsp[-1].StrVal)) {
5254 Fn->setSection((yyvsp[-1].StrVal));
5255 free((yyvsp[-1].StrVal));
5258 // Add all of the arguments we parsed to the function...
5259 if ((yyvsp[-3].ArgList)) { // Is null if empty...
5260 if (isVarArg) { // Nuke the last entry
5261 assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5262 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5263 delete (yyvsp[-3].ArgList)->back().first.PAT;
5264 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
5266 Function::arg_iterator ArgIt = Fn->arg_begin();
5267 Function::arg_iterator ArgEnd = Fn->arg_end();
5268 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
5269 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end();
5270 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
5271 delete I->first.PAT; // Delete the typeholder...
5272 ValueInfo VI; VI.V = ArgIt; VI.S = Signless; // FIXME: Sign
5273 setValueName(VI, I->second); // Insert arg into symtab...
5276 delete (yyvsp[-3].ArgList); // We're now done with the argument list
5282 #line 2781 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5284 (yyval.FunctionVal) = CurFun.CurrentFunction;
5286 // Make sure that we keep track of the linkage type even if there was a
5287 // previous "declare".
5288 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
5293 #line 2795 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5295 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5300 #line 2800 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5301 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5305 #line 2801 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5306 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
5310 #line 2802 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5311 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
5315 #line 2806 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5316 { CurFun.isDeclare = true; ;}
5320 #line 2807 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5321 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5325 #line 2807 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5327 (yyval.FunctionVal) = CurFun.CurrentFunction;
5328 CurFun.FunctionDone();
5334 #line 2819 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5335 { (yyval.BoolVal) = false; ;}
5339 #line 2820 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5340 { (yyval.BoolVal) = true; ;}
5344 #line 2825 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5345 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
5349 #line 2826 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5350 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5354 #line 2827 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5355 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5359 #line 2828 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5361 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true), Signed);
5366 #line 2831 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5368 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false), Unsigned);
5373 #line 2834 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5374 { (yyval.ValIDVal) = ValID::createNull(); ;}
5378 #line 2835 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5379 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5383 #line 2836 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5384 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5388 #line 2837 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5389 { // Nonempty unsized packed vector
5390 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5391 int NumElements = (yyvsp[-1].ConstVector)->size();
5392 VectorType* pt = VectorType::get(ETy, NumElements);
5393 PATypeHolder* PTy = new PATypeHolder(
5394 HandleUpRefs(VectorType::get(ETy, NumElements)));
5396 // Verify all elements are correct type!
5397 std::vector<Constant*> Elems;
5398 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5399 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
5400 const Type *CTy = C->getType();
5402 error("Element #" + utostr(i) + " is not of type '" +
5403 ETy->getDescription() +"' as required!\nIt is of type '" +
5404 CTy->getDescription() + "'");
5407 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems), Signless);
5408 delete PTy; delete (yyvsp[-1].ConstVector);
5413 #line 2858 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5415 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C, (yyvsp[0].ConstVal).S);
5420 #line 2861 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5422 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5423 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5424 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5425 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5426 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5427 free((yyvsp[-2].StrVal));
5428 free((yyvsp[0].StrVal));
5433 #line 2875 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5434 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal),Signless); ;}
5438 #line 2876 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5439 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal),Signless); ;}
5443 #line 2889 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5445 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
5446 (yyvsp[0].ValIDVal).S = (yyvsp[-1].TypeVal).S;
5447 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5448 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5449 delete (yyvsp[-1].TypeVal).PAT;
5454 #line 2899 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5456 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5461 #line 2902 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5462 { // Do not allow functions with 0 basic blocks
5463 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5468 #line 2911 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5470 ValueInfo VI; VI.V = (yyvsp[0].TermInstVal); VI.S = Signless;
5471 setValueName(VI, (yyvsp[-1].StrVal));
5472 InsertValue((yyvsp[0].TermInstVal));
5473 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5474 InsertValue((yyvsp[-2].BasicBlockVal));
5475 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5480 #line 2922 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5482 if ((yyvsp[0].InstVal).I)
5483 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5484 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5489 #line 2927 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5491 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++,Signless),true);
5492 // Make sure to move the basic block to the correct location in the
5493 // function, instead of leaving it inserted wherever it was first
5495 Function::BasicBlockListType &BBL =
5496 CurFun.CurrentFunction->getBasicBlockList();
5497 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5502 #line 2936 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5504 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal),Signless), true);
5505 // Make sure to move the basic block to the correct location in the
5506 // function, instead of leaving it inserted wherever it was first
5508 Function::BasicBlockListType &BBL =
5509 CurFun.CurrentFunction->getBasicBlockList();
5510 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5515 #line 2950 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5516 { // Return with a result...
5517 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
5522 #line 2953 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5523 { // Return with no result...
5524 (yyval.TermInstVal) = new ReturnInst();
5529 #line 2956 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5530 { // Unconditional Branch...
5531 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5532 (yyval.TermInstVal) = new BranchInst(tmpBB);
5537 #line 2960 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5539 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5540 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5541 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5542 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5547 #line 2966 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5549 (yyvsp[-6].ValIDVal).S = (yyvsp[-7].PrimType).S;
5550 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5551 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5552 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5553 (yyval.TermInstVal) = S;
5554 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5555 E = (yyvsp[-1].JumpTable)->end();
5556 for (; I != E; ++I) {
5557 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5558 S->addCase(CI, I->second);
5560 error("Switch case is constant, but not a simple integer");
5562 delete (yyvsp[-1].JumpTable);
5567 #line 2982 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5569 (yyvsp[-5].ValIDVal).S = (yyvsp[-6].PrimType).S;
5570 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5571 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
5572 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5573 (yyval.TermInstVal) = S;
5578 #line 2990 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5580 const PointerType *PFTy;
5581 const FunctionType *Ty;
5583 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) ||
5584 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5585 // Pull out the types of all of the arguments...
5586 std::vector<const Type*> ParamTypes;
5587 if ((yyvsp[-7].ValueList)) {
5588 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
5590 ParamTypes.push_back((*I).V->getType());
5592 FunctionType::ParamAttrsList ParamAttrs;
5593 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
5594 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5595 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5597 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5598 if (isVarArg) ParamTypes.pop_back();
5599 Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs);
5600 PFTy = PointerType::get(Ty);
5602 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5603 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5604 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
5606 // Create the call node...
5607 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
5608 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, 0, 0);
5609 } else { // Has arguments?
5610 // Loop through FunctionType's arguments and ensure they are specified
5613 FunctionType::param_iterator I = Ty->param_begin();
5614 FunctionType::param_iterator E = Ty->param_end();
5615 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
5617 std::vector<Value*> Args;
5618 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5619 if ((*ArgI).V->getType() != *I)
5620 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5621 (*I)->getDescription() + "'");
5622 Args.push_back((*ArgI).V);
5625 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5626 error("Invalid number of parameters detected");
5628 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
5630 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
5631 delete (yyvsp[-10].TypeVal).PAT;
5632 delete (yyvsp[-7].ValueList);
5637 #line 3045 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5639 (yyval.TermInstVal) = new UnwindInst();
5644 #line 3048 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5646 (yyval.TermInstVal) = new UnreachableInst();
5651 #line 3054 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5653 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5654 (yyvsp[-3].ValIDVal).S = (yyvsp[-4].PrimType).S;
5655 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5658 error("May only switch on a constant pool value");
5660 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5661 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5666 #line 3065 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5668 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5669 (yyvsp[-3].ValIDVal).S = (yyvsp[-4].PrimType).S;
5670 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5673 error("May only switch on a constant pool value");
5675 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5676 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5681 #line 3079 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5684 if ((yyvsp[-1].StrVal))
5685 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
5686 if (BCI->getSrcTy() == BCI->getDestTy() &&
5687 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
5688 // This is a useless bit cast causing a name redefinition. It is
5689 // a bit cast from a type to the same type of an operand with the
5690 // same name as the name we would give this instruction. Since this
5691 // instruction results in no code generation, it is safe to omit
5692 // the instruction. This situation can occur because of collapsed
5693 // type planes. For example:
5694 // %X = add int %Y, %Z
5695 // %X = cast int %Y to uint
5696 // After upgrade, this looks like:
5697 // %X = add i32 %Y, %Z
5698 // %X = bitcast i32 to i32
5699 // The bitcast is clearly useless so we omit it.
5702 (yyval.InstVal).I = 0;
5703 (yyval.InstVal).S = Signless;
5705 ValueInfo VI; VI.V = (yyvsp[0].InstVal).I; VI.S = (yyvsp[0].InstVal).S;
5706 setValueName(VI, (yyvsp[-1].StrVal));
5707 InsertValue((yyvsp[0].InstVal).I);
5708 (yyval.InstVal) = (yyvsp[0].InstVal);
5714 #line 3109 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5715 { // Used for PHI nodes
5716 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5717 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5718 (yyvsp[-3].ValIDVal).S = (yyvsp[-5].TypeVal).S;
5719 Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal));
5720 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5721 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5722 delete (yyvsp[-5].TypeVal).PAT;
5727 #line 3118 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5729 (yyval.PHIList) = (yyvsp[-6].PHIList);
5730 (yyvsp[-3].ValIDVal).S = (yyvsp[-6].PHIList).S;
5731 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5732 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5733 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5738 #line 3127 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5739 { // Used for call statements, and memory insts...
5740 (yyval.ValueList) = new std::vector<ValueInfo>();
5741 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5746 #line 3131 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5748 (yyval.ValueList) = (yyvsp[-2].ValueList);
5749 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
5754 #line 3139 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5755 { (yyval.ValueList) = 0; ;}
5759 #line 3143 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5761 (yyval.BoolVal) = true;
5766 #line 3146 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5768 (yyval.BoolVal) = false;
5773 #line 3152 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5775 (yyvsp[-2].ValIDVal).S = (yyvsp[0].ValIDVal).S = (yyvsp[-3].TypeVal).S;
5776 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
5777 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
5778 error("Arithmetic operator requires integer, FP, or packed operands");
5779 if (isa<VectorType>(Ty) &&
5780 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
5781 error("Remainder not supported on vector types");
5782 // Upgrade the opcode from obsolete versions before we do anything with it.
5783 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5784 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5785 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
5786 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5787 if ((yyval.InstVal).I == 0)
5788 error("binary operator returned null");
5789 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5790 delete (yyvsp[-3].TypeVal).PAT;
5795 #line 3170 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5797 (yyvsp[-2].ValIDVal).S = (yyvsp[0].ValIDVal).S = (yyvsp[-3].TypeVal).S;
5798 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
5799 if (!Ty->isInteger()) {
5800 if (!isa<VectorType>(Ty) ||
5801 !cast<VectorType>(Ty)->getElementType()->isInteger())
5802 error("Logical operator requires integral operands");
5804 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5805 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5806 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5807 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5808 if ((yyval.InstVal).I == 0)
5809 error("binary operator returned null");
5810 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5811 delete (yyvsp[-3].TypeVal).PAT;
5816 #line 3187 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5818 (yyvsp[-2].ValIDVal).S = (yyvsp[0].ValIDVal).S = (yyvsp[-3].TypeVal).S;
5819 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
5820 if(isa<VectorType>(Ty))
5821 error("VectorTypes currently not supported in setcc instructions");
5822 unsigned short pred;
5823 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5824 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5825 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5826 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5827 if ((yyval.InstVal).I == 0)
5828 error("binary operator returned null");
5829 (yyval.InstVal).S = Unsigned;
5830 delete (yyvsp[-3].TypeVal).PAT;
5835 #line 3202 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5837 (yyvsp[-2].ValIDVal).S = (yyvsp[0].ValIDVal).S = (yyvsp[-3].TypeVal).S;
5838 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
5839 if (isa<VectorType>(Ty))
5840 error("VectorTypes currently not supported in icmp instructions");
5841 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5842 error("icmp requires integer or pointer typed operands");
5843 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5844 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5845 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
5846 (yyval.InstVal).S = Unsigned;
5847 delete (yyvsp[-3].TypeVal).PAT;
5852 #line 3215 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5854 (yyvsp[-2].ValIDVal).S = (yyvsp[0].ValIDVal).S = (yyvsp[-3].TypeVal).S;
5855 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
5856 if (isa<VectorType>(Ty))
5857 error("VectorTypes currently not supported in fcmp instructions");
5858 else if (!Ty->isFloatingPoint())
5859 error("fcmp instruction requires floating point operands");
5860 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5861 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5862 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
5863 (yyval.InstVal).S = Unsigned;
5864 delete (yyvsp[-3].TypeVal).PAT;
5869 #line 3228 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5871 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5872 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
5873 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5875 error("Expected integral type for not instruction");
5876 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
5877 if ((yyval.InstVal).I == 0)
5878 error("Could not create a xor instruction");
5879 (yyval.InstVal).S = (yyvsp[0].ValueVal).S;
5884 #line 3239 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5886 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5887 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
5888 error("Shift amount must be int8");
5889 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
5890 if (!Ty->isInteger())
5891 error("Shift constant expression requires integer operand");
5892 Value* ShiftAmt = 0;
5893 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
5894 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
5895 ShiftAmt = ConstantExpr::getZExt(C, Ty);
5897 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
5899 ShiftAmt = (yyvsp[0].ValueVal).V;
5900 (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[-3].BinaryOpVal), Ty, (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, ShiftAmt);
5901 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5906 #line 3257 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5908 const Type *DstTy = (yyvsp[0].TypeVal).PAT->get();
5909 if (!DstTy->isFirstClassType())
5910 error("cast instruction to a non-primitive type: '" +
5911 DstTy->getDescription() + "'");
5912 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5913 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5914 delete (yyvsp[0].TypeVal).PAT;
5919 #line 3266 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5921 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5922 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
5923 error("select condition must be bool");
5924 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
5925 error("select value types should match");
5926 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5927 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5932 #line 3275 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5934 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
5936 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5937 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5938 delete (yyvsp[0].TypeVal).PAT;
5943 #line 3282 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5945 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5946 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
5947 ObsoleteVarArgs = true;
5948 Function* NF = cast<Function>(CurModule.CurrentModule->
5949 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5952 //foo = alloca 1 of t
5956 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5957 CurBB->getInstList().push_back(foo);
5958 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5959 CurBB->getInstList().push_back(bar);
5960 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5961 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5962 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5963 delete (yyvsp[0].TypeVal).PAT;
5968 #line 3303 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5970 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5971 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
5972 ObsoleteVarArgs = true;
5973 Function* NF = cast<Function>(CurModule.CurrentModule->
5974 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5976 //b = vanext a, t ->
5977 //foo = alloca 1 of t
5980 //tmp = vaarg foo, t
5982 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5983 CurBB->getInstList().push_back(foo);
5984 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5985 CurBB->getInstList().push_back(bar);
5986 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5987 Instruction* tmp = new VAArgInst(foo, DstTy);
5988 CurBB->getInstList().push_back(tmp);
5989 (yyval.InstVal).I = new LoadInst(foo);
5990 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5991 delete (yyvsp[0].TypeVal).PAT;
5996 #line 3327 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5998 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5999 error("Invalid extractelement operands");
6000 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
6001 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
6006 #line 3333 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6008 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
6009 error("Invalid insertelement operands");
6010 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
6011 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
6016 #line 3339 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6018 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
6019 error("Invalid shufflevector operands");
6020 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
6021 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
6026 #line 3345 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6028 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
6029 if (!Ty->isFirstClassType())
6030 error("PHI node operands must be of first class type");
6031 PHINode *PHI = new PHINode(Ty);
6032 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
6033 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
6034 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
6035 error("All elements of a PHI node must be of the same type");
6036 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
6037 (yyvsp[0].PHIList).P->pop_front();
6039 (yyval.InstVal).I = PHI;
6040 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
6041 delete (yyvsp[0].PHIList).P; // Free the list...
6046 #line 3361 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6048 // Handle the short call syntax
6049 const PointerType *PFTy;
6050 const FunctionType *FTy;
6051 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) ||
6052 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6053 // Pull out the types of all of the arguments...
6054 std::vector<const Type*> ParamTypes;
6055 if ((yyvsp[-1].ValueList)) {
6056 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
6058 ParamTypes.push_back((*I).V->getType());
6061 FunctionType::ParamAttrsList ParamAttrs;
6062 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
6063 ParamAttrs.push_back(FunctionType::NoAttributeSet);
6064 ParamAttrs.push_back(FunctionType::StructRetAttribute);
6066 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6067 if (isVarArg) ParamTypes.pop_back();
6069 const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get();
6070 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6071 error("Functions cannot return aggregate types");
6073 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
6074 PFTy = PointerType::get(FTy);
6077 // First upgrade any intrinsic calls.
6078 std::vector<Value*> Args;
6079 if ((yyvsp[-1].ValueList))
6080 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
6081 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
6082 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
6084 // If we got an upgraded intrinsic
6086 (yyval.InstVal).I = Inst;
6087 (yyval.InstVal).S = Signless;
6089 // Get the function we're calling
6090 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
6092 // Check the argument values match
6093 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
6094 // Make sure no arguments is a good thing!
6095 if (FTy->getNumParams() != 0)
6096 error("No arguments passed to a function that expects arguments");
6097 } else { // Has arguments?
6098 // Loop through FunctionType's arguments and ensure they are specified
6101 FunctionType::param_iterator I = FTy->param_begin();
6102 FunctionType::param_iterator E = FTy->param_end();
6103 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
6105 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6106 if ((*ArgI).V->getType() != *I)
6107 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6108 (*I)->getDescription() + "'");
6110 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6111 error("Invalid number of parameters detected");
6114 // Create the call instruction
6115 CallInst *CI = new CallInst(V, &Args[0], Args.size());
6116 CI->setTailCall((yyvsp[-6].BoolVal));
6117 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
6118 (yyval.InstVal).I = CI;
6119 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6121 delete (yyvsp[-4].TypeVal).PAT;
6122 delete (yyvsp[-1].ValueList);
6127 #line 3438 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6129 (yyval.InstVal) = (yyvsp[0].InstVal);
6134 #line 3446 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6135 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
6139 #line 3447 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6140 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6144 #line 3451 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6145 { (yyval.BoolVal) = true; ;}
6149 #line 3452 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6150 { (yyval.BoolVal) = false; ;}
6154 #line 3456 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6156 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
6157 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6158 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6159 delete (yyvsp[-1].TypeVal).PAT;
6164 #line 3462 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6166 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
6167 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6168 (yyvsp[-1].ValIDVal).S = Unsigned;
6169 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6170 delete (yyvsp[-4].TypeVal).PAT;
6175 #line 3469 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6177 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
6178 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6179 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6180 delete (yyvsp[-1].TypeVal).PAT;
6185 #line 3475 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6187 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
6188 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6189 (yyvsp[-1].ValIDVal).S = Unsigned;
6190 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6191 delete (yyvsp[-4].TypeVal).PAT;
6196 #line 3482 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6198 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
6199 if (!isa<PointerType>(PTy))
6200 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
6201 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
6202 (yyval.InstVal).S = Signless;
6207 #line 3489 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6209 const Type* Ty = (yyvsp[-1].TypeVal).PAT->get();
6210 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6211 (yyvsp[0].ValIDVal).S = (yyvsp[-1].TypeVal).S;
6212 if (!isa<PointerType>(Ty))
6213 error("Can't load from nonpointer type: " + Ty->getDescription());
6214 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6215 error("Can't load from pointer of non-first-class type: " +
6216 Ty->getDescription());
6217 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6218 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
6219 delete (yyvsp[-1].TypeVal).PAT;
6224 #line 3502 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6226 (yyvsp[0].ValIDVal).S = (yyvsp[-1].TypeVal).S;
6227 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
6229 error("Can't store to a nonpointer type: " +
6230 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
6231 const Type *ElTy = PTy->getElementType();
6232 Value *StoreVal = (yyvsp[-3].ValueVal).V;
6233 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6234 if (ElTy != (yyvsp[-3].ValueVal).V->getType()) {
6235 StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy);
6237 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
6238 "' into space of type '" + ElTy->getDescription() + "'");
6240 PTy = PointerType::get(StoreVal->getType());
6241 if (Constant *C = dyn_cast<Constant>(tmpVal))
6242 tmpVal = ConstantExpr::getBitCast(C, PTy);
6244 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6247 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal));
6248 (yyval.InstVal).S = Signless;
6249 delete (yyvsp[-1].TypeVal).PAT;
6254 #line 3528 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6256 (yyvsp[-1].ValIDVal).S = (yyvsp[-2].TypeVal).S;
6257 const Type* Ty = (yyvsp[-2].TypeVal).PAT->get();
6258 if (!isa<PointerType>(Ty))
6259 error("getelementptr insn requires pointer operand");
6261 std::vector<Value*> VIndices;
6262 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
6264 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
6265 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size());
6266 (yyval.InstVal).S = Signless;
6267 delete (yyvsp[-2].TypeVal).PAT;
6268 delete (yyvsp[0].ValueList);
6276 /* Line 1126 of yacc.c. */
6277 #line 6278 "UpgradeParser.tab.c"
6283 YY_STACK_PRINT (yyss, yyssp);
6288 /* Now `shift' the result of the reduction. Determine what state
6289 that goes to, based on the state we popped back to and the rule
6290 number reduced by. */
6294 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6295 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
6296 yystate = yytable[yystate];
6298 yystate = yydefgoto[yyn - YYNTOKENS];
6303 /*------------------------------------.
6304 | yyerrlab -- here on detecting error |
6305 `------------------------------------*/
6307 /* If not already recovering from an error, report this error. */
6312 yyn = yypact[yystate];
6314 if (YYPACT_NINF < yyn && yyn < YYLAST)
6316 int yytype = YYTRANSLATE (yychar);
6317 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6318 YYSIZE_T yysize = yysize0;
6320 int yysize_overflow = 0;
6322 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6323 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6327 /* This is so xgettext sees the translatable formats that are
6328 constructed on the fly. */
6329 YY_("syntax error, unexpected %s");
6330 YY_("syntax error, unexpected %s, expecting %s");
6331 YY_("syntax error, unexpected %s, expecting %s or %s");
6332 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6333 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6337 static char const yyunexpected[] = "syntax error, unexpected %s";
6338 static char const yyexpecting[] = ", expecting %s";
6339 static char const yyor[] = " or %s";
6340 char yyformat[sizeof yyunexpected
6341 + sizeof yyexpecting - 1
6342 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6343 * (sizeof yyor - 1))];
6344 char const *yyprefix = yyexpecting;
6346 /* Start YYX at -YYN if negative to avoid negative indexes in
6348 int yyxbegin = yyn < 0 ? -yyn : 0;
6350 /* Stay within bounds of both yycheck and yytname. */
6351 int yychecklim = YYLAST - yyn;
6352 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6355 yyarg[0] = yytname[yytype];
6356 yyfmt = yystpcpy (yyformat, yyunexpected);
6358 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6359 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6361 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6365 yyformat[sizeof yyunexpected - 1] = '\0';
6368 yyarg[yycount++] = yytname[yyx];
6369 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6370 yysize_overflow |= yysize1 < yysize;
6372 yyfmt = yystpcpy (yyfmt, yyprefix);
6376 yyf = YY_(yyformat);
6377 yysize1 = yysize + yystrlen (yyf);
6378 yysize_overflow |= yysize1 < yysize;
6381 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6382 yymsg = (char *) YYSTACK_ALLOC (yysize);
6385 /* Avoid sprintf, as that infringes on the user's name space.
6386 Don't have undefined behavior even if the translation
6387 produced a string with the wrong number of "%s"s. */
6390 while ((*yyp = *yyf))
6392 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6394 yyp += yytnamerr (yyp, yyarg[yyi++]);
6404 YYSTACK_FREE (yymsg);
6408 yyerror (YY_("syntax error"));
6409 goto yyexhaustedlab;
6413 #endif /* YYERROR_VERBOSE */
6414 yyerror (YY_("syntax error"));
6419 if (yyerrstatus == 3)
6421 /* If just tried and failed to reuse look-ahead token after an
6422 error, discard it. */
6424 if (yychar <= YYEOF)
6426 /* Return failure if at end of input. */
6427 if (yychar == YYEOF)
6432 yydestruct ("Error: discarding", yytoken, &yylval);
6437 /* Else will try to reuse look-ahead token after shifting the error
6442 /*---------------------------------------------------.
6443 | yyerrorlab -- error raised explicitly by YYERROR. |
6444 `---------------------------------------------------*/
6447 /* Pacify compilers like GCC when the user code never invokes
6448 YYERROR and the label yyerrorlab therefore never appears in user
6459 /*-------------------------------------------------------------.
6460 | yyerrlab1 -- common code for both syntax error and YYERROR. |
6461 `-------------------------------------------------------------*/
6463 yyerrstatus = 3; /* Each real token shifted decrements this. */
6467 yyn = yypact[yystate];
6468 if (yyn != YYPACT_NINF)
6471 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6479 /* Pop the current state because it cannot handle the error token. */
6484 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6487 YY_STACK_PRINT (yyss, yyssp);
6496 /* Shift the error token. */
6497 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6503 /*-------------------------------------.
6504 | yyacceptlab -- YYACCEPT comes here. |
6505 `-------------------------------------*/
6510 /*-----------------------------------.
6511 | yyabortlab -- YYABORT comes here. |
6512 `-----------------------------------*/
6518 /*-------------------------------------------------.
6519 | yyexhaustedlab -- memory exhaustion comes here. |
6520 `-------------------------------------------------*/
6522 yyerror (YY_("memory exhausted"));
6528 if (yychar != YYEOF && yychar != YYEMPTY)
6529 yydestruct ("Cleanup: discarding lookahead",
6531 while (yyssp != yyss)
6533 yydestruct ("Cleanup: popping",
6534 yystos[*yyssp], yyvsp);
6539 YYSTACK_FREE (yyss);
6545 #line 3545 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6548 int yyerror(const char *ErrorMsg) {
6550 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6551 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
6552 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6553 if (yychar != YYEMPTY && yychar != 0)
6554 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6556 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6557 std::cout << "llvm-upgrade: parse failed.\n";
6561 void warning(const std::string& ErrorMsg) {
6563 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6564 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
6565 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6566 if (yychar != YYEMPTY && yychar != 0)
6567 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6569 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6572 void error(const std::string& ErrorMsg, int LineNo) {
6573 if (LineNo == -1) LineNo = Upgradelineno;
6574 Upgradelineno = LineNo;
6575 yyerror(ErrorMsg.c_str());