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,
156 EXTRACTELEMENT = 349,
161 #define ESINT64VAL 258
162 #define EUINT64VAL 259
182 #define STRINGCONSTANT 279
183 #define IMPLEMENTATION 280
184 #define ZEROINITIALIZER 281
195 #define DOTDOTDOT 292
202 #define APPENDING 299
209 #define POINTERSIZE 306
218 #define FASTCC_TOK 315
219 #define COLDCC_TOK 316
225 #define UNREACHABLE 322
245 #define GETELEMENTPTR 342
252 #define EXTRACTELEMENT 349
253 #define VAARG_old 350
254 #define VANEXT_old 351
259 /* Copy the first part of user declarations. */
260 #line 14 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
262 #include "ParserInternals.h"
263 #include "llvm/CallingConv.h"
264 #include "llvm/Instructions.h"
265 #include "llvm/Module.h"
266 #include "llvm/SymbolTable.h"
267 #include "llvm/Assembly/AutoUpgrade.h"
268 #include "llvm/Support/GetElementPtrTypeIterator.h"
269 #include "llvm/ADT/STLExtras.h"
270 #include "llvm/Support/MathExtras.h"
276 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
277 int yylex(); // declaration" of xxx warnings.
281 std::string CurFilename;
283 using namespace llvm;
285 static Module *ParserResult;
287 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
288 // relating to upreferences in the input stream.
290 //#define DEBUG_UPREFS 1
292 #define UR_OUT(X) std::cerr << X
297 #define YYERROR_VERBOSE 1
299 static bool ObsoleteVarArgs;
300 static bool NewVarArgs;
301 static BasicBlock *CurBB;
302 static GlobalVariable *CurGV;
305 // This contains info used when building the body of a function. It is
306 // destroyed when the function is completed.
308 typedef std::vector<Value *> ValueList; // Numbered defs
310 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
311 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
313 static struct PerModuleInfo {
314 Module *CurrentModule;
315 std::map<const Type *, ValueList> Values; // Module level numbered definitions
316 std::map<const Type *,ValueList> LateResolveValues;
317 std::vector<PATypeHolder> Types;
318 std::map<ValID, PATypeHolder> LateResolveTypes;
320 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
321 /// how they were referenced and one which line of the input they came from so
322 /// that we can resolve them later and print error messages as appropriate.
323 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
325 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
326 // references to global values. Global values may be referenced before they
327 // are defined, and if so, the temporary object that they represent is held
328 // here. This is used for forward references of GlobalValues.
330 typedef std::map<std::pair<const PointerType *,
331 ValID>, GlobalValue*> GlobalRefsType;
332 GlobalRefsType GlobalRefs;
335 // If we could not resolve some functions at function compilation time
336 // (calls to functions before they are defined), resolve them now... Types
337 // are resolved when the constant pool has been completely parsed.
339 ResolveDefinitions(LateResolveValues);
341 // Check to make sure that all global value forward references have been
344 if (!GlobalRefs.empty()) {
345 std::string UndefinedReferences = "Unresolved global references exist:\n";
347 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
349 UndefinedReferences += " " + I->first.first->getDescription() + " " +
350 I->first.second.getName() + "\n";
352 ThrowException(UndefinedReferences);
355 // Rename any overloaded intrinsic functions.
356 for (Module::iterator FI = CurrentModule->begin(), FE =
357 CurrentModule->end(); FI != FE; ++FI)
358 UpgradeIntrinsicFunction(&(*FI));
360 Values.clear(); // Clear out function local definitions
365 // GetForwardRefForGlobal - Check to see if there is a forward reference
366 // for this global. If so, remove it from the GlobalRefs map and return it.
367 // If not, just return null.
368 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
369 // Check to see if there is a forward reference to this global variable...
370 // if there is, eliminate it and patch the reference to use the new def'n.
371 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
372 GlobalValue *Ret = 0;
373 if (I != GlobalRefs.end()) {
381 static struct PerFunctionInfo {
382 Function *CurrentFunction; // Pointer to current function being created
384 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
385 std::map<const Type*, ValueList> LateResolveValues;
386 bool isDeclare; // Is this function a forward declararation?
388 /// BBForwardRefs - When we see forward references to basic blocks, keep
389 /// track of them here.
390 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
391 std::vector<BasicBlock*> NumberedBlocks;
394 inline PerFunctionInfo() {
399 inline void FunctionStart(Function *M) {
404 void FunctionDone() {
405 NumberedBlocks.clear();
407 // Any forward referenced blocks left?
408 if (!BBForwardRefs.empty())
409 ThrowException("Undefined reference to label " +
410 BBForwardRefs.begin()->first->getName());
412 // Resolve all forward references now.
413 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
415 Values.clear(); // Clear out function local definitions
419 } CurFun; // Info for the current function...
421 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
424 //===----------------------------------------------------------------------===//
425 // Code to handle definitions of all the types
426 //===----------------------------------------------------------------------===//
428 static int InsertValue(Value *V,
429 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
430 if (V->hasName()) return -1; // Is this a numbered definition?
432 // Yes, insert the value into the value table...
433 ValueList &List = ValueTab[V->getType()];
435 return List.size()-1;
438 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
440 case ValID::NumberVal: // Is it a numbered definition?
441 // Module constants occupy the lowest numbered slots...
442 if ((unsigned)D.Num < CurModule.Types.size())
443 return CurModule.Types[(unsigned)D.Num];
445 case ValID::NameVal: // Is it a named definition?
446 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
447 D.destroy(); // Free old strdup'd memory...
452 ThrowException("Internal parser error: Invalid symbol type reference!");
455 // If we reached here, we referenced either a symbol that we don't know about
456 // or an id number that hasn't been read yet. We may be referencing something
457 // forward, so just create an entry to be resolved later and get to it...
459 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
462 if (inFunctionScope()) {
463 if (D.Type == ValID::NameVal)
464 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
466 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
469 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
470 if (I != CurModule.LateResolveTypes.end())
473 Type *Typ = OpaqueType::get();
474 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
478 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
479 SymbolTable &SymTab =
480 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
481 CurModule.CurrentModule->getSymbolTable();
482 return SymTab.lookup(Ty, Name);
485 // getValNonImprovising - Look up the value specified by the provided type and
486 // the provided ValID. If the value exists and has already been defined, return
487 // it. Otherwise return null.
489 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
490 if (isa<FunctionType>(Ty))
491 ThrowException("Functions are not values and "
492 "must be referenced as pointers");
495 case ValID::NumberVal: { // Is it a numbered definition?
496 unsigned Num = (unsigned)D.Num;
498 // Module constants occupy the lowest numbered slots...
499 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
500 if (VI != CurModule.Values.end()) {
501 if (Num < VI->second.size())
502 return VI->second[Num];
503 Num -= VI->second.size();
506 // Make sure that our type is within bounds
507 VI = CurFun.Values.find(Ty);
508 if (VI == CurFun.Values.end()) return 0;
510 // Check that the number is within bounds...
511 if (VI->second.size() <= Num) return 0;
513 return VI->second[Num];
516 case ValID::NameVal: { // Is it a named definition?
517 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
518 if (N == 0) return 0;
520 D.destroy(); // Free old strdup'd memory...
524 // Check to make sure that "Ty" is an integral type, and that our
525 // value will fit into the specified type...
526 case ValID::ConstSIntVal: // Is it a constant pool reference??
527 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
528 ThrowException("Signed integral constant '" +
529 itostr(D.ConstPool64) + "' is invalid for type '" +
530 Ty->getDescription() + "'!");
531 return ConstantSInt::get(Ty, D.ConstPool64);
533 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
534 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
535 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
536 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
537 "' is invalid or out of range!");
538 } else { // This is really a signed reference. Transmogrify.
539 return ConstantSInt::get(Ty, D.ConstPool64);
542 return ConstantUInt::get(Ty, D.UConstPool64);
545 case ValID::ConstFPVal: // Is it a floating point const pool reference?
546 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
547 ThrowException("FP constant invalid for type!!");
548 return ConstantFP::get(Ty, D.ConstPoolFP);
550 case ValID::ConstNullVal: // Is it a null value?
551 if (!isa<PointerType>(Ty))
552 ThrowException("Cannot create a a non pointer null!");
553 return ConstantPointerNull::get(cast<PointerType>(Ty));
555 case ValID::ConstUndefVal: // Is it an undef value?
556 return UndefValue::get(Ty);
558 case ValID::ConstZeroVal: // Is it a zero value?
559 return Constant::getNullValue(Ty);
561 case ValID::ConstantVal: // Fully resolved constant?
562 if (D.ConstantValue->getType() != Ty)
563 ThrowException("Constant expression type different from required type!");
564 return D.ConstantValue;
567 assert(0 && "Unhandled case!");
571 assert(0 && "Unhandled case!");
575 // getVal - This function is identical to getValNonImprovising, except that if a
576 // value is not already defined, it "improvises" by creating a placeholder var
577 // that looks and acts just like the requested variable. When the value is
578 // defined later, all uses of the placeholder variable are replaced with the
581 static Value *getVal(const Type *Ty, const ValID &ID) {
582 if (Ty == Type::LabelTy)
583 ThrowException("Cannot use a basic block here");
585 // See if the value has already been defined.
586 Value *V = getValNonImprovising(Ty, ID);
589 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
590 ThrowException("Invalid use of a composite type!");
592 // If we reached here, we referenced either a symbol that we don't know about
593 // or an id number that hasn't been read yet. We may be referencing something
594 // forward, so just create an entry to be resolved later and get to it...
596 V = new Argument(Ty);
598 // Remember where this forward reference came from. FIXME, shouldn't we try
599 // to recycle these things??
600 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
603 if (inFunctionScope())
604 InsertValue(V, CurFun.LateResolveValues);
606 InsertValue(V, CurModule.LateResolveValues);
610 /// getBBVal - This is used for two purposes:
611 /// * If isDefinition is true, a new basic block with the specified ID is being
613 /// * If isDefinition is true, this is a reference to a basic block, which may
614 /// or may not be a forward reference.
616 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
617 assert(inFunctionScope() && "Can't get basic block at global scope!");
622 default: ThrowException("Illegal label reference " + ID.getName());
623 case ValID::NumberVal: // Is it a numbered definition?
624 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
625 CurFun.NumberedBlocks.resize(ID.Num+1);
626 BB = CurFun.NumberedBlocks[ID.Num];
628 case ValID::NameVal: // Is it a named definition?
630 if (Value *N = CurFun.CurrentFunction->
631 getSymbolTable().lookup(Type::LabelTy, Name))
632 BB = cast<BasicBlock>(N);
636 // See if the block has already been defined.
638 // If this is the definition of the block, make sure the existing value was
639 // just a forward reference. If it was a forward reference, there will be
640 // an entry for it in the PlaceHolderInfo map.
641 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
642 // The existing value was a definition, not a forward reference.
643 ThrowException("Redefinition of label " + ID.getName());
645 ID.destroy(); // Free strdup'd memory.
649 // Otherwise this block has not been seen before.
650 BB = new BasicBlock("", CurFun.CurrentFunction);
651 if (ID.Type == ValID::NameVal) {
652 BB->setName(ID.Name);
654 CurFun.NumberedBlocks[ID.Num] = BB;
657 // If this is not a definition, keep track of it so we can use it as a forward
660 // Remember where this forward reference came from.
661 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
663 // The forward declaration could have been inserted anywhere in the
664 // function: insert it into the correct place now.
665 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
666 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
673 //===----------------------------------------------------------------------===//
674 // Code to handle forward references in instructions
675 //===----------------------------------------------------------------------===//
677 // This code handles the late binding needed with statements that reference
678 // values not defined yet... for example, a forward branch, or the PHI node for
681 // This keeps a table (CurFun.LateResolveValues) of all such forward references
682 // and back patchs after we are done.
685 // ResolveDefinitions - If we could not resolve some defs at parsing
686 // time (forward branches, phi functions for loops, etc...) resolve the
690 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
691 std::map<const Type*,ValueList> *FutureLateResolvers) {
692 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
693 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
694 E = LateResolvers.end(); LRI != E; ++LRI) {
695 ValueList &List = LRI->second;
696 while (!List.empty()) {
697 Value *V = List.back();
700 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
701 CurModule.PlaceHolderInfo.find(V);
702 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
704 ValID &DID = PHI->second.first;
706 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
708 V->replaceAllUsesWith(TheRealValue);
710 CurModule.PlaceHolderInfo.erase(PHI);
711 } else if (FutureLateResolvers) {
712 // Functions have their unresolved items forwarded to the module late
714 InsertValue(V, *FutureLateResolvers);
716 if (DID.Type == ValID::NameVal)
717 ThrowException("Reference to an invalid definition: '" +DID.getName()+
718 "' of type '" + V->getType()->getDescription() + "'",
721 ThrowException("Reference to an invalid definition: #" +
722 itostr(DID.Num) + " of type '" +
723 V->getType()->getDescription() + "'",
729 LateResolvers.clear();
732 // ResolveTypeTo - A brand new type was just declared. This means that (if
733 // name is not null) things referencing Name can be resolved. Otherwise, things
734 // refering to the number can be resolved. Do this now.
736 static void ResolveTypeTo(char *Name, const Type *ToTy) {
738 if (Name) D = ValID::create(Name);
739 else D = ValID::create((int)CurModule.Types.size());
741 std::map<ValID, PATypeHolder>::iterator I =
742 CurModule.LateResolveTypes.find(D);
743 if (I != CurModule.LateResolveTypes.end()) {
744 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
745 CurModule.LateResolveTypes.erase(I);
749 // setValueName - Set the specified value to the name given. The name may be
750 // null potentially, in which case this is a noop. The string passed in is
751 // assumed to be a malloc'd string buffer, and is free'd by this function.
753 static void setValueName(Value *V, char *NameStr) {
755 std::string Name(NameStr); // Copy string
756 free(NameStr); // Free old string
758 if (V->getType() == Type::VoidTy)
759 ThrowException("Can't assign name '" + Name+"' to value with void type!");
761 assert(inFunctionScope() && "Must be in function scope!");
762 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
763 if (ST.lookup(V->getType(), Name))
764 ThrowException("Redefinition of value named '" + Name + "' in the '" +
765 V->getType()->getDescription() + "' type plane!");
772 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
773 /// this is a declaration, otherwise it is a definition.
774 static GlobalVariable *
775 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
776 bool isConstantGlobal, const Type *Ty,
777 Constant *Initializer) {
778 if (isa<FunctionType>(Ty))
779 ThrowException("Cannot declare global vars of function type!");
781 const PointerType *PTy = PointerType::get(Ty);
785 Name = NameStr; // Copy string
786 free(NameStr); // Free old string
789 // See if this global value was forward referenced. If so, recycle the
793 ID = ValID::create((char*)Name.c_str());
795 ID = ValID::create((int)CurModule.Values[PTy].size());
798 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
799 // Move the global to the end of the list, from whereever it was
800 // previously inserted.
801 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
802 CurModule.CurrentModule->getGlobalList().remove(GV);
803 CurModule.CurrentModule->getGlobalList().push_back(GV);
804 GV->setInitializer(Initializer);
805 GV->setLinkage(Linkage);
806 GV->setConstant(isConstantGlobal);
807 InsertValue(GV, CurModule.Values);
811 // If this global has a name, check to see if there is already a definition
812 // of this global in the module. If so, merge as appropriate. Note that
813 // this is really just a hack around problems in the CFE. :(
815 // We are a simple redefinition of a value, check to see if it is defined
816 // the same as the old one.
817 if (GlobalVariable *EGV =
818 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
819 // We are allowed to redefine a global variable in two circumstances:
820 // 1. If at least one of the globals is uninitialized or
821 // 2. If both initializers have the same value.
823 if (!EGV->hasInitializer() || !Initializer ||
824 EGV->getInitializer() == Initializer) {
826 // Make sure the existing global version gets the initializer! Make
827 // sure that it also gets marked const if the new version is.
828 if (Initializer && !EGV->hasInitializer())
829 EGV->setInitializer(Initializer);
830 if (isConstantGlobal)
831 EGV->setConstant(true);
832 EGV->setLinkage(Linkage);
836 ThrowException("Redefinition of global variable named '" + Name +
837 "' in the '" + Ty->getDescription() + "' type plane!");
841 // Otherwise there is no existing GV to use, create one now.
843 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
844 CurModule.CurrentModule);
845 InsertValue(GV, CurModule.Values);
849 // setTypeName - Set the specified type to the name given. The name may be
850 // null potentially, in which case this is a noop. The string passed in is
851 // assumed to be a malloc'd string buffer, and is freed by this function.
853 // This function returns true if the type has already been defined, but is
854 // allowed to be redefined in the specified context. If the name is a new name
855 // for the type plane, it is inserted and false is returned.
856 static bool setTypeName(const Type *T, char *NameStr) {
857 assert(!inFunctionScope() && "Can't give types function-local names!");
858 if (NameStr == 0) return false;
860 std::string Name(NameStr); // Copy string
861 free(NameStr); // Free old string
863 // We don't allow assigning names to void type
864 if (T == Type::VoidTy)
865 ThrowException("Can't assign name '" + Name + "' to the void type!");
867 // Set the type name, checking for conflicts as we do so.
868 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
870 if (AlreadyExists) { // Inserting a name that is already defined???
871 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
872 assert(Existing && "Conflict but no matching type?");
874 // There is only one case where this is allowed: when we are refining an
875 // opaque type. In this case, Existing will be an opaque type.
876 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
877 // We ARE replacing an opaque type!
878 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
882 // Otherwise, this is an attempt to redefine a type. That's okay if
883 // the redefinition is identical to the original. This will be so if
884 // Existing and T point to the same Type object. In this one case we
885 // allow the equivalent redefinition.
886 if (Existing == T) return true; // Yes, it's equal.
888 // Any other kind of (non-equivalent) redefinition is an error.
889 ThrowException("Redefinition of type named '" + Name + "' in the '" +
890 T->getDescription() + "' type plane!");
896 //===----------------------------------------------------------------------===//
897 // Code for handling upreferences in type names...
900 // TypeContains - Returns true if Ty directly contains E in it.
902 static bool TypeContains(const Type *Ty, const Type *E) {
903 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
904 E) != Ty->subtype_end();
909 // NestingLevel - The number of nesting levels that need to be popped before
910 // this type is resolved.
911 unsigned NestingLevel;
913 // LastContainedTy - This is the type at the current binding level for the
914 // type. Every time we reduce the nesting level, this gets updated.
915 const Type *LastContainedTy;
917 // UpRefTy - This is the actual opaque type that the upreference is
921 UpRefRecord(unsigned NL, OpaqueType *URTy)
922 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
926 // UpRefs - A list of the outstanding upreferences that need to be resolved.
927 static std::vector<UpRefRecord> UpRefs;
929 /// HandleUpRefs - Every time we finish a new layer of types, this function is
930 /// called. It loops through the UpRefs vector, which is a list of the
931 /// currently active types. For each type, if the up reference is contained in
932 /// the newly completed type, we decrement the level count. When the level
933 /// count reaches zero, the upreferenced type is the type that is passed in:
934 /// thus we can complete the cycle.
936 static PATypeHolder HandleUpRefs(const Type *ty) {
937 if (!ty->isAbstract()) return ty;
939 UR_OUT("Type '" << Ty->getDescription() <<
940 "' newly formed. Resolving upreferences.\n" <<
941 UpRefs.size() << " upreferences active!\n");
943 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
944 // to zero), we resolve them all together before we resolve them to Ty. At
945 // the end of the loop, if there is anything to resolve to Ty, it will be in
947 OpaqueType *TypeToResolve = 0;
949 for (unsigned i = 0; i != UpRefs.size(); ++i) {
950 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
951 << UpRefs[i].second->getDescription() << ") = "
952 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
953 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
954 // Decrement level of upreference
955 unsigned Level = --UpRefs[i].NestingLevel;
956 UpRefs[i].LastContainedTy = Ty;
957 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
958 if (Level == 0) { // Upreference should be resolved!
959 if (!TypeToResolve) {
960 TypeToResolve = UpRefs[i].UpRefTy;
962 UR_OUT(" * Resolving upreference for "
963 << UpRefs[i].second->getDescription() << "\n";
964 std::string OldName = UpRefs[i].UpRefTy->getDescription());
965 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
966 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
967 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
969 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
970 --i; // Do not skip the next element...
976 UR_OUT(" * Resolving upreference for "
977 << UpRefs[i].second->getDescription() << "\n";
978 std::string OldName = TypeToResolve->getDescription());
979 TypeToResolve->refineAbstractTypeTo(Ty);
986 // common code from the two 'RunVMAsmParser' functions
987 static Module * RunParser(Module * M) {
989 llvmAsmlineno = 1; // Reset the current line number...
990 ObsoleteVarArgs = false;
993 CurModule.CurrentModule = M;
994 yyparse(); // Parse the file, potentially throwing exception
996 Module *Result = ParserResult;
999 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1002 if ((F = Result->getNamedFunction("llvm.va_start"))
1003 && F->getFunctionType()->getNumParams() == 0)
1004 ObsoleteVarArgs = true;
1005 if((F = Result->getNamedFunction("llvm.va_copy"))
1006 && F->getFunctionType()->getNumParams() == 1)
1007 ObsoleteVarArgs = true;
1010 if (ObsoleteVarArgs && NewVarArgs)
1011 ThrowException("This file is corrupt: it uses both new and old style varargs");
1013 if(ObsoleteVarArgs) {
1014 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1015 if (F->arg_size() != 0)
1016 ThrowException("Obsolete va_start takes 0 argument!");
1020 //bar = alloca typeof(foo)
1024 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1025 const Type* ArgTy = F->getFunctionType()->getReturnType();
1026 const Type* ArgTyPtr = PointerType::get(ArgTy);
1027 Function* NF = Result->getOrInsertFunction("llvm.va_start",
1028 RetTy, ArgTyPtr, (Type *)0);
1030 while (!F->use_empty()) {
1031 CallInst* CI = cast<CallInst>(F->use_back());
1032 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1033 new CallInst(NF, bar, "", CI);
1034 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1035 CI->replaceAllUsesWith(foo);
1036 CI->getParent()->getInstList().erase(CI);
1038 Result->getFunctionList().erase(F);
1041 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1042 if(F->arg_size() != 1)
1043 ThrowException("Obsolete va_end takes 1 argument!");
1047 //bar = alloca 1 of typeof(foo)
1049 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1050 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1051 const Type* ArgTyPtr = PointerType::get(ArgTy);
1052 Function* NF = Result->getOrInsertFunction("llvm.va_end",
1053 RetTy, ArgTyPtr, (Type *)0);
1055 while (!F->use_empty()) {
1056 CallInst* CI = cast<CallInst>(F->use_back());
1057 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1058 new StoreInst(CI->getOperand(1), bar, CI);
1059 new CallInst(NF, bar, "", CI);
1060 CI->getParent()->getInstList().erase(CI);
1062 Result->getFunctionList().erase(F);
1065 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1066 if(F->arg_size() != 1)
1067 ThrowException("Obsolete va_copy takes 1 argument!");
1070 //a = alloca 1 of typeof(foo)
1071 //b = alloca 1 of typeof(foo)
1076 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1077 const Type* ArgTy = F->getFunctionType()->getReturnType();
1078 const Type* ArgTyPtr = PointerType::get(ArgTy);
1079 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
1080 RetTy, ArgTyPtr, ArgTyPtr,
1083 while (!F->use_empty()) {
1084 CallInst* CI = cast<CallInst>(F->use_back());
1085 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1086 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1087 new StoreInst(CI->getOperand(1), b, CI);
1088 new CallInst(NF, a, b, "", CI);
1089 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1090 CI->replaceAllUsesWith(foo);
1091 CI->getParent()->getInstList().erase(CI);
1093 Result->getFunctionList().erase(F);
1101 //===----------------------------------------------------------------------===//
1102 // RunVMAsmParser - Define an interface to this parser
1103 //===----------------------------------------------------------------------===//
1105 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1108 CurFilename = Filename;
1109 return RunParser(new Module(CurFilename));
1112 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1113 set_scan_string(AsmString);
1115 CurFilename = "from_memory";
1117 return RunParser(new Module (CurFilename));
1119 return RunParser(M);
1125 /* Enabling traces. */
1130 /* Enabling verbose error messages. */
1131 #ifdef YYERROR_VERBOSE
1132 # undef YYERROR_VERBOSE
1133 # define YYERROR_VERBOSE 1
1135 # define YYERROR_VERBOSE 0
1138 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1139 #line 878 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
1140 typedef union YYSTYPE {
1141 llvm::Module *ModuleVal;
1142 llvm::Function *FunctionVal;
1143 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1144 llvm::BasicBlock *BasicBlockVal;
1145 llvm::TerminatorInst *TermInstVal;
1146 llvm::Instruction *InstVal;
1147 llvm::Constant *ConstVal;
1149 const llvm::Type *PrimType;
1150 llvm::PATypeHolder *TypeVal;
1151 llvm::Value *ValueVal;
1153 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1154 std::vector<llvm::Value*> *ValueList;
1155 std::list<llvm::PATypeHolder> *TypeList;
1156 // Represent the RHS of PHI node
1157 std::list<std::pair<llvm::Value*,
1158 llvm::BasicBlock*> > *PHIList;
1159 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1160 std::vector<llvm::Constant*> *ConstVector;
1162 llvm::GlobalValue::LinkageTypes Linkage;
1170 char *StrVal; // This memory is strdup'd!
1171 llvm::ValID ValIDVal; // strdup'd memory maybe!
1173 llvm::Instruction::BinaryOps BinaryOpVal;
1174 llvm::Instruction::TermOps TermOpVal;
1175 llvm::Instruction::MemoryOps MemOpVal;
1176 llvm::Instruction::OtherOps OtherOpVal;
1177 llvm::Module::Endianness Endianness;
1179 /* Line 191 of yacc.c. */
1180 #line 1181 "llvmAsmParser.tab.c"
1181 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1182 # define YYSTYPE_IS_DECLARED 1
1183 # define YYSTYPE_IS_TRIVIAL 1
1188 /* Copy the second part of user declarations. */
1191 /* Line 214 of yacc.c. */
1192 #line 1193 "llvmAsmParser.tab.c"
1194 #if ! defined (yyoverflow) || YYERROR_VERBOSE
1197 # define YYFREE free
1200 # define YYMALLOC malloc
1203 /* The parser invokes alloca or malloc; define the necessary symbols. */
1205 # ifdef YYSTACK_USE_ALLOCA
1206 # if YYSTACK_USE_ALLOCA
1207 # define YYSTACK_ALLOC alloca
1210 # if defined (alloca) || defined (_ALLOCA_H)
1211 # define YYSTACK_ALLOC alloca
1214 # define YYSTACK_ALLOC __builtin_alloca
1219 # ifdef YYSTACK_ALLOC
1220 /* Pacify GCC's `empty if-body' warning. */
1221 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1223 # if defined (__STDC__) || defined (__cplusplus)
1224 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1225 # define YYSIZE_T size_t
1227 # define YYSTACK_ALLOC YYMALLOC
1228 # define YYSTACK_FREE YYFREE
1230 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1233 #if (! defined (yyoverflow) \
1234 && (! defined (__cplusplus) \
1235 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1237 /* A type that is properly aligned for any stack member. */
1244 /* The size of the maximum gap between one aligned stack and the next. */
1245 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1247 /* The size of an array large to enough to hold all stacks, each with
1249 # define YYSTACK_BYTES(N) \
1250 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
1251 + YYSTACK_GAP_MAXIMUM)
1253 /* Copy COUNT objects from FROM to TO. The source and destination do
1256 # if defined (__GNUC__) && 1 < __GNUC__
1257 # define YYCOPY(To, From, Count) \
1258 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1260 # define YYCOPY(To, From, Count) \
1263 register YYSIZE_T yyi; \
1264 for (yyi = 0; yyi < (Count); yyi++) \
1265 (To)[yyi] = (From)[yyi]; \
1271 /* Relocate STACK from its old location to the new one. The
1272 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1273 elements in the stack, and YYPTR gives the new location of the
1274 stack. Advance YYPTR to a properly aligned location for the next
1276 # define YYSTACK_RELOCATE(Stack) \
1279 YYSIZE_T yynewbytes; \
1280 YYCOPY (&yyptr->Stack, Stack, yysize); \
1281 Stack = &yyptr->Stack; \
1282 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1283 yyptr += yynewbytes / sizeof (*yyptr); \
1289 #if defined (__STDC__) || defined (__cplusplus)
1290 typedef signed char yysigned_char;
1292 typedef short yysigned_char;
1295 /* YYFINAL -- State number of the termination state. */
1297 /* YYLAST -- Last index in YYTABLE. */
1300 /* YYNTOKENS -- Number of terminals. */
1301 #define YYNTOKENS 111
1302 /* YYNNTS -- Number of nonterminals. */
1304 /* YYNRULES -- Number of rules. */
1305 #define YYNRULES 228
1306 /* YYNRULES -- Number of states. */
1307 #define YYNSTATES 454
1309 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1310 #define YYUNDEFTOK 2
1311 #define YYMAXUTOK 351
1313 #define YYTRANSLATE(YYX) \
1314 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1316 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1317 static const unsigned char yytranslate[] =
1319 0, 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 100, 101, 109, 2, 98, 2, 2, 2, 2, 2,
1324 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1325 105, 97, 106, 2, 2, 2, 2, 2, 2, 2,
1326 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1327 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1328 2, 102, 99, 104, 2, 2, 2, 2, 2, 110,
1329 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1330 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1331 103, 2, 2, 107, 2, 108, 2, 2, 2, 2,
1332 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1333 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1334 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1335 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1336 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1337 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1338 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1339 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1340 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1341 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1342 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1343 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1344 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1345 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1346 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1347 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1348 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1349 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1350 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1351 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1352 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1353 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1358 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1360 static const unsigned short yyprhs[] =
1362 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1363 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1364 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1365 59, 61, 63, 65, 67, 70, 71, 73, 75, 77,
1366 79, 80, 81, 83, 85, 87, 90, 91, 94, 95,
1367 99, 102, 103, 105, 106, 110, 112, 115, 117, 119,
1368 121, 123, 125, 127, 129, 131, 133, 135, 137, 139,
1369 141, 143, 145, 147, 149, 151, 153, 155, 157, 160,
1370 165, 171, 177, 181, 184, 187, 189, 193, 195, 199,
1371 201, 202, 207, 211, 215, 220, 225, 229, 232, 235,
1372 238, 241, 244, 247, 250, 253, 256, 259, 266, 272,
1373 281, 288, 295, 302, 309, 316, 320, 322, 324, 326,
1374 328, 331, 334, 337, 339, 344, 347, 348, 356, 357,
1375 365, 369, 374, 375, 377, 379, 383, 387, 391, 395,
1376 399, 401, 402, 404, 406, 408, 409, 412, 416, 418,
1377 420, 424, 426, 427, 436, 438, 440, 444, 446, 448,
1378 451, 452, 456, 458, 460, 462, 464, 466, 468, 470,
1379 472, 476, 478, 480, 482, 484, 486, 489, 492, 495,
1380 499, 502, 503, 505, 508, 511, 515, 525, 535, 544,
1381 558, 560, 562, 569, 575, 578, 585, 593, 595, 599,
1382 601, 602, 605, 607, 613, 619, 625, 628, 633, 638,
1383 645, 650, 655, 660, 665, 668, 676, 678, 681, 682,
1384 684, 685, 689, 696, 700, 707, 710, 715, 722
1387 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
1388 static const short yyrhs[] =
1390 142, 0, -1, 5, -1, 6, -1, 3, -1, 4,
1391 -1, 68, -1, 69, -1, 70, -1, 71, -1, 72,
1392 -1, 73, -1, 74, -1, 75, -1, 76, -1, 77,
1393 -1, 78, -1, 79, -1, 80, -1, 81, -1, 91,
1394 -1, 92, -1, 16, -1, 14, -1, 12, -1, 10,
1395 -1, 17, -1, 15, -1, 13, -1, 11, -1, 118,
1396 -1, 119, -1, 18, -1, 19, -1, 151, 97, -1,
1397 -1, 41, -1, 42, -1, 43, -1, 44, -1, -1,
1398 -1, 59, -1, 60, -1, 61, -1, 58, 4, -1,
1399 -1, 54, 4, -1, -1, 98, 54, 4, -1, 34,
1400 24, -1, -1, 127, -1, -1, 98, 130, 129, -1,
1401 127, -1, 54, 4, -1, 133, -1, 8, -1, 135,
1402 -1, 8, -1, 135, -1, 9, -1, 10, -1, 11,
1403 -1, 12, -1, 13, -1, 14, -1, 15, -1, 16,
1404 -1, 17, -1, 18, -1, 19, -1, 20, -1, 21,
1405 -1, 45, -1, 134, -1, 164, -1, 99, 4, -1,
1406 132, 100, 137, 101, -1, 102, 4, 103, 135, 104,
1407 -1, 105, 4, 103, 135, 106, -1, 107, 136, 108,
1408 -1, 107, 108, -1, 135, 109, -1, 135, -1, 136,
1409 98, 135, -1, 136, -1, 136, 98, 37, -1, 37,
1410 -1, -1, 133, 102, 140, 104, -1, 133, 102, 104,
1411 -1, 133, 110, 24, -1, 133, 105, 140, 106, -1,
1412 133, 107, 140, 108, -1, 133, 107, 108, -1, 133,
1413 38, -1, 133, 39, -1, 133, 164, -1, 133, 139,
1414 -1, 133, 26, -1, 118, 113, -1, 119, 4, -1,
1415 9, 27, -1, 9, 28, -1, 121, 7, -1, 89,
1416 100, 138, 36, 133, 101, -1, 87, 100, 138, 178,
1417 101, -1, 90, 100, 138, 98, 138, 98, 138, 101,
1418 -1, 114, 100, 138, 98, 138, 101, -1, 115, 100,
1419 138, 98, 138, 101, -1, 116, 100, 138, 98, 138,
1420 101, -1, 117, 100, 138, 98, 138, 101, -1, 94,
1421 100, 138, 98, 138, 101, -1, 140, 98, 138, -1,
1422 138, -1, 32, -1, 33, -1, 143, -1, 143, 160,
1423 -1, 143, 161, -1, 143, 25, -1, 144, -1, 144,
1424 122, 20, 131, -1, 144, 161, -1, -1, 144, 122,
1425 123, 141, 138, 145, 129, -1, -1, 144, 122, 47,
1426 141, 133, 146, 129, -1, 144, 48, 148, -1, 144,
1427 55, 97, 149, -1, -1, 53, -1, 52, -1, 50,
1428 97, 147, -1, 51, 97, 4, -1, 49, 97, 24,
1429 -1, 102, 150, 104, -1, 150, 98, 24, -1, 24,
1430 -1, -1, 22, -1, 24, -1, 151, -1, -1, 133,
1431 152, -1, 154, 98, 153, -1, 153, -1, 154, -1,
1432 154, 98, 37, -1, 37, -1, -1, 124, 131, 151,
1433 100, 155, 101, 128, 125, -1, 29, -1, 107, -1,
1434 123, 156, 157, -1, 30, -1, 108, -1, 167, 159,
1435 -1, -1, 31, 162, 156, -1, 3, -1, 4, -1,
1436 7, -1, 27, -1, 28, -1, 38, -1, 39, -1,
1437 26, -1, 105, 140, 106, -1, 139, -1, 112, -1,
1438 151, -1, 164, -1, 163, -1, 133, 165, -1, 167,
1439 168, -1, 158, 168, -1, 169, 122, 170, -1, 169,
1440 172, -1, -1, 23, -1, 62, 166, -1, 62, 8,
1441 -1, 63, 21, 165, -1, 63, 9, 165, 98, 21,
1442 165, 98, 21, 165, -1, 64, 120, 165, 98, 21,
1443 165, 102, 171, 104, -1, 64, 120, 165, 98, 21,
1444 165, 102, 104, -1, 65, 124, 131, 165, 100, 175,
1445 101, 36, 21, 165, 66, 21, 165, -1, 66, -1,
1446 67, -1, 171, 120, 163, 98, 21, 165, -1, 120,
1447 163, 98, 21, 165, -1, 122, 177, -1, 133, 102,
1448 165, 98, 165, 104, -1, 173, 98, 102, 165, 98,
1449 165, 104, -1, 166, -1, 174, 98, 166, -1, 174,
1450 -1, -1, 57, 56, -1, 56, -1, 114, 133, 165,
1451 98, 165, -1, 115, 133, 165, 98, 165, -1, 116,
1452 133, 165, 98, 165, -1, 46, 166, -1, 117, 166,
1453 98, 166, -1, 89, 166, 36, 133, -1, 90, 166,
1454 98, 166, 98, 166, -1, 93, 166, 98, 133, -1,
1455 95, 166, 98, 133, -1, 96, 166, 98, 133, -1,
1456 94, 166, 98, 166, -1, 88, 173, -1, 176, 124,
1457 131, 165, 100, 175, 101, -1, 180, -1, 98, 174,
1458 -1, -1, 35, -1, -1, 82, 133, 126, -1, 82,
1459 133, 98, 15, 165, 126, -1, 83, 133, 126, -1,
1460 83, 133, 98, 15, 165, 126, -1, 84, 166, -1,
1461 179, 85, 133, 165, -1, 179, 86, 166, 98, 133,
1462 165, -1, 87, 133, 165, 178, -1
1465 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1466 static const unsigned short yyrline[] =
1468 0, 996, 996, 997, 1004, 1005, 1014, 1014, 1014, 1014,
1469 1014, 1015, 1015, 1015, 1016, 1016, 1016, 1016, 1016, 1016,
1470 1018, 1018, 1022, 1022, 1022, 1022, 1023, 1023, 1023, 1023,
1471 1024, 1024, 1025, 1025, 1028, 1031, 1035, 1036, 1037, 1038,
1472 1039, 1041, 1042, 1043, 1044, 1045, 1053, 1054, 1059, 1060,
1473 1067, 1074, 1075, 1080, 1081, 1082, 1086, 1099, 1099, 1100,
1474 1100, 1102, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1112,
1475 1112, 1112, 1112, 1112, 1112, 1113, 1116, 1119, 1125, 1132,
1476 1144, 1148, 1159, 1168, 1171, 1179, 1183, 1188, 1189, 1192,
1477 1195, 1205, 1230, 1243, 1271, 1296, 1316, 1328, 1337, 1341,
1478 1400, 1406, 1414, 1419, 1424, 1427, 1430, 1437, 1447, 1478,
1479 1485, 1506, 1516, 1521, 1528, 1538, 1541, 1548, 1548, 1558,
1480 1565, 1569, 1572, 1575, 1588, 1608, 1610, 1610, 1616, 1616,
1481 1623, 1625, 1627, 1632, 1633, 1635, 1638, 1646, 1651, 1653,
1482 1657, 1661, 1669, 1669, 1670, 1670, 1672, 1678, 1683, 1689,
1483 1692, 1697, 1701, 1705, 1791, 1791, 1793, 1801, 1801, 1803,
1484 1807, 1807, 1816, 1819, 1822, 1825, 1828, 1831, 1834, 1837,
1485 1840, 1864, 1871, 1874, 1879, 1879, 1885, 1889, 1892, 1900,
1486 1909, 1913, 1923, 1934, 1937, 1940, 1943, 1946, 1960, 1964,
1487 2017, 2020, 2026, 2034, 2044, 2051, 2056, 2063, 2067, 2073,
1488 2073, 2075, 2078, 2084, 2096, 2107, 2117, 2129, 2136, 2143,
1489 2150, 2155, 2174, 2196, 2204, 2218, 2275, 2281, 2283, 2287,
1490 2290, 2296, 2300, 2304, 2308, 2312, 2319, 2329, 2342
1494 #if YYDEBUG || YYERROR_VERBOSE
1495 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1496 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1497 static const char *const yytname[] =
1499 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1500 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1501 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1502 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1503 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1504 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1505 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1506 "WEAK", "APPENDING", "OPAQUE", "NOT", "EXTERNAL", "TARGET", "TRIPLE",
1507 "ENDIAN", "POINTERSIZE", "LITTLE", "BIG", "ALIGN", "DEPLIBS", "CALL",
1508 "TAIL", "CC_TOK", "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "RET", "BR",
1509 "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "DIV",
1510 "REM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ",
1511 "SETNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1512 "PHI_TOK", "CAST", "SELECT", "SHL", "SHR", "VAARG", "EXTRACTELEMENT",
1513 "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['",
1514 "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept",
1515 "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps",
1516 "ShiftOps", "SIntType", "UIntType", "IntType", "FPType", "OptAssign",
1517 "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign", "SectionString",
1518 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "TypesV",
1519 "UpRTypesV", "Types", "PrimType", "UpRTypes", "TypeListI",
1520 "ArgTypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1521 "Module", "FunctionList", "ConstPool", "@1", "@2", "BigOrLittle",
1522 "TargetDefinition", "LibrariesDefinition", "LibList", "Name", "OptName",
1523 "ArgVal", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1524 "FunctionHeader", "END", "Function", "FunctionProto", "@3",
1525 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1526 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1527 "JumpTable", "Inst", "PHIList", "ValueRefList", "ValueRefListE",
1528 "OptTailCall", "InstVal", "IndexList", "OptVolatile", "MemoryInst", 0
1533 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1535 static const unsigned short yytoknum[] =
1537 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1538 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1539 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1540 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1541 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1542 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1543 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1544 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1545 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1546 345, 346, 347, 348, 349, 350, 351, 61, 44, 92,
1547 40, 41, 91, 120, 93, 60, 62, 123, 125, 42,
1552 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1553 static const unsigned char yyr1[] =
1555 0, 111, 112, 112, 113, 113, 114, 114, 114, 114,
1556 114, 115, 115, 115, 116, 116, 116, 116, 116, 116,
1557 117, 117, 118, 118, 118, 118, 119, 119, 119, 119,
1558 120, 120, 121, 121, 122, 122, 123, 123, 123, 123,
1559 123, 124, 124, 124, 124, 124, 125, 125, 126, 126,
1560 127, 128, 128, 129, 129, 130, 130, 131, 131, 132,
1561 132, 133, 134, 134, 134, 134, 134, 134, 134, 134,
1562 134, 134, 134, 134, 134, 135, 135, 135, 135, 135,
1563 135, 135, 135, 135, 135, 136, 136, 137, 137, 137,
1564 137, 138, 138, 138, 138, 138, 138, 138, 138, 138,
1565 138, 138, 138, 138, 138, 138, 138, 139, 139, 139,
1566 139, 139, 139, 139, 139, 140, 140, 141, 141, 142,
1567 143, 143, 143, 143, 144, 144, 145, 144, 146, 144,
1568 144, 144, 144, 147, 147, 148, 148, 148, 149, 150,
1569 150, 150, 151, 151, 152, 152, 153, 154, 154, 155,
1570 155, 155, 155, 156, 157, 157, 158, 159, 159, 160,
1571 162, 161, 163, 163, 163, 163, 163, 163, 163, 163,
1572 163, 163, 164, 164, 165, 165, 166, 167, 167, 168,
1573 169, 169, 169, 170, 170, 170, 170, 170, 170, 170,
1574 170, 170, 171, 171, 172, 173, 173, 174, 174, 175,
1575 175, 176, 176, 177, 177, 177, 177, 177, 177, 177,
1576 177, 177, 177, 177, 177, 177, 177, 178, 178, 179,
1577 179, 180, 180, 180, 180, 180, 180, 180, 180
1580 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1581 static const unsigned char yyr2[] =
1583 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1584 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1585 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1586 1, 1, 1, 1, 2, 0, 1, 1, 1, 1,
1587 0, 0, 1, 1, 1, 2, 0, 2, 0, 3,
1588 2, 0, 1, 0, 3, 1, 2, 1, 1, 1,
1589 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1590 1, 1, 1, 1, 1, 1, 1, 1, 2, 4,
1591 5, 5, 3, 2, 2, 1, 3, 1, 3, 1,
1592 0, 4, 3, 3, 4, 4, 3, 2, 2, 2,
1593 2, 2, 2, 2, 2, 2, 2, 6, 5, 8,
1594 6, 6, 6, 6, 6, 3, 1, 1, 1, 1,
1595 2, 2, 2, 1, 4, 2, 0, 7, 0, 7,
1596 3, 4, 0, 1, 1, 3, 3, 3, 3, 3,
1597 1, 0, 1, 1, 1, 0, 2, 3, 1, 1,
1598 3, 1, 0, 8, 1, 1, 3, 1, 1, 2,
1599 0, 3, 1, 1, 1, 1, 1, 1, 1, 1,
1600 3, 1, 1, 1, 1, 1, 2, 2, 2, 3,
1601 2, 0, 1, 2, 2, 3, 9, 9, 8, 13,
1602 1, 1, 6, 5, 2, 6, 7, 1, 3, 1,
1603 0, 2, 1, 5, 5, 5, 2, 4, 4, 6,
1604 4, 4, 4, 4, 2, 7, 1, 2, 0, 1,
1605 0, 3, 6, 3, 6, 2, 4, 6, 4
1608 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1609 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1610 means the default is an error. */
1611 static const unsigned char yydefact[] =
1613 132, 0, 40, 123, 1, 122, 160, 36, 37, 38,
1614 39, 41, 181, 120, 121, 181, 142, 143, 0, 0,
1615 40, 0, 125, 41, 0, 42, 43, 44, 0, 0,
1616 182, 178, 35, 157, 158, 159, 177, 0, 0, 0,
1617 130, 0, 0, 0, 0, 34, 161, 45, 2, 3,
1618 58, 62, 63, 64, 65, 66, 67, 68, 69, 70,
1619 71, 72, 73, 74, 75, 0, 0, 0, 0, 172,
1620 0, 0, 57, 76, 61, 173, 77, 154, 155, 156,
1621 220, 180, 0, 0, 0, 141, 131, 124, 117, 118,
1622 0, 0, 78, 0, 0, 60, 83, 85, 0, 0,
1623 90, 84, 219, 0, 202, 0, 0, 0, 0, 41,
1624 190, 191, 6, 7, 8, 9, 10, 11, 12, 13,
1625 14, 15, 16, 17, 18, 19, 0, 0, 0, 0,
1626 0, 0, 0, 20, 21, 0, 0, 0, 0, 0,
1627 0, 0, 0, 179, 41, 194, 0, 216, 137, 134,
1628 133, 135, 136, 140, 0, 128, 62, 63, 64, 65,
1629 66, 67, 68, 69, 70, 71, 72, 0, 0, 0,
1630 0, 126, 0, 0, 0, 82, 152, 89, 87, 0,
1631 0, 206, 201, 184, 183, 0, 0, 25, 29, 24,
1632 28, 23, 27, 22, 26, 30, 31, 0, 0, 48,
1633 48, 225, 0, 0, 214, 0, 0, 0, 0, 0,
1634 0, 0, 0, 0, 0, 0, 0, 0, 0, 138,
1635 53, 104, 105, 4, 5, 102, 103, 106, 101, 97,
1636 98, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1637 0, 0, 0, 100, 99, 53, 59, 59, 86, 151,
1638 145, 148, 149, 0, 0, 79, 162, 163, 164, 169,
1639 165, 166, 167, 168, 0, 171, 175, 174, 176, 0,
1640 185, 0, 0, 0, 221, 0, 223, 218, 0, 0,
1641 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1642 0, 0, 0, 139, 0, 129, 0, 0, 0, 0,
1643 92, 116, 0, 0, 96, 0, 93, 0, 0, 0,
1644 0, 127, 80, 81, 144, 146, 0, 51, 88, 0,
1645 0, 0, 0, 0, 0, 0, 0, 228, 0, 0,
1646 208, 0, 210, 213, 211, 212, 0, 0, 0, 207,
1647 0, 226, 0, 0, 0, 55, 53, 218, 0, 0,
1648 0, 0, 91, 94, 95, 0, 0, 0, 0, 150,
1649 147, 52, 46, 170, 0, 0, 200, 48, 49, 48,
1650 197, 217, 0, 0, 0, 203, 204, 205, 200, 0,
1651 50, 56, 54, 0, 0, 0, 0, 115, 0, 0,
1652 0, 0, 0, 153, 0, 0, 199, 0, 0, 222,
1653 224, 0, 0, 0, 209, 0, 227, 108, 0, 0,
1654 0, 0, 0, 0, 0, 47, 0, 0, 0, 198,
1655 195, 0, 215, 107, 0, 114, 110, 111, 112, 113,
1656 0, 188, 0, 0, 0, 196, 0, 186, 0, 187,
1657 0, 0, 109, 0, 0, 0, 0, 0, 0, 193,
1661 /* YYDEFGOTO[NTERM-NUM]. */
1662 static const short yydefgoto[] =
1664 -1, 69, 225, 239, 240, 241, 242, 167, 168, 197,
1665 169, 20, 11, 28, 393, 274, 345, 362, 295, 346,
1666 70, 71, 170, 73, 74, 98, 179, 301, 265, 302,
1667 90, 1, 2, 3, 245, 220, 151, 40, 86, 154,
1668 75, 315, 251, 252, 253, 29, 79, 12, 35, 13,
1669 14, 23, 266, 76, 268, 370, 15, 31, 32, 143,
1670 433, 81, 204, 396, 397, 144, 145, 327, 146, 147
1673 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1675 #define YYPACT_NINF -408
1676 static const short yypact[] =
1678 -408, 21, 120, 181, -408, -408, -408, -408, -408, -408,
1679 -408, 63, 1, -408, -408, -14, -408, -408, 87, -66,
1680 48, -23, -408, 63, 79, -408, -408, -408, 979, -22,
1681 -408, -408, 62, -408, -408, -408, -408, -10, 37, 47,
1682 -408, 44, 979, 64, 64, -408, -408, -408, -408, -408,
1683 65, -408, -408, -408, -408, -408, -408, -408, -408, -408,
1684 -408, -408, -408, -408, -408, 165, 170, 172, 491, -408,
1685 62, 80, -408, -408, -82, -408, -408, -408, -408, -408,
1686 1140, -408, 157, 53, 178, 160, -408, -408, -408, -408,
1687 1017, 1055, -408, 83, 89, -408, -408, -82, -85, 90,
1688 789, -408, -408, 1017, -408, 137, 1093, 11, 116, 63,
1689 -408, -408, -408, -408, -408, -408, -408, -408, -408, -408,
1690 -408, -408, -408, -408, -408, -408, 1017, 1017, 1017, 1017,
1691 1017, 1017, 1017, -408, -408, 1017, 1017, 1017, 1017, 1017,
1692 1017, 1017, 1017, -408, 63, -408, 57, -408, -408, -408,
1693 -408, -408, -408, -408, -62, -408, 122, 150, 190, 152,
1694 191, 155, 192, 168, 194, 193, 195, 175, 200, 199,
1695 360, -408, 1017, 1017, 1017, -408, 827, -408, 101, 110,
1696 610, -408, -408, 65, -408, 610, 610, -408, -408, -408,
1697 -408, -408, -408, -408, -408, -408, -408, 610, 979, 117,
1698 118, -408, 610, 115, 128, 196, 132, 133, 136, 139,
1699 140, 610, 610, 610, 141, 979, 1017, 1017, 211, -408,
1700 142, -408, -408, -408, -408, -408, -408, -408, -408, -408,
1701 -408, 143, 144, 147, 148, 865, 1055, 567, 217, 149,
1702 151, 158, 163, -408, -408, 142, -33, -39, -82, -408,
1703 62, -408, 162, 164, 903, -408, -408, -408, -408, -408,
1704 -408, -408, -408, -408, 1055, -408, -408, -408, -408, 166,
1705 -408, 169, 610, 7, -408, 10, -408, 171, 610, 173,
1706 1017, 1017, 1017, 1017, 1017, 1017, 174, 176, 179, 1017,
1707 610, 610, 183, -408, -19, -408, 1055, 1055, 1055, 1055,
1708 -408, -408, -16, -29, -408, -79, -408, 1055, 1055, 1055,
1709 1055, -408, -408, -408, -408, -408, 941, 208, -408, -26,
1710 229, 245, 182, 610, 264, 610, 1017, -408, 185, 610,
1711 -408, 187, -408, -408, -408, -408, 610, 610, 610, -408,
1712 186, -408, 1017, 246, 267, -408, 142, 171, 237, 189,
1713 197, 1055, -408, -408, -408, 209, 210, 213, 215, -408,
1714 -408, -408, 225, -408, 610, 610, 1017, 219, -408, 219,
1715 -408, 220, 610, 224, 1017, -408, -408, -408, 1017, 610,
1716 -408, -408, -408, 188, 1017, 1055, 1055, -408, 1055, 1055,
1717 1055, 1055, 286, -408, 226, 204, 220, 214, 240, -408,
1718 -408, 1017, 205, 610, -408, 222, -408, -408, 228, 227,
1719 232, 235, 236, 238, 239, -408, 320, 35, 306, -408,
1720 -408, 241, -408, -408, 1055, -408, -408, -408, -408, -408,
1721 610, -408, 691, 43, 322, -408, 243, -408, 249, -408,
1722 691, 610, -408, 327, 251, 285, 610, 331, 332, -408,
1723 610, 610, -408, -408
1726 /* YYPGOTO[NTERM-NUM]. */
1727 static const short yypgoto[] =
1729 -408, -408, -408, 274, 275, 277, 279, -107, -105, -407,
1730 -408, 328, 341, -81, -408, -194, 45, -408, -228, -408,
1731 -38, -408, -28, -408, -57, 263, -408, -89, 198, -171,
1732 323, -408, -408, -408, -408, -408, -408, -408, -408, -408,
1733 9, -408, 54, -408, -408, 346, -408, -408, -408, -408,
1734 361, -408, -359, -45, 119, -98, -408, 356, -408, -408,
1735 -408, -408, -408, 46, -4, -408, -408, 28, -408, -408
1738 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1739 positive, shift that token. If negative, reduce the rule which
1740 number is the opposite. If zero, do what YYDEFACT says.
1741 If YYTABLE_NINF, syntax error. */
1742 #define YYTABLE_NINF -120
1743 static const short yytable[] =
1745 72, 195, 171, 196, 87, 181, 276, 77, 184, 30,
1746 432, 97, 21, 174, 72, 343, 33, 311, -59, 351,
1747 185, 4, 323, 175, 30, 325, 440, 101, 198, 354,
1748 201, 41, 186, 205, 206, 344, 218, 207, 208, 209,
1749 210, 21, 219, 97, 214, 187, 188, 189, 190, 191,
1750 192, 193, 194, 187, 188, 189, 190, 191, 192, 193,
1751 194, 324, 155, 215, 324, 303, 305, 313, 42, 351,
1752 101, 312, 351, 438, 45, 180, 101, 353, 180, 99,
1753 363, 444, 351, 47, 16, 78, 17, 82, 352, 7,
1754 8, 9, 10, 319, 34, 43, 88, 89, 199, 200,
1755 180, 202, 203, 180, 180, 149, 150, 180, 180, 180,
1756 180, 211, 212, 213, 180, 246, 247, 248, 382, 292,
1757 -119, 24, 25, 26, 27, 244, 187, 188, 189, 190,
1758 191, 192, 193, 194, 83, 267, 37, 38, 39, 431,
1759 267, 267, 216, 217, 84, 5, 85, 439, 250, 221,
1760 222, 6, 267, -25, -25, -24, -24, 267, -23, -23,
1761 272, 7, 8, 9, 10, -60, 267, 267, 267, 92,
1762 72, -22, -22, 399, 93, 400, 94, 290, 223, 224,
1763 100, 148, 152, 331, 153, 333, 172, 72, 291, 180,
1764 176, 339, 173, 182, -29, -28, -27, 248, -26, 254,
1765 -32, -35, -33, 16, 226, 17, 227, 347, 348, 349,
1766 350, 255, 6, -35, -35, 273, 275, 278, 355, 356,
1767 357, 358, -35, -35, -35, -35, 279, 267, -35, 18,
1768 281, 282, 280, 267, 283, 293, 19, 284, 285, 289,
1769 294, 306, 343, 296, 297, 267, 267, 298, 299, 307,
1770 364, 308, 330, 180, 332, 180, 334, 335, 309, 314,
1771 316, 180, 387, 310, 320, 317, 365, 321, 368, 326,
1772 380, 381, 336, 384, 337, 329, 404, 338, 267, 392,
1773 267, 342, 366, 372, 267, 374, 378, 385, 250, 407,
1774 415, 267, 267, 267, 324, 386, 409, 410, 180, 411,
1775 412, 413, 414, 419, 269, 270, 417, 388, 389, 420,
1776 195, 390, 196, 391, 379, 418, 271, 398, 401, 267,
1777 267, 277, 403, 422, 416, 424, 195, 267, 196, 423,
1778 286, 287, 288, 425, 267, 436, 426, 427, 180, 428,
1779 429, 430, 434, 441, 442, 435, 180, 443, 446, 447,
1780 180, 448, 450, 451, 139, 140, 408, 141, 267, 142,
1781 80, 44, 361, 178, 22, 48, 49, 91, 243, 46,
1782 360, 36, 371, 180, 405, 383, 0, 0, 0, 0,
1783 0, 0, 16, 0, 17, 267, 228, 0, 0, 0,
1784 0, 322, 0, 0, 0, 0, 267, 328, 229, 230,
1785 0, 267, 0, 0, 0, 267, 267, 0, 0, 340,
1786 341, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1787 0, 0, 0, 0, 0, 0, 0, 0, 112, 113,
1788 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1789 124, 125, 367, 0, 369, 0, 0, 231, 373, 232,
1790 233, 133, 134, 0, 234, 375, 376, 377, 0, 0,
1791 0, 0, 235, 0, 0, 236, 0, 237, 0, 0,
1792 238, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1793 0, 0, 0, 394, 395, 0, 0, 0, 0, 0,
1794 0, 402, 0, 0, 0, 0, 48, 49, 406, 95,
1795 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1796 61, 62, 63, 16, 0, 17, 0, 0, 0, 0,
1797 0, 0, 421, 0, 0, 0, 0, 0, 0, 0,
1798 0, 0, 0, 0, 0, 0, 64, 0, 0, 0,
1799 0, 0, 0, 0, 0, 0, 0, 0, 0, 437,
1800 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1801 445, 0, 0, 0, 0, 449, 0, 0, 0, 452,
1802 453, 0, 48, 49, 0, 95, 156, 157, 158, 159,
1803 160, 161, 162, 163, 164, 165, 166, 62, 63, 16,
1804 65, 17, 0, 66, 0, 0, 67, 0, 68, 96,
1805 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1806 0, 0, 64, 256, 257, 48, 49, 258, 0, 0,
1807 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1808 0, 0, 16, 0, 17, 0, 259, 260, 261, 0,
1809 0, 0, 0, 0, 0, 0, 0, 0, 262, 263,
1810 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1811 0, 0, 0, 0, 0, 0, 65, 0, 0, 66,
1812 0, 0, 67, 0, 68, 304, 0, 0, 112, 113,
1813 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1814 124, 125, 0, 0, 256, 257, 0, 231, 258, 232,
1815 233, 133, 134, 0, 234, 0, 0, 0, 0, 0,
1816 0, 0, 0, 0, 0, 264, 0, 259, 260, 261,
1817 0, 0, 0, 0, 0, 0, 0, 0, 0, 262,
1818 263, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1819 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1820 0, 0, 0, 0, 0, 0, 0, 0, 0, 112,
1821 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1822 123, 124, 125, 0, 0, 0, 0, 0, 231, 0,
1823 232, 233, 133, 134, 0, 234, 0, 0, 0, 0,
1824 0, 0, 0, 0, 48, 49, 264, 95, 51, 52,
1825 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1826 63, 16, 0, 17, 0, 0, 0, 0, 0, 0,
1827 0, 0, 0, 0, 0, 0, 177, 0, 0, 0,
1828 0, 0, 48, 49, 64, 95, 51, 52, 53, 54,
1829 55, 56, 57, 58, 59, 60, 61, 62, 63, 16,
1830 0, 17, 0, 0, 0, 0, 0, 0, 0, 0,
1831 0, 0, 0, 0, 249, 0, 0, 0, 0, 0,
1832 48, 49, 64, 95, 156, 157, 158, 159, 160, 161,
1833 162, 163, 164, 165, 166, 62, 63, 16, 65, 17,
1834 0, 66, 0, 0, 67, 0, 68, 0, 0, 0,
1835 0, 0, 0, 0, 0, 0, 0, 0, 48, 49,
1836 64, 95, 51, 52, 53, 54, 55, 56, 57, 58,
1837 59, 60, 61, 62, 63, 16, 65, 17, 0, 66,
1838 0, 0, 67, 0, 68, 0, 0, 0, 0, 0,
1839 318, 0, 0, 0, 0, 0, 48, 49, 64, 95,
1840 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1841 61, 62, 63, 16, 65, 17, 0, 66, 0, 300,
1842 67, 0, 68, 0, 0, 0, 0, 0, 359, 0,
1843 0, 0, 0, 0, 48, 49, 64, 50, 51, 52,
1844 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1845 63, 16, 65, 17, 0, 66, 0, 0, 67, 0,
1846 68, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1847 0, 0, 48, 49, 64, 95, 51, 52, 53, 54,
1848 55, 56, 57, 58, 59, 60, 61, 62, 63, 16,
1849 65, 17, 0, 66, 0, 0, 67, 0, 68, 0,
1850 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1851 48, 49, 64, 95, 156, 157, 158, 159, 160, 161,
1852 162, 163, 164, 165, 166, 62, 63, 16, 65, 17,
1853 0, 66, 0, 0, 67, 0, 68, 0, 0, 0,
1854 0, 0, 0, 0, 0, 0, 0, 0, 48, 49,
1855 64, 183, 51, 52, 53, 54, 55, 56, 57, 58,
1856 59, 60, 61, 62, 63, 16, 65, 17, 0, 66,
1857 0, 0, 67, 0, 68, 0, 0, 0, 0, 0,
1858 0, 0, 0, 0, 0, 0, 0, 0, 64, 0,
1859 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1860 0, 0, 0, 0, 65, 0, 0, 66, 0, 0,
1861 67, 0, 68, 0, 0, 0, 0, 0, 0, 0,
1862 0, 0, 0, 0, 0, 102, 0, 0, 0, 0,
1863 0, 0, 0, 0, 0, 0, 103, 0, 0, 0,
1864 0, 0, 65, 0, 0, 66, 104, 105, 67, 0,
1865 68, 0, 106, 107, 108, 109, 110, 111, 112, 113,
1866 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1867 124, 125, 126, 127, 128, 0, 0, 129, 130, 131,
1868 132, 133, 134, 135, 136, 137, 138
1871 static const short yycheck[] =
1873 28, 108, 91, 108, 42, 103, 200, 29, 106, 23,
1874 417, 68, 3, 98, 42, 34, 30, 245, 100, 98,
1875 9, 0, 15, 108, 23, 15, 433, 109, 109, 108,
1876 128, 97, 21, 131, 132, 54, 98, 135, 136, 137,
1877 138, 32, 104, 100, 142, 10, 11, 12, 13, 14,
1878 15, 16, 17, 10, 11, 12, 13, 14, 15, 16,
1879 17, 54, 90, 144, 54, 236, 237, 106, 20, 98,
1880 109, 104, 98, 432, 97, 103, 109, 106, 106, 70,
1881 106, 440, 98, 4, 22, 107, 24, 97, 104, 41,
1882 42, 43, 44, 264, 108, 47, 32, 33, 126, 127,
1883 128, 129, 130, 131, 132, 52, 53, 135, 136, 137,
1884 138, 139, 140, 141, 142, 172, 173, 174, 346, 217,
1885 0, 58, 59, 60, 61, 170, 10, 11, 12, 13,
1886 14, 15, 16, 17, 97, 180, 49, 50, 51, 104,
1887 185, 186, 85, 86, 97, 25, 102, 104, 176, 27,
1888 28, 31, 197, 3, 4, 3, 4, 202, 3, 4,
1889 198, 41, 42, 43, 44, 100, 211, 212, 213, 4,
1890 198, 3, 4, 367, 4, 369, 4, 215, 3, 4,
1891 100, 24, 4, 281, 24, 283, 103, 215, 216, 217,
1892 100, 289, 103, 56, 4, 4, 4, 254, 4, 98,
1893 7, 20, 7, 22, 4, 24, 7, 296, 297, 298,
1894 299, 101, 31, 32, 33, 98, 98, 102, 307, 308,
1895 309, 310, 41, 42, 43, 44, 98, 272, 47, 48,
1896 98, 98, 36, 278, 98, 24, 55, 98, 98, 98,
1897 98, 24, 34, 100, 100, 290, 291, 100, 100, 100,
1898 21, 100, 280, 281, 282, 283, 284, 285, 100, 250,
1899 98, 289, 351, 100, 98, 101, 21, 98, 4, 98,
1900 24, 4, 98, 36, 98, 102, 374, 98, 323, 54,
1901 325, 98, 100, 98, 329, 98, 100, 98, 316, 101,
1902 4, 336, 337, 338, 54, 98, 385, 386, 326, 388,
1903 389, 390, 391, 401, 185, 186, 102, 98, 98, 104,
1904 417, 98, 417, 98, 342, 101, 197, 98, 98, 364,
1905 365, 202, 98, 101, 98, 98, 433, 372, 433, 101,
1906 211, 212, 213, 101, 379, 424, 101, 101, 366, 101,
1907 101, 21, 36, 21, 101, 104, 374, 98, 21, 98,
1908 378, 66, 21, 21, 80, 80, 384, 80, 403, 80,
1909 32, 20, 317, 100, 3, 5, 6, 44, 170, 23,
1910 316, 15, 326, 401, 378, 347, -1, -1, -1, -1,
1911 -1, -1, 22, -1, 24, 430, 26, -1, -1, -1,
1912 -1, 272, -1, -1, -1, -1, 441, 278, 38, 39,
1913 -1, 446, -1, -1, -1, 450, 451, -1, -1, 290,
1914 291, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1915 -1, -1, -1, -1, -1, -1, -1, -1, 68, 69,
1916 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1917 80, 81, 323, -1, 325, -1, -1, 87, 329, 89,
1918 90, 91, 92, -1, 94, 336, 337, 338, -1, -1,
1919 -1, -1, 102, -1, -1, 105, -1, 107, -1, -1,
1920 110, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1921 -1, -1, -1, 364, 365, -1, -1, -1, -1, -1,
1922 -1, 372, -1, -1, -1, -1, 5, 6, 379, 8,
1923 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1924 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1925 -1, -1, 403, -1, -1, -1, -1, -1, -1, -1,
1926 -1, -1, -1, -1, -1, -1, 45, -1, -1, -1,
1927 -1, -1, -1, -1, -1, -1, -1, -1, -1, 430,
1928 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1929 441, -1, -1, -1, -1, 446, -1, -1, -1, 450,
1930 451, -1, 5, 6, -1, 8, 9, 10, 11, 12,
1931 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1932 99, 24, -1, 102, -1, -1, 105, -1, 107, 108,
1933 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1934 -1, -1, 45, 3, 4, 5, 6, 7, -1, -1,
1935 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1936 -1, -1, 22, -1, 24, -1, 26, 27, 28, -1,
1937 -1, -1, -1, -1, -1, -1, -1, -1, 38, 39,
1938 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1939 -1, -1, -1, -1, -1, -1, 99, -1, -1, 102,
1940 -1, -1, 105, -1, 107, 108, -1, -1, 68, 69,
1941 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1942 80, 81, -1, -1, 3, 4, -1, 87, 7, 89,
1943 90, 91, 92, -1, 94, -1, -1, -1, -1, -1,
1944 -1, -1, -1, -1, -1, 105, -1, 26, 27, 28,
1945 -1, -1, -1, -1, -1, -1, -1, -1, -1, 38,
1946 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1947 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1948 -1, -1, -1, -1, -1, -1, -1, -1, -1, 68,
1949 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1950 79, 80, 81, -1, -1, -1, -1, -1, 87, -1,
1951 89, 90, 91, 92, -1, 94, -1, -1, -1, -1,
1952 -1, -1, -1, -1, 5, 6, 105, 8, 9, 10,
1953 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1954 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1955 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
1956 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1957 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1958 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
1959 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
1960 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1961 15, 16, 17, 18, 19, 20, 21, 22, 99, 24,
1962 -1, 102, -1, -1, 105, -1, 107, -1, -1, -1,
1963 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1964 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1965 17, 18, 19, 20, 21, 22, 99, 24, -1, 102,
1966 -1, -1, 105, -1, 107, -1, -1, -1, -1, -1,
1967 37, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1968 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1969 19, 20, 21, 22, 99, 24, -1, 102, -1, 104,
1970 105, -1, 107, -1, -1, -1, -1, -1, 37, -1,
1971 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1972 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1973 21, 22, 99, 24, -1, 102, -1, -1, 105, -1,
1974 107, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1975 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1976 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1977 99, 24, -1, 102, -1, -1, 105, -1, 107, -1,
1978 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1979 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1980 15, 16, 17, 18, 19, 20, 21, 22, 99, 24,
1981 -1, 102, -1, -1, 105, -1, 107, -1, -1, -1,
1982 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1983 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1984 17, 18, 19, 20, 21, 22, 99, 24, -1, 102,
1985 -1, -1, 105, -1, 107, -1, -1, -1, -1, -1,
1986 -1, -1, -1, -1, -1, -1, -1, -1, 45, -1,
1987 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1988 -1, -1, -1, -1, 99, -1, -1, 102, -1, -1,
1989 105, -1, 107, -1, -1, -1, -1, -1, -1, -1,
1990 -1, -1, -1, -1, -1, 35, -1, -1, -1, -1,
1991 -1, -1, -1, -1, -1, -1, 46, -1, -1, -1,
1992 -1, -1, 99, -1, -1, 102, 56, 57, 105, -1,
1993 107, -1, 62, 63, 64, 65, 66, 67, 68, 69,
1994 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1995 80, 81, 82, 83, 84, -1, -1, 87, 88, 89,
1996 90, 91, 92, 93, 94, 95, 96
1999 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2000 symbol of state STATE-NUM. */
2001 static const unsigned char yystos[] =
2003 0, 142, 143, 144, 0, 25, 31, 41, 42, 43,
2004 44, 123, 158, 160, 161, 167, 22, 24, 48, 55,
2005 122, 151, 161, 162, 58, 59, 60, 61, 124, 156,
2006 23, 168, 169, 30, 108, 159, 168, 49, 50, 51,
2007 148, 97, 20, 47, 123, 97, 156, 4, 5, 6,
2008 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2009 18, 19, 20, 21, 45, 99, 102, 105, 107, 112,
2010 131, 132, 133, 134, 135, 151, 164, 29, 107, 157,
2011 122, 172, 97, 97, 97, 102, 149, 131, 32, 33,
2012 141, 141, 4, 4, 4, 8, 108, 135, 136, 151,
2013 100, 109, 35, 46, 56, 57, 62, 63, 64, 65,
2014 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2015 76, 77, 78, 79, 80, 81, 82, 83, 84, 87,
2016 88, 89, 90, 91, 92, 93, 94, 95, 96, 114,
2017 115, 116, 117, 170, 176, 177, 179, 180, 24, 52,
2018 53, 147, 4, 24, 150, 133, 9, 10, 11, 12,
2019 13, 14, 15, 16, 17, 18, 19, 118, 119, 121,
2020 133, 138, 103, 103, 98, 108, 100, 37, 136, 137,
2021 133, 166, 56, 8, 166, 9, 21, 10, 11, 12,
2022 13, 14, 15, 16, 17, 118, 119, 120, 124, 133,
2023 133, 166, 133, 133, 173, 166, 166, 166, 166, 166,
2024 166, 133, 133, 133, 166, 124, 85, 86, 98, 104,
2025 146, 27, 28, 3, 4, 113, 4, 7, 26, 38,
2026 39, 87, 89, 90, 94, 102, 105, 107, 110, 114,
2027 115, 116, 117, 139, 164, 145, 135, 135, 135, 37,
2028 133, 153, 154, 155, 98, 101, 3, 4, 7, 26,
2029 27, 28, 38, 39, 105, 139, 163, 164, 165, 165,
2030 165, 165, 131, 98, 126, 98, 126, 165, 102, 98,
2031 36, 98, 98, 98, 98, 98, 165, 165, 165, 98,
2032 131, 133, 166, 24, 98, 129, 100, 100, 100, 100,
2033 104, 138, 140, 140, 108, 140, 24, 100, 100, 100,
2034 100, 129, 104, 106, 151, 152, 98, 101, 37, 140,
2035 98, 98, 165, 15, 54, 15, 98, 178, 165, 102,
2036 133, 166, 133, 166, 133, 133, 98, 98, 98, 166,
2037 165, 165, 98, 34, 54, 127, 130, 138, 138, 138,
2038 138, 98, 104, 106, 108, 138, 138, 138, 138, 37,
2039 153, 127, 128, 106, 21, 21, 100, 165, 4, 165,
2040 166, 174, 98, 165, 98, 165, 165, 165, 100, 133,
2041 24, 4, 129, 178, 36, 98, 98, 138, 98, 98,
2042 98, 98, 54, 125, 165, 165, 174, 175, 98, 126,
2043 126, 98, 165, 98, 166, 175, 165, 101, 133, 138,
2044 138, 138, 138, 138, 138, 4, 98, 102, 101, 166,
2045 104, 165, 101, 101, 98, 101, 101, 101, 101, 101,
2046 21, 104, 120, 171, 36, 104, 138, 165, 163, 104,
2047 120, 21, 101, 98, 163, 165, 21, 98, 66, 165,
2051 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2052 # define YYSIZE_T __SIZE_TYPE__
2054 #if ! defined (YYSIZE_T) && defined (size_t)
2055 # define YYSIZE_T size_t
2057 #if ! defined (YYSIZE_T)
2058 # if defined (__STDC__) || defined (__cplusplus)
2059 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2060 # define YYSIZE_T size_t
2063 #if ! defined (YYSIZE_T)
2064 # define YYSIZE_T unsigned int
2067 #define yyerrok (yyerrstatus = 0)
2068 #define yyclearin (yychar = YYEMPTY)
2069 #define YYEMPTY (-2)
2072 #define YYACCEPT goto yyacceptlab
2073 #define YYABORT goto yyabortlab
2074 #define YYERROR goto yyerrorlab
2077 /* Like YYERROR except do call yyerror. This remains here temporarily
2078 to ease the transition to the new meaning of YYERROR, for GCC.
2079 Once GCC version 2 has supplanted version 1, this can go. */
2081 #define YYFAIL goto yyerrlab
2083 #define YYRECOVERING() (!!yyerrstatus)
2085 #define YYBACKUP(Token, Value) \
2087 if (yychar == YYEMPTY && yylen == 1) \
2091 yytoken = YYTRANSLATE (yychar); \
2097 yyerror ("syntax error: cannot back up");\
2103 #define YYERRCODE 256
2105 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
2108 #ifndef YYLLOC_DEFAULT
2109 # define YYLLOC_DEFAULT(Current, Rhs, N) \
2110 ((Current).first_line = (Rhs)[1].first_line, \
2111 (Current).first_column = (Rhs)[1].first_column, \
2112 (Current).last_line = (Rhs)[N].last_line, \
2113 (Current).last_column = (Rhs)[N].last_column)
2116 /* YYLEX -- calling `yylex' with the right arguments. */
2119 # define YYLEX yylex (YYLEX_PARAM)
2121 # define YYLEX yylex ()
2124 /* Enable debugging if requested. */
2128 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2129 # define YYFPRINTF fprintf
2132 # define YYDPRINTF(Args) \
2138 # define YYDSYMPRINT(Args) \
2144 # define YYDSYMPRINTF(Title, Token, Value, Location) \
2148 YYFPRINTF (stderr, "%s ", Title); \
2149 yysymprint (stderr, \
2151 YYFPRINTF (stderr, "\n"); \
2155 /*------------------------------------------------------------------.
2156 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
2158 `------------------------------------------------------------------*/
2160 #if defined (__STDC__) || defined (__cplusplus)
2162 yy_stack_print (short *bottom, short *top)
2165 yy_stack_print (bottom, top)
2170 YYFPRINTF (stderr, "Stack now");
2171 for (/* Nothing. */; bottom <= top; ++bottom)
2172 YYFPRINTF (stderr, " %d", *bottom);
2173 YYFPRINTF (stderr, "\n");
2176 # define YY_STACK_PRINT(Bottom, Top) \
2179 yy_stack_print ((Bottom), (Top)); \
2183 /*------------------------------------------------.
2184 | Report that the YYRULE is going to be reduced. |
2185 `------------------------------------------------*/
2187 #if defined (__STDC__) || defined (__cplusplus)
2189 yy_reduce_print (int yyrule)
2192 yy_reduce_print (yyrule)
2197 unsigned int yylno = yyrline[yyrule];
2198 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
2200 /* Print the symbols being reduced, and their result. */
2201 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2202 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
2203 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
2206 # define YY_REDUCE_PRINT(Rule) \
2209 yy_reduce_print (Rule); \
2212 /* Nonzero means print parse trace. It is left uninitialized so that
2213 multiple parsers can coexist. */
2215 #else /* !YYDEBUG */
2216 # define YYDPRINTF(Args)
2217 # define YYDSYMPRINT(Args)
2218 # define YYDSYMPRINTF(Title, Token, Value, Location)
2219 # define YY_STACK_PRINT(Bottom, Top)
2220 # define YY_REDUCE_PRINT(Rule)
2221 #endif /* !YYDEBUG */
2224 /* YYINITDEPTH -- initial size of the parser's stacks. */
2226 # define YYINITDEPTH 200
2229 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2230 if the built-in stack extension method is used).
2232 Do not make this value too large; the results are undefined if
2233 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
2234 evaluated with infinite-precision integer arithmetic. */
2236 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
2241 # define YYMAXDEPTH 10000
2249 # if defined (__GLIBC__) && defined (_STRING_H)
2250 # define yystrlen strlen
2252 /* Return the length of YYSTR. */
2254 # if defined (__STDC__) || defined (__cplusplus)
2255 yystrlen (const char *yystr)
2261 register const char *yys = yystr;
2263 while (*yys++ != '\0')
2266 return yys - yystr - 1;
2272 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2273 # define yystpcpy stpcpy
2275 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2278 # if defined (__STDC__) || defined (__cplusplus)
2279 yystpcpy (char *yydest, const char *yysrc)
2281 yystpcpy (yydest, yysrc)
2286 register char *yyd = yydest;
2287 register const char *yys = yysrc;
2289 while ((*yyd++ = *yys++) != '\0')
2297 #endif /* !YYERROR_VERBOSE */
2302 /*--------------------------------.
2303 | Print this symbol on YYOUTPUT. |
2304 `--------------------------------*/
2306 #if defined (__STDC__) || defined (__cplusplus)
2308 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
2311 yysymprint (yyoutput, yytype, yyvaluep)
2317 /* Pacify ``unused variable'' warnings. */
2320 if (yytype < YYNTOKENS)
2322 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2324 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2328 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2335 YYFPRINTF (yyoutput, ")");
2338 #endif /* ! YYDEBUG */
2339 /*-----------------------------------------------.
2340 | Release the memory associated to this symbol. |
2341 `-----------------------------------------------*/
2343 #if defined (__STDC__) || defined (__cplusplus)
2345 yydestruct (int yytype, YYSTYPE *yyvaluep)
2348 yydestruct (yytype, yyvaluep)
2353 /* Pacify ``unused variable'' warnings. */
2365 /* Prevent warnings from -Wmissing-prototypes. */
2367 #ifdef YYPARSE_PARAM
2368 # if defined (__STDC__) || defined (__cplusplus)
2369 int yyparse (void *YYPARSE_PARAM);
2373 #else /* ! YYPARSE_PARAM */
2374 #if defined (__STDC__) || defined (__cplusplus)
2379 #endif /* ! YYPARSE_PARAM */
2383 /* The lookahead symbol. */
2386 /* The semantic value of the lookahead symbol. */
2389 /* Number of syntax errors so far. */
2398 #ifdef YYPARSE_PARAM
2399 # if defined (__STDC__) || defined (__cplusplus)
2400 int yyparse (void *YYPARSE_PARAM)
2402 int yyparse (YYPARSE_PARAM)
2403 void *YYPARSE_PARAM;
2405 #else /* ! YYPARSE_PARAM */
2406 #if defined (__STDC__) || defined (__cplusplus)
2417 register int yystate;
2420 /* Number of tokens to shift before error messages enabled. */
2422 /* Lookahead token as an internal (translated) token number. */
2425 /* Three stacks and their tools:
2426 `yyss': related to states,
2427 `yyvs': related to semantic values,
2428 `yyls': related to locations.
2430 Refer to the stacks thru separate pointers, to allow yyoverflow
2431 to reallocate them elsewhere. */
2433 /* The state stack. */
2434 short yyssa[YYINITDEPTH];
2435 short *yyss = yyssa;
2436 register short *yyssp;
2438 /* The semantic value stack. */
2439 YYSTYPE yyvsa[YYINITDEPTH];
2440 YYSTYPE *yyvs = yyvsa;
2441 register YYSTYPE *yyvsp;
2445 #define YYPOPSTACK (yyvsp--, yyssp--)
2447 YYSIZE_T yystacksize = YYINITDEPTH;
2449 /* The variables used to return semantic value and location from the
2454 /* When reducing, the number of symbols on the RHS of the reduced
2458 YYDPRINTF ((stderr, "Starting parse\n"));
2463 yychar = YYEMPTY; /* Cause a token to be read. */
2465 /* Initialize stack pointers.
2466 Waste one element of value and location stack
2467 so that they stay on the same level as the state stack.
2468 The wasted elements are never initialized. */
2475 /*------------------------------------------------------------.
2476 | yynewstate -- Push a new state, which is found in yystate. |
2477 `------------------------------------------------------------*/
2479 /* In all cases, when you get here, the value and location stacks
2480 have just been pushed. so pushing a state here evens the stacks.
2487 if (yyss + yystacksize - 1 <= yyssp)
2489 /* Get the current used size of the three stacks, in elements. */
2490 YYSIZE_T yysize = yyssp - yyss + 1;
2494 /* Give user a chance to reallocate the stack. Use copies of
2495 these so that the &'s don't force the real ones into
2497 YYSTYPE *yyvs1 = yyvs;
2498 short *yyss1 = yyss;
2501 /* Each stack pointer address is followed by the size of the
2502 data in use in that stack, in bytes. This used to be a
2503 conditional around just the two extra args, but that might
2504 be undefined if yyoverflow is a macro. */
2505 yyoverflow ("parser stack overflow",
2506 &yyss1, yysize * sizeof (*yyssp),
2507 &yyvs1, yysize * sizeof (*yyvsp),
2514 #else /* no yyoverflow */
2515 # ifndef YYSTACK_RELOCATE
2518 /* Extend the stack our own way. */
2519 if (YYMAXDEPTH <= yystacksize)
2522 if (YYMAXDEPTH < yystacksize)
2523 yystacksize = YYMAXDEPTH;
2526 short *yyss1 = yyss;
2527 union yyalloc *yyptr =
2528 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2531 YYSTACK_RELOCATE (yyss);
2532 YYSTACK_RELOCATE (yyvs);
2534 # undef YYSTACK_RELOCATE
2536 YYSTACK_FREE (yyss1);
2539 #endif /* no yyoverflow */
2541 yyssp = yyss + yysize - 1;
2542 yyvsp = yyvs + yysize - 1;
2545 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2546 (unsigned long int) yystacksize));
2548 if (yyss + yystacksize - 1 <= yyssp)
2552 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2561 /* Do appropriate processing given the current state. */
2562 /* Read a lookahead token if we need one and don't already have one. */
2565 /* First try to decide what to do without reference to lookahead token. */
2567 yyn = yypact[yystate];
2568 if (yyn == YYPACT_NINF)
2571 /* Not known => get a lookahead token if don't already have one. */
2573 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
2574 if (yychar == YYEMPTY)
2576 YYDPRINTF ((stderr, "Reading a token: "));
2580 if (yychar <= YYEOF)
2582 yychar = yytoken = YYEOF;
2583 YYDPRINTF ((stderr, "Now at end of input.\n"));
2587 yytoken = YYTRANSLATE (yychar);
2588 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
2591 /* If the proper action on seeing token YYTOKEN is to reduce or to
2592 detect an error, take that action. */
2594 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2599 if (yyn == 0 || yyn == YYTABLE_NINF)
2608 /* Shift the lookahead token. */
2609 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
2611 /* Discard the token being shifted unless it is eof. */
2612 if (yychar != YYEOF)
2618 /* Count tokens shifted since error; after three, turn off error
2627 /*-----------------------------------------------------------.
2628 | yydefault -- do the default action for the current state. |
2629 `-----------------------------------------------------------*/
2631 yyn = yydefact[yystate];
2637 /*-----------------------------.
2638 | yyreduce -- Do a reduction. |
2639 `-----------------------------*/
2641 /* yyn is the number of a rule to reduce with. */
2644 /* If YYLEN is nonzero, implement the default value of the action:
2647 Otherwise, the following line sets YYVAL to garbage.
2648 This behavior is undocumented and Bison
2649 users should not rely upon it. Assigning to YYVAL
2650 unconditionally makes the parser a bit smaller, and it avoids a
2651 GCC warning that YYVAL may be used uninitialized. */
2652 yyval = yyvsp[1-yylen];
2655 YY_REDUCE_PRINT (yyn);
2659 #line 997 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2661 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2662 ThrowException("Value too large for type!");
2663 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2668 #line 1005 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2670 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2671 ThrowException("Value too large for type!");
2672 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2677 #line 1028 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2679 yyval.StrVal = yyvsp[-1].StrVal;
2684 #line 1031 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2691 #line 1035 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2692 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
2696 #line 1036 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2697 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;}
2701 #line 1037 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2702 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
2706 #line 1038 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2707 { yyval.Linkage = GlobalValue::AppendingLinkage; ;}
2711 #line 1039 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2712 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
2716 #line 1041 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2717 { yyval.UIntVal = CallingConv::C; ;}
2721 #line 1042 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2722 { yyval.UIntVal = CallingConv::C; ;}
2726 #line 1043 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2727 { yyval.UIntVal = CallingConv::Fast; ;}
2731 #line 1044 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2732 { yyval.UIntVal = CallingConv::Cold; ;}
2736 #line 1045 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2738 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2739 ThrowException("Calling conv too large!");
2740 yyval.UIntVal = yyvsp[0].UInt64Val;
2745 #line 1053 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2746 { yyval.UIntVal = 0; ;}
2750 #line 1054 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2752 yyval.UIntVal = yyvsp[0].UInt64Val;
2753 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2754 ThrowException("Alignment must be a power of two!");
2759 #line 1059 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2760 { yyval.UIntVal = 0; ;}
2764 #line 1060 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2766 yyval.UIntVal = yyvsp[0].UInt64Val;
2767 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2768 ThrowException("Alignment must be a power of two!");
2773 #line 1067 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2775 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2776 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2777 ThrowException("Invalid character in section name!");
2778 yyval.StrVal = yyvsp[0].StrVal;
2783 #line 1074 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2784 { yyval.StrVal = 0; ;}
2788 #line 1075 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2789 { yyval.StrVal = yyvsp[0].StrVal; ;}
2793 #line 1080 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2798 #line 1081 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2803 #line 1082 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2805 CurGV->setSection(yyvsp[0].StrVal);
2806 free(yyvsp[0].StrVal);
2811 #line 1086 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2813 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2814 ThrowException("Alignment must be a power of two!");
2815 CurGV->setAlignment(yyvsp[0].UInt64Val);
2820 #line 1099 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2821 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;}
2825 #line 1100 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2826 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;}
2830 #line 1102 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2832 if (!UpRefs.empty())
2833 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2834 yyval.TypeVal = yyvsp[0].TypeVal;
2839 #line 1113 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2841 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2846 #line 1116 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2848 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2853 #line 1119 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2854 { // Named types are also simple types...
2855 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2860 #line 1125 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2861 { // Type UpReference
2862 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2863 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2864 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2865 yyval.TypeVal = new PATypeHolder(OT);
2866 UR_OUT("New Upreference!\n");
2871 #line 1132 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2872 { // Function derived type?
2873 std::vector<const Type*> Params;
2874 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2875 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2876 Params.push_back(*I);
2877 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2878 if (isVarArg) Params.pop_back();
2880 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2881 delete yyvsp[-1].TypeList; // Delete the argument list
2882 delete yyvsp[-3].TypeVal; // Delete the return type handle
2887 #line 1144 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2888 { // Sized array type?
2889 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2890 delete yyvsp[-1].TypeVal;
2895 #line 1148 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2896 { // Packed array type?
2897 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2898 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2899 ThrowException("Unsigned result not equal to signed result");
2900 if (!ElemTy->isPrimitiveType())
2901 ThrowException("Elemental type of a PackedType must be primitive");
2902 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2903 ThrowException("Vector length should be a power of 2!");
2904 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2905 delete yyvsp[-1].TypeVal;
2910 #line 1159 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2911 { // Structure type?
2912 std::vector<const Type*> Elements;
2913 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2914 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2915 Elements.push_back(*I);
2917 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2918 delete yyvsp[-1].TypeList;
2923 #line 1168 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2924 { // Empty structure type?
2925 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2930 #line 1171 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2932 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2933 delete yyvsp[-1].TypeVal;
2938 #line 1179 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2940 yyval.TypeList = new std::list<PATypeHolder>();
2941 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2946 #line 1183 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2948 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2953 #line 1189 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2955 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2960 #line 1192 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2962 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2967 #line 1195 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2969 yyval.TypeList = new std::list<PATypeHolder>();
2974 #line 1205 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
2975 { // Nonempty unsized arr
2976 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2978 ThrowException("Cannot make array constant with type: '" +
2979 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2980 const Type *ETy = ATy->getElementType();
2981 int NumElements = ATy->getNumElements();
2983 // Verify that we have the correct size...
2984 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2985 ThrowException("Type mismatch: constant sized array initialized with " +
2986 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2987 itostr(NumElements) + "!");
2989 // Verify all elements are correct type!
2990 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2991 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2992 ThrowException("Element #" + utostr(i) + " is not of type '" +
2993 ETy->getDescription() +"' as required!\nIt is of type '"+
2994 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2997 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2998 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3003 #line 1230 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3005 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
3007 ThrowException("Cannot make array constant with type: '" +
3008 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
3010 int NumElements = ATy->getNumElements();
3011 if (NumElements != -1 && NumElements != 0)
3012 ThrowException("Type mismatch: constant sized array initialized with 0"
3013 " arguments, but has size of " + itostr(NumElements) +"!");
3014 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3015 delete yyvsp[-2].TypeVal;
3020 #line 1243 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3022 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
3024 ThrowException("Cannot make array constant with type: '" +
3025 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
3027 int NumElements = ATy->getNumElements();
3028 const Type *ETy = ATy->getElementType();
3029 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3030 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
3031 ThrowException("Can't build string constant of size " +
3032 itostr((int)(EndStr-yyvsp[0].StrVal)) +
3033 " when array has size " + itostr(NumElements) + "!");
3034 std::vector<Constant*> Vals;
3035 if (ETy == Type::SByteTy) {
3036 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
3037 Vals.push_back(ConstantSInt::get(ETy, *C));
3038 } else if (ETy == Type::UByteTy) {
3039 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
3040 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
3042 free(yyvsp[0].StrVal);
3043 ThrowException("Cannot build string arrays of non byte sized elements!");
3045 free(yyvsp[0].StrVal);
3046 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3047 delete yyvsp[-2].TypeVal;
3052 #line 1271 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3053 { // Nonempty unsized arr
3054 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
3056 ThrowException("Cannot make packed constant with type: '" +
3057 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
3058 const Type *ETy = PTy->getElementType();
3059 int NumElements = PTy->getNumElements();
3061 // Verify that we have the correct size...
3062 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
3063 ThrowException("Type mismatch: constant sized packed initialized with " +
3064 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
3065 itostr(NumElements) + "!");
3067 // Verify all elements are correct type!
3068 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3069 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3070 ThrowException("Element #" + utostr(i) + " is not of type '" +
3071 ETy->getDescription() +"' as required!\nIt is of type '"+
3072 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3075 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
3076 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3081 #line 1296 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3083 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
3085 ThrowException("Cannot make struct constant with type: '" +
3086 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
3088 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
3089 ThrowException("Illegal number of initializers for structure type!");
3091 // Check to ensure that constants are compatible with the type initializer!
3092 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3093 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
3094 ThrowException("Expected type '" +
3095 STy->getElementType(i)->getDescription() +
3096 "' for element #" + utostr(i) +
3097 " of structure initializer!");
3099 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3100 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3105 #line 1316 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3107 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
3109 ThrowException("Cannot make struct constant with type: '" +
3110 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
3112 if (STy->getNumContainedTypes() != 0)
3113 ThrowException("Illegal number of initializers for structure type!");
3115 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3116 delete yyvsp[-2].TypeVal;
3121 #line 1328 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3123 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3125 ThrowException("Cannot make null pointer constant with type: '" +
3126 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
3128 yyval.ConstVal = ConstantPointerNull::get(PTy);
3129 delete yyvsp[-1].TypeVal;
3134 #line 1337 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3136 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3137 delete yyvsp[-1].TypeVal;
3142 #line 1341 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3144 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3146 ThrowException("Global const reference must be a pointer type!");
3148 // ConstExprs can exist in the body of a function, thus creating
3149 // GlobalValues whenever they refer to a variable. Because we are in
3150 // the context of a function, getValNonImprovising will search the functions
3151 // symbol table instead of the module symbol table for the global symbol,
3152 // which throws things all off. To get around this, we just tell
3153 // getValNonImprovising that we are at global scope here.
3155 Function *SavedCurFn = CurFun.CurrentFunction;
3156 CurFun.CurrentFunction = 0;
3158 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
3160 CurFun.CurrentFunction = SavedCurFn;
3162 // If this is an initializer for a constant pointer, which is referencing a
3163 // (currently) undefined variable, create a stub now that shall be replaced
3164 // in the future with the right type of variable.
3167 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3168 const PointerType *PT = cast<PointerType>(Ty);
3170 // First check to see if the forward references value is already created!
3171 PerModuleInfo::GlobalRefsType::iterator I =
3172 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
3174 if (I != CurModule.GlobalRefs.end()) {
3175 V = I->second; // Placeholder already exists, use it...
3176 yyvsp[0].ValIDVal.destroy();
3179 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
3181 // Create the forward referenced global.
3183 if (const FunctionType *FTy =
3184 dyn_cast<FunctionType>(PT->getElementType())) {
3185 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3186 CurModule.CurrentModule);
3188 GV = new GlobalVariable(PT->getElementType(), false,
3189 GlobalValue::ExternalLinkage, 0,
3190 Name, CurModule.CurrentModule);
3193 // Keep track of the fact that we have a forward ref to recycle it
3194 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
3199 yyval.ConstVal = cast<GlobalValue>(V);
3200 delete yyvsp[-1].TypeVal; // Free the type handle
3205 #line 1400 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3207 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
3208 ThrowException("Mismatched types for constant expression!");
3209 yyval.ConstVal = yyvsp[0].ConstVal;
3210 delete yyvsp[-1].TypeVal;
3215 #line 1406 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3217 const Type *Ty = yyvsp[-1].TypeVal->get();
3218 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3219 ThrowException("Cannot create a null initialized value of this type!");
3220 yyval.ConstVal = Constant::getNullValue(Ty);
3221 delete yyvsp[-1].TypeVal;
3226 #line 1414 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3227 { // integral constants
3228 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
3229 ThrowException("Constant value doesn't fit in type!");
3230 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
3235 #line 1419 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3236 { // integral constants
3237 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
3238 ThrowException("Constant value doesn't fit in type!");
3239 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
3244 #line 1424 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3245 { // Boolean constants
3246 yyval.ConstVal = ConstantBool::True;
3251 #line 1427 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3252 { // Boolean constants
3253 yyval.ConstVal = ConstantBool::False;
3258 #line 1430 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3259 { // Float & Double constants
3260 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
3261 ThrowException("Floating point constant invalid for type!!");
3262 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
3267 #line 1437 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3269 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
3270 ThrowException("cast constant expression from a non-primitive type: '" +
3271 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
3272 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
3273 ThrowException("cast constant expression to a non-primitive type: '" +
3274 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
3275 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3276 delete yyvsp[-1].TypeVal;
3281 #line 1447 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3283 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
3284 ThrowException("GetElementPtr requires a pointer operand!");
3286 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3287 // indices to uint struct indices for compatibility.
3288 generic_gep_type_iterator<std::vector<Value*>::iterator>
3289 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
3290 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
3291 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3292 if (isa<StructType>(*GTI)) // Only change struct indices
3293 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
3294 if (CUI->getType() == Type::UByteTy)
3295 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3298 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
3300 ThrowException("Index list invalid for constant getelementptr!");
3302 std::vector<Constant*> IdxVec;
3303 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3304 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
3305 IdxVec.push_back(C);
3307 ThrowException("Indices to constant getelementptr must be constants!");
3309 delete yyvsp[-1].ValueList;
3311 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
3316 #line 1478 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3318 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
3319 ThrowException("Select condition must be of boolean type!");
3320 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3321 ThrowException("Select operand types must match!");
3322 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3327 #line 1485 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3329 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3330 ThrowException("Binary operator types must match!");
3331 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3332 // To retain backward compatibility with these early compilers, we emit a
3333 // cast to the appropriate integer type automatically if we are in the
3334 // broken case. See PR424 for more information.
3335 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
3336 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3338 const Type *IntPtrTy = 0;
3339 switch (CurModule.CurrentModule->getPointerSize()) {
3340 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3341 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
3342 default: ThrowException("invalid pointer binary constant expr!");
3344 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
3345 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
3346 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
3352 #line 1506 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3354 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3355 ThrowException("Logical operator types must match!");
3356 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
3357 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3358 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
3359 ThrowException("Logical operator requires integral operands!");
3361 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3366 #line 1516 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3368 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3369 ThrowException("setcc operand types must match!");
3370 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3375 #line 1521 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3377 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
3378 ThrowException("Shift count for shift constant must be unsigned byte!");
3379 if (!yyvsp[-3].ConstVal->getType()->isInteger())
3380 ThrowException("Shift constant expression requires integer operand!");
3381 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3386 #line 1528 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3388 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()))
3389 ThrowException("First operand of extractelement must be "
3391 if (yyvsp[-1].ConstVal->getType() != Type::UIntTy)
3392 ThrowException("Second operand of extractelement must be uint!");
3393 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3398 #line 1538 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3400 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
3405 #line 1541 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3407 yyval.ConstVector = new std::vector<Constant*>();
3408 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
3413 #line 1548 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3414 { yyval.BoolVal = false; ;}
3418 #line 1548 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3419 { yyval.BoolVal = true; ;}
3423 #line 1558 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3425 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
3426 CurModule.ModuleDone();
3431 #line 1565 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3433 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3434 CurFun.FunctionDone();
3439 #line 1569 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3441 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3446 #line 1572 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3448 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3453 #line 1575 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3455 yyval.ModuleVal = CurModule.CurrentModule;
3456 // Emit an error if there are any unresolved types left.
3457 if (!CurModule.LateResolveTypes.empty()) {
3458 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
3459 if (DID.Type == ValID::NameVal)
3460 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
3462 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
3468 #line 1588 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3470 // Eagerly resolve types. This is not an optimization, this is a
3471 // requirement that is due to the fact that we could have this:
3473 // %list = type { %list * }
3474 // %list = type { %list * } ; repeated type decl
3476 // If types are not resolved eagerly, then the two types will not be
3477 // determined to be the same type!
3479 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3481 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3482 // If this is a named type that is not a redefinition, add it to the slot
3484 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3487 delete yyvsp[0].TypeVal;
3492 #line 1608 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3493 { // Function prototypes can be in const pool
3498 #line 1610 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3500 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3501 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3506 #line 1613 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3513 #line 1616 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3515 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3516 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3517 delete yyvsp[0].TypeVal;
3522 #line 1620 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3529 #line 1623 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3535 #line 1625 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3541 #line 1627 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3547 #line 1632 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3548 { yyval.Endianness = Module::BigEndian; ;}
3552 #line 1633 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3553 { yyval.Endianness = Module::LittleEndian; ;}
3557 #line 1635 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3559 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3564 #line 1638 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3566 if (yyvsp[0].UInt64Val == 32)
3567 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3568 else if (yyvsp[0].UInt64Val == 64)
3569 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3571 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3576 #line 1646 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3578 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3579 free(yyvsp[0].StrVal);
3584 #line 1653 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3586 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3587 free(yyvsp[0].StrVal);
3592 #line 1657 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3594 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3595 free(yyvsp[0].StrVal);
3600 #line 1661 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3606 #line 1670 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3607 { yyval.StrVal = 0; ;}
3611 #line 1672 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3613 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3614 ThrowException("void typed arguments are invalid!");
3615 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3620 #line 1678 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3622 yyval.ArgList = yyvsp[-2].ArgList;
3623 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3624 delete yyvsp[0].ArgVal;
3629 #line 1683 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3631 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3632 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3633 delete yyvsp[0].ArgVal;
3638 #line 1689 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3640 yyval.ArgList = yyvsp[0].ArgList;
3645 #line 1692 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3647 yyval.ArgList = yyvsp[-2].ArgList;
3648 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3649 char*>(new PATypeHolder(Type::VoidTy), 0));
3654 #line 1697 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3656 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3657 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3662 #line 1701 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3669 #line 1706 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3671 UnEscapeLexed(yyvsp[-5].StrVal);
3672 std::string FunctionName(yyvsp[-5].StrVal);
3673 free(yyvsp[-5].StrVal); // Free strdup'd memory!
3675 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
3676 ThrowException("LLVM functions cannot return aggregate types!");
3678 std::vector<const Type*> ParamTypeList;
3679 if (yyvsp[-3].ArgList) { // If there are arguments...
3680 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3681 I != yyvsp[-3].ArgList->end(); ++I)
3682 ParamTypeList.push_back(I->first->get());
3685 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3686 if (isVarArg) ParamTypeList.pop_back();
3688 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
3689 const PointerType *PFT = PointerType::get(FT);
3690 delete yyvsp[-6].TypeVal;
3693 if (!FunctionName.empty()) {
3694 ID = ValID::create((char*)FunctionName.c_str());
3696 ID = ValID::create((int)CurModule.Values[PFT].size());
3700 // See if this function was forward referenced. If so, recycle the object.
3701 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3702 // Move the function to the end of the list, from whereever it was
3703 // previously inserted.
3704 Fn = cast<Function>(FWRef);
3705 CurModule.CurrentModule->getFunctionList().remove(Fn);
3706 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3707 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3708 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3709 // If this is the case, either we need to be a forward decl, or it needs
3711 if (!CurFun.isDeclare && !Fn->isExternal())
3712 ThrowException("Redefinition of function '" + FunctionName + "'!");
3714 // Make sure to strip off any argument names so we can't get conflicts.
3715 if (Fn->isExternal())
3716 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3720 } else { // Not already defined?
3721 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3722 CurModule.CurrentModule);
3723 InsertValue(Fn, CurModule.Values);
3726 CurFun.FunctionStart(Fn);
3727 Fn->setCallingConv(yyvsp[-7].UIntVal);
3728 Fn->setAlignment(yyvsp[0].UIntVal);
3729 if (yyvsp[-1].StrVal) {
3730 Fn->setSection(yyvsp[-1].StrVal);
3731 free(yyvsp[-1].StrVal);
3734 // Add all of the arguments we parsed to the function...
3735 if (yyvsp[-3].ArgList) { // Is null if empty...
3736 if (isVarArg) { // Nuke the last entry
3737 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
3738 "Not a varargs marker!");
3739 delete yyvsp[-3].ArgList->back().first;
3740 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
3742 Function::arg_iterator ArgIt = Fn->arg_begin();
3743 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3744 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
3745 delete I->first; // Delete the typeholder...
3747 setValueName(ArgIt, I->second); // Insert arg into symtab...
3751 delete yyvsp[-3].ArgList; // We're now done with the argument list
3757 #line 1793 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3759 yyval.FunctionVal = CurFun.CurrentFunction;
3761 // Make sure that we keep track of the linkage type even if there was a
3762 // previous "declare".
3763 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3768 #line 1803 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3770 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3775 #line 1807 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3776 { CurFun.isDeclare = true; ;}
3780 #line 1807 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3782 yyval.FunctionVal = CurFun.CurrentFunction;
3783 CurFun.FunctionDone();
3788 #line 1816 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3789 { // A reference to a direct constant
3790 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3795 #line 1819 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3797 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3802 #line 1822 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3803 { // Perhaps it's an FP constant?
3804 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3809 #line 1825 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3811 yyval.ValIDVal = ValID::create(ConstantBool::True);
3816 #line 1828 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3818 yyval.ValIDVal = ValID::create(ConstantBool::False);
3823 #line 1831 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3825 yyval.ValIDVal = ValID::createNull();
3830 #line 1834 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3832 yyval.ValIDVal = ValID::createUndef();
3837 #line 1837 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3838 { // A vector zero constant.
3839 yyval.ValIDVal = ValID::createZeroInit();
3844 #line 1840 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3845 { // Nonempty unsized packed vector
3846 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3847 int NumElements = yyvsp[-1].ConstVector->size();
3849 PackedType* pt = PackedType::get(ETy, NumElements);
3850 PATypeHolder* PTy = new PATypeHolder(
3858 // Verify all elements are correct type!
3859 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3860 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3861 ThrowException("Element #" + utostr(i) + " is not of type '" +
3862 ETy->getDescription() +"' as required!\nIt is of type '" +
3863 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3866 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3867 delete PTy; delete yyvsp[-1].ConstVector;
3872 #line 1864 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3874 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3879 #line 1871 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3880 { // Is it an integer reference...?
3881 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3886 #line 1874 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3887 { // Is it a named reference...?
3888 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3893 #line 1885 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3895 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3900 #line 1889 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3902 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3907 #line 1892 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3908 { // Do not allow functions with 0 basic blocks
3909 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3914 #line 1900 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3916 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3917 InsertValue(yyvsp[0].TermInstVal);
3919 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3920 InsertValue(yyvsp[-2].BasicBlockVal);
3921 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3926 #line 1909 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3928 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3929 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3934 #line 1913 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3936 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3938 // Make sure to move the basic block to the correct location in the
3939 // function, instead of leaving it inserted wherever it was first
3941 Function::BasicBlockListType &BBL =
3942 CurFun.CurrentFunction->getBasicBlockList();
3943 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3948 #line 1923 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3950 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3952 // Make sure to move the basic block to the correct location in the
3953 // function, instead of leaving it inserted wherever it was first
3955 Function::BasicBlockListType &BBL =
3956 CurFun.CurrentFunction->getBasicBlockList();
3957 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3962 #line 1934 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3963 { // Return with a result...
3964 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3969 #line 1937 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3970 { // Return with no result...
3971 yyval.TermInstVal = new ReturnInst();
3976 #line 1940 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3977 { // Unconditional Branch...
3978 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3983 #line 1943 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3985 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3990 #line 1946 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
3992 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3993 yyval.TermInstVal = S;
3995 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3996 E = yyvsp[-1].JumpTable->end();
3997 for (; I != E; ++I) {
3998 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3999 S->addCase(CI, I->second);
4001 ThrowException("Switch case is constant, but not a simple integer!");
4003 delete yyvsp[-1].JumpTable;
4008 #line 1960 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4010 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
4011 yyval.TermInstVal = S;
4016 #line 1965 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4018 const PointerType *PFTy;
4019 const FunctionType *Ty;
4021 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
4022 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4023 // Pull out the types of all of the arguments...
4024 std::vector<const Type*> ParamTypes;
4025 if (yyvsp[-7].ValueList) {
4026 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
4028 ParamTypes.push_back((*I)->getType());
4031 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4032 if (isVarArg) ParamTypes.pop_back();
4034 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
4035 PFTy = PointerType::get(Ty);
4038 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
4040 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
4041 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
4043 // Create the call node...
4044 if (!yyvsp[-7].ValueList) { // Has no arguments?
4045 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
4046 } else { // Has arguments?
4047 // Loop through FunctionType's arguments and ensure they are specified
4050 FunctionType::param_iterator I = Ty->param_begin();
4051 FunctionType::param_iterator E = Ty->param_end();
4052 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
4054 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4055 if ((*ArgI)->getType() != *I)
4056 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4057 (*I)->getDescription() + "'!");
4059 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
4060 ThrowException("Invalid number of parameters detected!");
4062 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
4064 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
4066 delete yyvsp[-10].TypeVal;
4067 delete yyvsp[-7].ValueList;
4072 #line 2017 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4074 yyval.TermInstVal = new UnwindInst();
4079 #line 2020 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4081 yyval.TermInstVal = new UnreachableInst();
4086 #line 2026 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4088 yyval.JumpTable = yyvsp[-5].JumpTable;
4089 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4091 ThrowException("May only switch on a constant pool value!");
4093 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
4098 #line 2034 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4100 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4101 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4104 ThrowException("May only switch on a constant pool value!");
4106 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
4111 #line 2044 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4113 // Is this definition named?? if so, assign the name...
4114 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
4115 InsertValue(yyvsp[0].InstVal);
4116 yyval.InstVal = yyvsp[0].InstVal;
4121 #line 2051 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4122 { // Used for PHI nodes
4123 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4124 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
4125 delete yyvsp[-5].TypeVal;
4130 #line 2056 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4132 yyval.PHIList = yyvsp[-6].PHIList;
4133 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
4134 getBBVal(yyvsp[-1].ValIDVal)));
4139 #line 2063 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4140 { // Used for call statements, and memory insts...
4141 yyval.ValueList = new std::vector<Value*>();
4142 yyval.ValueList->push_back(yyvsp[0].ValueVal);
4147 #line 2067 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4149 yyval.ValueList = yyvsp[-2].ValueList;
4150 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
4155 #line 2073 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4156 { yyval.ValueList = 0; ;}
4160 #line 2075 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4162 yyval.BoolVal = true;
4167 #line 2078 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4169 yyval.BoolVal = false;
4174 #line 2084 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4176 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4177 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4179 "Arithmetic operator requires integer, FP, or packed operands!");
4180 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
4181 ThrowException("Rem not supported on packed types!");
4182 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
4183 if (yyval.InstVal == 0)
4184 ThrowException("binary operator returned null!");
4185 delete yyvsp[-3].TypeVal;
4190 #line 2096 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4192 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
4193 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
4194 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
4195 ThrowException("Logical operator requires integral operands!");
4197 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
4198 if (yyval.InstVal == 0)
4199 ThrowException("binary operator returned null!");
4200 delete yyvsp[-3].TypeVal;
4205 #line 2107 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4207 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
4209 "PackedTypes currently not supported in setcc instructions!");
4211 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
4212 if (yyval.InstVal == 0)
4213 ThrowException("binary operator returned null!");
4214 delete yyvsp[-3].TypeVal;
4219 #line 2117 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4221 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4222 << " Replacing with 'xor'.\n";
4224 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
4226 ThrowException("Expected integral type for not instruction!");
4228 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
4229 if (yyval.InstVal == 0)
4230 ThrowException("Could not create a xor instruction!");
4235 #line 2129 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4237 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
4238 ThrowException("Shift amount must be ubyte!");
4239 if (!yyvsp[-2].ValueVal->getType()->isInteger())
4240 ThrowException("Shift constant expression requires integer operand!");
4241 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4246 #line 2136 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4248 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
4249 ThrowException("cast instruction to a non-primitive type: '" +
4250 yyvsp[0].TypeVal->get()->getDescription() + "'!");
4251 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4252 delete yyvsp[0].TypeVal;
4257 #line 2143 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4259 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
4260 ThrowException("select condition must be boolean!");
4261 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
4262 ThrowException("select value types should match!");
4263 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4268 #line 2150 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4271 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4272 delete yyvsp[0].TypeVal;
4277 #line 2155 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4279 ObsoleteVarArgs = true;
4280 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4281 Function* NF = CurModule.CurrentModule->
4282 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
4285 //foo = alloca 1 of t
4289 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4290 CurBB->getInstList().push_back(foo);
4291 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4292 CurBB->getInstList().push_back(bar);
4293 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4294 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
4295 delete yyvsp[0].TypeVal;
4300 #line 2174 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4302 ObsoleteVarArgs = true;
4303 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4304 Function* NF = CurModule.CurrentModule->
4305 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
4307 //b = vanext a, t ->
4308 //foo = alloca 1 of t
4311 //tmp = vaarg foo, t
4313 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4314 CurBB->getInstList().push_back(foo);
4315 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4316 CurBB->getInstList().push_back(bar);
4317 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4318 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
4319 CurBB->getInstList().push_back(tmp);
4320 yyval.InstVal = new LoadInst(foo);
4321 delete yyvsp[0].TypeVal;
4326 #line 2196 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4328 if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
4329 ThrowException("First operand of extractelement must be a "
4330 "packed type val!");
4331 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
4332 ThrowException("Second operand of extractelement must be a uint!");
4333 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4338 #line 2204 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4340 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
4341 if (!Ty->isFirstClassType())
4342 ThrowException("PHI node operands must be of first class type!");
4343 yyval.InstVal = new PHINode(Ty);
4344 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4345 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4346 if (yyvsp[0].PHIList->front().first->getType() != Ty)
4347 ThrowException("All elements of a PHI node must be of the same type!");
4348 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4349 yyvsp[0].PHIList->pop_front();
4351 delete yyvsp[0].PHIList; // Free the list...
4356 #line 2218 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4358 const PointerType *PFTy;
4359 const FunctionType *Ty;
4361 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
4362 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4363 // Pull out the types of all of the arguments...
4364 std::vector<const Type*> ParamTypes;
4365 if (yyvsp[-1].ValueList) {
4366 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
4368 ParamTypes.push_back((*I)->getType());
4371 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4372 if (isVarArg) ParamTypes.pop_back();
4374 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
4375 ThrowException("LLVM functions cannot return aggregate types!");
4377 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
4378 PFTy = PointerType::get(Ty);
4381 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
4383 // Create the call node...
4384 if (!yyvsp[-1].ValueList) { // Has no arguments?
4385 // Make sure no arguments is a good thing!
4386 if (Ty->getNumParams() != 0)
4387 ThrowException("No arguments passed to a function that "
4388 "expects arguments!");
4390 yyval.InstVal = new CallInst(V, std::vector<Value*>());
4391 } else { // Has arguments?
4392 // Loop through FunctionType's arguments and ensure they are specified
4395 FunctionType::param_iterator I = Ty->param_begin();
4396 FunctionType::param_iterator E = Ty->param_end();
4397 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
4399 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4400 if ((*ArgI)->getType() != *I)
4401 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4402 (*I)->getDescription() + "'!");
4404 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
4405 ThrowException("Invalid number of parameters detected!");
4407 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
4409 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
4410 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
4411 delete yyvsp[-4].TypeVal;
4412 delete yyvsp[-1].ValueList;
4417 #line 2275 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4419 yyval.InstVal = yyvsp[0].InstVal;
4424 #line 2281 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4426 yyval.ValueList = yyvsp[0].ValueList;
4431 #line 2283 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4433 yyval.ValueList = new std::vector<Value*>();
4438 #line 2287 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4440 yyval.BoolVal = true;
4445 #line 2290 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4447 yyval.BoolVal = false;
4452 #line 2296 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4454 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4455 delete yyvsp[-1].TypeVal;
4460 #line 2300 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4462 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
4463 delete yyvsp[-4].TypeVal;
4468 #line 2304 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4470 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4471 delete yyvsp[-1].TypeVal;
4476 #line 2308 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4478 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
4479 delete yyvsp[-4].TypeVal;
4484 #line 2312 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4486 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
4487 ThrowException("Trying to free nonpointer type " +
4488 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4489 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
4494 #line 2319 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4496 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4497 ThrowException("Can't load from nonpointer type: " +
4498 (*yyvsp[-1].TypeVal)->getDescription());
4499 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4500 ThrowException("Can't load from pointer of non-first-class type: " +
4501 (*yyvsp[-1].TypeVal)->getDescription());
4502 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
4503 delete yyvsp[-1].TypeVal;
4508 #line 2329 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4510 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4512 ThrowException("Can't store to a nonpointer type: " +
4513 (*yyvsp[-1].TypeVal)->getDescription());
4514 const Type *ElTy = PT->getElementType();
4515 if (ElTy != yyvsp[-3].ValueVal->getType())
4516 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4517 "' into space of type '" + ElTy->getDescription() + "'!");
4519 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
4520 delete yyvsp[-1].TypeVal;
4525 #line 2342 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4527 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4528 ThrowException("getelementptr insn requires pointer operand!");
4530 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4531 // indices to uint struct indices for compatibility.
4532 generic_gep_type_iterator<std::vector<Value*>::iterator>
4533 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4534 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4535 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4536 if (isa<StructType>(*GTI)) // Only change struct indices
4537 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4538 if (CUI->getType() == Type::UByteTy)
4539 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4541 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4542 ThrowException("Invalid getelementptr indices for type '" +
4543 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4544 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4545 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
4552 /* Line 1000 of yacc.c. */
4553 #line 4554 "llvmAsmParser.tab.c"
4559 YY_STACK_PRINT (yyss, yyssp);
4564 /* Now `shift' the result of the reduction. Determine what state
4565 that goes to, based on the state we popped back to and the rule
4566 number reduced by. */
4570 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
4571 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4572 yystate = yytable[yystate];
4574 yystate = yydefgoto[yyn - YYNTOKENS];
4579 /*------------------------------------.
4580 | yyerrlab -- here on detecting error |
4581 `------------------------------------*/
4583 /* If not already recovering from an error, report this error. */
4588 yyn = yypact[yystate];
4590 if (YYPACT_NINF < yyn && yyn < YYLAST)
4592 YYSIZE_T yysize = 0;
4593 int yytype = YYTRANSLATE (yychar);
4594 const char* yyprefix;
4598 /* Start YYX at -YYN if negative to avoid negative indexes in
4600 int yyxbegin = yyn < 0 ? -yyn : 0;
4602 /* Stay within bounds of both yycheck and yytname. */
4603 int yychecklim = YYLAST - yyn;
4604 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
4607 yyprefix = ", expecting ";
4608 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
4609 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
4611 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
4619 yysize += (sizeof ("syntax error, unexpected ")
4620 + yystrlen (yytname[yytype]));
4621 yymsg = (char *) YYSTACK_ALLOC (yysize);
4624 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
4625 yyp = yystpcpy (yyp, yytname[yytype]);
4629 yyprefix = ", expecting ";
4630 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
4631 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
4633 yyp = yystpcpy (yyp, yyprefix);
4634 yyp = yystpcpy (yyp, yytname[yyx]);
4639 YYSTACK_FREE (yymsg);
4642 yyerror ("syntax error; also virtual memory exhausted");
4645 #endif /* YYERROR_VERBOSE */
4646 yyerror ("syntax error");
4651 if (yyerrstatus == 3)
4653 /* If just tried and failed to reuse lookahead token after an
4654 error, discard it. */
4656 if (yychar <= YYEOF)
4658 /* If at end of input, pop the error token,
4659 then the rest of the stack, then return failure. */
4660 if (yychar == YYEOF)
4666 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
4667 yydestruct (yystos[*yyssp], yyvsp);
4672 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
4673 yydestruct (yytoken, &yylval);
4679 /* Else will try to reuse lookahead token after shifting the error
4684 /*---------------------------------------------------.
4685 | yyerrorlab -- error raised explicitly by YYERROR. |
4686 `---------------------------------------------------*/
4690 /* Pacify GCC when the user code never invokes YYERROR and the label
4691 yyerrorlab therefore never appears in user code. */
4702 /*-------------------------------------------------------------.
4703 | yyerrlab1 -- common code for both syntax error and YYERROR. |
4704 `-------------------------------------------------------------*/
4706 yyerrstatus = 3; /* Each real token shifted decrements this. */
4710 yyn = yypact[yystate];
4711 if (yyn != YYPACT_NINF)
4714 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
4722 /* Pop the current state because it cannot handle the error token. */
4726 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
4727 yydestruct (yystos[yystate], yyvsp);
4730 YY_STACK_PRINT (yyss, yyssp);
4736 YYDPRINTF ((stderr, "Shifting error token, "));
4745 /*-------------------------------------.
4746 | yyacceptlab -- YYACCEPT comes here. |
4747 `-------------------------------------*/
4752 /*-----------------------------------.
4753 | yyabortlab -- YYABORT comes here. |
4754 `-----------------------------------*/
4760 /*----------------------------------------------.
4761 | yyoverflowlab -- parser overflow comes here. |
4762 `----------------------------------------------*/
4764 yyerror ("parser stack overflow");
4772 YYSTACK_FREE (yyss);
4778 #line 2365 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y"
4780 int yyerror(const char *ErrorMsg) {
4782 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4783 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4784 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4785 if (yychar == YYEMPTY || yychar == 0)
4786 errMsg += "end-of-file.";
4788 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4789 ThrowException(errMsg);