1 /* A Bison parser, made by GNU Bison 1.875c. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, 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 YYSKELETON_NAME "yacc.c"
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
48 /* If NAME_PREFIX is specified substitute the variables and functions
50 #define yyparse llvmAsmparse
51 #define yylex llvmAsmlex
52 #define yyerror llvmAsmerror
53 #define yylval llvmAsmlval
54 #define yychar llvmAsmchar
55 #define yydebug llvmAsmdebug
56 #define yynerrs llvmAsmnerrs
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
88 ZEROINITIALIZER = 281,
158 #define ESINT64VAL 258
159 #define EUINT64VAL 259
179 #define STRINGCONSTANT 279
180 #define IMPLEMENTATION 280
181 #define ZEROINITIALIZER 281
191 #define DOTDOTDOT 291
198 #define APPENDING 298
205 #define POINTERSIZE 305
213 #define FASTCC_TOK 313
214 #define COLDCC_TOK 314
220 #define UNREACHABLE 320
240 #define GETELEMENTPTR 340
247 #define VAARG_old 347
248 #define VANEXT_old 348
253 /* Copy the first part of user declarations. */
254 #line 14 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
256 #include "ParserInternals.h"
257 #include "llvm/CallingConv.h"
258 #include "llvm/Instructions.h"
259 #include "llvm/Module.h"
260 #include "llvm/SymbolTable.h"
261 #include "llvm/Support/GetElementPtrTypeIterator.h"
262 #include "llvm/ADT/STLExtras.h"
268 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
269 int yylex(); // declaration" of xxx warnings.
273 std::string CurFilename;
275 using namespace llvm;
277 static Module *ParserResult;
279 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
280 // relating to upreferences in the input stream.
282 //#define DEBUG_UPREFS 1
284 #define UR_OUT(X) std::cerr << X
289 #define YYERROR_VERBOSE 1
291 static bool ObsoleteVarArgs;
292 static bool NewVarArgs;
293 static BasicBlock* CurBB;
296 // This contains info used when building the body of a function. It is
297 // destroyed when the function is completed.
299 typedef std::vector<Value *> ValueList; // Numbered defs
301 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
302 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
304 static struct PerModuleInfo {
305 Module *CurrentModule;
306 std::map<const Type *, ValueList> Values; // Module level numbered definitions
307 std::map<const Type *,ValueList> LateResolveValues;
308 std::vector<PATypeHolder> Types;
309 std::map<ValID, PATypeHolder> LateResolveTypes;
311 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
312 /// how they were referenced and one which line of the input they came from so
313 /// that we can resolve them later and print error messages as appropriate.
314 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
316 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
317 // references to global values. Global values may be referenced before they
318 // are defined, and if so, the temporary object that they represent is held
319 // here. This is used for forward references of GlobalValues.
321 typedef std::map<std::pair<const PointerType *,
322 ValID>, GlobalValue*> GlobalRefsType;
323 GlobalRefsType GlobalRefs;
326 // If we could not resolve some functions at function compilation time
327 // (calls to functions before they are defined), resolve them now... Types
328 // are resolved when the constant pool has been completely parsed.
330 ResolveDefinitions(LateResolveValues);
332 // Check to make sure that all global value forward references have been
335 if (!GlobalRefs.empty()) {
336 std::string UndefinedReferences = "Unresolved global references exist:\n";
338 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
340 UndefinedReferences += " " + I->first.first->getDescription() + " " +
341 I->first.second.getName() + "\n";
343 ThrowException(UndefinedReferences);
346 Values.clear(); // Clear out function local definitions
352 // GetForwardRefForGlobal - Check to see if there is a forward reference
353 // for this global. If so, remove it from the GlobalRefs map and return it.
354 // If not, just return null.
355 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
356 // Check to see if there is a forward reference to this global variable...
357 // if there is, eliminate it and patch the reference to use the new def'n.
358 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
359 GlobalValue *Ret = 0;
360 if (I != GlobalRefs.end()) {
368 static struct PerFunctionInfo {
369 Function *CurrentFunction; // Pointer to current function being created
371 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
372 std::map<const Type*, ValueList> LateResolveValues;
373 bool isDeclare; // Is this function a forward declararation?
375 /// BBForwardRefs - When we see forward references to basic blocks, keep
376 /// track of them here.
377 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
378 std::vector<BasicBlock*> NumberedBlocks;
381 inline PerFunctionInfo() {
386 inline void FunctionStart(Function *M) {
391 void FunctionDone() {
392 NumberedBlocks.clear();
394 // Any forward referenced blocks left?
395 if (!BBForwardRefs.empty())
396 ThrowException("Undefined reference to label " +
397 BBForwardRefs.begin()->first->getName());
399 // Resolve all forward references now.
400 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
402 Values.clear(); // Clear out function local definitions
406 } CurFun; // Info for the current function...
408 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
411 //===----------------------------------------------------------------------===//
412 // Code to handle definitions of all the types
413 //===----------------------------------------------------------------------===//
415 static int InsertValue(Value *V,
416 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
417 if (V->hasName()) return -1; // Is this a numbered definition?
419 // Yes, insert the value into the value table...
420 ValueList &List = ValueTab[V->getType()];
422 return List.size()-1;
425 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
427 case ValID::NumberVal: // Is it a numbered definition?
428 // Module constants occupy the lowest numbered slots...
429 if ((unsigned)D.Num < CurModule.Types.size())
430 return CurModule.Types[(unsigned)D.Num];
432 case ValID::NameVal: // Is it a named definition?
433 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
434 D.destroy(); // Free old strdup'd memory...
439 ThrowException("Internal parser error: Invalid symbol type reference!");
442 // If we reached here, we referenced either a symbol that we don't know about
443 // or an id number that hasn't been read yet. We may be referencing something
444 // forward, so just create an entry to be resolved later and get to it...
446 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
449 if (inFunctionScope()) {
450 if (D.Type == ValID::NameVal)
451 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
453 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
456 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
457 if (I != CurModule.LateResolveTypes.end())
460 Type *Typ = OpaqueType::get();
461 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
465 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
466 SymbolTable &SymTab =
467 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
468 CurModule.CurrentModule->getSymbolTable();
469 return SymTab.lookup(Ty, Name);
472 // getValNonImprovising - Look up the value specified by the provided type and
473 // the provided ValID. If the value exists and has already been defined, return
474 // it. Otherwise return null.
476 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
477 if (isa<FunctionType>(Ty))
478 ThrowException("Functions are not values and "
479 "must be referenced as pointers");
482 case ValID::NumberVal: { // Is it a numbered definition?
483 unsigned Num = (unsigned)D.Num;
485 // Module constants occupy the lowest numbered slots...
486 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
487 if (VI != CurModule.Values.end()) {
488 if (Num < VI->second.size())
489 return VI->second[Num];
490 Num -= VI->second.size();
493 // Make sure that our type is within bounds
494 VI = CurFun.Values.find(Ty);
495 if (VI == CurFun.Values.end()) return 0;
497 // Check that the number is within bounds...
498 if (VI->second.size() <= Num) return 0;
500 return VI->second[Num];
503 case ValID::NameVal: { // Is it a named definition?
504 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
505 if (N == 0) return 0;
507 D.destroy(); // Free old strdup'd memory...
511 // Check to make sure that "Ty" is an integral type, and that our
512 // value will fit into the specified type...
513 case ValID::ConstSIntVal: // Is it a constant pool reference??
514 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
515 ThrowException("Signed integral constant '" +
516 itostr(D.ConstPool64) + "' is invalid for type '" +
517 Ty->getDescription() + "'!");
518 return ConstantSInt::get(Ty, D.ConstPool64);
520 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
521 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
522 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
523 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
524 "' is invalid or out of range!");
525 } else { // This is really a signed reference. Transmogrify.
526 return ConstantSInt::get(Ty, D.ConstPool64);
529 return ConstantUInt::get(Ty, D.UConstPool64);
532 case ValID::ConstFPVal: // Is it a floating point const pool reference?
533 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
534 ThrowException("FP constant invalid for type!!");
535 return ConstantFP::get(Ty, D.ConstPoolFP);
537 case ValID::ConstNullVal: // Is it a null value?
538 if (!isa<PointerType>(Ty))
539 ThrowException("Cannot create a a non pointer null!");
540 return ConstantPointerNull::get(cast<PointerType>(Ty));
542 case ValID::ConstUndefVal: // Is it an undef value?
543 return UndefValue::get(Ty);
545 case ValID::ConstantVal: // Fully resolved constant?
546 if (D.ConstantValue->getType() != Ty)
547 ThrowException("Constant expression type different from required type!");
548 return D.ConstantValue;
551 assert(0 && "Unhandled case!");
555 assert(0 && "Unhandled case!");
559 // getVal - This function is identical to getValNonImprovising, except that if a
560 // value is not already defined, it "improvises" by creating a placeholder var
561 // that looks and acts just like the requested variable. When the value is
562 // defined later, all uses of the placeholder variable are replaced with the
565 static Value *getVal(const Type *Ty, const ValID &ID) {
566 if (Ty == Type::LabelTy)
567 ThrowException("Cannot use a basic block here");
569 // See if the value has already been defined.
570 Value *V = getValNonImprovising(Ty, ID);
573 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
574 ThrowException("Invalid use of a composite type!");
576 // If we reached here, we referenced either a symbol that we don't know about
577 // or an id number that hasn't been read yet. We may be referencing something
578 // forward, so just create an entry to be resolved later and get to it...
580 V = new Argument(Ty);
582 // Remember where this forward reference came from. FIXME, shouldn't we try
583 // to recycle these things??
584 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
587 if (inFunctionScope())
588 InsertValue(V, CurFun.LateResolveValues);
590 InsertValue(V, CurModule.LateResolveValues);
594 /// getBBVal - This is used for two purposes:
595 /// * If isDefinition is true, a new basic block with the specified ID is being
597 /// * If isDefinition is true, this is a reference to a basic block, which may
598 /// or may not be a forward reference.
600 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
601 assert(inFunctionScope() && "Can't get basic block at global scope!");
606 default: ThrowException("Illegal label reference " + ID.getName());
607 case ValID::NumberVal: // Is it a numbered definition?
608 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
609 CurFun.NumberedBlocks.resize(ID.Num+1);
610 BB = CurFun.NumberedBlocks[ID.Num];
612 case ValID::NameVal: // Is it a named definition?
614 if (Value *N = CurFun.CurrentFunction->
615 getSymbolTable().lookup(Type::LabelTy, Name))
616 BB = cast<BasicBlock>(N);
620 // See if the block has already been defined.
622 // If this is the definition of the block, make sure the existing value was
623 // just a forward reference. If it was a forward reference, there will be
624 // an entry for it in the PlaceHolderInfo map.
625 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
626 // The existing value was a definition, not a forward reference.
627 ThrowException("Redefinition of label " + ID.getName());
629 ID.destroy(); // Free strdup'd memory.
633 // Otherwise this block has not been seen before.
634 BB = new BasicBlock("", CurFun.CurrentFunction);
635 if (ID.Type == ValID::NameVal) {
636 BB->setName(ID.Name);
638 CurFun.NumberedBlocks[ID.Num] = BB;
641 // If this is not a definition, keep track of it so we can use it as a forward
644 // Remember where this forward reference came from.
645 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
647 // The forward declaration could have been inserted anywhere in the
648 // function: insert it into the correct place now.
649 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
650 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
657 //===----------------------------------------------------------------------===//
658 // Code to handle forward references in instructions
659 //===----------------------------------------------------------------------===//
661 // This code handles the late binding needed with statements that reference
662 // values not defined yet... for example, a forward branch, or the PHI node for
665 // This keeps a table (CurFun.LateResolveValues) of all such forward references
666 // and back patchs after we are done.
669 // ResolveDefinitions - If we could not resolve some defs at parsing
670 // time (forward branches, phi functions for loops, etc...) resolve the
674 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
675 std::map<const Type*,ValueList> *FutureLateResolvers) {
676 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
677 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
678 E = LateResolvers.end(); LRI != E; ++LRI) {
679 ValueList &List = LRI->second;
680 while (!List.empty()) {
681 Value *V = List.back();
684 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
685 CurModule.PlaceHolderInfo.find(V);
686 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
688 ValID &DID = PHI->second.first;
690 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
692 V->replaceAllUsesWith(TheRealValue);
694 CurModule.PlaceHolderInfo.erase(PHI);
695 } else if (FutureLateResolvers) {
696 // Functions have their unresolved items forwarded to the module late
698 InsertValue(V, *FutureLateResolvers);
700 if (DID.Type == ValID::NameVal)
701 ThrowException("Reference to an invalid definition: '" +DID.getName()+
702 "' of type '" + V->getType()->getDescription() + "'",
705 ThrowException("Reference to an invalid definition: #" +
706 itostr(DID.Num) + " of type '" +
707 V->getType()->getDescription() + "'",
713 LateResolvers.clear();
716 // ResolveTypeTo - A brand new type was just declared. This means that (if
717 // name is not null) things referencing Name can be resolved. Otherwise, things
718 // refering to the number can be resolved. Do this now.
720 static void ResolveTypeTo(char *Name, const Type *ToTy) {
722 if (Name) D = ValID::create(Name);
723 else D = ValID::create((int)CurModule.Types.size());
725 std::map<ValID, PATypeHolder>::iterator I =
726 CurModule.LateResolveTypes.find(D);
727 if (I != CurModule.LateResolveTypes.end()) {
728 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
729 CurModule.LateResolveTypes.erase(I);
733 // setValueName - Set the specified value to the name given. The name may be
734 // null potentially, in which case this is a noop. The string passed in is
735 // assumed to be a malloc'd string buffer, and is free'd by this function.
737 static void setValueName(Value *V, char *NameStr) {
739 std::string Name(NameStr); // Copy string
740 free(NameStr); // Free old string
742 if (V->getType() == Type::VoidTy)
743 ThrowException("Can't assign name '" + Name+"' to value with void type!");
745 assert(inFunctionScope() && "Must be in function scope!");
746 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
747 if (ST.lookup(V->getType(), Name))
748 ThrowException("Redefinition of value named '" + Name + "' in the '" +
749 V->getType()->getDescription() + "' type plane!");
756 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
757 /// this is a declaration, otherwise it is a definition.
758 static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
759 bool isConstantGlobal, const Type *Ty,
760 Constant *Initializer) {
761 if (isa<FunctionType>(Ty))
762 ThrowException("Cannot declare global vars of function type!");
764 const PointerType *PTy = PointerType::get(Ty);
768 Name = NameStr; // Copy string
769 free(NameStr); // Free old string
772 // See if this global value was forward referenced. If so, recycle the
776 ID = ValID::create((char*)Name.c_str());
778 ID = ValID::create((int)CurModule.Values[PTy].size());
781 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
782 // Move the global to the end of the list, from whereever it was
783 // previously inserted.
784 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
785 CurModule.CurrentModule->getGlobalList().remove(GV);
786 CurModule.CurrentModule->getGlobalList().push_back(GV);
787 GV->setInitializer(Initializer);
788 GV->setLinkage(Linkage);
789 GV->setConstant(isConstantGlobal);
790 InsertValue(GV, CurModule.Values);
794 // If this global has a name, check to see if there is already a definition
795 // of this global in the module. If so, merge as appropriate. Note that
796 // this is really just a hack around problems in the CFE. :(
798 // We are a simple redefinition of a value, check to see if it is defined
799 // the same as the old one.
800 if (GlobalVariable *EGV =
801 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
802 // We are allowed to redefine a global variable in two circumstances:
803 // 1. If at least one of the globals is uninitialized or
804 // 2. If both initializers have the same value.
806 if (!EGV->hasInitializer() || !Initializer ||
807 EGV->getInitializer() == Initializer) {
809 // Make sure the existing global version gets the initializer! Make
810 // sure that it also gets marked const if the new version is.
811 if (Initializer && !EGV->hasInitializer())
812 EGV->setInitializer(Initializer);
813 if (isConstantGlobal)
814 EGV->setConstant(true);
815 EGV->setLinkage(Linkage);
819 ThrowException("Redefinition of global variable named '" + Name +
820 "' in the '" + Ty->getDescription() + "' type plane!");
824 // Otherwise there is no existing GV to use, create one now.
826 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
827 CurModule.CurrentModule);
828 InsertValue(GV, CurModule.Values);
831 // setTypeName - Set the specified type to the name given. The name may be
832 // null potentially, in which case this is a noop. The string passed in is
833 // assumed to be a malloc'd string buffer, and is freed by this function.
835 // This function returns true if the type has already been defined, but is
836 // allowed to be redefined in the specified context. If the name is a new name
837 // for the type plane, it is inserted and false is returned.
838 static bool setTypeName(const Type *T, char *NameStr) {
839 assert(!inFunctionScope() && "Can't give types function-local names!");
840 if (NameStr == 0) return false;
842 std::string Name(NameStr); // Copy string
843 free(NameStr); // Free old string
845 // We don't allow assigning names to void type
846 if (T == Type::VoidTy)
847 ThrowException("Can't assign name '" + Name + "' to the void type!");
849 // Set the type name, checking for conflicts as we do so.
850 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
852 if (AlreadyExists) { // Inserting a name that is already defined???
853 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
854 assert(Existing && "Conflict but no matching type?");
856 // There is only one case where this is allowed: when we are refining an
857 // opaque type. In this case, Existing will be an opaque type.
858 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
859 // We ARE replacing an opaque type!
860 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
864 // Otherwise, this is an attempt to redefine a type. That's okay if
865 // the redefinition is identical to the original. This will be so if
866 // Existing and T point to the same Type object. In this one case we
867 // allow the equivalent redefinition.
868 if (Existing == T) return true; // Yes, it's equal.
870 // Any other kind of (non-equivalent) redefinition is an error.
871 ThrowException("Redefinition of type named '" + Name + "' in the '" +
872 T->getDescription() + "' type plane!");
878 //===----------------------------------------------------------------------===//
879 // Code for handling upreferences in type names...
882 // TypeContains - Returns true if Ty directly contains E in it.
884 static bool TypeContains(const Type *Ty, const Type *E) {
885 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
886 E) != Ty->subtype_end();
891 // NestingLevel - The number of nesting levels that need to be popped before
892 // this type is resolved.
893 unsigned NestingLevel;
895 // LastContainedTy - This is the type at the current binding level for the
896 // type. Every time we reduce the nesting level, this gets updated.
897 const Type *LastContainedTy;
899 // UpRefTy - This is the actual opaque type that the upreference is
903 UpRefRecord(unsigned NL, OpaqueType *URTy)
904 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
908 // UpRefs - A list of the outstanding upreferences that need to be resolved.
909 static std::vector<UpRefRecord> UpRefs;
911 /// HandleUpRefs - Every time we finish a new layer of types, this function is
912 /// called. It loops through the UpRefs vector, which is a list of the
913 /// currently active types. For each type, if the up reference is contained in
914 /// the newly completed type, we decrement the level count. When the level
915 /// count reaches zero, the upreferenced type is the type that is passed in:
916 /// thus we can complete the cycle.
918 static PATypeHolder HandleUpRefs(const Type *ty) {
919 if (!ty->isAbstract()) return ty;
921 UR_OUT("Type '" << Ty->getDescription() <<
922 "' newly formed. Resolving upreferences.\n" <<
923 UpRefs.size() << " upreferences active!\n");
925 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
926 // to zero), we resolve them all together before we resolve them to Ty. At
927 // the end of the loop, if there is anything to resolve to Ty, it will be in
929 OpaqueType *TypeToResolve = 0;
931 for (unsigned i = 0; i != UpRefs.size(); ++i) {
932 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
933 << UpRefs[i].second->getDescription() << ") = "
934 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
935 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
936 // Decrement level of upreference
937 unsigned Level = --UpRefs[i].NestingLevel;
938 UpRefs[i].LastContainedTy = Ty;
939 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
940 if (Level == 0) { // Upreference should be resolved!
941 if (!TypeToResolve) {
942 TypeToResolve = UpRefs[i].UpRefTy;
944 UR_OUT(" * Resolving upreference for "
945 << UpRefs[i].second->getDescription() << "\n";
946 std::string OldName = UpRefs[i].UpRefTy->getDescription());
947 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
948 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
949 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
951 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
952 --i; // Do not skip the next element...
958 UR_OUT(" * Resolving upreference for "
959 << UpRefs[i].second->getDescription() << "\n";
960 std::string OldName = TypeToResolve->getDescription());
961 TypeToResolve->refineAbstractTypeTo(Ty);
968 // common code from the two 'RunVMAsmParser' functions
969 static Module * RunParser(Module * M) {
971 llvmAsmlineno = 1; // Reset the current line number...
972 ObsoleteVarArgs = false;
975 CurModule.CurrentModule = M;
976 yyparse(); // Parse the file, potentially throwing exception
978 Module *Result = ParserResult;
981 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
984 if ((F = Result->getNamedFunction("llvm.va_start"))
985 && F->getFunctionType()->getNumParams() == 0)
986 ObsoleteVarArgs = true;
987 if((F = Result->getNamedFunction("llvm.va_copy"))
988 && F->getFunctionType()->getNumParams() == 1)
989 ObsoleteVarArgs = true;
992 if (ObsoleteVarArgs && NewVarArgs)
993 ThrowException("This file is corrupt: it uses both new and old style varargs");
995 if(ObsoleteVarArgs) {
996 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
997 if (F->arg_size() != 0)
998 ThrowException("Obsolete va_start takes 0 argument!");
1002 //bar = alloca typeof(foo)
1006 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1007 const Type* ArgTy = F->getFunctionType()->getReturnType();
1008 const Type* ArgTyPtr = PointerType::get(ArgTy);
1009 Function* NF = Result->getOrInsertFunction("llvm.va_start",
1010 RetTy, ArgTyPtr, 0);
1012 while (!F->use_empty()) {
1013 CallInst* CI = cast<CallInst>(F->use_back());
1014 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1015 new CallInst(NF, bar, "", CI);
1016 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1017 CI->replaceAllUsesWith(foo);
1018 CI->getParent()->getInstList().erase(CI);
1020 Result->getFunctionList().erase(F);
1023 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1024 if(F->arg_size() != 1)
1025 ThrowException("Obsolete va_end takes 1 argument!");
1029 //bar = alloca 1 of typeof(foo)
1031 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1032 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1033 const Type* ArgTyPtr = PointerType::get(ArgTy);
1034 Function* NF = Result->getOrInsertFunction("llvm.va_end",
1035 RetTy, ArgTyPtr, 0);
1037 while (!F->use_empty()) {
1038 CallInst* CI = cast<CallInst>(F->use_back());
1039 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1040 new StoreInst(CI->getOperand(1), bar, CI);
1041 new CallInst(NF, bar, "", CI);
1042 CI->getParent()->getInstList().erase(CI);
1044 Result->getFunctionList().erase(F);
1047 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1048 if(F->arg_size() != 1)
1049 ThrowException("Obsolete va_copy takes 1 argument!");
1052 //a = alloca 1 of typeof(foo)
1053 //b = alloca 1 of typeof(foo)
1058 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1059 const Type* ArgTy = F->getFunctionType()->getReturnType();
1060 const Type* ArgTyPtr = PointerType::get(ArgTy);
1061 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
1062 RetTy, ArgTyPtr, ArgTyPtr, 0);
1064 while (!F->use_empty()) {
1065 CallInst* CI = cast<CallInst>(F->use_back());
1066 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1067 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1068 new StoreInst(CI->getOperand(1), b, CI);
1069 new CallInst(NF, a, b, "", CI);
1070 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1071 CI->replaceAllUsesWith(foo);
1072 CI->getParent()->getInstList().erase(CI);
1074 Result->getFunctionList().erase(F);
1082 //===----------------------------------------------------------------------===//
1083 // RunVMAsmParser - Define an interface to this parser
1084 //===----------------------------------------------------------------------===//
1086 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1089 CurFilename = Filename;
1090 return RunParser(new Module(CurFilename));
1093 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1094 set_scan_string(AsmString);
1096 CurFilename = "from_memory";
1098 return RunParser(new Module (CurFilename));
1100 return RunParser(M);
1106 /* Enabling traces. */
1111 /* Enabling verbose error messages. */
1112 #ifdef YYERROR_VERBOSE
1113 # undef YYERROR_VERBOSE
1114 # define YYERROR_VERBOSE 1
1116 # define YYERROR_VERBOSE 0
1119 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1120 #line 865 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
1121 typedef union YYSTYPE {
1122 llvm::Module *ModuleVal;
1123 llvm::Function *FunctionVal;
1124 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1125 llvm::BasicBlock *BasicBlockVal;
1126 llvm::TerminatorInst *TermInstVal;
1127 llvm::Instruction *InstVal;
1128 llvm::Constant *ConstVal;
1130 const llvm::Type *PrimType;
1131 llvm::PATypeHolder *TypeVal;
1132 llvm::Value *ValueVal;
1134 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1135 std::vector<llvm::Value*> *ValueList;
1136 std::list<llvm::PATypeHolder> *TypeList;
1137 // Represent the RHS of PHI node
1138 std::list<std::pair<llvm::Value*,
1139 llvm::BasicBlock*> > *PHIList;
1140 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1141 std::vector<llvm::Constant*> *ConstVector;
1143 llvm::GlobalValue::LinkageTypes Linkage;
1151 char *StrVal; // This memory is strdup'd!
1152 llvm::ValID ValIDVal; // strdup'd memory maybe!
1154 llvm::Instruction::BinaryOps BinaryOpVal;
1155 llvm::Instruction::TermOps TermOpVal;
1156 llvm::Instruction::MemoryOps MemOpVal;
1157 llvm::Instruction::OtherOps OtherOpVal;
1158 llvm::Module::Endianness Endianness;
1160 /* Line 191 of yacc.c. */
1161 #line 1162 "llvmAsmParser.tab.c"
1162 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1163 # define YYSTYPE_IS_DECLARED 1
1164 # define YYSTYPE_IS_TRIVIAL 1
1169 /* Copy the second part of user declarations. */
1172 /* Line 214 of yacc.c. */
1173 #line 1174 "llvmAsmParser.tab.c"
1175 #if ! defined (yyoverflow) || YYERROR_VERBOSE
1178 # define YYFREE free
1181 # define YYMALLOC malloc
1184 /* The parser invokes alloca or malloc; define the necessary symbols. */
1186 # ifdef YYSTACK_USE_ALLOCA
1187 # if YYSTACK_USE_ALLOCA
1188 # define YYSTACK_ALLOC alloca
1191 # if defined (alloca) || defined (_ALLOCA_H)
1192 # define YYSTACK_ALLOC alloca
1195 # define YYSTACK_ALLOC __builtin_alloca
1200 # ifdef YYSTACK_ALLOC
1201 /* Pacify GCC's `empty if-body' warning. */
1202 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1204 # if defined (__STDC__) || defined (__cplusplus)
1205 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1206 # define YYSIZE_T size_t
1208 # define YYSTACK_ALLOC YYMALLOC
1209 # define YYSTACK_FREE YYFREE
1211 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1214 #if (! defined (yyoverflow) \
1215 && (! defined (__cplusplus) \
1216 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1218 /* A type that is properly aligned for any stack member. */
1225 /* The size of the maximum gap between one aligned stack and the next. */
1226 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1228 /* The size of an array large to enough to hold all stacks, each with
1230 # define YYSTACK_BYTES(N) \
1231 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
1232 + YYSTACK_GAP_MAXIMUM)
1234 /* Copy COUNT objects from FROM to TO. The source and destination do
1237 # if defined (__GNUC__) && 1 < __GNUC__
1238 # define YYCOPY(To, From, Count) \
1239 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1241 # define YYCOPY(To, From, Count) \
1244 register YYSIZE_T yyi; \
1245 for (yyi = 0; yyi < (Count); yyi++) \
1246 (To)[yyi] = (From)[yyi]; \
1252 /* Relocate STACK from its old location to the new one. The
1253 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1254 elements in the stack, and YYPTR gives the new location of the
1255 stack. Advance YYPTR to a properly aligned location for the next
1257 # define YYSTACK_RELOCATE(Stack) \
1260 YYSIZE_T yynewbytes; \
1261 YYCOPY (&yyptr->Stack, Stack, yysize); \
1262 Stack = &yyptr->Stack; \
1263 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1264 yyptr += yynewbytes / sizeof (*yyptr); \
1270 #if defined (__STDC__) || defined (__cplusplus)
1271 typedef signed char yysigned_char;
1273 typedef short yysigned_char;
1276 /* YYFINAL -- State number of the termination state. */
1278 /* YYLAST -- Last index in YYTABLE. */
1281 /* YYNTOKENS -- Number of terminals. */
1282 #define YYNTOKENS 108
1283 /* YYNNTS -- Number of nonterminals. */
1285 /* YYNRULES -- Number of rules. */
1286 #define YYNRULES 212
1287 /* YYNRULES -- Number of states. */
1288 #define YYNSTATES 419
1290 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1291 #define YYUNDEFTOK 2
1292 #define YYMAXUTOK 348
1294 #define YYTRANSLATE(YYX) \
1295 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1297 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1298 static const unsigned char yytranslate[] =
1300 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1301 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1302 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1303 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1304 96, 97, 105, 2, 106, 2, 2, 2, 2, 2,
1305 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1306 101, 94, 102, 2, 2, 2, 2, 2, 2, 2,
1307 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1308 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1309 2, 98, 95, 100, 2, 2, 2, 2, 2, 107,
1310 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1311 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1312 99, 2, 2, 103, 2, 104, 2, 2, 2, 2,
1313 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1314 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1315 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1316 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1317 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1318 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1319 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1320 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1321 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1322 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1323 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1324 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1325 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1326 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1327 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1328 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1329 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1330 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1331 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1332 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1333 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1334 85, 86, 87, 88, 89, 90, 91, 92, 93
1338 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1340 static const unsigned short yyprhs[] =
1342 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1343 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1344 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1345 59, 61, 63, 65, 67, 70, 71, 73, 75, 77,
1346 79, 80, 81, 83, 85, 87, 90, 92, 94, 96,
1347 98, 100, 102, 104, 106, 108, 110, 112, 114, 116,
1348 118, 120, 122, 124, 126, 128, 130, 132, 135, 140,
1349 146, 152, 156, 159, 162, 164, 168, 170, 174, 176,
1350 177, 182, 186, 190, 195, 200, 204, 207, 210, 213,
1351 216, 219, 222, 225, 228, 231, 234, 241, 247, 256,
1352 263, 270, 277, 284, 288, 290, 292, 294, 296, 299,
1353 302, 305, 307, 312, 315, 321, 327, 331, 336, 337,
1354 339, 341, 345, 349, 353, 357, 361, 363, 364, 366,
1355 368, 370, 371, 374, 378, 380, 382, 386, 388, 389,
1356 396, 398, 400, 404, 406, 408, 411, 412, 416, 418,
1357 420, 422, 424, 426, 428, 430, 434, 436, 438, 440,
1358 442, 444, 447, 450, 453, 457, 460, 461, 463, 466,
1359 469, 473, 483, 493, 502, 516, 518, 520, 527, 533,
1360 536, 543, 551, 553, 557, 559, 560, 563, 565, 571,
1361 577, 583, 586, 591, 596, 603, 608, 613, 618, 621,
1362 629, 631, 634, 635, 637, 638, 641, 647, 650, 656,
1366 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
1367 static const short yyrhs[] =
1369 133, 0, -1, 5, -1, 6, -1, 3, -1, 4,
1370 -1, 66, -1, 67, -1, 68, -1, 69, -1, 70,
1371 -1, 71, -1, 72, -1, 73, -1, 74, -1, 75,
1372 -1, 76, -1, 77, -1, 78, -1, 79, -1, 89,
1373 -1, 90, -1, 16, -1, 14, -1, 12, -1, 10,
1374 -1, 17, -1, 15, -1, 13, -1, 11, -1, 115,
1375 -1, 116, -1, 18, -1, 19, -1, 140, 94, -1,
1376 -1, 40, -1, 41, -1, 42, -1, 43, -1, -1,
1377 -1, 57, -1, 58, -1, 59, -1, 56, 4, -1,
1378 124, -1, 8, -1, 126, -1, 8, -1, 126, -1,
1379 9, -1, 10, -1, 11, -1, 12, -1, 13, -1,
1380 14, -1, 15, -1, 16, -1, 17, -1, 18, -1,
1381 19, -1, 20, -1, 21, -1, 44, -1, 125, -1,
1382 153, -1, 95, 4, -1, 123, 96, 128, 97, -1,
1383 98, 4, 99, 126, 100, -1, 101, 4, 99, 126,
1384 102, -1, 103, 127, 104, -1, 103, 104, -1, 126,
1385 105, -1, 126, -1, 127, 106, 126, -1, 127, -1,
1386 127, 106, 36, -1, 36, -1, -1, 124, 98, 131,
1387 100, -1, 124, 98, 100, -1, 124, 107, 24, -1,
1388 124, 101, 131, 102, -1, 124, 103, 131, 104, -1,
1389 124, 103, 104, -1, 124, 37, -1, 124, 38, -1,
1390 124, 153, -1, 124, 130, -1, 124, 26, -1, 115,
1391 110, -1, 116, 4, -1, 9, 27, -1, 9, 28,
1392 -1, 118, 7, -1, 87, 96, 129, 35, 124, 97,
1393 -1, 85, 96, 129, 167, 97, -1, 88, 96, 129,
1394 106, 129, 106, 129, 97, -1, 111, 96, 129, 106,
1395 129, 97, -1, 112, 96, 129, 106, 129, 97, -1,
1396 113, 96, 129, 106, 129, 97, -1, 114, 96, 129,
1397 106, 129, 97, -1, 131, 106, 129, -1, 129, -1,
1398 32, -1, 33, -1, 134, -1, 134, 149, -1, 134,
1399 150, -1, 134, 25, -1, 135, -1, 135, 119, 20,
1400 122, -1, 135, 150, -1, 135, 119, 120, 132, 129,
1401 -1, 135, 119, 46, 132, 124, -1, 135, 47, 137,
1402 -1, 135, 53, 94, 138, -1, -1, 52, -1, 51,
1403 -1, 49, 94, 136, -1, 50, 94, 4, -1, 48,
1404 94, 24, -1, 98, 139, 100, -1, 139, 106, 24,
1405 -1, 24, -1, -1, 22, -1, 24, -1, 140, -1,
1406 -1, 124, 141, -1, 143, 106, 142, -1, 142, -1,
1407 143, -1, 143, 106, 36, -1, 36, -1, -1, 121,
1408 122, 140, 96, 144, 97, -1, 29, -1, 103, -1,
1409 120, 145, 146, -1, 30, -1, 104, -1, 156, 148,
1410 -1, -1, 31, 151, 145, -1, 3, -1, 4, -1,
1411 7, -1, 27, -1, 28, -1, 37, -1, 38, -1,
1412 101, 131, 102, -1, 130, -1, 109, -1, 140, -1,
1413 153, -1, 152, -1, 124, 154, -1, 156, 157, -1,
1414 147, 157, -1, 158, 119, 159, -1, 158, 161, -1,
1415 -1, 23, -1, 60, 155, -1, 60, 8, -1, 61,
1416 21, 154, -1, 61, 9, 154, 106, 21, 154, 106,
1417 21, 154, -1, 62, 117, 154, 106, 21, 154, 98,
1418 160, 100, -1, 62, 117, 154, 106, 21, 154, 98,
1419 100, -1, 63, 121, 122, 154, 96, 164, 97, 35,
1420 21, 154, 64, 21, 154, -1, 64, -1, 65, -1,
1421 160, 117, 152, 106, 21, 154, -1, 117, 152, 106,
1422 21, 154, -1, 119, 166, -1, 124, 98, 154, 106,
1423 154, 100, -1, 162, 106, 98, 154, 106, 154, 100,
1424 -1, 155, -1, 163, 106, 155, -1, 163, -1, -1,
1425 55, 54, -1, 54, -1, 111, 124, 154, 106, 154,
1426 -1, 112, 124, 154, 106, 154, -1, 113, 124, 154,
1427 106, 154, -1, 45, 155, -1, 114, 155, 106, 155,
1428 -1, 87, 155, 35, 124, -1, 88, 155, 106, 155,
1429 106, 155, -1, 91, 155, 106, 124, -1, 92, 155,
1430 106, 124, -1, 93, 155, 106, 124, -1, 86, 162,
1431 -1, 165, 121, 122, 154, 96, 164, 97, -1, 169,
1432 -1, 106, 163, -1, -1, 34, -1, -1, 80, 124,
1433 -1, 80, 124, 106, 15, 154, -1, 81, 124, -1,
1434 81, 124, 106, 15, 154, -1, 82, 155, -1, 168,
1435 83, 124, 154, -1, 168, 84, 155, 106, 124, 154,
1436 -1, 85, 124, 154, 167, -1
1439 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1440 static const unsigned short yyrline[] =
1442 0, 982, 982, 983, 990, 991, 1000, 1000, 1000, 1000,
1443 1000, 1001, 1001, 1001, 1002, 1002, 1002, 1002, 1002, 1002,
1444 1004, 1004, 1008, 1008, 1008, 1008, 1009, 1009, 1009, 1009,
1445 1010, 1010, 1011, 1011, 1014, 1017, 1021, 1022, 1023, 1024,
1446 1025, 1027, 1028, 1029, 1030, 1031, 1044, 1044, 1045, 1045,
1447 1047, 1056, 1056, 1056, 1056, 1056, 1056, 1056, 1057, 1057,
1448 1057, 1057, 1057, 1057, 1058, 1061, 1064, 1070, 1077, 1089,
1449 1093, 1104, 1113, 1116, 1124, 1128, 1133, 1134, 1137, 1140,
1450 1150, 1175, 1188, 1216, 1241, 1261, 1273, 1282, 1286, 1345,
1451 1351, 1359, 1364, 1369, 1372, 1375, 1382, 1392, 1423, 1430,
1452 1451, 1458, 1463, 1473, 1476, 1483, 1483, 1493, 1500, 1504,
1453 1507, 1510, 1523, 1543, 1545, 1549, 1553, 1555, 1557, 1562,
1454 1563, 1565, 1568, 1576, 1581, 1583, 1587, 1591, 1599, 1599,
1455 1600, 1600, 1602, 1608, 1613, 1619, 1622, 1627, 1631, 1635,
1456 1715, 1715, 1717, 1725, 1725, 1727, 1731, 1731, 1740, 1743,
1457 1746, 1749, 1752, 1755, 1758, 1761, 1785, 1792, 1795, 1800,
1458 1800, 1806, 1810, 1813, 1821, 1830, 1834, 1844, 1855, 1858,
1459 1861, 1864, 1867, 1881, 1885, 1938, 1941, 1947, 1955, 1965,
1460 1972, 1977, 1984, 1988, 1994, 1994, 1996, 1999, 2005, 2017,
1461 2025, 2035, 2047, 2054, 2061, 2068, 2073, 2092, 2114, 2128,
1462 2185, 2191, 2193, 2197, 2200, 2206, 2210, 2214, 2218, 2222,
1467 #if YYDEBUG || YYERROR_VERBOSE
1468 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1469 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1470 static const char *const yytname[] =
1472 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1473 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1474 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1475 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1476 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1477 "DECLARE", "GLOBAL", "CONSTANT", "VOLATILE", "TO", "DOTDOTDOT",
1478 "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", "WEAK",
1479 "APPENDING", "OPAQUE", "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN",
1480 "POINTERSIZE", "LITTLE", "BIG", "DEPLIBS", "CALL", "TAIL", "CC_TOK",
1481 "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "RET", "BR", "SWITCH", "INVOKE",
1482 "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "DIV", "REM", "AND", "OR",
1483 "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC",
1484 "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", "CAST",
1485 "SELECT", "SHL", "SHR", "VAARG", "VAARG_old", "VANEXT_old", "'='",
1486 "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'",
1487 "'*'", "','", "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps",
1488 "LogicalOps", "SetCondOps", "ShiftOps", "SIntType", "UIntType",
1489 "IntType", "FPType", "OptAssign", "OptLinkage", "OptCallingConv",
1490 "TypesV", "UpRTypesV", "Types", "PrimType", "UpRTypes", "TypeListI",
1491 "ArgTypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1492 "Module", "FunctionList", "ConstPool", "BigOrLittle", "TargetDefinition",
1493 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
1494 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1495 "END", "Function", "FunctionProto", "@1", "ConstValueRef",
1496 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1497 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1498 "PHIList", "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal",
1499 "IndexList", "OptVolatile", "MemoryInst", 0
1504 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1506 static const unsigned short yytoknum[] =
1508 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1509 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1510 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1511 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1512 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1513 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1514 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1515 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1516 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1517 345, 346, 347, 348, 61, 92, 40, 41, 91, 120,
1518 93, 60, 62, 123, 125, 42, 44, 99
1522 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1523 static const unsigned char yyr1[] =
1525 0, 108, 109, 109, 110, 110, 111, 111, 111, 111,
1526 111, 112, 112, 112, 113, 113, 113, 113, 113, 113,
1527 114, 114, 115, 115, 115, 115, 116, 116, 116, 116,
1528 117, 117, 118, 118, 119, 119, 120, 120, 120, 120,
1529 120, 121, 121, 121, 121, 121, 122, 122, 123, 123,
1530 124, 125, 125, 125, 125, 125, 125, 125, 125, 125,
1531 125, 125, 125, 125, 126, 126, 126, 126, 126, 126,
1532 126, 126, 126, 126, 127, 127, 128, 128, 128, 128,
1533 129, 129, 129, 129, 129, 129, 129, 129, 129, 129,
1534 129, 129, 129, 129, 129, 129, 130, 130, 130, 130,
1535 130, 130, 130, 131, 131, 132, 132, 133, 134, 134,
1536 134, 134, 135, 135, 135, 135, 135, 135, 135, 136,
1537 136, 137, 137, 137, 138, 139, 139, 139, 140, 140,
1538 141, 141, 142, 143, 143, 144, 144, 144, 144, 145,
1539 146, 146, 147, 148, 148, 149, 151, 150, 152, 152,
1540 152, 152, 152, 152, 152, 152, 152, 153, 153, 154,
1541 154, 155, 156, 156, 157, 158, 158, 158, 159, 159,
1542 159, 159, 159, 159, 159, 159, 159, 160, 160, 161,
1543 162, 162, 163, 163, 164, 164, 165, 165, 166, 166,
1544 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
1545 166, 167, 167, 168, 168, 169, 169, 169, 169, 169,
1549 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1550 static const unsigned char yyr2[] =
1552 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1553 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1554 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1555 1, 1, 1, 1, 2, 0, 1, 1, 1, 1,
1556 0, 0, 1, 1, 1, 2, 1, 1, 1, 1,
1557 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1558 1, 1, 1, 1, 1, 1, 1, 2, 4, 5,
1559 5, 3, 2, 2, 1, 3, 1, 3, 1, 0,
1560 4, 3, 3, 4, 4, 3, 2, 2, 2, 2,
1561 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1562 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
1563 2, 1, 4, 2, 5, 5, 3, 4, 0, 1,
1564 1, 3, 3, 3, 3, 3, 1, 0, 1, 1,
1565 1, 0, 2, 3, 1, 1, 3, 1, 0, 6,
1566 1, 1, 3, 1, 1, 2, 0, 3, 1, 1,
1567 1, 1, 1, 1, 1, 3, 1, 1, 1, 1,
1568 1, 2, 2, 2, 3, 2, 0, 1, 2, 2,
1569 3, 9, 9, 8, 13, 1, 1, 6, 5, 2,
1570 6, 7, 1, 3, 1, 0, 2, 1, 5, 5,
1571 5, 2, 4, 4, 6, 4, 4, 4, 2, 7,
1572 1, 2, 0, 1, 0, 2, 5, 2, 5, 2,
1576 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1577 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1578 means the default is an error. */
1579 static const unsigned char yydefact[] =
1581 118, 0, 40, 111, 1, 110, 146, 36, 37, 38,
1582 39, 41, 166, 108, 109, 166, 128, 129, 0, 0,
1583 40, 0, 113, 41, 0, 42, 43, 44, 0, 0,
1584 167, 163, 35, 143, 144, 145, 162, 0, 0, 0,
1585 116, 0, 0, 0, 0, 34, 147, 45, 2, 3,
1586 47, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1587 60, 61, 62, 63, 64, 0, 0, 0, 0, 157,
1588 0, 0, 46, 65, 50, 158, 66, 140, 141, 142,
1589 204, 165, 0, 0, 0, 127, 117, 112, 105, 106,
1590 0, 0, 67, 0, 0, 49, 72, 74, 0, 0,
1591 79, 73, 203, 0, 187, 0, 0, 0, 0, 41,
1592 175, 176, 6, 7, 8, 9, 10, 11, 12, 13,
1593 14, 15, 16, 17, 18, 19, 0, 0, 0, 0,
1594 0, 0, 0, 20, 21, 0, 0, 0, 0, 0,
1595 0, 0, 164, 41, 179, 0, 200, 123, 120, 119,
1596 121, 122, 126, 0, 115, 51, 52, 53, 54, 55,
1597 56, 57, 58, 59, 60, 61, 0, 0, 0, 0,
1598 114, 0, 0, 71, 0, 138, 78, 76, 0, 0,
1599 191, 186, 169, 168, 0, 0, 25, 29, 24, 28,
1600 23, 27, 22, 26, 30, 31, 0, 0, 205, 207,
1601 209, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1602 0, 0, 0, 0, 0, 0, 124, 0, 93, 94,
1603 4, 5, 91, 92, 95, 90, 86, 87, 0, 0,
1604 0, 0, 0, 0, 0, 0, 0, 0, 0, 89,
1605 88, 48, 48, 75, 137, 131, 134, 135, 0, 0,
1606 68, 148, 149, 150, 151, 152, 153, 154, 0, 156,
1607 160, 159, 161, 0, 170, 0, 0, 0, 0, 202,
1608 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1609 0, 0, 0, 0, 125, 0, 0, 0, 81, 104,
1610 0, 0, 85, 0, 82, 0, 0, 0, 0, 69,
1611 70, 130, 132, 0, 139, 77, 0, 0, 0, 0,
1612 0, 0, 0, 212, 0, 0, 193, 0, 195, 196,
1613 197, 0, 0, 0, 192, 0, 210, 0, 202, 0,
1614 0, 80, 0, 83, 84, 0, 0, 0, 0, 136,
1615 133, 155, 0, 0, 185, 206, 208, 182, 201, 0,
1616 0, 0, 188, 189, 190, 185, 0, 0, 0, 0,
1617 103, 0, 0, 0, 0, 0, 0, 184, 0, 0,
1618 0, 0, 194, 0, 211, 97, 0, 0, 0, 0,
1619 0, 0, 0, 0, 0, 183, 180, 0, 199, 96,
1620 0, 99, 100, 101, 102, 0, 173, 0, 0, 0,
1621 181, 0, 171, 0, 172, 0, 0, 98, 0, 0,
1622 0, 0, 0, 0, 178, 0, 0, 177, 174
1625 /* YYDEFGOTO[NTERM-NUM]. */
1626 static const short yydefgoto[] =
1628 -1, 69, 222, 235, 236, 237, 238, 166, 167, 196,
1629 168, 20, 11, 28, 70, 71, 169, 73, 74, 98,
1630 178, 289, 259, 290, 90, 1, 2, 3, 150, 40,
1631 86, 153, 75, 302, 246, 247, 248, 29, 79, 12,
1632 35, 13, 14, 23, 260, 76, 262, 347, 15, 31,
1633 32, 142, 398, 81, 203, 367, 368, 143, 144, 313,
1637 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1639 #define YYPACT_NINF -383
1640 static const short yypact[] =
1642 -383, 48, 136, 517, -383, -383, -383, -383, -383, -383,
1643 -383, 27, 36, -383, -383, -17, -383, -383, 46, -21,
1644 -3, 3, -383, 27, 73, -383, -383, -383, 879, -24,
1645 -383, -383, 113, -383, -383, -383, -383, 20, 51, 60,
1646 -383, 21, 879, -13, -13, -383, -383, -383, -383, -383,
1647 62, -383, -383, -383, -383, -383, -383, -383, -383, -383,
1648 -383, -383, -383, -383, -383, 156, 162, 164, 480, -383,
1649 113, 76, -383, -383, -25, -383, -383, -383, -383, -383,
1650 992, -383, 149, 37, 170, 157, -383, -383, -383, -383,
1651 900, 941, -383, 81, 83, -383, -383, -25, 34, 87,
1652 643, -383, -383, 900, -383, 130, 999, 32, 243, 27,
1653 -383, -383, -383, -383, -383, -383, -383, -383, -383, -383,
1654 -383, -383, -383, -383, -383, -383, 900, 900, 900, 900,
1655 900, 900, 900, -383, -383, 900, 900, 900, 900, 900,
1656 900, 900, -383, 27, -383, 22, -383, -383, -383, -383,
1657 -383, -383, -383, -82, -383, 122, 148, 184, 153, 185,
1658 159, 186, 161, 187, 191, 193, 167, 197, 195, 380,
1659 -383, 900, 900, -383, 900, 680, -383, 97, 114, 549,
1660 -383, -383, 62, -383, 549, 549, -383, -383, -383, -383,
1661 -383, -383, -383, -383, -383, -383, 549, 879, 108, 109,
1662 -383, 549, 118, 111, 183, 116, 117, 119, 121, 549,
1663 549, 549, 124, 879, 900, 900, -383, 196, -383, -383,
1664 -383, -383, -383, -383, -383, -383, -383, -383, 123, 132,
1665 135, 742, 941, 501, 208, 137, 144, 145, 147, -383,
1666 -383, -84, -12, -25, -383, 113, -383, 155, 154, 779,
1667 -383, -383, -383, -383, -383, -383, -383, -383, 941, -383,
1668 -383, -383, -383, 158, -383, 160, 549, 235, 247, 173,
1669 549, 165, 900, 900, 900, 900, 900, 174, 175, 176,
1670 900, 549, 549, 177, -383, 941, 941, 941, -383, -383,
1671 -54, -57, -383, 42, -383, 941, 941, 941, 941, -383,
1672 -383, -383, -383, 842, -383, -383, -30, 244, 246, 172,
1673 549, 549, 900, -383, 179, 549, -383, 180, -383, -383,
1674 -383, 549, 549, 549, -383, 194, -383, 900, 173, 241,
1675 181, -383, 941, -383, -383, 190, 198, 199, 202, -383,
1676 -383, -383, 549, 549, 900, -383, -383, -383, 205, 549,
1677 206, 900, -383, -383, -383, 900, 549, 192, 900, 941,
1678 -383, 941, 941, 941, 941, 207, 203, 205, 200, 900,
1679 214, 549, -383, 218, -383, -383, 220, 212, 222, 223,
1680 224, 225, 281, 17, 268, -383, -383, 226, -383, -383,
1681 941, -383, -383, -383, -383, 549, -383, 54, 53, 303,
1682 -383, 228, -383, 227, -383, 54, 549, -383, 307, 231,
1683 265, 549, 310, 311, -383, 549, 549, -383, -383
1686 /* YYPGOTO[NTERM-NUM]. */
1687 static const short yypgoto[] =
1689 -383, -383, -383, 254, 262, 264, 272, -106, -105, -372,
1690 -383, 313, 333, -101, -38, -383, -28, -383, -56, 255,
1691 -383, -90, 188, -223, 312, -383, -383, -383, -383, -383,
1692 -383, -383, 4, -383, 55, -383, -383, 331, -383, -383,
1693 -383, -383, 356, -383, -382, 25, 28, -81, -383, 345,
1694 -383, -383, -383, -383, -383, 49, 7, -383, -383, 35,
1698 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1699 positive, shift that token. If negative, reduce the rule which
1700 number is the opposite. If zero, do what YYDEFACT says.
1701 If YYTABLE_NINF, syntax error. */
1702 #define YYTABLE_NINF -108
1703 static const short yytable[] =
1705 72, 170, 194, 195, 87, 77, 30, 21, 197, 291,
1706 293, 397, 97, 33, 72, 403, 299, 42, 216, 88,
1707 89, 101, 180, 409, 217, 183, 405, 186, 187, 188,
1708 189, 190, 191, 192, 193, 306, 21, 7, 8, 9,
1709 10, 184, 213, 43, 97, 333, 331, 200, 4, 332,
1710 204, 205, 332, 185, 206, 207, 208, 251, 252, 30,
1711 212, 253, 154, 186, 187, 188, 189, 190, 191, 192,
1712 193, -48, 341, 41, 99, 179, 332, 47, 179, 78,
1713 101, 254, 255, 24, 25, 26, 27, 34, 148, 149,
1714 300, 256, 257, 101, 37, 38, 39, 45, 198, 199,
1715 179, 201, 202, 179, 179, 214, 215, 179, 179, 179,
1716 209, 210, 211, 179, 82, 241, 242, 396, 243, 85,
1717 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
1718 122, 123, 124, 125, 283, 16, -107, 17, 173, 228,
1719 174, 229, 230, 133, 134, 83, 334, 245, 332, 218,
1720 219, -25, -25, 404, 84, 258, -24, -24, -49, 266,
1721 92, 5, -23, -23, -22, -22, 93, 6, 94, 72,
1722 220, 221, 100, 147, 151, 281, 7, 8, 9, 10,
1723 171, 152, 172, 175, 181, 72, 282, 179, -29, -28,
1724 -27, -26, 317, 243, 240, 328, 329, 330, -32, 324,
1725 -33, 223, 224, 249, 261, 335, 336, 337, 338, 261,
1726 261, 250, 263, 264, 267, 268, 270, 271, 272, 285,
1727 284, 261, 273, 274, 265, 275, 261, 276, 286, 269,
1728 280, 287, 294, 295, 261, 261, 261, 277, 278, 279,
1729 296, 297, 360, 298, 316, 179, 318, 319, 320, 301,
1730 310, 304, 179, 186, 187, 188, 189, 190, 191, 192,
1731 193, 303, 311, 315, 307, 342, 308, 343, 344, 377,
1732 372, 378, 379, 380, 381, 245, 358, 194, 195, 312,
1733 321, 322, 323, 327, 179, 349, 351, 359, 385, 375,
1734 355, 261, 194, 195, 309, 261, 361, 384, 314, 356,
1735 401, 383, 395, 399, 362, 363, 261, 261, 364, 325,
1736 326, 369, 371, 382, 386, 388, 179, 389, 390, 391,
1737 392, 393, 394, 179, 406, 407, 400, 179, 411, 413,
1738 376, 415, 416, 408, 138, 261, 261, 412, 345, 346,
1739 261, 179, 139, 350, 140, 80, 261, 261, 261, 352,
1740 353, 354, 141, 44, 46, 177, 91, 239, 340, 22,
1741 36, 348, 373, 357, 0, 0, 0, 261, 261, 0,
1742 365, 366, 0, 0, 261, 0, 0, 370, 0, 0,
1743 0, 261, 0, 0, 374, 48, 49, 0, 0, 0,
1744 0, 0, 0, 0, 0, 0, 261, 0, 0, 387,
1745 0, 0, 16, 0, 17, 0, 225, 0, 0, 0,
1746 0, 0, 0, 0, 0, 0, 0, 226, 227, 0,
1747 261, 0, 0, 402, 0, 0, 0, 0, 0, 0,
1748 0, 261, 0, 0, 410, 0, 261, 0, 0, 414,
1749 261, 261, 0, 417, 418, 0, 112, 113, 114, 115,
1750 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1751 0, 0, 0, 0, 0, 228, 0, 229, 230, 133,
1752 134, 0, 0, 0, 0, 0, 0, 0, 231, 0,
1753 0, 232, 0, 233, 0, 48, 49, 234, 95, 51,
1754 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1755 62, 63, 16, 0, 17, 0, 48, 49, 0, 95,
1756 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
1757 165, 62, 63, 16, 64, 17, 0, 0, 0, 0,
1758 0, 0, 0, 0, 0, 0, 0, -35, 0, 16,
1759 0, 17, 0, 0, 0, 64, 0, 0, 6, -35,
1760 -35, 0, 251, 252, 48, 49, 253, -35, -35, -35,
1761 -35, 0, 0, -35, 18, 0, 0, 0, 0, 0,
1762 19, 16, 0, 17, 0, 65, 254, 255, 66, 0,
1763 0, 67, 0, 68, 96, 0, 256, 257, 0, 0,
1764 0, 0, 0, 0, 0, 0, 65, 0, 0, 66,
1765 0, 0, 67, 0, 68, 292, 0, 0, 0, 0,
1766 0, 0, 0, 0, 0, 112, 113, 114, 115, 116,
1767 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
1768 0, 0, 0, 0, 228, 0, 229, 230, 133, 134,
1769 0, 0, 0, 0, 0, 0, 0, 0, 48, 49,
1770 258, 95, 51, 52, 53, 54, 55, 56, 57, 58,
1771 59, 60, 61, 62, 63, 16, 0, 17, 0, 0,
1772 0, 0, 0, 0, 0, 0, 0, 0, 0, 176,
1773 0, 0, 0, 0, 0, 48, 49, 64, 95, 51,
1774 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1775 62, 63, 16, 0, 17, 0, 0, 0, 0, 0,
1776 0, 0, 0, 0, 0, 0, 244, 0, 0, 0,
1777 0, 0, 0, 0, 64, 0, 0, 0, 0, 0,
1778 0, 0, 0, 0, 0, 0, 0, 0, 65, 0,
1779 0, 66, 0, 0, 67, 0, 68, 48, 49, 0,
1780 95, 155, 156, 157, 158, 159, 160, 161, 162, 163,
1781 164, 165, 62, 63, 16, 0, 17, 0, 0, 0,
1782 0, 0, 0, 0, 0, 65, 0, 0, 66, 0,
1783 0, 67, 0, 68, 48, 49, 64, 95, 51, 52,
1784 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1785 63, 16, 0, 17, 0, 0, 0, 0, 0, 0,
1786 0, 0, 0, 0, 0, 305, 0, 0, 0, 0,
1787 0, 0, 0, 64, 0, 0, 0, 0, 0, 0,
1788 0, 0, 0, 0, 0, 0, 0, 65, 0, 0,
1789 66, 0, 288, 67, 0, 68, 0, 48, 49, 0,
1790 95, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1791 60, 61, 62, 63, 16, 0, 17, 0, 0, 0,
1792 0, 0, 0, 0, 65, 0, 0, 66, 339, 0,
1793 67, 0, 68, 0, 48, 49, 64, 50, 51, 52,
1794 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1795 63, 16, 0, 17, 0, 48, 49, 0, 95, 51,
1796 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1797 62, 63, 16, 64, 17, 0, 0, 0, 0, 0,
1798 0, 0, 0, 0, 0, 0, 0, 65, 0, 0,
1799 66, 0, 0, 67, 64, 68, 48, 49, 0, 95,
1800 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
1801 165, 62, 63, 16, 0, 17, 0, 0, 0, 0,
1802 0, 0, 0, 0, 65, 0, 0, 66, 0, 0,
1803 67, 0, 68, 0, 0, 64, 0, 0, 0, 0,
1804 0, 0, 0, 0, 0, 65, 0, 0, 66, 0,
1805 0, 67, 0, 68, 48, 49, 0, 182, 51, 52,
1806 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1807 63, 16, 0, 17, 0, 0, 102, 0, 0, 0,
1808 0, 0, 0, 0, 0, 0, 65, 103, 0, 66,
1809 0, 0, 67, 64, 68, 0, 104, 105, 0, 0,
1810 0, 0, 106, 107, 108, 109, 110, 111, 112, 113,
1811 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1812 124, 125, 126, 127, 128, 0, 0, 129, 130, 131,
1813 132, 133, 134, 135, 136, 137, 0, 0, 0, 0,
1814 0, 0, 0, 0, 65, 0, 0, 66, 0, 0,
1818 static const short yycheck[] =
1820 28, 91, 108, 108, 42, 29, 23, 3, 109, 232,
1821 233, 383, 68, 30, 42, 397, 100, 20, 100, 32,
1822 33, 105, 103, 405, 106, 106, 398, 10, 11, 12,
1823 13, 14, 15, 16, 17, 258, 32, 40, 41, 42,
1824 43, 9, 143, 46, 100, 102, 100, 128, 0, 106,
1825 131, 132, 106, 21, 135, 136, 137, 3, 4, 23,
1826 141, 7, 90, 10, 11, 12, 13, 14, 15, 16,
1827 17, 96, 102, 94, 70, 103, 106, 4, 106, 103,
1828 105, 27, 28, 56, 57, 58, 59, 104, 51, 52,
1829 102, 37, 38, 105, 48, 49, 50, 94, 126, 127,
1830 128, 129, 130, 131, 132, 83, 84, 135, 136, 137,
1831 138, 139, 140, 141, 94, 171, 172, 100, 174, 98,
1832 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1833 76, 77, 78, 79, 215, 22, 0, 24, 104, 85,
1834 106, 87, 88, 89, 90, 94, 104, 175, 106, 27,
1835 28, 3, 4, 100, 94, 101, 3, 4, 96, 197,
1836 4, 25, 3, 4, 3, 4, 4, 31, 4, 197,
1837 3, 4, 96, 24, 4, 213, 40, 41, 42, 43,
1838 99, 24, 99, 96, 54, 213, 214, 215, 4, 4,
1839 4, 4, 273, 249, 169, 285, 286, 287, 7, 280,
1840 7, 4, 7, 106, 179, 295, 296, 297, 298, 184,
1841 185, 97, 184, 185, 106, 106, 98, 106, 35, 96,
1842 24, 196, 106, 106, 196, 106, 201, 106, 96, 201,
1843 106, 96, 24, 96, 209, 210, 211, 209, 210, 211,
1844 96, 96, 332, 96, 272, 273, 274, 275, 276, 245,
1845 15, 97, 280, 10, 11, 12, 13, 14, 15, 16,
1846 17, 106, 15, 98, 106, 21, 106, 21, 96, 359,
1847 351, 361, 362, 363, 364, 303, 35, 383, 383, 106,
1848 106, 106, 106, 106, 312, 106, 106, 106, 369, 97,
1849 96, 266, 398, 398, 266, 270, 106, 97, 270, 327,
1850 390, 98, 21, 35, 106, 106, 281, 282, 106, 281,
1851 282, 106, 106, 106, 100, 97, 344, 97, 106, 97,
1852 97, 97, 97, 351, 21, 97, 100, 355, 21, 64,
1853 358, 21, 21, 106, 80, 310, 311, 106, 310, 311,
1854 315, 369, 80, 315, 80, 32, 321, 322, 323, 321,
1855 322, 323, 80, 20, 23, 100, 44, 169, 303, 3,
1856 15, 312, 355, 328, -1, -1, -1, 342, 343, -1,
1857 342, 343, -1, -1, 349, -1, -1, 349, -1, -1,
1858 -1, 356, -1, -1, 356, 5, 6, -1, -1, -1,
1859 -1, -1, -1, -1, -1, -1, 371, -1, -1, 371,
1860 -1, -1, 22, -1, 24, -1, 26, -1, -1, -1,
1861 -1, -1, -1, -1, -1, -1, -1, 37, 38, -1,
1862 395, -1, -1, 395, -1, -1, -1, -1, -1, -1,
1863 -1, 406, -1, -1, 406, -1, 411, -1, -1, 411,
1864 415, 416, -1, 415, 416, -1, 66, 67, 68, 69,
1865 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1866 -1, -1, -1, -1, -1, 85, -1, 87, 88, 89,
1867 90, -1, -1, -1, -1, -1, -1, -1, 98, -1,
1868 -1, 101, -1, 103, -1, 5, 6, 107, 8, 9,
1869 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1870 20, 21, 22, -1, 24, -1, 5, 6, -1, 8,
1871 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1872 19, 20, 21, 22, 44, 24, -1, -1, -1, -1,
1873 -1, -1, -1, -1, -1, -1, -1, 20, -1, 22,
1874 -1, 24, -1, -1, -1, 44, -1, -1, 31, 32,
1875 33, -1, 3, 4, 5, 6, 7, 40, 41, 42,
1876 43, -1, -1, 46, 47, -1, -1, -1, -1, -1,
1877 53, 22, -1, 24, -1, 95, 27, 28, 98, -1,
1878 -1, 101, -1, 103, 104, -1, 37, 38, -1, -1,
1879 -1, -1, -1, -1, -1, -1, 95, -1, -1, 98,
1880 -1, -1, 101, -1, 103, 104, -1, -1, -1, -1,
1881 -1, -1, -1, -1, -1, 66, 67, 68, 69, 70,
1882 71, 72, 73, 74, 75, 76, 77, 78, 79, -1,
1883 -1, -1, -1, -1, 85, -1, 87, 88, 89, 90,
1884 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1885 101, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1886 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1887 -1, -1, -1, -1, -1, -1, -1, -1, -1, 36,
1888 -1, -1, -1, -1, -1, 5, 6, 44, 8, 9,
1889 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1890 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
1891 -1, -1, -1, -1, -1, -1, 36, -1, -1, -1,
1892 -1, -1, -1, -1, 44, -1, -1, -1, -1, -1,
1893 -1, -1, -1, -1, -1, -1, -1, -1, 95, -1,
1894 -1, 98, -1, -1, 101, -1, 103, 5, 6, -1,
1895 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1896 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1897 -1, -1, -1, -1, -1, 95, -1, -1, 98, -1,
1898 -1, 101, -1, 103, 5, 6, 44, 8, 9, 10,
1899 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1900 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1901 -1, -1, -1, -1, -1, 36, -1, -1, -1, -1,
1902 -1, -1, -1, 44, -1, -1, -1, -1, -1, -1,
1903 -1, -1, -1, -1, -1, -1, -1, 95, -1, -1,
1904 98, -1, 100, 101, -1, 103, -1, 5, 6, -1,
1905 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1906 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1907 -1, -1, -1, -1, 95, -1, -1, 98, 36, -1,
1908 101, -1, 103, -1, 5, 6, 44, 8, 9, 10,
1909 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1910 21, 22, -1, 24, -1, 5, 6, -1, 8, 9,
1911 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1912 20, 21, 22, 44, 24, -1, -1, -1, -1, -1,
1913 -1, -1, -1, -1, -1, -1, -1, 95, -1, -1,
1914 98, -1, -1, 101, 44, 103, 5, 6, -1, 8,
1915 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1916 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1917 -1, -1, -1, -1, 95, -1, -1, 98, -1, -1,
1918 101, -1, 103, -1, -1, 44, -1, -1, -1, -1,
1919 -1, -1, -1, -1, -1, 95, -1, -1, 98, -1,
1920 -1, 101, -1, 103, 5, 6, -1, 8, 9, 10,
1921 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1922 21, 22, -1, 24, -1, -1, 34, -1, -1, -1,
1923 -1, -1, -1, -1, -1, -1, 95, 45, -1, 98,
1924 -1, -1, 101, 44, 103, -1, 54, 55, -1, -1,
1925 -1, -1, 60, 61, 62, 63, 64, 65, 66, 67,
1926 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1927 78, 79, 80, 81, 82, -1, -1, 85, 86, 87,
1928 88, 89, 90, 91, 92, 93, -1, -1, -1, -1,
1929 -1, -1, -1, -1, 95, -1, -1, 98, -1, -1,
1933 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1934 symbol of state STATE-NUM. */
1935 static const unsigned char yystos[] =
1937 0, 133, 134, 135, 0, 25, 31, 40, 41, 42,
1938 43, 120, 147, 149, 150, 156, 22, 24, 47, 53,
1939 119, 140, 150, 151, 56, 57, 58, 59, 121, 145,
1940 23, 157, 158, 30, 104, 148, 157, 48, 49, 50,
1941 137, 94, 20, 46, 120, 94, 145, 4, 5, 6,
1942 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1943 18, 19, 20, 21, 44, 95, 98, 101, 103, 109,
1944 122, 123, 124, 125, 126, 140, 153, 29, 103, 146,
1945 119, 161, 94, 94, 94, 98, 138, 122, 32, 33,
1946 132, 132, 4, 4, 4, 8, 104, 126, 127, 140,
1947 96, 105, 34, 45, 54, 55, 60, 61, 62, 63,
1948 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
1949 74, 75, 76, 77, 78, 79, 80, 81, 82, 85,
1950 86, 87, 88, 89, 90, 91, 92, 93, 111, 112,
1951 113, 114, 159, 165, 166, 168, 169, 24, 51, 52,
1952 136, 4, 24, 139, 124, 9, 10, 11, 12, 13,
1953 14, 15, 16, 17, 18, 19, 115, 116, 118, 124,
1954 129, 99, 99, 104, 106, 96, 36, 127, 128, 124,
1955 155, 54, 8, 155, 9, 21, 10, 11, 12, 13,
1956 14, 15, 16, 17, 115, 116, 117, 121, 124, 124,
1957 155, 124, 124, 162, 155, 155, 155, 155, 155, 124,
1958 124, 124, 155, 121, 83, 84, 100, 106, 27, 28,
1959 3, 4, 110, 4, 7, 26, 37, 38, 85, 87,
1960 88, 98, 101, 103, 107, 111, 112, 113, 114, 130,
1961 153, 126, 126, 126, 36, 124, 142, 143, 144, 106,
1962 97, 3, 4, 7, 27, 28, 37, 38, 101, 130,
1963 152, 153, 154, 154, 154, 154, 122, 106, 106, 154,
1964 98, 106, 35, 106, 106, 106, 106, 154, 154, 154,
1965 106, 122, 124, 155, 24, 96, 96, 96, 100, 129,
1966 131, 131, 104, 131, 24, 96, 96, 96, 96, 100,
1967 102, 140, 141, 106, 97, 36, 131, 106, 106, 154,
1968 15, 15, 106, 167, 154, 98, 124, 155, 124, 124,
1969 124, 106, 106, 106, 155, 154, 154, 106, 129, 129,
1970 129, 100, 106, 102, 104, 129, 129, 129, 129, 36,
1971 142, 102, 21, 21, 96, 154, 154, 155, 163, 106,
1972 154, 106, 154, 154, 154, 96, 124, 167, 35, 106,
1973 129, 106, 106, 106, 106, 154, 154, 163, 164, 106,
1974 154, 106, 155, 164, 154, 97, 124, 129, 129, 129,
1975 129, 129, 106, 98, 97, 155, 100, 154, 97, 97,
1976 106, 97, 97, 97, 97, 21, 100, 117, 160, 35,
1977 100, 129, 154, 152, 100, 117, 21, 97, 106, 152,
1978 154, 21, 106, 64, 154, 21, 21, 154, 154
1981 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1982 # define YYSIZE_T __SIZE_TYPE__
1984 #if ! defined (YYSIZE_T) && defined (size_t)
1985 # define YYSIZE_T size_t
1987 #if ! defined (YYSIZE_T)
1988 # if defined (__STDC__) || defined (__cplusplus)
1989 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1990 # define YYSIZE_T size_t
1993 #if ! defined (YYSIZE_T)
1994 # define YYSIZE_T unsigned int
1997 #define yyerrok (yyerrstatus = 0)
1998 #define yyclearin (yychar = YYEMPTY)
1999 #define YYEMPTY (-2)
2002 #define YYACCEPT goto yyacceptlab
2003 #define YYABORT goto yyabortlab
2004 #define YYERROR goto yyerrorlab
2007 /* Like YYERROR except do call yyerror. This remains here temporarily
2008 to ease the transition to the new meaning of YYERROR, for GCC.
2009 Once GCC version 2 has supplanted version 1, this can go. */
2011 #define YYFAIL goto yyerrlab
2013 #define YYRECOVERING() (!!yyerrstatus)
2015 #define YYBACKUP(Token, Value) \
2017 if (yychar == YYEMPTY && yylen == 1) \
2021 yytoken = YYTRANSLATE (yychar); \
2027 yyerror ("syntax error: cannot back up");\
2033 #define YYERRCODE 256
2035 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
2038 #ifndef YYLLOC_DEFAULT
2039 # define YYLLOC_DEFAULT(Current, Rhs, N) \
2040 ((Current).first_line = (Rhs)[1].first_line, \
2041 (Current).first_column = (Rhs)[1].first_column, \
2042 (Current).last_line = (Rhs)[N].last_line, \
2043 (Current).last_column = (Rhs)[N].last_column)
2046 /* YYLEX -- calling `yylex' with the right arguments. */
2049 # define YYLEX yylex (YYLEX_PARAM)
2051 # define YYLEX yylex ()
2054 /* Enable debugging if requested. */
2058 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2059 # define YYFPRINTF fprintf
2062 # define YYDPRINTF(Args) \
2068 # define YYDSYMPRINT(Args) \
2074 # define YYDSYMPRINTF(Title, Token, Value, Location) \
2078 YYFPRINTF (stderr, "%s ", Title); \
2079 yysymprint (stderr, \
2081 YYFPRINTF (stderr, "\n"); \
2085 /*------------------------------------------------------------------.
2086 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
2088 `------------------------------------------------------------------*/
2090 #if defined (__STDC__) || defined (__cplusplus)
2092 yy_stack_print (short *bottom, short *top)
2095 yy_stack_print (bottom, top)
2100 YYFPRINTF (stderr, "Stack now");
2101 for (/* Nothing. */; bottom <= top; ++bottom)
2102 YYFPRINTF (stderr, " %d", *bottom);
2103 YYFPRINTF (stderr, "\n");
2106 # define YY_STACK_PRINT(Bottom, Top) \
2109 yy_stack_print ((Bottom), (Top)); \
2113 /*------------------------------------------------.
2114 | Report that the YYRULE is going to be reduced. |
2115 `------------------------------------------------*/
2117 #if defined (__STDC__) || defined (__cplusplus)
2119 yy_reduce_print (int yyrule)
2122 yy_reduce_print (yyrule)
2127 unsigned int yylno = yyrline[yyrule];
2128 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
2130 /* Print the symbols being reduced, and their result. */
2131 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2132 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
2133 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
2136 # define YY_REDUCE_PRINT(Rule) \
2139 yy_reduce_print (Rule); \
2142 /* Nonzero means print parse trace. It is left uninitialized so that
2143 multiple parsers can coexist. */
2145 #else /* !YYDEBUG */
2146 # define YYDPRINTF(Args)
2147 # define YYDSYMPRINT(Args)
2148 # define YYDSYMPRINTF(Title, Token, Value, Location)
2149 # define YY_STACK_PRINT(Bottom, Top)
2150 # define YY_REDUCE_PRINT(Rule)
2151 #endif /* !YYDEBUG */
2154 /* YYINITDEPTH -- initial size of the parser's stacks. */
2156 # define YYINITDEPTH 200
2159 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2160 if the built-in stack extension method is used).
2162 Do not make this value too large; the results are undefined if
2163 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
2164 evaluated with infinite-precision integer arithmetic. */
2166 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
2171 # define YYMAXDEPTH 10000
2179 # if defined (__GLIBC__) && defined (_STRING_H)
2180 # define yystrlen strlen
2182 /* Return the length of YYSTR. */
2184 # if defined (__STDC__) || defined (__cplusplus)
2185 yystrlen (const char *yystr)
2191 register const char *yys = yystr;
2193 while (*yys++ != '\0')
2196 return yys - yystr - 1;
2202 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2203 # define yystpcpy stpcpy
2205 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2208 # if defined (__STDC__) || defined (__cplusplus)
2209 yystpcpy (char *yydest, const char *yysrc)
2211 yystpcpy (yydest, yysrc)
2216 register char *yyd = yydest;
2217 register const char *yys = yysrc;
2219 while ((*yyd++ = *yys++) != '\0')
2227 #endif /* !YYERROR_VERBOSE */
2232 /*--------------------------------.
2233 | Print this symbol on YYOUTPUT. |
2234 `--------------------------------*/
2236 #if defined (__STDC__) || defined (__cplusplus)
2238 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
2241 yysymprint (yyoutput, yytype, yyvaluep)
2247 /* Pacify ``unused variable'' warnings. */
2250 if (yytype < YYNTOKENS)
2252 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2254 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2258 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2265 YYFPRINTF (yyoutput, ")");
2268 #endif /* ! YYDEBUG */
2269 /*-----------------------------------------------.
2270 | Release the memory associated to this symbol. |
2271 `-----------------------------------------------*/
2273 #if defined (__STDC__) || defined (__cplusplus)
2275 yydestruct (int yytype, YYSTYPE *yyvaluep)
2278 yydestruct (yytype, yyvaluep)
2283 /* Pacify ``unused variable'' warnings. */
2295 /* Prevent warnings from -Wmissing-prototypes. */
2297 #ifdef YYPARSE_PARAM
2298 # if defined (__STDC__) || defined (__cplusplus)
2299 int yyparse (void *YYPARSE_PARAM);
2303 #else /* ! YYPARSE_PARAM */
2304 #if defined (__STDC__) || defined (__cplusplus)
2309 #endif /* ! YYPARSE_PARAM */
2313 /* The lookahead symbol. */
2316 /* The semantic value of the lookahead symbol. */
2319 /* Number of syntax errors so far. */
2328 #ifdef YYPARSE_PARAM
2329 # if defined (__STDC__) || defined (__cplusplus)
2330 int yyparse (void *YYPARSE_PARAM)
2332 int yyparse (YYPARSE_PARAM)
2333 void *YYPARSE_PARAM;
2335 #else /* ! YYPARSE_PARAM */
2336 #if defined (__STDC__) || defined (__cplusplus)
2347 register int yystate;
2350 /* Number of tokens to shift before error messages enabled. */
2352 /* Lookahead token as an internal (translated) token number. */
2355 /* Three stacks and their tools:
2356 `yyss': related to states,
2357 `yyvs': related to semantic values,
2358 `yyls': related to locations.
2360 Refer to the stacks thru separate pointers, to allow yyoverflow
2361 to reallocate them elsewhere. */
2363 /* The state stack. */
2364 short yyssa[YYINITDEPTH];
2365 short *yyss = yyssa;
2366 register short *yyssp;
2368 /* The semantic value stack. */
2369 YYSTYPE yyvsa[YYINITDEPTH];
2370 YYSTYPE *yyvs = yyvsa;
2371 register YYSTYPE *yyvsp;
2375 #define YYPOPSTACK (yyvsp--, yyssp--)
2377 YYSIZE_T yystacksize = YYINITDEPTH;
2379 /* The variables used to return semantic value and location from the
2384 /* When reducing, the number of symbols on the RHS of the reduced
2388 YYDPRINTF ((stderr, "Starting parse\n"));
2393 yychar = YYEMPTY; /* Cause a token to be read. */
2395 /* Initialize stack pointers.
2396 Waste one element of value and location stack
2397 so that they stay on the same level as the state stack.
2398 The wasted elements are never initialized. */
2405 /*------------------------------------------------------------.
2406 | yynewstate -- Push a new state, which is found in yystate. |
2407 `------------------------------------------------------------*/
2409 /* In all cases, when you get here, the value and location stacks
2410 have just been pushed. so pushing a state here evens the stacks.
2417 if (yyss + yystacksize - 1 <= yyssp)
2419 /* Get the current used size of the three stacks, in elements. */
2420 YYSIZE_T yysize = yyssp - yyss + 1;
2424 /* Give user a chance to reallocate the stack. Use copies of
2425 these so that the &'s don't force the real ones into
2427 YYSTYPE *yyvs1 = yyvs;
2428 short *yyss1 = yyss;
2431 /* Each stack pointer address is followed by the size of the
2432 data in use in that stack, in bytes. This used to be a
2433 conditional around just the two extra args, but that might
2434 be undefined if yyoverflow is a macro. */
2435 yyoverflow ("parser stack overflow",
2436 &yyss1, yysize * sizeof (*yyssp),
2437 &yyvs1, yysize * sizeof (*yyvsp),
2444 #else /* no yyoverflow */
2445 # ifndef YYSTACK_RELOCATE
2448 /* Extend the stack our own way. */
2449 if (YYMAXDEPTH <= yystacksize)
2452 if (YYMAXDEPTH < yystacksize)
2453 yystacksize = YYMAXDEPTH;
2456 short *yyss1 = yyss;
2457 union yyalloc *yyptr =
2458 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2461 YYSTACK_RELOCATE (yyss);
2462 YYSTACK_RELOCATE (yyvs);
2464 # undef YYSTACK_RELOCATE
2466 YYSTACK_FREE (yyss1);
2469 #endif /* no yyoverflow */
2471 yyssp = yyss + yysize - 1;
2472 yyvsp = yyvs + yysize - 1;
2475 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2476 (unsigned long int) yystacksize));
2478 if (yyss + yystacksize - 1 <= yyssp)
2482 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2491 /* Do appropriate processing given the current state. */
2492 /* Read a lookahead token if we need one and don't already have one. */
2495 /* First try to decide what to do without reference to lookahead token. */
2497 yyn = yypact[yystate];
2498 if (yyn == YYPACT_NINF)
2501 /* Not known => get a lookahead token if don't already have one. */
2503 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
2504 if (yychar == YYEMPTY)
2506 YYDPRINTF ((stderr, "Reading a token: "));
2510 if (yychar <= YYEOF)
2512 yychar = yytoken = YYEOF;
2513 YYDPRINTF ((stderr, "Now at end of input.\n"));
2517 yytoken = YYTRANSLATE (yychar);
2518 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
2521 /* If the proper action on seeing token YYTOKEN is to reduce or to
2522 detect an error, take that action. */
2524 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2529 if (yyn == 0 || yyn == YYTABLE_NINF)
2538 /* Shift the lookahead token. */
2539 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
2541 /* Discard the token being shifted unless it is eof. */
2542 if (yychar != YYEOF)
2548 /* Count tokens shifted since error; after three, turn off error
2557 /*-----------------------------------------------------------.
2558 | yydefault -- do the default action for the current state. |
2559 `-----------------------------------------------------------*/
2561 yyn = yydefact[yystate];
2567 /*-----------------------------.
2568 | yyreduce -- Do a reduction. |
2569 `-----------------------------*/
2571 /* yyn is the number of a rule to reduce with. */
2574 /* If YYLEN is nonzero, implement the default value of the action:
2577 Otherwise, the following line sets YYVAL to garbage.
2578 This behavior is undocumented and Bison
2579 users should not rely upon it. Assigning to YYVAL
2580 unconditionally makes the parser a bit smaller, and it avoids a
2581 GCC warning that YYVAL may be used uninitialized. */
2582 yyval = yyvsp[1-yylen];
2585 YY_REDUCE_PRINT (yyn);
2589 #line 983 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2591 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2592 ThrowException("Value too large for type!");
2593 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2598 #line 991 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2600 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2601 ThrowException("Value too large for type!");
2602 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2607 #line 1014 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2609 yyval.StrVal = yyvsp[-1].StrVal;
2614 #line 1017 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2621 #line 1021 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2622 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
2626 #line 1022 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2627 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;}
2631 #line 1023 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2632 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
2636 #line 1024 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2637 { yyval.Linkage = GlobalValue::AppendingLinkage; ;}
2641 #line 1025 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2642 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
2646 #line 1027 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2647 { yyval.UIntVal = CallingConv::C; ;}
2651 #line 1028 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2652 { yyval.UIntVal = CallingConv::C; ;}
2656 #line 1029 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2657 { yyval.UIntVal = CallingConv::Fast; ;}
2661 #line 1030 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2662 { yyval.UIntVal = CallingConv::Cold; ;}
2666 #line 1031 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2668 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2669 ThrowException("Calling conv too large!");
2670 yyval.UIntVal = yyvsp[0].UInt64Val;
2675 #line 1044 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2676 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;}
2680 #line 1045 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2681 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;}
2685 #line 1047 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2687 if (!UpRefs.empty())
2688 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2689 yyval.TypeVal = yyvsp[0].TypeVal;
2694 #line 1058 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2696 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2701 #line 1061 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2703 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2708 #line 1064 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2709 { // Named types are also simple types...
2710 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2715 #line 1070 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2716 { // Type UpReference
2717 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2718 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2719 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2720 yyval.TypeVal = new PATypeHolder(OT);
2721 UR_OUT("New Upreference!\n");
2726 #line 1077 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2727 { // Function derived type?
2728 std::vector<const Type*> Params;
2729 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2730 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2731 Params.push_back(*I);
2732 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2733 if (isVarArg) Params.pop_back();
2735 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2736 delete yyvsp[-1].TypeList; // Delete the argument list
2737 delete yyvsp[-3].TypeVal; // Delete the return type handle
2742 #line 1089 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2743 { // Sized array type?
2744 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2745 delete yyvsp[-1].TypeVal;
2750 #line 1093 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2751 { // Packed array type?
2752 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2753 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) {
2754 ThrowException("Unsigned result not equal to signed result");
2756 if(!ElemTy->isPrimitiveType()) {
2757 ThrowException("Elemental type of a PackedType must be primitive");
2759 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2760 delete yyvsp[-1].TypeVal;
2765 #line 1104 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2766 { // Structure type?
2767 std::vector<const Type*> Elements;
2768 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2769 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2770 Elements.push_back(*I);
2772 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2773 delete yyvsp[-1].TypeList;
2778 #line 1113 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2779 { // Empty structure type?
2780 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2785 #line 1116 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2787 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2788 delete yyvsp[-1].TypeVal;
2793 #line 1124 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2795 yyval.TypeList = new std::list<PATypeHolder>();
2796 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2801 #line 1128 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2803 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2808 #line 1134 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2810 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2815 #line 1137 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2817 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2822 #line 1140 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2824 yyval.TypeList = new std::list<PATypeHolder>();
2829 #line 1150 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2830 { // Nonempty unsized arr
2831 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2833 ThrowException("Cannot make array constant with type: '" +
2834 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2835 const Type *ETy = ATy->getElementType();
2836 int NumElements = ATy->getNumElements();
2838 // Verify that we have the correct size...
2839 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2840 ThrowException("Type mismatch: constant sized array initialized with " +
2841 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2842 itostr(NumElements) + "!");
2844 // Verify all elements are correct type!
2845 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2846 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2847 ThrowException("Element #" + utostr(i) + " is not of type '" +
2848 ETy->getDescription() +"' as required!\nIt is of type '"+
2849 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2852 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2853 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2858 #line 1175 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2860 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2862 ThrowException("Cannot make array constant with type: '" +
2863 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2865 int NumElements = ATy->getNumElements();
2866 if (NumElements != -1 && NumElements != 0)
2867 ThrowException("Type mismatch: constant sized array initialized with 0"
2868 " arguments, but has size of " + itostr(NumElements) +"!");
2869 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2870 delete yyvsp[-2].TypeVal;
2875 #line 1188 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2877 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2879 ThrowException("Cannot make array constant with type: '" +
2880 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2882 int NumElements = ATy->getNumElements();
2883 const Type *ETy = ATy->getElementType();
2884 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2885 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2886 ThrowException("Can't build string constant of size " +
2887 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2888 " when array has size " + itostr(NumElements) + "!");
2889 std::vector<Constant*> Vals;
2890 if (ETy == Type::SByteTy) {
2891 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2892 Vals.push_back(ConstantSInt::get(ETy, *C));
2893 } else if (ETy == Type::UByteTy) {
2894 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2895 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2897 free(yyvsp[0].StrVal);
2898 ThrowException("Cannot build string arrays of non byte sized elements!");
2900 free(yyvsp[0].StrVal);
2901 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2902 delete yyvsp[-2].TypeVal;
2907 #line 1216 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2908 { // Nonempty unsized arr
2909 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2911 ThrowException("Cannot make packed constant with type: '" +
2912 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2913 const Type *ETy = PTy->getElementType();
2914 int NumElements = PTy->getNumElements();
2916 // Verify that we have the correct size...
2917 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2918 ThrowException("Type mismatch: constant sized packed initialized with " +
2919 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2920 itostr(NumElements) + "!");
2922 // Verify all elements are correct type!
2923 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2924 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2925 ThrowException("Element #" + utostr(i) + " is not of type '" +
2926 ETy->getDescription() +"' as required!\nIt is of type '"+
2927 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2930 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2931 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2936 #line 1241 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2938 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2940 ThrowException("Cannot make struct constant with type: '" +
2941 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2943 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2944 ThrowException("Illegal number of initializers for structure type!");
2946 // Check to ensure that constants are compatible with the type initializer!
2947 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2948 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2949 ThrowException("Expected type '" +
2950 STy->getElementType(i)->getDescription() +
2951 "' for element #" + utostr(i) +
2952 " of structure initializer!");
2954 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2955 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2960 #line 1261 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2962 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2964 ThrowException("Cannot make struct constant with type: '" +
2965 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2967 if (STy->getNumContainedTypes() != 0)
2968 ThrowException("Illegal number of initializers for structure type!");
2970 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2971 delete yyvsp[-2].TypeVal;
2976 #line 1273 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2978 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2980 ThrowException("Cannot make null pointer constant with type: '" +
2981 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2983 yyval.ConstVal = ConstantPointerNull::get(PTy);
2984 delete yyvsp[-1].TypeVal;
2989 #line 1282 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2991 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2992 delete yyvsp[-1].TypeVal;
2997 #line 1286 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
2999 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3001 ThrowException("Global const reference must be a pointer type!");
3003 // ConstExprs can exist in the body of a function, thus creating
3004 // GlobalValues whenever they refer to a variable. Because we are in
3005 // the context of a function, getValNonImprovising will search the functions
3006 // symbol table instead of the module symbol table for the global symbol,
3007 // which throws things all off. To get around this, we just tell
3008 // getValNonImprovising that we are at global scope here.
3010 Function *SavedCurFn = CurFun.CurrentFunction;
3011 CurFun.CurrentFunction = 0;
3013 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
3015 CurFun.CurrentFunction = SavedCurFn;
3017 // If this is an initializer for a constant pointer, which is referencing a
3018 // (currently) undefined variable, create a stub now that shall be replaced
3019 // in the future with the right type of variable.
3022 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3023 const PointerType *PT = cast<PointerType>(Ty);
3025 // First check to see if the forward references value is already created!
3026 PerModuleInfo::GlobalRefsType::iterator I =
3027 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
3029 if (I != CurModule.GlobalRefs.end()) {
3030 V = I->second; // Placeholder already exists, use it...
3031 yyvsp[0].ValIDVal.destroy();
3034 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
3036 // Create the forward referenced global.
3038 if (const FunctionType *FTy =
3039 dyn_cast<FunctionType>(PT->getElementType())) {
3040 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3041 CurModule.CurrentModule);
3043 GV = new GlobalVariable(PT->getElementType(), false,
3044 GlobalValue::ExternalLinkage, 0,
3045 Name, CurModule.CurrentModule);
3048 // Keep track of the fact that we have a forward ref to recycle it
3049 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
3054 yyval.ConstVal = cast<GlobalValue>(V);
3055 delete yyvsp[-1].TypeVal; // Free the type handle
3060 #line 1345 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3062 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
3063 ThrowException("Mismatched types for constant expression!");
3064 yyval.ConstVal = yyvsp[0].ConstVal;
3065 delete yyvsp[-1].TypeVal;
3070 #line 1351 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3072 const Type *Ty = yyvsp[-1].TypeVal->get();
3073 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3074 ThrowException("Cannot create a null initialized value of this type!");
3075 yyval.ConstVal = Constant::getNullValue(Ty);
3076 delete yyvsp[-1].TypeVal;
3081 #line 1359 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3082 { // integral constants
3083 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
3084 ThrowException("Constant value doesn't fit in type!");
3085 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
3090 #line 1364 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3091 { // integral constants
3092 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
3093 ThrowException("Constant value doesn't fit in type!");
3094 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
3099 #line 1369 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3100 { // Boolean constants
3101 yyval.ConstVal = ConstantBool::True;
3106 #line 1372 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3107 { // Boolean constants
3108 yyval.ConstVal = ConstantBool::False;
3113 #line 1375 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3114 { // Float & Double constants
3115 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
3116 ThrowException("Floating point constant invalid for type!!");
3117 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
3122 #line 1382 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3124 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
3125 ThrowException("cast constant expression from a non-primitive type: '" +
3126 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
3127 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
3128 ThrowException("cast constant expression to a non-primitive type: '" +
3129 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
3130 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3131 delete yyvsp[-1].TypeVal;
3136 #line 1392 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3138 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
3139 ThrowException("GetElementPtr requires a pointer operand!");
3141 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3142 // indices to uint struct indices for compatibility.
3143 generic_gep_type_iterator<std::vector<Value*>::iterator>
3144 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
3145 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
3146 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3147 if (isa<StructType>(*GTI)) // Only change struct indices
3148 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
3149 if (CUI->getType() == Type::UByteTy)
3150 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3153 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
3155 ThrowException("Index list invalid for constant getelementptr!");
3157 std::vector<Constant*> IdxVec;
3158 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3159 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
3160 IdxVec.push_back(C);
3162 ThrowException("Indices to constant getelementptr must be constants!");
3164 delete yyvsp[-1].ValueList;
3166 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
3171 #line 1423 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3173 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
3174 ThrowException("Select condition must be of boolean type!");
3175 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3176 ThrowException("Select operand types must match!");
3177 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3182 #line 1430 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3184 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3185 ThrowException("Binary operator types must match!");
3186 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3187 // To retain backward compatibility with these early compilers, we emit a
3188 // cast to the appropriate integer type automatically if we are in the
3189 // broken case. See PR424 for more information.
3190 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
3191 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3193 const Type *IntPtrTy = 0;
3194 switch (CurModule.CurrentModule->getPointerSize()) {
3195 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3196 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
3197 default: ThrowException("invalid pointer binary constant expr!");
3199 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
3200 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
3201 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
3207 #line 1451 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3209 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3210 ThrowException("Logical operator types must match!");
3211 if (!yyvsp[-3].ConstVal->getType()->isIntegral())
3212 ThrowException("Logical operands must have integral types!");
3213 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3218 #line 1458 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3220 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3221 ThrowException("setcc operand types must match!");
3222 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3227 #line 1463 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3229 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
3230 ThrowException("Shift count for shift constant must be unsigned byte!");
3231 if (!yyvsp[-3].ConstVal->getType()->isInteger())
3232 ThrowException("Shift constant expression requires integer operand!");
3233 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3238 #line 1473 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3240 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
3245 #line 1476 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3247 yyval.ConstVector = new std::vector<Constant*>();
3248 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
3253 #line 1483 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3254 { yyval.BoolVal = false; ;}
3258 #line 1483 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3259 { yyval.BoolVal = true; ;}
3263 #line 1493 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3265 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
3266 CurModule.ModuleDone();
3271 #line 1500 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3273 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3274 CurFun.FunctionDone();
3279 #line 1504 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3281 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3286 #line 1507 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3288 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3293 #line 1510 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3295 yyval.ModuleVal = CurModule.CurrentModule;
3296 // Emit an error if there are any unresolved types left.
3297 if (!CurModule.LateResolveTypes.empty()) {
3298 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
3299 if (DID.Type == ValID::NameVal)
3300 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
3302 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
3308 #line 1523 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3310 // Eagerly resolve types. This is not an optimization, this is a
3311 // requirement that is due to the fact that we could have this:
3313 // %list = type { %list * }
3314 // %list = type { %list * } ; repeated type decl
3316 // If types are not resolved eagerly, then the two types will not be
3317 // determined to be the same type!
3319 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3321 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3322 // If this is a named type that is not a redefinition, add it to the slot
3324 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3327 delete yyvsp[0].TypeVal;
3332 #line 1543 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3333 { // Function prototypes can be in const pool
3338 #line 1545 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3340 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3341 ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3346 #line 1549 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3348 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3349 delete yyvsp[0].TypeVal;
3354 #line 1553 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3360 #line 1555 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3366 #line 1557 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3372 #line 1562 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3373 { yyval.Endianness = Module::BigEndian; ;}
3377 #line 1563 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3378 { yyval.Endianness = Module::LittleEndian; ;}
3382 #line 1565 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3384 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3389 #line 1568 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3391 if (yyvsp[0].UInt64Val == 32)
3392 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3393 else if (yyvsp[0].UInt64Val == 64)
3394 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3396 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3401 #line 1576 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3403 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3404 free(yyvsp[0].StrVal);
3409 #line 1583 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3411 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3412 free(yyvsp[0].StrVal);
3417 #line 1587 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3419 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3420 free(yyvsp[0].StrVal);
3425 #line 1591 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3431 #line 1600 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3432 { yyval.StrVal = 0; ;}
3436 #line 1602 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3438 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3439 ThrowException("void typed arguments are invalid!");
3440 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3445 #line 1608 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3447 yyval.ArgList = yyvsp[-2].ArgList;
3448 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3449 delete yyvsp[0].ArgVal;
3454 #line 1613 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3456 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3457 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3458 delete yyvsp[0].ArgVal;
3463 #line 1619 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3465 yyval.ArgList = yyvsp[0].ArgList;
3470 #line 1622 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3472 yyval.ArgList = yyvsp[-2].ArgList;
3473 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3474 char*>(new PATypeHolder(Type::VoidTy), 0));
3479 #line 1627 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3481 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3482 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3487 #line 1631 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3494 #line 1635 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3496 UnEscapeLexed(yyvsp[-3].StrVal);
3497 std::string FunctionName(yyvsp[-3].StrVal);
3498 free(yyvsp[-3].StrVal); // Free strdup'd memory!
3500 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3501 ThrowException("LLVM functions cannot return aggregate types!");
3503 std::vector<const Type*> ParamTypeList;
3504 if (yyvsp[-1].ArgList) { // If there are arguments...
3505 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3506 I != yyvsp[-1].ArgList->end(); ++I)
3507 ParamTypeList.push_back(I->first->get());
3510 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3511 if (isVarArg) ParamTypeList.pop_back();
3513 const FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, ParamTypeList, isVarArg);
3514 const PointerType *PFT = PointerType::get(FT);
3515 delete yyvsp[-4].TypeVal;
3518 if (!FunctionName.empty()) {
3519 ID = ValID::create((char*)FunctionName.c_str());
3521 ID = ValID::create((int)CurModule.Values[PFT].size());
3525 // See if this function was forward referenced. If so, recycle the object.
3526 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3527 // Move the function to the end of the list, from whereever it was
3528 // previously inserted.
3529 Fn = cast<Function>(FWRef);
3530 CurModule.CurrentModule->getFunctionList().remove(Fn);
3531 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3532 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3533 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3534 // If this is the case, either we need to be a forward decl, or it needs
3536 if (!CurFun.isDeclare && !Fn->isExternal())
3537 ThrowException("Redefinition of function '" + FunctionName + "'!");
3539 // Make sure to strip off any argument names so we can't get conflicts.
3540 if (Fn->isExternal())
3541 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3545 } else { // Not already defined?
3546 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3547 CurModule.CurrentModule);
3548 InsertValue(Fn, CurModule.Values);
3551 CurFun.FunctionStart(Fn);
3552 Fn->setCallingConv(yyvsp[-5].UIntVal);
3554 // Add all of the arguments we parsed to the function...
3555 if (yyvsp[-1].ArgList) { // Is null if empty...
3556 if (isVarArg) { // Nuke the last entry
3557 assert(yyvsp[-1].ArgList->back().first->get() == Type::VoidTy && yyvsp[-1].ArgList->back().second == 0&&
3558 "Not a varargs marker!");
3559 delete yyvsp[-1].ArgList->back().first;
3560 yyvsp[-1].ArgList->pop_back(); // Delete the last entry
3562 Function::arg_iterator ArgIt = Fn->arg_begin();
3563 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3564 I != yyvsp[-1].ArgList->end(); ++I, ++ArgIt) {
3565 delete I->first; // Delete the typeholder...
3567 setValueName(ArgIt, I->second); // Insert arg into symtab...
3571 delete yyvsp[-1].ArgList; // We're now done with the argument list
3577 #line 1717 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3579 yyval.FunctionVal = CurFun.CurrentFunction;
3581 // Make sure that we keep track of the linkage type even if there was a
3582 // previous "declare".
3583 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3588 #line 1727 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3590 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3595 #line 1731 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3596 { CurFun.isDeclare = true; ;}
3600 #line 1731 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3602 yyval.FunctionVal = CurFun.CurrentFunction;
3603 CurFun.FunctionDone();
3608 #line 1740 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3609 { // A reference to a direct constant
3610 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3615 #line 1743 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3617 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3622 #line 1746 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3623 { // Perhaps it's an FP constant?
3624 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3629 #line 1749 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3631 yyval.ValIDVal = ValID::create(ConstantBool::True);
3636 #line 1752 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3638 yyval.ValIDVal = ValID::create(ConstantBool::False);
3643 #line 1755 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3645 yyval.ValIDVal = ValID::createNull();
3650 #line 1758 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3652 yyval.ValIDVal = ValID::createUndef();
3657 #line 1761 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3658 { // Nonempty unsized packed vector
3659 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3660 int NumElements = yyvsp[-1].ConstVector->size();
3662 PackedType* pt = PackedType::get(ETy, NumElements);
3663 PATypeHolder* PTy = new PATypeHolder(
3671 // Verify all elements are correct type!
3672 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3673 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3674 ThrowException("Element #" + utostr(i) + " is not of type '" +
3675 ETy->getDescription() +"' as required!\nIt is of type '" +
3676 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3679 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3680 delete PTy; delete yyvsp[-1].ConstVector;
3685 #line 1785 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3687 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3692 #line 1792 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3693 { // Is it an integer reference...?
3694 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3699 #line 1795 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3700 { // Is it a named reference...?
3701 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3706 #line 1806 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3708 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3713 #line 1810 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3715 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3720 #line 1813 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3721 { // Do not allow functions with 0 basic blocks
3722 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3727 #line 1821 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3729 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3730 InsertValue(yyvsp[0].TermInstVal);
3732 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3733 InsertValue(yyvsp[-2].BasicBlockVal);
3734 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3739 #line 1830 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3741 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3742 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3747 #line 1834 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3749 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3751 // Make sure to move the basic block to the correct location in the
3752 // function, instead of leaving it inserted wherever it was first
3754 Function::BasicBlockListType &BBL =
3755 CurFun.CurrentFunction->getBasicBlockList();
3756 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3761 #line 1844 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3763 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3765 // Make sure to move the basic block to the correct location in the
3766 // function, instead of leaving it inserted wherever it was first
3768 Function::BasicBlockListType &BBL =
3769 CurFun.CurrentFunction->getBasicBlockList();
3770 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3775 #line 1855 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3776 { // Return with a result...
3777 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3782 #line 1858 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3783 { // Return with no result...
3784 yyval.TermInstVal = new ReturnInst();
3789 #line 1861 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3790 { // Unconditional Branch...
3791 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3796 #line 1864 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3798 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3803 #line 1867 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3805 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3806 yyval.TermInstVal = S;
3808 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3809 E = yyvsp[-1].JumpTable->end();
3810 for (; I != E; ++I) {
3811 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3812 S->addCase(CI, I->second);
3814 ThrowException("Switch case is constant, but not a simple integer!");
3816 delete yyvsp[-1].JumpTable;
3821 #line 1881 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3823 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3824 yyval.TermInstVal = S;
3829 #line 1886 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3831 const PointerType *PFTy;
3832 const FunctionType *Ty;
3834 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3835 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3836 // Pull out the types of all of the arguments...
3837 std::vector<const Type*> ParamTypes;
3838 if (yyvsp[-7].ValueList) {
3839 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3841 ParamTypes.push_back((*I)->getType());
3844 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3845 if (isVarArg) ParamTypes.pop_back();
3847 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3848 PFTy = PointerType::get(Ty);
3851 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3853 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3854 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3856 // Create the call node...
3857 if (!yyvsp[-7].ValueList) { // Has no arguments?
3858 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3859 } else { // Has arguments?
3860 // Loop through FunctionType's arguments and ensure they are specified
3863 FunctionType::param_iterator I = Ty->param_begin();
3864 FunctionType::param_iterator E = Ty->param_end();
3865 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3867 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3868 if ((*ArgI)->getType() != *I)
3869 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3870 (*I)->getDescription() + "'!");
3872 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3873 ThrowException("Invalid number of parameters detected!");
3875 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3877 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3879 delete yyvsp[-10].TypeVal;
3880 delete yyvsp[-7].ValueList;
3885 #line 1938 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3887 yyval.TermInstVal = new UnwindInst();
3892 #line 1941 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3894 yyval.TermInstVal = new UnreachableInst();
3899 #line 1947 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3901 yyval.JumpTable = yyvsp[-5].JumpTable;
3902 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3904 ThrowException("May only switch on a constant pool value!");
3906 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3911 #line 1955 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3913 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3914 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3917 ThrowException("May only switch on a constant pool value!");
3919 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3924 #line 1965 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3926 // Is this definition named?? if so, assign the name...
3927 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3928 InsertValue(yyvsp[0].InstVal);
3929 yyval.InstVal = yyvsp[0].InstVal;
3934 #line 1972 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3935 { // Used for PHI nodes
3936 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3937 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3938 delete yyvsp[-5].TypeVal;
3943 #line 1977 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3945 yyval.PHIList = yyvsp[-6].PHIList;
3946 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3947 getBBVal(yyvsp[-1].ValIDVal)));
3952 #line 1984 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3953 { // Used for call statements, and memory insts...
3954 yyval.ValueList = new std::vector<Value*>();
3955 yyval.ValueList->push_back(yyvsp[0].ValueVal);
3960 #line 1988 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3962 yyval.ValueList = yyvsp[-2].ValueList;
3963 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
3968 #line 1994 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3969 { yyval.ValueList = 0; ;}
3973 #line 1996 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3975 yyval.BoolVal = true;
3980 #line 1999 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3982 yyval.BoolVal = false;
3987 #line 2005 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
3989 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3990 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3992 "Arithmetic operator requires integer, FP, or packed operands!");
3993 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3994 ThrowException("Rem not supported on packed types!");
3995 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3996 if (yyval.InstVal == 0)
3997 ThrowException("binary operator returned null!");
3998 delete yyvsp[-3].TypeVal;
4003 #line 2017 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4005 if (!(*yyvsp[-3].TypeVal)->isIntegral())
4006 ThrowException("Logical operator requires integral operands!");
4007 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
4008 if (yyval.InstVal == 0)
4009 ThrowException("binary operator returned null!");
4010 delete yyvsp[-3].TypeVal;
4015 #line 2025 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4017 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
4019 "PackedTypes currently not supported in setcc instructions!");
4021 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
4022 if (yyval.InstVal == 0)
4023 ThrowException("binary operator returned null!");
4024 delete yyvsp[-3].TypeVal;
4029 #line 2035 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4031 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4032 << " Replacing with 'xor'.\n";
4034 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
4036 ThrowException("Expected integral type for not instruction!");
4038 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
4039 if (yyval.InstVal == 0)
4040 ThrowException("Could not create a xor instruction!");
4045 #line 2047 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4047 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
4048 ThrowException("Shift amount must be ubyte!");
4049 if (!yyvsp[-2].ValueVal->getType()->isInteger())
4050 ThrowException("Shift constant expression requires integer operand!");
4051 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4056 #line 2054 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4058 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
4059 ThrowException("cast instruction to a non-primitive type: '" +
4060 yyvsp[0].TypeVal->get()->getDescription() + "'!");
4061 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4062 delete yyvsp[0].TypeVal;
4067 #line 2061 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4069 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
4070 ThrowException("select condition must be boolean!");
4071 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
4072 ThrowException("select value types should match!");
4073 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4078 #line 2068 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4081 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4082 delete yyvsp[0].TypeVal;
4087 #line 2073 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4089 ObsoleteVarArgs = true;
4090 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4091 Function* NF = CurModule.CurrentModule->
4092 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, 0);
4095 //foo = alloca 1 of t
4099 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4100 CurBB->getInstList().push_back(foo);
4101 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4102 CurBB->getInstList().push_back(bar);
4103 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4104 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
4105 delete yyvsp[0].TypeVal;
4110 #line 2092 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4112 ObsoleteVarArgs = true;
4113 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4114 Function* NF = CurModule.CurrentModule->
4115 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, 0);
4117 //b = vanext a, t ->
4118 //foo = alloca 1 of t
4121 //tmp = vaarg foo, t
4123 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4124 CurBB->getInstList().push_back(foo);
4125 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4126 CurBB->getInstList().push_back(bar);
4127 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4128 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
4129 CurBB->getInstList().push_back(tmp);
4130 yyval.InstVal = new LoadInst(foo);
4131 delete yyvsp[0].TypeVal;
4136 #line 2114 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4138 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
4139 if (!Ty->isFirstClassType())
4140 ThrowException("PHI node operands must be of first class type!");
4141 yyval.InstVal = new PHINode(Ty);
4142 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4143 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4144 if (yyvsp[0].PHIList->front().first->getType() != Ty)
4145 ThrowException("All elements of a PHI node must be of the same type!");
4146 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4147 yyvsp[0].PHIList->pop_front();
4149 delete yyvsp[0].PHIList; // Free the list...
4154 #line 2128 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4156 const PointerType *PFTy;
4157 const FunctionType *Ty;
4159 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
4160 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4161 // Pull out the types of all of the arguments...
4162 std::vector<const Type*> ParamTypes;
4163 if (yyvsp[-1].ValueList) {
4164 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
4166 ParamTypes.push_back((*I)->getType());
4169 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4170 if (isVarArg) ParamTypes.pop_back();
4172 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
4173 ThrowException("LLVM functions cannot return aggregate types!");
4175 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
4176 PFTy = PointerType::get(Ty);
4179 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
4181 // Create the call node...
4182 if (!yyvsp[-1].ValueList) { // Has no arguments?
4183 // Make sure no arguments is a good thing!
4184 if (Ty->getNumParams() != 0)
4185 ThrowException("No arguments passed to a function that "
4186 "expects arguments!");
4188 yyval.InstVal = new CallInst(V, std::vector<Value*>());
4189 } else { // Has arguments?
4190 // Loop through FunctionType's arguments and ensure they are specified
4193 FunctionType::param_iterator I = Ty->param_begin();
4194 FunctionType::param_iterator E = Ty->param_end();
4195 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
4197 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4198 if ((*ArgI)->getType() != *I)
4199 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4200 (*I)->getDescription() + "'!");
4202 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
4203 ThrowException("Invalid number of parameters detected!");
4205 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
4207 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
4208 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
4209 delete yyvsp[-4].TypeVal;
4210 delete yyvsp[-1].ValueList;
4215 #line 2185 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4217 yyval.InstVal = yyvsp[0].InstVal;
4222 #line 2191 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4224 yyval.ValueList = yyvsp[0].ValueList;
4229 #line 2193 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4231 yyval.ValueList = new std::vector<Value*>();
4236 #line 2197 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4238 yyval.BoolVal = true;
4243 #line 2200 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4245 yyval.BoolVal = false;
4250 #line 2206 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4252 yyval.InstVal = new MallocInst(*yyvsp[0].TypeVal);
4253 delete yyvsp[0].TypeVal;
4258 #line 2210 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4260 yyval.InstVal = new MallocInst(*yyvsp[-3].TypeVal, getVal(yyvsp[-1].PrimType, yyvsp[0].ValIDVal));
4261 delete yyvsp[-3].TypeVal;
4266 #line 2214 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4268 yyval.InstVal = new AllocaInst(*yyvsp[0].TypeVal);
4269 delete yyvsp[0].TypeVal;
4274 #line 2218 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4276 yyval.InstVal = new AllocaInst(*yyvsp[-3].TypeVal, getVal(yyvsp[-1].PrimType, yyvsp[0].ValIDVal));
4277 delete yyvsp[-3].TypeVal;
4282 #line 2222 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4284 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
4285 ThrowException("Trying to free nonpointer type " +
4286 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4287 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
4292 #line 2229 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4294 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4295 ThrowException("Can't load from nonpointer type: " +
4296 (*yyvsp[-1].TypeVal)->getDescription());
4297 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4298 ThrowException("Can't load from pointer of non-first-class type: " +
4299 (*yyvsp[-1].TypeVal)->getDescription());
4300 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
4301 delete yyvsp[-1].TypeVal;
4306 #line 2239 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4308 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4310 ThrowException("Can't store to a nonpointer type: " +
4311 (*yyvsp[-1].TypeVal)->getDescription());
4312 const Type *ElTy = PT->getElementType();
4313 if (ElTy != yyvsp[-3].ValueVal->getType())
4314 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4315 "' into space of type '" + ElTy->getDescription() + "'!");
4317 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
4318 delete yyvsp[-1].TypeVal;
4323 #line 2252 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4325 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4326 ThrowException("getelementptr insn requires pointer operand!");
4328 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4329 // indices to uint struct indices for compatibility.
4330 generic_gep_type_iterator<std::vector<Value*>::iterator>
4331 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4332 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4333 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4334 if (isa<StructType>(*GTI)) // Only change struct indices
4335 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4336 if (CUI->getType() == Type::UByteTy)
4337 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4339 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4340 ThrowException("Invalid getelementptr indices for type '" +
4341 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4342 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4343 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
4350 /* Line 1000 of yacc.c. */
4351 #line 4352 "llvmAsmParser.tab.c"
4357 YY_STACK_PRINT (yyss, yyssp);
4362 /* Now `shift' the result of the reduction. Determine what state
4363 that goes to, based on the state we popped back to and the rule
4364 number reduced by. */
4368 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
4369 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4370 yystate = yytable[yystate];
4372 yystate = yydefgoto[yyn - YYNTOKENS];
4377 /*------------------------------------.
4378 | yyerrlab -- here on detecting error |
4379 `------------------------------------*/
4381 /* If not already recovering from an error, report this error. */
4386 yyn = yypact[yystate];
4388 if (YYPACT_NINF < yyn && yyn < YYLAST)
4390 YYSIZE_T yysize = 0;
4391 int yytype = YYTRANSLATE (yychar);
4392 const char* yyprefix;
4396 /* Start YYX at -YYN if negative to avoid negative indexes in
4398 int yyxbegin = yyn < 0 ? -yyn : 0;
4400 /* Stay within bounds of both yycheck and yytname. */
4401 int yychecklim = YYLAST - yyn;
4402 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
4405 yyprefix = ", expecting ";
4406 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
4407 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
4409 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
4417 yysize += (sizeof ("syntax error, unexpected ")
4418 + yystrlen (yytname[yytype]));
4419 yymsg = (char *) YYSTACK_ALLOC (yysize);
4422 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
4423 yyp = yystpcpy (yyp, yytname[yytype]);
4427 yyprefix = ", expecting ";
4428 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
4429 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
4431 yyp = yystpcpy (yyp, yyprefix);
4432 yyp = yystpcpy (yyp, yytname[yyx]);
4437 YYSTACK_FREE (yymsg);
4440 yyerror ("syntax error; also virtual memory exhausted");
4443 #endif /* YYERROR_VERBOSE */
4444 yyerror ("syntax error");
4449 if (yyerrstatus == 3)
4451 /* If just tried and failed to reuse lookahead token after an
4452 error, discard it. */
4454 if (yychar <= YYEOF)
4456 /* If at end of input, pop the error token,
4457 then the rest of the stack, then return failure. */
4458 if (yychar == YYEOF)
4464 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
4465 yydestruct (yystos[*yyssp], yyvsp);
4470 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
4471 yydestruct (yytoken, &yylval);
4477 /* Else will try to reuse lookahead token after shifting the error
4482 /*---------------------------------------------------.
4483 | yyerrorlab -- error raised explicitly by YYERROR. |
4484 `---------------------------------------------------*/
4488 /* Pacify GCC when the user code never invokes YYERROR and the label
4489 yyerrorlab therefore never appears in user code. */
4500 /*-------------------------------------------------------------.
4501 | yyerrlab1 -- common code for both syntax error and YYERROR. |
4502 `-------------------------------------------------------------*/
4504 yyerrstatus = 3; /* Each real token shifted decrements this. */
4508 yyn = yypact[yystate];
4509 if (yyn != YYPACT_NINF)
4512 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
4520 /* Pop the current state because it cannot handle the error token. */
4524 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
4525 yydestruct (yystos[yystate], yyvsp);
4528 YY_STACK_PRINT (yyss, yyssp);
4534 YYDPRINTF ((stderr, "Shifting error token, "));
4543 /*-------------------------------------.
4544 | yyacceptlab -- YYACCEPT comes here. |
4545 `-------------------------------------*/
4550 /*-----------------------------------.
4551 | yyabortlab -- YYABORT comes here. |
4552 `-----------------------------------*/
4558 /*----------------------------------------------.
4559 | yyoverflowlab -- parser overflow comes here. |
4560 `----------------------------------------------*/
4562 yyerror ("parser stack overflow");
4570 YYSTACK_FREE (yyss);
4576 #line 2275 "/proj/llvm/build/../llvm/lib/AsmParser/llvmAsmParser.y"
4578 int yyerror(const char *ErrorMsg) {
4580 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4581 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4582 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4583 if (yychar == YYEMPTY || yychar == 0)
4584 errMsg += "end-of-file.";
4586 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4587 ThrowException(errMsg);