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/chandlerc/code/compilers/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 /// This function determines if two function types differ only in their use of
747 /// the sret parameter attribute in the first argument. If they are identical
748 /// in all other respects, it returns true. Otherwise, it returns false.
749 static bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
750 const FunctionType *F2) {
751 if (F1->getReturnType() != F2->getReturnType() ||
752 F1->getNumParams() != F2->getNumParams())
754 const ParamAttrsList *PAL1 = F1->getParamAttrs();
755 const ParamAttrsList *PAL2 = F2->getParamAttrs();
756 if (PAL1 && !PAL2 || PAL2 && !PAL1)
758 if (PAL1 && PAL2 && ((PAL1->size() != PAL2->size()) ||
759 (PAL1->getParamAttrs(0) != PAL2->getParamAttrs(0))))
761 unsigned SRetMask = ~unsigned(ParamAttr::StructRet);
762 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
763 if (F1->getParamType(i) != F2->getParamType(i) || (PAL1 && PAL2 &&
764 (unsigned(PAL1->getParamAttrs(i+1)) & SRetMask !=
765 unsigned(PAL2->getParamAttrs(i+1)) & SRetMask)))
771 /// This function determines if the type of V and Ty differ only by the SRet
772 /// parameter attribute. This is a more generalized case of
773 /// FuncTysDIfferOnlyBySRet since it doesn't require FunctionType arguments.
774 static bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) {
775 if (V->getType() == Ty)
777 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
778 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
780 const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType());
781 const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType());
783 return FuncTysDifferOnlyBySRet(FT1, FT2);
788 // The upgrade of csretcc to sret param attribute may have caused a function
789 // to not be found because the param attribute changed the type of the called
790 // function. This helper function, used in getExistingValue, detects that
791 // situation and bitcasts the function to the correct type.
792 static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
793 // Handle degenerate cases
796 if (V->getType() == Ty)
799 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
800 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
802 const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType());
803 const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType());
804 if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) {
805 const ParamAttrsList *PAL2 = FT2->getParamAttrs();
806 if (PAL2 && PAL2->paramHasAttr(1, ParamAttr::StructRet))
808 else if (Constant *C = dyn_cast<Constant>(V))
809 return ConstantExpr::getBitCast(C, PF1);
811 return new BitCastInst(V, PF1, "upgrd.cast", CurBB);
818 // getExistingValue - Look up the value specified by the provided type and
819 // the provided ValID. If the value exists and has already been defined, return
820 // it. Otherwise return null.
822 static Value *getExistingValue(const Type *Ty, const ValID &D) {
823 if (isa<FunctionType>(Ty)) {
824 error("Functions are not values and must be referenced as pointers");
828 case ValID::NumberVal: { // Is it a numbered definition?
829 unsigned Num = (unsigned)D.Num;
831 // Module constants occupy the lowest numbered slots...
832 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
833 if (VI != CurModule.Values.end()) {
834 if (Num < VI->second.size())
835 return VI->second[Num];
836 Num -= VI->second.size();
839 // Make sure that our type is within bounds
840 VI = CurFun.Values.find(Ty);
841 if (VI == CurFun.Values.end()) return 0;
843 // Check that the number is within bounds...
844 if (VI->second.size() <= Num) return 0;
846 return VI->second[Num];
849 case ValID::NameVal: { // Is it a named definition?
850 // Get the name out of the ID
851 RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
853 if (inFunctionScope()) {
854 // See if the name was renamed
855 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
856 std::string LookupName;
857 if (I != CurFun.RenameMap.end())
858 LookupName = I->second;
861 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
862 V = SymTab.lookup(LookupName);
863 if (V && V->getType() != Ty)
864 V = handleSRetFuncTypeMerge(V, Ty);
865 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
868 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
869 std::string LookupName;
870 if (I != CurModule.RenameMap.end())
871 LookupName = I->second;
874 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
875 if (V && V->getType() != Ty)
876 V = handleSRetFuncTypeMerge(V, Ty);
877 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
882 D.destroy(); // Free old strdup'd memory...
886 // Check to make sure that "Ty" is an integral type, and that our
887 // value will fit into the specified type...
888 case ValID::ConstSIntVal: // Is it a constant pool reference??
889 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
890 error("Signed integral constant '" + itostr(D.ConstPool64) +
891 "' is invalid for type '" + Ty->getDescription() + "'");
893 return ConstantInt::get(Ty, D.ConstPool64);
895 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
896 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
897 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
898 error("Integral constant '" + utostr(D.UConstPool64) +
899 "' is invalid or out of range");
900 else // This is really a signed reference. Transmogrify.
901 return ConstantInt::get(Ty, D.ConstPool64);
903 return ConstantInt::get(Ty, D.UConstPool64);
905 case ValID::ConstFPVal: // Is it a floating point const pool reference?
906 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
907 error("FP constant invalid for type");
908 return ConstantFP::get(Ty, D.ConstPoolFP);
910 case ValID::ConstNullVal: // Is it a null value?
911 if (!isa<PointerType>(Ty))
912 error("Cannot create a a non pointer null");
913 return ConstantPointerNull::get(cast<PointerType>(Ty));
915 case ValID::ConstUndefVal: // Is it an undef value?
916 return UndefValue::get(Ty);
918 case ValID::ConstZeroVal: // Is it a zero value?
919 return Constant::getNullValue(Ty);
921 case ValID::ConstantVal: // Fully resolved constant?
922 if (D.ConstantValue->getType() != Ty)
923 error("Constant expression type different from required type");
924 return D.ConstantValue;
926 case ValID::InlineAsmVal: { // Inline asm expression
927 const PointerType *PTy = dyn_cast<PointerType>(Ty);
928 const FunctionType *FTy =
929 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
930 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
931 error("Invalid type for asm constraint string");
932 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
933 D.IAD->HasSideEffects);
934 D.destroy(); // Free InlineAsmDescriptor.
938 assert(0 && "Unhandled case");
942 assert(0 && "Unhandled case");
946 // getVal - This function is identical to getExistingValue, except that if a
947 // value is not already defined, it "improvises" by creating a placeholder var
948 // that looks and acts just like the requested variable. When the value is
949 // defined later, all uses of the placeholder variable are replaced with the
952 static Value *getVal(const Type *Ty, const ValID &ID) {
953 if (Ty == Type::LabelTy)
954 error("Cannot use a basic block here");
956 // See if the value has already been defined.
957 Value *V = getExistingValue(Ty, ID);
960 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
961 error("Invalid use of a composite type");
963 // If we reached here, we referenced either a symbol that we don't know about
964 // or an id number that hasn't been read yet. We may be referencing something
965 // forward, so just create an entry to be resolved later and get to it...
966 V = new Argument(Ty);
968 // Remember where this forward reference came from. FIXME, shouldn't we try
969 // to recycle these things??
970 CurModule.PlaceHolderInfo.insert(
971 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
973 if (inFunctionScope())
974 InsertValue(V, CurFun.LateResolveValues);
976 InsertValue(V, CurModule.LateResolveValues);
980 /// @brief This just makes any name given to it unique, up to MAX_UINT times.
981 static std::string makeNameUnique(const std::string& Name) {
982 static unsigned UniqueNameCounter = 1;
983 std::string Result(Name);
984 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
988 /// getBBVal - This is used for two purposes:
989 /// * If isDefinition is true, a new basic block with the specified ID is being
991 /// * If isDefinition is true, this is a reference to a basic block, which may
992 /// or may not be a forward reference.
994 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
995 assert(inFunctionScope() && "Can't get basic block at global scope");
1001 error("Illegal label reference " + ID.getName());
1003 case ValID::NumberVal: // Is it a numbered definition?
1004 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
1005 CurFun.NumberedBlocks.resize(ID.Num+1);
1006 BB = CurFun.NumberedBlocks[ID.Num];
1008 case ValID::NameVal: // Is it a named definition?
1010 if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
1011 if (N->getType() != Type::LabelTy) {
1012 // Register names didn't use to conflict with basic block names
1013 // because of type planes. Now they all have to be unique. So, we just
1014 // rename the register and treat this name as if no basic block
1016 RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
1017 N->setName(makeNameUnique(N->getName()));
1018 CurModule.RenameMap[Key] = N->getName();
1021 BB = cast<BasicBlock>(N);
1027 // See if the block has already been defined.
1029 // If this is the definition of the block, make sure the existing value was
1030 // just a forward reference. If it was a forward reference, there will be
1031 // an entry for it in the PlaceHolderInfo map.
1032 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
1033 // The existing value was a definition, not a forward reference.
1034 error("Redefinition of label " + ID.getName());
1036 ID.destroy(); // Free strdup'd memory.
1040 // Otherwise this block has not been seen before.
1041 BB = new BasicBlock("", CurFun.CurrentFunction);
1042 if (ID.Type == ValID::NameVal) {
1043 BB->setName(ID.Name);
1045 CurFun.NumberedBlocks[ID.Num] = BB;
1048 // If this is not a definition, keep track of it so we can use it as a forward
1050 if (!isDefinition) {
1051 // Remember where this forward reference came from.
1052 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
1054 // The forward declaration could have been inserted anywhere in the
1055 // function: insert it into the correct place now.
1056 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
1057 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
1064 //===----------------------------------------------------------------------===//
1065 // Code to handle forward references in instructions
1066 //===----------------------------------------------------------------------===//
1068 // This code handles the late binding needed with statements that reference
1069 // values not defined yet... for example, a forward branch, or the PHI node for
1072 // This keeps a table (CurFun.LateResolveValues) of all such forward references
1073 // and back patchs after we are done.
1076 // ResolveDefinitions - If we could not resolve some defs at parsing
1077 // time (forward branches, phi functions for loops, etc...) resolve the
1081 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
1082 std::map<const Type*,ValueList> *FutureLateResolvers) {
1084 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1085 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
1086 E = LateResolvers.end(); LRI != E; ++LRI) {
1087 const Type* Ty = LRI->first;
1088 ValueList &List = LRI->second;
1089 while (!List.empty()) {
1090 Value *V = List.back();
1093 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1094 CurModule.PlaceHolderInfo.find(V);
1095 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
1097 ValID &DID = PHI->second.first;
1099 Value *TheRealValue = getExistingValue(Ty, DID);
1101 V->replaceAllUsesWith(TheRealValue);
1103 CurModule.PlaceHolderInfo.erase(PHI);
1104 } else if (FutureLateResolvers) {
1105 // Functions have their unresolved items forwarded to the module late
1107 InsertValue(V, *FutureLateResolvers);
1109 if (DID.Type == ValID::NameVal) {
1110 error("Reference to an invalid definition: '" + DID.getName() +
1111 "' of type '" + V->getType()->getDescription() + "'",
1112 PHI->second.second);
1115 error("Reference to an invalid definition: #" +
1116 itostr(DID.Num) + " of type '" +
1117 V->getType()->getDescription() + "'", PHI->second.second);
1124 LateResolvers.clear();
1127 /// This function is used for type resolution and upref handling. When a type
1128 /// becomes concrete, this function is called to adjust the signedness for the
1130 static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
1131 std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
1132 if (!TyName.empty())
1133 CurModule.NamedTypeSigns[TyName] = Sign;
1136 /// ResolveTypeTo - A brand new type was just declared. This means that (if
1137 /// name is not null) things referencing Name can be resolved. Otherwise,
1138 /// things refering to the number can be resolved. Do this now.
1139 static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
1142 D = ValID::create(Name);
1144 D = ValID::create((int)CurModule.Types.size());
1148 CurModule.NamedTypeSigns[Name] = Sign;
1150 std::map<ValID, PATypeHolder>::iterator I =
1151 CurModule.LateResolveTypes.find(D);
1152 if (I != CurModule.LateResolveTypes.end()) {
1153 const Type *OldTy = I->second.get();
1154 ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
1155 CurModule.LateResolveTypes.erase(I);
1159 /// This is the implementation portion of TypeHasInteger. It traverses the
1160 /// type given, avoiding recursive types, and returns true as soon as it finds
1161 /// an integer type. If no integer type is found, it returns false.
1162 static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
1163 // Handle some easy cases
1164 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
1166 if (Ty->isInteger())
1168 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
1169 return STy->getElementType()->isInteger();
1171 // Avoid type structure recursion
1172 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
1177 // Push us on the type stack
1178 Stack.push_back(Ty);
1180 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1181 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1183 FunctionType::param_iterator I = FTy->param_begin();
1184 FunctionType::param_iterator E = FTy->param_end();
1186 if (TypeHasIntegerI(*I, Stack))
1189 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1190 StructType::element_iterator I = STy->element_begin();
1191 StructType::element_iterator E = STy->element_end();
1192 for (; I != E; ++I) {
1193 if (TypeHasIntegerI(*I, Stack))
1198 // There shouldn't be anything else, but its definitely not integer
1199 assert(0 && "What type is this?");
1203 /// This is the interface to TypeHasIntegerI. It just provides the type stack,
1204 /// to avoid recursion, and then calls TypeHasIntegerI.
1205 static inline bool TypeHasInteger(const Type *Ty) {
1206 std::vector<const Type*> TyStack;
1207 return TypeHasIntegerI(Ty, TyStack);
1210 // setValueName - Set the specified value to the name given. The name may be
1211 // null potentially, in which case this is a noop. The string passed in is
1212 // assumed to be a malloc'd string buffer, and is free'd by this function.
1214 static void setValueName(const ValueInfo &V, char *NameStr) {
1216 std::string Name(NameStr); // Copy string
1217 free(NameStr); // Free old string
1219 if (V.V->getType() == Type::VoidTy) {
1220 error("Can't assign name '" + Name + "' to value with void type");
1224 assert(inFunctionScope() && "Must be in function scope");
1226 // Search the function's symbol table for an existing value of this name
1227 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1228 Value* Existing = ST.lookup(Name);
1230 // An existing value of the same name was found. This might have happened
1231 // because of the integer type planes collapsing in LLVM 2.0.
1232 if (Existing->getType() == V.V->getType() &&
1233 !TypeHasInteger(Existing->getType())) {
1234 // If the type does not contain any integers in them then this can't be
1235 // a type plane collapsing issue. It truly is a redefinition and we
1236 // should error out as the assembly is invalid.
1237 error("Redefinition of value named '" + Name + "' of type '" +
1238 V.V->getType()->getDescription() + "'");
1241 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1242 // function, regardless of Type. Previously re-use of names was okay as
1243 // long as they were distinct types. With type planes collapsing because
1244 // of the signedness change and because of PR411, this can no longer be
1245 // supported. We must search the entire symbol table for a conflicting
1246 // name and make the name unique. No warning is needed as this can't
1248 std::string NewName = makeNameUnique(Name);
1249 // We're changing the name but it will probably be used by other
1250 // instructions as operands later on. Consequently we have to retain
1251 // a mapping of the renaming that we're doing.
1252 RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
1253 CurFun.RenameMap[Key] = NewName;
1262 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1263 /// this is a declaration, otherwise it is a definition.
1264 static GlobalVariable *
1265 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1266 bool isConstantGlobal, const Type *Ty,
1267 Constant *Initializer,
1268 const Signedness &Sign) {
1269 if (isa<FunctionType>(Ty))
1270 error("Cannot declare global vars of function type");
1272 const PointerType *PTy = PointerType::get(Ty);
1276 Name = NameStr; // Copy string
1277 free(NameStr); // Free old string
1280 // See if this global value was forward referenced. If so, recycle the
1283 if (!Name.empty()) {
1284 ID = ValID::create((char*)Name.c_str());
1286 ID = ValID::create((int)CurModule.Values[PTy].size());
1288 ID.S.makeComposite(Sign);
1290 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1291 // Move the global to the end of the list, from whereever it was
1292 // previously inserted.
1293 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1294 CurModule.CurrentModule->getGlobalList().remove(GV);
1295 CurModule.CurrentModule->getGlobalList().push_back(GV);
1296 GV->setInitializer(Initializer);
1297 GV->setLinkage(Linkage);
1298 GV->setConstant(isConstantGlobal);
1299 InsertValue(GV, CurModule.Values);
1303 // If this global has a name, check to see if there is already a definition
1304 // of this global in the module and emit warnings if there are conflicts.
1305 if (!Name.empty()) {
1306 // The global has a name. See if there's an existing one of the same name.
1307 if (CurModule.CurrentModule->getNamedGlobal(Name) ||
1308 CurModule.CurrentModule->getFunction(Name)) {
1309 // We found an existing global of the same name. This isn't allowed
1310 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1311 // can at least compile. This can happen because of type planes
1312 // There is alread a global of the same name which means there is a
1313 // conflict. Let's see what we can do about it.
1314 std::string NewName(makeNameUnique(Name));
1315 if (Linkage != GlobalValue::InternalLinkage) {
1316 // The linkage of this gval is external so we can't reliably rename
1317 // it because it could potentially create a linking problem.
1318 // However, we can't leave the name conflict in the output either or
1319 // it won't assemble with LLVM 2.0. So, all we can do is rename
1320 // this one to something unique and emit a warning about the problem.
1321 warning("Renaming global variable '" + Name + "' to '" + NewName +
1322 "' may cause linkage errors");
1325 // Put the renaming in the global rename map
1326 RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
1327 CurModule.RenameMap[Key] = NewName;
1334 // Otherwise there is no existing GV to use, create one now.
1335 GlobalVariable *GV =
1336 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1337 CurModule.CurrentModule);
1338 InsertValue(GV, CurModule.Values);
1339 // Remember the sign of this global.
1340 CurModule.NamedValueSigns[Name] = ID.S;
1344 // setTypeName - Set the specified type to the name given. The name may be
1345 // null potentially, in which case this is a noop. The string passed in is
1346 // assumed to be a malloc'd string buffer, and is freed by this function.
1348 // This function returns true if the type has already been defined, but is
1349 // allowed to be redefined in the specified context. If the name is a new name
1350 // for the type plane, it is inserted and false is returned.
1351 static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
1352 assert(!inFunctionScope() && "Can't give types function-local names");
1353 if (NameStr == 0) return false;
1355 std::string Name(NameStr); // Copy string
1356 free(NameStr); // Free old string
1358 const Type* Ty = TI.PAT->get();
1360 // We don't allow assigning names to void type
1361 if (Ty == Type::VoidTy) {
1362 error("Can't assign name '" + Name + "' to the void type");
1366 // Set the type name, checking for conflicts as we do so.
1367 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
1369 // Save the sign information for later use
1370 CurModule.NamedTypeSigns[Name] = TI.S;
1372 if (AlreadyExists) { // Inserting a name that is already defined???
1373 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1374 assert(Existing && "Conflict but no matching type?");
1376 // There is only one case where this is allowed: when we are refining an
1377 // opaque type. In this case, Existing will be an opaque type.
1378 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1379 // We ARE replacing an opaque type!
1380 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
1384 // Otherwise, this is an attempt to redefine a type. That's okay if
1385 // the redefinition is identical to the original. This will be so if
1386 // Existing and T point to the same Type object. In this one case we
1387 // allow the equivalent redefinition.
1388 if (Existing == Ty) return true; // Yes, it's equal.
1390 // Any other kind of (non-equivalent) redefinition is an error.
1391 error("Redefinition of type named '" + Name + "' in the '" +
1392 Ty->getDescription() + "' type plane");
1398 //===----------------------------------------------------------------------===//
1399 // Code for handling upreferences in type names...
1402 // TypeContains - Returns true if Ty directly contains E in it.
1404 static bool TypeContains(const Type *Ty, const Type *E) {
1405 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1406 E) != Ty->subtype_end();
1410 struct UpRefRecord {
1411 // NestingLevel - The number of nesting levels that need to be popped before
1412 // this type is resolved.
1413 unsigned NestingLevel;
1415 // LastContainedTy - This is the type at the current binding level for the
1416 // type. Every time we reduce the nesting level, this gets updated.
1417 const Type *LastContainedTy;
1419 // UpRefTy - This is the actual opaque type that the upreference is
1420 // represented with.
1421 OpaqueType *UpRefTy;
1423 UpRefRecord(unsigned NL, OpaqueType *URTy)
1424 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
1428 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1429 static std::vector<UpRefRecord> UpRefs;
1431 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1432 /// called. It loops through the UpRefs vector, which is a list of the
1433 /// currently active types. For each type, if the up reference is contained in
1434 /// the newly completed type, we decrement the level count. When the level
1435 /// count reaches zero, the upreferenced type is the type that is passed in:
1436 /// thus we can complete the cycle.
1438 static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
1439 // If Ty isn't abstract, or if there are no up-references in it, then there is
1440 // nothing to resolve here.
1441 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1443 PATypeHolder Ty(ty);
1444 UR_OUT("Type '" << Ty->getDescription() <<
1445 "' newly formed. Resolving upreferences.\n" <<
1446 UpRefs.size() << " upreferences active!\n");
1448 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1449 // to zero), we resolve them all together before we resolve them to Ty. At
1450 // the end of the loop, if there is anything to resolve to Ty, it will be in
1452 OpaqueType *TypeToResolve = 0;
1455 for (; i != UpRefs.size(); ++i) {
1456 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1457 << UpRefs[i].UpRefTy->getDescription() << ") = "
1458 << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
1459 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1460 // Decrement level of upreference
1461 unsigned Level = --UpRefs[i].NestingLevel;
1462 UpRefs[i].LastContainedTy = Ty;
1463 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1464 if (Level == 0) { // Upreference should be resolved!
1465 if (!TypeToResolve) {
1466 TypeToResolve = UpRefs[i].UpRefTy;
1468 UR_OUT(" * Resolving upreference for "
1469 << UpRefs[i].UpRefTy->getDescription() << "\n";
1470 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1471 ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
1472 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1473 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1474 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1476 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1477 --i; // Do not skip the next element...
1482 if (TypeToResolve) {
1483 UR_OUT(" * Resolving upreference for "
1484 << UpRefs[i].UpRefTy->getDescription() << "\n";
1485 std::string OldName = TypeToResolve->getDescription());
1486 ResolveTypeSign(TypeToResolve, Sign);
1487 TypeToResolve->refineAbstractTypeTo(Ty);
1493 bool Signedness::operator<(const Signedness &that) const {
1496 return *(this->name) < *(that.name);
1498 return CurModule.NamedTypeSigns[*name] < that;
1499 } else if (that.isNamed()) {
1500 return *this < CurModule.NamedTypeSigns[*that.name];
1503 if (isComposite() && that.isComposite()) {
1504 if (sv->size() == that.sv->size()) {
1505 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1506 SignVector::const_iterator thatI = that.sv->begin(),
1507 thatE = that.sv->end();
1508 for (; thisI != thisE; ++thisI, ++thatI) {
1509 if (*thisI < *thatI)
1511 else if (!(*thisI == *thatI))
1516 return sv->size() < that.sv->size();
1518 return kind < that.kind;
1521 bool Signedness::operator==(const Signedness &that) const {
1524 return *(this->name) == *(that.name);
1526 return CurModule.NamedTypeSigns[*(this->name)] == that;
1527 else if (that.isNamed())
1528 return *this == CurModule.NamedTypeSigns[*(that.name)];
1529 if (isComposite() && that.isComposite()) {
1530 if (sv->size() == that.sv->size()) {
1531 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1532 SignVector::const_iterator thatI = that.sv->begin(),
1533 thatE = that.sv->end();
1534 for (; thisI != thisE; ++thisI, ++thatI) {
1535 if (!(*thisI == *thatI))
1542 return kind == that.kind;
1545 void Signedness::copy(const Signedness &that) {
1546 if (that.isNamed()) {
1548 name = new std::string(*that.name);
1549 } else if (that.isComposite()) {
1551 sv = new SignVector();
1559 void Signedness::destroy() {
1562 } else if (isComposite()) {
1568 void Signedness::dump() const {
1569 if (isComposite()) {
1570 if (sv->size() == 1) {
1575 for (unsigned i = 0; i < sv->size(); ++i) {
1582 } else if (isNamed()) {
1584 } else if (isSigned()) {
1586 } else if (isUnsigned()) {
1593 static inline Instruction::TermOps
1594 getTermOp(TermOps op) {
1596 default : assert(0 && "Invalid OldTermOp");
1597 case RetOp : return Instruction::Ret;
1598 case BrOp : return Instruction::Br;
1599 case SwitchOp : return Instruction::Switch;
1600 case InvokeOp : return Instruction::Invoke;
1601 case UnwindOp : return Instruction::Unwind;
1602 case UnreachableOp: return Instruction::Unreachable;
1606 static inline Instruction::BinaryOps
1607 getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
1609 default : assert(0 && "Invalid OldBinaryOps");
1615 case SetGT : assert(0 && "Should use getCompareOp");
1616 case AddOp : return Instruction::Add;
1617 case SubOp : return Instruction::Sub;
1618 case MulOp : return Instruction::Mul;
1620 // This is an obsolete instruction so we must upgrade it based on the
1621 // types of its operands.
1622 bool isFP = Ty->isFloatingPoint();
1623 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
1624 // If its a vector type we want to use the element type
1625 isFP = PTy->getElementType()->isFloatingPoint();
1627 return Instruction::FDiv;
1628 else if (Sign.isSigned())
1629 return Instruction::SDiv;
1630 return Instruction::UDiv;
1632 case UDivOp : return Instruction::UDiv;
1633 case SDivOp : return Instruction::SDiv;
1634 case FDivOp : return Instruction::FDiv;
1636 // This is an obsolete instruction so we must upgrade it based on the
1637 // types of its operands.
1638 bool isFP = Ty->isFloatingPoint();
1639 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
1640 // If its a vector type we want to use the element type
1641 isFP = PTy->getElementType()->isFloatingPoint();
1642 // Select correct opcode
1644 return Instruction::FRem;
1645 else if (Sign.isSigned())
1646 return Instruction::SRem;
1647 return Instruction::URem;
1649 case URemOp : return Instruction::URem;
1650 case SRemOp : return Instruction::SRem;
1651 case FRemOp : return Instruction::FRem;
1652 case LShrOp : return Instruction::LShr;
1653 case AShrOp : return Instruction::AShr;
1654 case ShlOp : return Instruction::Shl;
1656 if (Sign.isSigned())
1657 return Instruction::AShr;
1658 return Instruction::LShr;
1659 case AndOp : return Instruction::And;
1660 case OrOp : return Instruction::Or;
1661 case XorOp : return Instruction::Xor;
1665 static inline Instruction::OtherOps
1666 getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1667 const Signedness &Sign) {
1668 bool isSigned = Sign.isSigned();
1669 bool isFP = Ty->isFloatingPoint();
1671 default : assert(0 && "Invalid OldSetCC");
1674 predicate = FCmpInst::FCMP_OEQ;
1675 return Instruction::FCmp;
1677 predicate = ICmpInst::ICMP_EQ;
1678 return Instruction::ICmp;
1682 predicate = FCmpInst::FCMP_UNE;
1683 return Instruction::FCmp;
1685 predicate = ICmpInst::ICMP_NE;
1686 return Instruction::ICmp;
1690 predicate = FCmpInst::FCMP_OLE;
1691 return Instruction::FCmp;
1694 predicate = ICmpInst::ICMP_SLE;
1696 predicate = ICmpInst::ICMP_ULE;
1697 return Instruction::ICmp;
1701 predicate = FCmpInst::FCMP_OGE;
1702 return Instruction::FCmp;
1705 predicate = ICmpInst::ICMP_SGE;
1707 predicate = ICmpInst::ICMP_UGE;
1708 return Instruction::ICmp;
1712 predicate = FCmpInst::FCMP_OLT;
1713 return Instruction::FCmp;
1716 predicate = ICmpInst::ICMP_SLT;
1718 predicate = ICmpInst::ICMP_ULT;
1719 return Instruction::ICmp;
1723 predicate = FCmpInst::FCMP_OGT;
1724 return Instruction::FCmp;
1727 predicate = ICmpInst::ICMP_SGT;
1729 predicate = ICmpInst::ICMP_UGT;
1730 return Instruction::ICmp;
1735 static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1737 default : assert(0 && "Invalid OldMemoryOps");
1738 case MallocOp : return Instruction::Malloc;
1739 case FreeOp : return Instruction::Free;
1740 case AllocaOp : return Instruction::Alloca;
1741 case LoadOp : return Instruction::Load;
1742 case StoreOp : return Instruction::Store;
1743 case GetElementPtrOp : return Instruction::GetElementPtr;
1747 static inline Instruction::OtherOps
1748 getOtherOp(OtherOps op, const Signedness &Sign) {
1750 default : assert(0 && "Invalid OldOtherOps");
1751 case PHIOp : return Instruction::PHI;
1752 case CallOp : return Instruction::Call;
1753 case SelectOp : return Instruction::Select;
1754 case UserOp1 : return Instruction::UserOp1;
1755 case UserOp2 : return Instruction::UserOp2;
1756 case VAArg : return Instruction::VAArg;
1757 case ExtractElementOp : return Instruction::ExtractElement;
1758 case InsertElementOp : return Instruction::InsertElement;
1759 case ShuffleVectorOp : return Instruction::ShuffleVector;
1760 case ICmpOp : return Instruction::ICmp;
1761 case FCmpOp : return Instruction::FCmp;
1765 static inline Value*
1766 getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
1767 const Signedness &DstSign, bool ForceInstruction = false) {
1768 Instruction::CastOps Opcode;
1769 const Type* SrcTy = Src->getType();
1771 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1772 // fp -> ptr cast is no longer supported but we must upgrade this
1773 // by doing a double cast: fp -> int -> ptr
1774 SrcTy = Type::Int64Ty;
1775 Opcode = Instruction::IntToPtr;
1776 if (isa<Constant>(Src)) {
1777 Src = ConstantExpr::getCast(Instruction::FPToUI,
1778 cast<Constant>(Src), SrcTy);
1780 std::string NewName(makeNameUnique(Src->getName()));
1781 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1783 } else if (isa<IntegerType>(DstTy) &&
1784 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1785 // cast type %x to bool was previously defined as setne type %x, null
1786 // The cast semantic is now to truncate, not compare so we must retain
1787 // the original intent by replacing the cast with a setne
1788 Constant* Null = Constant::getNullValue(SrcTy);
1789 Instruction::OtherOps Opcode = Instruction::ICmp;
1790 unsigned short predicate = ICmpInst::ICMP_NE;
1791 if (SrcTy->isFloatingPoint()) {
1792 Opcode = Instruction::FCmp;
1793 predicate = FCmpInst::FCMP_ONE;
1794 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1795 error("Invalid cast to bool");
1797 if (isa<Constant>(Src) && !ForceInstruction)
1798 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1800 return CmpInst::create(Opcode, predicate, Src, Null);
1802 // Determine the opcode to use by calling CastInst::getCastOpcode
1804 CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
1805 DstSign.isSigned());
1807 } else switch (op) {
1808 default: assert(0 && "Invalid cast token");
1809 case TruncOp: Opcode = Instruction::Trunc; break;
1810 case ZExtOp: Opcode = Instruction::ZExt; break;
1811 case SExtOp: Opcode = Instruction::SExt; break;
1812 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1813 case FPExtOp: Opcode = Instruction::FPExt; break;
1814 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1815 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1816 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1817 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1818 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1819 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1820 case BitCastOp: Opcode = Instruction::BitCast; break;
1823 if (isa<Constant>(Src) && !ForceInstruction)
1824 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1825 return CastInst::create(Opcode, Src, DstTy);
1828 static Instruction *
1829 upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1830 std::vector<Value*>& Args) {
1832 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1833 if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' ||
1834 Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.')
1839 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1840 if (Args.size() != 2)
1841 error("Invalid prototype for " + Name);
1842 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1847 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1848 std::vector<const Type*> Params;
1849 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1850 if (Args.size() != 1)
1851 error("Invalid prototype for " + Name + " prototype");
1852 Params.push_back(PtrTy);
1853 const FunctionType *FTy =
1854 FunctionType::get(Type::VoidTy, Params, false);
1855 const PointerType *PFTy = PointerType::get(FTy);
1856 Value* Func = getVal(PFTy, ID);
1857 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
1858 return new CallInst(Func, Args.begin(), Args.end());
1859 } else if (Name == "llvm.va_copy") {
1860 if (Args.size() != 2)
1861 error("Invalid prototype for " + Name + " prototype");
1862 Params.push_back(PtrTy);
1863 Params.push_back(PtrTy);
1864 const FunctionType *FTy =
1865 FunctionType::get(Type::VoidTy, Params, false);
1866 const PointerType *PFTy = PointerType::get(FTy);
1867 Value* Func = getVal(PFTy, ID);
1868 std::string InstName0(makeNameUnique("va0"));
1869 std::string InstName1(makeNameUnique("va1"));
1870 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1871 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1872 return new CallInst(Func, Args.begin(), Args.end());
1879 const Type* upgradeGEPCEIndices(const Type* PTy,
1880 std::vector<ValueInfo> *Indices,
1881 std::vector<Constant*> &Result) {
1882 const Type *Ty = PTy;
1884 for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
1885 Constant *Index = cast<Constant>((*Indices)[i].V);
1887 if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
1888 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1889 // struct indices to i32 struct indices with ZExt for compatibility.
1890 if (CI->getBitWidth() < 32)
1891 Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
1894 if (isa<SequentialType>(Ty)) {
1895 // Make sure that unsigned SequentialType indices are zext'd to
1896 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1897 // all indices for SequentialType elements. We must retain the same
1898 // semantic (zext) for unsigned types.
1899 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
1900 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
1901 Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty);
1905 Result.push_back(Index);
1906 Ty = GetElementPtrInst::getIndexedType(PTy, (Value**)&Result[0],
1907 Result.size(),true);
1909 error("Index list invalid for constant getelementptr");
1914 const Type* upgradeGEPInstIndices(const Type* PTy,
1915 std::vector<ValueInfo> *Indices,
1916 std::vector<Value*> &Result) {
1917 const Type *Ty = PTy;
1919 for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
1920 Value *Index = (*Indices)[i].V;
1922 if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
1923 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1924 // struct indices to i32 struct indices with ZExt for compatibility.
1925 if (CI->getBitWidth() < 32)
1926 Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
1930 if (isa<StructType>(Ty)) { // Only change struct indices
1931 if (!isa<Constant>(Index)) {
1932 error("Invalid non-constant structure index");
1936 // Make sure that unsigned SequentialType indices are zext'd to
1937 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1938 // all indices for SequentialType elements. We must retain the same
1939 // semantic (zext) for unsigned types.
1940 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
1941 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
1942 if (isa<Constant>(Index))
1943 Index = ConstantExpr::getCast(Instruction::ZExt,
1944 cast<Constant>(Index), Type::Int64Ty);
1946 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1947 makeNameUnique("gep"), CurBB);
1951 Result.push_back(Index);
1952 Ty = GetElementPtrInst::getIndexedType(PTy, &Result[0], Result.size(),true);
1954 error("Index list invalid for constant getelementptr");
1959 unsigned upgradeCallingConv(unsigned CC) {
1961 case OldCallingConv::C : return CallingConv::C;
1962 case OldCallingConv::CSRet : return CallingConv::C;
1963 case OldCallingConv::Fast : return CallingConv::Fast;
1964 case OldCallingConv::Cold : return CallingConv::Cold;
1965 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1966 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1972 Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1973 bool debug, bool addAttrs)
1976 CurFilename = infile;
1979 AddAttributes = addAttrs;
1980 ObsoleteVarArgs = false;
1983 CurModule.CurrentModule = new Module(CurFilename);
1985 // Check to make sure the parser succeeded
1988 delete ParserResult;
1989 std::cerr << "llvm-upgrade: parse failed.\n";
1993 // Check to make sure that parsing produced a result
1994 if (!ParserResult) {
1995 std::cerr << "llvm-upgrade: no parse result.\n";
1999 // Reset ParserResult variable while saving its value for the result.
2000 Module *Result = ParserResult;
2003 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
2006 if ((F = Result->getFunction("llvm.va_start"))
2007 && F->getFunctionType()->getNumParams() == 0)
2008 ObsoleteVarArgs = true;
2009 if((F = Result->getFunction("llvm.va_copy"))
2010 && F->getFunctionType()->getNumParams() == 1)
2011 ObsoleteVarArgs = true;
2014 if (ObsoleteVarArgs && NewVarArgs) {
2015 error("This file is corrupt: it uses both new and old style varargs");
2019 if(ObsoleteVarArgs) {
2020 if(Function* F = Result->getFunction("llvm.va_start")) {
2021 if (F->arg_size() != 0) {
2022 error("Obsolete va_start takes 0 argument");
2028 //bar = alloca typeof(foo)
2032 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2033 const Type* ArgTy = F->getFunctionType()->getReturnType();
2034 const Type* ArgTyPtr = PointerType::get(ArgTy);
2035 Function* NF = cast<Function>(Result->getOrInsertFunction(
2036 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
2038 while (!F->use_empty()) {
2039 CallInst* CI = cast<CallInst>(F->use_back());
2040 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
2041 new CallInst(NF, bar, "", CI);
2042 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
2043 CI->replaceAllUsesWith(foo);
2044 CI->getParent()->getInstList().erase(CI);
2046 Result->getFunctionList().erase(F);
2049 if(Function* F = Result->getFunction("llvm.va_end")) {
2050 if(F->arg_size() != 1) {
2051 error("Obsolete va_end takes 1 argument");
2057 //bar = alloca 1 of typeof(foo)
2059 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2060 const Type* ArgTy = F->getFunctionType()->getParamType(0);
2061 const Type* ArgTyPtr = PointerType::get(ArgTy);
2062 Function* NF = cast<Function>(Result->getOrInsertFunction(
2063 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
2065 while (!F->use_empty()) {
2066 CallInst* CI = cast<CallInst>(F->use_back());
2067 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
2068 new StoreInst(CI->getOperand(1), bar, CI);
2069 new CallInst(NF, bar, "", CI);
2070 CI->getParent()->getInstList().erase(CI);
2072 Result->getFunctionList().erase(F);
2075 if(Function* F = Result->getFunction("llvm.va_copy")) {
2076 if(F->arg_size() != 1) {
2077 error("Obsolete va_copy takes 1 argument");
2082 //a = alloca 1 of typeof(foo)
2083 //b = alloca 1 of typeof(foo)
2088 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2089 const Type* ArgTy = F->getFunctionType()->getReturnType();
2090 const Type* ArgTyPtr = PointerType::get(ArgTy);
2091 Function* NF = cast<Function>(Result->getOrInsertFunction(
2092 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
2094 while (!F->use_empty()) {
2095 CallInst* CI = cast<CallInst>(F->use_back());
2096 SmallVector<Value *, 2> Args;
2097 Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI));
2098 Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI));
2099 new StoreInst(CI->getOperand(1), Args[1], CI);
2100 new CallInst(NF, Args.begin(), Args.end(), "", CI);
2101 Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
2102 CI->replaceAllUsesWith(foo);
2103 CI->getParent()->getInstList().erase(CI);
2105 Result->getFunctionList().erase(F);
2112 } // end llvm namespace
2114 using namespace llvm;
2118 /* Enabling traces. */
2123 /* Enabling verbose error messages. */
2124 #ifdef YYERROR_VERBOSE
2125 # undef YYERROR_VERBOSE
2126 # define YYERROR_VERBOSE 1
2128 # define YYERROR_VERBOSE 0
2131 /* Enabling the token table. */
2132 #ifndef YYTOKEN_TABLE
2133 # define YYTOKEN_TABLE 0
2136 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
2137 typedef union YYSTYPE
2138 #line 1748 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
2140 llvm::Module *ModuleVal;
2141 llvm::Function *FunctionVal;
2142 std::pair<llvm::PATypeInfo, char*> *ArgVal;
2143 llvm::BasicBlock *BasicBlockVal;
2144 llvm::TermInstInfo TermInstVal;
2145 llvm::InstrInfo InstVal;
2146 llvm::ConstInfo ConstVal;
2147 llvm::ValueInfo ValueVal;
2148 llvm::PATypeInfo TypeVal;
2149 llvm::TypeInfo PrimType;
2150 llvm::PHIListInfo PHIList;
2151 std::list<llvm::PATypeInfo> *TypeList;
2152 std::vector<llvm::ValueInfo> *ValueList;
2153 std::vector<llvm::ConstInfo> *ConstVector;
2156 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
2157 // Represent the RHS of PHI node
2158 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
2160 llvm::GlobalValue::LinkageTypes Linkage;
2168 char *StrVal; // This memory is strdup'd!
2169 llvm::ValID ValIDVal; // strdup'd memory maybe!
2171 llvm::BinaryOps BinaryOpVal;
2172 llvm::TermOps TermOpVal;
2173 llvm::MemoryOps MemOpVal;
2174 llvm::OtherOps OtherOpVal;
2175 llvm::CastOps CastOpVal;
2176 llvm::ICmpInst::Predicate IPred;
2177 llvm::FCmpInst::Predicate FPred;
2178 llvm::Module::Endianness Endianness;
2180 /* Line 187 of yacc.c. */
2181 #line 2182 "UpgradeParser.tab.c"
2183 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
2184 # define YYSTYPE_IS_DECLARED 1
2185 # define YYSTYPE_IS_TRIVIAL 1
2190 /* Copy the second part of user declarations. */
2193 /* Line 216 of yacc.c. */
2194 #line 2195 "UpgradeParser.tab.c"
2201 typedef YYTYPE_UINT8 yytype_uint8;
2203 typedef unsigned char yytype_uint8;
2207 typedef YYTYPE_INT8 yytype_int8;
2208 #elif (defined __STDC__ || defined __C99__FUNC__ \
2209 || defined __cplusplus || defined _MSC_VER)
2210 typedef signed char yytype_int8;
2212 typedef short int yytype_int8;
2215 #ifdef YYTYPE_UINT16
2216 typedef YYTYPE_UINT16 yytype_uint16;
2218 typedef unsigned short int yytype_uint16;
2222 typedef YYTYPE_INT16 yytype_int16;
2224 typedef short int yytype_int16;
2228 # ifdef __SIZE_TYPE__
2229 # define YYSIZE_T __SIZE_TYPE__
2230 # elif defined size_t
2231 # define YYSIZE_T size_t
2232 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
2233 || defined __cplusplus || defined _MSC_VER)
2234 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2235 # define YYSIZE_T size_t
2237 # define YYSIZE_T unsigned int
2241 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
2246 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
2247 # define YY_(msgid) dgettext ("bison-runtime", msgid)
2251 # define YY_(msgid) msgid
2255 /* Suppress unused-variable warnings by "using" E. */
2256 #if ! defined lint || defined __GNUC__
2257 # define YYUSE(e) ((void) (e))
2259 # define YYUSE(e) /* empty */
2262 /* Identity function, used to suppress warnings about constant conditions. */
2264 # define YYID(n) (n)
2266 #if (defined __STDC__ || defined __C99__FUNC__ \
2267 || defined __cplusplus || defined _MSC_VER)
2280 #if ! defined yyoverflow || YYERROR_VERBOSE
2282 /* The parser invokes alloca or malloc; define the necessary symbols. */
2284 # ifdef YYSTACK_USE_ALLOCA
2285 # if YYSTACK_USE_ALLOCA
2287 # define YYSTACK_ALLOC __builtin_alloca
2288 # elif defined __BUILTIN_VA_ARG_INCR
2289 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
2291 # define YYSTACK_ALLOC __alloca
2292 # elif defined _MSC_VER
2293 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
2294 # define alloca _alloca
2296 # define YYSTACK_ALLOC alloca
2297 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2298 || defined __cplusplus || defined _MSC_VER)
2299 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2301 # define _STDLIB_H 1
2308 # ifdef YYSTACK_ALLOC
2309 /* Pacify GCC's `empty if-body' warning. */
2310 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
2311 # ifndef YYSTACK_ALLOC_MAXIMUM
2312 /* The OS might guarantee only one guard page at the bottom of the stack,
2313 and a page size can be as small as 4096 bytes. So we cannot safely
2314 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
2315 to allow for a few compiler-allocated temporary stack slots. */
2316 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
2319 # define YYSTACK_ALLOC YYMALLOC
2320 # define YYSTACK_FREE YYFREE
2321 # ifndef YYSTACK_ALLOC_MAXIMUM
2322 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
2324 # if (defined __cplusplus && ! defined _STDLIB_H \
2325 && ! ((defined YYMALLOC || defined malloc) \
2326 && (defined YYFREE || defined free)))
2327 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2329 # define _STDLIB_H 1
2333 # define YYMALLOC malloc
2334 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2335 || defined __cplusplus || defined _MSC_VER)
2336 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
2340 # define YYFREE free
2341 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2342 || defined __cplusplus || defined _MSC_VER)
2343 void free (void *); /* INFRINGES ON USER NAME SPACE */
2347 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
2350 #if (! defined yyoverflow \
2351 && (! defined __cplusplus \
2352 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
2354 /* A type that is properly aligned for any stack member. */
2361 /* The size of the maximum gap between one aligned stack and the next. */
2362 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2364 /* The size of an array large to enough to hold all stacks, each with
2366 # define YYSTACK_BYTES(N) \
2367 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
2368 + YYSTACK_GAP_MAXIMUM)
2370 /* Copy COUNT objects from FROM to TO. The source and destination do
2373 # if defined __GNUC__ && 1 < __GNUC__
2374 # define YYCOPY(To, From, Count) \
2375 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2377 # define YYCOPY(To, From, Count) \
2381 for (yyi = 0; yyi < (Count); yyi++) \
2382 (To)[yyi] = (From)[yyi]; \
2388 /* Relocate STACK from its old location to the new one. The
2389 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2390 elements in the stack, and YYPTR gives the new location of the
2391 stack. Advance YYPTR to a properly aligned location for the next
2393 # define YYSTACK_RELOCATE(Stack) \
2396 YYSIZE_T yynewbytes; \
2397 YYCOPY (&yyptr->Stack, Stack, yysize); \
2398 Stack = &yyptr->Stack; \
2399 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2400 yyptr += yynewbytes / sizeof (*yyptr); \
2406 /* YYFINAL -- State number of the termination state. */
2408 /* YYLAST -- Last index in YYTABLE. */
2411 /* YYNTOKENS -- Number of terminals. */
2412 #define YYNTOKENS 166
2413 /* YYNNTS -- Number of nonterminals. */
2415 /* YYNRULES -- Number of rules. */
2416 #define YYNRULES 310
2417 /* YYNRULES -- Number of states. */
2418 #define YYNSTATES 606
2420 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2421 #define YYUNDEFTOK 2
2422 #define YYMAXUTOK 406
2424 #define YYTRANSLATE(YYX) \
2425 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2427 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2428 static const yytype_uint8 yytranslate[] =
2430 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2434 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2436 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2439 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2442 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2455 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2456 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2457 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2458 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2459 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2460 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2461 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2462 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2463 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2464 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2465 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2466 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2467 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2468 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2469 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2470 145, 146, 147, 148, 149, 150, 151
2474 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2476 static const yytype_uint16 yyprhs[] =
2478 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2479 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2480 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2481 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2482 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2483 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2484 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2485 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2486 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2487 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2488 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2489 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2490 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2491 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2492 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2493 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2494 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2495 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2496 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2497 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2498 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2499 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2500 622, 623, 632, 634, 636, 637, 642, 644, 646, 649,
2501 650, 652, 654, 655, 656, 662, 663, 665, 667, 669,
2502 671, 673, 675, 677, 679, 681, 685, 687, 693, 695,
2503 697, 699, 701, 704, 707, 710, 714, 717, 718, 720,
2504 722, 724, 727, 730, 734, 744, 754, 763, 777, 779,
2505 781, 788, 794, 797, 804, 812, 814, 818, 820, 821,
2506 824, 826, 832, 838, 844, 851, 858, 861, 866, 871,
2507 878, 883, 888, 893, 898, 905, 912, 915, 923, 925,
2508 928, 929, 931, 932, 936, 943, 947, 954, 957, 962,
2512 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
2513 static const yytype_int16 yyrhs[] =
2515 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2516 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2517 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2518 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2519 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2520 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2521 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2522 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2523 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2524 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2525 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2526 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2527 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2528 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2529 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2530 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2531 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2532 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2533 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2534 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2535 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2536 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2537 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2538 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2539 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2540 -1, 19, -1, 21, -1, 192, -1, 48, -1, 229,
2541 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2542 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2543 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2544 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2545 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2546 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2547 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2548 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2549 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2550 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2551 191, 39, -1, 191, 229, -1, 191, 197, -1, 191,
2552 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2553 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2554 36, 191, 156, -1, 110, 155, 196, 244, 156, -1,
2555 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2556 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2557 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2558 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2559 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2560 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2561 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2562 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2563 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2564 201, 222, -1, 201, 224, -1, 201, 62, 61, 207,
2565 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2566 -1, 202, 224, -1, 202, 62, 61, 207, -1, -1,
2567 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2568 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2569 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2570 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2571 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2572 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2573 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2574 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2575 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2576 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2577 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2578 183, -1, 29, -1, 162, -1, -1, 181, 220, 217,
2579 218, -1, 30, -1, 163, -1, 232, 221, -1, -1,
2580 45, -1, 47, -1, -1, -1, 31, 225, 223, 226,
2581 217, -1, -1, 63, -1, 3, -1, 4, -1, 7,
2582 -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
2583 -1, 160, 198, 161, -1, 197, -1, 61, 227, 24,
2584 153, 24, -1, 167, -1, 212, -1, 229, -1, 228,
2585 -1, 191, 230, -1, 232, 233, -1, 219, 233, -1,
2586 234, 180, 236, -1, 234, 238, -1, -1, 23, -1,
2587 77, -1, 78, -1, 72, 231, -1, 72, 8, -1,
2588 73, 21, 230, -1, 73, 9, 230, 153, 21, 230,
2589 153, 21, 230, -1, 74, 178, 230, 153, 21, 230,
2590 157, 237, 159, -1, 74, 178, 230, 153, 21, 230,
2591 157, 159, -1, 75, 182, 189, 230, 155, 241, 156,
2592 36, 21, 230, 235, 21, 230, -1, 235, -1, 76,
2593 -1, 237, 178, 228, 153, 21, 230, -1, 178, 228,
2594 153, 21, 230, -1, 180, 243, -1, 191, 157, 230,
2595 153, 230, 159, -1, 239, 153, 157, 230, 153, 230,
2596 159, -1, 231, -1, 240, 153, 231, -1, 240, -1,
2597 -1, 60, 59, -1, 59, -1, 169, 191, 230, 153,
2598 230, -1, 170, 191, 230, 153, 230, -1, 171, 191,
2599 230, 153, 230, -1, 103, 172, 191, 230, 153, 230,
2600 -1, 104, 173, 191, 230, 153, 230, -1, 49, 231,
2601 -1, 174, 231, 153, 231, -1, 175, 231, 36, 191,
2602 -1, 112, 231, 153, 231, 153, 231, -1, 113, 231,
2603 153, 191, -1, 117, 231, 153, 191, -1, 118, 231,
2604 153, 191, -1, 114, 231, 153, 231, -1, 115, 231,
2605 153, 231, 153, 231, -1, 116, 231, 153, 231, 153,
2606 231, -1, 111, 239, -1, 242, 182, 189, 230, 155,
2607 241, 156, -1, 246, -1, 153, 240, -1, -1, 35,
2608 -1, -1, 105, 191, 184, -1, 105, 191, 153, 15,
2609 230, 184, -1, 106, 191, 184, -1, 106, 191, 153,
2610 15, 230, 184, -1, 107, 231, -1, 245, 108, 191,
2611 230, -1, 245, 109, 231, 153, 191, 230, -1, 110,
2615 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2616 static const yytype_uint16 yyrline[] =
2618 0, 1888, 1888, 1889, 1897, 1898, 1908, 1908, 1908, 1908,
2619 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1912, 1912, 1912,
2620 1916, 1916, 1916, 1916, 1916, 1916, 1920, 1920, 1921, 1921,
2621 1922, 1922, 1923, 1923, 1924, 1924, 1928, 1928, 1929, 1929,
2622 1930, 1930, 1931, 1931, 1932, 1932, 1933, 1933, 1934, 1934,
2623 1935, 1936, 1939, 1939, 1939, 1939, 1943, 1943, 1943, 1943,
2624 1943, 1943, 1943, 1944, 1944, 1944, 1944, 1944, 1944, 1950,
2625 1950, 1950, 1950, 1954, 1954, 1954, 1954, 1958, 1958, 1962,
2626 1962, 1967, 1970, 1975, 1976, 1977, 1978, 1979, 1980, 1981,
2627 1982, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 2003,
2628 2004, 2012, 2013, 2021, 2030, 2031, 2038, 2039, 2043, 2047,
2629 2063, 2064, 2071, 2072, 2079, 2087, 2087, 2087, 2087, 2087,
2630 2087, 2087, 2088, 2088, 2088, 2088, 2088, 2093, 2097, 2101,
2631 2106, 2115, 2142, 2148, 2161, 2172, 2176, 2189, 2193, 2207,
2632 2211, 2218, 2219, 2225, 2232, 2244, 2274, 2287, 2310, 2338,
2633 2360, 2371, 2393, 2404, 2413, 2418, 2477, 2484, 2492, 2499,
2634 2506, 2510, 2514, 2523, 2538, 2550, 2559, 2587, 2600, 2609,
2635 2615, 2621, 2632, 2638, 2644, 2655, 2656, 2665, 2666, 2678,
2636 2687, 2688, 2689, 2690, 2691, 2707, 2727, 2729, 2731, 2731,
2637 2738, 2738, 2746, 2746, 2754, 2754, 2763, 2765, 2767, 2772,
2638 2786, 2787, 2791, 2794, 2802, 2806, 2813, 2817, 2821, 2825,
2639 2833, 2833, 2837, 2838, 2842, 2850, 2855, 2863, 2864, 2871,
2640 2878, 2882, 3072, 3072, 3076, 3076, 3086, 3086, 3090, 3095,
2641 3096, 3097, 3101, 3102, 3101, 3114, 3115, 3120, 3121, 3122,
2642 3123, 3127, 3131, 3132, 3133, 3134, 3155, 3159, 3173, 3174,
2643 3179, 3179, 3187, 3197, 3200, 3209, 3220, 3225, 3234, 3245,
2644 3245, 3248, 3252, 3256, 3261, 3271, 3289, 3298, 3371, 3375,
2645 3382, 3394, 3409, 3439, 3449, 3459, 3463, 3470, 3471, 3475,
2646 3478, 3484, 3503, 3521, 3537, 3551, 3565, 3576, 3594, 3603,
2647 3612, 3619, 3640, 3664, 3670, 3676, 3682, 3698, 3791, 3799,
2648 3800, 3804, 3805, 3809, 3815, 3822, 3828, 3835, 3842, 3855,
2653 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2654 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2655 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2656 static const char *const yytname[] =
2658 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2659 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2660 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2661 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2662 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2663 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2664 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2665 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2666 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2667 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2668 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2669 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2670 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2671 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2672 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2673 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2674 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2675 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2676 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2677 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2678 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2679 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2680 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2681 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2682 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2683 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2684 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2685 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2686 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2687 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2688 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2689 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2690 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2691 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2692 "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7",
2693 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2694 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2695 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2696 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2697 "OptVolatile", "MemoryInst", 0
2702 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2704 static const yytype_uint16 yytoknum[] =
2706 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2707 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2708 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2709 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2710 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2711 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2712 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2713 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2714 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2715 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2716 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2717 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2718 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2719 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2720 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2721 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2722 60, 62, 123, 125, 42, 99
2726 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2727 static const yytype_uint8 yyr1[] =
2729 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2730 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2731 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2732 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2733 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2734 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2735 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2736 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2737 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2738 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2739 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2740 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2741 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2742 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2743 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2744 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2745 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2746 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2747 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2748 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2749 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2750 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2751 216, 217, 218, 218, 220, 219, 221, 221, 222, 223,
2752 223, 223, 225, 226, 224, 227, 227, 228, 228, 228,
2753 228, 228, 228, 228, 228, 228, 228, 228, 229, 229,
2754 230, 230, 231, 232, 232, 233, 234, 234, 234, 235,
2755 235, 236, 236, 236, 236, 236, 236, 236, 236, 236,
2756 237, 237, 238, 239, 239, 240, 240, 241, 241, 242,
2757 242, 243, 243, 243, 243, 243, 243, 243, 243, 243,
2758 243, 243, 243, 243, 243, 243, 243, 243, 243, 244,
2759 244, 245, 245, 246, 246, 246, 246, 246, 246, 246,
2763 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2764 static const yytype_uint8 yyr2[] =
2766 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2767 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2768 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2769 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2770 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2771 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2772 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2773 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2774 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2775 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2776 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2777 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2778 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2779 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2780 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2781 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2782 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2783 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2784 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2785 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2786 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2787 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2788 0, 8, 1, 1, 0, 4, 1, 1, 2, 0,
2789 1, 1, 0, 0, 5, 0, 1, 1, 1, 1,
2790 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
2791 1, 1, 2, 2, 2, 3, 2, 0, 1, 1,
2792 1, 2, 2, 3, 9, 9, 8, 13, 1, 1,
2793 6, 5, 2, 6, 7, 1, 3, 1, 0, 2,
2794 1, 5, 5, 5, 6, 6, 2, 4, 4, 6,
2795 4, 4, 4, 4, 6, 6, 2, 7, 1, 2,
2796 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
2800 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2801 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2802 means the default is an error. */
2803 static const yytype_uint16 yydefact[] =
2805 198, 0, 90, 184, 1, 183, 232, 83, 84, 85,
2806 86, 87, 88, 89, 0, 224, 257, 180, 181, 257,
2807 210, 211, 0, 0, 0, 90, 0, 186, 229, 0,
2808 91, 258, 254, 82, 226, 227, 228, 253, 0, 0,
2809 0, 0, 196, 0, 0, 0, 0, 0, 0, 0,
2810 81, 230, 231, 233, 199, 182, 0, 92, 93, 94,
2811 95, 96, 97, 0, 0, 302, 256, 0, 0, 0,
2812 0, 209, 197, 187, 2, 3, 111, 115, 116, 117,
2813 118, 119, 120, 121, 122, 123, 124, 125, 126, 128,
2814 0, 0, 0, 0, 248, 185, 0, 110, 127, 114,
2815 249, 129, 177, 178, 0, 0, 0, 0, 91, 98,
2816 0, 222, 223, 225, 301, 0, 280, 0, 0, 0,
2817 0, 91, 269, 259, 260, 6, 7, 8, 9, 10,
2818 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2819 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2820 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2821 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2822 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2823 0, 268, 255, 91, 272, 0, 298, 204, 201, 200,
2824 202, 203, 205, 208, 0, 130, 0, 0, 0, 113,
2825 135, 139, 0, 144, 138, 192, 194, 190, 115, 116,
2826 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2827 0, 0, 0, 188, 234, 0, 0, 286, 279, 262,
2828 261, 0, 0, 72, 76, 71, 75, 70, 74, 69,
2829 73, 77, 78, 0, 0, 26, 27, 28, 29, 30,
2830 31, 32, 33, 34, 35, 0, 50, 51, 46, 47,
2831 48, 49, 36, 37, 38, 39, 40, 41, 42, 43,
2832 44, 45, 0, 101, 101, 307, 0, 0, 296, 0,
2833 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2834 0, 0, 0, 0, 0, 206, 0, 0, 0, 0,
2835 0, 134, 143, 141, 0, 106, 106, 106, 160, 161,
2836 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2837 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2838 0, 0, 0, 0, 156, 155, 106, 220, 237, 238,
2839 239, 244, 240, 241, 242, 243, 235, 0, 246, 251,
2840 250, 252, 0, 263, 0, 0, 0, 0, 0, 303,
2841 0, 305, 300, 0, 0, 0, 0, 0, 0, 0,
2842 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2843 207, 112, 112, 137, 0, 140, 0, 131, 0, 193,
2844 195, 191, 0, 0, 0, 0, 0, 0, 0, 146,
2845 176, 0, 0, 0, 150, 0, 147, 0, 0, 0,
2846 0, 0, 189, 219, 213, 216, 217, 0, 236, 0,
2847 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2848 310, 0, 0, 0, 290, 293, 0, 0, 291, 292,
2849 0, 0, 0, 287, 288, 0, 308, 0, 132, 133,
2850 136, 142, 0, 0, 108, 106, 0, 0, 300, 0,
2851 0, 0, 0, 0, 145, 135, 114, 0, 148, 149,
2852 0, 0, 0, 0, 0, 212, 214, 0, 104, 0,
2853 245, 0, 0, 278, 0, 0, 101, 102, 101, 275,
2854 299, 0, 0, 0, 0, 0, 281, 282, 283, 278,
2855 0, 103, 109, 107, 0, 0, 0, 0, 0, 0,
2856 0, 175, 152, 0, 0, 0, 0, 0, 0, 218,
2857 215, 105, 99, 0, 0, 0, 277, 0, 284, 285,
2858 0, 304, 306, 0, 0, 0, 289, 294, 295, 0,
2859 309, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2860 0, 0, 0, 0, 0, 221, 247, 0, 0, 0,
2861 276, 273, 0, 297, 0, 0, 0, 172, 0, 0,
2862 166, 167, 168, 171, 163, 100, 0, 266, 0, 0,
2863 0, 274, 169, 170, 0, 0, 0, 264, 0, 265,
2864 0, 0, 165, 173, 174, 0, 0, 0, 0, 0,
2865 0, 271, 0, 0, 270, 267
2868 /* YYDEFGOTO[NTERM-NUM]. */
2869 static const yytype_int16 yydefgoto[] =
2871 -1, 94, 312, 329, 330, 331, 255, 272, 332, 333,
2872 219, 220, 243, 221, 25, 15, 63, 555, 359, 454,
2873 522, 389, 455, 95, 96, 222, 98, 99, 202, 304,
2874 400, 348, 401, 104, 1, 2, 3, 336, 307, 305,
2875 306, 55, 190, 42, 72, 194, 100, 476, 415, 416,
2876 417, 64, 113, 16, 30, 36, 17, 53, 18, 28,
2877 108, 419, 349, 101, 351, 489, 19, 32, 33, 181,
2878 182, 579, 66, 278, 526, 527, 183, 184, 430, 185,
2882 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2884 #define YYPACT_NINF -542
2885 static const yytype_int16 yypact[] =
2887 -542, 13, 162, 567, -542, -542, -542, -542, -542, -542,
2888 -542, -542, -542, -542, 83, -542, 19, -542, -542, -14,
2889 -542, -542, 50, -87, 87, 233, 27, -542, 123, 141,
2890 175, -542, -542, 98, -542, -542, -542, -542, 33, 40,
2891 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156,
2892 -542, -542, -542, -542, -542, -542, 221, -542, -542, -542,
2893 -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226,
2894 227, 235, -542, -542, -542, -542, 81, -542, -542, -542,
2895 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2896 256, 257, 4, 15, -542, -542, 108, -542, -542, 12,
2897 -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542,
2898 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116,
2899 479, 175, -542, -542, -542, -542, -542, -542, -542, -542,
2900 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2901 -542, -542, -542, -542, -542, -542, -542, -542, -542, 355,
2902 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306,
2903 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542,
2904 -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306,
2905 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542,
2906 -542, -542, -542, -542, -13, -542, 110, 111, 75, -542,
2907 -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208,
2908 266, 210, 267, 212, 268, 230, 277, 275, 278, 246,
2909 280, 279, 566, -542, -542, 136, 766, -542, -542, 81,
2910 -542, 766, 766, -542, -542, -542, -542, -542, -542, -542,
2911 -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542,
2912 -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542,
2913 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2914 -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147,
2915 148, 149, 151, 152, 158, 160, 766, 766, 766, 161,
2916 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27,
2917 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542,
2918 -542, -542, -542, -542, -542, -542, -542, -542, 355, 429,
2919 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184,
2920 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542,
2921 -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542,
2922 -542, -542, 193, -542, 194, 766, 766, 766, 7, -542,
2923 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306,
2924 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207,
2925 -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542,
2926 -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542,
2927 -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326,
2928 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337,
2929 -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306,
2930 -542, 223, 766, 224, -542, -542, 225, 234, -542, -542,
2931 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542,
2932 -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236,
2933 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542,
2934 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252,
2935 -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542,
2936 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306,
2937 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326,
2938 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542,
2939 -542, -542, 368, 402, 274, 276, 259, 287, -542, -542,
2940 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290,
2941 -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296,
2942 297, 299, 302, 303, 430, -542, -542, 414, 41, 425,
2943 -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326,
2944 -542, -542, -542, -542, -542, -542, 766, -542, 893, 144,
2945 448, -542, -542, -542, 314, 315, 316, -542, 331, -542,
2946 893, 766, -542, -542, -542, 464, 334, 180, 766, 481,
2947 482, -542, 766, 766, -542, -542
2950 /* YYPGOTO[NTERM-NUM]. */
2951 static const yytype_int16 yypgoto[] =
2953 -542, -542, -542, 435, 439, 441, 191, 197, 442, 445,
2954 -119, -116, -541, -542, 478, 489, -107, -542, -267, 37,
2955 -542, -238, -542, -60, -542, -45, -542, -74, -51, -542,
2956 -101, 300, -252, 134, -542, -542, -542, -542, -542, -542,
2957 -542, 473, -542, -542, -542, -542, 8, -542, 46, -542,
2958 -542, 410, -542, -542, -542, -542, -542, -542, 518, -542,
2959 -542, -542, -528, 142, -90, -113, -542, 505, -542, -72,
2960 -542, -542, -542, -542, 97, 28, -542, -542, 70, -542,
2964 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2965 positive, shift that token. If negative, reduce the rule which
2966 number is the opposite. If zero, do what YYDEFACT says.
2967 If YYTABLE_NINF, syntax error. */
2968 #define YYTABLE_NINF -180
2969 static const yytype_int16 yytable[] =
2971 97, 241, 227, 110, 242, 230, 223, 361, 197, 31,
2972 111, 26, 449, 4, 244, 204, 34, 578, 97, 201,
2973 74, 75, 426, 199, 77, 78, 79, 80, 81, 82,
2974 83, 84, 85, 86, 87, 428, 88, 20, 590, 21,
2975 275, 26, 31, 279, 280, 281, 282, 283, 284, 285,
2976 588, 233, 234, 235, 236, 237, 238, 239, 240, 205,
2977 206, 207, 596, 89, 427, 43, 289, 290, 390, 391,
2978 226, 463, 300, 226, 403, 405, 291, 427, 452, 468,
2979 74, 75, 301, 199, 77, 78, 79, 80, 81, 82,
2980 83, 84, 85, 86, 87, 420, 88, 20, 412, 21,
2981 448, 453, 38, 39, 40, 204, 273, 274, 226, 276,
2982 277, 226, 226, 226, 226, 226, 226, 226, 225, 463,
2983 20, 41, 21, 89, 201, 231, 300, 480, -139, 201,
2984 -112, 286, 287, 288, 226, 226, 384, 232, -139, 204,
2985 294, 352, 353, 112, 29, 463, 295, 299, 44, 35,
2986 467, 464, 303, 354, 233, 234, 235, 236, 237, 238,
2987 239, 240, -179, 463, 463, 54, 198, -112, 51, 90,
2988 52, 71, 91, 469, 513, 92, 204, 93, 200, 50,
2989 379, 105, 106, 107, 355, 67, 362, 5, 102, 103,
2990 188, 189, 68, 6, 292, 293, 372, 373, 374, 97,
2991 577, 308, 309, 7, 8, 9, 10, 11, 12, 13,
2992 356, -72, -72, -71, -71, -70, -70, 503, 69, 531,
2993 70, 532, 381, 382, 14, 109, 385, 357, 187, 90,
2994 191, 377, 91, -69, -69, 92, -113, 93, 298, 56,
2995 57, 58, 59, 60, 61, 62, 97, 378, 226, 310,
2996 311, 192, 433, 45, 435, 436, 437, 123, 124, 193,
2997 195, 196, 443, 203, 228, 423, 424, 425, 296, 297,
2998 -76, -75, -74, 431, 7, 8, 9, 10, 46, 12,
2999 47, -73, -79, 48, 313, -80, 314, 445, 446, 363,
3000 358, 337, 414, 458, 459, 460, 461, 462, 360, 364,
3001 365, 366, 367, 589, 368, 369, 470, 471, 472, 473,
3002 474, 370, 385, 371, 375, 380, 383, 376, 386, 387,
3003 226, 434, 226, 226, 226, 438, 439, 394, 466, 388,
3004 226, 444, 395, 396, 397, 406, 486, 398, 488, 407,
3005 408, 409, 492, 410, 411, 418, 421, 422, 429, 432,
3006 496, 497, 498, 440, 441, 504, 505, 450, 456, 442,
3007 447, 479, 511, 481, 335, 478, 457, 477, 350, 482,
3008 483, 484, 485, 350, 350, 487, 491, 493, 494, 502,
3009 536, 537, 538, 499, 226, 350, 501, 495, 518, 507,
3010 508, 524, 525, 509, 528, 529, 510, 514, 515, 512,
3011 516, 534, 500, 517, 452, 523, 544, 545, 546, 547,
3012 540, 530, 533, 549, 550, 551, 552, 535, 350, 543,
3013 560, 548, 475, 541, 542, 554, 556, 557, 350, 350,
3014 350, 427, 414, 558, 575, 576, 566, 568, 226, 241,
3015 564, 565, 242, 559, 561, 562, 563, 569, 226, 226,
3016 226, 567, 570, 571, 226, 572, 256, 257, 573, 574,
3017 241, 580, 582, 242, 581, 584, 583, 585, 586, 591,
3018 592, 593, 594, 553, 245, 246, 247, 248, 249, 250,
3019 251, 252, 253, 254, 595, 598, 587, 599, 226, 233,
3020 234, 235, 236, 237, 238, 239, 240, 350, 350, 350,
3021 176, 597, 602, 603, 177, 350, 178, 179, 601, 392,
3022 180, 65, 604, 605, 49, 521, 393, 73, 224, 350,
3023 350, 27, 334, 520, 37, 600, 490, 539, 506, 0,
3024 0, 0, 0, 0, 74, 75, 0, 199, 208, 209,
3025 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
3026 88, 20, 0, 21, 258, 259, 260, 261, 262, 263,
3027 264, 265, 266, 267, 268, 269, 270, 271, 350, 0,
3028 350, 74, 75, 0, 350, 0, 0, 89, 0, 0,
3029 0, 0, 350, 350, 350, 0, 0, -82, 20, 20,
3030 21, 21, 315, 0, 0, 0, 0, 0, 6, -82,
3031 -82, 0, 0, 0, 316, 317, 0, 0, -82, -82,
3032 -82, -82, -82, -82, -82, 0, 0, -82, 22, 0,
3033 0, 0, 0, 350, 350, 23, 350, 350, 0, 24,
3034 0, 0, 0, 350, 0, 0, 0, 0, 0, 0,
3035 0, 0, 350, 0, 0, 125, 126, 127, 128, 129,
3036 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
3037 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
3038 319, 0, 0, 0, 0, 0, 320, 350, 321, 0,
3039 322, 323, 324, 90, 0, 0, 91, 0, 0, 92,
3040 0, 93, 404, 0, 0, 0, 0, 0, 0, 0,
3041 0, 0, 0, 0, 0, 163, 164, 165, 166, 167,
3042 168, 169, 170, 171, 172, 173, 174, 175, 350, 0,
3043 0, 0, 0, 325, 0, 0, 326, 0, 327, 0,
3044 0, 328, 0, 350, 0, 0, 0, 0, 0, 0,
3045 350, 0, 0, 0, 350, 350, 74, 75, 0, 199,
3046 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
3047 218, 0, 88, 20, 0, 21, 0, 0, 0, 338,
3048 339, 74, 75, 340, 0, 0, 0, 0, 0, 0,
3049 0, 0, 0, 0, 0, 0, 0, 0, 20, 89,
3050 21, 0, 341, 342, 343, 0, 0, 0, 0, 0,
3051 0, 0, 0, 0, 344, 345, 0, 0, 0, 0,
3052 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3053 0, 0, 0, 0, 0, 0, 0, 346, 0, 0,
3054 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3055 0, 0, 0, 0, 0, 125, 126, 127, 128, 129,
3056 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
3057 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
3058 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
3059 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
3060 0, 0, 0, 0, 0, 90, 338, 339, 91, 0,
3061 340, 92, 0, 93, 465, 163, 164, 165, 166, 167,
3062 168, 169, 170, 171, 172, 173, 174, 175, 0, 341,
3063 342, 343, 0, 0, 0, 0, 347, 0, 0, 0,
3064 0, 344, 345, 0, 0, 0, 0, 0, 0, 0,
3065 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3066 0, 0, 0, 0, 346, 0, 0, 0, 0, 0,
3067 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3068 0, 0, 125, 126, 127, 128, 129, 130, 131, 132,
3069 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
3070 143, 144, 145, 146, 147, 148, 318, 319, 0, 0,
3071 0, 0, 0, 320, 0, 321, 0, 322, 323, 324,
3072 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3073 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3074 0, 0, 163, 164, 165, 166, 167, 168, 169, 170,
3075 171, 172, 173, 174, 175, 0, 0, 0, 0, 0,
3076 0, 74, 75, 347, 199, 77, 78, 79, 80, 81,
3077 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
3078 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3079 0, 0, 0, 302, 0, 0, 0, 0, 0, 0,
3080 0, 0, 74, 75, 89, 199, 208, 209, 210, 211,
3081 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3082 0, 21, 74, 75, 0, 199, 77, 78, 79, 80,
3083 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3084 0, 21, 0, 0, 0, 89, 0, 0, 0, 0,
3085 0, 0, 0, 0, 413, 0, 0, 0, 0, 0,
3086 0, 0, 0, 74, 75, 89, 199, 77, 78, 79,
3087 80, 81, 82, 83, 84, 85, 86, 87, 0, 88,
3088 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
3089 0, 0, 0, 0, 0, 451, 0, 0, 0, 0,
3090 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
3091 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
3092 74, 75, 0, 199, 77, 78, 79, 80, 81, 82,
3093 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
3094 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3095 0, 90, 519, 0, 91, 0, 399, 92, 0, 93,
3096 0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
3097 0, 90, 0, 0, 91, 0, 0, 92, 0, 93,
3098 74, 75, 0, 76, 77, 78, 79, 80, 81, 82,
3099 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
3100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3101 0, 0, 90, 0, 0, 91, 0, 0, 92, 0,
3102 93, 74, 75, 89, 199, 77, 78, 79, 80, 81,
3103 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
3104 21, 74, 75, 0, 199, 208, 209, 210, 211, 212,
3105 213, 214, 215, 216, 217, 218, 0, 88, 20, 0,
3106 21, 0, 0, 0, 89, 0, 0, 0, 0, 90,
3107 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3108 0, 0, 74, 75, 89, 229, 77, 78, 79, 80,
3109 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3110 0, 21, 74, 75, 0, 199, 208, 209, 210, 211,
3111 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3112 0, 21, 0, 0, 0, 89, 0, 0, 0, 90,
3113 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3114 0, 0, 0, 0, 0, 89, 0, 0, 0, 0,
3115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3117 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
3118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3119 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
3120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3122 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
3123 0, 90, 0, 0, 91, 0, 0, 92, 115, 93,
3124 0, 0, 0, 0, 0, 0, 0, 0, 116, 117,
3125 0, 90, 0, 0, 91, 0, 0, 92, 0, 402,
3126 0, 118, 119, 120, 121, 122, 123, 124, 125, 126,
3127 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3128 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
3129 147, 148, 149, 150, 151, 152, 153, 0, 0, 154,
3130 155, 156, 157, 158, 159, 160, 161, 162, 0, 0,
3131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3132 0, 0, 0, 0, 0, 0, 0, 0, 163, 164,
3133 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
3137 static const yytype_int16 yycheck[] =
3139 45, 120, 115, 63, 120, 118, 107, 274, 4, 23,
3140 29, 3, 161, 0, 121, 164, 30, 558, 63, 93,
3141 5, 6, 15, 8, 9, 10, 11, 12, 13, 14,
3142 15, 16, 17, 18, 19, 15, 21, 22, 579, 24,
3143 153, 33, 23, 156, 157, 158, 159, 160, 161, 162,
3144 578, 10, 11, 12, 13, 14, 15, 16, 17, 104,
3145 105, 106, 590, 48, 57, 152, 179, 180, 306, 307,
3146 115, 153, 153, 118, 326, 327, 183, 57, 34, 161,
3147 5, 6, 163, 8, 9, 10, 11, 12, 13, 14,
3148 15, 16, 17, 18, 19, 347, 21, 22, 336, 24,
3149 159, 57, 52, 53, 54, 164, 151, 152, 153, 154,
3150 155, 156, 157, 158, 159, 160, 161, 162, 110, 153,
3151 22, 71, 24, 48, 198, 9, 153, 161, 153, 203,
3152 155, 176, 177, 178, 179, 180, 163, 21, 163, 164,
3153 153, 231, 232, 162, 61, 153, 159, 198, 61, 163,
3154 402, 159, 203, 243, 10, 11, 12, 13, 14, 15,
3155 16, 17, 0, 153, 153, 24, 162, 155, 45, 154,
3156 47, 157, 157, 163, 163, 160, 164, 162, 163, 152,
3157 293, 47, 48, 49, 244, 152, 276, 25, 32, 33,
3158 55, 56, 152, 31, 108, 109, 286, 287, 288, 244,
3159 159, 27, 28, 41, 42, 43, 44, 45, 46, 47,
3160 255, 3, 4, 3, 4, 3, 4, 455, 152, 486,
3161 152, 488, 296, 297, 62, 4, 300, 272, 24, 154,
3162 4, 291, 157, 3, 4, 160, 155, 162, 163, 64,
3163 65, 66, 67, 68, 69, 70, 291, 292, 293, 3,
3164 4, 24, 365, 20, 367, 368, 369, 77, 78, 24,
3165 4, 4, 375, 155, 59, 355, 356, 357, 158, 158,
3166 4, 4, 4, 363, 41, 42, 43, 44, 45, 46,
3167 47, 4, 7, 50, 4, 7, 7, 377, 378, 157,
3168 153, 155, 337, 394, 395, 396, 397, 398, 153, 153,
3169 153, 153, 153, 159, 153, 153, 407, 408, 409, 410,
3170 411, 153, 386, 153, 153, 24, 161, 36, 153, 156,
3171 365, 366, 367, 368, 369, 370, 371, 155, 402, 153,
3172 375, 376, 155, 155, 155, 24, 426, 155, 428, 155,
3173 155, 155, 432, 155, 155, 63, 153, 153, 153, 157,
3174 440, 441, 442, 153, 153, 456, 457, 161, 155, 153,
3175 153, 24, 463, 21, 222, 156, 155, 153, 226, 21,
3176 155, 153, 153, 231, 232, 4, 153, 153, 153, 4,
3177 493, 494, 495, 155, 429, 243, 24, 153, 36, 153,
3178 153, 481, 482, 153, 484, 485, 153, 153, 153, 161,
3179 153, 491, 447, 153, 34, 153, 507, 508, 509, 510,
3180 500, 153, 153, 514, 515, 516, 517, 153, 276, 156,
3181 533, 161, 414, 153, 153, 57, 24, 153, 286, 287,
3182 288, 57, 477, 157, 4, 21, 153, 153, 483, 558,
3183 541, 542, 558, 156, 159, 535, 156, 153, 493, 494,
3184 495, 156, 156, 156, 499, 156, 27, 28, 156, 156,
3185 579, 36, 156, 579, 159, 566, 156, 568, 569, 21,
3186 156, 156, 156, 518, 119, 120, 121, 122, 123, 124,
3187 125, 126, 127, 128, 153, 21, 576, 153, 533, 10,
3188 11, 12, 13, 14, 15, 16, 17, 355, 356, 357,
3189 65, 591, 21, 21, 65, 363, 65, 65, 598, 318,
3190 65, 33, 602, 603, 25, 478, 319, 44, 108, 377,
3191 378, 3, 222, 477, 19, 597, 429, 499, 458, -1,
3192 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
3193 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3194 21, 22, -1, 24, 125, 126, 127, 128, 129, 130,
3195 131, 132, 133, 134, 135, 136, 137, 138, 426, -1,
3196 428, 5, 6, -1, 432, -1, -1, 48, -1, -1,
3197 -1, -1, 440, 441, 442, -1, -1, 20, 22, 22,
3198 24, 24, 26, -1, -1, -1, -1, -1, 31, 32,
3199 33, -1, -1, -1, 38, 39, -1, -1, 41, 42,
3200 43, 44, 45, 46, 47, -1, -1, 50, 51, -1,
3201 -1, -1, -1, 481, 482, 58, 484, 485, -1, 62,
3202 -1, -1, -1, 491, -1, -1, -1, -1, -1, -1,
3203 -1, -1, 500, -1, -1, 79, 80, 81, 82, 83,
3204 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3205 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3206 104, -1, -1, -1, -1, -1, 110, 535, 112, -1,
3207 114, 115, 116, 154, -1, -1, 157, -1, -1, 160,
3208 -1, 162, 163, -1, -1, -1, -1, -1, -1, -1,
3209 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
3210 144, 145, 146, 147, 148, 149, 150, 151, 576, -1,
3211 -1, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3212 -1, 165, -1, 591, -1, -1, -1, -1, -1, -1,
3213 598, -1, -1, -1, 602, 603, 5, 6, -1, 8,
3214 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
3215 19, -1, 21, 22, -1, 24, -1, -1, -1, 3,
3216 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
3217 -1, -1, -1, -1, -1, -1, -1, -1, 22, 48,
3218 24, -1, 26, 27, 28, -1, -1, -1, -1, -1,
3219 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
3220 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3221 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
3222 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3223 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
3224 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3225 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3226 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
3227 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
3228 -1, -1, -1, -1, -1, 154, 3, 4, 157, -1,
3229 7, 160, -1, 162, 163, 139, 140, 141, 142, 143,
3230 144, 145, 146, 147, 148, 149, 150, 151, -1, 26,
3231 27, 28, -1, -1, -1, -1, 160, -1, -1, -1,
3232 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
3233 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3234 -1, -1, -1, -1, 61, -1, -1, -1, -1, -1,
3235 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3236 -1, -1, 79, 80, 81, 82, 83, 84, 85, 86,
3237 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
3238 97, 98, 99, 100, 101, 102, 103, 104, -1, -1,
3239 -1, -1, -1, 110, -1, 112, -1, 114, 115, 116,
3240 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3241 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3242 -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
3243 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
3244 -1, 5, 6, 160, 8, 9, 10, 11, 12, 13,
3245 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3246 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3247 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
3248 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
3249 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3250 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3251 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3252 -1, 24, -1, -1, -1, 48, -1, -1, -1, -1,
3253 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
3254 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
3255 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
3256 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
3257 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
3258 -1, -1, -1, -1, -1, -1, 48, -1, -1, -1,
3259 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3260 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3261 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
3262 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3263 -1, 154, 37, -1, 157, -1, 159, 160, -1, 162,
3264 -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
3265 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3266 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3267 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
3268 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3269 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
3270 162, 5, 6, 48, 8, 9, 10, 11, 12, 13,
3271 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3272 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
3273 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3274 24, -1, -1, -1, 48, -1, -1, -1, -1, 154,
3275 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3276 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
3277 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3278 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3279 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3280 -1, 24, -1, -1, -1, 48, -1, -1, -1, 154,
3281 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3282 -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
3283 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3284 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3285 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3287 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3290 -1, -1, -1, -1, 35, -1, -1, -1, -1, -1,
3291 -1, 154, -1, -1, 157, -1, -1, 160, 49, 162,
3292 -1, -1, -1, -1, -1, -1, -1, -1, 59, 60,
3293 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3294 -1, 72, 73, 74, 75, 76, 77, 78, 79, 80,
3295 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
3296 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
3297 101, 102, 103, 104, 105, 106, 107, -1, -1, 110,
3298 111, 112, 113, 114, 115, 116, 117, 118, -1, -1,
3299 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3300 -1, -1, -1, -1, -1, -1, -1, -1, 139, 140,
3301 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
3305 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
3306 symbol of state STATE-NUM. */
3307 static const yytype_uint8 yystos[] =
3309 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
3310 44, 45, 46, 47, 62, 181, 219, 222, 224, 232,
3311 22, 24, 51, 58, 62, 180, 212, 224, 225, 61,
3312 220, 23, 233, 234, 30, 163, 221, 233, 52, 53,
3313 54, 71, 209, 152, 61, 20, 45, 47, 50, 181,
3314 152, 45, 47, 223, 24, 207, 64, 65, 66, 67,
3315 68, 69, 70, 182, 217, 180, 238, 152, 152, 152,
3316 152, 157, 210, 207, 5, 6, 8, 9, 10, 11,
3317 12, 13, 14, 15, 16, 17, 18, 19, 21, 48,
3318 154, 157, 160, 162, 167, 189, 190, 191, 192, 193,
3319 212, 229, 32, 33, 199, 199, 199, 199, 226, 4,
3320 189, 29, 162, 218, 35, 49, 59, 60, 72, 73,
3321 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
3322 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3323 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3324 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
3325 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
3326 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
3327 175, 235, 236, 242, 243, 245, 246, 24, 55, 56,
3328 208, 4, 24, 24, 211, 4, 4, 4, 162, 8,
3329 163, 193, 194, 155, 164, 191, 191, 191, 9, 10,
3330 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
3331 177, 179, 191, 196, 217, 212, 191, 231, 59, 8,
3332 231, 9, 21, 10, 11, 12, 13, 14, 15, 16,
3333 17, 176, 177, 178, 182, 119, 120, 121, 122, 123,
3334 124, 125, 126, 127, 128, 172, 27, 28, 125, 126,
3335 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3336 137, 138, 173, 191, 191, 231, 191, 191, 239, 231,
3337 231, 231, 231, 231, 231, 231, 191, 191, 191, 231,
3338 231, 182, 108, 109, 153, 159, 158, 158, 163, 194,
3339 153, 163, 37, 194, 195, 205, 206, 204, 27, 28,
3340 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
3341 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
3342 170, 171, 174, 175, 197, 229, 203, 155, 3, 4,
3343 7, 26, 27, 28, 38, 39, 61, 160, 197, 228,
3344 229, 230, 230, 230, 230, 189, 191, 191, 153, 184,
3345 153, 184, 230, 157, 153, 153, 153, 153, 153, 153,
3346 153, 153, 230, 230, 230, 153, 36, 189, 191, 231,
3347 24, 193, 193, 161, 163, 193, 153, 156, 153, 187,
3348 187, 187, 172, 173, 155, 155, 155, 155, 155, 159,
3349 196, 198, 162, 198, 163, 198, 24, 155, 155, 155,
3350 155, 155, 187, 37, 191, 214, 215, 216, 63, 227,
3351 198, 153, 153, 230, 230, 230, 15, 57, 15, 153,
3352 244, 230, 157, 231, 191, 231, 231, 231, 191, 191,
3353 153, 153, 153, 231, 191, 230, 230, 153, 159, 161,
3354 161, 37, 34, 57, 185, 188, 155, 155, 196, 196,
3355 196, 196, 196, 153, 159, 163, 193, 198, 161, 163,
3356 196, 196, 196, 196, 196, 212, 213, 153, 156, 24,
3357 161, 21, 21, 155, 153, 153, 230, 4, 230, 231,
3358 240, 153, 230, 153, 153, 153, 230, 230, 230, 155,
3359 191, 24, 4, 187, 196, 196, 244, 153, 153, 153,
3360 153, 196, 161, 163, 153, 153, 153, 153, 36, 37,
3361 214, 185, 186, 153, 230, 230, 240, 241, 230, 230,
3362 153, 184, 184, 153, 230, 153, 231, 231, 231, 241,
3363 230, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3364 196, 196, 196, 191, 57, 183, 24, 153, 157, 156,
3365 231, 159, 230, 156, 196, 196, 153, 156, 153, 153,
3366 156, 156, 156, 156, 156, 4, 21, 159, 178, 237,
3367 36, 159, 156, 156, 196, 196, 196, 230, 228, 159,
3368 178, 21, 156, 156, 156, 153, 228, 230, 21, 153,
3369 235, 230, 21, 21, 230, 230
3372 #define yyerrok (yyerrstatus = 0)
3373 #define yyclearin (yychar = YYEMPTY)
3374 #define YYEMPTY (-2)
3377 #define YYACCEPT goto yyacceptlab
3378 #define YYABORT goto yyabortlab
3379 #define YYERROR goto yyerrorlab
3382 /* Like YYERROR except do call yyerror. This remains here temporarily
3383 to ease the transition to the new meaning of YYERROR, for GCC.
3384 Once GCC version 2 has supplanted version 1, this can go. */
3386 #define YYFAIL goto yyerrlab
3388 #define YYRECOVERING() (!!yyerrstatus)
3390 #define YYBACKUP(Token, Value) \
3392 if (yychar == YYEMPTY && yylen == 1) \
3396 yytoken = YYTRANSLATE (yychar); \
3402 yyerror (YY_("syntax error: cannot back up")); \
3409 #define YYERRCODE 256
3412 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3413 If N is 0, then set CURRENT to the empty location which ends
3414 the previous symbol: RHS[0] (always defined). */
3416 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
3417 #ifndef YYLLOC_DEFAULT
3418 # define YYLLOC_DEFAULT(Current, Rhs, N) \
3422 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3423 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3424 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3425 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3429 (Current).first_line = (Current).last_line = \
3430 YYRHSLOC (Rhs, 0).last_line; \
3431 (Current).first_column = (Current).last_column = \
3432 YYRHSLOC (Rhs, 0).last_column; \
3438 /* YY_LOCATION_PRINT -- Print the location on the stream.
3439 This macro was not mandated originally: define only if we know
3440 we won't break user code: when these are the locations we know. */
3442 #ifndef YY_LOCATION_PRINT
3443 # if YYLTYPE_IS_TRIVIAL
3444 # define YY_LOCATION_PRINT(File, Loc) \
3445 fprintf (File, "%d.%d-%d.%d", \
3446 (Loc).first_line, (Loc).first_column, \
3447 (Loc).last_line, (Loc).last_column)
3449 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3454 /* YYLEX -- calling `yylex' with the right arguments. */
3457 # define YYLEX yylex (YYLEX_PARAM)
3459 # define YYLEX yylex ()
3462 /* Enable debugging if requested. */
3466 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3467 # define YYFPRINTF fprintf
3470 # define YYDPRINTF(Args) \
3476 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3480 YYFPRINTF (stderr, "%s ", Title); \
3481 yy_symbol_print (stderr, \
3483 YYFPRINTF (stderr, "\n"); \
3488 /*--------------------------------.
3489 | Print this symbol on YYOUTPUT. |
3490 `--------------------------------*/
3493 #if (defined __STDC__ || defined __C99__FUNC__ \
3494 || defined __cplusplus || defined _MSC_VER)
3496 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3499 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
3502 YYSTYPE const * const yyvaluep;
3508 if (yytype < YYNTOKENS)
3509 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3521 /*--------------------------------.
3522 | Print this symbol on YYOUTPUT. |
3523 `--------------------------------*/
3525 #if (defined __STDC__ || defined __C99__FUNC__ \
3526 || defined __cplusplus || defined _MSC_VER)
3528 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3531 yy_symbol_print (yyoutput, yytype, yyvaluep)
3534 YYSTYPE const * const yyvaluep;
3537 if (yytype < YYNTOKENS)
3538 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3540 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3542 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3543 YYFPRINTF (yyoutput, ")");
3546 /*------------------------------------------------------------------.
3547 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
3549 `------------------------------------------------------------------*/
3551 #if (defined __STDC__ || defined __C99__FUNC__ \
3552 || defined __cplusplus || defined _MSC_VER)
3554 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3557 yy_stack_print (bottom, top)
3558 yytype_int16 *bottom;
3562 YYFPRINTF (stderr, "Stack now");
3563 for (; bottom <= top; ++bottom)
3564 YYFPRINTF (stderr, " %d", *bottom);
3565 YYFPRINTF (stderr, "\n");
3568 # define YY_STACK_PRINT(Bottom, Top) \
3571 yy_stack_print ((Bottom), (Top)); \
3575 /*------------------------------------------------.
3576 | Report that the YYRULE is going to be reduced. |
3577 `------------------------------------------------*/
3579 #if (defined __STDC__ || defined __C99__FUNC__ \
3580 || defined __cplusplus || defined _MSC_VER)
3582 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3585 yy_reduce_print (yyvsp, yyrule)
3590 int yynrhs = yyr2[yyrule];
3592 unsigned long int yylno = yyrline[yyrule];
3593 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3595 /* The symbols being reduced. */
3596 for (yyi = 0; yyi < yynrhs; yyi++)
3598 fprintf (stderr, " $%d = ", yyi + 1);
3599 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3600 &(yyvsp[(yyi + 1) - (yynrhs)])
3602 fprintf (stderr, "\n");
3606 # define YY_REDUCE_PRINT(Rule) \
3609 yy_reduce_print (yyvsp, Rule); \
3612 /* Nonzero means print parse trace. It is left uninitialized so that
3613 multiple parsers can coexist. */
3615 #else /* !YYDEBUG */
3616 # define YYDPRINTF(Args)
3617 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3618 # define YY_STACK_PRINT(Bottom, Top)
3619 # define YY_REDUCE_PRINT(Rule)
3620 #endif /* !YYDEBUG */
3623 /* YYINITDEPTH -- initial size of the parser's stacks. */
3625 # define YYINITDEPTH 200
3628 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3629 if the built-in stack extension method is used).
3631 Do not make this value too large; the results are undefined if
3632 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3633 evaluated with infinite-precision integer arithmetic. */
3636 # define YYMAXDEPTH 10000
3644 # if defined __GLIBC__ && defined _STRING_H
3645 # define yystrlen strlen
3647 /* Return the length of YYSTR. */
3648 #if (defined __STDC__ || defined __C99__FUNC__ \
3649 || defined __cplusplus || defined _MSC_VER)
3651 yystrlen (const char *yystr)
3659 for (yylen = 0; yystr[yylen]; yylen++)
3667 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3668 # define yystpcpy stpcpy
3670 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3672 #if (defined __STDC__ || defined __C99__FUNC__ \
3673 || defined __cplusplus || defined _MSC_VER)
3675 yystpcpy (char *yydest, const char *yysrc)
3678 yystpcpy (yydest, yysrc)
3684 const char *yys = yysrc;
3686 while ((*yyd++ = *yys++) != '\0')
3695 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3696 quotes and backslashes, so that it's suitable for yyerror. The
3697 heuristic is that double-quoting is unnecessary unless the string
3698 contains an apostrophe, a comma, or backslash (other than
3699 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3700 null, do not copy; instead, return the length of what the result
3703 yytnamerr (char *yyres, const char *yystr)
3708 char const *yyp = yystr;
3715 goto do_not_strip_quotes;
3719 goto do_not_strip_quotes;
3732 do_not_strip_quotes: ;
3736 return yystrlen (yystr);
3738 return yystpcpy (yyres, yystr) - yyres;
3742 /* Copy into YYRESULT an error message about the unexpected token
3743 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3744 including the terminating null byte. If YYRESULT is null, do not
3745 copy anything; just return the number of bytes that would be
3746 copied. As a special case, return 0 if an ordinary "syntax error"
3747 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3748 size calculation. */
3750 yysyntax_error (char *yyresult, int yystate, int yychar)
3752 int yyn = yypact[yystate];
3754 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3758 int yytype = YYTRANSLATE (yychar);
3759 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3760 YYSIZE_T yysize = yysize0;
3762 int yysize_overflow = 0;
3763 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3764 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3768 /* This is so xgettext sees the translatable formats that are
3769 constructed on the fly. */
3770 YY_("syntax error, unexpected %s");
3771 YY_("syntax error, unexpected %s, expecting %s");
3772 YY_("syntax error, unexpected %s, expecting %s or %s");
3773 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3774 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3778 static char const yyunexpected[] = "syntax error, unexpected %s";
3779 static char const yyexpecting[] = ", expecting %s";
3780 static char const yyor[] = " or %s";
3781 char yyformat[sizeof yyunexpected
3782 + sizeof yyexpecting - 1
3783 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3784 * (sizeof yyor - 1))];
3785 char const *yyprefix = yyexpecting;
3787 /* Start YYX at -YYN if negative to avoid negative indexes in
3789 int yyxbegin = yyn < 0 ? -yyn : 0;
3791 /* Stay within bounds of both yycheck and yytname. */
3792 int yychecklim = YYLAST - yyn + 1;
3793 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3796 yyarg[0] = yytname[yytype];
3797 yyfmt = yystpcpy (yyformat, yyunexpected);
3799 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3800 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3802 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3806 yyformat[sizeof yyunexpected - 1] = '\0';
3809 yyarg[yycount++] = yytname[yyx];
3810 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3811 yysize_overflow |= (yysize1 < yysize);
3813 yyfmt = yystpcpy (yyfmt, yyprefix);
3817 yyf = YY_(yyformat);
3818 yysize1 = yysize + yystrlen (yyf);
3819 yysize_overflow |= (yysize1 < yysize);
3822 if (yysize_overflow)
3823 return YYSIZE_MAXIMUM;
3827 /* Avoid sprintf, as that infringes on the user's name space.
3828 Don't have undefined behavior even if the translation
3829 produced a string with the wrong number of "%s"s. */
3830 char *yyp = yyresult;
3832 while ((*yyp = *yyf) != '\0')
3834 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3836 yyp += yytnamerr (yyp, yyarg[yyi++]);
3849 #endif /* YYERROR_VERBOSE */
3852 /*-----------------------------------------------.
3853 | Release the memory associated to this symbol. |
3854 `-----------------------------------------------*/
3857 #if (defined __STDC__ || defined __C99__FUNC__ \
3858 || defined __cplusplus || defined _MSC_VER)
3860 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3863 yydestruct (yymsg, yytype, yyvaluep)
3873 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3884 /* Prevent warnings from -Wmissing-prototypes. */
3886 #ifdef YYPARSE_PARAM
3887 #if defined __STDC__ || defined __cplusplus
3888 int yyparse (void *YYPARSE_PARAM);
3892 #else /* ! YYPARSE_PARAM */
3893 #if defined __STDC__ || defined __cplusplus
3898 #endif /* ! YYPARSE_PARAM */
3902 /* The look-ahead symbol. */
3905 /* The semantic value of the look-ahead symbol. */
3908 /* Number of syntax errors so far. */
3917 #ifdef YYPARSE_PARAM
3918 #if (defined __STDC__ || defined __C99__FUNC__ \
3919 || defined __cplusplus || defined _MSC_VER)
3921 yyparse (void *YYPARSE_PARAM)
3924 yyparse (YYPARSE_PARAM)
3925 void *YYPARSE_PARAM;
3927 #else /* ! YYPARSE_PARAM */
3928 #if (defined __STDC__ || defined __C99__FUNC__ \
3929 || defined __cplusplus || defined _MSC_VER)
3943 /* Number of tokens to shift before error messages enabled. */
3945 /* Look-ahead token as an internal (translated) token number. */
3948 /* Buffer for error messages, and its allocated size. */
3950 char *yymsg = yymsgbuf;
3951 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3954 /* Three stacks and their tools:
3955 `yyss': related to states,
3956 `yyvs': related to semantic values,
3957 `yyls': related to locations.
3959 Refer to the stacks thru separate pointers, to allow yyoverflow
3960 to reallocate them elsewhere. */
3962 /* The state stack. */
3963 yytype_int16 yyssa[YYINITDEPTH];
3964 yytype_int16 *yyss = yyssa;
3965 yytype_int16 *yyssp;
3967 /* The semantic value stack. */
3968 YYSTYPE yyvsa[YYINITDEPTH];
3969 YYSTYPE *yyvs = yyvsa;
3974 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3976 YYSIZE_T yystacksize = YYINITDEPTH;
3978 /* The variables used to return semantic value and location from the
3983 /* The number of symbols on the RHS of the reduced rule.
3984 Keep to zero when no symbol should be popped. */
3987 YYDPRINTF ((stderr, "Starting parse\n"));
3992 yychar = YYEMPTY; /* Cause a token to be read. */
3994 /* Initialize stack pointers.
3995 Waste one element of value and location stack
3996 so that they stay on the same level as the state stack.
3997 The wasted elements are never initialized. */
4004 /*------------------------------------------------------------.
4005 | yynewstate -- Push a new state, which is found in yystate. |
4006 `------------------------------------------------------------*/
4008 /* In all cases, when you get here, the value and location stacks
4009 have just been pushed. So pushing a state here evens the stacks. */
4015 if (yyss + yystacksize - 1 <= yyssp)
4017 /* Get the current used size of the three stacks, in elements. */
4018 YYSIZE_T yysize = yyssp - yyss + 1;
4022 /* Give user a chance to reallocate the stack. Use copies of
4023 these so that the &'s don't force the real ones into
4025 YYSTYPE *yyvs1 = yyvs;
4026 yytype_int16 *yyss1 = yyss;
4029 /* Each stack pointer address is followed by the size of the
4030 data in use in that stack, in bytes. This used to be a
4031 conditional around just the two extra args, but that might
4032 be undefined if yyoverflow is a macro. */
4033 yyoverflow (YY_("memory exhausted"),
4034 &yyss1, yysize * sizeof (*yyssp),
4035 &yyvs1, yysize * sizeof (*yyvsp),
4042 #else /* no yyoverflow */
4043 # ifndef YYSTACK_RELOCATE
4044 goto yyexhaustedlab;
4046 /* Extend the stack our own way. */
4047 if (YYMAXDEPTH <= yystacksize)
4048 goto yyexhaustedlab;
4050 if (YYMAXDEPTH < yystacksize)
4051 yystacksize = YYMAXDEPTH;
4054 yytype_int16 *yyss1 = yyss;
4055 union yyalloc *yyptr =
4056 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
4058 goto yyexhaustedlab;
4059 YYSTACK_RELOCATE (yyss);
4060 YYSTACK_RELOCATE (yyvs);
4062 # undef YYSTACK_RELOCATE
4064 YYSTACK_FREE (yyss1);
4067 #endif /* no yyoverflow */
4069 yyssp = yyss + yysize - 1;
4070 yyvsp = yyvs + yysize - 1;
4073 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
4074 (unsigned long int) yystacksize));
4076 if (yyss + yystacksize - 1 <= yyssp)
4080 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
4089 /* Do appropriate processing given the current state. Read a
4090 look-ahead token if we need one and don't already have one. */
4092 /* First try to decide what to do without reference to look-ahead token. */
4093 yyn = yypact[yystate];
4094 if (yyn == YYPACT_NINF)
4097 /* Not known => get a look-ahead token if don't already have one. */
4099 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
4100 if (yychar == YYEMPTY)
4102 YYDPRINTF ((stderr, "Reading a token: "));
4106 if (yychar <= YYEOF)
4108 yychar = yytoken = YYEOF;
4109 YYDPRINTF ((stderr, "Now at end of input.\n"));
4113 yytoken = YYTRANSLATE (yychar);
4114 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
4117 /* If the proper action on seeing token YYTOKEN is to reduce or to
4118 detect an error, take that action. */
4120 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
4125 if (yyn == 0 || yyn == YYTABLE_NINF)
4134 /* Count tokens shifted since error; after three, turn off error
4139 /* Shift the look-ahead token. */
4140 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
4142 /* Discard the shifted token unless it is eof. */
4143 if (yychar != YYEOF)
4152 /*-----------------------------------------------------------.
4153 | yydefault -- do the default action for the current state. |
4154 `-----------------------------------------------------------*/
4156 yyn = yydefact[yystate];
4162 /*-----------------------------.
4163 | yyreduce -- Do a reduction. |
4164 `-----------------------------*/
4166 /* yyn is the number of a rule to reduce with. */
4169 /* If YYLEN is nonzero, implement the default value of the action:
4172 Otherwise, the following line sets YYVAL to garbage.
4173 This behavior is undocumented and Bison
4174 users should not rely upon it. Assigning to YYVAL
4175 unconditionally makes the parser a bit smaller, and it avoids a
4176 GCC warning that YYVAL may be used uninitialized. */
4177 yyval = yyvsp[1-yylen];
4180 YY_REDUCE_PRINT (yyn);
4184 #line 1889 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4186 if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
4187 error("Value too large for type");
4188 (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
4193 #line 1898 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4195 if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
4196 error("Value too large for type");
4197 (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
4202 #line 1920 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4203 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
4207 #line 1920 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4208 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
4212 #line 1921 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4213 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
4217 #line 1921 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4218 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
4222 #line 1922 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4223 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
4227 #line 1922 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4228 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
4232 #line 1923 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4233 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
4237 #line 1923 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4238 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
4242 #line 1924 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4243 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
4247 #line 1924 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4248 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
4252 #line 1928 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4253 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
4257 #line 1928 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4258 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
4262 #line 1929 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4263 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
4267 #line 1929 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4268 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
4272 #line 1930 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4273 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
4277 #line 1930 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4278 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
4282 #line 1931 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4283 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
4287 #line 1931 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4288 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
4292 #line 1932 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4293 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
4297 #line 1932 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4298 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
4302 #line 1933 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4303 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
4307 #line 1933 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4308 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
4312 #line 1934 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4313 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
4317 #line 1934 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4318 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
4322 #line 1935 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4323 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
4327 #line 1936 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4328 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
4332 #line 1967 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4334 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
4339 #line 1970 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4346 #line 1975 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4347 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
4351 #line 1976 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4352 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
4356 #line 1977 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4357 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
4361 #line 1978 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4362 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
4366 #line 1979 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4367 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
4371 #line 1980 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4372 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
4376 #line 1981 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4377 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
4381 #line 1982 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4382 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
4386 #line 1986 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4387 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;}
4391 #line 1987 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4392 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;}
4396 #line 1988 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4397 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::CSRet; ;}
4401 #line 1989 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4402 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Fast; ;}
4406 #line 1990 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4407 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Cold; ;}
4411 #line 1991 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4412 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_StdCall; ;}
4416 #line 1992 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4417 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_FastCall; ;}
4421 #line 1993 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4423 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
4424 error("Calling conv too large");
4425 (yyval.UIntVal) = lastCallingConv = (yyvsp[(2) - (2)].UInt64Val);
4430 #line 2003 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4431 { (yyval.UIntVal) = 0; ;}
4435 #line 2004 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4437 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4438 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4439 error("Alignment must be a power of two");
4444 #line 2012 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4445 { (yyval.UIntVal) = 0; ;}
4449 #line 2013 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4451 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4452 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4453 error("Alignment must be a power of two");
4458 #line 2021 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4460 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
4461 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
4462 error("Invalid character in section name");
4463 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4468 #line 2030 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4469 { (yyval.StrVal) = 0; ;}
4473 #line 2031 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4474 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4478 #line 2038 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4483 #line 2039 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4488 #line 2043 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4490 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
4491 free((yyvsp[(1) - (1)].StrVal));
4496 #line 2047 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4498 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
4499 error("Alignment must be a power of two");
4500 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
4506 #line 2064 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4508 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4509 (yyval.TypeVal).S.makeSignless();
4514 #line 2072 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4516 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4517 (yyval.TypeVal).S.makeSignless();
4522 #line 2079 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4524 if (!UpRefs.empty())
4525 error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).PAT)->getDescription());
4526 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4531 #line 2093 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4533 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4534 (yyval.TypeVal).S.copy((yyvsp[(1) - (1)].PrimType).S);
4539 #line 2097 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4541 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
4542 (yyval.TypeVal).S.makeSignless();
4547 #line 2101 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4548 { // Named types are also simple types...
4549 (yyval.TypeVal).S.copy(getTypeSign((yyvsp[(1) - (1)].ValIDVal)));
4550 const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
4551 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
4556 #line 2106 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4557 { // Type UpReference
4558 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U)
4559 error("Value out of range");
4560 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
4561 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4562 (yyval.TypeVal).PAT = new PATypeHolder(OT);
4563 (yyval.TypeVal).S.makeSignless();
4564 UR_OUT("New Upreference!\n");
4569 #line 2115 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4570 { // Function derived type?
4571 (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (4)].TypeVal).S);
4572 std::vector<const Type*> Params;
4573 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
4574 E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
4575 Params.push_back(I->PAT->get());
4576 (yyval.TypeVal).S.add(I->S);
4578 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4579 if (isVarArg) Params.pop_back();
4581 ParamAttrsList *PAL = 0;
4582 if (lastCallingConv == OldCallingConv::CSRet) {
4583 ParamAttrsVector Attrs;
4584 ParamAttrsWithIndex PAWI;
4585 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
4586 Attrs.push_back(PAWI);
4587 PAL = ParamAttrsList::get(Attrs);
4590 const FunctionType *FTy =
4591 FunctionType::get((yyvsp[(1) - (4)].TypeVal).PAT->get(), Params, isVarArg, PAL);
4593 (yyval.TypeVal).PAT = new PATypeHolder( HandleUpRefs(FTy, (yyval.TypeVal).S) );
4594 delete (yyvsp[(1) - (4)].TypeVal).PAT; // Delete the return type handle
4595 delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list
4600 #line 2142 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4601 { // Sized array type?
4602 (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S);
4603 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).PAT->get(),
4604 (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S));
4605 delete (yyvsp[(4) - (5)].TypeVal).PAT;
4610 #line 2148 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4612 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).PAT->get();
4613 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
4614 error("Unsigned result not equal to signed result");
4615 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4616 error("Elements of a VectorType must be integer or floating point");
4617 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
4618 error("VectorType length should be a power of 2");
4619 (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S);
4620 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4621 (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S));
4622 delete (yyvsp[(4) - (5)].TypeVal).PAT;
4627 #line 2161 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4628 { // Structure type?
4629 std::vector<const Type*> Elements;
4630 (yyval.TypeVal).S.makeComposite();
4631 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4632 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I) {
4633 Elements.push_back(I->PAT->get());
4634 (yyval.TypeVal).S.add(I->S);
4636 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S));
4637 delete (yyvsp[(2) - (3)].TypeList);
4642 #line 2172 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4643 { // Empty structure type?
4644 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4645 (yyval.TypeVal).S.makeComposite();
4650 #line 2176 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4651 { // Packed Structure type?
4652 (yyval.TypeVal).S.makeComposite();
4653 std::vector<const Type*> Elements;
4654 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4655 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
4656 Elements.push_back(I->PAT->get());
4657 (yyval.TypeVal).S.add(I->S);
4660 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
4661 (yyval.TypeVal).S));
4662 delete (yyvsp[(3) - (5)].TypeList);
4667 #line 2189 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4668 { // Empty packed structure type?
4669 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4670 (yyval.TypeVal).S.makeComposite();
4675 #line 2193 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4677 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::LabelTy)
4678 error("Cannot form a pointer to a basic block");
4679 (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (2)].TypeVal).S);
4680 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).PAT->get()),
4681 (yyval.TypeVal).S));
4682 delete (yyvsp[(1) - (2)].TypeVal).PAT;
4687 #line 2207 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4689 (yyval.TypeList) = new std::list<PATypeInfo>();
4690 (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal));
4695 #line 2211 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4697 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
4702 #line 2219 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4705 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
4706 VoidTI.S.makeSignless();
4707 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
4712 #line 2225 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4714 (yyval.TypeList) = new std::list<PATypeInfo>();
4716 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
4717 VoidTI.S.makeSignless();
4718 (yyval.TypeList)->push_back(VoidTI);
4723 #line 2232 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4725 (yyval.TypeList) = new std::list<PATypeInfo>();
4730 #line 2244 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4731 { // Nonempty unsized arr
4732 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
4734 error("Cannot make array constant with type: '" +
4735 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
4736 const Type *ETy = ATy->getElementType();
4737 int NumElements = ATy->getNumElements();
4739 // Verify that we have the correct size...
4740 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4741 error("Type mismatch: constant sized array initialized with " +
4742 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
4743 itostr(NumElements) + "");
4745 // Verify all elements are correct type!
4746 std::vector<Constant*> Elems;
4747 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4748 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4749 const Type* ValTy = C->getType();
4751 error("Element #" + utostr(i) + " is not of type '" +
4752 ETy->getDescription() +"' as required!\nIt is of type '"+
4753 ValTy->getDescription() + "'");
4756 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4757 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4758 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4759 delete (yyvsp[(3) - (4)].ConstVector);
4764 #line 2274 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4766 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
4768 error("Cannot make array constant with type: '" +
4769 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
4770 int NumElements = ATy->getNumElements();
4771 if (NumElements != -1 && NumElements != 0)
4772 error("Type mismatch: constant sized array initialized with 0"
4773 " arguments, but has size of " + itostr(NumElements) +"");
4774 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4775 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4776 delete (yyvsp[(1) - (3)].TypeVal).PAT;
4781 #line 2287 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4783 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
4785 error("Cannot make array constant with type: '" +
4786 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
4787 int NumElements = ATy->getNumElements();
4788 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4789 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4790 error("String arrays require type i8, not '" + ETy->getDescription() +
4792 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4793 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
4794 error("Can't build string constant of size " +
4795 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " +
4796 itostr(NumElements) + "");
4797 std::vector<Constant*> Vals;
4798 for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
4799 Vals.push_back(ConstantInt::get(ETy, *C));
4800 free((yyvsp[(3) - (3)].StrVal));
4801 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4802 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4803 delete (yyvsp[(1) - (3)].TypeVal).PAT;
4808 #line 2310 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4809 { // Nonempty unsized arr
4810 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
4812 error("Cannot make packed constant with type: '" +
4813 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
4814 const Type *ETy = PTy->getElementType();
4815 int NumElements = PTy->getNumElements();
4816 // Verify that we have the correct size...
4817 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4818 error("Type mismatch: constant sized packed initialized with " +
4819 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
4820 itostr(NumElements) + "");
4821 // Verify all elements are correct type!
4822 std::vector<Constant*> Elems;
4823 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4824 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4825 const Type* ValTy = C->getType();
4827 error("Element #" + utostr(i) + " is not of type '" +
4828 ETy->getDescription() +"' as required!\nIt is of type '"+
4829 ValTy->getDescription() + "'");
4832 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
4833 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4834 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4835 delete (yyvsp[(3) - (4)].ConstVector);
4840 #line 2338 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4842 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
4844 error("Cannot make struct constant with type: '" +
4845 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
4846 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
4847 error("Illegal number of initializers for structure type");
4849 // Check to ensure that constants are compatible with the type initializer!
4850 std::vector<Constant*> Fields;
4851 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
4852 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4853 if (C->getType() != STy->getElementType(i))
4854 error("Expected type '" + STy->getElementType(i)->getDescription() +
4855 "' for element #" + utostr(i) + " of structure initializer");
4856 Fields.push_back(C);
4858 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4859 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4860 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4861 delete (yyvsp[(3) - (4)].ConstVector);
4866 #line 2360 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4868 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
4870 error("Cannot make struct constant with type: '" +
4871 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
4872 if (STy->getNumContainedTypes() != 0)
4873 error("Illegal number of initializers for structure type");
4874 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4875 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4876 delete (yyvsp[(1) - (3)].TypeVal).PAT;
4881 #line 2371 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4883 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).PAT->get());
4885 error("Cannot make packed struct constant with type: '" +
4886 (yyvsp[(1) - (6)].TypeVal).PAT->get()->getDescription() + "'");
4887 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
4888 error("Illegal number of initializers for packed structure type");
4890 // Check to ensure that constants are compatible with the type initializer!
4891 std::vector<Constant*> Fields;
4892 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
4893 Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
4894 if (C->getType() != STy->getElementType(i))
4895 error("Expected type '" + STy->getElementType(i)->getDescription() +
4896 "' for element #" + utostr(i) + " of packed struct initializer");
4897 Fields.push_back(C);
4899 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4900 (yyval.ConstVal).S.copy((yyvsp[(1) - (6)].TypeVal).S);
4901 delete (yyvsp[(1) - (6)].TypeVal).PAT;
4902 delete (yyvsp[(4) - (6)].ConstVector);
4907 #line 2393 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4909 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).PAT->get());
4911 error("Cannot make packed struct constant with type: '" +
4912 (yyvsp[(1) - (5)].TypeVal).PAT->get()->getDescription() + "'");
4913 if (STy->getNumContainedTypes() != 0)
4914 error("Illegal number of initializers for packed structure type");
4915 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4916 (yyval.ConstVal).S.copy((yyvsp[(1) - (5)].TypeVal).S);
4917 delete (yyvsp[(1) - (5)].TypeVal).PAT;
4922 #line 2404 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4924 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get());
4926 error("Cannot make null pointer constant with type: '" +
4927 (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription() + "'");
4928 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4929 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4930 delete (yyvsp[(1) - (2)].TypeVal).PAT;
4935 #line 2413 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4937 (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).PAT->get());
4938 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4939 delete (yyvsp[(1) - (2)].TypeVal).PAT;
4944 #line 2418 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4946 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get());
4948 error("Global const reference must be a pointer type, not" +
4949 (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription());
4951 // ConstExprs can exist in the body of a function, thus creating
4952 // GlobalValues whenever they refer to a variable. Because we are in
4953 // the context of a function, getExistingValue will search the functions
4954 // symbol table instead of the module symbol table for the global symbol,
4955 // which throws things all off. To get around this, we just tell
4956 // getExistingValue that we are at global scope here.
4958 Function *SavedCurFn = CurFun.CurrentFunction;
4959 CurFun.CurrentFunction = 0;
4960 (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4961 Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
4962 CurFun.CurrentFunction = SavedCurFn;
4964 // If this is an initializer for a constant pointer, which is referencing a
4965 // (currently) undefined variable, create a stub now that shall be replaced
4966 // in the future with the right type of variable.
4969 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4970 const PointerType *PT = cast<PointerType>(Ty);
4972 // First check to see if the forward references value is already created!
4973 PerModuleInfo::GlobalRefsType::iterator I =
4974 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
4976 if (I != CurModule.GlobalRefs.end()) {
4977 V = I->second; // Placeholder already exists, use it...
4978 (yyvsp[(2) - (2)].ValIDVal).destroy();
4981 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4983 // Create the forward referenced global.
4985 if (const FunctionType *FTy =
4986 dyn_cast<FunctionType>(PT->getElementType())) {
4987 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4988 CurModule.CurrentModule);
4990 GV = new GlobalVariable(PT->getElementType(), false,
4991 GlobalValue::ExternalLinkage, 0,
4992 Name, CurModule.CurrentModule);
4995 // Keep track of the fact that we have a forward ref to recycle it
4996 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
5000 (yyval.ConstVal).C = cast<GlobalValue>(V);
5001 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5002 delete (yyvsp[(1) - (2)].TypeVal).PAT; // Free the type handle
5007 #line 2477 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5009 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
5010 error("Mismatched types for constant expression");
5011 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
5012 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5013 delete (yyvsp[(1) - (2)].TypeVal).PAT;
5018 #line 2484 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5020 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get();
5021 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
5022 error("Cannot create a null initialized value of this type");
5023 (yyval.ConstVal).C = Constant::getNullValue(Ty);
5024 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5025 delete (yyvsp[(1) - (2)].TypeVal).PAT;
5030 #line 2492 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5031 { // integral constants
5032 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
5033 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
5034 error("Constant value doesn't fit in type");
5035 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
5036 (yyval.ConstVal).S.makeSigned();
5041 #line 2499 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5042 { // integral constants
5043 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
5044 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
5045 error("Constant value doesn't fit in type");
5046 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
5047 (yyval.ConstVal).S.makeUnsigned();
5052 #line 2506 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5053 { // Boolean constants
5054 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
5055 (yyval.ConstVal).S.makeUnsigned();
5060 #line 2510 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5061 { // Boolean constants
5062 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
5063 (yyval.ConstVal).S.makeUnsigned();
5068 #line 2514 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5069 { // Float & Double constants
5070 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal)))
5071 error("Floating point constant invalid for type");
5072 (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal));
5073 (yyval.ConstVal).S.makeSignless();
5078 #line 2523 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5080 const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
5081 const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).PAT->get();
5082 Signedness SrcSign((yyvsp[(3) - (6)].ConstVal).S);
5083 Signedness DstSign((yyvsp[(5) - (6)].TypeVal).S);
5084 if (!SrcTy->isFirstClassType())
5085 error("cast constant expression from a non-primitive type: '" +
5086 SrcTy->getDescription() + "'");
5087 if (!DstTy->isFirstClassType())
5088 error("cast constant expression to a non-primitive type: '" +
5089 DstTy->getDescription() + "'");
5090 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign));
5091 (yyval.ConstVal).S.copy(DstSign);
5092 delete (yyvsp[(5) - (6)].TypeVal).PAT;
5097 #line 2538 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5099 const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
5100 if (!isa<PointerType>(Ty))
5101 error("GetElementPtr requires a pointer operand");
5103 std::vector<Constant*> CIndices;
5104 upgradeGEPCEIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), CIndices);
5106 delete (yyvsp[(4) - (5)].ValueList);
5107 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, &CIndices[0], CIndices.size());
5108 (yyval.ConstVal).S.copy(getElementSign((yyvsp[(3) - (5)].ConstVal), CIndices));
5113 #line 2550 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5115 if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
5116 cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
5117 error("Select condition must be bool type");
5118 if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
5119 error("Select operand types must match");
5120 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5121 (yyval.ConstVal).S.copy((yyvsp[(5) - (8)].ConstVal).S);
5126 #line 2559 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5128 const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5129 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
5130 error("Binary operator types must match");
5131 // First, make sure we're dealing with the right opcode by upgrading from
5132 // obsolete versions.
5133 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
5135 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
5136 // To retain backward compatibility with these early compilers, we emit a
5137 // cast to the appropriate integer type automatically if we are in the
5138 // broken case. See PR424 for more information.
5139 if (!isa<PointerType>(Ty)) {
5140 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5142 const Type *IntPtrTy = 0;
5143 switch (CurModule.CurrentModule->getPointerSize()) {
5144 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
5145 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
5146 default: error("invalid pointer binary constant expr");
5148 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
5149 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
5150 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
5151 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
5153 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
5158 #line 2587 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5160 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5161 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
5162 error("Logical operator types must match");
5163 if (!Ty->isInteger()) {
5164 if (!isa<VectorType>(Ty) ||
5165 !cast<VectorType>(Ty)->getElementType()->isInteger())
5166 error("Logical operator requires integer operands");
5168 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
5169 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5170 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
5175 #line 2600 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5177 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5178 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
5179 error("setcc operand types must match");
5180 unsigned short pred;
5181 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
5182 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5183 (yyval.ConstVal).S.makeUnsigned();
5188 #line 2609 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5190 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
5191 error("icmp operand types must match");
5192 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
5193 (yyval.ConstVal).S.makeUnsigned();
5198 #line 2615 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5200 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
5201 error("fcmp operand types must match");
5202 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
5203 (yyval.ConstVal).S.makeUnsigned();
5208 #line 2621 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5210 if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
5211 cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
5212 error("Shift count for shift constant must be unsigned byte");
5213 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5214 if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
5215 error("Shift constant expression requires integer operand");
5216 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[(5) - (6)].ConstVal).C, Ty);
5217 (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S), (yyvsp[(3) - (6)].ConstVal).C, ShiftAmt);
5218 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
5223 #line 2632 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5225 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
5226 error("Invalid extractelement operands");
5227 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5228 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S.get(0));
5233 #line 2638 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5235 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
5236 error("Invalid insertelement operands");
5237 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5238 (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S);
5243 #line 2644 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5245 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
5246 error("Invalid shufflevector operands");
5247 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5248 (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S);
5253 #line 2655 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5254 { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
5258 #line 2656 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5260 (yyval.ConstVector) = new std::vector<ConstInfo>();
5261 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
5266 #line 2665 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5267 { (yyval.BoolVal) = false; ;}
5271 #line 2666 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5272 { (yyval.BoolVal) = true; ;}
5276 #line 2678 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5278 (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
5279 CurModule.ModuleDone();
5284 #line 2687 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5285 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
5289 #line 2688 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5290 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
5294 #line 2689 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5295 { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
5299 #line 2690 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5300 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
5304 #line 2691 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5306 (yyval.ModuleVal) = CurModule.CurrentModule;
5307 // Emit an error if there are any unresolved types left.
5308 if (!CurModule.LateResolveTypes.empty()) {
5309 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5310 if (DID.Type == ValID::NameVal) {
5311 error("Reference to an undefined type: '"+DID.getName() + "'");
5313 error("Reference to an undefined type: #" + itostr(DID.Num));
5320 #line 2707 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5322 // Eagerly resolve types. This is not an optimization, this is a
5323 // requirement that is due to the fact that we could have this:
5325 // %list = type { %list * }
5326 // %list = type { %list * } ; repeated type decl
5328 // If types are not resolved eagerly, then the two types will not be
5329 // determined to be the same type!
5331 ResolveTypeTo((yyvsp[(2) - (4)].StrVal), (yyvsp[(4) - (4)].TypeVal).PAT->get(), (yyvsp[(4) - (4)].TypeVal).S);
5333 if (!setTypeName((yyvsp[(4) - (4)].TypeVal), (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
5334 // If this is a numbered type that is not a redefinition, add it to the
5336 CurModule.Types.push_back((yyvsp[(4) - (4)].TypeVal).PAT->get());
5337 CurModule.TypeSigns.push_back((yyvsp[(4) - (4)].TypeVal).S);
5339 delete (yyvsp[(4) - (4)].TypeVal).PAT;
5344 #line 2727 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5345 { // Function prototypes can be in const pool
5350 #line 2729 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5351 { // Asm blocks can be in the const pool
5356 #line 2731 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5358 if ((yyvsp[(5) - (5)].ConstVal).C == 0)
5359 error("Global value initializer is not a constant");
5360 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);
5365 #line 2735 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5372 #line 2738 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5374 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
5375 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5376 (yyvsp[(5) - (5)].TypeVal).S);
5377 delete (yyvsp[(5) - (5)].TypeVal).PAT;
5382 #line 2743 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5389 #line 2746 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5391 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
5392 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5393 (yyvsp[(5) - (5)].TypeVal).S);
5394 delete (yyvsp[(5) - (5)].TypeVal).PAT;
5399 #line 2751 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5406 #line 2754 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5408 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
5410 ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5411 (yyvsp[(5) - (5)].TypeVal).S);
5412 delete (yyvsp[(5) - (5)].TypeVal).PAT;
5417 #line 2760 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5424 #line 2763 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5430 #line 2765 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5436 #line 2767 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5442 #line 2772 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5444 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5445 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
5446 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
5447 free((yyvsp[(1) - (1)].StrVal));
5449 if (AsmSoFar.empty())
5450 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5452 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
5457 #line 2786 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5458 { (yyval.Endianness) = Module::BigEndian; ;}
5462 #line 2787 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5463 { (yyval.Endianness) = Module::LittleEndian; ;}
5467 #line 2791 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5469 CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
5474 #line 2794 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5476 if ((yyvsp[(3) - (3)].UInt64Val) == 32)
5477 CurModule.setPointerSize(Module::Pointer32);
5478 else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
5479 CurModule.setPointerSize(Module::Pointer64);
5481 error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
5486 #line 2802 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5488 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
5489 free((yyvsp[(3) - (3)].StrVal));
5494 #line 2806 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5496 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
5497 free((yyvsp[(3) - (3)].StrVal));
5502 #line 2817 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5504 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
5505 free((yyvsp[(3) - (3)].StrVal));
5510 #line 2821 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5512 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
5513 free((yyvsp[(1) - (1)].StrVal));
5518 #line 2825 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5523 #line 2838 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5524 { (yyval.StrVal) = 0; ;}
5528 #line 2842 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5530 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::VoidTy)
5531 error("void typed arguments are invalid");
5532 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
5537 #line 2850 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5539 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5540 (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
5541 delete (yyvsp[(3) - (3)].ArgVal);
5546 #line 2855 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5548 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5549 (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
5550 delete (yyvsp[(1) - (1)].ArgVal);
5555 #line 2863 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5556 { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
5560 #line 2864 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5562 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5564 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
5565 VoidTI.S.makeSignless();
5566 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5571 #line 2871 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5573 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5575 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
5576 VoidTI.S.makeSignless();
5577 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5582 #line 2878 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5583 { (yyval.ArgList) = 0; ;}
5587 #line 2882 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5589 UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
5590 std::string FunctionName((yyvsp[(3) - (8)].StrVal));
5591 free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory!
5593 const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).PAT->get();
5595 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5596 error("LLVM functions cannot return aggregate types");
5599 FTySign.makeComposite((yyvsp[(2) - (8)].TypeVal).S);
5600 std::vector<const Type*> ParamTyList;
5602 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5603 // i8*. We check here for those names and override the parameter list
5604 // types to ensure the prototype is correct.
5605 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5606 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5607 } else if (FunctionName == "llvm.va_copy") {
5608 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5609 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5610 } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments...
5611 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5612 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
5613 const Type *Ty = I->first.PAT->get();
5614 ParamTyList.push_back(Ty);
5615 FTySign.add(I->first.S);
5619 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5621 ParamTyList.pop_back();
5623 // Convert the CSRet calling convention into the corresponding parameter
5625 ParamAttrsList *PAL = 0;
5626 if ((yyvsp[(1) - (8)].UIntVal) == OldCallingConv::CSRet) {
5627 ParamAttrsVector Attrs;
5628 ParamAttrsWithIndex PAWI;
5629 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
5630 Attrs.push_back(PAWI);
5631 PAL = ParamAttrsList::get(Attrs);
5634 const FunctionType *FT =
5635 FunctionType::get(RetTy, ParamTyList, isVarArg, PAL);
5636 const PointerType *PFT = PointerType::get(FT);
5637 delete (yyvsp[(2) - (8)].TypeVal).PAT;
5640 if (!FunctionName.empty()) {
5641 ID = ValID::create((char*)FunctionName.c_str());
5643 ID = ValID::create((int)CurModule.Values[PFT].size());
5645 ID.S.makeComposite(FTySign);
5648 Module* M = CurModule.CurrentModule;
5650 // See if this function was forward referenced. If so, recycle the object.
5651 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5652 // Move the function to the end of the list, from whereever it was
5653 // previously inserted.
5654 Fn = cast<Function>(FWRef);
5655 M->getFunctionList().remove(Fn);
5656 M->getFunctionList().push_back(Fn);
5657 } else if (!FunctionName.empty()) {
5658 GlobalValue *Conflict = M->getFunction(FunctionName);
5660 Conflict = M->getNamedGlobal(FunctionName);
5661 if (Conflict && PFT == Conflict->getType()) {
5662 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5663 // We have two function definitions that conflict, same type, same
5664 // name. We should really check to make sure that this is the result
5665 // of integer type planes collapsing and generate an error if it is
5666 // not, but we'll just rename on the assumption that it is. However,
5667 // let's do it intelligently and rename the internal linkage one
5669 std::string NewName(makeNameUnique(FunctionName));
5670 if (Conflict->hasInternalLinkage()) {
5671 Conflict->setName(NewName);
5673 makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
5674 CurModule.RenameMap[Key] = NewName;
5675 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5676 InsertValue(Fn, CurModule.Values);
5678 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5679 InsertValue(Fn, CurModule.Values);
5681 makeRenameMapKey(FunctionName, PFT, ID.S);
5682 CurModule.RenameMap[Key] = NewName;
5685 // If they are not both definitions, then just use the function we
5686 // found since the types are the same.
5687 Fn = cast<Function>(Conflict);
5689 // Make sure to strip off any argument names so we can't get
5691 if (Fn->isDeclaration())
5692 for (Function::arg_iterator AI = Fn->arg_begin(),
5693 AE = Fn->arg_end(); AI != AE; ++AI)
5696 } else if (Conflict) {
5697 // We have two globals with the same name and different types.
5698 // Previously, this was permitted because the symbol table had
5699 // "type planes" and names only needed to be distinct within a
5700 // type plane. After PR411 was fixed, this is no loner the case.
5701 // To resolve this we must rename one of the two.
5702 if (Conflict->hasInternalLinkage()) {
5703 // We can safely rename the Conflict.
5705 makeRenameMapKey(Conflict->getName(), Conflict->getType(),
5706 CurModule.NamedValueSigns[Conflict->getName()]);
5707 Conflict->setName(makeNameUnique(Conflict->getName()));
5708 CurModule.RenameMap[Key] = Conflict->getName();
5709 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5710 InsertValue(Fn, CurModule.Values);
5712 // We can't quietly rename either of these things, but we must
5713 // rename one of them. Only if the function's linkage is internal can
5714 // we forgo a warning message about the renamed function.
5715 std::string NewName = makeNameUnique(FunctionName);
5716 if (CurFun.Linkage != GlobalValue::InternalLinkage) {
5717 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5718 "' may cause linkage errors");
5720 // Elect to rename the thing we're now defining.
5721 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5722 InsertValue(Fn, CurModule.Values);
5723 RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
5724 CurModule.RenameMap[Key] = NewName;
5727 // There's no conflict, just define the function
5728 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5729 InsertValue(Fn, CurModule.Values);
5732 // There's no conflict, just define the function
5733 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5734 InsertValue(Fn, CurModule.Values);
5738 CurFun.FunctionStart(Fn);
5740 if (CurFun.isDeclare) {
5741 // If we have declaration, always overwrite linkage. This will allow us
5742 // to correctly handle cases, when pointer to function is passed as
5743 // argument to another function.
5744 Fn->setLinkage(CurFun.Linkage);
5746 Fn->setCallingConv(upgradeCallingConv((yyvsp[(1) - (8)].UIntVal)));
5747 Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
5748 if ((yyvsp[(7) - (8)].StrVal)) {
5749 Fn->setSection((yyvsp[(7) - (8)].StrVal));
5750 free((yyvsp[(7) - (8)].StrVal));
5753 // Add all of the arguments we parsed to the function...
5754 if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty...
5755 if (isVarArg) { // Nuke the last entry
5756 assert((yyvsp[(5) - (8)].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5757 (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
5758 delete (yyvsp[(5) - (8)].ArgList)->back().first.PAT;
5759 (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry
5761 Function::arg_iterator ArgIt = Fn->arg_begin();
5762 Function::arg_iterator ArgEnd = Fn->arg_end();
5763 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[(5) - (8)].ArgList)->begin();
5764 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[(5) - (8)].ArgList)->end();
5765 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
5766 delete I->first.PAT; // Delete the typeholder...
5767 ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
5768 setValueName(VI, I->second); // Insert arg into symtab...
5771 delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list
5773 lastCallingConv = OldCallingConv::C;
5778 #line 3076 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5779 { CurFun.Linkage = (yyvsp[(1) - (1)].Linkage); ;}
5783 #line 3076 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5785 (yyval.FunctionVal) = CurFun.CurrentFunction;
5787 // Make sure that we keep track of the linkage type even if there was a
5788 // previous "declare".
5789 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5794 #line 3090 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5796 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5801 #line 3095 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5802 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5806 #line 3096 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5807 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
5811 #line 3097 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5812 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
5816 #line 3101 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5817 { CurFun.isDeclare = true; ;}
5821 #line 3102 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5822 { CurFun.Linkage = (yyvsp[(3) - (3)].Linkage); ;}
5826 #line 3102 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5828 (yyval.FunctionVal) = CurFun.CurrentFunction;
5829 CurFun.FunctionDone();
5835 #line 3114 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5836 { (yyval.BoolVal) = false; ;}
5840 #line 3115 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5841 { (yyval.BoolVal) = true; ;}
5845 #line 3120 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5846 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
5850 #line 3121 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5851 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
5855 #line 3122 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5856 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
5860 #line 3123 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5862 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true));
5863 (yyval.ValIDVal).S.makeUnsigned();
5868 #line 3127 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5870 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false));
5871 (yyval.ValIDVal).S.makeUnsigned();
5876 #line 3131 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5877 { (yyval.ValIDVal) = ValID::createNull(); ;}
5881 #line 3132 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5882 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5886 #line 3133 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5887 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5891 #line 3134 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5892 { // Nonempty unsized packed vector
5893 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
5894 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
5895 VectorType* pt = VectorType::get(ETy, NumElements);
5896 (yyval.ValIDVal).S.makeComposite((*(yyvsp[(2) - (3)].ConstVector))[0].S);
5897 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S));
5899 // Verify all elements are correct type!
5900 std::vector<Constant*> Elems;
5901 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5902 Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
5903 const Type *CTy = C->getType();
5905 error("Element #" + utostr(i) + " is not of type '" +
5906 ETy->getDescription() +"' as required!\nIt is of type '" +
5907 CTy->getDescription() + "'");
5910 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
5911 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5916 #line 3155 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5918 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
5919 (yyval.ValIDVal).S.copy((yyvsp[(1) - (1)].ConstVal).S);
5924 #line 3159 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5926 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5927 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5928 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5929 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5930 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5931 free((yyvsp[(3) - (5)].StrVal));
5932 free((yyvsp[(5) - (5)].StrVal));
5937 #line 3173 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5938 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;}
5942 #line 3174 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5943 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;}
5947 #line 3187 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5949 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get();
5950 (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5951 (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
5952 (yyval.ValueVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5953 delete (yyvsp[(1) - (2)].TypeVal).PAT;
5958 #line 3197 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5960 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5965 #line 3200 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5966 { // Do not allow functions with 0 basic blocks
5967 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5972 #line 3209 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5974 ValueInfo VI; VI.V = (yyvsp[(3) - (3)].TermInstVal).TI; VI.S.copy((yyvsp[(3) - (3)].TermInstVal).S);
5975 setValueName(VI, (yyvsp[(2) - (3)].StrVal));
5976 InsertValue((yyvsp[(3) - (3)].TermInstVal).TI);
5977 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal).TI);
5978 InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5979 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5984 #line 3220 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5986 if ((yyvsp[(2) - (2)].InstVal).I)
5987 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
5988 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
5993 #line 3225 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5995 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
5996 // Make sure to move the basic block to the correct location in the
5997 // function, instead of leaving it inserted wherever it was first
5999 Function::BasicBlockListType &BBL =
6000 CurFun.CurrentFunction->getBasicBlockList();
6001 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
6006 #line 3234 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6008 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
6009 // Make sure to move the basic block to the correct location in the
6010 // function, instead of leaving it inserted wherever it was first
6012 Function::BasicBlockListType &BBL =
6013 CurFun.CurrentFunction->getBasicBlockList();
6014 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
6019 #line 3248 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6020 { // Return with a result...
6021 (yyval.TermInstVal).TI = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
6022 (yyval.TermInstVal).S.makeSignless();
6027 #line 3252 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6028 { // Return with no result...
6029 (yyval.TermInstVal).TI = new ReturnInst();
6030 (yyval.TermInstVal).S.makeSignless();
6035 #line 3256 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6036 { // Unconditional Branch...
6037 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6038 (yyval.TermInstVal).TI = new BranchInst(tmpBB);
6039 (yyval.TermInstVal).S.makeSignless();
6044 #line 3261 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6046 (yyvsp[(6) - (9)].ValIDVal).S.makeSignless();
6047 (yyvsp[(9) - (9)].ValIDVal).S.makeSignless();
6048 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6049 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6050 (yyvsp[(3) - (9)].ValIDVal).S.makeUnsigned();
6051 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6052 (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
6053 (yyval.TermInstVal).S.makeSignless();
6058 #line 3271 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6060 (yyvsp[(3) - (9)].ValIDVal).S.copy((yyvsp[(2) - (9)].PrimType).S);
6061 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
6062 (yyvsp[(6) - (9)].ValIDVal).S.makeSignless();
6063 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6064 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6065 (yyval.TermInstVal).TI = S;
6066 (yyval.TermInstVal).S.makeSignless();
6067 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6068 E = (yyvsp[(8) - (9)].JumpTable)->end();
6069 for (; I != E; ++I) {
6070 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6071 S->addCase(CI, I->second);
6073 error("Switch case is constant, but not a simple integer");
6075 delete (yyvsp[(8) - (9)].JumpTable);
6080 #line 3289 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6082 (yyvsp[(3) - (8)].ValIDVal).S.copy((yyvsp[(2) - (8)].PrimType).S);
6083 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
6084 (yyvsp[(6) - (8)].ValIDVal).S.makeSignless();
6085 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
6086 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
6087 (yyval.TermInstVal).TI = S;
6088 (yyval.TermInstVal).S.makeSignless();
6093 #line 3299 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6095 const PointerType *PFTy;
6096 const FunctionType *Ty;
6099 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).PAT->get())) ||
6100 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6101 // Pull out the types of all of the arguments...
6102 std::vector<const Type*> ParamTypes;
6103 FTySign.makeComposite((yyvsp[(3) - (13)].TypeVal).S);
6104 if ((yyvsp[(6) - (13)].ValueList)) {
6105 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
6107 ParamTypes.push_back((*I).V->getType());
6111 ParamAttrsList *PAL = 0;
6112 if ((yyvsp[(2) - (13)].UIntVal) == OldCallingConv::CSRet) {
6113 ParamAttrsVector Attrs;
6114 ParamAttrsWithIndex PAWI;
6115 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
6116 Attrs.push_back(PAWI);
6117 PAL = ParamAttrsList::get(Attrs);
6119 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6120 if (isVarArg) ParamTypes.pop_back();
6121 Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).PAT->get(), ParamTypes, isVarArg, PAL);
6122 PFTy = PointerType::get(Ty);
6123 (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S);
6125 FTySign = (yyvsp[(3) - (13)].TypeVal).S;
6126 // Get the signedness of the result type. $3 is the pointer to the
6127 // function type so we get the 0th element to extract the function type,
6128 // and then the 0th element again to get the result type.
6129 (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S.get(0).get(0));
6132 (yyvsp[(4) - (13)].ValIDVal).S.makeComposite(FTySign);
6133 Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling...
6134 BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
6135 BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
6137 // Create the call node...
6138 if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments?
6139 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0);
6140 } else { // Has arguments?
6141 // Loop through FunctionType's arguments and ensure they are specified
6144 FunctionType::param_iterator I = Ty->param_begin();
6145 FunctionType::param_iterator E = Ty->param_end();
6146 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
6148 std::vector<Value*> Args;
6149 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
6150 if ((*ArgI).V->getType() != *I)
6151 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6152 (*I)->getDescription() + "'");
6153 Args.push_back((*ArgI).V);
6156 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
6157 error("Invalid number of parameters detected");
6159 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
6161 cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[(2) - (13)].UIntVal)));
6162 delete (yyvsp[(3) - (13)].TypeVal).PAT;
6163 delete (yyvsp[(6) - (13)].ValueList);
6164 lastCallingConv = OldCallingConv::C;
6169 #line 3371 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6171 (yyval.TermInstVal).TI = new UnwindInst();
6172 (yyval.TermInstVal).S.makeSignless();
6177 #line 3375 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6179 (yyval.TermInstVal).TI = new UnreachableInst();
6180 (yyval.TermInstVal).S.makeSignless();
6185 #line 3382 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6187 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6188 (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(2) - (6)].PrimType).S);
6189 Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
6192 error("May only switch on a constant pool value");
6194 (yyvsp[(6) - (6)].ValIDVal).S.makeSignless();
6195 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
6196 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6201 #line 3394 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6203 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6204 (yyvsp[(2) - (5)].ValIDVal).S.copy((yyvsp[(1) - (5)].PrimType).S);
6205 Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
6208 error("May only switch on a constant pool value");
6210 (yyvsp[(5) - (5)].ValIDVal).S.makeSignless();
6211 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
6212 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
6217 #line 3409 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6220 if ((yyvsp[(1) - (2)].StrVal))
6221 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
6222 if (BCI->getSrcTy() == BCI->getDestTy() &&
6223 BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
6224 // This is a useless bit cast causing a name redefinition. It is
6225 // a bit cast from a type to the same type of an operand with the
6226 // same name as the name we would give this instruction. Since this
6227 // instruction results in no code generation, it is safe to omit
6228 // the instruction. This situation can occur because of collapsed
6229 // type planes. For example:
6230 // %X = add int %Y, %Z
6231 // %X = cast int %Y to uint
6232 // After upgrade, this looks like:
6233 // %X = add i32 %Y, %Z
6234 // %X = bitcast i32 to i32
6235 // The bitcast is clearly useless so we omit it.
6238 (yyval.InstVal).I = 0;
6239 (yyval.InstVal).S.makeSignless();
6241 ValueInfo VI; VI.V = (yyvsp[(2) - (2)].InstVal).I; VI.S.copy((yyvsp[(2) - (2)].InstVal).S);
6242 setValueName(VI, (yyvsp[(1) - (2)].StrVal));
6243 InsertValue((yyvsp[(2) - (2)].InstVal).I);
6244 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
6250 #line 3439 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6251 { // Used for PHI nodes
6252 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
6253 (yyval.PHIList).S.copy((yyvsp[(1) - (6)].TypeVal).S);
6254 (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(1) - (6)].TypeVal).S);
6255 Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).PAT->get(), (yyvsp[(3) - (6)].ValIDVal));
6256 (yyvsp[(5) - (6)].ValIDVal).S.makeSignless();
6257 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
6258 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
6259 delete (yyvsp[(1) - (6)].TypeVal).PAT;
6264 #line 3449 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6266 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6267 (yyvsp[(4) - (7)].ValIDVal).S.copy((yyvsp[(1) - (7)].PHIList).S);
6268 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
6269 (yyvsp[(6) - (7)].ValIDVal).S.makeSignless();
6270 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
6271 (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
6276 #line 3459 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6277 { // Used for call statements, and memory insts...
6278 (yyval.ValueList) = new std::vector<ValueInfo>();
6279 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
6284 #line 3463 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6286 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6287 (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
6292 #line 3471 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6293 { (yyval.ValueList) = 0; ;}
6297 #line 3475 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6299 (yyval.BoolVal) = true;
6304 #line 3478 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6306 (yyval.BoolVal) = false;
6311 #line 3484 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6313 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6314 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6315 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
6316 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
6317 error("Arithmetic operator requires integer, FP, or packed operands");
6318 if (isa<VectorType>(Ty) &&
6319 ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp))
6320 error("Remainder not supported on vector types");
6321 // Upgrade the opcode from obsolete versions before we do anything with it.
6322 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
6323 Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6324 Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6325 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
6326 if ((yyval.InstVal).I == 0)
6327 error("binary operator returned null");
6328 (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6329 delete (yyvsp[(2) - (5)].TypeVal).PAT;
6334 #line 3503 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6336 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6337 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6338 const Type *Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
6339 if (!Ty->isInteger()) {
6340 if (!isa<VectorType>(Ty) ||
6341 !cast<VectorType>(Ty)->getElementType()->isInteger())
6342 error("Logical operator requires integral operands");
6344 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
6345 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6346 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6347 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
6348 if ((yyval.InstVal).I == 0)
6349 error("binary operator returned null");
6350 (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6351 delete (yyvsp[(2) - (5)].TypeVal).PAT;
6356 #line 3521 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6358 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6359 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6360 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
6361 if(isa<VectorType>(Ty))
6362 error("VectorTypes currently not supported in setcc instructions");
6363 unsigned short pred;
6364 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
6365 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6366 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6367 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
6368 if ((yyval.InstVal).I == 0)
6369 error("binary operator returned null");
6370 (yyval.InstVal).S.makeUnsigned();
6371 delete (yyvsp[(2) - (5)].TypeVal).PAT;
6376 #line 3537 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6378 (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6379 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6380 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get();
6381 if (isa<VectorType>(Ty))
6382 error("VectorTypes currently not supported in icmp instructions");
6383 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
6384 error("icmp requires integer or pointer typed operands");
6385 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
6386 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
6387 (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
6388 (yyval.InstVal).S.makeUnsigned();
6389 delete (yyvsp[(3) - (6)].TypeVal).PAT;
6394 #line 3551 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6396 (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6397 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6398 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get();
6399 if (isa<VectorType>(Ty))
6400 error("VectorTypes currently not supported in fcmp instructions");
6401 else if (!Ty->isFloatingPoint())
6402 error("fcmp instruction requires floating point operands");
6403 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
6404 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
6405 (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
6406 (yyval.InstVal).S.makeUnsigned();
6407 delete (yyvsp[(3) - (6)].TypeVal).PAT;
6412 #line 3565 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6414 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
6415 const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
6416 Value *Ones = ConstantInt::getAllOnesValue(Ty);
6418 error("Expected integral type for not instruction");
6419 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
6420 if ((yyval.InstVal).I == 0)
6421 error("Could not create a xor instruction");
6422 (yyval.InstVal).S.copy((yyvsp[(2) - (2)].ValueVal).S);
6427 #line 3576 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6429 if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
6430 cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
6431 error("Shift amount must be int8");
6432 const Type* Ty = (yyvsp[(2) - (4)].ValueVal).V->getType();
6433 if (!Ty->isInteger())
6434 error("Shift constant expression requires integer operand");
6435 Value* ShiftAmt = 0;
6436 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
6437 if (Constant *C = dyn_cast<Constant>((yyvsp[(4) - (4)].ValueVal).V))
6438 ShiftAmt = ConstantExpr::getZExt(C, Ty);
6440 ShiftAmt = new ZExtInst((yyvsp[(4) - (4)].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
6442 ShiftAmt = (yyvsp[(4) - (4)].ValueVal).V;
6443 (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[(1) - (4)].BinaryOpVal), Ty, (yyvsp[(2) - (4)].ValueVal).S), (yyvsp[(2) - (4)].ValueVal).V, ShiftAmt);
6444 (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S);
6449 #line 3594 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6451 const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
6452 if (!DstTy->isFirstClassType())
6453 error("cast instruction to a non-primitive type: '" +
6454 DstTy->getDescription() + "'");
6455 (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));
6456 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6457 delete (yyvsp[(4) - (4)].TypeVal).PAT;
6462 #line 3603 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6464 if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
6465 cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
6466 error("select condition must be bool");
6467 if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
6468 error("select value types should match");
6469 (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6470 (yyval.InstVal).S.copy((yyvsp[(4) - (6)].ValueVal).S);
6475 #line 3612 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6477 const Type *Ty = (yyvsp[(4) - (4)].TypeVal).PAT->get();
6479 (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
6480 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6481 delete (yyvsp[(4) - (4)].TypeVal).PAT;
6486 #line 3619 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6488 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
6489 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
6490 ObsoleteVarArgs = true;
6491 Function* NF = cast<Function>(CurModule.CurrentModule->
6492 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6495 //foo = alloca 1 of t
6499 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
6500 CurBB->getInstList().push_back(foo);
6501 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
6502 CurBB->getInstList().push_back(bar);
6503 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6504 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
6505 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6506 delete (yyvsp[(4) - (4)].TypeVal).PAT;
6511 #line 3640 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6513 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
6514 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
6515 ObsoleteVarArgs = true;
6516 Function* NF = cast<Function>(CurModule.CurrentModule->
6517 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6519 //b = vanext a, t ->
6520 //foo = alloca 1 of t
6523 //tmp = vaarg foo, t
6525 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
6526 CurBB->getInstList().push_back(foo);
6527 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
6528 CurBB->getInstList().push_back(bar);
6529 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6530 Instruction* tmp = new VAArgInst(foo, DstTy);
6531 CurBB->getInstList().push_back(tmp);
6532 (yyval.InstVal).I = new LoadInst(foo);
6533 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6534 delete (yyvsp[(4) - (4)].TypeVal).PAT;
6539 #line 3664 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6541 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
6542 error("Invalid extractelement operands");
6543 (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
6544 (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S.get(0));
6549 #line 3670 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6551 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
6552 error("Invalid insertelement operands");
6553 (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6554 (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S);
6559 #line 3676 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6561 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
6562 error("Invalid shufflevector operands");
6563 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6564 (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S);
6569 #line 3682 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6571 const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
6572 if (!Ty->isFirstClassType())
6573 error("PHI node operands must be of first class type");
6574 PHINode *PHI = new PHINode(Ty);
6575 PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
6576 while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
6577 if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty)
6578 error("All elements of a PHI node must be of the same type");
6579 PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
6580 (yyvsp[(2) - (2)].PHIList).P->pop_front();
6582 (yyval.InstVal).I = PHI;
6583 (yyval.InstVal).S.copy((yyvsp[(2) - (2)].PHIList).S);
6584 delete (yyvsp[(2) - (2)].PHIList).P; // Free the list...
6589 #line 3698 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6591 // Handle the short call syntax
6592 const PointerType *PFTy;
6593 const FunctionType *FTy;
6595 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).PAT->get())) ||
6596 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6597 // Pull out the types of all of the arguments...
6598 std::vector<const Type*> ParamTypes;
6599 FTySign.makeComposite((yyvsp[(3) - (7)].TypeVal).S);
6600 if ((yyvsp[(6) - (7)].ValueList)) {
6601 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
6603 ParamTypes.push_back((*I).V->getType());
6608 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6609 if (isVarArg) ParamTypes.pop_back();
6611 const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).PAT->get();
6612 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6613 error("Functions cannot return aggregate types");
6615 // Deal with CSRetCC
6616 ParamAttrsList *PAL = 0;
6617 if ((yyvsp[(2) - (7)].UIntVal) == OldCallingConv::CSRet) {
6618 ParamAttrsVector Attrs;
6619 ParamAttrsWithIndex PAWI;
6620 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
6621 Attrs.push_back(PAWI);
6622 PAL = ParamAttrsList::get(Attrs);
6625 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, PAL);
6626 PFTy = PointerType::get(FTy);
6627 (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S);
6629 FTySign = (yyvsp[(3) - (7)].TypeVal).S;
6630 // Get the signedness of the result type. $3 is the pointer to the
6631 // function type so we get the 0th element to extract the function type,
6632 // and then the 0th element again to get the result type.
6633 (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S.get(0).get(0));
6635 (yyvsp[(4) - (7)].ValIDVal).S.makeComposite(FTySign);
6637 // First upgrade any intrinsic calls.
6638 std::vector<Value*> Args;
6639 if ((yyvsp[(6) - (7)].ValueList))
6640 for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i)
6641 Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
6642 Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[(4) - (7)].ValIDVal), Args);
6644 // If we got an upgraded intrinsic
6646 (yyval.InstVal).I = Inst;
6648 // Get the function we're calling
6649 Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
6651 // Check the argument values match
6652 if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments?
6653 // Make sure no arguments is a good thing!
6654 if (FTy->getNumParams() != 0)
6655 error("No arguments passed to a function that expects arguments");
6656 } else { // Has arguments?
6657 // Loop through FunctionType's arguments and ensure they are specified
6660 FunctionType::param_iterator I = FTy->param_begin();
6661 FunctionType::param_iterator E = FTy->param_end();
6662 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
6664 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6665 if ((*ArgI).V->getType() != *I)
6666 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6667 (*I)->getDescription() + "'");
6669 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6670 error("Invalid number of parameters detected");
6673 // Create the call instruction
6674 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
6675 CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
6676 CI->setCallingConv(upgradeCallingConv((yyvsp[(2) - (7)].UIntVal)));
6677 (yyval.InstVal).I = CI;
6679 delete (yyvsp[(3) - (7)].TypeVal).PAT;
6680 delete (yyvsp[(6) - (7)].ValueList);
6681 lastCallingConv = OldCallingConv::C;
6686 #line 3791 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6688 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
6693 #line 3799 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6694 { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
6698 #line 3800 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6699 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6703 #line 3804 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6704 { (yyval.BoolVal) = true; ;}
6708 #line 3805 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6709 { (yyval.BoolVal) = false; ;}
6713 #line 3809 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6715 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get();
6716 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S);
6717 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6718 delete (yyvsp[(2) - (3)].TypeVal).PAT;
6723 #line 3815 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6725 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get();
6726 (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned();
6727 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (6)].TypeVal).S);
6728 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6729 delete (yyvsp[(2) - (6)].TypeVal).PAT;
6734 #line 3822 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6736 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get();
6737 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S);
6738 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6739 delete (yyvsp[(2) - (3)].TypeVal).PAT;
6744 #line 3828 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6746 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get();
6747 (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned();
6748 (yyval.InstVal).S.makeComposite((yyvsp[(4) - (6)].PrimType).S);
6749 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6750 delete (yyvsp[(2) - (6)].TypeVal).PAT;
6755 #line 3835 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6757 const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
6758 if (!isa<PointerType>(PTy))
6759 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
6760 (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
6761 (yyval.InstVal).S.makeSignless();
6766 #line 3842 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6768 const Type* Ty = (yyvsp[(3) - (4)].TypeVal).PAT->get();
6769 (yyvsp[(4) - (4)].ValIDVal).S.copy((yyvsp[(3) - (4)].TypeVal).S);
6770 if (!isa<PointerType>(Ty))
6771 error("Can't load from nonpointer type: " + Ty->getDescription());
6772 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6773 error("Can't load from pointer of non-first-class type: " +
6774 Ty->getDescription());
6775 Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
6776 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
6777 (yyval.InstVal).S.copy((yyvsp[(3) - (4)].TypeVal).S.get(0));
6778 delete (yyvsp[(3) - (4)].TypeVal).PAT;
6783 #line 3855 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6785 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(5) - (6)].TypeVal).S);
6786 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).PAT->get());
6788 error("Can't store to a nonpointer type: " +
6789 (yyvsp[(5) - (6)].TypeVal).PAT->get()->getDescription());
6790 const Type *ElTy = PTy->getElementType();
6791 Value *StoreVal = (yyvsp[(3) - (6)].ValueVal).V;
6792 Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
6793 if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType()) {
6794 StoreVal = handleSRetFuncTypeMerge((yyvsp[(3) - (6)].ValueVal).V, ElTy);
6796 error("Can't store '" + (yyvsp[(3) - (6)].ValueVal).V->getType()->getDescription() +
6797 "' into space of type '" + ElTy->getDescription() + "'");
6799 PTy = PointerType::get(StoreVal->getType());
6800 if (Constant *C = dyn_cast<Constant>(tmpVal))
6801 tmpVal = ConstantExpr::getBitCast(C, PTy);
6803 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6806 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[(1) - (6)].BoolVal));
6807 (yyval.InstVal).S.makeSignless();
6808 delete (yyvsp[(5) - (6)].TypeVal).PAT;
6813 #line 3881 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6815 (yyvsp[(3) - (4)].ValIDVal).S.copy((yyvsp[(2) - (4)].TypeVal).S);
6816 const Type* Ty = (yyvsp[(2) - (4)].TypeVal).PAT->get();
6817 if (!isa<PointerType>(Ty))
6818 error("getelementptr insn requires pointer operand");
6820 std::vector<Value*> VIndices;
6821 upgradeGEPInstIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
6823 Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
6824 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size());
6825 ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[(2) - (4)].TypeVal).S);
6826 (yyval.InstVal).S.copy(getElementSign(VI, VIndices));
6827 delete (yyvsp[(2) - (4)].TypeVal).PAT;
6828 delete (yyvsp[(4) - (4)].ValueList);
6833 /* Line 1267 of yacc.c. */
6834 #line 6835 "UpgradeParser.tab.c"
6837 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6841 YY_STACK_PRINT (yyss, yyssp);
6846 /* Now `shift' the result of the reduction. Determine what state
6847 that goes to, based on the state we popped back to and the rule
6848 number reduced by. */
6852 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6853 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
6854 yystate = yytable[yystate];
6856 yystate = yydefgoto[yyn - YYNTOKENS];
6861 /*------------------------------------.
6862 | yyerrlab -- here on detecting error |
6863 `------------------------------------*/
6865 /* If not already recovering from an error, report this error. */
6869 #if ! YYERROR_VERBOSE
6870 yyerror (YY_("syntax error"));
6873 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6874 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6876 YYSIZE_T yyalloc = 2 * yysize;
6877 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6878 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6879 if (yymsg != yymsgbuf)
6880 YYSTACK_FREE (yymsg);
6881 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6883 yymsg_alloc = yyalloc;
6887 yymsg_alloc = sizeof yymsgbuf;
6891 if (0 < yysize && yysize <= yymsg_alloc)
6893 (void) yysyntax_error (yymsg, yystate, yychar);
6898 yyerror (YY_("syntax error"));
6900 goto yyexhaustedlab;
6908 if (yyerrstatus == 3)
6910 /* If just tried and failed to reuse look-ahead token after an
6911 error, discard it. */
6913 if (yychar <= YYEOF)
6915 /* Return failure if at end of input. */
6916 if (yychar == YYEOF)
6921 yydestruct ("Error: discarding",
6927 /* Else will try to reuse look-ahead token after shifting the error
6932 /*---------------------------------------------------.
6933 | yyerrorlab -- error raised explicitly by YYERROR. |
6934 `---------------------------------------------------*/
6937 /* Pacify compilers like GCC when the user code never invokes
6938 YYERROR and the label yyerrorlab therefore never appears in user
6940 if (/*CONSTCOND*/ 0)
6943 /* Do not reclaim the symbols of the rule which action triggered
6947 YY_STACK_PRINT (yyss, yyssp);
6952 /*-------------------------------------------------------------.
6953 | yyerrlab1 -- common code for both syntax error and YYERROR. |
6954 `-------------------------------------------------------------*/
6956 yyerrstatus = 3; /* Each real token shifted decrements this. */
6960 yyn = yypact[yystate];
6961 if (yyn != YYPACT_NINF)
6964 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6972 /* Pop the current state because it cannot handle the error token. */
6977 yydestruct ("Error: popping",
6978 yystos[yystate], yyvsp);
6981 YY_STACK_PRINT (yyss, yyssp);
6990 /* Shift the error token. */
6991 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6997 /*-------------------------------------.
6998 | yyacceptlab -- YYACCEPT comes here. |
6999 `-------------------------------------*/
7004 /*-----------------------------------.
7005 | yyabortlab -- YYABORT comes here. |
7006 `-----------------------------------*/
7012 /*-------------------------------------------------.
7013 | yyexhaustedlab -- memory exhaustion comes here. |
7014 `-------------------------------------------------*/
7016 yyerror (YY_("memory exhausted"));
7022 if (yychar != YYEOF && yychar != YYEMPTY)
7023 yydestruct ("Cleanup: discarding lookahead",
7025 /* Do not reclaim the symbols of the rule which action triggered
7026 this YYABORT or YYACCEPT. */
7028 YY_STACK_PRINT (yyss, yyssp);
7029 while (yyssp != yyss)
7031 yydestruct ("Cleanup: popping",
7032 yystos[*yyssp], yyvsp);
7037 YYSTACK_FREE (yyss);
7040 if (yymsg != yymsgbuf)
7041 YYSTACK_FREE (yymsg);
7043 /* Make sure YYID is used. */
7044 return YYID (yyresult);
7048 #line 3899 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
7051 int yyerror(const char *ErrorMsg) {
7053 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
7054 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
7055 std::string errMsg = where + "error: " + std::string(ErrorMsg);
7056 if (yychar != YYEMPTY && yychar != 0)
7057 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
7059 std::cerr << "llvm-upgrade: " << errMsg << '\n';
7060 std::cout << "llvm-upgrade: parse failed.\n";
7064 void warning(const std::string& ErrorMsg) {
7066 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
7067 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
7068 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
7069 if (yychar != YYEMPTY && yychar != 0)
7070 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
7072 std::cerr << "llvm-upgrade: " << errMsg << '\n';
7075 void error(const std::string& ErrorMsg, int LineNo) {
7076 if (LineNo == -1) LineNo = Upgradelineno;
7077 Upgradelineno = LineNo;
7078 yyerror(ErrorMsg.c_str());