1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
61 /* Substitute the variable and function names. */
62 #define yyparse Upgradeparse
63 #define yylex Upgradelex
64 #define yyerror Upgradeerror
65 #define yylval Upgradelval
66 #define yychar Upgradechar
67 #define yydebug Upgradedebug
68 #define yynerrs Upgradenerrs
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
100 ZEROINITIALIZER = 281,
143 X86_STDCALLCC_TOK = 324,
144 X86_FASTCALLCC_TOK = 325,
188 EXTRACTELEMENT = 369,
229 #define ESINT64VAL 258
230 #define EUINT64VAL 259
250 #define STRINGCONSTANT 279
251 #define IMPLEMENTATION 280
252 #define ZEROINITIALIZER 281
263 #define DOTDOTDOT 292
270 #define APPENDING 299
271 #define DLLIMPORT 300
272 #define DLLEXPORT 301
273 #define EXTERN_WEAK 302
280 #define POINTERSIZE 309
289 #define SIDEEFFECT 318
292 #define CSRETCC_TOK 321
293 #define FASTCC_TOK 322
294 #define COLDCC_TOK 323
295 #define X86_STDCALLCC_TOK 324
296 #define X86_FASTCALLCC_TOK 325
297 #define DATALAYOUT 326
302 #define UNREACHABLE 331
336 #define GETELEMENTPTR 365
340 #define EXTRACTELEMENT 369
341 #define INSERTELEMENT 370
342 #define SHUFFLEVECTOR 371
343 #define VAARG_old 372
344 #define VANEXT_old 373
382 /* Copy the first part of user declarations. */
383 #line 14 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
385 #include "UpgradeInternals.h"
386 #include "llvm/CallingConv.h"
387 #include "llvm/InlineAsm.h"
388 #include "llvm/Instructions.h"
389 #include "llvm/Module.h"
390 #include "llvm/ParameterAttributes.h"
391 #include "llvm/ValueSymbolTable.h"
392 #include "llvm/Support/GetElementPtrTypeIterator.h"
393 #include "llvm/ADT/STLExtras.h"
394 #include "llvm/Support/MathExtras.h"
401 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
402 // relating to upreferences in the input stream.
404 //#define DEBUG_UPREFS 1
406 #define UR_OUT(X) std::cerr << X
411 #define YYERROR_VERBOSE 1
412 #define YYINCLUDED_STDLIB_H
418 int yyerror(const char*);
419 static void warning(const std::string& WarningMsg);
423 std::istream* LexInput;
424 static std::string CurFilename;
426 // This bool controls whether attributes are ever added to function declarations
427 // definitions and calls.
428 static bool AddAttributes = false;
430 static Module *ParserResult;
431 static bool ObsoleteVarArgs;
432 static bool NewVarArgs;
433 static BasicBlock *CurBB;
434 static GlobalVariable *CurGV;
435 static unsigned lastCallingConv;
437 // This contains info used when building the body of a function. It is
438 // destroyed when the function is completed.
440 typedef std::vector<Value *> ValueList; // Numbered defs
442 typedef std::pair<std::string,TypeInfo> RenameMapKey;
443 typedef std::map<RenameMapKey,std::string> RenameMapType;
446 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
447 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
449 static struct PerModuleInfo {
450 Module *CurrentModule;
451 std::map<const Type *, ValueList> Values; // Module level numbered definitions
452 std::map<const Type *,ValueList> LateResolveValues;
453 std::vector<PATypeHolder> Types;
454 std::vector<Signedness> TypeSigns;
455 std::map<std::string,Signedness> NamedTypeSigns;
456 std::map<std::string,Signedness> NamedValueSigns;
457 std::map<ValID, PATypeHolder> LateResolveTypes;
458 static Module::Endianness Endian;
459 static Module::PointerSize PointerSize;
460 RenameMapType RenameMap;
462 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
463 /// how they were referenced and on which line of the input they came from so
464 /// that we can resolve them later and print error messages as appropriate.
465 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
467 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
468 // references to global values. Global values may be referenced before they
469 // are defined, and if so, the temporary object that they represent is held
470 // here. This is used for forward references of GlobalValues.
472 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
474 GlobalRefsType GlobalRefs;
477 // If we could not resolve some functions at function compilation time
478 // (calls to functions before they are defined), resolve them now... Types
479 // are resolved when the constant pool has been completely parsed.
481 ResolveDefinitions(LateResolveValues);
483 // Check to make sure that all global value forward references have been
486 if (!GlobalRefs.empty()) {
487 std::string UndefinedReferences = "Unresolved global references exist:\n";
489 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
491 UndefinedReferences += " " + I->first.first->getDescription() + " " +
492 I->first.second.getName() + "\n";
494 error(UndefinedReferences);
498 if (CurrentModule->getDataLayout().empty()) {
499 std::string dataLayout;
500 if (Endian != Module::AnyEndianness)
501 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
502 if (PointerSize != Module::AnyPointerSize) {
503 if (!dataLayout.empty())
505 dataLayout.append(PointerSize == Module::Pointer64 ?
506 "p:64:64" : "p:32:32");
508 CurrentModule->setDataLayout(dataLayout);
511 Values.clear(); // Clear out function local definitions
514 NamedTypeSigns.clear();
515 NamedValueSigns.clear();
519 // GetForwardRefForGlobal - Check to see if there is a forward reference
520 // for this global. If so, remove it from the GlobalRefs map and return it.
521 // If not, just return null.
522 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
523 // Check to see if there is a forward reference to this global variable...
524 // if there is, eliminate it and patch the reference to use the new def'n.
525 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
526 GlobalValue *Ret = 0;
527 if (I != GlobalRefs.end()) {
533 void setEndianness(Module::Endianness E) { Endian = E; }
534 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
537 Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
538 Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
540 static struct PerFunctionInfo {
541 Function *CurrentFunction; // Pointer to current function being created
543 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
544 std::map<const Type*, ValueList> LateResolveValues;
545 bool isDeclare; // Is this function a forward declararation?
546 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
548 /// BBForwardRefs - When we see forward references to basic blocks, keep
549 /// track of them here.
550 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
551 std::vector<BasicBlock*> NumberedBlocks;
552 RenameMapType RenameMap;
555 inline PerFunctionInfo() {
558 Linkage = GlobalValue::ExternalLinkage;
561 inline void FunctionStart(Function *M) {
566 void FunctionDone() {
567 NumberedBlocks.clear();
569 // Any forward referenced blocks left?
570 if (!BBForwardRefs.empty()) {
571 error("Undefined reference to label " +
572 BBForwardRefs.begin()->first->getName());
576 // Resolve all forward references now.
577 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
579 Values.clear(); // Clear out function local definitions
583 Linkage = GlobalValue::ExternalLinkage;
585 } CurFun; // Info for the current function...
587 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
589 /// This function is just a utility to make a Key value for the rename map.
590 /// The Key is a combination of the name, type, Signedness of the original
591 /// value (global/function). This just constructs the key and ensures that
592 /// named Signedness values are resolved to the actual Signedness.
593 /// @brief Make a key for the RenameMaps
594 static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty,
595 const Signedness &Sign) {
599 // Don't allow Named Signedness nodes because they won't match. The actual
600 // Signedness must be looked up in the NamedTypeSigns map.
601 TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]);
604 return std::make_pair(Name, TI);
608 //===----------------------------------------------------------------------===//
609 // Code to handle definitions of all the types
610 //===----------------------------------------------------------------------===//
612 static int InsertValue(Value *V,
613 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
614 if (V->hasName()) return -1; // Is this a numbered definition?
616 // Yes, insert the value into the value table...
617 ValueList &List = ValueTab[V->getType()];
619 return List.size()-1;
622 static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
624 case ValID::NumberVal: // Is it a numbered definition?
625 // Module constants occupy the lowest numbered slots...
626 if ((unsigned)D.Num < CurModule.Types.size()) {
627 return CurModule.Types[(unsigned)D.Num];
630 case ValID::NameVal: // Is it a named definition?
631 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
636 error("Internal parser error: Invalid symbol type reference");
640 // If we reached here, we referenced either a symbol that we don't know about
641 // or an id number that hasn't been read yet. We may be referencing something
642 // forward, so just create an entry to be resolved later and get to it...
644 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
646 if (inFunctionScope()) {
647 if (D.Type == ValID::NameVal) {
648 error("Reference to an undefined type: '" + D.getName() + "'");
651 error("Reference to an undefined type: #" + itostr(D.Num));
656 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
657 if (I != CurModule.LateResolveTypes.end())
660 Type *Typ = OpaqueType::get();
661 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
665 /// This is like the getType method except that instead of looking up the type
666 /// for a given ID, it looks up that type's sign.
667 /// @brief Get the signedness of a referenced type
668 static Signedness getTypeSign(const ValID &D) {
670 case ValID::NumberVal: // Is it a numbered definition?
671 // Module constants occupy the lowest numbered slots...
672 if ((unsigned)D.Num < CurModule.TypeSigns.size()) {
673 return CurModule.TypeSigns[(unsigned)D.Num];
676 case ValID::NameVal: { // Is it a named definition?
677 std::map<std::string,Signedness>::const_iterator I =
678 CurModule.NamedTypeSigns.find(D.Name);
679 if (I != CurModule.NamedTypeSigns.end())
681 // Perhaps its a named forward .. just cache the name
689 // If we don't find it, its signless
695 /// This function is analagous to getElementType in LLVM. It provides the same
696 /// function except that it looks up the Signedness instead of the type. This is
697 /// used when processing GEP instructions that need to extract the type of an
698 /// indexed struct/array/ptr member.
699 /// @brief Look up an element's sign.
700 static Signedness getElementSign(const ValueInfo& VI,
701 const std::vector<Value*> &Indices) {
702 const Type *Ptr = VI.V->getType();
703 assert(isa<PointerType>(Ptr) && "Need pointer type");
707 while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
708 if (CurIdx == Indices.size())
711 Value *Index = Indices[CurIdx++];
712 assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type");
713 Ptr = CT->getTypeAtIndex(Index);
714 if (const Type* Ty = Ptr->getForwardedType())
716 assert(S.isComposite() && "Bad Signedness type");
717 if (isa<StructType>(CT)) {
718 S = S.get(cast<ConstantInt>(Index)->getZExtValue());
723 S = CurModule.NamedTypeSigns[S.getName()];
726 Result.makeComposite(S);
730 /// This function just translates a ConstantInfo into a ValueInfo and calls
731 /// getElementSign(ValueInfo,...). Its just a convenience.
732 /// @brief ConstantInfo version of getElementSign.
733 static Signedness getElementSign(const ConstInfo& CI,
734 const std::vector<Constant*> &Indices) {
738 std::vector<Value*> Idx;
739 for (unsigned i = 0; i < Indices.size(); ++i)
740 Idx.push_back(Indices[i]);
741 Signedness result = getElementSign(VI, Idx);
746 // getExistingValue - Look up the value specified by the provided type and
747 // the provided ValID. If the value exists and has already been defined, return
748 // it. Otherwise return null.
750 static Value *getExistingValue(const Type *Ty, const ValID &D) {
751 if (isa<FunctionType>(Ty)) {
752 error("Functions are not values and must be referenced as pointers");
756 case ValID::NumberVal: { // Is it a numbered definition?
757 unsigned Num = (unsigned)D.Num;
759 // Module constants occupy the lowest numbered slots...
760 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
761 if (VI != CurModule.Values.end()) {
762 if (Num < VI->second.size())
763 return VI->second[Num];
764 Num -= VI->second.size();
767 // Make sure that our type is within bounds
768 VI = CurFun.Values.find(Ty);
769 if (VI == CurFun.Values.end()) return 0;
771 // Check that the number is within bounds...
772 if (VI->second.size() <= Num) return 0;
774 return VI->second[Num];
777 case ValID::NameVal: { // Is it a named definition?
778 // Get the name out of the ID
779 RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
781 if (inFunctionScope()) {
782 // See if the name was renamed
783 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
784 std::string LookupName;
785 if (I != CurFun.RenameMap.end())
786 LookupName = I->second;
789 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
790 V = SymTab.lookup(LookupName);
791 if (V && V->getType() != Ty)
795 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
796 std::string LookupName;
797 if (I != CurModule.RenameMap.end())
798 LookupName = I->second;
801 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
802 if (V && V->getType() != Ty)
808 D.destroy(); // Free old strdup'd memory...
812 // Check to make sure that "Ty" is an integral type, and that our
813 // value will fit into the specified type...
814 case ValID::ConstSIntVal: // Is it a constant pool reference??
815 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
816 error("Signed integral constant '" + itostr(D.ConstPool64) +
817 "' is invalid for type '" + Ty->getDescription() + "'");
819 return ConstantInt::get(Ty, D.ConstPool64);
821 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
822 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
823 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
824 error("Integral constant '" + utostr(D.UConstPool64) +
825 "' is invalid or out of range");
826 else // This is really a signed reference. Transmogrify.
827 return ConstantInt::get(Ty, D.ConstPool64);
829 return ConstantInt::get(Ty, D.UConstPool64);
831 case ValID::ConstFPVal: // Is it a floating point const pool reference?
832 if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP))
833 error("FP constant invalid for type");
834 // Lexer has no type info, so builds all FP constants as double.
836 if (Ty==Type::FloatTy)
837 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
838 return ConstantFP::get(Ty, *D.ConstPoolFP);
840 case ValID::ConstNullVal: // Is it a null value?
841 if (!isa<PointerType>(Ty))
842 error("Cannot create a a non pointer null");
843 return ConstantPointerNull::get(cast<PointerType>(Ty));
845 case ValID::ConstUndefVal: // Is it an undef value?
846 return UndefValue::get(Ty);
848 case ValID::ConstZeroVal: // Is it a zero value?
849 return Constant::getNullValue(Ty);
851 case ValID::ConstantVal: // Fully resolved constant?
852 if (D.ConstantValue->getType() != Ty)
853 error("Constant expression type different from required type");
854 return D.ConstantValue;
856 case ValID::InlineAsmVal: { // Inline asm expression
857 const PointerType *PTy = dyn_cast<PointerType>(Ty);
858 const FunctionType *FTy =
859 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
860 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
861 error("Invalid type for asm constraint string");
862 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
863 D.IAD->HasSideEffects);
864 D.destroy(); // Free InlineAsmDescriptor.
868 assert(0 && "Unhandled case");
872 assert(0 && "Unhandled case");
876 // getVal - This function is identical to getExistingValue, except that if a
877 // value is not already defined, it "improvises" by creating a placeholder var
878 // that looks and acts just like the requested variable. When the value is
879 // defined later, all uses of the placeholder variable are replaced with the
882 static Value *getVal(const Type *Ty, const ValID &ID) {
883 if (Ty == Type::LabelTy)
884 error("Cannot use a basic block here");
886 // See if the value has already been defined.
887 Value *V = getExistingValue(Ty, ID);
890 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
891 error("Invalid use of a composite type");
893 // If we reached here, we referenced either a symbol that we don't know about
894 // or an id number that hasn't been read yet. We may be referencing something
895 // forward, so just create an entry to be resolved later and get to it...
896 V = new Argument(Ty);
898 // Remember where this forward reference came from. FIXME, shouldn't we try
899 // to recycle these things??
900 CurModule.PlaceHolderInfo.insert(
901 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
903 if (inFunctionScope())
904 InsertValue(V, CurFun.LateResolveValues);
906 InsertValue(V, CurModule.LateResolveValues);
910 /// @brief This just makes any name given to it unique, up to MAX_UINT times.
911 static std::string makeNameUnique(const std::string& Name) {
912 static unsigned UniqueNameCounter = 1;
913 std::string Result(Name);
914 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
918 /// getBBVal - This is used for two purposes:
919 /// * If isDefinition is true, a new basic block with the specified ID is being
921 /// * If isDefinition is true, this is a reference to a basic block, which may
922 /// or may not be a forward reference.
924 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
925 assert(inFunctionScope() && "Can't get basic block at global scope");
931 error("Illegal label reference " + ID.getName());
933 case ValID::NumberVal: // Is it a numbered definition?
934 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
935 CurFun.NumberedBlocks.resize(ID.Num+1);
936 BB = CurFun.NumberedBlocks[ID.Num];
938 case ValID::NameVal: // Is it a named definition?
940 if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
941 if (N->getType() != Type::LabelTy) {
942 // Register names didn't use to conflict with basic block names
943 // because of type planes. Now they all have to be unique. So, we just
944 // rename the register and treat this name as if no basic block
946 RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
947 N->setName(makeNameUnique(N->getName()));
948 CurModule.RenameMap[Key] = N->getName();
951 BB = cast<BasicBlock>(N);
957 // See if the block has already been defined.
959 // If this is the definition of the block, make sure the existing value was
960 // just a forward reference. If it was a forward reference, there will be
961 // an entry for it in the PlaceHolderInfo map.
962 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
963 // The existing value was a definition, not a forward reference.
964 error("Redefinition of label " + ID.getName());
966 ID.destroy(); // Free strdup'd memory.
970 // Otherwise this block has not been seen before.
971 BB = new BasicBlock("", CurFun.CurrentFunction);
972 if (ID.Type == ValID::NameVal) {
973 BB->setName(ID.Name);
975 CurFun.NumberedBlocks[ID.Num] = BB;
978 // If this is not a definition, keep track of it so we can use it as a forward
981 // Remember where this forward reference came from.
982 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
984 // The forward declaration could have been inserted anywhere in the
985 // function: insert it into the correct place now.
986 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
987 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
994 //===----------------------------------------------------------------------===//
995 // Code to handle forward references in instructions
996 //===----------------------------------------------------------------------===//
998 // This code handles the late binding needed with statements that reference
999 // values not defined yet... for example, a forward branch, or the PHI node for
1002 // This keeps a table (CurFun.LateResolveValues) of all such forward references
1003 // and back patchs after we are done.
1006 // ResolveDefinitions - If we could not resolve some defs at parsing
1007 // time (forward branches, phi functions for loops, etc...) resolve the
1011 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
1012 std::map<const Type*,ValueList> *FutureLateResolvers) {
1014 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1015 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
1016 E = LateResolvers.end(); LRI != E; ++LRI) {
1017 const Type* Ty = LRI->first;
1018 ValueList &List = LRI->second;
1019 while (!List.empty()) {
1020 Value *V = List.back();
1023 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1024 CurModule.PlaceHolderInfo.find(V);
1025 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
1027 ValID &DID = PHI->second.first;
1029 Value *TheRealValue = getExistingValue(Ty, DID);
1031 V->replaceAllUsesWith(TheRealValue);
1033 CurModule.PlaceHolderInfo.erase(PHI);
1034 } else if (FutureLateResolvers) {
1035 // Functions have their unresolved items forwarded to the module late
1037 InsertValue(V, *FutureLateResolvers);
1039 if (DID.Type == ValID::NameVal) {
1040 error("Reference to an invalid definition: '" + DID.getName() +
1041 "' of type '" + V->getType()->getDescription() + "'",
1042 PHI->second.second);
1045 error("Reference to an invalid definition: #" +
1046 itostr(DID.Num) + " of type '" +
1047 V->getType()->getDescription() + "'", PHI->second.second);
1054 LateResolvers.clear();
1057 /// This function is used for type resolution and upref handling. When a type
1058 /// becomes concrete, this function is called to adjust the signedness for the
1060 static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
1061 std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
1062 if (!TyName.empty())
1063 CurModule.NamedTypeSigns[TyName] = Sign;
1066 /// ResolveTypeTo - A brand new type was just declared. This means that (if
1067 /// name is not null) things referencing Name can be resolved. Otherwise,
1068 /// things refering to the number can be resolved. Do this now.
1069 static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
1072 D = ValID::create(Name);
1074 D = ValID::create((int)CurModule.Types.size());
1078 CurModule.NamedTypeSigns[Name] = Sign;
1080 std::map<ValID, PATypeHolder>::iterator I =
1081 CurModule.LateResolveTypes.find(D);
1082 if (I != CurModule.LateResolveTypes.end()) {
1083 const Type *OldTy = I->second.get();
1084 ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
1085 CurModule.LateResolveTypes.erase(I);
1089 /// This is the implementation portion of TypeHasInteger. It traverses the
1090 /// type given, avoiding recursive types, and returns true as soon as it finds
1091 /// an integer type. If no integer type is found, it returns false.
1092 static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
1093 // Handle some easy cases
1094 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
1096 if (Ty->isInteger())
1098 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
1099 return STy->getElementType()->isInteger();
1101 // Avoid type structure recursion
1102 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
1107 // Push us on the type stack
1108 Stack.push_back(Ty);
1110 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1111 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1113 FunctionType::param_iterator I = FTy->param_begin();
1114 FunctionType::param_iterator E = FTy->param_end();
1116 if (TypeHasIntegerI(*I, Stack))
1119 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1120 StructType::element_iterator I = STy->element_begin();
1121 StructType::element_iterator E = STy->element_end();
1122 for (; I != E; ++I) {
1123 if (TypeHasIntegerI(*I, Stack))
1128 // There shouldn't be anything else, but its definitely not integer
1129 assert(0 && "What type is this?");
1133 /// This is the interface to TypeHasIntegerI. It just provides the type stack,
1134 /// to avoid recursion, and then calls TypeHasIntegerI.
1135 static inline bool TypeHasInteger(const Type *Ty) {
1136 std::vector<const Type*> TyStack;
1137 return TypeHasIntegerI(Ty, TyStack);
1140 // setValueName - Set the specified value to the name given. The name may be
1141 // null potentially, in which case this is a noop. The string passed in is
1142 // assumed to be a malloc'd string buffer, and is free'd by this function.
1144 static void setValueName(const ValueInfo &V, char *NameStr) {
1146 std::string Name(NameStr); // Copy string
1147 free(NameStr); // Free old string
1149 if (V.V->getType() == Type::VoidTy) {
1150 error("Can't assign name '" + Name + "' to value with void type");
1154 assert(inFunctionScope() && "Must be in function scope");
1156 // Search the function's symbol table for an existing value of this name
1157 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1158 Value* Existing = ST.lookup(Name);
1160 // An existing value of the same name was found. This might have happened
1161 // because of the integer type planes collapsing in LLVM 2.0.
1162 if (Existing->getType() == V.V->getType() &&
1163 !TypeHasInteger(Existing->getType())) {
1164 // If the type does not contain any integers in them then this can't be
1165 // a type plane collapsing issue. It truly is a redefinition and we
1166 // should error out as the assembly is invalid.
1167 error("Redefinition of value named '" + Name + "' of type '" +
1168 V.V->getType()->getDescription() + "'");
1171 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1172 // function, regardless of Type. Previously re-use of names was okay as
1173 // long as they were distinct types. With type planes collapsing because
1174 // of the signedness change and because of PR411, this can no longer be
1175 // supported. We must search the entire symbol table for a conflicting
1176 // name and make the name unique. No warning is needed as this can't
1178 std::string NewName = makeNameUnique(Name);
1179 // We're changing the name but it will probably be used by other
1180 // instructions as operands later on. Consequently we have to retain
1181 // a mapping of the renaming that we're doing.
1182 RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
1183 CurFun.RenameMap[Key] = NewName;
1192 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1193 /// this is a declaration, otherwise it is a definition.
1194 static GlobalVariable *
1195 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1196 bool isConstantGlobal, const Type *Ty,
1197 Constant *Initializer,
1198 const Signedness &Sign) {
1199 if (isa<FunctionType>(Ty))
1200 error("Cannot declare global vars of function type");
1202 const PointerType *PTy = PointerType::get(Ty);
1206 Name = NameStr; // Copy string
1207 free(NameStr); // Free old string
1210 // See if this global value was forward referenced. If so, recycle the
1213 if (!Name.empty()) {
1214 ID = ValID::create((char*)Name.c_str());
1216 ID = ValID::create((int)CurModule.Values[PTy].size());
1218 ID.S.makeComposite(Sign);
1220 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1221 // Move the global to the end of the list, from whereever it was
1222 // previously inserted.
1223 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1224 CurModule.CurrentModule->getGlobalList().remove(GV);
1225 CurModule.CurrentModule->getGlobalList().push_back(GV);
1226 GV->setInitializer(Initializer);
1227 GV->setLinkage(Linkage);
1228 GV->setConstant(isConstantGlobal);
1229 InsertValue(GV, CurModule.Values);
1233 // If this global has a name, check to see if there is already a definition
1234 // of this global in the module and emit warnings if there are conflicts.
1235 if (!Name.empty()) {
1236 // The global has a name. See if there's an existing one of the same name.
1237 if (CurModule.CurrentModule->getNamedGlobal(Name) ||
1238 CurModule.CurrentModule->getFunction(Name)) {
1239 // We found an existing global of the same name. This isn't allowed
1240 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1241 // can at least compile. This can happen because of type planes
1242 // There is alread a global of the same name which means there is a
1243 // conflict. Let's see what we can do about it.
1244 std::string NewName(makeNameUnique(Name));
1245 if (Linkage != GlobalValue::InternalLinkage) {
1246 // The linkage of this gval is external so we can't reliably rename
1247 // it because it could potentially create a linking problem.
1248 // However, we can't leave the name conflict in the output either or
1249 // it won't assemble with LLVM 2.0. So, all we can do is rename
1250 // this one to something unique and emit a warning about the problem.
1251 warning("Renaming global variable '" + Name + "' to '" + NewName +
1252 "' may cause linkage errors");
1255 // Put the renaming in the global rename map
1256 RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
1257 CurModule.RenameMap[Key] = NewName;
1264 // Otherwise there is no existing GV to use, create one now.
1265 GlobalVariable *GV =
1266 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1267 CurModule.CurrentModule);
1268 InsertValue(GV, CurModule.Values);
1269 // Remember the sign of this global.
1270 CurModule.NamedValueSigns[Name] = ID.S;
1274 // setTypeName - Set the specified type to the name given. The name may be
1275 // null potentially, in which case this is a noop. The string passed in is
1276 // assumed to be a malloc'd string buffer, and is freed by this function.
1278 // This function returns true if the type has already been defined, but is
1279 // allowed to be redefined in the specified context. If the name is a new name
1280 // for the type plane, it is inserted and false is returned.
1281 static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
1282 assert(!inFunctionScope() && "Can't give types function-local names");
1283 if (NameStr == 0) return false;
1285 std::string Name(NameStr); // Copy string
1286 free(NameStr); // Free old string
1288 const Type* Ty = TI.PAT->get();
1290 // We don't allow assigning names to void type
1291 if (Ty == Type::VoidTy) {
1292 error("Can't assign name '" + Name + "' to the void type");
1296 // Set the type name, checking for conflicts as we do so.
1297 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
1299 // Save the sign information for later use
1300 CurModule.NamedTypeSigns[Name] = TI.S;
1302 if (AlreadyExists) { // Inserting a name that is already defined???
1303 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1304 assert(Existing && "Conflict but no matching type?");
1306 // There is only one case where this is allowed: when we are refining an
1307 // opaque type. In this case, Existing will be an opaque type.
1308 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1309 // We ARE replacing an opaque type!
1310 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
1314 // Otherwise, this is an attempt to redefine a type. That's okay if
1315 // the redefinition is identical to the original. This will be so if
1316 // Existing and T point to the same Type object. In this one case we
1317 // allow the equivalent redefinition.
1318 if (Existing == Ty) return true; // Yes, it's equal.
1320 // Any other kind of (non-equivalent) redefinition is an error.
1321 error("Redefinition of type named '" + Name + "' in the '" +
1322 Ty->getDescription() + "' type plane");
1328 //===----------------------------------------------------------------------===//
1329 // Code for handling upreferences in type names...
1332 // TypeContains - Returns true if Ty directly contains E in it.
1334 static bool TypeContains(const Type *Ty, const Type *E) {
1335 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1336 E) != Ty->subtype_end();
1340 struct UpRefRecord {
1341 // NestingLevel - The number of nesting levels that need to be popped before
1342 // this type is resolved.
1343 unsigned NestingLevel;
1345 // LastContainedTy - This is the type at the current binding level for the
1346 // type. Every time we reduce the nesting level, this gets updated.
1347 const Type *LastContainedTy;
1349 // UpRefTy - This is the actual opaque type that the upreference is
1350 // represented with.
1351 OpaqueType *UpRefTy;
1353 UpRefRecord(unsigned NL, OpaqueType *URTy)
1354 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
1358 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1359 static std::vector<UpRefRecord> UpRefs;
1361 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1362 /// called. It loops through the UpRefs vector, which is a list of the
1363 /// currently active types. For each type, if the up reference is contained in
1364 /// the newly completed type, we decrement the level count. When the level
1365 /// count reaches zero, the upreferenced type is the type that is passed in:
1366 /// thus we can complete the cycle.
1368 static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
1369 // If Ty isn't abstract, or if there are no up-references in it, then there is
1370 // nothing to resolve here.
1371 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1373 PATypeHolder Ty(ty);
1374 UR_OUT("Type '" << Ty->getDescription() <<
1375 "' newly formed. Resolving upreferences.\n" <<
1376 UpRefs.size() << " upreferences active!\n");
1378 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1379 // to zero), we resolve them all together before we resolve them to Ty. At
1380 // the end of the loop, if there is anything to resolve to Ty, it will be in
1382 OpaqueType *TypeToResolve = 0;
1385 for (; i != UpRefs.size(); ++i) {
1386 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1387 << UpRefs[i].UpRefTy->getDescription() << ") = "
1388 << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
1389 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1390 // Decrement level of upreference
1391 unsigned Level = --UpRefs[i].NestingLevel;
1392 UpRefs[i].LastContainedTy = Ty;
1393 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1394 if (Level == 0) { // Upreference should be resolved!
1395 if (!TypeToResolve) {
1396 TypeToResolve = UpRefs[i].UpRefTy;
1398 UR_OUT(" * Resolving upreference for "
1399 << UpRefs[i].UpRefTy->getDescription() << "\n";
1400 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1401 ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
1402 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1403 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1404 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1406 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1407 --i; // Do not skip the next element...
1412 if (TypeToResolve) {
1413 UR_OUT(" * Resolving upreference for "
1414 << UpRefs[i].UpRefTy->getDescription() << "\n";
1415 std::string OldName = TypeToResolve->getDescription());
1416 ResolveTypeSign(TypeToResolve, Sign);
1417 TypeToResolve->refineAbstractTypeTo(Ty);
1423 bool Signedness::operator<(const Signedness &that) const {
1426 return *(this->name) < *(that.name);
1428 return CurModule.NamedTypeSigns[*name] < that;
1429 } else if (that.isNamed()) {
1430 return *this < CurModule.NamedTypeSigns[*that.name];
1433 if (isComposite() && that.isComposite()) {
1434 if (sv->size() == that.sv->size()) {
1435 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1436 SignVector::const_iterator thatI = that.sv->begin(),
1437 thatE = that.sv->end();
1438 for (; thisI != thisE; ++thisI, ++thatI) {
1439 if (*thisI < *thatI)
1441 else if (!(*thisI == *thatI))
1446 return sv->size() < that.sv->size();
1448 return kind < that.kind;
1451 bool Signedness::operator==(const Signedness &that) const {
1454 return *(this->name) == *(that.name);
1456 return CurModule.NamedTypeSigns[*(this->name)] == that;
1457 else if (that.isNamed())
1458 return *this == CurModule.NamedTypeSigns[*(that.name)];
1459 if (isComposite() && that.isComposite()) {
1460 if (sv->size() == that.sv->size()) {
1461 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1462 SignVector::const_iterator thatI = that.sv->begin(),
1463 thatE = that.sv->end();
1464 for (; thisI != thisE; ++thisI, ++thatI) {
1465 if (!(*thisI == *thatI))
1472 return kind == that.kind;
1475 void Signedness::copy(const Signedness &that) {
1476 if (that.isNamed()) {
1478 name = new std::string(*that.name);
1479 } else if (that.isComposite()) {
1481 sv = new SignVector();
1489 void Signedness::destroy() {
1492 } else if (isComposite()) {
1498 void Signedness::dump() const {
1499 if (isComposite()) {
1500 if (sv->size() == 1) {
1505 for (unsigned i = 0; i < sv->size(); ++i) {
1512 } else if (isNamed()) {
1514 } else if (isSigned()) {
1516 } else if (isUnsigned()) {
1523 static inline Instruction::TermOps
1524 getTermOp(TermOps op) {
1526 default : assert(0 && "Invalid OldTermOp");
1527 case RetOp : return Instruction::Ret;
1528 case BrOp : return Instruction::Br;
1529 case SwitchOp : return Instruction::Switch;
1530 case InvokeOp : return Instruction::Invoke;
1531 case UnwindOp : return Instruction::Unwind;
1532 case UnreachableOp: return Instruction::Unreachable;
1536 static inline Instruction::BinaryOps
1537 getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
1539 default : assert(0 && "Invalid OldBinaryOps");
1545 case SetGT : assert(0 && "Should use getCompareOp");
1546 case AddOp : return Instruction::Add;
1547 case SubOp : return Instruction::Sub;
1548 case MulOp : return Instruction::Mul;
1550 // This is an obsolete instruction so we must upgrade it based on the
1551 // types of its operands.
1552 bool isFP = Ty->isFloatingPoint();
1553 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
1554 // If its a vector type we want to use the element type
1555 isFP = PTy->getElementType()->isFloatingPoint();
1557 return Instruction::FDiv;
1558 else if (Sign.isSigned())
1559 return Instruction::SDiv;
1560 return Instruction::UDiv;
1562 case UDivOp : return Instruction::UDiv;
1563 case SDivOp : return Instruction::SDiv;
1564 case FDivOp : return Instruction::FDiv;
1566 // This is an obsolete instruction so we must upgrade it based on the
1567 // types of its operands.
1568 bool isFP = Ty->isFloatingPoint();
1569 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
1570 // If its a vector type we want to use the element type
1571 isFP = PTy->getElementType()->isFloatingPoint();
1572 // Select correct opcode
1574 return Instruction::FRem;
1575 else if (Sign.isSigned())
1576 return Instruction::SRem;
1577 return Instruction::URem;
1579 case URemOp : return Instruction::URem;
1580 case SRemOp : return Instruction::SRem;
1581 case FRemOp : return Instruction::FRem;
1582 case LShrOp : return Instruction::LShr;
1583 case AShrOp : return Instruction::AShr;
1584 case ShlOp : return Instruction::Shl;
1586 if (Sign.isSigned())
1587 return Instruction::AShr;
1588 return Instruction::LShr;
1589 case AndOp : return Instruction::And;
1590 case OrOp : return Instruction::Or;
1591 case XorOp : return Instruction::Xor;
1595 static inline Instruction::OtherOps
1596 getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1597 const Signedness &Sign) {
1598 bool isSigned = Sign.isSigned();
1599 bool isFP = Ty->isFloatingPoint();
1601 default : assert(0 && "Invalid OldSetCC");
1604 predicate = FCmpInst::FCMP_OEQ;
1605 return Instruction::FCmp;
1607 predicate = ICmpInst::ICMP_EQ;
1608 return Instruction::ICmp;
1612 predicate = FCmpInst::FCMP_UNE;
1613 return Instruction::FCmp;
1615 predicate = ICmpInst::ICMP_NE;
1616 return Instruction::ICmp;
1620 predicate = FCmpInst::FCMP_OLE;
1621 return Instruction::FCmp;
1624 predicate = ICmpInst::ICMP_SLE;
1626 predicate = ICmpInst::ICMP_ULE;
1627 return Instruction::ICmp;
1631 predicate = FCmpInst::FCMP_OGE;
1632 return Instruction::FCmp;
1635 predicate = ICmpInst::ICMP_SGE;
1637 predicate = ICmpInst::ICMP_UGE;
1638 return Instruction::ICmp;
1642 predicate = FCmpInst::FCMP_OLT;
1643 return Instruction::FCmp;
1646 predicate = ICmpInst::ICMP_SLT;
1648 predicate = ICmpInst::ICMP_ULT;
1649 return Instruction::ICmp;
1653 predicate = FCmpInst::FCMP_OGT;
1654 return Instruction::FCmp;
1657 predicate = ICmpInst::ICMP_SGT;
1659 predicate = ICmpInst::ICMP_UGT;
1660 return Instruction::ICmp;
1665 static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1667 default : assert(0 && "Invalid OldMemoryOps");
1668 case MallocOp : return Instruction::Malloc;
1669 case FreeOp : return Instruction::Free;
1670 case AllocaOp : return Instruction::Alloca;
1671 case LoadOp : return Instruction::Load;
1672 case StoreOp : return Instruction::Store;
1673 case GetElementPtrOp : return Instruction::GetElementPtr;
1677 static inline Instruction::OtherOps
1678 getOtherOp(OtherOps op, const Signedness &Sign) {
1680 default : assert(0 && "Invalid OldOtherOps");
1681 case PHIOp : return Instruction::PHI;
1682 case CallOp : return Instruction::Call;
1683 case SelectOp : return Instruction::Select;
1684 case UserOp1 : return Instruction::UserOp1;
1685 case UserOp2 : return Instruction::UserOp2;
1686 case VAArg : return Instruction::VAArg;
1687 case ExtractElementOp : return Instruction::ExtractElement;
1688 case InsertElementOp : return Instruction::InsertElement;
1689 case ShuffleVectorOp : return Instruction::ShuffleVector;
1690 case ICmpOp : return Instruction::ICmp;
1691 case FCmpOp : return Instruction::FCmp;
1695 static inline Value*
1696 getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
1697 const Signedness &DstSign, bool ForceInstruction = false) {
1698 Instruction::CastOps Opcode;
1699 const Type* SrcTy = Src->getType();
1701 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1702 // fp -> ptr cast is no longer supported but we must upgrade this
1703 // by doing a double cast: fp -> int -> ptr
1704 SrcTy = Type::Int64Ty;
1705 Opcode = Instruction::IntToPtr;
1706 if (isa<Constant>(Src)) {
1707 Src = ConstantExpr::getCast(Instruction::FPToUI,
1708 cast<Constant>(Src), SrcTy);
1710 std::string NewName(makeNameUnique(Src->getName()));
1711 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1713 } else if (isa<IntegerType>(DstTy) &&
1714 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1715 // cast type %x to bool was previously defined as setne type %x, null
1716 // The cast semantic is now to truncate, not compare so we must retain
1717 // the original intent by replacing the cast with a setne
1718 Constant* Null = Constant::getNullValue(SrcTy);
1719 Instruction::OtherOps Opcode = Instruction::ICmp;
1720 unsigned short predicate = ICmpInst::ICMP_NE;
1721 if (SrcTy->isFloatingPoint()) {
1722 Opcode = Instruction::FCmp;
1723 predicate = FCmpInst::FCMP_ONE;
1724 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1725 error("Invalid cast to bool");
1727 if (isa<Constant>(Src) && !ForceInstruction)
1728 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1730 return CmpInst::create(Opcode, predicate, Src, Null);
1732 // Determine the opcode to use by calling CastInst::getCastOpcode
1734 CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
1735 DstSign.isSigned());
1737 } else switch (op) {
1738 default: assert(0 && "Invalid cast token");
1739 case TruncOp: Opcode = Instruction::Trunc; break;
1740 case ZExtOp: Opcode = Instruction::ZExt; break;
1741 case SExtOp: Opcode = Instruction::SExt; break;
1742 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1743 case FPExtOp: Opcode = Instruction::FPExt; break;
1744 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1745 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1746 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1747 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1748 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1749 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1750 case BitCastOp: Opcode = Instruction::BitCast; break;
1753 if (isa<Constant>(Src) && !ForceInstruction)
1754 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1755 return CastInst::create(Opcode, Src, DstTy);
1758 static Instruction *
1759 upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1760 std::vector<Value*>& Args) {
1762 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1763 if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' ||
1764 Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.')
1769 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1770 if (Args.size() != 2)
1771 error("Invalid prototype for " + Name);
1772 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1777 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1778 std::vector<const Type*> Params;
1779 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1780 if (Args.size() != 1)
1781 error("Invalid prototype for " + Name + " prototype");
1782 Params.push_back(PtrTy);
1783 const FunctionType *FTy =
1784 FunctionType::get(Type::VoidTy, Params, false);
1785 const PointerType *PFTy = PointerType::get(FTy);
1786 Value* Func = getVal(PFTy, ID);
1787 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
1788 return new CallInst(Func, Args.begin(), Args.end());
1789 } else if (Name == "llvm.va_copy") {
1790 if (Args.size() != 2)
1791 error("Invalid prototype for " + Name + " prototype");
1792 Params.push_back(PtrTy);
1793 Params.push_back(PtrTy);
1794 const FunctionType *FTy =
1795 FunctionType::get(Type::VoidTy, Params, false);
1796 const PointerType *PFTy = PointerType::get(FTy);
1797 Value* Func = getVal(PFTy, ID);
1798 std::string InstName0(makeNameUnique("va0"));
1799 std::string InstName1(makeNameUnique("va1"));
1800 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1801 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1802 return new CallInst(Func, Args.begin(), Args.end());
1809 const Type* upgradeGEPCEIndices(const Type* PTy,
1810 std::vector<ValueInfo> *Indices,
1811 std::vector<Constant*> &Result) {
1812 const Type *Ty = PTy;
1814 for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
1815 Constant *Index = cast<Constant>((*Indices)[i].V);
1817 if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
1818 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1819 // struct indices to i32 struct indices with ZExt for compatibility.
1820 if (CI->getBitWidth() < 32)
1821 Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
1824 if (isa<SequentialType>(Ty)) {
1825 // Make sure that unsigned SequentialType indices are zext'd to
1826 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1827 // all indices for SequentialType elements. We must retain the same
1828 // semantic (zext) for unsigned types.
1829 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
1830 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
1831 Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty);
1835 Result.push_back(Index);
1836 Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
1839 error("Index list invalid for constant getelementptr");
1844 const Type* upgradeGEPInstIndices(const Type* PTy,
1845 std::vector<ValueInfo> *Indices,
1846 std::vector<Value*> &Result) {
1847 const Type *Ty = PTy;
1849 for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
1850 Value *Index = (*Indices)[i].V;
1852 if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
1853 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1854 // struct indices to i32 struct indices with ZExt for compatibility.
1855 if (CI->getBitWidth() < 32)
1856 Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
1860 if (isa<StructType>(Ty)) { // Only change struct indices
1861 if (!isa<Constant>(Index)) {
1862 error("Invalid non-constant structure index");
1866 // Make sure that unsigned SequentialType indices are zext'd to
1867 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1868 // all indices for SequentialType elements. We must retain the same
1869 // semantic (zext) for unsigned types.
1870 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
1871 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
1872 if (isa<Constant>(Index))
1873 Index = ConstantExpr::getCast(Instruction::ZExt,
1874 cast<Constant>(Index), Type::Int64Ty);
1876 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1877 makeNameUnique("gep"), CurBB);
1881 Result.push_back(Index);
1882 Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
1885 error("Index list invalid for constant getelementptr");
1890 unsigned upgradeCallingConv(unsigned CC) {
1892 case OldCallingConv::C : return CallingConv::C;
1893 case OldCallingConv::CSRet : return CallingConv::C;
1894 case OldCallingConv::Fast : return CallingConv::Fast;
1895 case OldCallingConv::Cold : return CallingConv::Cold;
1896 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1897 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1903 Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1904 bool debug, bool addAttrs)
1907 CurFilename = infile;
1910 AddAttributes = addAttrs;
1911 ObsoleteVarArgs = false;
1914 CurModule.CurrentModule = new Module(CurFilename);
1916 // Check to make sure the parser succeeded
1919 delete ParserResult;
1920 std::cerr << "llvm-upgrade: parse failed.\n";
1924 // Check to make sure that parsing produced a result
1925 if (!ParserResult) {
1926 std::cerr << "llvm-upgrade: no parse result.\n";
1930 // Reset ParserResult variable while saving its value for the result.
1931 Module *Result = ParserResult;
1934 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1937 if ((F = Result->getFunction("llvm.va_start"))
1938 && F->getFunctionType()->getNumParams() == 0)
1939 ObsoleteVarArgs = true;
1940 if((F = Result->getFunction("llvm.va_copy"))
1941 && F->getFunctionType()->getNumParams() == 1)
1942 ObsoleteVarArgs = true;
1945 if (ObsoleteVarArgs && NewVarArgs) {
1946 error("This file is corrupt: it uses both new and old style varargs");
1950 if(ObsoleteVarArgs) {
1951 if(Function* F = Result->getFunction("llvm.va_start")) {
1952 if (F->arg_size() != 0) {
1953 error("Obsolete va_start takes 0 argument");
1959 //bar = alloca typeof(foo)
1963 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1964 const Type* ArgTy = F->getFunctionType()->getReturnType();
1965 const Type* ArgTyPtr = PointerType::get(ArgTy);
1966 Function* NF = cast<Function>(Result->getOrInsertFunction(
1967 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1969 while (!F->use_empty()) {
1970 CallInst* CI = cast<CallInst>(F->use_back());
1971 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1972 new CallInst(NF, bar, "", CI);
1973 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1974 CI->replaceAllUsesWith(foo);
1975 CI->getParent()->getInstList().erase(CI);
1977 Result->getFunctionList().erase(F);
1980 if(Function* F = Result->getFunction("llvm.va_end")) {
1981 if(F->arg_size() != 1) {
1982 error("Obsolete va_end takes 1 argument");
1988 //bar = alloca 1 of typeof(foo)
1990 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1991 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1992 const Type* ArgTyPtr = PointerType::get(ArgTy);
1993 Function* NF = cast<Function>(Result->getOrInsertFunction(
1994 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
1996 while (!F->use_empty()) {
1997 CallInst* CI = cast<CallInst>(F->use_back());
1998 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1999 new StoreInst(CI->getOperand(1), bar, CI);
2000 new CallInst(NF, bar, "", CI);
2001 CI->getParent()->getInstList().erase(CI);
2003 Result->getFunctionList().erase(F);
2006 if(Function* F = Result->getFunction("llvm.va_copy")) {
2007 if(F->arg_size() != 1) {
2008 error("Obsolete va_copy takes 1 argument");
2013 //a = alloca 1 of typeof(foo)
2014 //b = alloca 1 of typeof(foo)
2019 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2020 const Type* ArgTy = F->getFunctionType()->getReturnType();
2021 const Type* ArgTyPtr = PointerType::get(ArgTy);
2022 Function* NF = cast<Function>(Result->getOrInsertFunction(
2023 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
2025 while (!F->use_empty()) {
2026 CallInst* CI = cast<CallInst>(F->use_back());
2028 new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI),
2029 new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI)
2031 new StoreInst(CI->getOperand(1), Args[1], CI);
2032 new CallInst(NF, Args, Args + 2, "", CI);
2033 Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
2034 CI->replaceAllUsesWith(foo);
2035 CI->getParent()->getInstList().erase(CI);
2037 Result->getFunctionList().erase(F);
2044 } // end llvm namespace
2046 using namespace llvm;
2050 /* Enabling traces. */
2055 /* Enabling verbose error messages. */
2056 #ifdef YYERROR_VERBOSE
2057 # undef YYERROR_VERBOSE
2058 # define YYERROR_VERBOSE 1
2060 # define YYERROR_VERBOSE 0
2063 /* Enabling the token table. */
2064 #ifndef YYTOKEN_TABLE
2065 # define YYTOKEN_TABLE 0
2068 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
2069 typedef union YYSTYPE
2070 #line 1680 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
2072 llvm::Module *ModuleVal;
2073 llvm::Function *FunctionVal;
2074 std::pair<llvm::PATypeInfo, char*> *ArgVal;
2075 llvm::BasicBlock *BasicBlockVal;
2076 llvm::TermInstInfo TermInstVal;
2077 llvm::InstrInfo InstVal;
2078 llvm::ConstInfo ConstVal;
2079 llvm::ValueInfo ValueVal;
2080 llvm::PATypeInfo TypeVal;
2081 llvm::TypeInfo PrimType;
2082 llvm::PHIListInfo PHIList;
2083 std::list<llvm::PATypeInfo> *TypeList;
2084 std::vector<llvm::ValueInfo> *ValueList;
2085 std::vector<llvm::ConstInfo> *ConstVector;
2088 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
2089 // Represent the RHS of PHI node
2090 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
2092 llvm::GlobalValue::LinkageTypes Linkage;
2097 llvm::APFloat *FPVal;
2100 char *StrVal; // This memory is strdup'd!
2101 llvm::ValID ValIDVal; // strdup'd memory maybe!
2103 llvm::BinaryOps BinaryOpVal;
2104 llvm::TermOps TermOpVal;
2105 llvm::MemoryOps MemOpVal;
2106 llvm::OtherOps OtherOpVal;
2107 llvm::CastOps CastOpVal;
2108 llvm::ICmpInst::Predicate IPred;
2109 llvm::FCmpInst::Predicate FPred;
2110 llvm::Module::Endianness Endianness;
2112 /* Line 187 of yacc.c. */
2113 #line 2114 "UpgradeParser.tab.c"
2115 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
2116 # define YYSTYPE_IS_DECLARED 1
2117 # define YYSTYPE_IS_TRIVIAL 1
2122 /* Copy the second part of user declarations. */
2125 /* Line 216 of yacc.c. */
2126 #line 2127 "UpgradeParser.tab.c"
2133 typedef YYTYPE_UINT8 yytype_uint8;
2135 typedef unsigned char yytype_uint8;
2139 typedef YYTYPE_INT8 yytype_int8;
2140 #elif (defined __STDC__ || defined __C99__FUNC__ \
2141 || defined __cplusplus || defined _MSC_VER)
2142 typedef signed char yytype_int8;
2144 typedef short int yytype_int8;
2147 #ifdef YYTYPE_UINT16
2148 typedef YYTYPE_UINT16 yytype_uint16;
2150 typedef unsigned short int yytype_uint16;
2154 typedef YYTYPE_INT16 yytype_int16;
2156 typedef short int yytype_int16;
2160 # ifdef __SIZE_TYPE__
2161 # define YYSIZE_T __SIZE_TYPE__
2162 # elif defined size_t
2163 # define YYSIZE_T size_t
2164 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
2165 || defined __cplusplus || defined _MSC_VER)
2166 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2167 # define YYSIZE_T size_t
2169 # define YYSIZE_T unsigned int
2173 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
2178 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
2179 # define YY_(msgid) dgettext ("bison-runtime", msgid)
2183 # define YY_(msgid) msgid
2187 /* Suppress unused-variable warnings by "using" E. */
2188 #if ! defined lint || defined __GNUC__
2189 # define YYUSE(e) ((void) (e))
2191 # define YYUSE(e) /* empty */
2194 /* Identity function, used to suppress warnings about constant conditions. */
2196 # define YYID(n) (n)
2198 #if (defined __STDC__ || defined __C99__FUNC__ \
2199 || defined __cplusplus || defined _MSC_VER)
2212 #if ! defined yyoverflow || YYERROR_VERBOSE
2214 /* The parser invokes alloca or malloc; define the necessary symbols. */
2216 # ifdef YYSTACK_USE_ALLOCA
2217 # if YYSTACK_USE_ALLOCA
2219 # define YYSTACK_ALLOC __builtin_alloca
2220 # elif defined __BUILTIN_VA_ARG_INCR
2221 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
2223 # define YYSTACK_ALLOC __alloca
2224 # elif defined _MSC_VER
2225 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
2226 # define alloca _alloca
2228 # define YYSTACK_ALLOC alloca
2229 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2230 || defined __cplusplus || defined _MSC_VER)
2231 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2233 # define _STDLIB_H 1
2240 # ifdef YYSTACK_ALLOC
2241 /* Pacify GCC's `empty if-body' warning. */
2242 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
2243 # ifndef YYSTACK_ALLOC_MAXIMUM
2244 /* The OS might guarantee only one guard page at the bottom of the stack,
2245 and a page size can be as small as 4096 bytes. So we cannot safely
2246 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
2247 to allow for a few compiler-allocated temporary stack slots. */
2248 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
2251 # define YYSTACK_ALLOC YYMALLOC
2252 # define YYSTACK_FREE YYFREE
2253 # ifndef YYSTACK_ALLOC_MAXIMUM
2254 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
2256 # if (defined __cplusplus && ! defined _STDLIB_H \
2257 && ! ((defined YYMALLOC || defined malloc) \
2258 && (defined YYFREE || defined free)))
2259 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2261 # define _STDLIB_H 1
2265 # define YYMALLOC malloc
2266 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2267 || defined __cplusplus || defined _MSC_VER)
2268 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
2272 # define YYFREE free
2273 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2274 || defined __cplusplus || defined _MSC_VER)
2275 void free (void *); /* INFRINGES ON USER NAME SPACE */
2279 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
2282 #if (! defined yyoverflow \
2283 && (! defined __cplusplus \
2284 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
2286 /* A type that is properly aligned for any stack member. */
2293 /* The size of the maximum gap between one aligned stack and the next. */
2294 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2296 /* The size of an array large to enough to hold all stacks, each with
2298 # define YYSTACK_BYTES(N) \
2299 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
2300 + YYSTACK_GAP_MAXIMUM)
2302 /* Copy COUNT objects from FROM to TO. The source and destination do
2305 # if defined __GNUC__ && 1 < __GNUC__
2306 # define YYCOPY(To, From, Count) \
2307 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2309 # define YYCOPY(To, From, Count) \
2313 for (yyi = 0; yyi < (Count); yyi++) \
2314 (To)[yyi] = (From)[yyi]; \
2320 /* Relocate STACK from its old location to the new one. The
2321 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2322 elements in the stack, and YYPTR gives the new location of the
2323 stack. Advance YYPTR to a properly aligned location for the next
2325 # define YYSTACK_RELOCATE(Stack) \
2328 YYSIZE_T yynewbytes; \
2329 YYCOPY (&yyptr->Stack, Stack, yysize); \
2330 Stack = &yyptr->Stack; \
2331 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2332 yyptr += yynewbytes / sizeof (*yyptr); \
2338 /* YYFINAL -- State number of the termination state. */
2340 /* YYLAST -- Last index in YYTABLE. */
2343 /* YYNTOKENS -- Number of terminals. */
2344 #define YYNTOKENS 166
2345 /* YYNNTS -- Number of nonterminals. */
2347 /* YYNRULES -- Number of rules. */
2348 #define YYNRULES 310
2349 /* YYNRULES -- Number of states. */
2350 #define YYNSTATES 606
2352 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2353 #define YYUNDEFTOK 2
2354 #define YYMAXUTOK 406
2356 #define YYTRANSLATE(YYX) \
2357 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2359 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2360 static const yytype_uint8 yytranslate[] =
2362 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2363 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2364 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2365 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2366 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2367 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2368 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2369 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2370 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2371 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2372 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2373 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2374 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2375 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2376 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2377 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2378 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2379 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2380 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2381 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2382 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2383 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2384 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2385 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2386 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2387 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2388 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2389 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2390 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2391 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2392 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2393 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2394 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2395 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2396 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2397 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2398 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2399 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2400 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2401 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2402 145, 146, 147, 148, 149, 150, 151
2406 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2408 static const yytype_uint16 yyprhs[] =
2410 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2411 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2412 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2413 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2414 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2415 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2416 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2417 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2418 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2419 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2420 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2421 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2422 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2423 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2424 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2425 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2426 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2427 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2428 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2429 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2430 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2431 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2432 622, 623, 632, 634, 636, 637, 642, 644, 646, 649,
2433 650, 652, 654, 655, 656, 662, 663, 665, 667, 669,
2434 671, 673, 675, 677, 679, 681, 685, 687, 693, 695,
2435 697, 699, 701, 704, 707, 710, 714, 717, 718, 720,
2436 722, 724, 727, 730, 734, 744, 754, 763, 777, 779,
2437 781, 788, 794, 797, 804, 812, 814, 818, 820, 821,
2438 824, 826, 832, 838, 844, 851, 858, 861, 866, 871,
2439 878, 883, 888, 893, 898, 905, 912, 915, 923, 925,
2440 928, 929, 931, 932, 936, 943, 947, 954, 957, 962,
2444 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
2445 static const yytype_int16 yyrhs[] =
2447 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2448 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2449 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2450 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2451 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2452 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2453 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2454 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2455 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2456 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2457 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2458 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2459 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2460 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2461 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2462 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2463 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2464 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2465 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2466 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2467 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2468 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2469 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2470 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2471 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2472 -1, 19, -1, 21, -1, 192, -1, 48, -1, 229,
2473 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2474 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2475 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2476 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2477 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2478 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2479 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2480 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2481 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2482 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2483 191, 39, -1, 191, 229, -1, 191, 197, -1, 191,
2484 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2485 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2486 36, 191, 156, -1, 110, 155, 196, 244, 156, -1,
2487 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2488 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2489 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2490 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2491 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2492 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2493 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2494 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2495 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2496 201, 222, -1, 201, 224, -1, 201, 62, 61, 207,
2497 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2498 -1, 202, 224, -1, 202, 62, 61, 207, -1, -1,
2499 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2500 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2501 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2502 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2503 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2504 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2505 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2506 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2507 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2508 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2509 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2510 183, -1, 29, -1, 162, -1, -1, 181, 220, 217,
2511 218, -1, 30, -1, 163, -1, 232, 221, -1, -1,
2512 45, -1, 47, -1, -1, -1, 31, 225, 223, 226,
2513 217, -1, -1, 63, -1, 3, -1, 4, -1, 7,
2514 -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
2515 -1, 160, 198, 161, -1, 197, -1, 61, 227, 24,
2516 153, 24, -1, 167, -1, 212, -1, 229, -1, 228,
2517 -1, 191, 230, -1, 232, 233, -1, 219, 233, -1,
2518 234, 180, 236, -1, 234, 238, -1, -1, 23, -1,
2519 77, -1, 78, -1, 72, 231, -1, 72, 8, -1,
2520 73, 21, 230, -1, 73, 9, 230, 153, 21, 230,
2521 153, 21, 230, -1, 74, 178, 230, 153, 21, 230,
2522 157, 237, 159, -1, 74, 178, 230, 153, 21, 230,
2523 157, 159, -1, 75, 182, 189, 230, 155, 241, 156,
2524 36, 21, 230, 235, 21, 230, -1, 235, -1, 76,
2525 -1, 237, 178, 228, 153, 21, 230, -1, 178, 228,
2526 153, 21, 230, -1, 180, 243, -1, 191, 157, 230,
2527 153, 230, 159, -1, 239, 153, 157, 230, 153, 230,
2528 159, -1, 231, -1, 240, 153, 231, -1, 240, -1,
2529 -1, 60, 59, -1, 59, -1, 169, 191, 230, 153,
2530 230, -1, 170, 191, 230, 153, 230, -1, 171, 191,
2531 230, 153, 230, -1, 103, 172, 191, 230, 153, 230,
2532 -1, 104, 173, 191, 230, 153, 230, -1, 49, 231,
2533 -1, 174, 231, 153, 231, -1, 175, 231, 36, 191,
2534 -1, 112, 231, 153, 231, 153, 231, -1, 113, 231,
2535 153, 191, -1, 117, 231, 153, 191, -1, 118, 231,
2536 153, 191, -1, 114, 231, 153, 231, -1, 115, 231,
2537 153, 231, 153, 231, -1, 116, 231, 153, 231, 153,
2538 231, -1, 111, 239, -1, 242, 182, 189, 230, 155,
2539 241, 156, -1, 246, -1, 153, 240, -1, -1, 35,
2540 -1, -1, 105, 191, 184, -1, 105, 191, 153, 15,
2541 230, 184, -1, 106, 191, 184, -1, 106, 191, 153,
2542 15, 230, 184, -1, 107, 231, -1, 245, 108, 191,
2543 230, -1, 245, 109, 231, 153, 191, 230, -1, 110,
2547 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2548 static const yytype_uint16 yyrline[] =
2550 0, 1820, 1820, 1821, 1829, 1830, 1840, 1840, 1840, 1840,
2551 1840, 1840, 1840, 1840, 1840, 1840, 1840, 1844, 1844, 1844,
2552 1848, 1848, 1848, 1848, 1848, 1848, 1852, 1852, 1853, 1853,
2553 1854, 1854, 1855, 1855, 1856, 1856, 1860, 1860, 1861, 1861,
2554 1862, 1862, 1863, 1863, 1864, 1864, 1865, 1865, 1866, 1866,
2555 1867, 1868, 1871, 1871, 1871, 1871, 1875, 1875, 1875, 1875,
2556 1875, 1875, 1875, 1876, 1876, 1876, 1876, 1876, 1876, 1882,
2557 1882, 1882, 1882, 1886, 1886, 1886, 1886, 1890, 1890, 1894,
2558 1894, 1899, 1902, 1907, 1908, 1909, 1910, 1911, 1912, 1913,
2559 1914, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1935,
2560 1936, 1944, 1945, 1953, 1962, 1963, 1970, 1971, 1975, 1979,
2561 1995, 1996, 2003, 2004, 2011, 2019, 2019, 2019, 2019, 2019,
2562 2019, 2019, 2020, 2020, 2020, 2020, 2020, 2025, 2029, 2033,
2563 2038, 2047, 2074, 2080, 2093, 2104, 2108, 2121, 2125, 2139,
2564 2143, 2150, 2151, 2157, 2164, 2176, 2206, 2219, 2242, 2270,
2565 2292, 2303, 2325, 2336, 2345, 2350, 2409, 2416, 2424, 2431,
2566 2438, 2442, 2446, 2460, 2475, 2487, 2496, 2524, 2537, 2546,
2567 2552, 2558, 2569, 2575, 2581, 2592, 2593, 2602, 2603, 2615,
2568 2624, 2625, 2626, 2627, 2628, 2644, 2664, 2666, 2668, 2668,
2569 2675, 2675, 2683, 2683, 2691, 2691, 2700, 2702, 2704, 2709,
2570 2723, 2724, 2728, 2731, 2739, 2743, 2750, 2754, 2758, 2762,
2571 2770, 2770, 2774, 2775, 2779, 2787, 2792, 2800, 2801, 2808,
2572 2815, 2819, 3007, 3007, 3011, 3011, 3021, 3021, 3025, 3030,
2573 3031, 3032, 3036, 3037, 3036, 3049, 3050, 3055, 3056, 3057,
2574 3058, 3062, 3066, 3067, 3068, 3069, 3090, 3094, 3108, 3109,
2575 3114, 3114, 3122, 3132, 3135, 3144, 3155, 3160, 3169, 3180,
2576 3180, 3183, 3187, 3191, 3196, 3206, 3224, 3233, 3306, 3310,
2577 3317, 3329, 3344, 3374, 3384, 3394, 3398, 3405, 3406, 3410,
2578 3413, 3419, 3438, 3456, 3472, 3486, 3500, 3511, 3529, 3538,
2579 3547, 3554, 3575, 3599, 3605, 3611, 3617, 3633, 3725, 3733,
2580 3734, 3738, 3739, 3743, 3749, 3756, 3762, 3769, 3776, 3789,
2585 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2586 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2587 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2588 static const char *const yytname[] =
2590 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2591 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2592 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2593 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2594 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2595 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2596 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2597 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2598 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2599 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2600 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2601 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2602 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2603 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2604 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2605 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2606 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2607 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2608 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2609 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2610 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2611 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2612 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2613 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2614 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2615 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2616 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2617 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2618 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2619 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2620 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2621 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2622 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2623 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2624 "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7",
2625 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2626 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2627 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2628 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2629 "OptVolatile", "MemoryInst", 0
2634 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2636 static const yytype_uint16 yytoknum[] =
2638 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2639 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2640 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2641 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2642 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2643 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2644 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2645 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2646 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2647 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2648 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2649 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2650 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2651 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2652 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2653 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2654 60, 62, 123, 125, 42, 99
2658 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2659 static const yytype_uint8 yyr1[] =
2661 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2662 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2663 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2664 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2665 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2666 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2667 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2668 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2669 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2670 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2671 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2672 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2673 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2674 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2675 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2676 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2677 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2678 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2679 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2680 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2681 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2682 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2683 216, 217, 218, 218, 220, 219, 221, 221, 222, 223,
2684 223, 223, 225, 226, 224, 227, 227, 228, 228, 228,
2685 228, 228, 228, 228, 228, 228, 228, 228, 229, 229,
2686 230, 230, 231, 232, 232, 233, 234, 234, 234, 235,
2687 235, 236, 236, 236, 236, 236, 236, 236, 236, 236,
2688 237, 237, 238, 239, 239, 240, 240, 241, 241, 242,
2689 242, 243, 243, 243, 243, 243, 243, 243, 243, 243,
2690 243, 243, 243, 243, 243, 243, 243, 243, 243, 244,
2691 244, 245, 245, 246, 246, 246, 246, 246, 246, 246,
2695 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2696 static const yytype_uint8 yyr2[] =
2698 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2699 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2700 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2701 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2702 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2703 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2704 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2705 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2706 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2707 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2708 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2709 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2710 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2711 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2712 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2713 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2714 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2715 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2716 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2717 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2718 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2719 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2720 0, 8, 1, 1, 0, 4, 1, 1, 2, 0,
2721 1, 1, 0, 0, 5, 0, 1, 1, 1, 1,
2722 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
2723 1, 1, 2, 2, 2, 3, 2, 0, 1, 1,
2724 1, 2, 2, 3, 9, 9, 8, 13, 1, 1,
2725 6, 5, 2, 6, 7, 1, 3, 1, 0, 2,
2726 1, 5, 5, 5, 6, 6, 2, 4, 4, 6,
2727 4, 4, 4, 4, 6, 6, 2, 7, 1, 2,
2728 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
2732 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2733 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2734 means the default is an error. */
2735 static const yytype_uint16 yydefact[] =
2737 198, 0, 90, 184, 1, 183, 232, 83, 84, 85,
2738 86, 87, 88, 89, 0, 224, 257, 180, 181, 257,
2739 210, 211, 0, 0, 0, 90, 0, 186, 229, 0,
2740 91, 258, 254, 82, 226, 227, 228, 253, 0, 0,
2741 0, 0, 196, 0, 0, 0, 0, 0, 0, 0,
2742 81, 230, 231, 233, 199, 182, 0, 92, 93, 94,
2743 95, 96, 97, 0, 0, 302, 256, 0, 0, 0,
2744 0, 209, 197, 187, 2, 3, 111, 115, 116, 117,
2745 118, 119, 120, 121, 122, 123, 124, 125, 126, 128,
2746 0, 0, 0, 0, 248, 185, 0, 110, 127, 114,
2747 249, 129, 177, 178, 0, 0, 0, 0, 91, 98,
2748 0, 222, 223, 225, 301, 0, 280, 0, 0, 0,
2749 0, 91, 269, 259, 260, 6, 7, 8, 9, 10,
2750 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2751 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2752 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2753 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2754 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2755 0, 268, 255, 91, 272, 0, 298, 204, 201, 200,
2756 202, 203, 205, 208, 0, 130, 0, 0, 0, 113,
2757 135, 139, 0, 144, 138, 192, 194, 190, 115, 116,
2758 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2759 0, 0, 0, 188, 234, 0, 0, 286, 279, 262,
2760 261, 0, 0, 72, 76, 71, 75, 70, 74, 69,
2761 73, 77, 78, 0, 0, 26, 27, 28, 29, 30,
2762 31, 32, 33, 34, 35, 0, 50, 51, 46, 47,
2763 48, 49, 36, 37, 38, 39, 40, 41, 42, 43,
2764 44, 45, 0, 101, 101, 307, 0, 0, 296, 0,
2765 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2766 0, 0, 0, 0, 0, 206, 0, 0, 0, 0,
2767 0, 134, 143, 141, 0, 106, 106, 106, 160, 161,
2768 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2769 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2770 0, 0, 0, 0, 156, 155, 106, 220, 237, 238,
2771 239, 244, 240, 241, 242, 243, 235, 0, 246, 251,
2772 250, 252, 0, 263, 0, 0, 0, 0, 0, 303,
2773 0, 305, 300, 0, 0, 0, 0, 0, 0, 0,
2774 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2775 207, 112, 112, 137, 0, 140, 0, 131, 0, 193,
2776 195, 191, 0, 0, 0, 0, 0, 0, 0, 146,
2777 176, 0, 0, 0, 150, 0, 147, 0, 0, 0,
2778 0, 0, 189, 219, 213, 216, 217, 0, 236, 0,
2779 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2780 310, 0, 0, 0, 290, 293, 0, 0, 291, 292,
2781 0, 0, 0, 287, 288, 0, 308, 0, 132, 133,
2782 136, 142, 0, 0, 108, 106, 0, 0, 300, 0,
2783 0, 0, 0, 0, 145, 135, 114, 0, 148, 149,
2784 0, 0, 0, 0, 0, 212, 214, 0, 104, 0,
2785 245, 0, 0, 278, 0, 0, 101, 102, 101, 275,
2786 299, 0, 0, 0, 0, 0, 281, 282, 283, 278,
2787 0, 103, 109, 107, 0, 0, 0, 0, 0, 0,
2788 0, 175, 152, 0, 0, 0, 0, 0, 0, 218,
2789 215, 105, 99, 0, 0, 0, 277, 0, 284, 285,
2790 0, 304, 306, 0, 0, 0, 289, 294, 295, 0,
2791 309, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2792 0, 0, 0, 0, 0, 221, 247, 0, 0, 0,
2793 276, 273, 0, 297, 0, 0, 0, 172, 0, 0,
2794 166, 167, 168, 171, 163, 100, 0, 266, 0, 0,
2795 0, 274, 169, 170, 0, 0, 0, 264, 0, 265,
2796 0, 0, 165, 173, 174, 0, 0, 0, 0, 0,
2797 0, 271, 0, 0, 270, 267
2800 /* YYDEFGOTO[NTERM-NUM]. */
2801 static const yytype_int16 yydefgoto[] =
2803 -1, 94, 312, 329, 330, 331, 255, 272, 332, 333,
2804 219, 220, 243, 221, 25, 15, 63, 555, 359, 454,
2805 522, 389, 455, 95, 96, 222, 98, 99, 202, 304,
2806 400, 348, 401, 104, 1, 2, 3, 336, 307, 305,
2807 306, 55, 190, 42, 72, 194, 100, 476, 415, 416,
2808 417, 64, 113, 16, 30, 36, 17, 53, 18, 28,
2809 108, 419, 349, 101, 351, 489, 19, 32, 33, 181,
2810 182, 579, 66, 278, 526, 527, 183, 184, 430, 185,
2814 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2816 #define YYPACT_NINF -542
2817 static const yytype_int16 yypact[] =
2819 -542, 13, 162, 567, -542, -542, -542, -542, -542, -542,
2820 -542, -542, -542, -542, 83, -542, 19, -542, -542, -14,
2821 -542, -542, 50, -87, 87, 233, 27, -542, 123, 141,
2822 175, -542, -542, 98, -542, -542, -542, -542, 33, 40,
2823 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156,
2824 -542, -542, -542, -542, -542, -542, 221, -542, -542, -542,
2825 -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226,
2826 227, 235, -542, -542, -542, -542, 81, -542, -542, -542,
2827 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2828 256, 257, 4, 15, -542, -542, 108, -542, -542, 12,
2829 -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542,
2830 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116,
2831 479, 175, -542, -542, -542, -542, -542, -542, -542, -542,
2832 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2833 -542, -542, -542, -542, -542, -542, -542, -542, -542, 355,
2834 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306,
2835 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542,
2836 -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306,
2837 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542,
2838 -542, -542, -542, -542, -13, -542, 110, 111, 75, -542,
2839 -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208,
2840 266, 210, 267, 212, 268, 230, 277, 275, 278, 246,
2841 280, 279, 566, -542, -542, 136, 766, -542, -542, 81,
2842 -542, 766, 766, -542, -542, -542, -542, -542, -542, -542,
2843 -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542,
2844 -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542,
2845 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2846 -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147,
2847 148, 149, 151, 152, 158, 160, 766, 766, 766, 161,
2848 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27,
2849 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542,
2850 -542, -542, -542, -542, -542, -542, -542, -542, 355, 429,
2851 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184,
2852 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542,
2853 -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542,
2854 -542, -542, 193, -542, 194, 766, 766, 766, 7, -542,
2855 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306,
2856 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207,
2857 -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542,
2858 -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542,
2859 -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326,
2860 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337,
2861 -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306,
2862 -542, 223, 766, 224, -542, -542, 225, 234, -542, -542,
2863 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542,
2864 -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236,
2865 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542,
2866 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252,
2867 -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542,
2868 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306,
2869 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326,
2870 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542,
2871 -542, -542, 368, 402, 274, 276, 259, 287, -542, -542,
2872 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290,
2873 -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296,
2874 297, 299, 302, 303, 430, -542, -542, 414, 41, 425,
2875 -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326,
2876 -542, -542, -542, -542, -542, -542, 766, -542, 893, 144,
2877 448, -542, -542, -542, 314, 315, 316, -542, 331, -542,
2878 893, 766, -542, -542, -542, 464, 334, 180, 766, 481,
2879 482, -542, 766, 766, -542, -542
2882 /* YYPGOTO[NTERM-NUM]. */
2883 static const yytype_int16 yypgoto[] =
2885 -542, -542, -542, 435, 439, 441, 191, 197, 442, 445,
2886 -119, -116, -541, -542, 478, 489, -107, -542, -267, 37,
2887 -542, -238, -542, -60, -542, -45, -542, -74, -51, -542,
2888 -101, 300, -252, 134, -542, -542, -542, -542, -542, -542,
2889 -542, 473, -542, -542, -542, -542, 8, -542, 46, -542,
2890 -542, 410, -542, -542, -542, -542, -542, -542, 518, -542,
2891 -542, -542, -528, 142, -90, -113, -542, 505, -542, -72,
2892 -542, -542, -542, -542, 97, 28, -542, -542, 70, -542,
2896 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2897 positive, shift that token. If negative, reduce the rule which
2898 number is the opposite. If zero, do what YYDEFACT says.
2899 If YYTABLE_NINF, syntax error. */
2900 #define YYTABLE_NINF -180
2901 static const yytype_int16 yytable[] =
2903 97, 241, 227, 110, 242, 230, 223, 361, 197, 31,
2904 111, 26, 449, 4, 244, 204, 34, 578, 97, 201,
2905 74, 75, 426, 199, 77, 78, 79, 80, 81, 82,
2906 83, 84, 85, 86, 87, 428, 88, 20, 590, 21,
2907 275, 26, 31, 279, 280, 281, 282, 283, 284, 285,
2908 588, 233, 234, 235, 236, 237, 238, 239, 240, 205,
2909 206, 207, 596, 89, 427, 43, 289, 290, 390, 391,
2910 226, 463, 300, 226, 403, 405, 291, 427, 452, 468,
2911 74, 75, 301, 199, 77, 78, 79, 80, 81, 82,
2912 83, 84, 85, 86, 87, 420, 88, 20, 412, 21,
2913 448, 453, 38, 39, 40, 204, 273, 274, 226, 276,
2914 277, 226, 226, 226, 226, 226, 226, 226, 225, 463,
2915 20, 41, 21, 89, 201, 231, 300, 480, -139, 201,
2916 -112, 286, 287, 288, 226, 226, 384, 232, -139, 204,
2917 294, 352, 353, 112, 29, 463, 295, 299, 44, 35,
2918 467, 464, 303, 354, 233, 234, 235, 236, 237, 238,
2919 239, 240, -179, 463, 463, 54, 198, -112, 51, 90,
2920 52, 71, 91, 469, 513, 92, 204, 93, 200, 50,
2921 379, 105, 106, 107, 355, 67, 362, 5, 102, 103,
2922 188, 189, 68, 6, 292, 293, 372, 373, 374, 97,
2923 577, 308, 309, 7, 8, 9, 10, 11, 12, 13,
2924 356, -72, -72, -71, -71, -70, -70, 503, 69, 531,
2925 70, 532, 381, 382, 14, 109, 385, 357, 187, 90,
2926 191, 377, 91, -69, -69, 92, -113, 93, 298, 56,
2927 57, 58, 59, 60, 61, 62, 97, 378, 226, 310,
2928 311, 192, 433, 45, 435, 436, 437, 123, 124, 193,
2929 195, 196, 443, 203, 228, 423, 424, 425, 296, 297,
2930 -76, -75, -74, 431, 7, 8, 9, 10, 46, 12,
2931 47, -73, -79, 48, 313, -80, 314, 445, 446, 363,
2932 358, 337, 414, 458, 459, 460, 461, 462, 360, 364,
2933 365, 366, 367, 589, 368, 369, 470, 471, 472, 473,
2934 474, 370, 385, 371, 375, 380, 383, 376, 386, 387,
2935 226, 434, 226, 226, 226, 438, 439, 394, 466, 388,
2936 226, 444, 395, 396, 397, 406, 486, 398, 488, 407,
2937 408, 409, 492, 410, 411, 418, 421, 422, 429, 432,
2938 496, 497, 498, 440, 441, 504, 505, 450, 456, 442,
2939 447, 479, 511, 481, 335, 478, 457, 477, 350, 482,
2940 483, 484, 485, 350, 350, 487, 491, 493, 494, 502,
2941 536, 537, 538, 499, 226, 350, 501, 495, 518, 507,
2942 508, 524, 525, 509, 528, 529, 510, 514, 515, 512,
2943 516, 534, 500, 517, 452, 523, 544, 545, 546, 547,
2944 540, 530, 533, 549, 550, 551, 552, 535, 350, 543,
2945 560, 548, 475, 541, 542, 554, 556, 557, 350, 350,
2946 350, 427, 414, 558, 575, 576, 566, 568, 226, 241,
2947 564, 565, 242, 559, 561, 562, 563, 569, 226, 226,
2948 226, 567, 570, 571, 226, 572, 256, 257, 573, 574,
2949 241, 580, 582, 242, 581, 584, 583, 585, 586, 591,
2950 592, 593, 594, 553, 245, 246, 247, 248, 249, 250,
2951 251, 252, 253, 254, 595, 598, 587, 599, 226, 233,
2952 234, 235, 236, 237, 238, 239, 240, 350, 350, 350,
2953 176, 597, 602, 603, 177, 350, 178, 179, 601, 392,
2954 180, 65, 604, 605, 49, 521, 393, 73, 224, 350,
2955 350, 27, 334, 520, 37, 600, 490, 539, 506, 0,
2956 0, 0, 0, 0, 74, 75, 0, 199, 208, 209,
2957 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2958 88, 20, 0, 21, 258, 259, 260, 261, 262, 263,
2959 264, 265, 266, 267, 268, 269, 270, 271, 350, 0,
2960 350, 74, 75, 0, 350, 0, 0, 89, 0, 0,
2961 0, 0, 350, 350, 350, 0, 0, -82, 20, 20,
2962 21, 21, 315, 0, 0, 0, 0, 0, 6, -82,
2963 -82, 0, 0, 0, 316, 317, 0, 0, -82, -82,
2964 -82, -82, -82, -82, -82, 0, 0, -82, 22, 0,
2965 0, 0, 0, 350, 350, 23, 350, 350, 0, 24,
2966 0, 0, 0, 350, 0, 0, 0, 0, 0, 0,
2967 0, 0, 350, 0, 0, 125, 126, 127, 128, 129,
2968 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2969 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
2970 319, 0, 0, 0, 0, 0, 320, 350, 321, 0,
2971 322, 323, 324, 90, 0, 0, 91, 0, 0, 92,
2972 0, 93, 404, 0, 0, 0, 0, 0, 0, 0,
2973 0, 0, 0, 0, 0, 163, 164, 165, 166, 167,
2974 168, 169, 170, 171, 172, 173, 174, 175, 350, 0,
2975 0, 0, 0, 325, 0, 0, 326, 0, 327, 0,
2976 0, 328, 0, 350, 0, 0, 0, 0, 0, 0,
2977 350, 0, 0, 0, 350, 350, 74, 75, 0, 199,
2978 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
2979 218, 0, 88, 20, 0, 21, 0, 0, 0, 338,
2980 339, 74, 75, 340, 0, 0, 0, 0, 0, 0,
2981 0, 0, 0, 0, 0, 0, 0, 0, 20, 89,
2982 21, 0, 341, 342, 343, 0, 0, 0, 0, 0,
2983 0, 0, 0, 0, 344, 345, 0, 0, 0, 0,
2984 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2985 0, 0, 0, 0, 0, 0, 0, 346, 0, 0,
2986 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2987 0, 0, 0, 0, 0, 125, 126, 127, 128, 129,
2988 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2989 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
2990 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
2991 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
2992 0, 0, 0, 0, 0, 90, 338, 339, 91, 0,
2993 340, 92, 0, 93, 465, 163, 164, 165, 166, 167,
2994 168, 169, 170, 171, 172, 173, 174, 175, 0, 341,
2995 342, 343, 0, 0, 0, 0, 347, 0, 0, 0,
2996 0, 344, 345, 0, 0, 0, 0, 0, 0, 0,
2997 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2998 0, 0, 0, 0, 346, 0, 0, 0, 0, 0,
2999 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3000 0, 0, 125, 126, 127, 128, 129, 130, 131, 132,
3001 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
3002 143, 144, 145, 146, 147, 148, 318, 319, 0, 0,
3003 0, 0, 0, 320, 0, 321, 0, 322, 323, 324,
3004 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3005 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3006 0, 0, 163, 164, 165, 166, 167, 168, 169, 170,
3007 171, 172, 173, 174, 175, 0, 0, 0, 0, 0,
3008 0, 74, 75, 347, 199, 77, 78, 79, 80, 81,
3009 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
3010 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3011 0, 0, 0, 302, 0, 0, 0, 0, 0, 0,
3012 0, 0, 74, 75, 89, 199, 208, 209, 210, 211,
3013 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3014 0, 21, 74, 75, 0, 199, 77, 78, 79, 80,
3015 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3016 0, 21, 0, 0, 0, 89, 0, 0, 0, 0,
3017 0, 0, 0, 0, 413, 0, 0, 0, 0, 0,
3018 0, 0, 0, 74, 75, 89, 199, 77, 78, 79,
3019 80, 81, 82, 83, 84, 85, 86, 87, 0, 88,
3020 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
3021 0, 0, 0, 0, 0, 451, 0, 0, 0, 0,
3022 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
3023 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
3024 74, 75, 0, 199, 77, 78, 79, 80, 81, 82,
3025 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
3026 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3027 0, 90, 519, 0, 91, 0, 399, 92, 0, 93,
3028 0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
3029 0, 90, 0, 0, 91, 0, 0, 92, 0, 93,
3030 74, 75, 0, 76, 77, 78, 79, 80, 81, 82,
3031 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
3032 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3033 0, 0, 90, 0, 0, 91, 0, 0, 92, 0,
3034 93, 74, 75, 89, 199, 77, 78, 79, 80, 81,
3035 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
3036 21, 74, 75, 0, 199, 208, 209, 210, 211, 212,
3037 213, 214, 215, 216, 217, 218, 0, 88, 20, 0,
3038 21, 0, 0, 0, 89, 0, 0, 0, 0, 90,
3039 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3040 0, 0, 74, 75, 89, 229, 77, 78, 79, 80,
3041 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3042 0, 21, 74, 75, 0, 199, 208, 209, 210, 211,
3043 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3044 0, 21, 0, 0, 0, 89, 0, 0, 0, 90,
3045 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3046 0, 0, 0, 0, 0, 89, 0, 0, 0, 0,
3047 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3048 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3049 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
3050 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3051 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
3052 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3053 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3054 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
3055 0, 90, 0, 0, 91, 0, 0, 92, 115, 93,
3056 0, 0, 0, 0, 0, 0, 0, 0, 116, 117,
3057 0, 90, 0, 0, 91, 0, 0, 92, 0, 402,
3058 0, 118, 119, 120, 121, 122, 123, 124, 125, 126,
3059 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3060 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
3061 147, 148, 149, 150, 151, 152, 153, 0, 0, 154,
3062 155, 156, 157, 158, 159, 160, 161, 162, 0, 0,
3063 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3064 0, 0, 0, 0, 0, 0, 0, 0, 163, 164,
3065 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
3069 static const yytype_int16 yycheck[] =
3071 45, 120, 115, 63, 120, 118, 107, 274, 4, 23,
3072 29, 3, 161, 0, 121, 164, 30, 558, 63, 93,
3073 5, 6, 15, 8, 9, 10, 11, 12, 13, 14,
3074 15, 16, 17, 18, 19, 15, 21, 22, 579, 24,
3075 153, 33, 23, 156, 157, 158, 159, 160, 161, 162,
3076 578, 10, 11, 12, 13, 14, 15, 16, 17, 104,
3077 105, 106, 590, 48, 57, 152, 179, 180, 306, 307,
3078 115, 153, 153, 118, 326, 327, 183, 57, 34, 161,
3079 5, 6, 163, 8, 9, 10, 11, 12, 13, 14,
3080 15, 16, 17, 18, 19, 347, 21, 22, 336, 24,
3081 159, 57, 52, 53, 54, 164, 151, 152, 153, 154,
3082 155, 156, 157, 158, 159, 160, 161, 162, 110, 153,
3083 22, 71, 24, 48, 198, 9, 153, 161, 153, 203,
3084 155, 176, 177, 178, 179, 180, 163, 21, 163, 164,
3085 153, 231, 232, 162, 61, 153, 159, 198, 61, 163,
3086 402, 159, 203, 243, 10, 11, 12, 13, 14, 15,
3087 16, 17, 0, 153, 153, 24, 162, 155, 45, 154,
3088 47, 157, 157, 163, 163, 160, 164, 162, 163, 152,
3089 293, 47, 48, 49, 244, 152, 276, 25, 32, 33,
3090 55, 56, 152, 31, 108, 109, 286, 287, 288, 244,
3091 159, 27, 28, 41, 42, 43, 44, 45, 46, 47,
3092 255, 3, 4, 3, 4, 3, 4, 455, 152, 486,
3093 152, 488, 296, 297, 62, 4, 300, 272, 24, 154,
3094 4, 291, 157, 3, 4, 160, 155, 162, 163, 64,
3095 65, 66, 67, 68, 69, 70, 291, 292, 293, 3,
3096 4, 24, 365, 20, 367, 368, 369, 77, 78, 24,
3097 4, 4, 375, 155, 59, 355, 356, 357, 158, 158,
3098 4, 4, 4, 363, 41, 42, 43, 44, 45, 46,
3099 47, 4, 7, 50, 4, 7, 7, 377, 378, 157,
3100 153, 155, 337, 394, 395, 396, 397, 398, 153, 153,
3101 153, 153, 153, 159, 153, 153, 407, 408, 409, 410,
3102 411, 153, 386, 153, 153, 24, 161, 36, 153, 156,
3103 365, 366, 367, 368, 369, 370, 371, 155, 402, 153,
3104 375, 376, 155, 155, 155, 24, 426, 155, 428, 155,
3105 155, 155, 432, 155, 155, 63, 153, 153, 153, 157,
3106 440, 441, 442, 153, 153, 456, 457, 161, 155, 153,
3107 153, 24, 463, 21, 222, 156, 155, 153, 226, 21,
3108 155, 153, 153, 231, 232, 4, 153, 153, 153, 4,
3109 493, 494, 495, 155, 429, 243, 24, 153, 36, 153,
3110 153, 481, 482, 153, 484, 485, 153, 153, 153, 161,
3111 153, 491, 447, 153, 34, 153, 507, 508, 509, 510,
3112 500, 153, 153, 514, 515, 516, 517, 153, 276, 156,
3113 533, 161, 414, 153, 153, 57, 24, 153, 286, 287,
3114 288, 57, 477, 157, 4, 21, 153, 153, 483, 558,
3115 541, 542, 558, 156, 159, 535, 156, 153, 493, 494,
3116 495, 156, 156, 156, 499, 156, 27, 28, 156, 156,
3117 579, 36, 156, 579, 159, 566, 156, 568, 569, 21,
3118 156, 156, 156, 518, 119, 120, 121, 122, 123, 124,
3119 125, 126, 127, 128, 153, 21, 576, 153, 533, 10,
3120 11, 12, 13, 14, 15, 16, 17, 355, 356, 357,
3121 65, 591, 21, 21, 65, 363, 65, 65, 598, 318,
3122 65, 33, 602, 603, 25, 478, 319, 44, 108, 377,
3123 378, 3, 222, 477, 19, 597, 429, 499, 458, -1,
3124 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
3125 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3126 21, 22, -1, 24, 125, 126, 127, 128, 129, 130,
3127 131, 132, 133, 134, 135, 136, 137, 138, 426, -1,
3128 428, 5, 6, -1, 432, -1, -1, 48, -1, -1,
3129 -1, -1, 440, 441, 442, -1, -1, 20, 22, 22,
3130 24, 24, 26, -1, -1, -1, -1, -1, 31, 32,
3131 33, -1, -1, -1, 38, 39, -1, -1, 41, 42,
3132 43, 44, 45, 46, 47, -1, -1, 50, 51, -1,
3133 -1, -1, -1, 481, 482, 58, 484, 485, -1, 62,
3134 -1, -1, -1, 491, -1, -1, -1, -1, -1, -1,
3135 -1, -1, 500, -1, -1, 79, 80, 81, 82, 83,
3136 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3137 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3138 104, -1, -1, -1, -1, -1, 110, 535, 112, -1,
3139 114, 115, 116, 154, -1, -1, 157, -1, -1, 160,
3140 -1, 162, 163, -1, -1, -1, -1, -1, -1, -1,
3141 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
3142 144, 145, 146, 147, 148, 149, 150, 151, 576, -1,
3143 -1, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3144 -1, 165, -1, 591, -1, -1, -1, -1, -1, -1,
3145 598, -1, -1, -1, 602, 603, 5, 6, -1, 8,
3146 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
3147 19, -1, 21, 22, -1, 24, -1, -1, -1, 3,
3148 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
3149 -1, -1, -1, -1, -1, -1, -1, -1, 22, 48,
3150 24, -1, 26, 27, 28, -1, -1, -1, -1, -1,
3151 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
3152 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3153 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
3154 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3155 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
3156 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3157 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3158 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
3159 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
3160 -1, -1, -1, -1, -1, 154, 3, 4, 157, -1,
3161 7, 160, -1, 162, 163, 139, 140, 141, 142, 143,
3162 144, 145, 146, 147, 148, 149, 150, 151, -1, 26,
3163 27, 28, -1, -1, -1, -1, 160, -1, -1, -1,
3164 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
3165 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3166 -1, -1, -1, -1, 61, -1, -1, -1, -1, -1,
3167 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3168 -1, -1, 79, 80, 81, 82, 83, 84, 85, 86,
3169 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
3170 97, 98, 99, 100, 101, 102, 103, 104, -1, -1,
3171 -1, -1, -1, 110, -1, 112, -1, 114, 115, 116,
3172 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3173 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3174 -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
3175 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
3176 -1, 5, 6, 160, 8, 9, 10, 11, 12, 13,
3177 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3178 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3179 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
3180 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
3181 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3182 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3183 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3184 -1, 24, -1, -1, -1, 48, -1, -1, -1, -1,
3185 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
3186 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
3187 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
3188 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
3189 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
3190 -1, -1, -1, -1, -1, -1, 48, -1, -1, -1,
3191 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3192 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3193 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
3194 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3195 -1, 154, 37, -1, 157, -1, 159, 160, -1, 162,
3196 -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
3197 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3198 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3199 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
3200 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3201 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
3202 162, 5, 6, 48, 8, 9, 10, 11, 12, 13,
3203 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3204 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
3205 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3206 24, -1, -1, -1, 48, -1, -1, -1, -1, 154,
3207 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3208 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
3209 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3210 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3211 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3212 -1, 24, -1, -1, -1, 48, -1, -1, -1, 154,
3213 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3214 -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
3215 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3216 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3217 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3218 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3219 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3220 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3221 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3222 -1, -1, -1, -1, 35, -1, -1, -1, -1, -1,
3223 -1, 154, -1, -1, 157, -1, -1, 160, 49, 162,
3224 -1, -1, -1, -1, -1, -1, -1, -1, 59, 60,
3225 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3226 -1, 72, 73, 74, 75, 76, 77, 78, 79, 80,
3227 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
3228 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
3229 101, 102, 103, 104, 105, 106, 107, -1, -1, 110,
3230 111, 112, 113, 114, 115, 116, 117, 118, -1, -1,
3231 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3232 -1, -1, -1, -1, -1, -1, -1, -1, 139, 140,
3233 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
3237 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
3238 symbol of state STATE-NUM. */
3239 static const yytype_uint8 yystos[] =
3241 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
3242 44, 45, 46, 47, 62, 181, 219, 222, 224, 232,
3243 22, 24, 51, 58, 62, 180, 212, 224, 225, 61,
3244 220, 23, 233, 234, 30, 163, 221, 233, 52, 53,
3245 54, 71, 209, 152, 61, 20, 45, 47, 50, 181,
3246 152, 45, 47, 223, 24, 207, 64, 65, 66, 67,
3247 68, 69, 70, 182, 217, 180, 238, 152, 152, 152,
3248 152, 157, 210, 207, 5, 6, 8, 9, 10, 11,
3249 12, 13, 14, 15, 16, 17, 18, 19, 21, 48,
3250 154, 157, 160, 162, 167, 189, 190, 191, 192, 193,
3251 212, 229, 32, 33, 199, 199, 199, 199, 226, 4,
3252 189, 29, 162, 218, 35, 49, 59, 60, 72, 73,
3253 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
3254 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3255 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3256 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
3257 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
3258 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
3259 175, 235, 236, 242, 243, 245, 246, 24, 55, 56,
3260 208, 4, 24, 24, 211, 4, 4, 4, 162, 8,
3261 163, 193, 194, 155, 164, 191, 191, 191, 9, 10,
3262 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
3263 177, 179, 191, 196, 217, 212, 191, 231, 59, 8,
3264 231, 9, 21, 10, 11, 12, 13, 14, 15, 16,
3265 17, 176, 177, 178, 182, 119, 120, 121, 122, 123,
3266 124, 125, 126, 127, 128, 172, 27, 28, 125, 126,
3267 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3268 137, 138, 173, 191, 191, 231, 191, 191, 239, 231,
3269 231, 231, 231, 231, 231, 231, 191, 191, 191, 231,
3270 231, 182, 108, 109, 153, 159, 158, 158, 163, 194,
3271 153, 163, 37, 194, 195, 205, 206, 204, 27, 28,
3272 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
3273 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
3274 170, 171, 174, 175, 197, 229, 203, 155, 3, 4,
3275 7, 26, 27, 28, 38, 39, 61, 160, 197, 228,
3276 229, 230, 230, 230, 230, 189, 191, 191, 153, 184,
3277 153, 184, 230, 157, 153, 153, 153, 153, 153, 153,
3278 153, 153, 230, 230, 230, 153, 36, 189, 191, 231,
3279 24, 193, 193, 161, 163, 193, 153, 156, 153, 187,
3280 187, 187, 172, 173, 155, 155, 155, 155, 155, 159,
3281 196, 198, 162, 198, 163, 198, 24, 155, 155, 155,
3282 155, 155, 187, 37, 191, 214, 215, 216, 63, 227,
3283 198, 153, 153, 230, 230, 230, 15, 57, 15, 153,
3284 244, 230, 157, 231, 191, 231, 231, 231, 191, 191,
3285 153, 153, 153, 231, 191, 230, 230, 153, 159, 161,
3286 161, 37, 34, 57, 185, 188, 155, 155, 196, 196,
3287 196, 196, 196, 153, 159, 163, 193, 198, 161, 163,
3288 196, 196, 196, 196, 196, 212, 213, 153, 156, 24,
3289 161, 21, 21, 155, 153, 153, 230, 4, 230, 231,
3290 240, 153, 230, 153, 153, 153, 230, 230, 230, 155,
3291 191, 24, 4, 187, 196, 196, 244, 153, 153, 153,
3292 153, 196, 161, 163, 153, 153, 153, 153, 36, 37,
3293 214, 185, 186, 153, 230, 230, 240, 241, 230, 230,
3294 153, 184, 184, 153, 230, 153, 231, 231, 231, 241,
3295 230, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3296 196, 196, 196, 191, 57, 183, 24, 153, 157, 156,
3297 231, 159, 230, 156, 196, 196, 153, 156, 153, 153,
3298 156, 156, 156, 156, 156, 4, 21, 159, 178, 237,
3299 36, 159, 156, 156, 196, 196, 196, 230, 228, 159,
3300 178, 21, 156, 156, 156, 153, 228, 230, 21, 153,
3301 235, 230, 21, 21, 230, 230
3304 #define yyerrok (yyerrstatus = 0)
3305 #define yyclearin (yychar = YYEMPTY)
3306 #define YYEMPTY (-2)
3309 #define YYACCEPT goto yyacceptlab
3310 #define YYABORT goto yyabortlab
3311 #define YYERROR goto yyerrorlab
3314 /* Like YYERROR except do call yyerror. This remains here temporarily
3315 to ease the transition to the new meaning of YYERROR, for GCC.
3316 Once GCC version 2 has supplanted version 1, this can go. */
3318 #define YYFAIL goto yyerrlab
3320 #define YYRECOVERING() (!!yyerrstatus)
3322 #define YYBACKUP(Token, Value) \
3324 if (yychar == YYEMPTY && yylen == 1) \
3328 yytoken = YYTRANSLATE (yychar); \
3334 yyerror (YY_("syntax error: cannot back up")); \
3341 #define YYERRCODE 256
3344 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3345 If N is 0, then set CURRENT to the empty location which ends
3346 the previous symbol: RHS[0] (always defined). */
3348 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
3349 #ifndef YYLLOC_DEFAULT
3350 # define YYLLOC_DEFAULT(Current, Rhs, N) \
3354 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3355 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3356 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3357 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3361 (Current).first_line = (Current).last_line = \
3362 YYRHSLOC (Rhs, 0).last_line; \
3363 (Current).first_column = (Current).last_column = \
3364 YYRHSLOC (Rhs, 0).last_column; \
3370 /* YY_LOCATION_PRINT -- Print the location on the stream.
3371 This macro was not mandated originally: define only if we know
3372 we won't break user code: when these are the locations we know. */
3374 #ifndef YY_LOCATION_PRINT
3375 # if YYLTYPE_IS_TRIVIAL
3376 # define YY_LOCATION_PRINT(File, Loc) \
3377 fprintf (File, "%d.%d-%d.%d", \
3378 (Loc).first_line, (Loc).first_column, \
3379 (Loc).last_line, (Loc).last_column)
3381 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3386 /* YYLEX -- calling `yylex' with the right arguments. */
3389 # define YYLEX yylex (YYLEX_PARAM)
3391 # define YYLEX yylex ()
3394 /* Enable debugging if requested. */
3398 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3399 # define YYFPRINTF fprintf
3402 # define YYDPRINTF(Args) \
3408 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3412 YYFPRINTF (stderr, "%s ", Title); \
3413 yy_symbol_print (stderr, \
3415 YYFPRINTF (stderr, "\n"); \
3420 /*--------------------------------.
3421 | Print this symbol on YYOUTPUT. |
3422 `--------------------------------*/
3425 #if (defined __STDC__ || defined __C99__FUNC__ \
3426 || defined __cplusplus || defined _MSC_VER)
3428 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3431 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
3434 YYSTYPE const * const yyvaluep;
3440 if (yytype < YYNTOKENS)
3441 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3453 /*--------------------------------.
3454 | Print this symbol on YYOUTPUT. |
3455 `--------------------------------*/
3457 #if (defined __STDC__ || defined __C99__FUNC__ \
3458 || defined __cplusplus || defined _MSC_VER)
3460 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3463 yy_symbol_print (yyoutput, yytype, yyvaluep)
3466 YYSTYPE const * const yyvaluep;
3469 if (yytype < YYNTOKENS)
3470 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3472 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3474 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3475 YYFPRINTF (yyoutput, ")");
3478 /*------------------------------------------------------------------.
3479 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
3481 `------------------------------------------------------------------*/
3483 #if (defined __STDC__ || defined __C99__FUNC__ \
3484 || defined __cplusplus || defined _MSC_VER)
3486 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3489 yy_stack_print (bottom, top)
3490 yytype_int16 *bottom;
3494 YYFPRINTF (stderr, "Stack now");
3495 for (; bottom <= top; ++bottom)
3496 YYFPRINTF (stderr, " %d", *bottom);
3497 YYFPRINTF (stderr, "\n");
3500 # define YY_STACK_PRINT(Bottom, Top) \
3503 yy_stack_print ((Bottom), (Top)); \
3507 /*------------------------------------------------.
3508 | Report that the YYRULE is going to be reduced. |
3509 `------------------------------------------------*/
3511 #if (defined __STDC__ || defined __C99__FUNC__ \
3512 || defined __cplusplus || defined _MSC_VER)
3514 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3517 yy_reduce_print (yyvsp, yyrule)
3522 int yynrhs = yyr2[yyrule];
3524 unsigned long int yylno = yyrline[yyrule];
3525 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3527 /* The symbols being reduced. */
3528 for (yyi = 0; yyi < yynrhs; yyi++)
3530 fprintf (stderr, " $%d = ", yyi + 1);
3531 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3532 &(yyvsp[(yyi + 1) - (yynrhs)])
3534 fprintf (stderr, "\n");
3538 # define YY_REDUCE_PRINT(Rule) \
3541 yy_reduce_print (yyvsp, Rule); \
3544 /* Nonzero means print parse trace. It is left uninitialized so that
3545 multiple parsers can coexist. */
3547 #else /* !YYDEBUG */
3548 # define YYDPRINTF(Args)
3549 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3550 # define YY_STACK_PRINT(Bottom, Top)
3551 # define YY_REDUCE_PRINT(Rule)
3552 #endif /* !YYDEBUG */
3555 /* YYINITDEPTH -- initial size of the parser's stacks. */
3557 # define YYINITDEPTH 200
3560 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3561 if the built-in stack extension method is used).
3563 Do not make this value too large; the results are undefined if
3564 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3565 evaluated with infinite-precision integer arithmetic. */
3568 # define YYMAXDEPTH 10000
3576 # if defined __GLIBC__ && defined _STRING_H
3577 # define yystrlen strlen
3579 /* Return the length of YYSTR. */
3580 #if (defined __STDC__ || defined __C99__FUNC__ \
3581 || defined __cplusplus || defined _MSC_VER)
3583 yystrlen (const char *yystr)
3591 for (yylen = 0; yystr[yylen]; yylen++)
3599 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3600 # define yystpcpy stpcpy
3602 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3604 #if (defined __STDC__ || defined __C99__FUNC__ \
3605 || defined __cplusplus || defined _MSC_VER)
3607 yystpcpy (char *yydest, const char *yysrc)
3610 yystpcpy (yydest, yysrc)
3616 const char *yys = yysrc;
3618 while ((*yyd++ = *yys++) != '\0')
3627 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3628 quotes and backslashes, so that it's suitable for yyerror. The
3629 heuristic is that double-quoting is unnecessary unless the string
3630 contains an apostrophe, a comma, or backslash (other than
3631 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3632 null, do not copy; instead, return the length of what the result
3635 yytnamerr (char *yyres, const char *yystr)
3640 char const *yyp = yystr;
3647 goto do_not_strip_quotes;
3651 goto do_not_strip_quotes;
3664 do_not_strip_quotes: ;
3668 return yystrlen (yystr);
3670 return yystpcpy (yyres, yystr) - yyres;
3674 /* Copy into YYRESULT an error message about the unexpected token
3675 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3676 including the terminating null byte. If YYRESULT is null, do not
3677 copy anything; just return the number of bytes that would be
3678 copied. As a special case, return 0 if an ordinary "syntax error"
3679 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3680 size calculation. */
3682 yysyntax_error (char *yyresult, int yystate, int yychar)
3684 int yyn = yypact[yystate];
3686 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3690 int yytype = YYTRANSLATE (yychar);
3691 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3692 YYSIZE_T yysize = yysize0;
3694 int yysize_overflow = 0;
3695 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3696 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3700 /* This is so xgettext sees the translatable formats that are
3701 constructed on the fly. */
3702 YY_("syntax error, unexpected %s");
3703 YY_("syntax error, unexpected %s, expecting %s");
3704 YY_("syntax error, unexpected %s, expecting %s or %s");
3705 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3706 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3710 static char const yyunexpected[] = "syntax error, unexpected %s";
3711 static char const yyexpecting[] = ", expecting %s";
3712 static char const yyor[] = " or %s";
3713 char yyformat[sizeof yyunexpected
3714 + sizeof yyexpecting - 1
3715 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3716 * (sizeof yyor - 1))];
3717 char const *yyprefix = yyexpecting;
3719 /* Start YYX at -YYN if negative to avoid negative indexes in
3721 int yyxbegin = yyn < 0 ? -yyn : 0;
3723 /* Stay within bounds of both yycheck and yytname. */
3724 int yychecklim = YYLAST - yyn + 1;
3725 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3728 yyarg[0] = yytname[yytype];
3729 yyfmt = yystpcpy (yyformat, yyunexpected);
3731 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3732 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3734 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3738 yyformat[sizeof yyunexpected - 1] = '\0';
3741 yyarg[yycount++] = yytname[yyx];
3742 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3743 yysize_overflow |= (yysize1 < yysize);
3745 yyfmt = yystpcpy (yyfmt, yyprefix);
3749 yyf = YY_(yyformat);
3750 yysize1 = yysize + yystrlen (yyf);
3751 yysize_overflow |= (yysize1 < yysize);
3754 if (yysize_overflow)
3755 return YYSIZE_MAXIMUM;
3759 /* Avoid sprintf, as that infringes on the user's name space.
3760 Don't have undefined behavior even if the translation
3761 produced a string with the wrong number of "%s"s. */
3762 char *yyp = yyresult;
3764 while ((*yyp = *yyf) != '\0')
3766 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3768 yyp += yytnamerr (yyp, yyarg[yyi++]);
3781 #endif /* YYERROR_VERBOSE */
3784 /*-----------------------------------------------.
3785 | Release the memory associated to this symbol. |
3786 `-----------------------------------------------*/
3789 #if (defined __STDC__ || defined __C99__FUNC__ \
3790 || defined __cplusplus || defined _MSC_VER)
3792 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3795 yydestruct (yymsg, yytype, yyvaluep)
3805 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3816 /* Prevent warnings from -Wmissing-prototypes. */
3818 #ifdef YYPARSE_PARAM
3819 #if defined __STDC__ || defined __cplusplus
3820 int yyparse (void *YYPARSE_PARAM);
3824 #else /* ! YYPARSE_PARAM */
3825 #if defined __STDC__ || defined __cplusplus
3830 #endif /* ! YYPARSE_PARAM */
3834 /* The look-ahead symbol. */
3837 /* The semantic value of the look-ahead symbol. */
3840 /* Number of syntax errors so far. */
3849 #ifdef YYPARSE_PARAM
3850 #if (defined __STDC__ || defined __C99__FUNC__ \
3851 || defined __cplusplus || defined _MSC_VER)
3853 yyparse (void *YYPARSE_PARAM)
3856 yyparse (YYPARSE_PARAM)
3857 void *YYPARSE_PARAM;
3859 #else /* ! YYPARSE_PARAM */
3860 #if (defined __STDC__ || defined __C99__FUNC__ \
3861 || defined __cplusplus || defined _MSC_VER)
3875 /* Number of tokens to shift before error messages enabled. */
3877 /* Look-ahead token as an internal (translated) token number. */
3880 /* Buffer for error messages, and its allocated size. */
3882 char *yymsg = yymsgbuf;
3883 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3886 /* Three stacks and their tools:
3887 `yyss': related to states,
3888 `yyvs': related to semantic values,
3889 `yyls': related to locations.
3891 Refer to the stacks thru separate pointers, to allow yyoverflow
3892 to reallocate them elsewhere. */
3894 /* The state stack. */
3895 yytype_int16 yyssa[YYINITDEPTH];
3896 yytype_int16 *yyss = yyssa;
3897 yytype_int16 *yyssp;
3899 /* The semantic value stack. */
3900 YYSTYPE yyvsa[YYINITDEPTH];
3901 YYSTYPE *yyvs = yyvsa;
3906 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3908 YYSIZE_T yystacksize = YYINITDEPTH;
3910 /* The variables used to return semantic value and location from the
3915 /* The number of symbols on the RHS of the reduced rule.
3916 Keep to zero when no symbol should be popped. */
3919 YYDPRINTF ((stderr, "Starting parse\n"));
3924 yychar = YYEMPTY; /* Cause a token to be read. */
3926 /* Initialize stack pointers.
3927 Waste one element of value and location stack
3928 so that they stay on the same level as the state stack.
3929 The wasted elements are never initialized. */
3936 /*------------------------------------------------------------.
3937 | yynewstate -- Push a new state, which is found in yystate. |
3938 `------------------------------------------------------------*/
3940 /* In all cases, when you get here, the value and location stacks
3941 have just been pushed. So pushing a state here evens the stacks. */
3947 if (yyss + yystacksize - 1 <= yyssp)
3949 /* Get the current used size of the three stacks, in elements. */
3950 YYSIZE_T yysize = yyssp - yyss + 1;
3954 /* Give user a chance to reallocate the stack. Use copies of
3955 these so that the &'s don't force the real ones into
3957 YYSTYPE *yyvs1 = yyvs;
3958 yytype_int16 *yyss1 = yyss;
3961 /* Each stack pointer address is followed by the size of the
3962 data in use in that stack, in bytes. This used to be a
3963 conditional around just the two extra args, but that might
3964 be undefined if yyoverflow is a macro. */
3965 yyoverflow (YY_("memory exhausted"),
3966 &yyss1, yysize * sizeof (*yyssp),
3967 &yyvs1, yysize * sizeof (*yyvsp),
3974 #else /* no yyoverflow */
3975 # ifndef YYSTACK_RELOCATE
3976 goto yyexhaustedlab;
3978 /* Extend the stack our own way. */
3979 if (YYMAXDEPTH <= yystacksize)
3980 goto yyexhaustedlab;
3982 if (YYMAXDEPTH < yystacksize)
3983 yystacksize = YYMAXDEPTH;
3986 yytype_int16 *yyss1 = yyss;
3987 union yyalloc *yyptr =
3988 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3990 goto yyexhaustedlab;
3991 YYSTACK_RELOCATE (yyss);
3992 YYSTACK_RELOCATE (yyvs);
3994 # undef YYSTACK_RELOCATE
3996 YYSTACK_FREE (yyss1);
3999 #endif /* no yyoverflow */
4001 yyssp = yyss + yysize - 1;
4002 yyvsp = yyvs + yysize - 1;
4005 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
4006 (unsigned long int) yystacksize));
4008 if (yyss + yystacksize - 1 <= yyssp)
4012 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
4021 /* Do appropriate processing given the current state. Read a
4022 look-ahead token if we need one and don't already have one. */
4024 /* First try to decide what to do without reference to look-ahead token. */
4025 yyn = yypact[yystate];
4026 if (yyn == YYPACT_NINF)
4029 /* Not known => get a look-ahead token if don't already have one. */
4031 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
4032 if (yychar == YYEMPTY)
4034 YYDPRINTF ((stderr, "Reading a token: "));
4038 if (yychar <= YYEOF)
4040 yychar = yytoken = YYEOF;
4041 YYDPRINTF ((stderr, "Now at end of input.\n"));
4045 yytoken = YYTRANSLATE (yychar);
4046 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
4049 /* If the proper action on seeing token YYTOKEN is to reduce or to
4050 detect an error, take that action. */
4052 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
4057 if (yyn == 0 || yyn == YYTABLE_NINF)
4066 /* Count tokens shifted since error; after three, turn off error
4071 /* Shift the look-ahead token. */
4072 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
4074 /* Discard the shifted token unless it is eof. */
4075 if (yychar != YYEOF)
4084 /*-----------------------------------------------------------.
4085 | yydefault -- do the default action for the current state. |
4086 `-----------------------------------------------------------*/
4088 yyn = yydefact[yystate];
4094 /*-----------------------------.
4095 | yyreduce -- Do a reduction. |
4096 `-----------------------------*/
4098 /* yyn is the number of a rule to reduce with. */
4101 /* If YYLEN is nonzero, implement the default value of the action:
4104 Otherwise, the following line sets YYVAL to garbage.
4105 This behavior is undocumented and Bison
4106 users should not rely upon it. Assigning to YYVAL
4107 unconditionally makes the parser a bit smaller, and it avoids a
4108 GCC warning that YYVAL may be used uninitialized. */
4109 yyval = yyvsp[1-yylen];
4112 YY_REDUCE_PRINT (yyn);
4116 #line 1821 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4118 if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
4119 error("Value too large for type");
4120 (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
4125 #line 1830 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4127 if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
4128 error("Value too large for type");
4129 (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
4134 #line 1852 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4135 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
4139 #line 1852 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4140 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
4144 #line 1853 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4145 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
4149 #line 1853 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4150 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
4154 #line 1854 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4155 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
4159 #line 1854 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4160 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
4164 #line 1855 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4165 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
4169 #line 1855 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4170 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
4174 #line 1856 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4175 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
4179 #line 1856 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4180 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
4184 #line 1860 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4185 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
4189 #line 1860 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4190 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
4194 #line 1861 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4195 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
4199 #line 1861 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4200 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
4204 #line 1862 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4205 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
4209 #line 1862 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4210 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
4214 #line 1863 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4215 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
4219 #line 1863 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4220 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
4224 #line 1864 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4225 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
4229 #line 1864 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4230 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
4234 #line 1865 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4235 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
4239 #line 1865 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4240 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
4244 #line 1866 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4245 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
4249 #line 1866 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4250 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
4254 #line 1867 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4255 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
4259 #line 1868 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4260 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
4264 #line 1899 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4266 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
4271 #line 1902 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4278 #line 1907 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4279 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
4283 #line 1908 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4284 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
4288 #line 1909 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4289 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
4293 #line 1910 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4294 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
4298 #line 1911 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4299 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
4303 #line 1912 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4304 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
4308 #line 1913 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4309 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
4313 #line 1914 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4314 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
4318 #line 1918 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4319 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;}
4323 #line 1919 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4324 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;}
4328 #line 1920 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4329 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::CSRet; ;}
4333 #line 1921 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4334 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Fast; ;}
4338 #line 1922 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4339 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Cold; ;}
4343 #line 1923 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4344 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_StdCall; ;}
4348 #line 1924 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4349 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_FastCall; ;}
4353 #line 1925 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4355 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
4356 error("Calling conv too large");
4357 (yyval.UIntVal) = lastCallingConv = (yyvsp[(2) - (2)].UInt64Val);
4362 #line 1935 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4363 { (yyval.UIntVal) = 0; ;}
4367 #line 1936 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4369 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4370 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4371 error("Alignment must be a power of two");
4376 #line 1944 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4377 { (yyval.UIntVal) = 0; ;}
4381 #line 1945 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4383 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4384 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4385 error("Alignment must be a power of two");
4390 #line 1953 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4392 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
4393 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
4394 error("Invalid character in section name");
4395 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4400 #line 1962 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4401 { (yyval.StrVal) = 0; ;}
4405 #line 1963 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4406 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4410 #line 1970 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4415 #line 1971 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4420 #line 1975 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4422 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
4423 free((yyvsp[(1) - (1)].StrVal));
4428 #line 1979 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4430 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
4431 error("Alignment must be a power of two");
4432 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
4438 #line 1996 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4440 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4441 (yyval.TypeVal).S.makeSignless();
4446 #line 2004 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4448 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4449 (yyval.TypeVal).S.makeSignless();
4454 #line 2011 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4456 if (!UpRefs.empty())
4457 error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).PAT)->getDescription());
4458 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4463 #line 2025 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4465 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4466 (yyval.TypeVal).S.copy((yyvsp[(1) - (1)].PrimType).S);
4471 #line 2029 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4473 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
4474 (yyval.TypeVal).S.makeSignless();
4479 #line 2033 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4480 { // Named types are also simple types...
4481 (yyval.TypeVal).S.copy(getTypeSign((yyvsp[(1) - (1)].ValIDVal)));
4482 const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
4483 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
4488 #line 2038 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4489 { // Type UpReference
4490 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U)
4491 error("Value out of range");
4492 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
4493 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4494 (yyval.TypeVal).PAT = new PATypeHolder(OT);
4495 (yyval.TypeVal).S.makeSignless();
4496 UR_OUT("New Upreference!\n");
4501 #line 2047 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4502 { // Function derived type?
4503 (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (4)].TypeVal).S);
4504 std::vector<const Type*> Params;
4505 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
4506 E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
4507 Params.push_back(I->PAT->get());
4508 (yyval.TypeVal).S.add(I->S);
4510 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4511 if (isVarArg) Params.pop_back();
4513 const ParamAttrsList *PAL = 0;
4514 if (lastCallingConv == OldCallingConv::CSRet) {
4515 ParamAttrsVector Attrs;
4516 ParamAttrsWithIndex PAWI;
4517 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
4518 Attrs.push_back(PAWI);
4519 PAL = ParamAttrsList::get(Attrs);
4522 const FunctionType *FTy =
4523 FunctionType::get((yyvsp[(1) - (4)].TypeVal).PAT->get(), Params, isVarArg);
4525 (yyval.TypeVal).PAT = new PATypeHolder( HandleUpRefs(FTy, (yyval.TypeVal).S) );
4526 delete (yyvsp[(1) - (4)].TypeVal).PAT; // Delete the return type handle
4527 delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list
4532 #line 2074 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4533 { // Sized array type?
4534 (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S);
4535 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).PAT->get(),
4536 (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S));
4537 delete (yyvsp[(4) - (5)].TypeVal).PAT;
4542 #line 2080 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4544 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).PAT->get();
4545 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
4546 error("Unsigned result not equal to signed result");
4547 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4548 error("Elements of a VectorType must be integer or floating point");
4549 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
4550 error("VectorType length should be a power of 2");
4551 (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S);
4552 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4553 (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S));
4554 delete (yyvsp[(4) - (5)].TypeVal).PAT;
4559 #line 2093 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4560 { // Structure type?
4561 std::vector<const Type*> Elements;
4562 (yyval.TypeVal).S.makeComposite();
4563 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4564 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I) {
4565 Elements.push_back(I->PAT->get());
4566 (yyval.TypeVal).S.add(I->S);
4568 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S));
4569 delete (yyvsp[(2) - (3)].TypeList);
4574 #line 2104 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4575 { // Empty structure type?
4576 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4577 (yyval.TypeVal).S.makeComposite();
4582 #line 2108 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4583 { // Packed Structure type?
4584 (yyval.TypeVal).S.makeComposite();
4585 std::vector<const Type*> Elements;
4586 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4587 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
4588 Elements.push_back(I->PAT->get());
4589 (yyval.TypeVal).S.add(I->S);
4592 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
4593 (yyval.TypeVal).S));
4594 delete (yyvsp[(3) - (5)].TypeList);
4599 #line 2121 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4600 { // Empty packed structure type?
4601 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4602 (yyval.TypeVal).S.makeComposite();
4607 #line 2125 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4609 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::LabelTy)
4610 error("Cannot form a pointer to a basic block");
4611 (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (2)].TypeVal).S);
4612 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).PAT->get()),
4613 (yyval.TypeVal).S));
4614 delete (yyvsp[(1) - (2)].TypeVal).PAT;
4619 #line 2139 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4621 (yyval.TypeList) = new std::list<PATypeInfo>();
4622 (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal));
4627 #line 2143 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4629 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
4634 #line 2151 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4637 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
4638 VoidTI.S.makeSignless();
4639 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
4644 #line 2157 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4646 (yyval.TypeList) = new std::list<PATypeInfo>();
4648 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
4649 VoidTI.S.makeSignless();
4650 (yyval.TypeList)->push_back(VoidTI);
4655 #line 2164 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4657 (yyval.TypeList) = new std::list<PATypeInfo>();
4662 #line 2176 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4663 { // Nonempty unsized arr
4664 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
4666 error("Cannot make array constant with type: '" +
4667 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
4668 const Type *ETy = ATy->getElementType();
4669 int NumElements = ATy->getNumElements();
4671 // Verify that we have the correct size...
4672 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4673 error("Type mismatch: constant sized array initialized with " +
4674 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
4675 itostr(NumElements) + "");
4677 // Verify all elements are correct type!
4678 std::vector<Constant*> Elems;
4679 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4680 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4681 const Type* ValTy = C->getType();
4683 error("Element #" + utostr(i) + " is not of type '" +
4684 ETy->getDescription() +"' as required!\nIt is of type '"+
4685 ValTy->getDescription() + "'");
4688 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4689 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4690 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4691 delete (yyvsp[(3) - (4)].ConstVector);
4696 #line 2206 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4698 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
4700 error("Cannot make array constant with type: '" +
4701 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
4702 int NumElements = ATy->getNumElements();
4703 if (NumElements != -1 && NumElements != 0)
4704 error("Type mismatch: constant sized array initialized with 0"
4705 " arguments, but has size of " + itostr(NumElements) +"");
4706 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4707 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4708 delete (yyvsp[(1) - (3)].TypeVal).PAT;
4713 #line 2219 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4715 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
4717 error("Cannot make array constant with type: '" +
4718 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
4719 int NumElements = ATy->getNumElements();
4720 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4721 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4722 error("String arrays require type i8, not '" + ETy->getDescription() +
4724 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4725 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
4726 error("Can't build string constant of size " +
4727 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " +
4728 itostr(NumElements) + "");
4729 std::vector<Constant*> Vals;
4730 for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
4731 Vals.push_back(ConstantInt::get(ETy, *C));
4732 free((yyvsp[(3) - (3)].StrVal));
4733 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4734 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4735 delete (yyvsp[(1) - (3)].TypeVal).PAT;
4740 #line 2242 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4741 { // Nonempty unsized arr
4742 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
4744 error("Cannot make packed constant with type: '" +
4745 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
4746 const Type *ETy = PTy->getElementType();
4747 int NumElements = PTy->getNumElements();
4748 // Verify that we have the correct size...
4749 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4750 error("Type mismatch: constant sized packed initialized with " +
4751 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
4752 itostr(NumElements) + "");
4753 // Verify all elements are correct type!
4754 std::vector<Constant*> Elems;
4755 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4756 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4757 const Type* ValTy = C->getType();
4759 error("Element #" + utostr(i) + " is not of type '" +
4760 ETy->getDescription() +"' as required!\nIt is of type '"+
4761 ValTy->getDescription() + "'");
4764 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
4765 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4766 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4767 delete (yyvsp[(3) - (4)].ConstVector);
4772 #line 2270 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4774 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
4776 error("Cannot make struct constant with type: '" +
4777 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
4778 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
4779 error("Illegal number of initializers for structure type");
4781 // Check to ensure that constants are compatible with the type initializer!
4782 std::vector<Constant*> Fields;
4783 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
4784 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4785 if (C->getType() != STy->getElementType(i))
4786 error("Expected type '" + STy->getElementType(i)->getDescription() +
4787 "' for element #" + utostr(i) + " of structure initializer");
4788 Fields.push_back(C);
4790 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4791 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4792 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4793 delete (yyvsp[(3) - (4)].ConstVector);
4798 #line 2292 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4800 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
4802 error("Cannot make struct constant with type: '" +
4803 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
4804 if (STy->getNumContainedTypes() != 0)
4805 error("Illegal number of initializers for structure type");
4806 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4807 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4808 delete (yyvsp[(1) - (3)].TypeVal).PAT;
4813 #line 2303 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4815 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).PAT->get());
4817 error("Cannot make packed struct constant with type: '" +
4818 (yyvsp[(1) - (6)].TypeVal).PAT->get()->getDescription() + "'");
4819 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
4820 error("Illegal number of initializers for packed structure type");
4822 // Check to ensure that constants are compatible with the type initializer!
4823 std::vector<Constant*> Fields;
4824 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
4825 Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
4826 if (C->getType() != STy->getElementType(i))
4827 error("Expected type '" + STy->getElementType(i)->getDescription() +
4828 "' for element #" + utostr(i) + " of packed struct initializer");
4829 Fields.push_back(C);
4831 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4832 (yyval.ConstVal).S.copy((yyvsp[(1) - (6)].TypeVal).S);
4833 delete (yyvsp[(1) - (6)].TypeVal).PAT;
4834 delete (yyvsp[(4) - (6)].ConstVector);
4839 #line 2325 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4841 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).PAT->get());
4843 error("Cannot make packed struct constant with type: '" +
4844 (yyvsp[(1) - (5)].TypeVal).PAT->get()->getDescription() + "'");
4845 if (STy->getNumContainedTypes() != 0)
4846 error("Illegal number of initializers for packed structure type");
4847 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4848 (yyval.ConstVal).S.copy((yyvsp[(1) - (5)].TypeVal).S);
4849 delete (yyvsp[(1) - (5)].TypeVal).PAT;
4854 #line 2336 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4856 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get());
4858 error("Cannot make null pointer constant with type: '" +
4859 (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription() + "'");
4860 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4861 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4862 delete (yyvsp[(1) - (2)].TypeVal).PAT;
4867 #line 2345 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4869 (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).PAT->get());
4870 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4871 delete (yyvsp[(1) - (2)].TypeVal).PAT;
4876 #line 2350 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4878 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get());
4880 error("Global const reference must be a pointer type, not" +
4881 (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription());
4883 // ConstExprs can exist in the body of a function, thus creating
4884 // GlobalValues whenever they refer to a variable. Because we are in
4885 // the context of a function, getExistingValue will search the functions
4886 // symbol table instead of the module symbol table for the global symbol,
4887 // which throws things all off. To get around this, we just tell
4888 // getExistingValue that we are at global scope here.
4890 Function *SavedCurFn = CurFun.CurrentFunction;
4891 CurFun.CurrentFunction = 0;
4892 (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4893 Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
4894 CurFun.CurrentFunction = SavedCurFn;
4896 // If this is an initializer for a constant pointer, which is referencing a
4897 // (currently) undefined variable, create a stub now that shall be replaced
4898 // in the future with the right type of variable.
4901 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4902 const PointerType *PT = cast<PointerType>(Ty);
4904 // First check to see if the forward references value is already created!
4905 PerModuleInfo::GlobalRefsType::iterator I =
4906 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
4908 if (I != CurModule.GlobalRefs.end()) {
4909 V = I->second; // Placeholder already exists, use it...
4910 (yyvsp[(2) - (2)].ValIDVal).destroy();
4913 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4915 // Create the forward referenced global.
4917 if (const FunctionType *FTy =
4918 dyn_cast<FunctionType>(PT->getElementType())) {
4919 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4920 CurModule.CurrentModule);
4922 GV = new GlobalVariable(PT->getElementType(), false,
4923 GlobalValue::ExternalLinkage, 0,
4924 Name, CurModule.CurrentModule);
4927 // Keep track of the fact that we have a forward ref to recycle it
4928 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
4932 (yyval.ConstVal).C = cast<GlobalValue>(V);
4933 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4934 delete (yyvsp[(1) - (2)].TypeVal).PAT; // Free the type handle
4939 #line 2409 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4941 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
4942 error("Mismatched types for constant expression");
4943 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4944 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4945 delete (yyvsp[(1) - (2)].TypeVal).PAT;
4950 #line 2416 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4952 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get();
4953 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4954 error("Cannot create a null initialized value of this type");
4955 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4956 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4957 delete (yyvsp[(1) - (2)].TypeVal).PAT;
4962 #line 2424 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4963 { // integral constants
4964 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4965 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
4966 error("Constant value doesn't fit in type");
4967 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
4968 (yyval.ConstVal).S.makeSigned();
4973 #line 2431 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4974 { // integral constants
4975 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4976 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
4977 error("Constant value doesn't fit in type");
4978 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
4979 (yyval.ConstVal).S.makeUnsigned();
4984 #line 2438 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4985 { // Boolean constants
4986 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4987 (yyval.ConstVal).S.makeUnsigned();
4992 #line 2442 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
4993 { // Boolean constants
4994 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4995 (yyval.ConstVal).S.makeUnsigned();
5000 #line 2446 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5001 { // Float & Double constants
5002 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, *(yyvsp[(2) - (2)].FPVal)))
5003 error("Floating point constant invalid for type");
5004 // Lexer has no type info, so builds all FP constants as double.
5006 if ((yyvsp[(1) - (2)].PrimType).T==Type::FloatTy)
5007 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
5008 (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, *(yyvsp[(2) - (2)].FPVal));
5009 delete (yyvsp[(2) - (2)].FPVal);
5010 (yyval.ConstVal).S.makeSignless();
5015 #line 2460 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5017 const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
5018 const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).PAT->get();
5019 Signedness SrcSign((yyvsp[(3) - (6)].ConstVal).S);
5020 Signedness DstSign((yyvsp[(5) - (6)].TypeVal).S);
5021 if (!SrcTy->isFirstClassType())
5022 error("cast constant expression from a non-primitive type: '" +
5023 SrcTy->getDescription() + "'");
5024 if (!DstTy->isFirstClassType())
5025 error("cast constant expression to a non-primitive type: '" +
5026 DstTy->getDescription() + "'");
5027 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign));
5028 (yyval.ConstVal).S.copy(DstSign);
5029 delete (yyvsp[(5) - (6)].TypeVal).PAT;
5034 #line 2475 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5036 const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
5037 if (!isa<PointerType>(Ty))
5038 error("GetElementPtr requires a pointer operand");
5040 std::vector<Constant*> CIndices;
5041 upgradeGEPCEIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), CIndices);
5043 delete (yyvsp[(4) - (5)].ValueList);
5044 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, &CIndices[0], CIndices.size());
5045 (yyval.ConstVal).S.copy(getElementSign((yyvsp[(3) - (5)].ConstVal), CIndices));
5050 #line 2487 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5052 if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
5053 cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
5054 error("Select condition must be bool type");
5055 if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
5056 error("Select operand types must match");
5057 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5058 (yyval.ConstVal).S.copy((yyvsp[(5) - (8)].ConstVal).S);
5063 #line 2496 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5065 const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5066 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
5067 error("Binary operator types must match");
5068 // First, make sure we're dealing with the right opcode by upgrading from
5069 // obsolete versions.
5070 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
5072 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
5073 // To retain backward compatibility with these early compilers, we emit a
5074 // cast to the appropriate integer type automatically if we are in the
5075 // broken case. See PR424 for more information.
5076 if (!isa<PointerType>(Ty)) {
5077 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5079 const Type *IntPtrTy = 0;
5080 switch (CurModule.CurrentModule->getPointerSize()) {
5081 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
5082 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
5083 default: error("invalid pointer binary constant expr");
5085 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
5086 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
5087 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
5088 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
5090 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
5095 #line 2524 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5097 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5098 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
5099 error("Logical operator types must match");
5100 if (!Ty->isInteger()) {
5101 if (!isa<VectorType>(Ty) ||
5102 !cast<VectorType>(Ty)->getElementType()->isInteger())
5103 error("Logical operator requires integer operands");
5105 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
5106 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5107 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
5112 #line 2537 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5114 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5115 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
5116 error("setcc operand types must match");
5117 unsigned short pred;
5118 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
5119 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5120 (yyval.ConstVal).S.makeUnsigned();
5125 #line 2546 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5127 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
5128 error("icmp operand types must match");
5129 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
5130 (yyval.ConstVal).S.makeUnsigned();
5135 #line 2552 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5137 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
5138 error("fcmp operand types must match");
5139 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
5140 (yyval.ConstVal).S.makeUnsigned();
5145 #line 2558 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5147 if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
5148 cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
5149 error("Shift count for shift constant must be unsigned byte");
5150 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5151 if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
5152 error("Shift constant expression requires integer operand");
5153 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[(5) - (6)].ConstVal).C, Ty);
5154 (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S), (yyvsp[(3) - (6)].ConstVal).C, ShiftAmt);
5155 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
5160 #line 2569 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5162 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
5163 error("Invalid extractelement operands");
5164 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5165 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S.get(0));
5170 #line 2575 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5172 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
5173 error("Invalid insertelement operands");
5174 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5175 (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S);
5180 #line 2581 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5182 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
5183 error("Invalid shufflevector operands");
5184 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5185 (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S);
5190 #line 2592 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5191 { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
5195 #line 2593 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5197 (yyval.ConstVector) = new std::vector<ConstInfo>();
5198 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
5203 #line 2602 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5204 { (yyval.BoolVal) = false; ;}
5208 #line 2603 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5209 { (yyval.BoolVal) = true; ;}
5213 #line 2615 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5215 (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
5216 CurModule.ModuleDone();
5221 #line 2624 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5222 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
5226 #line 2625 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5227 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
5231 #line 2626 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5232 { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
5236 #line 2627 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5237 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
5241 #line 2628 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5243 (yyval.ModuleVal) = CurModule.CurrentModule;
5244 // Emit an error if there are any unresolved types left.
5245 if (!CurModule.LateResolveTypes.empty()) {
5246 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5247 if (DID.Type == ValID::NameVal) {
5248 error("Reference to an undefined type: '"+DID.getName() + "'");
5250 error("Reference to an undefined type: #" + itostr(DID.Num));
5257 #line 2644 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5259 // Eagerly resolve types. This is not an optimization, this is a
5260 // requirement that is due to the fact that we could have this:
5262 // %list = type { %list * }
5263 // %list = type { %list * } ; repeated type decl
5265 // If types are not resolved eagerly, then the two types will not be
5266 // determined to be the same type!
5268 ResolveTypeTo((yyvsp[(2) - (4)].StrVal), (yyvsp[(4) - (4)].TypeVal).PAT->get(), (yyvsp[(4) - (4)].TypeVal).S);
5270 if (!setTypeName((yyvsp[(4) - (4)].TypeVal), (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
5271 // If this is a numbered type that is not a redefinition, add it to the
5273 CurModule.Types.push_back((yyvsp[(4) - (4)].TypeVal).PAT->get());
5274 CurModule.TypeSigns.push_back((yyvsp[(4) - (4)].TypeVal).S);
5276 delete (yyvsp[(4) - (4)].TypeVal).PAT;
5281 #line 2664 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5282 { // Function prototypes can be in const pool
5287 #line 2666 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5288 { // Asm blocks can be in the const pool
5293 #line 2668 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5295 if ((yyvsp[(5) - (5)].ConstVal).C == 0)
5296 error("Global value initializer is not a constant");
5297 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), (yyvsp[(3) - (5)].Linkage), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal).C->getType(), (yyvsp[(5) - (5)].ConstVal).C, (yyvsp[(5) - (5)].ConstVal).S);
5302 #line 2672 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5309 #line 2675 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5311 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
5312 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5313 (yyvsp[(5) - (5)].TypeVal).S);
5314 delete (yyvsp[(5) - (5)].TypeVal).PAT;
5319 #line 2680 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5326 #line 2683 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5328 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
5329 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5330 (yyvsp[(5) - (5)].TypeVal).S);
5331 delete (yyvsp[(5) - (5)].TypeVal).PAT;
5336 #line 2688 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5343 #line 2691 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5345 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
5347 ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5348 (yyvsp[(5) - (5)].TypeVal).S);
5349 delete (yyvsp[(5) - (5)].TypeVal).PAT;
5354 #line 2697 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5361 #line 2700 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5367 #line 2702 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5373 #line 2704 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5379 #line 2709 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5381 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5382 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
5383 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
5384 free((yyvsp[(1) - (1)].StrVal));
5386 if (AsmSoFar.empty())
5387 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5389 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
5394 #line 2723 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5395 { (yyval.Endianness) = Module::BigEndian; ;}
5399 #line 2724 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5400 { (yyval.Endianness) = Module::LittleEndian; ;}
5404 #line 2728 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5406 CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
5411 #line 2731 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5413 if ((yyvsp[(3) - (3)].UInt64Val) == 32)
5414 CurModule.setPointerSize(Module::Pointer32);
5415 else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
5416 CurModule.setPointerSize(Module::Pointer64);
5418 error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
5423 #line 2739 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5425 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
5426 free((yyvsp[(3) - (3)].StrVal));
5431 #line 2743 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5433 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
5434 free((yyvsp[(3) - (3)].StrVal));
5439 #line 2754 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5441 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
5442 free((yyvsp[(3) - (3)].StrVal));
5447 #line 2758 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5449 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
5450 free((yyvsp[(1) - (1)].StrVal));
5455 #line 2762 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5460 #line 2775 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5461 { (yyval.StrVal) = 0; ;}
5465 #line 2779 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5467 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::VoidTy)
5468 error("void typed arguments are invalid");
5469 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
5474 #line 2787 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5476 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5477 (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
5478 delete (yyvsp[(3) - (3)].ArgVal);
5483 #line 2792 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5485 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5486 (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
5487 delete (yyvsp[(1) - (1)].ArgVal);
5492 #line 2800 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5493 { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
5497 #line 2801 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5499 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5501 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
5502 VoidTI.S.makeSignless();
5503 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5508 #line 2808 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5510 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5512 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
5513 VoidTI.S.makeSignless();
5514 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5519 #line 2815 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5520 { (yyval.ArgList) = 0; ;}
5524 #line 2819 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5526 UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
5527 std::string FunctionName((yyvsp[(3) - (8)].StrVal));
5528 free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory!
5530 const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).PAT->get();
5532 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5533 error("LLVM functions cannot return aggregate types");
5536 FTySign.makeComposite((yyvsp[(2) - (8)].TypeVal).S);
5537 std::vector<const Type*> ParamTyList;
5539 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5540 // i8*. We check here for those names and override the parameter list
5541 // types to ensure the prototype is correct.
5542 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5543 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5544 } else if (FunctionName == "llvm.va_copy") {
5545 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5546 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5547 } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments...
5548 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5549 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
5550 const Type *Ty = I->first.PAT->get();
5551 ParamTyList.push_back(Ty);
5552 FTySign.add(I->first.S);
5556 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5558 ParamTyList.pop_back();
5560 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg);
5561 const PointerType *PFT = PointerType::get(FT);
5562 delete (yyvsp[(2) - (8)].TypeVal).PAT;
5565 if (!FunctionName.empty()) {
5566 ID = ValID::create((char*)FunctionName.c_str());
5568 ID = ValID::create((int)CurModule.Values[PFT].size());
5570 ID.S.makeComposite(FTySign);
5573 Module* M = CurModule.CurrentModule;
5575 // See if this function was forward referenced. If so, recycle the object.
5576 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5577 // Move the function to the end of the list, from whereever it was
5578 // previously inserted.
5579 Fn = cast<Function>(FWRef);
5580 M->getFunctionList().remove(Fn);
5581 M->getFunctionList().push_back(Fn);
5582 } else if (!FunctionName.empty()) {
5583 GlobalValue *Conflict = M->getFunction(FunctionName);
5585 Conflict = M->getNamedGlobal(FunctionName);
5586 if (Conflict && PFT == Conflict->getType()) {
5587 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5588 // We have two function definitions that conflict, same type, same
5589 // name. We should really check to make sure that this is the result
5590 // of integer type planes collapsing and generate an error if it is
5591 // not, but we'll just rename on the assumption that it is. However,
5592 // let's do it intelligently and rename the internal linkage one
5594 std::string NewName(makeNameUnique(FunctionName));
5595 if (Conflict->hasInternalLinkage()) {
5596 Conflict->setName(NewName);
5598 makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
5599 CurModule.RenameMap[Key] = NewName;
5600 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5601 InsertValue(Fn, CurModule.Values);
5603 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5604 InsertValue(Fn, CurModule.Values);
5606 makeRenameMapKey(FunctionName, PFT, ID.S);
5607 CurModule.RenameMap[Key] = NewName;
5610 // If they are not both definitions, then just use the function we
5611 // found since the types are the same.
5612 Fn = cast<Function>(Conflict);
5614 // Make sure to strip off any argument names so we can't get
5616 if (Fn->isDeclaration())
5617 for (Function::arg_iterator AI = Fn->arg_begin(),
5618 AE = Fn->arg_end(); AI != AE; ++AI)
5621 } else if (Conflict) {
5622 // We have two globals with the same name and different types.
5623 // Previously, this was permitted because the symbol table had
5624 // "type planes" and names only needed to be distinct within a
5625 // type plane. After PR411 was fixed, this is no loner the case.
5626 // To resolve this we must rename one of the two.
5627 if (Conflict->hasInternalLinkage()) {
5628 // We can safely rename the Conflict.
5630 makeRenameMapKey(Conflict->getName(), Conflict->getType(),
5631 CurModule.NamedValueSigns[Conflict->getName()]);
5632 Conflict->setName(makeNameUnique(Conflict->getName()));
5633 CurModule.RenameMap[Key] = Conflict->getName();
5634 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5635 InsertValue(Fn, CurModule.Values);
5637 // We can't quietly rename either of these things, but we must
5638 // rename one of them. Only if the function's linkage is internal can
5639 // we forgo a warning message about the renamed function.
5640 std::string NewName = makeNameUnique(FunctionName);
5641 if (CurFun.Linkage != GlobalValue::InternalLinkage) {
5642 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5643 "' may cause linkage errors");
5645 // Elect to rename the thing we're now defining.
5646 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5647 InsertValue(Fn, CurModule.Values);
5648 RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
5649 CurModule.RenameMap[Key] = NewName;
5652 // There's no conflict, just define the function
5653 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5654 InsertValue(Fn, CurModule.Values);
5657 // There's no conflict, just define the function
5658 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5659 InsertValue(Fn, CurModule.Values);
5663 CurFun.FunctionStart(Fn);
5665 if (CurFun.isDeclare) {
5666 // If we have declaration, always overwrite linkage. This will allow us
5667 // to correctly handle cases, when pointer to function is passed as
5668 // argument to another function.
5669 Fn->setLinkage(CurFun.Linkage);
5671 Fn->setCallingConv(upgradeCallingConv((yyvsp[(1) - (8)].UIntVal)));
5672 Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
5673 if ((yyvsp[(7) - (8)].StrVal)) {
5674 Fn->setSection((yyvsp[(7) - (8)].StrVal));
5675 free((yyvsp[(7) - (8)].StrVal));
5678 // Convert the CSRet calling convention into the corresponding parameter
5680 if ((yyvsp[(1) - (8)].UIntVal) == OldCallingConv::CSRet) {
5681 ParamAttrsVector Attrs;
5682 ParamAttrsWithIndex PAWI;
5683 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
5684 Attrs.push_back(PAWI);
5685 Fn->setParamAttrs(ParamAttrsList::get(Attrs));
5688 // Add all of the arguments we parsed to the function...
5689 if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty...
5690 if (isVarArg) { // Nuke the last entry
5691 assert((yyvsp[(5) - (8)].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5692 (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
5693 delete (yyvsp[(5) - (8)].ArgList)->back().first.PAT;
5694 (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry
5696 Function::arg_iterator ArgIt = Fn->arg_begin();
5697 Function::arg_iterator ArgEnd = Fn->arg_end();
5698 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[(5) - (8)].ArgList)->begin();
5699 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[(5) - (8)].ArgList)->end();
5700 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
5701 delete I->first.PAT; // Delete the typeholder...
5702 ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
5703 setValueName(VI, I->second); // Insert arg into symtab...
5706 delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list
5708 lastCallingConv = OldCallingConv::C;
5713 #line 3011 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5714 { CurFun.Linkage = (yyvsp[(1) - (1)].Linkage); ;}
5718 #line 3011 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5720 (yyval.FunctionVal) = CurFun.CurrentFunction;
5722 // Make sure that we keep track of the linkage type even if there was a
5723 // previous "declare".
5724 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5729 #line 3025 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5731 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5736 #line 3030 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5737 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5741 #line 3031 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5742 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
5746 #line 3032 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5747 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
5751 #line 3036 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5752 { CurFun.isDeclare = true; ;}
5756 #line 3037 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5757 { CurFun.Linkage = (yyvsp[(3) - (3)].Linkage); ;}
5761 #line 3037 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5763 (yyval.FunctionVal) = CurFun.CurrentFunction;
5764 CurFun.FunctionDone();
5770 #line 3049 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5771 { (yyval.BoolVal) = false; ;}
5775 #line 3050 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5776 { (yyval.BoolVal) = true; ;}
5780 #line 3055 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5781 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
5785 #line 3056 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5786 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
5790 #line 3057 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5791 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
5795 #line 3058 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5797 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true));
5798 (yyval.ValIDVal).S.makeUnsigned();
5803 #line 3062 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5805 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false));
5806 (yyval.ValIDVal).S.makeUnsigned();
5811 #line 3066 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5812 { (yyval.ValIDVal) = ValID::createNull(); ;}
5816 #line 3067 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5817 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5821 #line 3068 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5822 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5826 #line 3069 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5827 { // Nonempty unsized packed vector
5828 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
5829 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
5830 VectorType* pt = VectorType::get(ETy, NumElements);
5831 (yyval.ValIDVal).S.makeComposite((*(yyvsp[(2) - (3)].ConstVector))[0].S);
5832 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S));
5834 // Verify all elements are correct type!
5835 std::vector<Constant*> Elems;
5836 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5837 Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
5838 const Type *CTy = C->getType();
5840 error("Element #" + utostr(i) + " is not of type '" +
5841 ETy->getDescription() +"' as required!\nIt is of type '" +
5842 CTy->getDescription() + "'");
5845 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
5846 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5851 #line 3090 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5853 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
5854 (yyval.ValIDVal).S.copy((yyvsp[(1) - (1)].ConstVal).S);
5859 #line 3094 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5861 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5862 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5863 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5864 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5865 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5866 free((yyvsp[(3) - (5)].StrVal));
5867 free((yyvsp[(5) - (5)].StrVal));
5872 #line 3108 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5873 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;}
5877 #line 3109 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5878 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;}
5882 #line 3122 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5884 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get();
5885 (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5886 (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
5887 (yyval.ValueVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5888 delete (yyvsp[(1) - (2)].TypeVal).PAT;
5893 #line 3132 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5895 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5900 #line 3135 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5901 { // Do not allow functions with 0 basic blocks
5902 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5907 #line 3144 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5909 ValueInfo VI; VI.V = (yyvsp[(3) - (3)].TermInstVal).TI; VI.S.copy((yyvsp[(3) - (3)].TermInstVal).S);
5910 setValueName(VI, (yyvsp[(2) - (3)].StrVal));
5911 InsertValue((yyvsp[(3) - (3)].TermInstVal).TI);
5912 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal).TI);
5913 InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5914 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5919 #line 3155 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5921 if ((yyvsp[(2) - (2)].InstVal).I)
5922 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
5923 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
5928 #line 3160 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5930 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
5931 // Make sure to move the basic block to the correct location in the
5932 // function, instead of leaving it inserted wherever it was first
5934 Function::BasicBlockListType &BBL =
5935 CurFun.CurrentFunction->getBasicBlockList();
5936 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5941 #line 3169 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5943 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
5944 // Make sure to move the basic block to the correct location in the
5945 // function, instead of leaving it inserted wherever it was first
5947 Function::BasicBlockListType &BBL =
5948 CurFun.CurrentFunction->getBasicBlockList();
5949 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5954 #line 3183 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5955 { // Return with a result...
5956 (yyval.TermInstVal).TI = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
5957 (yyval.TermInstVal).S.makeSignless();
5962 #line 3187 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5963 { // Return with no result...
5964 (yyval.TermInstVal).TI = new ReturnInst();
5965 (yyval.TermInstVal).S.makeSignless();
5970 #line 3191 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5971 { // Unconditional Branch...
5972 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5973 (yyval.TermInstVal).TI = new BranchInst(tmpBB);
5974 (yyval.TermInstVal).S.makeSignless();
5979 #line 3196 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5981 (yyvsp[(6) - (9)].ValIDVal).S.makeSignless();
5982 (yyvsp[(9) - (9)].ValIDVal).S.makeSignless();
5983 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5984 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5985 (yyvsp[(3) - (9)].ValIDVal).S.makeUnsigned();
5986 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5987 (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5988 (yyval.TermInstVal).S.makeSignless();
5993 #line 3206 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
5995 (yyvsp[(3) - (9)].ValIDVal).S.copy((yyvsp[(2) - (9)].PrimType).S);
5996 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
5997 (yyvsp[(6) - (9)].ValIDVal).S.makeSignless();
5998 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5999 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6000 (yyval.TermInstVal).TI = S;
6001 (yyval.TermInstVal).S.makeSignless();
6002 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6003 E = (yyvsp[(8) - (9)].JumpTable)->end();
6004 for (; I != E; ++I) {
6005 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6006 S->addCase(CI, I->second);
6008 error("Switch case is constant, but not a simple integer");
6010 delete (yyvsp[(8) - (9)].JumpTable);
6015 #line 3224 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6017 (yyvsp[(3) - (8)].ValIDVal).S.copy((yyvsp[(2) - (8)].PrimType).S);
6018 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
6019 (yyvsp[(6) - (8)].ValIDVal).S.makeSignless();
6020 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
6021 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
6022 (yyval.TermInstVal).TI = S;
6023 (yyval.TermInstVal).S.makeSignless();
6028 #line 3234 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6030 const PointerType *PFTy;
6031 const FunctionType *Ty;
6034 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).PAT->get())) ||
6035 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6036 // Pull out the types of all of the arguments...
6037 std::vector<const Type*> ParamTypes;
6038 FTySign.makeComposite((yyvsp[(3) - (13)].TypeVal).S);
6039 if ((yyvsp[(6) - (13)].ValueList)) {
6040 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
6042 ParamTypes.push_back((*I).V->getType());
6046 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6047 if (isVarArg) ParamTypes.pop_back();
6048 Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).PAT->get(), ParamTypes, isVarArg);
6049 PFTy = PointerType::get(Ty);
6050 (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S);
6052 FTySign = (yyvsp[(3) - (13)].TypeVal).S;
6053 // Get the signedness of the result type. $3 is the pointer to the
6054 // function type so we get the 0th element to extract the function type,
6055 // and then the 0th element again to get the result type.
6056 (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S.get(0).get(0));
6059 (yyvsp[(4) - (13)].ValIDVal).S.makeComposite(FTySign);
6060 Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling...
6061 BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
6062 BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
6064 // Create the call node...
6065 if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments?
6066 std::vector<Value*> Args;
6067 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
6068 } else { // Has arguments?
6069 // Loop through FunctionType's arguments and ensure they are specified
6072 FunctionType::param_iterator I = Ty->param_begin();
6073 FunctionType::param_iterator E = Ty->param_end();
6074 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
6076 std::vector<Value*> Args;
6077 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
6078 if ((*ArgI).V->getType() != *I)
6079 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6080 (*I)->getDescription() + "'");
6081 Args.push_back((*ArgI).V);
6084 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
6085 error("Invalid number of parameters detected");
6087 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
6089 cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[(2) - (13)].UIntVal)));
6090 if ((yyvsp[(2) - (13)].UIntVal) == OldCallingConv::CSRet) {
6091 ParamAttrsVector Attrs;
6092 ParamAttrsWithIndex PAWI;
6093 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
6094 Attrs.push_back(PAWI);
6095 cast<InvokeInst>((yyval.TermInstVal).TI)->setParamAttrs(ParamAttrsList::get(Attrs));
6097 delete (yyvsp[(3) - (13)].TypeVal).PAT;
6098 delete (yyvsp[(6) - (13)].ValueList);
6099 lastCallingConv = OldCallingConv::C;
6104 #line 3306 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6106 (yyval.TermInstVal).TI = new UnwindInst();
6107 (yyval.TermInstVal).S.makeSignless();
6112 #line 3310 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6114 (yyval.TermInstVal).TI = new UnreachableInst();
6115 (yyval.TermInstVal).S.makeSignless();
6120 #line 3317 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6122 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6123 (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(2) - (6)].PrimType).S);
6124 Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
6127 error("May only switch on a constant pool value");
6129 (yyvsp[(6) - (6)].ValIDVal).S.makeSignless();
6130 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
6131 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6136 #line 3329 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6138 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6139 (yyvsp[(2) - (5)].ValIDVal).S.copy((yyvsp[(1) - (5)].PrimType).S);
6140 Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
6143 error("May only switch on a constant pool value");
6145 (yyvsp[(5) - (5)].ValIDVal).S.makeSignless();
6146 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
6147 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6152 #line 3344 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6155 if ((yyvsp[(1) - (2)].StrVal))
6156 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
6157 if (BCI->getSrcTy() == BCI->getDestTy() &&
6158 BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
6159 // This is a useless bit cast causing a name redefinition. It is
6160 // a bit cast from a type to the same type of an operand with the
6161 // same name as the name we would give this instruction. Since this
6162 // instruction results in no code generation, it is safe to omit
6163 // the instruction. This situation can occur because of collapsed
6164 // type planes. For example:
6165 // %X = add int %Y, %Z
6166 // %X = cast int %Y to uint
6167 // After upgrade, this looks like:
6168 // %X = add i32 %Y, %Z
6169 // %X = bitcast i32 to i32
6170 // The bitcast is clearly useless so we omit it.
6173 (yyval.InstVal).I = 0;
6174 (yyval.InstVal).S.makeSignless();
6176 ValueInfo VI; VI.V = (yyvsp[(2) - (2)].InstVal).I; VI.S.copy((yyvsp[(2) - (2)].InstVal).S);
6177 setValueName(VI, (yyvsp[(1) - (2)].StrVal));
6178 InsertValue((yyvsp[(2) - (2)].InstVal).I);
6179 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6185 #line 3374 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6186 { // Used for PHI nodes
6187 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
6188 (yyval.PHIList).S.copy((yyvsp[(1) - (6)].TypeVal).S);
6189 (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(1) - (6)].TypeVal).S);
6190 Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).PAT->get(), (yyvsp[(3) - (6)].ValIDVal));
6191 (yyvsp[(5) - (6)].ValIDVal).S.makeSignless();
6192 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
6193 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
6194 delete (yyvsp[(1) - (6)].TypeVal).PAT;
6199 #line 3384 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6201 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6202 (yyvsp[(4) - (7)].ValIDVal).S.copy((yyvsp[(1) - (7)].PHIList).S);
6203 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
6204 (yyvsp[(6) - (7)].ValIDVal).S.makeSignless();
6205 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
6206 (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
6211 #line 3394 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6212 { // Used for call statements, and memory insts...
6213 (yyval.ValueList) = new std::vector<ValueInfo>();
6214 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
6219 #line 3398 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6221 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6222 (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
6227 #line 3406 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6228 { (yyval.ValueList) = 0; ;}
6232 #line 3410 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6234 (yyval.BoolVal) = true;
6239 #line 3413 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6241 (yyval.BoolVal) = false;
6246 #line 3419 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6248 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6249 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6250 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
6251 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
6252 error("Arithmetic operator requires integer, FP, or packed operands");
6253 if (isa<VectorType>(Ty) &&
6254 ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp))
6255 error("Remainder not supported on vector types");
6256 // Upgrade the opcode from obsolete versions before we do anything with it.
6257 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
6258 Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6259 Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6260 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
6261 if ((yyval.InstVal).I == 0)
6262 error("binary operator returned null");
6263 (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6264 delete (yyvsp[(2) - (5)].TypeVal).PAT;
6269 #line 3438 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6271 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6272 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6273 const Type *Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
6274 if (!Ty->isInteger()) {
6275 if (!isa<VectorType>(Ty) ||
6276 !cast<VectorType>(Ty)->getElementType()->isInteger())
6277 error("Logical operator requires integral operands");
6279 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
6280 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6281 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6282 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
6283 if ((yyval.InstVal).I == 0)
6284 error("binary operator returned null");
6285 (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6286 delete (yyvsp[(2) - (5)].TypeVal).PAT;
6291 #line 3456 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6293 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6294 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6295 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
6296 if(isa<VectorType>(Ty))
6297 error("VectorTypes currently not supported in setcc instructions");
6298 unsigned short pred;
6299 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
6300 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6301 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6302 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
6303 if ((yyval.InstVal).I == 0)
6304 error("binary operator returned null");
6305 (yyval.InstVal).S.makeUnsigned();
6306 delete (yyvsp[(2) - (5)].TypeVal).PAT;
6311 #line 3472 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6313 (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6314 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6315 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get();
6316 if (isa<VectorType>(Ty))
6317 error("VectorTypes currently not supported in icmp instructions");
6318 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
6319 error("icmp requires integer or pointer typed operands");
6320 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
6321 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
6322 (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
6323 (yyval.InstVal).S.makeUnsigned();
6324 delete (yyvsp[(3) - (6)].TypeVal).PAT;
6329 #line 3486 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6331 (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6332 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6333 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get();
6334 if (isa<VectorType>(Ty))
6335 error("VectorTypes currently not supported in fcmp instructions");
6336 else if (!Ty->isFloatingPoint())
6337 error("fcmp instruction requires floating point operands");
6338 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
6339 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
6340 (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
6341 (yyval.InstVal).S.makeUnsigned();
6342 delete (yyvsp[(3) - (6)].TypeVal).PAT;
6347 #line 3500 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6349 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
6350 const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
6351 Value *Ones = ConstantInt::getAllOnesValue(Ty);
6353 error("Expected integral type for not instruction");
6354 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
6355 if ((yyval.InstVal).I == 0)
6356 error("Could not create a xor instruction");
6357 (yyval.InstVal).S.copy((yyvsp[(2) - (2)].ValueVal).S);
6362 #line 3511 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6364 if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
6365 cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
6366 error("Shift amount must be int8");
6367 const Type* Ty = (yyvsp[(2) - (4)].ValueVal).V->getType();
6368 if (!Ty->isInteger())
6369 error("Shift constant expression requires integer operand");
6370 Value* ShiftAmt = 0;
6371 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
6372 if (Constant *C = dyn_cast<Constant>((yyvsp[(4) - (4)].ValueVal).V))
6373 ShiftAmt = ConstantExpr::getZExt(C, Ty);
6375 ShiftAmt = new ZExtInst((yyvsp[(4) - (4)].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
6377 ShiftAmt = (yyvsp[(4) - (4)].ValueVal).V;
6378 (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[(1) - (4)].BinaryOpVal), Ty, (yyvsp[(2) - (4)].ValueVal).S), (yyvsp[(2) - (4)].ValueVal).V, ShiftAmt);
6379 (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S);
6384 #line 3529 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6386 const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
6387 if (!DstTy->isFirstClassType())
6388 error("cast instruction to a non-primitive type: '" +
6389 DstTy->getDescription() + "'");
6390 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[(1) - (4)].CastOpVal), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(2) - (4)].ValueVal).S, DstTy, (yyvsp[(4) - (4)].TypeVal).S, true));
6391 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6392 delete (yyvsp[(4) - (4)].TypeVal).PAT;
6397 #line 3538 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6399 if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
6400 cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
6401 error("select condition must be bool");
6402 if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
6403 error("select value types should match");
6404 (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6405 (yyval.InstVal).S.copy((yyvsp[(4) - (6)].ValueVal).S);
6410 #line 3547 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6412 const Type *Ty = (yyvsp[(4) - (4)].TypeVal).PAT->get();
6414 (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
6415 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6416 delete (yyvsp[(4) - (4)].TypeVal).PAT;
6421 #line 3554 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6423 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
6424 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
6425 ObsoleteVarArgs = true;
6426 Function* NF = cast<Function>(CurModule.CurrentModule->
6427 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6430 //foo = alloca 1 of t
6434 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
6435 CurBB->getInstList().push_back(foo);
6436 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
6437 CurBB->getInstList().push_back(bar);
6438 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6439 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
6440 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6441 delete (yyvsp[(4) - (4)].TypeVal).PAT;
6446 #line 3575 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6448 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
6449 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
6450 ObsoleteVarArgs = true;
6451 Function* NF = cast<Function>(CurModule.CurrentModule->
6452 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6454 //b = vanext a, t ->
6455 //foo = alloca 1 of t
6458 //tmp = vaarg foo, t
6460 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
6461 CurBB->getInstList().push_back(foo);
6462 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
6463 CurBB->getInstList().push_back(bar);
6464 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6465 Instruction* tmp = new VAArgInst(foo, DstTy);
6466 CurBB->getInstList().push_back(tmp);
6467 (yyval.InstVal).I = new LoadInst(foo);
6468 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6469 delete (yyvsp[(4) - (4)].TypeVal).PAT;
6474 #line 3599 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6476 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
6477 error("Invalid extractelement operands");
6478 (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
6479 (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S.get(0));
6484 #line 3605 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6486 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
6487 error("Invalid insertelement operands");
6488 (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6489 (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S);
6494 #line 3611 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6496 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
6497 error("Invalid shufflevector operands");
6498 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6499 (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S);
6504 #line 3617 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6506 const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
6507 if (!Ty->isFirstClassType())
6508 error("PHI node operands must be of first class type");
6509 PHINode *PHI = new PHINode(Ty);
6510 PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
6511 while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
6512 if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty)
6513 error("All elements of a PHI node must be of the same type");
6514 PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
6515 (yyvsp[(2) - (2)].PHIList).P->pop_front();
6517 (yyval.InstVal).I = PHI;
6518 (yyval.InstVal).S.copy((yyvsp[(2) - (2)].PHIList).S);
6519 delete (yyvsp[(2) - (2)].PHIList).P; // Free the list...
6524 #line 3633 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6526 // Handle the short call syntax
6527 const PointerType *PFTy;
6528 const FunctionType *FTy;
6530 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).PAT->get())) ||
6531 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6532 // Pull out the types of all of the arguments...
6533 std::vector<const Type*> ParamTypes;
6534 FTySign.makeComposite((yyvsp[(3) - (7)].TypeVal).S);
6535 if ((yyvsp[(6) - (7)].ValueList)) {
6536 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
6538 ParamTypes.push_back((*I).V->getType());
6543 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6544 if (isVarArg) ParamTypes.pop_back();
6546 const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).PAT->get();
6547 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6548 error("Functions cannot return aggregate types");
6550 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
6551 PFTy = PointerType::get(FTy);
6552 (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S);
6554 FTySign = (yyvsp[(3) - (7)].TypeVal).S;
6555 // Get the signedness of the result type. $3 is the pointer to the
6556 // function type so we get the 0th element to extract the function type,
6557 // and then the 0th element again to get the result type.
6558 (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S.get(0).get(0));
6560 (yyvsp[(4) - (7)].ValIDVal).S.makeComposite(FTySign);
6562 // First upgrade any intrinsic calls.
6563 std::vector<Value*> Args;
6564 if ((yyvsp[(6) - (7)].ValueList))
6565 for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i)
6566 Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
6567 Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[(4) - (7)].ValIDVal), Args);
6569 // If we got an upgraded intrinsic
6571 (yyval.InstVal).I = Inst;
6573 // Get the function we're calling
6574 Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
6576 // Check the argument values match
6577 if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments?
6578 // Make sure no arguments is a good thing!
6579 if (FTy->getNumParams() != 0)
6580 error("No arguments passed to a function that expects arguments");
6581 } else { // Has arguments?
6582 // Loop through FunctionType's arguments and ensure they are specified
6585 FunctionType::param_iterator I = FTy->param_begin();
6586 FunctionType::param_iterator E = FTy->param_end();
6587 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
6589 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6590 if ((*ArgI).V->getType() != *I)
6591 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6592 (*I)->getDescription() + "'");
6594 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6595 error("Invalid number of parameters detected");
6598 // Create the call instruction
6599 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
6600 CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
6601 CI->setCallingConv(upgradeCallingConv((yyvsp[(2) - (7)].UIntVal)));
6603 (yyval.InstVal).I = CI;
6605 // Deal with CSRetCC
6606 if ((yyvsp[(2) - (7)].UIntVal) == OldCallingConv::CSRet) {
6607 ParamAttrsVector Attrs;
6608 ParamAttrsWithIndex PAWI;
6609 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
6610 Attrs.push_back(PAWI);
6611 cast<CallInst>((yyval.InstVal).I)->setParamAttrs(ParamAttrsList::get(Attrs));
6613 delete (yyvsp[(3) - (7)].TypeVal).PAT;
6614 delete (yyvsp[(6) - (7)].ValueList);
6615 lastCallingConv = OldCallingConv::C;
6620 #line 3725 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6622 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
6627 #line 3733 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6628 { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
6632 #line 3734 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6633 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6637 #line 3738 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6638 { (yyval.BoolVal) = true; ;}
6642 #line 3739 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6643 { (yyval.BoolVal) = false; ;}
6647 #line 3743 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6649 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get();
6650 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S);
6651 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6652 delete (yyvsp[(2) - (3)].TypeVal).PAT;
6657 #line 3749 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6659 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get();
6660 (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned();
6661 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (6)].TypeVal).S);
6662 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6663 delete (yyvsp[(2) - (6)].TypeVal).PAT;
6668 #line 3756 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6670 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get();
6671 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S);
6672 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6673 delete (yyvsp[(2) - (3)].TypeVal).PAT;
6678 #line 3762 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6680 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get();
6681 (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned();
6682 (yyval.InstVal).S.makeComposite((yyvsp[(4) - (6)].PrimType).S);
6683 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6684 delete (yyvsp[(2) - (6)].TypeVal).PAT;
6689 #line 3769 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6691 const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
6692 if (!isa<PointerType>(PTy))
6693 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
6694 (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
6695 (yyval.InstVal).S.makeSignless();
6700 #line 3776 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6702 const Type* Ty = (yyvsp[(3) - (4)].TypeVal).PAT->get();
6703 (yyvsp[(4) - (4)].ValIDVal).S.copy((yyvsp[(3) - (4)].TypeVal).S);
6704 if (!isa<PointerType>(Ty))
6705 error("Can't load from nonpointer type: " + Ty->getDescription());
6706 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6707 error("Can't load from pointer of non-first-class type: " +
6708 Ty->getDescription());
6709 Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
6710 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
6711 (yyval.InstVal).S.copy((yyvsp[(3) - (4)].TypeVal).S.get(0));
6712 delete (yyvsp[(3) - (4)].TypeVal).PAT;
6717 #line 3789 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6719 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(5) - (6)].TypeVal).S);
6720 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).PAT->get());
6722 error("Can't store to a nonpointer type: " +
6723 (yyvsp[(5) - (6)].TypeVal).PAT->get()->getDescription());
6724 const Type *ElTy = PTy->getElementType();
6725 Value *StoreVal = (yyvsp[(3) - (6)].ValueVal).V;
6726 Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
6727 if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType()) {
6728 PTy = PointerType::get(StoreVal->getType());
6729 if (Constant *C = dyn_cast<Constant>(tmpVal))
6730 tmpVal = ConstantExpr::getBitCast(C, PTy);
6732 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6734 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[(1) - (6)].BoolVal));
6735 (yyval.InstVal).S.makeSignless();
6736 delete (yyvsp[(5) - (6)].TypeVal).PAT;
6741 #line 3809 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6743 (yyvsp[(3) - (4)].ValIDVal).S.copy((yyvsp[(2) - (4)].TypeVal).S);
6744 const Type* Ty = (yyvsp[(2) - (4)].TypeVal).PAT->get();
6745 if (!isa<PointerType>(Ty))
6746 error("getelementptr insn requires pointer operand");
6748 std::vector<Value*> VIndices;
6749 upgradeGEPInstIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
6751 Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
6752 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices.begin(), VIndices.end());
6753 ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[(2) - (4)].TypeVal).S);
6754 (yyval.InstVal).S.copy(getElementSign(VI, VIndices));
6755 delete (yyvsp[(2) - (4)].TypeVal).PAT;
6756 delete (yyvsp[(4) - (4)].ValueList);
6761 /* Line 1267 of yacc.c. */
6762 #line 6763 "UpgradeParser.tab.c"
6765 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6769 YY_STACK_PRINT (yyss, yyssp);
6774 /* Now `shift' the result of the reduction. Determine what state
6775 that goes to, based on the state we popped back to and the rule
6776 number reduced by. */
6780 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6781 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
6782 yystate = yytable[yystate];
6784 yystate = yydefgoto[yyn - YYNTOKENS];
6789 /*------------------------------------.
6790 | yyerrlab -- here on detecting error |
6791 `------------------------------------*/
6793 /* If not already recovering from an error, report this error. */
6797 #if ! YYERROR_VERBOSE
6798 yyerror (YY_("syntax error"));
6801 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6802 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6804 YYSIZE_T yyalloc = 2 * yysize;
6805 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6806 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6807 if (yymsg != yymsgbuf)
6808 YYSTACK_FREE (yymsg);
6809 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6811 yymsg_alloc = yyalloc;
6815 yymsg_alloc = sizeof yymsgbuf;
6819 if (0 < yysize && yysize <= yymsg_alloc)
6821 (void) yysyntax_error (yymsg, yystate, yychar);
6826 yyerror (YY_("syntax error"));
6828 goto yyexhaustedlab;
6836 if (yyerrstatus == 3)
6838 /* If just tried and failed to reuse look-ahead token after an
6839 error, discard it. */
6841 if (yychar <= YYEOF)
6843 /* Return failure if at end of input. */
6844 if (yychar == YYEOF)
6849 yydestruct ("Error: discarding",
6855 /* Else will try to reuse look-ahead token after shifting the error
6860 /*---------------------------------------------------.
6861 | yyerrorlab -- error raised explicitly by YYERROR. |
6862 `---------------------------------------------------*/
6865 /* Pacify compilers like GCC when the user code never invokes
6866 YYERROR and the label yyerrorlab therefore never appears in user
6868 if (/*CONSTCOND*/ 0)
6871 /* Do not reclaim the symbols of the rule which action triggered
6875 YY_STACK_PRINT (yyss, yyssp);
6880 /*-------------------------------------------------------------.
6881 | yyerrlab1 -- common code for both syntax error and YYERROR. |
6882 `-------------------------------------------------------------*/
6884 yyerrstatus = 3; /* Each real token shifted decrements this. */
6888 yyn = yypact[yystate];
6889 if (yyn != YYPACT_NINF)
6892 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6900 /* Pop the current state because it cannot handle the error token. */
6905 yydestruct ("Error: popping",
6906 yystos[yystate], yyvsp);
6909 YY_STACK_PRINT (yyss, yyssp);
6918 /* Shift the error token. */
6919 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6925 /*-------------------------------------.
6926 | yyacceptlab -- YYACCEPT comes here. |
6927 `-------------------------------------*/
6932 /*-----------------------------------.
6933 | yyabortlab -- YYABORT comes here. |
6934 `-----------------------------------*/
6940 /*-------------------------------------------------.
6941 | yyexhaustedlab -- memory exhaustion comes here. |
6942 `-------------------------------------------------*/
6944 yyerror (YY_("memory exhausted"));
6950 if (yychar != YYEOF && yychar != YYEMPTY)
6951 yydestruct ("Cleanup: discarding lookahead",
6953 /* Do not reclaim the symbols of the rule which action triggered
6954 this YYABORT or YYACCEPT. */
6956 YY_STACK_PRINT (yyss, yyssp);
6957 while (yyssp != yyss)
6959 yydestruct ("Cleanup: popping",
6960 yystos[*yyssp], yyvsp);
6965 YYSTACK_FREE (yyss);
6968 if (yymsg != yymsgbuf)
6969 YYSTACK_FREE (yymsg);
6971 /* Make sure YYID is used. */
6972 return YYID (yyresult);
6976 #line 3827 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y"
6979 int yyerror(const char *ErrorMsg) {
6981 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6982 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
6983 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6984 if (yychar != YYEMPTY && yychar != 0)
6985 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6987 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6988 std::cout << "llvm-upgrade: parse failed.\n";
6992 void warning(const std::string& ErrorMsg) {
6994 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6995 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
6996 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6997 if (yychar != YYEMPTY && yychar != 0)
6998 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
7000 std::cerr << "llvm-upgrade: " << errMsg << '\n';
7003 void error(const std::string& ErrorMsg, int LineNo) {
7004 if (LineNo == -1) LineNo = Upgradelineno;
7005 Upgradelineno = LineNo;
7006 yyerror(ErrorMsg.c_str());