1 /* A Bison parser, made by GNU Bison 2.1. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
40 #define YYBISON_VERSION "2.1"
43 #define YYSKELETON_NAME "yacc.c"
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
51 /* Substitute the variable and function names. */
52 #define yyparse Upgradeparse
53 #define yylex Upgradelex
54 #define yyerror Upgradeerror
55 #define yylval Upgradelval
56 #define yychar Upgradechar
57 #define yydebug Upgradedebug
58 #define yynerrs Upgradenerrs
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
90 ZEROINITIALIZER = 281,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
178 EXTRACTELEMENT = 369,
219 #define ESINT64VAL 258
220 #define EUINT64VAL 259
240 #define STRINGCONSTANT 279
241 #define IMPLEMENTATION 280
242 #define ZEROINITIALIZER 281
253 #define DOTDOTDOT 292
260 #define APPENDING 299
261 #define DLLIMPORT 300
262 #define DLLEXPORT 301
263 #define EXTERN_WEAK 302
270 #define POINTERSIZE 309
279 #define SIDEEFFECT 318
282 #define CSRETCC_TOK 321
283 #define FASTCC_TOK 322
284 #define COLDCC_TOK 323
285 #define X86_STDCALLCC_TOK 324
286 #define X86_FASTCALLCC_TOK 325
287 #define DATALAYOUT 326
292 #define UNREACHABLE 331
322 #define GETELEMENTPTR 361
330 #define EXTRACTELEMENT 369
331 #define INSERTELEMENT 370
332 #define SHUFFLEVECTOR 371
333 #define VAARG_old 372
334 #define VANEXT_old 373
372 /* Copy the first part of user declarations. */
373 #line 14 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
375 #include "UpgradeInternals.h"
376 #include "llvm/CallingConv.h"
377 #include "llvm/InlineAsm.h"
378 #include "llvm/Instructions.h"
379 #include "llvm/Module.h"
380 #include "llvm/SymbolTable.h"
381 #include "llvm/Support/GetElementPtrTypeIterator.h"
382 #include "llvm/ADT/STLExtras.h"
383 #include "llvm/Support/MathExtras.h"
389 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
390 // relating to upreferences in the input stream.
392 //#define DEBUG_UPREFS 1
394 #define UR_OUT(X) std::cerr << X
399 #define YYERROR_VERBOSE 1
400 #define YYINCLUDED_STDLIB_H
406 int yyerror(const char*);
407 static void warning(const std::string& WarningMsg);
411 std::istream* LexInput;
412 static std::string CurFilename;
414 // This bool controls whether attributes are ever added to function declarations
415 // definitions and calls.
416 static bool AddAttributes = false;
418 static Module *ParserResult;
419 static bool ObsoleteVarArgs;
420 static bool NewVarArgs;
421 static BasicBlock *CurBB;
422 static GlobalVariable *CurGV;
424 // This contains info used when building the body of a function. It is
425 // destroyed when the function is completed.
427 typedef std::vector<Value *> ValueList; // Numbered defs
429 typedef std::pair<std::string,const Type*> RenameMapKey;
430 typedef std::map<RenameMapKey,std::string> RenameMapType;
433 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
434 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
436 static struct PerModuleInfo {
437 Module *CurrentModule;
438 std::map<const Type *, ValueList> Values; // Module level numbered definitions
439 std::map<const Type *,ValueList> LateResolveValues;
440 std::vector<PATypeHolder> Types;
441 std::map<ValID, PATypeHolder> LateResolveTypes;
442 static Module::Endianness Endian;
443 static Module::PointerSize PointerSize;
444 RenameMapType RenameMap;
446 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
447 /// how they were referenced and on which line of the input they came from so
448 /// that we can resolve them later and print error messages as appropriate.
449 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
451 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
452 // references to global values. Global values may be referenced before they
453 // are defined, and if so, the temporary object that they represent is held
454 // here. This is used for forward references of GlobalValues.
456 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
458 GlobalRefsType GlobalRefs;
461 // If we could not resolve some functions at function compilation time
462 // (calls to functions before they are defined), resolve them now... Types
463 // are resolved when the constant pool has been completely parsed.
465 ResolveDefinitions(LateResolveValues);
467 // Check to make sure that all global value forward references have been
470 if (!GlobalRefs.empty()) {
471 std::string UndefinedReferences = "Unresolved global references exist:\n";
473 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
475 UndefinedReferences += " " + I->first.first->getDescription() + " " +
476 I->first.second.getName() + "\n";
478 error(UndefinedReferences);
482 if (CurrentModule->getDataLayout().empty()) {
483 std::string dataLayout;
484 if (Endian != Module::AnyEndianness)
485 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
486 if (PointerSize != Module::AnyPointerSize) {
487 if (!dataLayout.empty())
489 dataLayout.append(PointerSize == Module::Pointer64 ?
490 "p:64:64" : "p:32:32");
492 CurrentModule->setDataLayout(dataLayout);
495 Values.clear(); // Clear out function local definitions
500 // GetForwardRefForGlobal - Check to see if there is a forward reference
501 // for this global. If so, remove it from the GlobalRefs map and return it.
502 // If not, just return null.
503 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
504 // Check to see if there is a forward reference to this global variable...
505 // if there is, eliminate it and patch the reference to use the new def'n.
506 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
507 GlobalValue *Ret = 0;
508 if (I != GlobalRefs.end()) {
514 void setEndianness(Module::Endianness E) { Endian = E; }
515 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
518 Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
519 Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
521 static struct PerFunctionInfo {
522 Function *CurrentFunction; // Pointer to current function being created
524 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
525 std::map<const Type*, ValueList> LateResolveValues;
526 bool isDeclare; // Is this function a forward declararation?
527 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
529 /// BBForwardRefs - When we see forward references to basic blocks, keep
530 /// track of them here.
531 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
532 std::vector<BasicBlock*> NumberedBlocks;
533 RenameMapType RenameMap;
536 inline PerFunctionInfo() {
539 Linkage = GlobalValue::ExternalLinkage;
542 inline void FunctionStart(Function *M) {
547 void FunctionDone() {
548 NumberedBlocks.clear();
550 // Any forward referenced blocks left?
551 if (!BBForwardRefs.empty()) {
552 error("Undefined reference to label " +
553 BBForwardRefs.begin()->first->getName());
557 // Resolve all forward references now.
558 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
560 Values.clear(); // Clear out function local definitions
564 Linkage = GlobalValue::ExternalLinkage;
566 } CurFun; // Info for the current function...
568 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
571 //===----------------------------------------------------------------------===//
572 // Code to handle definitions of all the types
573 //===----------------------------------------------------------------------===//
575 static int InsertValue(Value *V,
576 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
577 if (V->hasName()) return -1; // Is this a numbered definition?
579 // Yes, insert the value into the value table...
580 ValueList &List = ValueTab[V->getType()];
582 return List.size()-1;
585 static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
587 case ValID::NumberVal: // Is it a numbered definition?
588 // Module constants occupy the lowest numbered slots...
589 if ((unsigned)D.Num < CurModule.Types.size()) {
590 return CurModule.Types[(unsigned)D.Num];
593 case ValID::NameVal: // Is it a named definition?
594 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
595 D.destroy(); // Free old strdup'd memory...
600 error("Internal parser error: Invalid symbol type reference");
604 // If we reached here, we referenced either a symbol that we don't know about
605 // or an id number that hasn't been read yet. We may be referencing something
606 // forward, so just create an entry to be resolved later and get to it...
608 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
611 if (inFunctionScope()) {
612 if (D.Type == ValID::NameVal) {
613 error("Reference to an undefined type: '" + D.getName() + "'");
616 error("Reference to an undefined type: #" + itostr(D.Num));
621 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
622 if (I != CurModule.LateResolveTypes.end())
625 Type *Typ = OpaqueType::get();
626 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
630 // getExistingValue - Look up the value specified by the provided type and
631 // the provided ValID. If the value exists and has already been defined, return
632 // it. Otherwise return null.
634 static Value *getExistingValue(const Type *Ty, const ValID &D) {
635 if (isa<FunctionType>(Ty)) {
636 error("Functions are not values and must be referenced as pointers");
640 case ValID::NumberVal: { // Is it a numbered definition?
641 unsigned Num = (unsigned)D.Num;
643 // Module constants occupy the lowest numbered slots...
644 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
645 if (VI != CurModule.Values.end()) {
646 if (Num < VI->second.size())
647 return VI->second[Num];
648 Num -= VI->second.size();
651 // Make sure that our type is within bounds
652 VI = CurFun.Values.find(Ty);
653 if (VI == CurFun.Values.end()) return 0;
655 // Check that the number is within bounds...
656 if (VI->second.size() <= Num) return 0;
658 return VI->second[Num];
661 case ValID::NameVal: { // Is it a named definition?
662 // Get the name out of the ID
663 std::string Name(D.Name);
665 RenameMapKey Key = std::make_pair(Name, Ty);
666 if (inFunctionScope()) {
667 // See if the name was renamed
668 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
669 std::string LookupName;
670 if (I != CurFun.RenameMap.end())
671 LookupName = I->second;
674 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
675 V = SymTab.lookup(Ty, LookupName);
678 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
679 std::string LookupName;
680 if (I != CurModule.RenameMap.end())
681 LookupName = I->second;
684 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
689 D.destroy(); // Free old strdup'd memory...
693 // Check to make sure that "Ty" is an integral type, and that our
694 // value will fit into the specified type...
695 case ValID::ConstSIntVal: // Is it a constant pool reference??
696 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
697 error("Signed integral constant '" + itostr(D.ConstPool64) +
698 "' is invalid for type '" + Ty->getDescription() + "'");
700 return ConstantInt::get(Ty, D.ConstPool64);
702 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
703 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
704 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
705 error("Integral constant '" + utostr(D.UConstPool64) +
706 "' is invalid or out of range");
707 else // This is really a signed reference. Transmogrify.
708 return ConstantInt::get(Ty, D.ConstPool64);
710 return ConstantInt::get(Ty, D.UConstPool64);
712 case ValID::ConstFPVal: // Is it a floating point const pool reference?
713 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
714 error("FP constant invalid for type");
715 return ConstantFP::get(Ty, D.ConstPoolFP);
717 case ValID::ConstNullVal: // Is it a null value?
718 if (!isa<PointerType>(Ty))
719 error("Cannot create a a non pointer null");
720 return ConstantPointerNull::get(cast<PointerType>(Ty));
722 case ValID::ConstUndefVal: // Is it an undef value?
723 return UndefValue::get(Ty);
725 case ValID::ConstZeroVal: // Is it a zero value?
726 return Constant::getNullValue(Ty);
728 case ValID::ConstantVal: // Fully resolved constant?
729 if (D.ConstantValue->getType() != Ty)
730 error("Constant expression type different from required type");
731 return D.ConstantValue;
733 case ValID::InlineAsmVal: { // Inline asm expression
734 const PointerType *PTy = dyn_cast<PointerType>(Ty);
735 const FunctionType *FTy =
736 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
737 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
738 error("Invalid type for asm constraint string");
739 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
740 D.IAD->HasSideEffects);
741 D.destroy(); // Free InlineAsmDescriptor.
745 assert(0 && "Unhandled case");
749 assert(0 && "Unhandled case");
753 // getVal - This function is identical to getExistingValue, except that if a
754 // value is not already defined, it "improvises" by creating a placeholder var
755 // that looks and acts just like the requested variable. When the value is
756 // defined later, all uses of the placeholder variable are replaced with the
759 static Value *getVal(const Type *Ty, const ValID &ID) {
760 if (Ty == Type::LabelTy)
761 error("Cannot use a basic block here");
763 // See if the value has already been defined.
764 Value *V = getExistingValue(Ty, ID);
767 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
768 error("Invalid use of a composite type");
770 // If we reached here, we referenced either a symbol that we don't know about
771 // or an id number that hasn't been read yet. We may be referencing something
772 // forward, so just create an entry to be resolved later and get to it...
773 V = new Argument(Ty);
775 // Remember where this forward reference came from. FIXME, shouldn't we try
776 // to recycle these things??
777 CurModule.PlaceHolderInfo.insert(
778 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
780 if (inFunctionScope())
781 InsertValue(V, CurFun.LateResolveValues);
783 InsertValue(V, CurModule.LateResolveValues);
787 /// getBBVal - This is used for two purposes:
788 /// * If isDefinition is true, a new basic block with the specified ID is being
790 /// * If isDefinition is true, this is a reference to a basic block, which may
791 /// or may not be a forward reference.
793 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
794 assert(inFunctionScope() && "Can't get basic block at global scope");
800 error("Illegal label reference " + ID.getName());
802 case ValID::NumberVal: // Is it a numbered definition?
803 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
804 CurFun.NumberedBlocks.resize(ID.Num+1);
805 BB = CurFun.NumberedBlocks[ID.Num];
807 case ValID::NameVal: // Is it a named definition?
809 if (Value *N = CurFun.CurrentFunction->
810 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
811 if (N->getType() != Type::LabelTy)
812 error("Name '" + Name + "' does not refer to a BasicBlock");
813 BB = cast<BasicBlock>(N);
818 // See if the block has already been defined.
820 // If this is the definition of the block, make sure the existing value was
821 // just a forward reference. If it was a forward reference, there will be
822 // an entry for it in the PlaceHolderInfo map.
823 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
824 // The existing value was a definition, not a forward reference.
825 error("Redefinition of label " + ID.getName());
827 ID.destroy(); // Free strdup'd memory.
831 // Otherwise this block has not been seen before.
832 BB = new BasicBlock("", CurFun.CurrentFunction);
833 if (ID.Type == ValID::NameVal) {
834 BB->setName(ID.Name);
836 CurFun.NumberedBlocks[ID.Num] = BB;
839 // If this is not a definition, keep track of it so we can use it as a forward
842 // Remember where this forward reference came from.
843 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
845 // The forward declaration could have been inserted anywhere in the
846 // function: insert it into the correct place now.
847 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
848 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
855 //===----------------------------------------------------------------------===//
856 // Code to handle forward references in instructions
857 //===----------------------------------------------------------------------===//
859 // This code handles the late binding needed with statements that reference
860 // values not defined yet... for example, a forward branch, or the PHI node for
863 // This keeps a table (CurFun.LateResolveValues) of all such forward references
864 // and back patchs after we are done.
867 // ResolveDefinitions - If we could not resolve some defs at parsing
868 // time (forward branches, phi functions for loops, etc...) resolve the
872 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
873 std::map<const Type*,ValueList> *FutureLateResolvers) {
874 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
875 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
876 E = LateResolvers.end(); LRI != E; ++LRI) {
877 ValueList &List = LRI->second;
878 while (!List.empty()) {
879 Value *V = List.back();
882 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
883 CurModule.PlaceHolderInfo.find(V);
884 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
886 ValID &DID = PHI->second.first;
888 Value *TheRealValue = getExistingValue(LRI->first, DID);
890 V->replaceAllUsesWith(TheRealValue);
892 CurModule.PlaceHolderInfo.erase(PHI);
893 } else if (FutureLateResolvers) {
894 // Functions have their unresolved items forwarded to the module late
896 InsertValue(V, *FutureLateResolvers);
898 if (DID.Type == ValID::NameVal) {
899 error("Reference to an invalid definition: '" +DID.getName()+
900 "' of type '" + V->getType()->getDescription() + "'",
904 error("Reference to an invalid definition: #" +
905 itostr(DID.Num) + " of type '" +
906 V->getType()->getDescription() + "'", PHI->second.second);
913 LateResolvers.clear();
916 // ResolveTypeTo - A brand new type was just declared. This means that (if
917 // name is not null) things referencing Name can be resolved. Otherwise, things
918 // refering to the number can be resolved. Do this now.
920 static void ResolveTypeTo(char *Name, const Type *ToTy) {
922 if (Name) D = ValID::create(Name);
923 else D = ValID::create((int)CurModule.Types.size());
925 std::map<ValID, PATypeHolder>::iterator I =
926 CurModule.LateResolveTypes.find(D);
927 if (I != CurModule.LateResolveTypes.end()) {
928 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
929 CurModule.LateResolveTypes.erase(I);
933 static std::string makeNameUnique(const std::string& Name) {
934 static unsigned UniqueNameCounter = 1;
935 std::string Result(Name);
936 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
940 // setValueName - Set the specified value to the name given. The name may be
941 // null potentially, in which case this is a noop. The string passed in is
942 // assumed to be a malloc'd string buffer, and is free'd by this function.
944 static void setValueName(Value *V, char *NameStr) {
946 std::string Name(NameStr); // Copy string
947 free(NameStr); // Free old string
949 if (V->getType() == Type::VoidTy) {
950 error("Can't assign name '" + Name + "' to value with void type");
954 assert(inFunctionScope() && "Must be in function scope");
956 // Search the function's symbol table for an existing value of this name
958 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
959 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
960 for ( ; PI != PE; ++PI) {
961 SymbolTable::value_const_iterator VI = PI->second.find(Name);
962 if (VI != PI->second.end()) {
963 Existing = VI->second;
968 if (Existing->getType() == V->getType()) {
969 // The type of the Existing value and the new one are the same. This
970 // is probably a type plane collapsing error. If the types involved
971 // are both integer, just rename it. Otherwise it
972 // is a redefinition error.
973 if (!Existing->getType()->isInteger()) {
974 error("Redefinition of value named '" + Name + "' in the '" +
975 V->getType()->getDescription() + "' type plane");
979 // In LLVM 2.0 we don't allow names to be re-used for any values in a
980 // function, regardless of Type. Previously re-use of names was okay as
981 // long as they were distinct types. With type planes collapsing because
982 // of the signedness change and because of PR411, this can no longer be
983 // supported. We must search the entire symbol table for a conflicting
984 // name and make the name unique. No warning is needed as this can't
986 std::string NewName = makeNameUnique(Name);
987 // We're changing the name but it will probably be used by other
988 // instructions as operands later on. Consequently we have to retain
989 // a mapping of the renaming that we're doing.
990 RenameMapKey Key = std::make_pair(Name,V->getType());
991 CurFun.RenameMap[Key] = NewName;
1000 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1001 /// this is a declaration, otherwise it is a definition.
1002 static GlobalVariable *
1003 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1004 bool isConstantGlobal, const Type *Ty,
1005 Constant *Initializer) {
1006 if (isa<FunctionType>(Ty))
1007 error("Cannot declare global vars of function type");
1009 const PointerType *PTy = PointerType::get(Ty);
1013 Name = NameStr; // Copy string
1014 free(NameStr); // Free old string
1017 // See if this global value was forward referenced. If so, recycle the
1020 if (!Name.empty()) {
1021 ID = ValID::create((char*)Name.c_str());
1023 ID = ValID::create((int)CurModule.Values[PTy].size());
1026 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1027 // Move the global to the end of the list, from whereever it was
1028 // previously inserted.
1029 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1030 CurModule.CurrentModule->getGlobalList().remove(GV);
1031 CurModule.CurrentModule->getGlobalList().push_back(GV);
1032 GV->setInitializer(Initializer);
1033 GV->setLinkage(Linkage);
1034 GV->setConstant(isConstantGlobal);
1035 InsertValue(GV, CurModule.Values);
1039 // If this global has a name, check to see if there is already a definition
1040 // of this global in the module and emit warnings if there are conflicts.
1041 if (!Name.empty()) {
1042 // The global has a name. See if there's an existing one of the same name.
1043 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1044 // We found an existing global ov the same name. This isn't allowed
1045 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1046 // can at least compile. This can happen because of type planes
1047 // There is alread a global of the same name which means there is a
1048 // conflict. Let's see what we can do about it.
1049 std::string NewName(makeNameUnique(Name));
1050 if (Linkage == GlobalValue::InternalLinkage) {
1051 // The linkage type is internal so just warn about the rename without
1052 // invoking "scarey language" about linkage failures. GVars with
1053 // InternalLinkage can be renamed at will.
1054 warning("Global variable '" + Name + "' was renamed to '"+
1057 // The linkage of this gval is external so we can't reliably rename
1058 // it because it could potentially create a linking problem.
1059 // However, we can't leave the name conflict in the output either or
1060 // it won't assemble with LLVM 2.0. So, all we can do is rename
1061 // this one to something unique and emit a warning about the problem.
1062 warning("Renaming global variable '" + Name + "' to '" + NewName +
1063 "' may cause linkage errors");
1066 // Put the renaming in the global rename map
1067 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1068 CurModule.RenameMap[Key] = NewName;
1075 // Otherwise there is no existing GV to use, create one now.
1076 GlobalVariable *GV =
1077 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1078 CurModule.CurrentModule);
1079 InsertValue(GV, CurModule.Values);
1083 // setTypeName - Set the specified type to the name given. The name may be
1084 // null potentially, in which case this is a noop. The string passed in is
1085 // assumed to be a malloc'd string buffer, and is freed by this function.
1087 // This function returns true if the type has already been defined, but is
1088 // allowed to be redefined in the specified context. If the name is a new name
1089 // for the type plane, it is inserted and false is returned.
1090 static bool setTypeName(const Type *T, char *NameStr) {
1091 assert(!inFunctionScope() && "Can't give types function-local names");
1092 if (NameStr == 0) return false;
1094 std::string Name(NameStr); // Copy string
1095 free(NameStr); // Free old string
1097 // We don't allow assigning names to void type
1098 if (T == Type::VoidTy) {
1099 error("Can't assign name '" + Name + "' to the void type");
1103 // Set the type name, checking for conflicts as we do so.
1104 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1106 if (AlreadyExists) { // Inserting a name that is already defined???
1107 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1108 assert(Existing && "Conflict but no matching type?");
1110 // There is only one case where this is allowed: when we are refining an
1111 // opaque type. In this case, Existing will be an opaque type.
1112 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1113 // We ARE replacing an opaque type!
1114 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1118 // Otherwise, this is an attempt to redefine a type. That's okay if
1119 // the redefinition is identical to the original. This will be so if
1120 // Existing and T point to the same Type object. In this one case we
1121 // allow the equivalent redefinition.
1122 if (Existing == T) return true; // Yes, it's equal.
1124 // Any other kind of (non-equivalent) redefinition is an error.
1125 error("Redefinition of type named '" + Name + "' in the '" +
1126 T->getDescription() + "' type plane");
1132 //===----------------------------------------------------------------------===//
1133 // Code for handling upreferences in type names...
1136 // TypeContains - Returns true if Ty directly contains E in it.
1138 static bool TypeContains(const Type *Ty, const Type *E) {
1139 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1140 E) != Ty->subtype_end();
1144 struct UpRefRecord {
1145 // NestingLevel - The number of nesting levels that need to be popped before
1146 // this type is resolved.
1147 unsigned NestingLevel;
1149 // LastContainedTy - This is the type at the current binding level for the
1150 // type. Every time we reduce the nesting level, this gets updated.
1151 const Type *LastContainedTy;
1153 // UpRefTy - This is the actual opaque type that the upreference is
1154 // represented with.
1155 OpaqueType *UpRefTy;
1157 UpRefRecord(unsigned NL, OpaqueType *URTy)
1158 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1162 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1163 static std::vector<UpRefRecord> UpRefs;
1165 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1166 /// called. It loops through the UpRefs vector, which is a list of the
1167 /// currently active types. For each type, if the up reference is contained in
1168 /// the newly completed type, we decrement the level count. When the level
1169 /// count reaches zero, the upreferenced type is the type that is passed in:
1170 /// thus we can complete the cycle.
1172 static PATypeHolder HandleUpRefs(const Type *ty) {
1173 // If Ty isn't abstract, or if there are no up-references in it, then there is
1174 // nothing to resolve here.
1175 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1177 PATypeHolder Ty(ty);
1178 UR_OUT("Type '" << Ty->getDescription() <<
1179 "' newly formed. Resolving upreferences.\n" <<
1180 UpRefs.size() << " upreferences active!\n");
1182 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1183 // to zero), we resolve them all together before we resolve them to Ty. At
1184 // the end of the loop, if there is anything to resolve to Ty, it will be in
1186 OpaqueType *TypeToResolve = 0;
1188 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1189 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1190 << UpRefs[i].second->getDescription() << ") = "
1191 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1192 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1193 // Decrement level of upreference
1194 unsigned Level = --UpRefs[i].NestingLevel;
1195 UpRefs[i].LastContainedTy = Ty;
1196 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1197 if (Level == 0) { // Upreference should be resolved!
1198 if (!TypeToResolve) {
1199 TypeToResolve = UpRefs[i].UpRefTy;
1201 UR_OUT(" * Resolving upreference for "
1202 << UpRefs[i].second->getDescription() << "\n";
1203 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1204 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1205 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1206 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1208 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1209 --i; // Do not skip the next element...
1214 if (TypeToResolve) {
1215 UR_OUT(" * Resolving upreference for "
1216 << UpRefs[i].second->getDescription() << "\n";
1217 std::string OldName = TypeToResolve->getDescription());
1218 TypeToResolve->refineAbstractTypeTo(Ty);
1224 static inline Instruction::TermOps
1225 getTermOp(TermOps op) {
1227 default : assert(0 && "Invalid OldTermOp");
1228 case RetOp : return Instruction::Ret;
1229 case BrOp : return Instruction::Br;
1230 case SwitchOp : return Instruction::Switch;
1231 case InvokeOp : return Instruction::Invoke;
1232 case UnwindOp : return Instruction::Unwind;
1233 case UnreachableOp: return Instruction::Unreachable;
1237 static inline Instruction::BinaryOps
1238 getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1240 default : assert(0 && "Invalid OldBinaryOps");
1246 case SetGT : assert(0 && "Should use getCompareOp");
1247 case AddOp : return Instruction::Add;
1248 case SubOp : return Instruction::Sub;
1249 case MulOp : return Instruction::Mul;
1251 // This is an obsolete instruction so we must upgrade it based on the
1252 // types of its operands.
1253 bool isFP = Ty->isFloatingPoint();
1254 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1255 // If its a packed type we want to use the element type
1256 isFP = PTy->getElementType()->isFloatingPoint();
1258 return Instruction::FDiv;
1259 else if (Sign == Signed)
1260 return Instruction::SDiv;
1261 return Instruction::UDiv;
1263 case UDivOp : return Instruction::UDiv;
1264 case SDivOp : return Instruction::SDiv;
1265 case FDivOp : return Instruction::FDiv;
1267 // This is an obsolete instruction so we must upgrade it based on the
1268 // types of its operands.
1269 bool isFP = Ty->isFloatingPoint();
1270 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1271 // If its a packed type we want to use the element type
1272 isFP = PTy->getElementType()->isFloatingPoint();
1273 // Select correct opcode
1275 return Instruction::FRem;
1276 else if (Sign == Signed)
1277 return Instruction::SRem;
1278 return Instruction::URem;
1280 case URemOp : return Instruction::URem;
1281 case SRemOp : return Instruction::SRem;
1282 case FRemOp : return Instruction::FRem;
1283 case AndOp : return Instruction::And;
1284 case OrOp : return Instruction::Or;
1285 case XorOp : return Instruction::Xor;
1289 static inline Instruction::OtherOps
1290 getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1292 bool isSigned = Sign == Signed;
1293 bool isFP = Ty->isFloatingPoint();
1295 default : assert(0 && "Invalid OldSetCC");
1298 predicate = FCmpInst::FCMP_OEQ;
1299 return Instruction::FCmp;
1301 predicate = ICmpInst::ICMP_EQ;
1302 return Instruction::ICmp;
1306 predicate = FCmpInst::FCMP_UNE;
1307 return Instruction::FCmp;
1309 predicate = ICmpInst::ICMP_NE;
1310 return Instruction::ICmp;
1314 predicate = FCmpInst::FCMP_OLE;
1315 return Instruction::FCmp;
1318 predicate = ICmpInst::ICMP_SLE;
1320 predicate = ICmpInst::ICMP_ULE;
1321 return Instruction::ICmp;
1325 predicate = FCmpInst::FCMP_OGE;
1326 return Instruction::FCmp;
1329 predicate = ICmpInst::ICMP_SGE;
1331 predicate = ICmpInst::ICMP_UGE;
1332 return Instruction::ICmp;
1336 predicate = FCmpInst::FCMP_OLT;
1337 return Instruction::FCmp;
1340 predicate = ICmpInst::ICMP_SLT;
1342 predicate = ICmpInst::ICMP_ULT;
1343 return Instruction::ICmp;
1347 predicate = FCmpInst::FCMP_OGT;
1348 return Instruction::FCmp;
1351 predicate = ICmpInst::ICMP_SGT;
1353 predicate = ICmpInst::ICMP_UGT;
1354 return Instruction::ICmp;
1359 static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1361 default : assert(0 && "Invalid OldMemoryOps");
1362 case MallocOp : return Instruction::Malloc;
1363 case FreeOp : return Instruction::Free;
1364 case AllocaOp : return Instruction::Alloca;
1365 case LoadOp : return Instruction::Load;
1366 case StoreOp : return Instruction::Store;
1367 case GetElementPtrOp : return Instruction::GetElementPtr;
1371 static inline Instruction::OtherOps
1372 getOtherOp(OtherOps op, Signedness Sign) {
1374 default : assert(0 && "Invalid OldOtherOps");
1375 case PHIOp : return Instruction::PHI;
1376 case CallOp : return Instruction::Call;
1377 case ShlOp : return Instruction::Shl;
1380 return Instruction::AShr;
1381 return Instruction::LShr;
1382 case SelectOp : return Instruction::Select;
1383 case UserOp1 : return Instruction::UserOp1;
1384 case UserOp2 : return Instruction::UserOp2;
1385 case VAArg : return Instruction::VAArg;
1386 case ExtractElementOp : return Instruction::ExtractElement;
1387 case InsertElementOp : return Instruction::InsertElement;
1388 case ShuffleVectorOp : return Instruction::ShuffleVector;
1389 case ICmpOp : return Instruction::ICmp;
1390 case FCmpOp : return Instruction::FCmp;
1391 case LShrOp : return Instruction::LShr;
1392 case AShrOp : return Instruction::AShr;
1396 static inline Value*
1397 getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1398 Signedness DstSign, bool ForceInstruction = false) {
1399 Instruction::CastOps Opcode;
1400 const Type* SrcTy = Src->getType();
1402 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1403 // fp -> ptr cast is no longer supported but we must upgrade this
1404 // by doing a double cast: fp -> int -> ptr
1405 SrcTy = Type::Int64Ty;
1406 Opcode = Instruction::IntToPtr;
1407 if (isa<Constant>(Src)) {
1408 Src = ConstantExpr::getCast(Instruction::FPToUI,
1409 cast<Constant>(Src), SrcTy);
1411 std::string NewName(makeNameUnique(Src->getName()));
1412 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1414 } else if (isa<IntegerType>(DstTy) &&
1415 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1416 // cast type %x to bool was previously defined as setne type %x, null
1417 // The cast semantic is now to truncate, not compare so we must retain
1418 // the original intent by replacing the cast with a setne
1419 Constant* Null = Constant::getNullValue(SrcTy);
1420 Instruction::OtherOps Opcode = Instruction::ICmp;
1421 unsigned short predicate = ICmpInst::ICMP_NE;
1422 if (SrcTy->isFloatingPoint()) {
1423 Opcode = Instruction::FCmp;
1424 predicate = FCmpInst::FCMP_ONE;
1425 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1426 error("Invalid cast to bool");
1428 if (isa<Constant>(Src) && !ForceInstruction)
1429 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1431 return CmpInst::create(Opcode, predicate, Src, Null);
1433 // Determine the opcode to use by calling CastInst::getCastOpcode
1435 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1437 } else switch (op) {
1438 default: assert(0 && "Invalid cast token");
1439 case TruncOp: Opcode = Instruction::Trunc; break;
1440 case ZExtOp: Opcode = Instruction::ZExt; break;
1441 case SExtOp: Opcode = Instruction::SExt; break;
1442 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1443 case FPExtOp: Opcode = Instruction::FPExt; break;
1444 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1445 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1446 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1447 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1448 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1449 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1450 case BitCastOp: Opcode = Instruction::BitCast; break;
1453 if (isa<Constant>(Src) && !ForceInstruction)
1454 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1455 return CastInst::create(Opcode, Src, DstTy);
1458 static Instruction *
1459 upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1460 std::vector<Value*>& Args) {
1462 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1463 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1464 if (Args.size() != 2)
1465 error("Invalid prototype for " + Name + " prototype");
1466 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1468 static unsigned upgradeCount = 1;
1469 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1470 std::vector<const Type*> Params;
1471 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1472 if (Args.size() != 1)
1473 error("Invalid prototype for " + Name + " prototype");
1474 Params.push_back(PtrTy);
1475 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1476 const PointerType *PFTy = PointerType::get(FTy);
1477 Value* Func = getVal(PFTy, ID);
1478 std::string InstName("va_upgrade");
1479 InstName += llvm::utostr(upgradeCount++);
1480 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1481 return new CallInst(Func, Args);
1482 } else if (Name == "llvm.va_copy") {
1483 if (Args.size() != 2)
1484 error("Invalid prototype for " + Name + " prototype");
1485 Params.push_back(PtrTy);
1486 Params.push_back(PtrTy);
1487 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1488 const PointerType *PFTy = PointerType::get(FTy);
1489 Value* Func = getVal(PFTy, ID);
1490 std::string InstName0("va_upgrade");
1491 InstName0 += llvm::utostr(upgradeCount++);
1492 std::string InstName1("va_upgrade");
1493 InstName1 += llvm::utostr(upgradeCount++);
1494 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1495 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1496 return new CallInst(Func, Args);
1502 const Type* upgradeGEPIndices(const Type* PTy,
1503 std::vector<ValueInfo> *Indices,
1504 std::vector<Value*> &VIndices,
1505 std::vector<Constant*> *CIndices = 0) {
1506 // Traverse the indices with a gep_type_iterator so we can build the list
1507 // of constant and value indices for use later. Also perform upgrades
1509 if (CIndices) CIndices->clear();
1510 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1511 VIndices.push_back((*Indices)[i].V);
1512 generic_gep_type_iterator<std::vector<Value*>::iterator>
1513 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1514 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1515 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1516 Value *Index = VIndices[i];
1517 if (CIndices && !isa<Constant>(Index))
1518 error("Indices to constant getelementptr must be constants");
1519 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1520 // struct indices to i32 struct indices with ZExt for compatibility.
1521 else if (isa<StructType>(*GTI)) { // Only change struct indices
1522 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1523 if (CUI->getType()->getBitWidth() == 8)
1525 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1527 // Make sure that unsigned SequentialType indices are zext'd to
1528 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1529 // all indices for SequentialType elements. We must retain the same
1530 // semantic (zext) for unsigned types.
1531 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
1532 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned)
1534 Index = ConstantExpr::getCast(Instruction::ZExt,
1535 cast<Constant>(Index), Type::Int64Ty);
1537 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1538 makeNameUnique("gep_upgrade"), CurBB);
1540 // Add to the CIndices list, if requested.
1542 CIndices->push_back(cast<Constant>(Index));
1546 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1548 error("Index list invalid for constant getelementptr");
1552 Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1553 bool debug, bool addAttrs)
1556 CurFilename = infile;
1559 AddAttributes = addAttrs;
1560 ObsoleteVarArgs = false;
1563 CurModule.CurrentModule = new Module(CurFilename);
1565 // Check to make sure the parser succeeded
1568 delete ParserResult;
1569 std::cerr << "llvm-upgrade: parse failed.\n";
1573 // Check to make sure that parsing produced a result
1574 if (!ParserResult) {
1575 std::cerr << "llvm-upgrade: no parse result.\n";
1579 // Reset ParserResult variable while saving its value for the result.
1580 Module *Result = ParserResult;
1583 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1586 if ((F = Result->getNamedFunction("llvm.va_start"))
1587 && F->getFunctionType()->getNumParams() == 0)
1588 ObsoleteVarArgs = true;
1589 if((F = Result->getNamedFunction("llvm.va_copy"))
1590 && F->getFunctionType()->getNumParams() == 1)
1591 ObsoleteVarArgs = true;
1594 if (ObsoleteVarArgs && NewVarArgs) {
1595 error("This file is corrupt: it uses both new and old style varargs");
1599 if(ObsoleteVarArgs) {
1600 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1601 if (F->arg_size() != 0) {
1602 error("Obsolete va_start takes 0 argument");
1608 //bar = alloca typeof(foo)
1612 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1613 const Type* ArgTy = F->getFunctionType()->getReturnType();
1614 const Type* ArgTyPtr = PointerType::get(ArgTy);
1615 Function* NF = cast<Function>(Result->getOrInsertFunction(
1616 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1618 while (!F->use_empty()) {
1619 CallInst* CI = cast<CallInst>(F->use_back());
1620 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1621 new CallInst(NF, bar, "", CI);
1622 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1623 CI->replaceAllUsesWith(foo);
1624 CI->getParent()->getInstList().erase(CI);
1626 Result->getFunctionList().erase(F);
1629 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1630 if(F->arg_size() != 1) {
1631 error("Obsolete va_end takes 1 argument");
1637 //bar = alloca 1 of typeof(foo)
1639 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1640 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1641 const Type* ArgTyPtr = PointerType::get(ArgTy);
1642 Function* NF = cast<Function>(Result->getOrInsertFunction(
1643 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
1645 while (!F->use_empty()) {
1646 CallInst* CI = cast<CallInst>(F->use_back());
1647 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1648 new StoreInst(CI->getOperand(1), bar, CI);
1649 new CallInst(NF, bar, "", CI);
1650 CI->getParent()->getInstList().erase(CI);
1652 Result->getFunctionList().erase(F);
1655 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1656 if(F->arg_size() != 1) {
1657 error("Obsolete va_copy takes 1 argument");
1662 //a = alloca 1 of typeof(foo)
1663 //b = alloca 1 of typeof(foo)
1668 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1669 const Type* ArgTy = F->getFunctionType()->getReturnType();
1670 const Type* ArgTyPtr = PointerType::get(ArgTy);
1671 Function* NF = cast<Function>(Result->getOrInsertFunction(
1672 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
1674 while (!F->use_empty()) {
1675 CallInst* CI = cast<CallInst>(F->use_back());
1676 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1677 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1678 new StoreInst(CI->getOperand(1), b, CI);
1679 new CallInst(NF, a, b, "", CI);
1680 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1681 CI->replaceAllUsesWith(foo);
1682 CI->getParent()->getInstList().erase(CI);
1684 Result->getFunctionList().erase(F);
1691 } // end llvm namespace
1693 using namespace llvm;
1697 /* Enabling traces. */
1702 /* Enabling verbose error messages. */
1703 #ifdef YYERROR_VERBOSE
1704 # undef YYERROR_VERBOSE
1705 # define YYERROR_VERBOSE 1
1707 # define YYERROR_VERBOSE 0
1710 /* Enabling the token table. */
1711 #ifndef YYTOKEN_TABLE
1712 # define YYTOKEN_TABLE 0
1715 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1716 #line 1337 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
1717 typedef union YYSTYPE {
1718 llvm::Module *ModuleVal;
1719 llvm::Function *FunctionVal;
1720 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1721 llvm::BasicBlock *BasicBlockVal;
1722 llvm::TerminatorInst *TermInstVal;
1723 llvm::InstrInfo InstVal;
1724 llvm::ConstInfo ConstVal;
1725 llvm::ValueInfo ValueVal;
1726 llvm::PATypeInfo TypeVal;
1727 llvm::TypeInfo PrimType;
1728 llvm::PHIListInfo PHIList;
1729 std::list<llvm::PATypeInfo> *TypeList;
1730 std::vector<llvm::ValueInfo> *ValueList;
1731 std::vector<llvm::ConstInfo> *ConstVector;
1734 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1735 // Represent the RHS of PHI node
1736 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1738 llvm::GlobalValue::LinkageTypes Linkage;
1746 char *StrVal; // This memory is strdup'd!
1747 llvm::ValID ValIDVal; // strdup'd memory maybe!
1749 llvm::BinaryOps BinaryOpVal;
1750 llvm::TermOps TermOpVal;
1751 llvm::MemoryOps MemOpVal;
1752 llvm::OtherOps OtherOpVal;
1753 llvm::CastOps CastOpVal;
1754 llvm::ICmpInst::Predicate IPred;
1755 llvm::FCmpInst::Predicate FPred;
1756 llvm::Module::Endianness Endianness;
1758 /* Line 196 of yacc.c. */
1759 #line 1760 "UpgradeParser.tab.c"
1760 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1761 # define YYSTYPE_IS_DECLARED 1
1762 # define YYSTYPE_IS_TRIVIAL 1
1767 /* Copy the second part of user declarations. */
1770 /* Line 219 of yacc.c. */
1771 #line 1772 "UpgradeParser.tab.c"
1773 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1774 # define YYSIZE_T __SIZE_TYPE__
1776 #if ! defined (YYSIZE_T) && defined (size_t)
1777 # define YYSIZE_T size_t
1779 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1780 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1781 # define YYSIZE_T size_t
1783 #if ! defined (YYSIZE_T)
1784 # define YYSIZE_T unsigned int
1790 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1791 # define YY_(msgid) dgettext ("bison-runtime", msgid)
1795 # define YY_(msgid) msgid
1799 #if ! defined (yyoverflow) || YYERROR_VERBOSE
1801 /* The parser invokes alloca or malloc; define the necessary symbols. */
1803 # ifdef YYSTACK_USE_ALLOCA
1804 # if YYSTACK_USE_ALLOCA
1806 # define YYSTACK_ALLOC __builtin_alloca
1808 # define YYSTACK_ALLOC alloca
1809 # if defined (__STDC__) || defined (__cplusplus)
1810 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1811 # define YYINCLUDED_STDLIB_H
1817 # ifdef YYSTACK_ALLOC
1818 /* Pacify GCC's `empty if-body' warning. */
1819 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1820 # ifndef YYSTACK_ALLOC_MAXIMUM
1821 /* The OS might guarantee only one guard page at the bottom of the stack,
1822 and a page size can be as small as 4096 bytes. So we cannot safely
1823 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1824 to allow for a few compiler-allocated temporary stack slots. */
1825 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1828 # define YYSTACK_ALLOC YYMALLOC
1829 # define YYSTACK_FREE YYFREE
1830 # ifndef YYSTACK_ALLOC_MAXIMUM
1831 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1837 # define YYMALLOC malloc
1838 # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1839 && (defined (__STDC__) || defined (__cplusplus)))
1840 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1844 # define YYFREE free
1845 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1846 && (defined (__STDC__) || defined (__cplusplus)))
1847 void free (void *); /* INFRINGES ON USER NAME SPACE */
1854 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1857 #if (! defined (yyoverflow) \
1858 && (! defined (__cplusplus) \
1859 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1861 /* A type that is properly aligned for any stack member. */
1868 /* The size of the maximum gap between one aligned stack and the next. */
1869 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1871 /* The size of an array large to enough to hold all stacks, each with
1873 # define YYSTACK_BYTES(N) \
1874 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1875 + YYSTACK_GAP_MAXIMUM)
1877 /* Copy COUNT objects from FROM to TO. The source and destination do
1880 # if defined (__GNUC__) && 1 < __GNUC__
1881 # define YYCOPY(To, From, Count) \
1882 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1884 # define YYCOPY(To, From, Count) \
1888 for (yyi = 0; yyi < (Count); yyi++) \
1889 (To)[yyi] = (From)[yyi]; \
1895 /* Relocate STACK from its old location to the new one. The
1896 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1897 elements in the stack, and YYPTR gives the new location of the
1898 stack. Advance YYPTR to a properly aligned location for the next
1900 # define YYSTACK_RELOCATE(Stack) \
1903 YYSIZE_T yynewbytes; \
1904 YYCOPY (&yyptr->Stack, Stack, yysize); \
1905 Stack = &yyptr->Stack; \
1906 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1907 yyptr += yynewbytes / sizeof (*yyptr); \
1913 #if defined (__STDC__) || defined (__cplusplus)
1914 typedef signed char yysigned_char;
1916 typedef short int yysigned_char;
1919 /* YYFINAL -- State number of the termination state. */
1921 /* YYLAST -- Last index in YYTABLE. */
1924 /* YYNTOKENS -- Number of terminals. */
1925 #define YYNTOKENS 166
1926 /* YYNNTS -- Number of nonterminals. */
1928 /* YYNRULES -- Number of rules. */
1929 #define YYNRULES 308
1930 /* YYNRULES -- Number of states. */
1931 #define YYNSTATES 604
1933 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1934 #define YYUNDEFTOK 2
1935 #define YYMAXUTOK 406
1937 #define YYTRANSLATE(YYX) \
1938 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1940 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1941 static const unsigned char yytranslate[] =
1943 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1944 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1945 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1946 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1947 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
1948 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1949 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
1950 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1951 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1952 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
1953 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1954 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1955 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
1956 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1957 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1958 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1959 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1960 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1961 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1962 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1963 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1964 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1965 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1966 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1967 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1968 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1969 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1970 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1971 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1972 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1973 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1974 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1975 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1976 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1977 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1978 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1979 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1980 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1981 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1982 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1983 145, 146, 147, 148, 149, 150, 151
1987 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1989 static const unsigned short int yyprhs[] =
1991 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1992 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1993 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1994 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1995 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1996 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1997 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
1998 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
1999 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2000 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2001 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2002 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2003 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2004 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2005 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2006 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2007 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2008 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2009 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2010 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2011 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2012 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2013 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2014 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2015 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2016 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2017 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2018 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2019 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2020 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2021 927, 928, 932, 939, 943, 950, 953, 958, 965
2024 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
2025 static const short int yyrhs[] =
2027 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2028 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2029 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2030 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2031 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
2032 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2033 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2034 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2035 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2036 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2037 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2038 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2039 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2040 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2041 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2042 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2043 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2044 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2045 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2046 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2047 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2048 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2049 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2050 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2051 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2052 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2053 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2054 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2055 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2056 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2057 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2058 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2059 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2060 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2061 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2062 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2063 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2064 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2065 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2066 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2067 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2068 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2069 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2070 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2071 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2072 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2073 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2074 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2075 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2076 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2077 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2078 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2079 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2080 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2081 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2082 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2083 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2084 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2085 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2086 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2087 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2088 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2089 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2090 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2091 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2092 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2093 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2094 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2095 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2096 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2097 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2098 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2099 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2100 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2101 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2102 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2103 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2104 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2105 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2106 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2107 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2108 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2109 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2110 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2111 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2112 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2113 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2114 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2115 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2116 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2117 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2118 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2119 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2120 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2121 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2122 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2123 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
2126 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2127 static const unsigned short int yyrline[] =
2129 0, 1477, 1477, 1478, 1486, 1487, 1497, 1497, 1497, 1497,
2130 1497, 1497, 1497, 1497, 1497, 1497, 1497, 1501, 1501, 1501,
2131 1505, 1505, 1505, 1505, 1505, 1505, 1509, 1509, 1510, 1510,
2132 1511, 1511, 1512, 1512, 1513, 1513, 1517, 1517, 1518, 1518,
2133 1519, 1519, 1520, 1520, 1521, 1521, 1522, 1522, 1523, 1523,
2134 1524, 1525, 1528, 1528, 1528, 1528, 1532, 1532, 1532, 1532,
2135 1532, 1532, 1532, 1533, 1533, 1533, 1533, 1533, 1533, 1539,
2136 1539, 1539, 1539, 1543, 1543, 1543, 1543, 1547, 1547, 1551,
2137 1551, 1556, 1559, 1564, 1565, 1566, 1567, 1568, 1569, 1570,
2138 1571, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1592,
2139 1593, 1601, 1602, 1610, 1619, 1620, 1627, 1628, 1632, 1636,
2140 1652, 1653, 1660, 1661, 1668, 1676, 1676, 1676, 1676, 1676,
2141 1676, 1676, 1677, 1677, 1677, 1677, 1677, 1682, 1686, 1690,
2142 1695, 1704, 1720, 1726, 1739, 1748, 1752, 1763, 1767, 1780,
2143 1784, 1791, 1792, 1798, 1805, 1817, 1847, 1860, 1883, 1911,
2144 1933, 1944, 1966, 1977, 1986, 1991, 2049, 2056, 2064, 2071,
2145 2078, 2082, 2086, 2095, 2110, 2123, 2132, 2160, 2173, 2182,
2146 2188, 2194, 2203, 2209, 2215, 2226, 2227, 2236, 2237, 2249,
2147 2258, 2259, 2260, 2261, 2262, 2278, 2298, 2300, 2302, 2302,
2148 2309, 2309, 2316, 2316, 2323, 2323, 2331, 2333, 2335, 2340,
2149 2354, 2355, 2359, 2362, 2370, 2374, 2381, 2385, 2389, 2393,
2150 2401, 2401, 2405, 2406, 2410, 2418, 2423, 2431, 2432, 2439,
2151 2446, 2450, 2556, 2556, 2560, 2570, 2570, 2574, 2578, 2580,
2152 2581, 2585, 2585, 2597, 2598, 2603, 2604, 2605, 2606, 2607,
2153 2608, 2609, 2610, 2611, 2632, 2635, 2650, 2651, 2656, 2656,
2154 2664, 2673, 2676, 2685, 2695, 2700, 2709, 2720, 2720, 2723,
2155 2726, 2729, 2733, 2739, 2754, 2760, 2811, 2814, 2820, 2830,
2156 2843, 2872, 2880, 2888, 2892, 2899, 2900, 2904, 2907, 2913,
2157 2930, 2946, 2960, 2972, 2984, 2995, 3004, 3013, 3022, 3029,
2158 3050, 3074, 3080, 3086, 3092, 3108, 3181, 3189, 3190, 3194,
2159 3195, 3199, 3205, 3211, 3217, 3223, 3230, 3242, 3256
2163 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2164 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2165 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2166 static const char *const yytname[] =
2168 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2169 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2170 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2171 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2172 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2173 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2174 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2175 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2176 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2177 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2178 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2179 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2180 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2181 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2182 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2183 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2184 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2185 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2186 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2187 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2188 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2189 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2190 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2191 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2192 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2193 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2194 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2195 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2196 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2197 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2198 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2199 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2200 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2201 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2202 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2203 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2204 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2205 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2206 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2207 "OptVolatile", "MemoryInst", 0
2212 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2214 static const unsigned short int yytoknum[] =
2216 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2217 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2218 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2219 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2220 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2221 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2222 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2223 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2224 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2225 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2226 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2227 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2228 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2229 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2230 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2231 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2232 60, 62, 123, 125, 42, 99
2236 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2237 static const unsigned char yyr1[] =
2239 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2240 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2241 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2242 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2243 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2244 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2245 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2246 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2247 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2248 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2249 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2250 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2251 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2252 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2253 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2254 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2255 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2256 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2257 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2258 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2259 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2260 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2261 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2262 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2263 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2264 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2265 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2266 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2267 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2268 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2269 243, 244, 244, 244, 244, 244, 244, 244, 244
2272 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2273 static const unsigned char yyr2[] =
2275 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2276 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2277 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2278 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2279 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2280 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2281 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2282 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2283 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2284 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2285 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2286 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2287 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2288 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2289 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2290 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2291 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2292 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2293 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2294 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2295 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2296 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2297 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2298 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2299 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2300 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2301 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2302 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2303 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2304 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2305 0, 3, 6, 3, 6, 2, 4, 6, 4
2308 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2309 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2310 means the default is an error. */
2311 static const unsigned short int yydefact[] =
2313 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2314 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2315 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2316 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2317 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2318 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2319 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2320 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2321 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2322 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2323 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2324 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2325 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2326 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2327 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2328 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2329 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2330 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2331 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2332 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2333 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2334 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2335 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2336 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2337 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2338 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2339 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2340 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2341 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
2342 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2343 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2344 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
2345 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2346 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2347 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2348 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2349 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2350 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2351 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2352 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2353 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2354 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2355 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2356 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2357 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2358 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2359 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2360 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2361 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2362 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2363 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2364 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2365 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2366 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2367 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2368 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2369 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2370 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2371 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2372 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2376 /* YYDEFGOTO[NTERM-NUM]. */
2377 static const short int yydefgoto[] =
2379 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2380 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2381 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2382 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2383 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2384 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2385 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2386 97, 286, 526, 527, 193, 194, 436, 195, 196
2389 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2391 #define YYPACT_NINF -508
2392 static const short int yypact[] =
2394 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2395 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2396 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2397 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2398 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2399 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2400 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2401 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2402 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2403 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2404 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2405 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2406 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2407 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2408 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2409 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2410 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2411 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2412 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2413 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2414 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2415 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2416 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2417 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2418 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2419 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2420 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2421 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2422 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2423 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2424 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2425 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2426 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2427 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2428 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2429 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2430 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2431 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2432 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2433 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2434 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2435 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2436 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2437 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2438 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2439 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2440 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2441 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2442 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2443 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2444 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2445 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2446 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2447 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2448 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2449 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2450 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2451 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2452 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2453 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2454 898, 898, -508, -508
2457 /* YYPGOTO[NTERM-NUM]. */
2458 static const short int yypgoto[] =
2460 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2461 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2462 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2463 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2464 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2465 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2466 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2467 -508, -508, 43, -22, -508, -508, 21, -508, -508
2470 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2471 positive, shift that token. If negative, reduce the rule which
2472 number is the opposite. If zero, do what YYDEFACT says.
2473 If YYTABLE_NINF, syntax error. */
2474 #define YYTABLE_NINF -180
2475 static const short int yytable[] =
2477 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2478 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2479 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2480 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2481 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2482 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2483 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2484 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2485 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2486 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2487 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2488 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2489 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2490 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2491 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2492 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2493 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2494 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2495 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2496 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2497 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2498 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2499 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2500 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2501 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2502 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2503 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2504 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2505 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2506 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2507 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2508 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2509 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2510 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2511 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2512 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2513 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2514 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2515 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2516 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2517 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2518 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2519 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2520 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2521 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2522 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2523 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2524 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2525 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2526 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2527 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2528 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2529 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2530 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2531 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2532 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2533 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2534 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2535 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2536 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2537 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2538 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2539 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2540 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2541 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2542 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2543 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2544 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2545 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2546 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2547 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2548 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2549 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2550 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2551 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2552 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2553 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2554 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2555 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2556 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2557 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2558 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2559 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2560 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2561 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2562 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2563 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2564 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
2565 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2566 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2567 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2568 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2569 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2570 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2571 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2572 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2573 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2574 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2575 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2576 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2577 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2578 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2579 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2580 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2581 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2582 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2583 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2584 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2585 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2586 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2587 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2588 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2589 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2590 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2591 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2592 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2593 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2594 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2595 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2596 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2597 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2598 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2599 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2600 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2601 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2602 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2603 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2604 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2605 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2606 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2607 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2608 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2609 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2610 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2611 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2612 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2613 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2614 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2615 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2616 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2617 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2618 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2619 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2620 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2621 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2622 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2623 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2624 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2625 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2626 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2627 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2628 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2629 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2630 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2631 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2632 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2633 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2634 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2635 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2636 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
2637 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2638 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2639 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2640 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2641 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2642 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2643 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2644 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2645 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2646 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2647 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2651 static const short int yycheck[] =
2653 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2654 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2655 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2656 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2657 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2658 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2659 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2660 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2661 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2662 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2663 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2664 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2665 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2666 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2667 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2668 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2669 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2670 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2671 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2672 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2673 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2674 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2675 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2676 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2677 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2678 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2679 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2680 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2681 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2682 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2683 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2684 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2685 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2686 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2687 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2688 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2689 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2690 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2691 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2692 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2693 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2694 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2695 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2696 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2697 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2698 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2699 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2700 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2701 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2702 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2703 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2704 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
2705 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
2706 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2707 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2708 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2709 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2710 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2711 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2712 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2713 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2714 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2715 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2716 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2717 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2718 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2719 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2720 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2721 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2722 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2723 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2724 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2725 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2726 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2727 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2728 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2729 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2730 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2731 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2732 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2733 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2734 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2735 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2736 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2737 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2738 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2739 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2740 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2741 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2742 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2743 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2744 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2745 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2746 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2747 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2748 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2749 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2750 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2751 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2752 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2753 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2754 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2755 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2756 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2757 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2758 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2759 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2760 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2761 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2762 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2763 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2764 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2765 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2766 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2767 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2768 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2769 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2770 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2771 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2772 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2773 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2774 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2775 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2776 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2777 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2778 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2779 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2780 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2781 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2782 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2783 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2784 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2785 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2786 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2787 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2788 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2789 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2790 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2791 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2792 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2793 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2794 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2795 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2796 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2797 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2798 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2799 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2800 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2801 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2802 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2803 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2804 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2805 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2806 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2807 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2808 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2809 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2810 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2811 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2812 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2813 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2814 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2815 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2816 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2817 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2818 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2819 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2820 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2821 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2822 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2823 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2827 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2828 symbol of state STATE-NUM. */
2829 static const unsigned char yystos[] =
2831 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2832 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2833 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2834 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2835 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2836 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2837 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2838 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2839 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2840 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2841 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2842 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2843 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2844 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2845 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2846 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2847 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2848 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2849 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2850 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2851 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2852 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2853 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2854 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2855 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2856 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2857 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2858 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2859 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2860 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2861 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2862 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2863 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2864 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2865 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2866 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2867 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2868 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2869 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2870 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2871 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2872 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2873 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2874 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2875 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2876 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2877 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2878 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2879 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2880 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2881 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2882 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2883 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2884 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2885 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2886 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2887 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2888 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2889 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2890 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2894 #define yyerrok (yyerrstatus = 0)
2895 #define yyclearin (yychar = YYEMPTY)
2896 #define YYEMPTY (-2)
2899 #define YYACCEPT goto yyacceptlab
2900 #define YYABORT goto yyabortlab
2901 #define YYERROR goto yyerrorlab
2904 /* Like YYERROR except do call yyerror. This remains here temporarily
2905 to ease the transition to the new meaning of YYERROR, for GCC.
2906 Once GCC version 2 has supplanted version 1, this can go. */
2908 #define YYFAIL goto yyerrlab
2910 #define YYRECOVERING() (!!yyerrstatus)
2912 #define YYBACKUP(Token, Value) \
2914 if (yychar == YYEMPTY && yylen == 1) \
2918 yytoken = YYTRANSLATE (yychar); \
2924 yyerror (YY_("syntax error: cannot back up")); \
2931 #define YYERRCODE 256
2934 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2935 If N is 0, then set CURRENT to the empty location which ends
2936 the previous symbol: RHS[0] (always defined). */
2938 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
2939 #ifndef YYLLOC_DEFAULT
2940 # define YYLLOC_DEFAULT(Current, Rhs, N) \
2944 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2945 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2946 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2947 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2951 (Current).first_line = (Current).last_line = \
2952 YYRHSLOC (Rhs, 0).last_line; \
2953 (Current).first_column = (Current).last_column = \
2954 YYRHSLOC (Rhs, 0).last_column; \
2960 /* YY_LOCATION_PRINT -- Print the location on the stream.
2961 This macro was not mandated originally: define only if we know
2962 we won't break user code: when these are the locations we know. */
2964 #ifndef YY_LOCATION_PRINT
2965 # if YYLTYPE_IS_TRIVIAL
2966 # define YY_LOCATION_PRINT(File, Loc) \
2967 fprintf (File, "%d.%d-%d.%d", \
2968 (Loc).first_line, (Loc).first_column, \
2969 (Loc).last_line, (Loc).last_column)
2971 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2976 /* YYLEX -- calling `yylex' with the right arguments. */
2979 # define YYLEX yylex (YYLEX_PARAM)
2981 # define YYLEX yylex ()
2984 /* Enable debugging if requested. */
2988 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2989 # define YYFPRINTF fprintf
2992 # define YYDPRINTF(Args) \
2998 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3002 YYFPRINTF (stderr, "%s ", Title); \
3003 yysymprint (stderr, \
3005 YYFPRINTF (stderr, "\n"); \
3009 /*------------------------------------------------------------------.
3010 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
3012 `------------------------------------------------------------------*/
3014 #if defined (__STDC__) || defined (__cplusplus)
3016 yy_stack_print (short int *bottom, short int *top)
3019 yy_stack_print (bottom, top)
3024 YYFPRINTF (stderr, "Stack now");
3025 for (/* Nothing. */; bottom <= top; ++bottom)
3026 YYFPRINTF (stderr, " %d", *bottom);
3027 YYFPRINTF (stderr, "\n");
3030 # define YY_STACK_PRINT(Bottom, Top) \
3033 yy_stack_print ((Bottom), (Top)); \
3037 /*------------------------------------------------.
3038 | Report that the YYRULE is going to be reduced. |
3039 `------------------------------------------------*/
3041 #if defined (__STDC__) || defined (__cplusplus)
3043 yy_reduce_print (int yyrule)
3046 yy_reduce_print (yyrule)
3051 unsigned long int yylno = yyrline[yyrule];
3052 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3054 /* Print the symbols being reduced, and their result. */
3055 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3056 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3057 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3060 # define YY_REDUCE_PRINT(Rule) \
3063 yy_reduce_print (Rule); \
3066 /* Nonzero means print parse trace. It is left uninitialized so that
3067 multiple parsers can coexist. */
3069 #else /* !YYDEBUG */
3070 # define YYDPRINTF(Args)
3071 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3072 # define YY_STACK_PRINT(Bottom, Top)
3073 # define YY_REDUCE_PRINT(Rule)
3074 #endif /* !YYDEBUG */
3077 /* YYINITDEPTH -- initial size of the parser's stacks. */
3079 # define YYINITDEPTH 200
3082 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3083 if the built-in stack extension method is used).
3085 Do not make this value too large; the results are undefined if
3086 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3087 evaluated with infinite-precision integer arithmetic. */
3090 # define YYMAXDEPTH 10000
3098 # if defined (__GLIBC__) && defined (_STRING_H)
3099 # define yystrlen strlen
3101 /* Return the length of YYSTR. */
3103 # if defined (__STDC__) || defined (__cplusplus)
3104 yystrlen (const char *yystr)
3110 const char *yys = yystr;
3112 while (*yys++ != '\0')
3115 return yys - yystr - 1;
3121 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3122 # define yystpcpy stpcpy
3124 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3127 # if defined (__STDC__) || defined (__cplusplus)
3128 yystpcpy (char *yydest, const char *yysrc)
3130 yystpcpy (yydest, yysrc)
3136 const char *yys = yysrc;
3138 while ((*yyd++ = *yys++) != '\0')
3147 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3148 quotes and backslashes, so that it's suitable for yyerror. The
3149 heuristic is that double-quoting is unnecessary unless the string
3150 contains an apostrophe, a comma, or backslash (other than
3151 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3152 null, do not copy; instead, return the length of what the result
3155 yytnamerr (char *yyres, const char *yystr)
3160 char const *yyp = yystr;
3167 goto do_not_strip_quotes;
3171 goto do_not_strip_quotes;
3184 do_not_strip_quotes: ;
3188 return yystrlen (yystr);
3190 return yystpcpy (yyres, yystr) - yyres;
3194 #endif /* YYERROR_VERBOSE */
3199 /*--------------------------------.
3200 | Print this symbol on YYOUTPUT. |
3201 `--------------------------------*/
3203 #if defined (__STDC__) || defined (__cplusplus)
3205 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
3208 yysymprint (yyoutput, yytype, yyvaluep)
3214 /* Pacify ``unused variable'' warnings. */
3217 if (yytype < YYNTOKENS)
3218 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3220 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3224 if (yytype < YYNTOKENS)
3225 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3232 YYFPRINTF (yyoutput, ")");
3235 #endif /* ! YYDEBUG */
3236 /*-----------------------------------------------.
3237 | Release the memory associated to this symbol. |
3238 `-----------------------------------------------*/
3240 #if defined (__STDC__) || defined (__cplusplus)
3242 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3245 yydestruct (yymsg, yytype, yyvaluep)
3251 /* Pacify ``unused variable'' warnings. */
3256 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3267 /* Prevent warnings from -Wmissing-prototypes. */
3269 #ifdef YYPARSE_PARAM
3270 # if defined (__STDC__) || defined (__cplusplus)
3271 int yyparse (void *YYPARSE_PARAM);
3275 #else /* ! YYPARSE_PARAM */
3276 #if defined (__STDC__) || defined (__cplusplus)
3281 #endif /* ! YYPARSE_PARAM */
3285 /* The look-ahead symbol. */
3288 /* The semantic value of the look-ahead symbol. */
3291 /* Number of syntax errors so far. */
3300 #ifdef YYPARSE_PARAM
3301 # if defined (__STDC__) || defined (__cplusplus)
3302 int yyparse (void *YYPARSE_PARAM)
3304 int yyparse (YYPARSE_PARAM)
3305 void *YYPARSE_PARAM;
3307 #else /* ! YYPARSE_PARAM */
3308 #if defined (__STDC__) || defined (__cplusplus)
3322 /* Number of tokens to shift before error messages enabled. */
3324 /* Look-ahead token as an internal (translated) token number. */
3327 /* Three stacks and their tools:
3328 `yyss': related to states,
3329 `yyvs': related to semantic values,
3330 `yyls': related to locations.
3332 Refer to the stacks thru separate pointers, to allow yyoverflow
3333 to reallocate them elsewhere. */
3335 /* The state stack. */
3336 short int yyssa[YYINITDEPTH];
3337 short int *yyss = yyssa;
3340 /* The semantic value stack. */
3341 YYSTYPE yyvsa[YYINITDEPTH];
3342 YYSTYPE *yyvs = yyvsa;
3347 #define YYPOPSTACK (yyvsp--, yyssp--)
3349 YYSIZE_T yystacksize = YYINITDEPTH;
3351 /* The variables used to return semantic value and location from the
3356 /* When reducing, the number of symbols on the RHS of the reduced
3360 YYDPRINTF ((stderr, "Starting parse\n"));
3365 yychar = YYEMPTY; /* Cause a token to be read. */
3367 /* Initialize stack pointers.
3368 Waste one element of value and location stack
3369 so that they stay on the same level as the state stack.
3370 The wasted elements are never initialized. */
3377 /*------------------------------------------------------------.
3378 | yynewstate -- Push a new state, which is found in yystate. |
3379 `------------------------------------------------------------*/
3381 /* In all cases, when you get here, the value and location stacks
3382 have just been pushed. so pushing a state here evens the stacks.
3389 if (yyss + yystacksize - 1 <= yyssp)
3391 /* Get the current used size of the three stacks, in elements. */
3392 YYSIZE_T yysize = yyssp - yyss + 1;
3396 /* Give user a chance to reallocate the stack. Use copies of
3397 these so that the &'s don't force the real ones into
3399 YYSTYPE *yyvs1 = yyvs;
3400 short int *yyss1 = yyss;
3403 /* Each stack pointer address is followed by the size of the
3404 data in use in that stack, in bytes. This used to be a
3405 conditional around just the two extra args, but that might
3406 be undefined if yyoverflow is a macro. */
3407 yyoverflow (YY_("memory exhausted"),
3408 &yyss1, yysize * sizeof (*yyssp),
3409 &yyvs1, yysize * sizeof (*yyvsp),
3416 #else /* no yyoverflow */
3417 # ifndef YYSTACK_RELOCATE
3418 goto yyexhaustedlab;
3420 /* Extend the stack our own way. */
3421 if (YYMAXDEPTH <= yystacksize)
3422 goto yyexhaustedlab;
3424 if (YYMAXDEPTH < yystacksize)
3425 yystacksize = YYMAXDEPTH;
3428 short int *yyss1 = yyss;
3429 union yyalloc *yyptr =
3430 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3432 goto yyexhaustedlab;
3433 YYSTACK_RELOCATE (yyss);
3434 YYSTACK_RELOCATE (yyvs);
3436 # undef YYSTACK_RELOCATE
3438 YYSTACK_FREE (yyss1);
3441 #endif /* no yyoverflow */
3443 yyssp = yyss + yysize - 1;
3444 yyvsp = yyvs + yysize - 1;
3447 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3448 (unsigned long int) yystacksize));
3450 if (yyss + yystacksize - 1 <= yyssp)
3454 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
3463 /* Do appropriate processing given the current state. */
3464 /* Read a look-ahead token if we need one and don't already have one. */
3467 /* First try to decide what to do without reference to look-ahead token. */
3469 yyn = yypact[yystate];
3470 if (yyn == YYPACT_NINF)
3473 /* Not known => get a look-ahead token if don't already have one. */
3475 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
3476 if (yychar == YYEMPTY)
3478 YYDPRINTF ((stderr, "Reading a token: "));
3482 if (yychar <= YYEOF)
3484 yychar = yytoken = YYEOF;
3485 YYDPRINTF ((stderr, "Now at end of input.\n"));
3489 yytoken = YYTRANSLATE (yychar);
3490 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
3493 /* If the proper action on seeing token YYTOKEN is to reduce or to
3494 detect an error, take that action. */
3496 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
3501 if (yyn == 0 || yyn == YYTABLE_NINF)
3510 /* Shift the look-ahead token. */
3511 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3513 /* Discard the token being shifted unless it is eof. */
3514 if (yychar != YYEOF)
3520 /* Count tokens shifted since error; after three, turn off error
3529 /*-----------------------------------------------------------.
3530 | yydefault -- do the default action for the current state. |
3531 `-----------------------------------------------------------*/
3533 yyn = yydefact[yystate];
3539 /*-----------------------------.
3540 | yyreduce -- Do a reduction. |
3541 `-----------------------------*/
3543 /* yyn is the number of a rule to reduce with. */
3546 /* If YYLEN is nonzero, implement the default value of the action:
3549 Otherwise, the following line sets YYVAL to garbage.
3550 This behavior is undocumented and Bison
3551 users should not rely upon it. Assigning to YYVAL
3552 unconditionally makes the parser a bit smaller, and it avoids a
3553 GCC warning that YYVAL may be used uninitialized. */
3554 yyval = yyvsp[1-yylen];
3557 YY_REDUCE_PRINT (yyn);
3561 #line 1478 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3563 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
3564 error("Value too large for type");
3565 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3570 #line 1487 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3572 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
3573 error("Value too large for type");
3574 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3579 #line 1509 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3580 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3584 #line 1509 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3585 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3589 #line 1510 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3590 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3594 #line 1510 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3595 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3599 #line 1511 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3600 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3604 #line 1511 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3605 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3609 #line 1512 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3610 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3614 #line 1512 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3615 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3619 #line 1513 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3620 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3624 #line 1513 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3625 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3629 #line 1517 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3630 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3634 #line 1517 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3635 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3639 #line 1518 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3640 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3644 #line 1518 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3645 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3649 #line 1519 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3650 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3654 #line 1519 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3655 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3659 #line 1520 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3660 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3664 #line 1520 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3665 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3669 #line 1521 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3670 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3674 #line 1521 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3675 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3679 #line 1522 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3680 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3684 #line 1522 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3685 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3689 #line 1523 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3690 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3694 #line 1523 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3695 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3699 #line 1524 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3700 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3704 #line 1525 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3705 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3709 #line 1556 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3711 (yyval.StrVal) = (yyvsp[-1].StrVal);
3716 #line 1559 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3723 #line 1564 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3724 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3728 #line 1565 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3729 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3733 #line 1566 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3734 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3738 #line 1567 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3739 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3743 #line 1568 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3744 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3748 #line 1569 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3749 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3753 #line 1570 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3754 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3758 #line 1571 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3759 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3763 #line 1575 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3764 { (yyval.UIntVal) = CallingConv::C; ;}
3768 #line 1576 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3769 { (yyval.UIntVal) = CallingConv::C; ;}
3773 #line 1577 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3774 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3778 #line 1578 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3779 { (yyval.UIntVal) = CallingConv::Fast; ;}
3783 #line 1579 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3784 { (yyval.UIntVal) = CallingConv::Cold; ;}
3788 #line 1580 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3789 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3793 #line 1581 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3794 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3798 #line 1582 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3800 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
3801 error("Calling conv too large");
3802 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3807 #line 1592 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3808 { (yyval.UIntVal) = 0; ;}
3812 #line 1593 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3814 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3815 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3816 error("Alignment must be a power of two");
3821 #line 1601 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3822 { (yyval.UIntVal) = 0; ;}
3826 #line 1602 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3828 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3829 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3830 error("Alignment must be a power of two");
3835 #line 1610 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3837 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3838 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
3839 error("Invalid character in section name");
3840 (yyval.StrVal) = (yyvsp[0].StrVal);
3845 #line 1619 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3846 { (yyval.StrVal) = 0; ;}
3850 #line 1620 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3851 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3855 #line 1627 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3860 #line 1628 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3865 #line 1632 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3867 CurGV->setSection((yyvsp[0].StrVal));
3868 free((yyvsp[0].StrVal));
3873 #line 1636 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3875 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
3876 error("Alignment must be a power of two");
3877 CurGV->setAlignment((yyvsp[0].UInt64Val));
3883 #line 1653 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3885 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3886 (yyval.TypeVal).S = Signless;
3891 #line 1661 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3893 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3894 (yyval.TypeVal).S = Signless;
3899 #line 1668 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3901 if (!UpRefs.empty())
3902 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).T)->getDescription());
3903 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3908 #line 1682 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3910 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3911 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
3916 #line 1686 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3918 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
3919 (yyval.TypeVal).S = Signless;
3924 #line 1690 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3925 { // Named types are also simple types...
3926 const Type* tmp = getType((yyvsp[0].ValIDVal));
3927 (yyval.TypeVal).T = new PATypeHolder(tmp);
3928 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
3933 #line 1695 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3934 { // Type UpReference
3935 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
3936 error("Value out of range");
3937 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
3938 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3939 (yyval.TypeVal).T = new PATypeHolder(OT);
3940 (yyval.TypeVal).S = Signless;
3941 UR_OUT("New Upreference!\n");
3946 #line 1704 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3947 { // Function derived type?
3948 std::vector<const Type*> Params;
3949 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
3950 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
3951 Params.push_back(I->T->get());
3954 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3955 if (isVarArg) Params.pop_back();
3957 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
3958 FunctionType::get((yyvsp[-3].TypeVal).T->get(),Params,isVarArg)));
3959 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
3960 delete (yyvsp[-3].TypeVal).T; // Delete the return type handle
3961 delete (yyvsp[-1].TypeList); // Delete the argument list
3966 #line 1720 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3967 { // Sized array type?
3968 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).T->get(),
3969 (unsigned)(yyvsp[-3].UInt64Val))));
3970 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
3971 delete (yyvsp[-1].TypeVal).T;
3976 #line 1726 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3977 { // Packed array type?
3978 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).T->get();
3979 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3980 error("Unsigned result not equal to signed result");
3981 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
3982 error("Elements of a PackedType must be integer or floating point");
3983 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3984 error("PackedType length should be a power of 2");
3985 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
3986 (unsigned)(yyvsp[-3].UInt64Val))));
3987 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
3988 delete (yyvsp[-1].TypeVal).T;
3993 #line 1739 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
3994 { // Structure type?
3995 std::vector<const Type*> Elements;
3996 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
3997 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
3998 Elements.push_back(I->T->get());
3999 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4000 (yyval.TypeVal).S = Signless;
4001 delete (yyvsp[-1].TypeList);
4006 #line 1748 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4007 { // Empty structure type?
4008 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4009 (yyval.TypeVal).S = Signless;
4014 #line 1752 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4015 { // Packed Structure type?
4016 std::vector<const Type*> Elements;
4017 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4018 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
4019 Elements.push_back(I->T->get());
4022 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4023 (yyval.TypeVal).S = Signless;
4024 delete (yyvsp[-2].TypeList);
4029 #line 1763 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4030 { // Empty packed structure type?
4031 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4032 (yyval.TypeVal).S = Signless;
4037 #line 1767 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4039 if ((yyvsp[-1].TypeVal).T->get() == Type::LabelTy)
4040 error("Cannot form a pointer to a basic block");
4041 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).T->get())));
4042 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4043 delete (yyvsp[-1].TypeVal).T;
4048 #line 1780 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4050 (yyval.TypeList) = new std::list<PATypeInfo>();
4051 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4056 #line 1784 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4058 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4063 #line 1792 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4066 VoidTI.T = new PATypeHolder(Type::VoidTy);
4067 VoidTI.S = Signless;
4068 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4073 #line 1798 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4075 (yyval.TypeList) = new std::list<PATypeInfo>();
4077 VoidTI.T = new PATypeHolder(Type::VoidTy);
4078 VoidTI.S = Signless;
4079 (yyval.TypeList)->push_back(VoidTI);
4084 #line 1805 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4086 (yyval.TypeList) = new std::list<PATypeInfo>();
4091 #line 1817 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4092 { // Nonempty unsized arr
4093 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).T->get());
4095 error("Cannot make array constant with type: '" +
4096 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4097 const Type *ETy = ATy->getElementType();
4098 int NumElements = ATy->getNumElements();
4100 // Verify that we have the correct size...
4101 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4102 error("Type mismatch: constant sized array initialized with " +
4103 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4104 itostr(NumElements) + "");
4106 // Verify all elements are correct type!
4107 std::vector<Constant*> Elems;
4108 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4109 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4110 const Type* ValTy = C->getType();
4112 error("Element #" + utostr(i) + " is not of type '" +
4113 ETy->getDescription() +"' as required!\nIt is of type '"+
4114 ValTy->getDescription() + "'");
4117 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4118 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4119 delete (yyvsp[-3].TypeVal).T;
4120 delete (yyvsp[-1].ConstVector);
4125 #line 1847 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4127 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
4129 error("Cannot make array constant with type: '" +
4130 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4131 int NumElements = ATy->getNumElements();
4132 if (NumElements != -1 && NumElements != 0)
4133 error("Type mismatch: constant sized array initialized with 0"
4134 " arguments, but has size of " + itostr(NumElements) +"");
4135 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4136 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4137 delete (yyvsp[-2].TypeVal).T;
4142 #line 1860 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4144 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
4146 error("Cannot make array constant with type: '" +
4147 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4148 int NumElements = ATy->getNumElements();
4149 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4150 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4151 error("String arrays require type i8, not '" + ETy->getDescription() +
4153 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4154 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
4155 error("Can't build string constant of size " +
4156 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
4157 itostr(NumElements) + "");
4158 std::vector<Constant*> Vals;
4159 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
4160 Vals.push_back(ConstantInt::get(ETy, *C));
4161 free((yyvsp[0].StrVal));
4162 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4163 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4164 delete (yyvsp[-2].TypeVal).T;
4169 #line 1883 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4170 { // Nonempty unsized arr
4171 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).T->get());
4173 error("Cannot make packed constant with type: '" +
4174 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4175 const Type *ETy = PTy->getElementType();
4176 int NumElements = PTy->getNumElements();
4177 // Verify that we have the correct size...
4178 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4179 error("Type mismatch: constant sized packed initialized with " +
4180 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4181 itostr(NumElements) + "");
4182 // Verify all elements are correct type!
4183 std::vector<Constant*> Elems;
4184 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4185 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4186 const Type* ValTy = C->getType();
4188 error("Element #" + utostr(i) + " is not of type '" +
4189 ETy->getDescription() +"' as required!\nIt is of type '"+
4190 ValTy->getDescription() + "'");
4193 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
4194 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4195 delete (yyvsp[-3].TypeVal).T;
4196 delete (yyvsp[-1].ConstVector);
4201 #line 1911 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4203 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).T->get());
4205 error("Cannot make struct constant with type: '" +
4206 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4207 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
4208 error("Illegal number of initializers for structure type");
4210 // Check to ensure that constants are compatible with the type initializer!
4211 std::vector<Constant*> Fields;
4212 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4213 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4214 if (C->getType() != STy->getElementType(i))
4215 error("Expected type '" + STy->getElementType(i)->getDescription() +
4216 "' for element #" + utostr(i) + " of structure initializer");
4217 Fields.push_back(C);
4219 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4220 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4221 delete (yyvsp[-3].TypeVal).T;
4222 delete (yyvsp[-1].ConstVector);
4227 #line 1933 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4229 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).T->get());
4231 error("Cannot make struct constant with type: '" +
4232 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4233 if (STy->getNumContainedTypes() != 0)
4234 error("Illegal number of initializers for structure type");
4235 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4236 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4237 delete (yyvsp[-2].TypeVal).T;
4242 #line 1944 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4244 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).T->get());
4246 error("Cannot make packed struct constant with type: '" +
4247 (yyvsp[-5].TypeVal).T->get()->getDescription() + "'");
4248 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
4249 error("Illegal number of initializers for packed structure type");
4251 // Check to ensure that constants are compatible with the type initializer!
4252 std::vector<Constant*> Fields;
4253 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4254 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
4255 if (C->getType() != STy->getElementType(i))
4256 error("Expected type '" + STy->getElementType(i)->getDescription() +
4257 "' for element #" + utostr(i) + " of packed struct initializer");
4258 Fields.push_back(C);
4260 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4261 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4262 delete (yyvsp[-5].TypeVal).T;
4263 delete (yyvsp[-2].ConstVector);
4268 #line 1966 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4270 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).T->get());
4272 error("Cannot make packed struct constant with type: '" +
4273 (yyvsp[-4].TypeVal).T->get()->getDescription() + "'");
4274 if (STy->getNumContainedTypes() != 0)
4275 error("Illegal number of initializers for packed structure type");
4276 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4277 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4278 delete (yyvsp[-4].TypeVal).T;
4283 #line 1977 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4285 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
4287 error("Cannot make null pointer constant with type: '" +
4288 (yyvsp[-1].TypeVal).T->get()->getDescription() + "'");
4289 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4290 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4291 delete (yyvsp[-1].TypeVal).T;
4296 #line 1986 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4298 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).T->get());
4299 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4300 delete (yyvsp[-1].TypeVal).T;
4305 #line 1991 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4307 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
4309 error("Global const reference must be a pointer type, not" +
4310 (yyvsp[-1].TypeVal).T->get()->getDescription());
4312 // ConstExprs can exist in the body of a function, thus creating
4313 // GlobalValues whenever they refer to a variable. Because we are in
4314 // the context of a function, getExistingValue will search the functions
4315 // symbol table instead of the module symbol table for the global symbol,
4316 // which throws things all off. To get around this, we just tell
4317 // getExistingValue that we are at global scope here.
4319 Function *SavedCurFn = CurFun.CurrentFunction;
4320 CurFun.CurrentFunction = 0;
4321 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
4322 CurFun.CurrentFunction = SavedCurFn;
4324 // If this is an initializer for a constant pointer, which is referencing a
4325 // (currently) undefined variable, create a stub now that shall be replaced
4326 // in the future with the right type of variable.
4329 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4330 const PointerType *PT = cast<PointerType>(Ty);
4332 // First check to see if the forward references value is already created!
4333 PerModuleInfo::GlobalRefsType::iterator I =
4334 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
4336 if (I != CurModule.GlobalRefs.end()) {
4337 V = I->second; // Placeholder already exists, use it...
4338 (yyvsp[0].ValIDVal).destroy();
4341 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
4343 // Create the forward referenced global.
4345 if (const FunctionType *FTy =
4346 dyn_cast<FunctionType>(PT->getElementType())) {
4347 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4348 CurModule.CurrentModule);
4350 GV = new GlobalVariable(PT->getElementType(), false,
4351 GlobalValue::ExternalLinkage, 0,
4352 Name, CurModule.CurrentModule);
4355 // Keep track of the fact that we have a forward ref to recycle it
4356 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
4360 (yyval.ConstVal).C = cast<GlobalValue>(V);
4361 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4362 delete (yyvsp[-1].TypeVal).T; // Free the type handle
4367 #line 2049 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4369 if ((yyvsp[-1].TypeVal).T->get() != (yyvsp[0].ConstVal).C->getType())
4370 error("Mismatched types for constant expression");
4371 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4372 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4373 delete (yyvsp[-1].TypeVal).T;
4378 #line 2056 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4380 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
4381 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4382 error("Cannot create a null initialized value of this type");
4383 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4384 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4385 delete (yyvsp[-1].TypeVal).T;
4390 #line 2064 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4391 { // integral constants
4392 const Type *Ty = (yyvsp[-1].PrimType).T;
4393 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
4394 error("Constant value doesn't fit in type");
4395 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
4396 (yyval.ConstVal).S = Signed;
4401 #line 2071 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4402 { // integral constants
4403 const Type *Ty = (yyvsp[-1].PrimType).T;
4404 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
4405 error("Constant value doesn't fit in type");
4406 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
4407 (yyval.ConstVal).S = Unsigned;
4412 #line 2078 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4413 { // Boolean constants
4414 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4415 (yyval.ConstVal).S = Unsigned;
4420 #line 2082 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4421 { // Boolean constants
4422 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4423 (yyval.ConstVal).S = Unsigned;
4428 #line 2086 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4429 { // Float & Double constants
4430 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
4431 error("Floating point constant invalid for type");
4432 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
4433 (yyval.ConstVal).S = Signless;
4438 #line 2095 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4440 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4441 const Type* DstTy = (yyvsp[-1].TypeVal).T->get();
4442 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4443 Signedness DstSign = (yyvsp[-1].TypeVal).S;
4444 if (!SrcTy->isFirstClassType())
4445 error("cast constant expression from a non-primitive type: '" +
4446 SrcTy->getDescription() + "'");
4447 if (!DstTy->isFirstClassType())
4448 error("cast constant expression to a non-primitive type: '" +
4449 DstTy->getDescription() + "'");
4450 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
4451 (yyval.ConstVal).S = DstSign;
4452 delete (yyvsp[-1].TypeVal).T;
4457 #line 2110 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4459 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
4460 if (!isa<PointerType>(Ty))
4461 error("GetElementPtr requires a pointer operand");
4463 std::vector<Value*> VIndices;
4464 std::vector<Constant*> CIndices;
4465 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
4467 delete (yyvsp[-1].ValueList);
4468 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
4469 (yyval.ConstVal).S = Signless;
4474 #line 2123 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4476 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4477 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
4478 error("Select condition must be bool type");
4479 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4480 error("Select operand types must match");
4481 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4482 (yyval.ConstVal).S = Unsigned;
4487 #line 2132 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4489 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4490 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4491 error("Binary operator types must match");
4492 // First, make sure we're dealing with the right opcode by upgrading from
4493 // obsolete versions.
4494 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4496 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4497 // To retain backward compatibility with these early compilers, we emit a
4498 // cast to the appropriate integer type automatically if we are in the
4499 // broken case. See PR424 for more information.
4500 if (!isa<PointerType>(Ty)) {
4501 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4503 const Type *IntPtrTy = 0;
4504 switch (CurModule.CurrentModule->getPointerSize()) {
4505 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4506 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4507 default: error("invalid pointer binary constant expr");
4509 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4510 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4511 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4512 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4514 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4519 #line 2160 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4521 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4522 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4523 error("Logical operator types must match");
4524 if (!Ty->isInteger()) {
4525 if (!isa<PackedType>(Ty) ||
4526 !cast<PackedType>(Ty)->getElementType()->isInteger())
4527 error("Logical operator requires integer operands");
4529 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4530 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4531 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4536 #line 2173 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4538 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4539 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4540 error("setcc operand types must match");
4541 unsigned short pred;
4542 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4543 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4544 (yyval.ConstVal).S = Unsigned;
4549 #line 2182 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4551 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4552 error("icmp operand types must match");
4553 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4554 (yyval.ConstVal).S = Unsigned;
4559 #line 2188 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4561 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4562 error("fcmp operand types must match");
4563 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4564 (yyval.ConstVal).S = Unsigned;
4569 #line 2194 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4571 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4572 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
4573 error("Shift count for shift constant must be unsigned byte");
4574 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
4575 error("Shift constant expression requires integer operand");
4576 (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4577 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4582 #line 2203 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4584 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4585 error("Invalid extractelement operands");
4586 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4587 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4592 #line 2209 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4594 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4595 error("Invalid insertelement operands");
4596 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4597 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4602 #line 2215 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4604 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4605 error("Invalid shufflevector operands");
4606 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4607 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4612 #line 2226 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4613 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
4617 #line 2227 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4619 (yyval.ConstVector) = new std::vector<ConstInfo>();
4620 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4625 #line 2236 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4626 { (yyval.BoolVal) = false; ;}
4630 #line 2237 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4631 { (yyval.BoolVal) = true; ;}
4635 #line 2249 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4637 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
4638 CurModule.ModuleDone();
4643 #line 2258 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4644 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
4648 #line 2259 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4649 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
4653 #line 2260 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4654 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
4658 #line 2261 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4659 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
4663 #line 2262 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4665 (yyval.ModuleVal) = CurModule.CurrentModule;
4666 // Emit an error if there are any unresolved types left.
4667 if (!CurModule.LateResolveTypes.empty()) {
4668 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4669 if (DID.Type == ValID::NameVal) {
4670 error("Reference to an undefined type: '"+DID.getName() + "'");
4672 error("Reference to an undefined type: #" + itostr(DID.Num));
4679 #line 2278 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4681 // Eagerly resolve types. This is not an optimization, this is a
4682 // requirement that is due to the fact that we could have this:
4684 // %list = type { %list * }
4685 // %list = type { %list * } ; repeated type decl
4687 // If types are not resolved eagerly, then the two types will not be
4688 // determined to be the same type!
4690 const Type* Ty = (yyvsp[0].TypeVal).T->get();
4691 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
4693 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
4694 // If this is a named type that is not a redefinition, add it to the slot
4696 CurModule.Types.push_back(Ty);
4698 delete (yyvsp[0].TypeVal).T;
4703 #line 2298 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4704 { // Function prototypes can be in const pool
4709 #line 2300 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4710 { // Asm blocks can be in the const pool
4715 #line 2302 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4717 if ((yyvsp[0].ConstVal).C == 0)
4718 error("Global value initializer is not a constant");
4719 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C);
4724 #line 2306 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4731 #line 2309 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4733 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4734 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4735 delete (yyvsp[0].TypeVal).T;
4740 #line 2313 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4747 #line 2316 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4749 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4750 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4751 delete (yyvsp[0].TypeVal).T;
4756 #line 2320 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4763 #line 2323 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4765 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4767 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4768 delete (yyvsp[0].TypeVal).T;
4773 #line 2328 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4780 #line 2331 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4786 #line 2333 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4792 #line 2335 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4798 #line 2340 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4800 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4801 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4802 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4803 free((yyvsp[0].StrVal));
4805 if (AsmSoFar.empty())
4806 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4808 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4813 #line 2354 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4814 { (yyval.Endianness) = Module::BigEndian; ;}
4818 #line 2355 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4819 { (yyval.Endianness) = Module::LittleEndian; ;}
4823 #line 2359 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4825 CurModule.setEndianness((yyvsp[0].Endianness));
4830 #line 2362 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4832 if ((yyvsp[0].UInt64Val) == 32)
4833 CurModule.setPointerSize(Module::Pointer32);
4834 else if ((yyvsp[0].UInt64Val) == 64)
4835 CurModule.setPointerSize(Module::Pointer64);
4837 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
4842 #line 2370 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4844 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4845 free((yyvsp[0].StrVal));
4850 #line 2374 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4852 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4853 free((yyvsp[0].StrVal));
4858 #line 2385 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4860 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4861 free((yyvsp[0].StrVal));
4866 #line 2389 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4868 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4869 free((yyvsp[0].StrVal));
4874 #line 2393 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4879 #line 2406 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4880 { (yyval.StrVal) = 0; ;}
4884 #line 2410 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4886 if ((yyvsp[-1].TypeVal).T->get() == Type::VoidTy)
4887 error("void typed arguments are invalid");
4888 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
4893 #line 2418 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4895 (yyval.ArgList) = (yyvsp[-2].ArgList);
4896 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4897 delete (yyvsp[0].ArgVal);
4902 #line 2423 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4904 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
4905 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4906 delete (yyvsp[0].ArgVal);
4911 #line 2431 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4912 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
4916 #line 2432 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4918 (yyval.ArgList) = (yyvsp[-2].ArgList);
4920 VoidTI.T = new PATypeHolder(Type::VoidTy);
4921 VoidTI.S = Signless;
4922 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4927 #line 2439 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4929 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
4931 VoidTI.T = new PATypeHolder(Type::VoidTy);
4932 VoidTI.S = Signless;
4933 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4938 #line 2446 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4939 { (yyval.ArgList) = 0; ;}
4943 #line 2450 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
4945 UnEscapeLexed((yyvsp[-5].StrVal));
4946 std::string FunctionName((yyvsp[-5].StrVal));
4947 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
4949 const Type* RetTy = (yyvsp[-6].TypeVal).T->get();
4951 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
4952 error("LLVM functions cannot return aggregate types");
4954 std::vector<const Type*> ParamTypeList;
4956 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
4957 // i8*. We check here for those names and override the parameter list
4958 // types to ensure the prototype is correct.
4959 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
4960 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
4961 } else if (FunctionName == "llvm.va_copy") {
4962 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
4963 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
4964 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
4965 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
4966 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
4967 const Type *Ty = I->first.T->get();
4968 ParamTypeList.push_back(Ty);
4973 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4974 if (isVarArg) ParamTypeList.pop_back();
4976 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
4977 const PointerType *PFT = PointerType::get(FT);
4978 delete (yyvsp[-6].TypeVal).T;
4981 if (!FunctionName.empty()) {
4982 ID = ValID::create((char*)FunctionName.c_str());
4984 ID = ValID::create((int)CurModule.Values[PFT].size());
4988 // See if this function was forward referenced. If so, recycle the object.
4989 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4990 // Move the function to the end of the list, from whereever it was
4991 // previously inserted.
4992 Fn = cast<Function>(FWRef);
4993 CurModule.CurrentModule->getFunctionList().remove(Fn);
4994 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4995 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4996 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4997 // If this is the case, either we need to be a forward decl, or it needs
4999 if (!CurFun.isDeclare && !Fn->isExternal())
5000 error("Redefinition of function '" + FunctionName + "'");
5002 // Make sure to strip off any argument names so we can't get conflicts.
5003 if (Fn->isExternal())
5004 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5007 } else { // Not already defined?
5008 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5009 CurModule.CurrentModule);
5011 InsertValue(Fn, CurModule.Values);
5014 CurFun.FunctionStart(Fn);
5016 if (CurFun.isDeclare) {
5017 // If we have declaration, always overwrite linkage. This will allow us
5018 // to correctly handle cases, when pointer to function is passed as
5019 // argument to another function.
5020 Fn->setLinkage(CurFun.Linkage);
5022 Fn->setCallingConv((yyvsp[-7].UIntVal));
5023 Fn->setAlignment((yyvsp[0].UIntVal));
5024 if ((yyvsp[-1].StrVal)) {
5025 Fn->setSection((yyvsp[-1].StrVal));
5026 free((yyvsp[-1].StrVal));
5029 // Add all of the arguments we parsed to the function...
5030 if ((yyvsp[-3].ArgList)) { // Is null if empty...
5031 if (isVarArg) { // Nuke the last entry
5032 assert((yyvsp[-3].ArgList)->back().first.T->get() == Type::VoidTy &&
5033 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5034 delete (yyvsp[-3].ArgList)->back().first.T;
5035 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
5037 Function::arg_iterator ArgIt = Fn->arg_begin();
5038 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5039 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I, ++ArgIt) {
5040 delete I->first.T; // Delete the typeholder...
5041 setValueName(ArgIt, I->second); // Insert arg into symtab...
5044 delete (yyvsp[-3].ArgList); // We're now done with the argument list
5050 #line 2560 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5052 (yyval.FunctionVal) = CurFun.CurrentFunction;
5054 // Make sure that we keep track of the linkage type even if there was a
5055 // previous "declare".
5056 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
5061 #line 2574 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5063 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5068 #line 2580 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5069 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5073 #line 2581 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5074 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5078 #line 2585 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5079 { CurFun.isDeclare = true; ;}
5083 #line 2585 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5085 (yyval.FunctionVal) = CurFun.CurrentFunction;
5086 CurFun.FunctionDone();
5092 #line 2597 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5093 { (yyval.BoolVal) = false; ;}
5097 #line 2598 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5098 { (yyval.BoolVal) = true; ;}
5102 #line 2603 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5103 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
5107 #line 2604 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5108 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5112 #line 2605 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5113 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5117 #line 2606 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5118 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
5122 #line 2607 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5123 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5127 #line 2608 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5128 { (yyval.ValIDVal) = ValID::createNull(); ;}
5132 #line 2609 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5133 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5137 #line 2610 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5138 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5142 #line 2611 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5143 { // Nonempty unsized packed vector
5144 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5145 int NumElements = (yyvsp[-1].ConstVector)->size();
5146 PackedType* pt = PackedType::get(ETy, NumElements);
5147 PATypeHolder* PTy = new PATypeHolder(
5148 HandleUpRefs(PackedType::get(ETy, NumElements)));
5150 // Verify all elements are correct type!
5151 std::vector<Constant*> Elems;
5152 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5153 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
5154 const Type *CTy = C->getType();
5156 error("Element #" + utostr(i) + " is not of type '" +
5157 ETy->getDescription() +"' as required!\nIt is of type '" +
5158 CTy->getDescription() + "'");
5161 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
5162 delete PTy; delete (yyvsp[-1].ConstVector);
5167 #line 2632 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5169 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
5174 #line 2635 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5176 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5177 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5178 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5179 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5180 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5181 free((yyvsp[-2].StrVal));
5182 free((yyvsp[0].StrVal));
5187 #line 2650 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5188 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
5192 #line 2651 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5193 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
5197 #line 2664 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5199 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5200 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5201 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5202 delete (yyvsp[-1].TypeVal).T;
5207 #line 2673 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5209 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5214 #line 2676 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5215 { // Do not allow functions with 0 basic blocks
5216 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5221 #line 2685 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5223 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5224 InsertValue((yyvsp[0].TermInstVal));
5225 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5226 InsertValue((yyvsp[-2].BasicBlockVal));
5227 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5232 #line 2695 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5234 if ((yyvsp[0].InstVal).I)
5235 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5236 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5241 #line 2700 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5243 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5244 // Make sure to move the basic block to the correct location in the
5245 // function, instead of leaving it inserted wherever it was first
5247 Function::BasicBlockListType &BBL =
5248 CurFun.CurrentFunction->getBasicBlockList();
5249 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5254 #line 2709 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5256 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
5257 // Make sure to move the basic block to the correct location in the
5258 // function, instead of leaving it inserted wherever it was first
5260 Function::BasicBlockListType &BBL =
5261 CurFun.CurrentFunction->getBasicBlockList();
5262 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5267 #line 2723 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5268 { // Return with a result...
5269 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
5274 #line 2726 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5275 { // Return with no result...
5276 (yyval.TermInstVal) = new ReturnInst();
5281 #line 2729 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5282 { // Unconditional Branch...
5283 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5284 (yyval.TermInstVal) = new BranchInst(tmpBB);
5289 #line 2733 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5291 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5292 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5293 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5294 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5299 #line 2739 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5301 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5302 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5303 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5304 (yyval.TermInstVal) = S;
5305 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5306 E = (yyvsp[-1].JumpTable)->end();
5307 for (; I != E; ++I) {
5308 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5309 S->addCase(CI, I->second);
5311 error("Switch case is constant, but not a simple integer");
5313 delete (yyvsp[-1].JumpTable);
5318 #line 2754 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5320 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5321 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
5322 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5323 (yyval.TermInstVal) = S;
5328 #line 2761 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5330 const PointerType *PFTy;
5331 const FunctionType *Ty;
5333 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).T->get())) ||
5334 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5335 // Pull out the types of all of the arguments...
5336 std::vector<const Type*> ParamTypes;
5337 if ((yyvsp[-7].ValueList)) {
5338 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
5340 ParamTypes.push_back((*I).V->getType());
5342 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5343 if (isVarArg) ParamTypes.pop_back();
5344 Ty = FunctionType::get((yyvsp[-10].TypeVal).T->get(), ParamTypes, isVarArg);
5345 PFTy = PointerType::get(Ty);
5347 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5348 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5349 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
5351 // Create the call node...
5352 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
5353 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5354 } else { // Has arguments?
5355 // Loop through FunctionType's arguments and ensure they are specified
5358 FunctionType::param_iterator I = Ty->param_begin();
5359 FunctionType::param_iterator E = Ty->param_end();
5360 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
5362 std::vector<Value*> Args;
5363 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5364 if ((*ArgI).V->getType() != *I)
5365 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5366 (*I)->getDescription() + "'");
5367 Args.push_back((*ArgI).V);
5370 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5371 error("Invalid number of parameters detected");
5373 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5375 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
5376 delete (yyvsp[-10].TypeVal).T;
5377 delete (yyvsp[-7].ValueList);
5382 #line 2811 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5384 (yyval.TermInstVal) = new UnwindInst();
5389 #line 2814 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5391 (yyval.TermInstVal) = new UnreachableInst();
5396 #line 2820 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5398 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5399 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5402 error("May only switch on a constant pool value");
5404 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5405 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5410 #line 2830 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5412 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5413 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5416 error("May only switch on a constant pool value");
5418 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5419 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5424 #line 2843 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5427 if ((yyvsp[-1].StrVal))
5428 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
5429 if (BCI->getSrcTy() == BCI->getDestTy() &&
5430 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
5431 // This is a useless bit cast causing a name redefinition. It is
5432 // a bit cast from a type to the same type of an operand with the
5433 // same name as the name we would give this instruction. Since this
5434 // instruction results in no code generation, it is safe to omit
5435 // the instruction. This situation can occur because of collapsed
5436 // type planes. For example:
5437 // %X = add int %Y, %Z
5438 // %X = cast int %Y to uint
5439 // After upgrade, this looks like:
5440 // %X = add i32 %Y, %Z
5441 // %X = bitcast i32 to i32
5442 // The bitcast is clearly useless so we omit it.
5445 (yyval.InstVal).I = 0;
5446 (yyval.InstVal).S = Signless;
5448 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5449 InsertValue((yyvsp[0].InstVal).I);
5450 (yyval.InstVal) = (yyvsp[0].InstVal);
5456 #line 2872 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5457 { // Used for PHI nodes
5458 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5459 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5460 Value* tmpVal = getVal((yyvsp[-5].TypeVal).T->get(), (yyvsp[-3].ValIDVal));
5461 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5462 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5463 delete (yyvsp[-5].TypeVal).T;
5468 #line 2880 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5470 (yyval.PHIList) = (yyvsp[-6].PHIList);
5471 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5472 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5473 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5478 #line 2888 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5479 { // Used for call statements, and memory insts...
5480 (yyval.ValueList) = new std::vector<ValueInfo>();
5481 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5486 #line 2892 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5488 (yyval.ValueList) = (yyvsp[-2].ValueList);
5489 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
5494 #line 2900 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5495 { (yyval.ValueList) = 0; ;}
5499 #line 2904 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5501 (yyval.BoolVal) = true;
5506 #line 2907 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5508 (yyval.BoolVal) = false;
5513 #line 2913 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5515 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
5516 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5517 error("Arithmetic operator requires integer, FP, or packed operands");
5518 if (isa<PackedType>(Ty) &&
5519 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
5520 error("Remainder not supported on packed types");
5521 // Upgrade the opcode from obsolete versions before we do anything with it.
5522 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5523 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5524 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
5525 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5526 if ((yyval.InstVal).I == 0)
5527 error("binary operator returned null");
5528 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5529 delete (yyvsp[-3].TypeVal).T;
5534 #line 2930 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5536 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5537 if (!Ty->isInteger()) {
5538 if (!isa<PackedType>(Ty) ||
5539 !cast<PackedType>(Ty)->getElementType()->isInteger())
5540 error("Logical operator requires integral operands");
5542 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5543 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5544 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5545 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5546 if ((yyval.InstVal).I == 0)
5547 error("binary operator returned null");
5548 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5549 delete (yyvsp[-3].TypeVal).T;
5554 #line 2946 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5556 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
5557 if(isa<PackedType>(Ty))
5558 error("PackedTypes currently not supported in setcc instructions");
5559 unsigned short pred;
5560 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5561 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5562 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5563 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5564 if ((yyval.InstVal).I == 0)
5565 error("binary operator returned null");
5566 (yyval.InstVal).S = Unsigned;
5567 delete (yyvsp[-3].TypeVal).T;
5572 #line 2960 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5574 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5575 if (isa<PackedType>(Ty))
5576 error("PackedTypes currently not supported in icmp instructions");
5577 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5578 error("icmp requires integer or pointer typed operands");
5579 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5580 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5581 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
5582 (yyval.InstVal).S = Unsigned;
5583 delete (yyvsp[-3].TypeVal).T;
5588 #line 2972 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5590 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5591 if (isa<PackedType>(Ty))
5592 error("PackedTypes currently not supported in fcmp instructions");
5593 else if (!Ty->isFloatingPoint())
5594 error("fcmp instruction requires floating point operands");
5595 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5596 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5597 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
5598 (yyval.InstVal).S = Unsigned;
5599 delete (yyvsp[-3].TypeVal).T;
5604 #line 2984 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5606 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5607 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
5608 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5610 error("Expected integral type for not instruction");
5611 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
5612 if ((yyval.InstVal).I == 0)
5613 error("Could not create a xor instruction");
5614 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
5619 #line 2995 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5621 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5622 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
5623 error("Shift amount must be int8");
5624 if (!(yyvsp[-2].ValueVal).V->getType()->isInteger())
5625 error("Shift constant expression requires integer operand");
5626 (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5627 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5632 #line 3004 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5634 const Type *DstTy = (yyvsp[0].TypeVal).T->get();
5635 if (!DstTy->isFirstClassType())
5636 error("cast instruction to a non-primitive type: '" +
5637 DstTy->getDescription() + "'");
5638 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5639 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5640 delete (yyvsp[0].TypeVal).T;
5645 #line 3013 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5647 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5648 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
5649 error("select condition must be bool");
5650 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
5651 error("select value types should match");
5652 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5653 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5658 #line 3022 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5660 const Type *Ty = (yyvsp[0].TypeVal).T->get();
5662 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5663 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5664 delete (yyvsp[0].TypeVal).T;
5669 #line 3029 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5671 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5672 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
5673 ObsoleteVarArgs = true;
5674 Function* NF = cast<Function>(CurModule.CurrentModule->
5675 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5678 //foo = alloca 1 of t
5682 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5683 CurBB->getInstList().push_back(foo);
5684 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5685 CurBB->getInstList().push_back(bar);
5686 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5687 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5688 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5689 delete (yyvsp[0].TypeVal).T;
5694 #line 3050 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5696 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5697 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
5698 ObsoleteVarArgs = true;
5699 Function* NF = cast<Function>(CurModule.CurrentModule->
5700 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5702 //b = vanext a, t ->
5703 //foo = alloca 1 of t
5706 //tmp = vaarg foo, t
5708 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5709 CurBB->getInstList().push_back(foo);
5710 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5711 CurBB->getInstList().push_back(bar);
5712 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5713 Instruction* tmp = new VAArgInst(foo, DstTy);
5714 CurBB->getInstList().push_back(tmp);
5715 (yyval.InstVal).I = new LoadInst(foo);
5716 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5717 delete (yyvsp[0].TypeVal).T;
5722 #line 3074 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5724 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5725 error("Invalid extractelement operands");
5726 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5727 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5732 #line 3080 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5734 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5735 error("Invalid insertelement operands");
5736 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5737 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5742 #line 3086 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5744 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5745 error("Invalid shufflevector operands");
5746 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5747 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5752 #line 3092 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5754 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
5755 if (!Ty->isFirstClassType())
5756 error("PHI node operands must be of first class type");
5757 PHINode *PHI = new PHINode(Ty);
5758 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5759 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5760 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
5761 error("All elements of a PHI node must be of the same type");
5762 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5763 (yyvsp[0].PHIList).P->pop_front();
5765 (yyval.InstVal).I = PHI;
5766 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5767 delete (yyvsp[0].PHIList).P; // Free the list...
5772 #line 3108 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5775 // Handle the short call syntax
5776 const PointerType *PFTy;
5777 const FunctionType *FTy;
5778 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).T->get())) ||
5779 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5780 // Pull out the types of all of the arguments...
5781 std::vector<const Type*> ParamTypes;
5782 if ((yyvsp[-1].ValueList)) {
5783 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
5785 ParamTypes.push_back((*I).V->getType());
5788 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5789 if (isVarArg) ParamTypes.pop_back();
5791 const Type *RetTy = (yyvsp[-4].TypeVal).T->get();
5792 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5793 error("Functions cannot return aggregate types");
5795 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
5796 PFTy = PointerType::get(FTy);
5799 // First upgrade any intrinsic calls.
5800 std::vector<Value*> Args;
5801 if ((yyvsp[-1].ValueList))
5802 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
5803 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
5804 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
5806 // If we got an upgraded intrinsic
5808 (yyval.InstVal).I = Inst;
5809 (yyval.InstVal).S = Signless;
5811 // Get the function we're calling
5812 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
5814 // Check the argument values match
5815 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
5816 // Make sure no arguments is a good thing!
5817 if (FTy->getNumParams() != 0)
5818 error("No arguments passed to a function that expects arguments");
5819 } else { // Has arguments?
5820 // Loop through FunctionType's arguments and ensure they are specified
5823 FunctionType::param_iterator I = FTy->param_begin();
5824 FunctionType::param_iterator E = FTy->param_end();
5825 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
5827 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5828 if ((*ArgI).V->getType() != *I)
5829 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5830 (*I)->getDescription() + "'");
5832 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
5833 error("Invalid number of parameters detected");
5836 // Create the call instruction
5837 CallInst *CI = new CallInst(V, Args);
5838 CI->setTailCall((yyvsp[-6].BoolVal));
5839 CI->setCallingConv((yyvsp[-5].UIntVal));
5840 (yyval.InstVal).I = CI;
5841 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5843 delete (yyvsp[-4].TypeVal).T;
5844 delete (yyvsp[-1].ValueList);
5849 #line 3181 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5851 (yyval.InstVal) = (yyvsp[0].InstVal);
5856 #line 3189 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5857 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
5861 #line 3190 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5862 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
5866 #line 3194 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5867 { (yyval.BoolVal) = true; ;}
5871 #line 3195 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5872 { (yyval.BoolVal) = false; ;}
5876 #line 3199 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5878 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5879 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5880 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
5881 delete (yyvsp[-1].TypeVal).T;
5886 #line 3205 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5888 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
5889 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5890 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
5891 delete (yyvsp[-4].TypeVal).T;
5896 #line 3211 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5898 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5899 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5900 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
5901 delete (yyvsp[-1].TypeVal).T;
5906 #line 3217 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5908 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
5909 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5910 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
5911 delete (yyvsp[-4].TypeVal).T;
5916 #line 3223 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5918 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
5919 if (!isa<PointerType>(PTy))
5920 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
5921 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
5922 (yyval.InstVal).S = Signless;
5927 #line 3230 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5929 const Type* Ty = (yyvsp[-1].TypeVal).T->get();
5930 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5931 if (!isa<PointerType>(Ty))
5932 error("Can't load from nonpointer type: " + Ty->getDescription());
5933 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
5934 error("Can't load from pointer of non-first-class type: " +
5935 Ty->getDescription());
5936 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
5937 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5938 delete (yyvsp[-1].TypeVal).T;
5943 #line 3242 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5945 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
5947 error("Can't store to a nonpointer type: " +
5948 (yyvsp[-1].TypeVal).T->get()->getDescription());
5949 const Type *ElTy = PTy->getElementType();
5950 if (ElTy != (yyvsp[-3].ValueVal).V->getType())
5951 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
5952 "' into space of type '" + ElTy->getDescription() + "'");
5953 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
5954 (yyval.InstVal).I = new StoreInst((yyvsp[-3].ValueVal).V, tmpVal, (yyvsp[-5].BoolVal));
5955 (yyval.InstVal).S = Signless;
5956 delete (yyvsp[-1].TypeVal).T;
5961 #line 3256 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
5963 const Type* Ty = (yyvsp[-2].TypeVal).T->get();
5964 if (!isa<PointerType>(Ty))
5965 error("getelementptr insn requires pointer operand");
5967 std::vector<Value*> VIndices;
5968 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
5970 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
5971 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
5972 (yyval.InstVal).S = Signless;
5973 delete (yyvsp[-2].TypeVal).T;
5974 delete (yyvsp[0].ValueList);
5982 /* Line 1126 of yacc.c. */
5983 #line 5984 "UpgradeParser.tab.c"
5989 YY_STACK_PRINT (yyss, yyssp);
5994 /* Now `shift' the result of the reduction. Determine what state
5995 that goes to, based on the state we popped back to and the rule
5996 number reduced by. */
6000 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6001 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
6002 yystate = yytable[yystate];
6004 yystate = yydefgoto[yyn - YYNTOKENS];
6009 /*------------------------------------.
6010 | yyerrlab -- here on detecting error |
6011 `------------------------------------*/
6013 /* If not already recovering from an error, report this error. */
6018 yyn = yypact[yystate];
6020 if (YYPACT_NINF < yyn && yyn < YYLAST)
6022 int yytype = YYTRANSLATE (yychar);
6023 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6024 YYSIZE_T yysize = yysize0;
6026 int yysize_overflow = 0;
6028 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6029 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6033 /* This is so xgettext sees the translatable formats that are
6034 constructed on the fly. */
6035 YY_("syntax error, unexpected %s");
6036 YY_("syntax error, unexpected %s, expecting %s");
6037 YY_("syntax error, unexpected %s, expecting %s or %s");
6038 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6039 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6043 static char const yyunexpected[] = "syntax error, unexpected %s";
6044 static char const yyexpecting[] = ", expecting %s";
6045 static char const yyor[] = " or %s";
6046 char yyformat[sizeof yyunexpected
6047 + sizeof yyexpecting - 1
6048 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6049 * (sizeof yyor - 1))];
6050 char const *yyprefix = yyexpecting;
6052 /* Start YYX at -YYN if negative to avoid negative indexes in
6054 int yyxbegin = yyn < 0 ? -yyn : 0;
6056 /* Stay within bounds of both yycheck and yytname. */
6057 int yychecklim = YYLAST - yyn;
6058 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6061 yyarg[0] = yytname[yytype];
6062 yyfmt = yystpcpy (yyformat, yyunexpected);
6064 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6065 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6067 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6071 yyformat[sizeof yyunexpected - 1] = '\0';
6074 yyarg[yycount++] = yytname[yyx];
6075 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6076 yysize_overflow |= yysize1 < yysize;
6078 yyfmt = yystpcpy (yyfmt, yyprefix);
6082 yyf = YY_(yyformat);
6083 yysize1 = yysize + yystrlen (yyf);
6084 yysize_overflow |= yysize1 < yysize;
6087 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6088 yymsg = (char *) YYSTACK_ALLOC (yysize);
6091 /* Avoid sprintf, as that infringes on the user's name space.
6092 Don't have undefined behavior even if the translation
6093 produced a string with the wrong number of "%s"s. */
6096 while ((*yyp = *yyf))
6098 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6100 yyp += yytnamerr (yyp, yyarg[yyi++]);
6110 YYSTACK_FREE (yymsg);
6114 yyerror (YY_("syntax error"));
6115 goto yyexhaustedlab;
6119 #endif /* YYERROR_VERBOSE */
6120 yyerror (YY_("syntax error"));
6125 if (yyerrstatus == 3)
6127 /* If just tried and failed to reuse look-ahead token after an
6128 error, discard it. */
6130 if (yychar <= YYEOF)
6132 /* Return failure if at end of input. */
6133 if (yychar == YYEOF)
6138 yydestruct ("Error: discarding", yytoken, &yylval);
6143 /* Else will try to reuse look-ahead token after shifting the error
6148 /*---------------------------------------------------.
6149 | yyerrorlab -- error raised explicitly by YYERROR. |
6150 `---------------------------------------------------*/
6153 /* Pacify compilers like GCC when the user code never invokes
6154 YYERROR and the label yyerrorlab therefore never appears in user
6165 /*-------------------------------------------------------------.
6166 | yyerrlab1 -- common code for both syntax error and YYERROR. |
6167 `-------------------------------------------------------------*/
6169 yyerrstatus = 3; /* Each real token shifted decrements this. */
6173 yyn = yypact[yystate];
6174 if (yyn != YYPACT_NINF)
6177 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6185 /* Pop the current state because it cannot handle the error token. */
6190 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6193 YY_STACK_PRINT (yyss, yyssp);
6202 /* Shift the error token. */
6203 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6209 /*-------------------------------------.
6210 | yyacceptlab -- YYACCEPT comes here. |
6211 `-------------------------------------*/
6216 /*-----------------------------------.
6217 | yyabortlab -- YYABORT comes here. |
6218 `-----------------------------------*/
6224 /*-------------------------------------------------.
6225 | yyexhaustedlab -- memory exhaustion comes here. |
6226 `-------------------------------------------------*/
6228 yyerror (YY_("memory exhausted"));
6234 if (yychar != YYEOF && yychar != YYEMPTY)
6235 yydestruct ("Cleanup: discarding lookahead",
6237 while (yyssp != yyss)
6239 yydestruct ("Cleanup: popping",
6240 yystos[*yyssp], yyvsp);
6245 YYSTACK_FREE (yyss);
6251 #line 3272 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
6254 int yyerror(const char *ErrorMsg) {
6256 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6257 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6258 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6259 if (yychar != YYEMPTY && yychar != 0)
6260 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6262 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6263 std::cout << "llvm-upgrade: parse failed.\n";
6267 void warning(const std::string& ErrorMsg) {
6269 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6270 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6271 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6272 if (yychar != YYEMPTY && yychar != 0)
6273 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6275 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6278 void error(const std::string& ErrorMsg, int LineNo) {
6279 if (LineNo == -1) LineNo = Upgradelineno;
6280 Upgradelineno = LineNo;
6281 yyerror(ErrorMsg.c_str());