2 /* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL 257
15 #define EUINT64VAL 258
35 #define STRINGCONSTANT 278
36 #define IMPLEMENTATION 279
37 #define ZEROINITIALIZER 280
61 #define POINTERSIZE 304
70 #define FASTCC_TOK 313
71 #define COLDCC_TOK 314
77 #define UNREACHABLE 320
97 #define GETELEMENTPTR 340
104 #define VAARG_old 347
105 #define VANEXT_old 348
107 #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
109 #include "ParserInternals.h"
110 #include "llvm/CallingConv.h"
111 #include "llvm/Instructions.h"
112 #include "llvm/Module.h"
113 #include "llvm/SymbolTable.h"
114 #include "llvm/Support/GetElementPtrTypeIterator.h"
115 #include "llvm/ADT/STLExtras.h"
121 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
122 int yylex(); // declaration" of xxx warnings.
126 std::string CurFilename;
128 using namespace llvm;
130 static Module *ParserResult;
132 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
133 // relating to upreferences in the input stream.
135 //#define DEBUG_UPREFS 1
137 #define UR_OUT(X) std::cerr << X
142 #define YYERROR_VERBOSE 1
144 static bool ObsoleteVarArgs;
145 static bool NewVarArgs;
146 static BasicBlock* CurBB;
149 // This contains info used when building the body of a function. It is
150 // destroyed when the function is completed.
152 typedef std::vector<Value *> ValueList; // Numbered defs
154 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
155 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
157 static struct PerModuleInfo {
158 Module *CurrentModule;
159 std::map<const Type *, ValueList> Values; // Module level numbered definitions
160 std::map<const Type *,ValueList> LateResolveValues;
161 std::vector<PATypeHolder> Types;
162 std::map<ValID, PATypeHolder> LateResolveTypes;
164 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
165 /// how they were referenced and one which line of the input they came from so
166 /// that we can resolve them later and print error messages as appropriate.
167 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
169 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
170 // references to global values. Global values may be referenced before they
171 // are defined, and if so, the temporary object that they represent is held
172 // here. This is used for forward references of GlobalValues.
174 typedef std::map<std::pair<const PointerType *,
175 ValID>, GlobalValue*> GlobalRefsType;
176 GlobalRefsType GlobalRefs;
179 // If we could not resolve some functions at function compilation time
180 // (calls to functions before they are defined), resolve them now... Types
181 // are resolved when the constant pool has been completely parsed.
183 ResolveDefinitions(LateResolveValues);
185 // Check to make sure that all global value forward references have been
188 if (!GlobalRefs.empty()) {
189 std::string UndefinedReferences = "Unresolved global references exist:\n";
191 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
193 UndefinedReferences += " " + I->first.first->getDescription() + " " +
194 I->first.second.getName() + "\n";
196 ThrowException(UndefinedReferences);
199 Values.clear(); // Clear out function local definitions
205 // GetForwardRefForGlobal - Check to see if there is a forward reference
206 // for this global. If so, remove it from the GlobalRefs map and return it.
207 // If not, just return null.
208 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
209 // Check to see if there is a forward reference to this global variable...
210 // if there is, eliminate it and patch the reference to use the new def'n.
211 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
212 GlobalValue *Ret = 0;
213 if (I != GlobalRefs.end()) {
221 static struct PerFunctionInfo {
222 Function *CurrentFunction; // Pointer to current function being created
224 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
225 std::map<const Type*, ValueList> LateResolveValues;
226 bool isDeclare; // Is this function a forward declararation?
228 /// BBForwardRefs - When we see forward references to basic blocks, keep
229 /// track of them here.
230 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
231 std::vector<BasicBlock*> NumberedBlocks;
234 inline PerFunctionInfo() {
239 inline void FunctionStart(Function *M) {
244 void FunctionDone() {
245 NumberedBlocks.clear();
247 // Any forward referenced blocks left?
248 if (!BBForwardRefs.empty())
249 ThrowException("Undefined reference to label " +
250 BBForwardRefs.begin()->first->getName());
252 // Resolve all forward references now.
253 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
255 Values.clear(); // Clear out function local definitions
259 } CurFun; // Info for the current function...
261 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
264 //===----------------------------------------------------------------------===//
265 // Code to handle definitions of all the types
266 //===----------------------------------------------------------------------===//
268 static int InsertValue(Value *V,
269 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
270 if (V->hasName()) return -1; // Is this a numbered definition?
272 // Yes, insert the value into the value table...
273 ValueList &List = ValueTab[V->getType()];
275 return List.size()-1;
278 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
280 case ValID::NumberVal: // Is it a numbered definition?
281 // Module constants occupy the lowest numbered slots...
282 if ((unsigned)D.Num < CurModule.Types.size())
283 return CurModule.Types[(unsigned)D.Num];
285 case ValID::NameVal: // Is it a named definition?
286 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
287 D.destroy(); // Free old strdup'd memory...
292 ThrowException("Internal parser error: Invalid symbol type reference!");
295 // If we reached here, we referenced either a symbol that we don't know about
296 // or an id number that hasn't been read yet. We may be referencing something
297 // forward, so just create an entry to be resolved later and get to it...
299 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
302 if (inFunctionScope()) {
303 if (D.Type == ValID::NameVal)
304 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
306 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
309 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
310 if (I != CurModule.LateResolveTypes.end())
313 Type *Typ = OpaqueType::get();
314 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
318 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
319 SymbolTable &SymTab =
320 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
321 CurModule.CurrentModule->getSymbolTable();
322 return SymTab.lookup(Ty, Name);
325 // getValNonImprovising - Look up the value specified by the provided type and
326 // the provided ValID. If the value exists and has already been defined, return
327 // it. Otherwise return null.
329 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
330 if (isa<FunctionType>(Ty))
331 ThrowException("Functions are not values and "
332 "must be referenced as pointers");
335 case ValID::NumberVal: { // Is it a numbered definition?
336 unsigned Num = (unsigned)D.Num;
338 // Module constants occupy the lowest numbered slots...
339 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
340 if (VI != CurModule.Values.end()) {
341 if (Num < VI->second.size())
342 return VI->second[Num];
343 Num -= VI->second.size();
346 // Make sure that our type is within bounds
347 VI = CurFun.Values.find(Ty);
348 if (VI == CurFun.Values.end()) return 0;
350 // Check that the number is within bounds...
351 if (VI->second.size() <= Num) return 0;
353 return VI->second[Num];
356 case ValID::NameVal: { // Is it a named definition?
357 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
358 if (N == 0) return 0;
360 D.destroy(); // Free old strdup'd memory...
364 // Check to make sure that "Ty" is an integral type, and that our
365 // value will fit into the specified type...
366 case ValID::ConstSIntVal: // Is it a constant pool reference??
367 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
368 ThrowException("Signed integral constant '" +
369 itostr(D.ConstPool64) + "' is invalid for type '" +
370 Ty->getDescription() + "'!");
371 return ConstantSInt::get(Ty, D.ConstPool64);
373 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
374 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
375 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
376 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
377 "' is invalid or out of range!");
378 } else { // This is really a signed reference. Transmogrify.
379 return ConstantSInt::get(Ty, D.ConstPool64);
382 return ConstantUInt::get(Ty, D.UConstPool64);
385 case ValID::ConstFPVal: // Is it a floating point const pool reference?
386 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
387 ThrowException("FP constant invalid for type!!");
388 return ConstantFP::get(Ty, D.ConstPoolFP);
390 case ValID::ConstNullVal: // Is it a null value?
391 if (!isa<PointerType>(Ty))
392 ThrowException("Cannot create a a non pointer null!");
393 return ConstantPointerNull::get(cast<PointerType>(Ty));
395 case ValID::ConstUndefVal: // Is it an undef value?
396 return UndefValue::get(Ty);
398 case ValID::ConstantVal: // Fully resolved constant?
399 if (D.ConstantValue->getType() != Ty)
400 ThrowException("Constant expression type different from required type!");
401 return D.ConstantValue;
404 assert(0 && "Unhandled case!");
408 assert(0 && "Unhandled case!");
412 // getVal - This function is identical to getValNonImprovising, except that if a
413 // value is not already defined, it "improvises" by creating a placeholder var
414 // that looks and acts just like the requested variable. When the value is
415 // defined later, all uses of the placeholder variable are replaced with the
418 static Value *getVal(const Type *Ty, const ValID &ID) {
419 if (Ty == Type::LabelTy)
420 ThrowException("Cannot use a basic block here");
422 // See if the value has already been defined.
423 Value *V = getValNonImprovising(Ty, ID);
426 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
427 ThrowException("Invalid use of a composite type!");
429 // If we reached here, we referenced either a symbol that we don't know about
430 // or an id number that hasn't been read yet. We may be referencing something
431 // forward, so just create an entry to be resolved later and get to it...
433 V = new Argument(Ty);
435 // Remember where this forward reference came from. FIXME, shouldn't we try
436 // to recycle these things??
437 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
440 if (inFunctionScope())
441 InsertValue(V, CurFun.LateResolveValues);
443 InsertValue(V, CurModule.LateResolveValues);
447 /// getBBVal - This is used for two purposes:
448 /// * If isDefinition is true, a new basic block with the specified ID is being
450 /// * If isDefinition is true, this is a reference to a basic block, which may
451 /// or may not be a forward reference.
453 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
454 assert(inFunctionScope() && "Can't get basic block at global scope!");
459 default: ThrowException("Illegal label reference " + ID.getName());
460 case ValID::NumberVal: // Is it a numbered definition?
461 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
462 CurFun.NumberedBlocks.resize(ID.Num+1);
463 BB = CurFun.NumberedBlocks[ID.Num];
465 case ValID::NameVal: // Is it a named definition?
467 if (Value *N = CurFun.CurrentFunction->
468 getSymbolTable().lookup(Type::LabelTy, Name))
469 BB = cast<BasicBlock>(N);
473 // See if the block has already been defined.
475 // If this is the definition of the block, make sure the existing value was
476 // just a forward reference. If it was a forward reference, there will be
477 // an entry for it in the PlaceHolderInfo map.
478 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
479 // The existing value was a definition, not a forward reference.
480 ThrowException("Redefinition of label " + ID.getName());
482 ID.destroy(); // Free strdup'd memory.
486 // Otherwise this block has not been seen before.
487 BB = new BasicBlock("", CurFun.CurrentFunction);
488 if (ID.Type == ValID::NameVal) {
489 BB->setName(ID.Name);
491 CurFun.NumberedBlocks[ID.Num] = BB;
494 // If this is not a definition, keep track of it so we can use it as a forward
497 // Remember where this forward reference came from.
498 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
500 // The forward declaration could have been inserted anywhere in the
501 // function: insert it into the correct place now.
502 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
503 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
510 //===----------------------------------------------------------------------===//
511 // Code to handle forward references in instructions
512 //===----------------------------------------------------------------------===//
514 // This code handles the late binding needed with statements that reference
515 // values not defined yet... for example, a forward branch, or the PHI node for
518 // This keeps a table (CurFun.LateResolveValues) of all such forward references
519 // and back patchs after we are done.
522 // ResolveDefinitions - If we could not resolve some defs at parsing
523 // time (forward branches, phi functions for loops, etc...) resolve the
527 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
528 std::map<const Type*,ValueList> *FutureLateResolvers) {
529 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
530 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
531 E = LateResolvers.end(); LRI != E; ++LRI) {
532 ValueList &List = LRI->second;
533 while (!List.empty()) {
534 Value *V = List.back();
537 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
538 CurModule.PlaceHolderInfo.find(V);
539 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
541 ValID &DID = PHI->second.first;
543 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
545 V->replaceAllUsesWith(TheRealValue);
547 CurModule.PlaceHolderInfo.erase(PHI);
548 } else if (FutureLateResolvers) {
549 // Functions have their unresolved items forwarded to the module late
551 InsertValue(V, *FutureLateResolvers);
553 if (DID.Type == ValID::NameVal)
554 ThrowException("Reference to an invalid definition: '" +DID.getName()+
555 "' of type '" + V->getType()->getDescription() + "'",
558 ThrowException("Reference to an invalid definition: #" +
559 itostr(DID.Num) + " of type '" +
560 V->getType()->getDescription() + "'",
566 LateResolvers.clear();
569 // ResolveTypeTo - A brand new type was just declared. This means that (if
570 // name is not null) things referencing Name can be resolved. Otherwise, things
571 // refering to the number can be resolved. Do this now.
573 static void ResolveTypeTo(char *Name, const Type *ToTy) {
575 if (Name) D = ValID::create(Name);
576 else D = ValID::create((int)CurModule.Types.size());
578 std::map<ValID, PATypeHolder>::iterator I =
579 CurModule.LateResolveTypes.find(D);
580 if (I != CurModule.LateResolveTypes.end()) {
581 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
582 CurModule.LateResolveTypes.erase(I);
586 // setValueName - Set the specified value to the name given. The name may be
587 // null potentially, in which case this is a noop. The string passed in is
588 // assumed to be a malloc'd string buffer, and is free'd by this function.
590 static void setValueName(Value *V, char *NameStr) {
592 std::string Name(NameStr); // Copy string
593 free(NameStr); // Free old string
595 if (V->getType() == Type::VoidTy)
596 ThrowException("Can't assign name '" + Name+"' to value with void type!");
598 assert(inFunctionScope() && "Must be in function scope!");
599 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
600 if (ST.lookup(V->getType(), Name))
601 ThrowException("Redefinition of value named '" + Name + "' in the '" +
602 V->getType()->getDescription() + "' type plane!");
609 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
610 /// this is a declaration, otherwise it is a definition.
611 static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
612 bool isConstantGlobal, const Type *Ty,
613 Constant *Initializer) {
614 if (isa<FunctionType>(Ty))
615 ThrowException("Cannot declare global vars of function type!");
617 const PointerType *PTy = PointerType::get(Ty);
621 Name = NameStr; // Copy string
622 free(NameStr); // Free old string
625 // See if this global value was forward referenced. If so, recycle the
629 ID = ValID::create((char*)Name.c_str());
631 ID = ValID::create((int)CurModule.Values[PTy].size());
634 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
635 // Move the global to the end of the list, from whereever it was
636 // previously inserted.
637 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
638 CurModule.CurrentModule->getGlobalList().remove(GV);
639 CurModule.CurrentModule->getGlobalList().push_back(GV);
640 GV->setInitializer(Initializer);
641 GV->setLinkage(Linkage);
642 GV->setConstant(isConstantGlobal);
643 InsertValue(GV, CurModule.Values);
647 // If this global has a name, check to see if there is already a definition
648 // of this global in the module. If so, merge as appropriate. Note that
649 // this is really just a hack around problems in the CFE. :(
651 // We are a simple redefinition of a value, check to see if it is defined
652 // the same as the old one.
653 if (GlobalVariable *EGV =
654 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
655 // We are allowed to redefine a global variable in two circumstances:
656 // 1. If at least one of the globals is uninitialized or
657 // 2. If both initializers have the same value.
659 if (!EGV->hasInitializer() || !Initializer ||
660 EGV->getInitializer() == Initializer) {
662 // Make sure the existing global version gets the initializer! Make
663 // sure that it also gets marked const if the new version is.
664 if (Initializer && !EGV->hasInitializer())
665 EGV->setInitializer(Initializer);
666 if (isConstantGlobal)
667 EGV->setConstant(true);
668 EGV->setLinkage(Linkage);
672 ThrowException("Redefinition of global variable named '" + Name +
673 "' in the '" + Ty->getDescription() + "' type plane!");
677 // Otherwise there is no existing GV to use, create one now.
679 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
680 CurModule.CurrentModule);
681 InsertValue(GV, CurModule.Values);
684 // setTypeName - Set the specified type to the name given. The name may be
685 // null potentially, in which case this is a noop. The string passed in is
686 // assumed to be a malloc'd string buffer, and is freed by this function.
688 // This function returns true if the type has already been defined, but is
689 // allowed to be redefined in the specified context. If the name is a new name
690 // for the type plane, it is inserted and false is returned.
691 static bool setTypeName(const Type *T, char *NameStr) {
692 assert(!inFunctionScope() && "Can't give types function-local names!");
693 if (NameStr == 0) return false;
695 std::string Name(NameStr); // Copy string
696 free(NameStr); // Free old string
698 // We don't allow assigning names to void type
699 if (T == Type::VoidTy)
700 ThrowException("Can't assign name '" + Name + "' to the void type!");
702 // Set the type name, checking for conflicts as we do so.
703 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
705 if (AlreadyExists) { // Inserting a name that is already defined???
706 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
707 assert(Existing && "Conflict but no matching type?");
709 // There is only one case where this is allowed: when we are refining an
710 // opaque type. In this case, Existing will be an opaque type.
711 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
712 // We ARE replacing an opaque type!
713 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
717 // Otherwise, this is an attempt to redefine a type. That's okay if
718 // the redefinition is identical to the original. This will be so if
719 // Existing and T point to the same Type object. In this one case we
720 // allow the equivalent redefinition.
721 if (Existing == T) return true; // Yes, it's equal.
723 // Any other kind of (non-equivalent) redefinition is an error.
724 ThrowException("Redefinition of type named '" + Name + "' in the '" +
725 T->getDescription() + "' type plane!");
731 //===----------------------------------------------------------------------===//
732 // Code for handling upreferences in type names...
735 // TypeContains - Returns true if Ty directly contains E in it.
737 static bool TypeContains(const Type *Ty, const Type *E) {
738 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
739 E) != Ty->subtype_end();
744 // NestingLevel - The number of nesting levels that need to be popped before
745 // this type is resolved.
746 unsigned NestingLevel;
748 // LastContainedTy - This is the type at the current binding level for the
749 // type. Every time we reduce the nesting level, this gets updated.
750 const Type *LastContainedTy;
752 // UpRefTy - This is the actual opaque type that the upreference is
756 UpRefRecord(unsigned NL, OpaqueType *URTy)
757 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
761 // UpRefs - A list of the outstanding upreferences that need to be resolved.
762 static std::vector<UpRefRecord> UpRefs;
764 /// HandleUpRefs - Every time we finish a new layer of types, this function is
765 /// called. It loops through the UpRefs vector, which is a list of the
766 /// currently active types. For each type, if the up reference is contained in
767 /// the newly completed type, we decrement the level count. When the level
768 /// count reaches zero, the upreferenced type is the type that is passed in:
769 /// thus we can complete the cycle.
771 static PATypeHolder HandleUpRefs(const Type *ty) {
772 if (!ty->isAbstract()) return ty;
774 UR_OUT("Type '" << Ty->getDescription() <<
775 "' newly formed. Resolving upreferences.\n" <<
776 UpRefs.size() << " upreferences active!\n");
778 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
779 // to zero), we resolve them all together before we resolve them to Ty. At
780 // the end of the loop, if there is anything to resolve to Ty, it will be in
782 OpaqueType *TypeToResolve = 0;
784 for (unsigned i = 0; i != UpRefs.size(); ++i) {
785 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
786 << UpRefs[i].second->getDescription() << ") = "
787 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
788 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
789 // Decrement level of upreference
790 unsigned Level = --UpRefs[i].NestingLevel;
791 UpRefs[i].LastContainedTy = Ty;
792 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
793 if (Level == 0) { // Upreference should be resolved!
794 if (!TypeToResolve) {
795 TypeToResolve = UpRefs[i].UpRefTy;
797 UR_OUT(" * Resolving upreference for "
798 << UpRefs[i].second->getDescription() << "\n";
799 std::string OldName = UpRefs[i].UpRefTy->getDescription());
800 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
801 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
802 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
804 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
805 --i; // Do not skip the next element...
811 UR_OUT(" * Resolving upreference for "
812 << UpRefs[i].second->getDescription() << "\n";
813 std::string OldName = TypeToResolve->getDescription());
814 TypeToResolve->refineAbstractTypeTo(Ty);
821 // common code from the two 'RunVMAsmParser' functions
822 static Module * RunParser(Module * M) {
824 llvmAsmlineno = 1; // Reset the current line number...
825 ObsoleteVarArgs = false;
828 CurModule.CurrentModule = M;
829 yyparse(); // Parse the file, potentially throwing exception
831 Module *Result = ParserResult;
834 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
837 if ((F = Result->getNamedFunction("llvm.va_start"))
838 && F->getFunctionType()->getNumParams() == 0)
839 ObsoleteVarArgs = true;
840 if((F = Result->getNamedFunction("llvm.va_copy"))
841 && F->getFunctionType()->getNumParams() == 1)
842 ObsoleteVarArgs = true;
845 if (ObsoleteVarArgs && NewVarArgs)
846 ThrowException("This file is corrupt: it uses both new and old style varargs");
848 if(ObsoleteVarArgs) {
849 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
850 if (F->arg_size() != 0)
851 ThrowException("Obsolete va_start takes 0 argument!");
855 //bar = alloca typeof(foo)
859 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
860 const Type* ArgTy = F->getFunctionType()->getReturnType();
861 const Type* ArgTyPtr = PointerType::get(ArgTy);
862 Function* NF = Result->getOrInsertFunction("llvm.va_start",
863 RetTy, ArgTyPtr, (Type *)0);
865 while (!F->use_empty()) {
866 CallInst* CI = cast<CallInst>(F->use_back());
867 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
868 new CallInst(NF, bar, "", CI);
869 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
870 CI->replaceAllUsesWith(foo);
871 CI->getParent()->getInstList().erase(CI);
873 Result->getFunctionList().erase(F);
876 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
877 if(F->arg_size() != 1)
878 ThrowException("Obsolete va_end takes 1 argument!");
882 //bar = alloca 1 of typeof(foo)
884 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
885 const Type* ArgTy = F->getFunctionType()->getParamType(0);
886 const Type* ArgTyPtr = PointerType::get(ArgTy);
887 Function* NF = Result->getOrInsertFunction("llvm.va_end",
888 RetTy, ArgTyPtr, (Type *)0);
890 while (!F->use_empty()) {
891 CallInst* CI = cast<CallInst>(F->use_back());
892 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
893 new StoreInst(CI->getOperand(1), bar, CI);
894 new CallInst(NF, bar, "", CI);
895 CI->getParent()->getInstList().erase(CI);
897 Result->getFunctionList().erase(F);
900 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
901 if(F->arg_size() != 1)
902 ThrowException("Obsolete va_copy takes 1 argument!");
905 //a = alloca 1 of typeof(foo)
906 //b = alloca 1 of typeof(foo)
911 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
912 const Type* ArgTy = F->getFunctionType()->getReturnType();
913 const Type* ArgTyPtr = PointerType::get(ArgTy);
914 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
915 RetTy, ArgTyPtr, ArgTyPtr,
918 while (!F->use_empty()) {
919 CallInst* CI = cast<CallInst>(F->use_back());
920 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
921 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
922 new StoreInst(CI->getOperand(1), b, CI);
923 new CallInst(NF, a, b, "", CI);
924 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
925 CI->replaceAllUsesWith(foo);
926 CI->getParent()->getInstList().erase(CI);
928 Result->getFunctionList().erase(F);
936 //===----------------------------------------------------------------------===//
937 // RunVMAsmParser - Define an interface to this parser
938 //===----------------------------------------------------------------------===//
940 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
943 CurFilename = Filename;
944 return RunParser(new Module(CurFilename));
947 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
948 set_scan_string(AsmString);
950 CurFilename = "from_memory";
952 return RunParser(new Module (CurFilename));
959 #line 866 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
961 llvm::Module *ModuleVal;
962 llvm::Function *FunctionVal;
963 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
964 llvm::BasicBlock *BasicBlockVal;
965 llvm::TerminatorInst *TermInstVal;
966 llvm::Instruction *InstVal;
967 llvm::Constant *ConstVal;
969 const llvm::Type *PrimType;
970 llvm::PATypeHolder *TypeVal;
971 llvm::Value *ValueVal;
973 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
974 std::vector<llvm::Value*> *ValueList;
975 std::list<llvm::PATypeHolder> *TypeList;
976 // Represent the RHS of PHI node
977 std::list<std::pair<llvm::Value*,
978 llvm::BasicBlock*> > *PHIList;
979 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
980 std::vector<llvm::Constant*> *ConstVector;
982 llvm::GlobalValue::LinkageTypes Linkage;
990 char *StrVal; // This memory is strdup'd!
991 llvm::ValID ValIDVal; // strdup'd memory maybe!
993 llvm::Instruction::BinaryOps BinaryOpVal;
994 llvm::Instruction::TermOps TermOpVal;
995 llvm::Instruction::MemoryOps MemOpVal;
996 llvm::Instruction::OtherOps OtherOpVal;
997 llvm::Module::Endianness Endianness;
1010 #define YYFLAG -32768
1011 #define YYNTBASE 109
1013 #define YYTRANSLATE(x) ((unsigned)(x) <= 348 ? yytranslate[x] : 171)
1015 static const char yytranslate[] = { 0,
1016 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1017 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1018 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1019 2, 2, 2, 2, 2, 2, 2, 2, 2, 98,
1020 99, 107, 2, 96, 2, 2, 2, 2, 2, 2,
1021 2, 2, 2, 2, 2, 2, 2, 2, 2, 103,
1022 95, 104, 2, 2, 2, 2, 2, 2, 2, 2,
1023 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1024 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1025 100, 97, 102, 2, 2, 2, 2, 2, 108, 2,
1026 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1027 2, 2, 2, 2, 2, 2, 2, 2, 2, 101,
1028 2, 2, 105, 2, 106, 2, 2, 2, 2, 2,
1029 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1030 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1031 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1033 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1034 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1035 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1036 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1037 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1038 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1039 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1041 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1042 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1043 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1044 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1045 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1046 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1047 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1048 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1049 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1050 87, 88, 89, 90, 91, 92, 93, 94
1054 static const short yyprhs[] = { 0,
1055 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1056 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1057 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1058 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1059 78, 80, 82, 84, 87, 88, 92, 94, 96, 98,
1060 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1061 120, 122, 124, 126, 128, 130, 132, 134, 137, 142,
1062 148, 154, 158, 161, 164, 166, 170, 172, 176, 178,
1063 179, 184, 188, 192, 197, 202, 206, 209, 212, 215,
1064 218, 221, 224, 227, 230, 233, 236, 243, 249, 258,
1065 265, 272, 279, 286, 290, 292, 294, 296, 298, 301,
1066 304, 307, 309, 314, 317, 323, 329, 333, 338, 339,
1067 341, 343, 347, 351, 355, 359, 363, 365, 366, 368,
1068 370, 372, 373, 376, 380, 382, 384, 388, 390, 391,
1069 398, 400, 402, 406, 408, 410, 413, 414, 418, 420,
1070 422, 424, 426, 428, 430, 432, 436, 438, 440, 442,
1071 444, 446, 449, 452, 455, 459, 462, 463, 465, 468,
1072 471, 475, 485, 495, 504, 518, 520, 522, 529, 535,
1073 538, 545, 553, 555, 559, 561, 562, 565, 567, 573,
1074 579, 585, 588, 593, 598, 605, 610, 615, 620, 623,
1075 631, 633, 636, 637, 639, 640, 644, 651, 655, 662,
1079 static const short yyrhs[] = { 5,
1080 0, 6, 0, 3, 0, 4, 0, 67, 0, 68,
1081 0, 69, 0, 70, 0, 71, 0, 72, 0, 73,
1082 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1083 0, 79, 0, 80, 0, 90, 0, 91, 0, 16,
1084 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1085 0, 13, 0, 11, 0, 115, 0, 116, 0, 18,
1086 0, 19, 0, 141, 95, 0, 0, 40, 0, 41,
1087 0, 42, 0, 43, 0, 0, 0, 58, 0, 59,
1088 0, 60, 0, 57, 4, 0, 0, 96, 53, 4,
1089 0, 125, 0, 8, 0, 127, 0, 8, 0, 127,
1090 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1091 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
1092 0, 19, 0, 20, 0, 21, 0, 44, 0, 126,
1093 0, 154, 0, 97, 4, 0, 124, 98, 129, 99,
1094 0, 100, 4, 101, 127, 102, 0, 103, 4, 101,
1095 127, 104, 0, 105, 128, 106, 0, 105, 106, 0,
1096 127, 107, 0, 127, 0, 128, 96, 127, 0, 128,
1097 0, 128, 96, 36, 0, 36, 0, 0, 125, 100,
1098 132, 102, 0, 125, 100, 102, 0, 125, 108, 24,
1099 0, 125, 103, 132, 104, 0, 125, 105, 132, 106,
1100 0, 125, 105, 106, 0, 125, 37, 0, 125, 38,
1101 0, 125, 154, 0, 125, 131, 0, 125, 26, 0,
1102 115, 110, 0, 116, 4, 0, 9, 27, 0, 9,
1103 28, 0, 118, 7, 0, 88, 98, 130, 35, 125,
1104 99, 0, 86, 98, 130, 168, 99, 0, 89, 98,
1105 130, 96, 130, 96, 130, 99, 0, 111, 98, 130,
1106 96, 130, 99, 0, 112, 98, 130, 96, 130, 99,
1107 0, 113, 98, 130, 96, 130, 99, 0, 114, 98,
1108 130, 96, 130, 99, 0, 132, 96, 130, 0, 130,
1109 0, 32, 0, 33, 0, 135, 0, 135, 150, 0,
1110 135, 151, 0, 135, 25, 0, 136, 0, 136, 119,
1111 20, 123, 0, 136, 151, 0, 136, 119, 120, 133,
1112 130, 0, 136, 119, 46, 133, 125, 0, 136, 47,
1113 138, 0, 136, 54, 95, 139, 0, 0, 52, 0,
1114 51, 0, 49, 95, 137, 0, 50, 95, 4, 0,
1115 48, 95, 24, 0, 100, 140, 102, 0, 140, 96,
1116 24, 0, 24, 0, 0, 22, 0, 24, 0, 141,
1117 0, 0, 125, 142, 0, 144, 96, 143, 0, 143,
1118 0, 144, 0, 144, 96, 36, 0, 36, 0, 0,
1119 121, 123, 141, 98, 145, 99, 0, 29, 0, 105,
1120 0, 120, 146, 147, 0, 30, 0, 106, 0, 157,
1121 149, 0, 0, 31, 152, 146, 0, 3, 0, 4,
1122 0, 7, 0, 27, 0, 28, 0, 37, 0, 38,
1123 0, 103, 132, 104, 0, 131, 0, 109, 0, 141,
1124 0, 154, 0, 153, 0, 125, 155, 0, 157, 158,
1125 0, 148, 158, 0, 159, 119, 160, 0, 159, 162,
1126 0, 0, 23, 0, 61, 156, 0, 61, 8, 0,
1127 62, 21, 155, 0, 62, 9, 155, 96, 21, 155,
1128 96, 21, 155, 0, 63, 117, 155, 96, 21, 155,
1129 100, 161, 102, 0, 63, 117, 155, 96, 21, 155,
1130 100, 102, 0, 64, 121, 123, 155, 98, 165, 99,
1131 35, 21, 155, 65, 21, 155, 0, 65, 0, 66,
1132 0, 161, 117, 153, 96, 21, 155, 0, 117, 153,
1133 96, 21, 155, 0, 119, 167, 0, 125, 100, 155,
1134 96, 155, 102, 0, 163, 96, 100, 155, 96, 155,
1135 102, 0, 156, 0, 164, 96, 156, 0, 164, 0,
1136 0, 56, 55, 0, 55, 0, 111, 125, 155, 96,
1137 155, 0, 112, 125, 155, 96, 155, 0, 113, 125,
1138 155, 96, 155, 0, 45, 156, 0, 114, 156, 96,
1139 156, 0, 88, 156, 35, 125, 0, 89, 156, 96,
1140 156, 96, 156, 0, 92, 156, 96, 125, 0, 93,
1141 156, 96, 125, 0, 94, 156, 96, 125, 0, 87,
1142 163, 0, 166, 121, 123, 155, 98, 165, 99, 0,
1143 170, 0, 96, 164, 0, 0, 34, 0, 0, 81,
1144 125, 122, 0, 81, 125, 96, 15, 155, 122, 0,
1145 82, 125, 122, 0, 82, 125, 96, 15, 155, 122,
1146 0, 83, 156, 0, 169, 84, 125, 155, 0, 169,
1147 85, 156, 96, 125, 155, 0, 86, 125, 155, 168,
1154 static const short yyrline[] = { 0,
1155 983, 984, 991, 992, 1001, 1001, 1001, 1001, 1001, 1002,
1156 1002, 1002, 1003, 1003, 1003, 1003, 1003, 1003, 1005, 1005,
1157 1009, 1009, 1009, 1009, 1010, 1010, 1010, 1010, 1011, 1011,
1158 1012, 1012, 1015, 1018, 1022, 1022, 1023, 1024, 1025, 1028,
1159 1028, 1029, 1030, 1031, 1040, 1040, 1050, 1050, 1051, 1051,
1160 1053, 1062, 1062, 1062, 1062, 1062, 1062, 1062, 1063, 1063,
1161 1063, 1063, 1063, 1063, 1064, 1067, 1070, 1076, 1083, 1095,
1162 1099, 1110, 1119, 1122, 1130, 1134, 1139, 1140, 1143, 1146,
1163 1156, 1181, 1194, 1222, 1247, 1267, 1279, 1288, 1292, 1351,
1164 1357, 1365, 1370, 1375, 1378, 1381, 1388, 1398, 1429, 1436,
1165 1457, 1464, 1469, 1479, 1482, 1489, 1489, 1499, 1506, 1510,
1166 1513, 1516, 1529, 1549, 1551, 1555, 1559, 1561, 1563, 1568,
1167 1569, 1571, 1574, 1582, 1587, 1589, 1593, 1597, 1605, 1605,
1168 1606, 1606, 1608, 1614, 1619, 1625, 1628, 1633, 1637, 1641,
1169 1721, 1721, 1723, 1731, 1731, 1733, 1737, 1737, 1746, 1749,
1170 1752, 1755, 1758, 1761, 1764, 1767, 1791, 1798, 1801, 1806,
1171 1806, 1812, 1816, 1819, 1827, 1836, 1840, 1850, 1861, 1864,
1172 1867, 1870, 1873, 1887, 1891, 1944, 1947, 1953, 1961, 1971,
1173 1978, 1983, 1990, 1994, 2000, 2000, 2002, 2005, 2011, 2023,
1174 2031, 2041, 2053, 2060, 2067, 2074, 2079, 2098, 2120, 2134,
1175 2191, 2197, 2199, 2203, 2206, 2212, 2219, 2226, 2233, 2240,
1181 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1183 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1184 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1185 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1186 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1187 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","VOLATILE","TO","DOTDOTDOT",
1188 "NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING","OPAQUE",
1189 "NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN",
1190 "DEPLIBS","CALL","TAIL","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR",
1191 "SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND",
1192 "OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA",
1193 "FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR",
1194 "VAARG","VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'",
1195 "']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps",
1196 "LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType",
1197 "OptAssign","OptLinkage","OptCallingConv","OptCAlign","TypesV","UpRTypesV","Types",
1198 "PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr","ConstVector",
1199 "GlobalType","Module","FunctionList","ConstPool","BigOrLittle","TargetDefinition",
1200 "LibrariesDefinition","LibList","Name","OptName","ArgVal","ArgListH","ArgList",
1201 "FunctionHeaderH","BEGIN","FunctionHeader","END","Function","FunctionProto",
1202 "@1","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList",
1203 "BasicBlock","InstructionList","BBTerminatorInst","JumpTable","Inst","PHIList",
1204 "ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList","OptVolatile",
1209 static const short yyr1[] = { 0,
1210 109, 109, 110, 110, 111, 111, 111, 111, 111, 112,
1211 112, 112, 113, 113, 113, 113, 113, 113, 114, 114,
1212 115, 115, 115, 115, 116, 116, 116, 116, 117, 117,
1213 118, 118, 119, 119, 120, 120, 120, 120, 120, 121,
1214 121, 121, 121, 121, 122, 122, 123, 123, 124, 124,
1215 125, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1216 126, 126, 126, 126, 127, 127, 127, 127, 127, 127,
1217 127, 127, 127, 127, 128, 128, 129, 129, 129, 129,
1218 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
1219 130, 130, 130, 130, 130, 130, 131, 131, 131, 131,
1220 131, 131, 131, 132, 132, 133, 133, 134, 135, 135,
1221 135, 135, 136, 136, 136, 136, 136, 136, 136, 137,
1222 137, 138, 138, 138, 139, 140, 140, 140, 141, 141,
1223 142, 142, 143, 144, 144, 145, 145, 145, 145, 146,
1224 147, 147, 148, 149, 149, 150, 152, 151, 153, 153,
1225 153, 153, 153, 153, 153, 153, 153, 154, 154, 155,
1226 155, 156, 157, 157, 158, 159, 159, 159, 160, 160,
1227 160, 160, 160, 160, 160, 160, 160, 161, 161, 162,
1228 163, 163, 164, 164, 165, 165, 166, 166, 167, 167,
1229 167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
1230 167, 168, 168, 169, 169, 170, 170, 170, 170, 170,
1234 static const short yyr2[] = { 0,
1235 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1236 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1237 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1238 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1239 1, 1, 1, 2, 0, 3, 1, 1, 1, 1,
1240 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1241 1, 1, 1, 1, 1, 1, 1, 2, 4, 5,
1242 5, 3, 2, 2, 1, 3, 1, 3, 1, 0,
1243 4, 3, 3, 4, 4, 3, 2, 2, 2, 2,
1244 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1245 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
1246 2, 1, 4, 2, 5, 5, 3, 4, 0, 1,
1247 1, 3, 3, 3, 3, 3, 1, 0, 1, 1,
1248 1, 0, 2, 3, 1, 1, 3, 1, 0, 6,
1249 1, 1, 3, 1, 1, 2, 0, 3, 1, 1,
1250 1, 1, 1, 1, 1, 3, 1, 1, 1, 1,
1251 1, 2, 2, 2, 3, 2, 0, 1, 2, 2,
1252 3, 9, 9, 8, 13, 1, 1, 6, 5, 2,
1253 6, 7, 1, 3, 1, 0, 2, 1, 5, 5,
1254 5, 2, 4, 4, 6, 4, 4, 4, 2, 7,
1255 1, 2, 0, 1, 0, 3, 6, 3, 6, 2,
1259 static const short yydefact[] = { 119,
1260 39, 112, 111, 147, 35, 36, 37, 38, 40, 167,
1261 109, 110, 167, 129, 130, 0, 0, 39, 0, 114,
1262 40, 0, 41, 42, 43, 0, 0, 168, 164, 34,
1263 144, 145, 146, 163, 0, 0, 0, 117, 0, 0,
1264 0, 0, 33, 148, 44, 1, 2, 48, 52, 53,
1265 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
1266 64, 65, 0, 0, 0, 0, 158, 0, 0, 47,
1267 66, 51, 159, 67, 141, 142, 143, 205, 166, 0,
1268 0, 0, 128, 118, 113, 106, 107, 0, 0, 68,
1269 0, 0, 50, 73, 75, 0, 0, 80, 74, 204,
1270 0, 188, 0, 0, 0, 0, 40, 176, 177, 5,
1271 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1272 16, 17, 18, 0, 0, 0, 0, 0, 0, 0,
1273 19, 20, 0, 0, 0, 0, 0, 0, 0, 165,
1274 40, 180, 0, 201, 124, 121, 120, 122, 123, 127,
1275 0, 116, 52, 53, 54, 55, 56, 57, 58, 59,
1276 60, 61, 62, 0, 0, 0, 0, 115, 0, 0,
1277 0, 72, 139, 79, 77, 0, 0, 192, 187, 170,
1278 169, 0, 0, 24, 28, 23, 27, 22, 26, 21,
1279 25, 29, 30, 0, 0, 45, 45, 210, 0, 0,
1280 199, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1281 0, 0, 0, 0, 125, 94, 95, 3, 4, 92,
1282 93, 96, 91, 87, 88, 0, 0, 0, 0, 0,
1283 0, 0, 0, 0, 0, 0, 90, 89, 49, 49,
1284 76, 138, 132, 135, 136, 0, 0, 69, 149, 150,
1285 151, 152, 153, 154, 155, 0, 157, 161, 160, 162,
1286 0, 171, 0, 0, 0, 206, 0, 208, 203, 0,
1287 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1288 0, 0, 0, 126, 0, 0, 0, 82, 105, 0,
1289 0, 86, 0, 83, 0, 0, 0, 0, 70, 71,
1290 131, 133, 0, 140, 78, 0, 0, 0, 0, 0,
1291 0, 0, 0, 213, 0, 0, 194, 0, 196, 197,
1292 198, 0, 0, 0, 193, 0, 211, 0, 203, 0,
1293 0, 0, 81, 84, 85, 0, 0, 0, 0, 137,
1294 134, 156, 0, 0, 186, 45, 46, 45, 183, 202,
1295 0, 0, 0, 189, 190, 191, 186, 0, 0, 0,
1296 0, 104, 0, 0, 0, 0, 0, 0, 185, 0,
1297 0, 207, 209, 0, 0, 0, 195, 0, 212, 98,
1298 0, 0, 0, 0, 0, 0, 0, 0, 0, 184,
1299 181, 0, 200, 97, 0, 100, 101, 102, 103, 0,
1300 174, 0, 0, 0, 182, 0, 172, 0, 173, 0,
1301 0, 99, 0, 0, 0, 0, 0, 0, 179, 0,
1302 0, 178, 175, 0, 0, 0
1305 static const short yydefgoto[] = { 67,
1306 220, 233, 234, 235, 236, 164, 165, 194, 166, 18,
1307 9, 26, 266, 68, 69, 167, 71, 72, 96, 176,
1308 289, 257, 290, 88, 424, 1, 2, 148, 38, 84,
1309 151, 73, 302, 244, 245, 246, 27, 77, 10, 33,
1310 11, 12, 21, 258, 74, 260, 349, 13, 29, 30,
1311 140, 403, 79, 201, 369, 370, 141, 142, 314, 143,
1315 static const short yypact[] = {-32768,
1316 15, 304,-32768,-32768,-32768,-32768,-32768,-32768, 104, -16,
1317 -32768,-32768, -13,-32768,-32768, -27, -69, 23, -57,-32768,
1318 104, 88,-32768,-32768,-32768, 954, -18,-32768,-32768, 50,
1319 -32768,-32768,-32768,-32768, -34, -22, 10,-32768, -5, 954,
1320 58, 58,-32768,-32768,-32768,-32768,-32768, 17,-32768,-32768,
1321 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1322 -32768,-32768, 126, 142, 148, 531,-32768, 50, 61,-32768,
1323 -32768, -30,-32768,-32768,-32768,-32768,-32768, 1111,-32768, 150,
1324 66, 166, 153,-32768,-32768,-32768,-32768, 991, 1028,-32768,
1325 74, 77,-32768,-32768, -30, -36, 81, 769,-32768,-32768,
1326 991,-32768, 125, 1065, 3, 123, 104,-32768,-32768,-32768,
1327 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1328 -32768,-32768,-32768, 991, 991, 991, 991, 991, 991, 991,
1329 -32768,-32768, 991, 991, 991, 991, 991, 991, 991,-32768,
1330 104,-32768, 57,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1331 -8,-32768, 117, 146, 177, 151, 178, 162, 179, 164,
1332 180, 182, 183, 169, 187, 185, 407,-32768, 991, 991,
1333 991,-32768, 806,-32768, 97, 95, 595,-32768,-32768, 17,
1334 -32768, 595, 595,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1335 -32768,-32768,-32768, 595, 954, 100, 101,-32768, 595, 98,
1336 103, 165, 106, 107, 111, 112, 595, 595, 595, 113,
1337 954, 991, 991, 186,-32768,-32768,-32768,-32768,-32768,-32768,
1338 -32768,-32768,-32768,-32768,-32768, 120, 122, 124, 843, 1028,
1339 552, 188, 127, 128, 129, 130,-32768,-32768, -31, -65,
1340 -30,-32768, 50,-32768, 115, 133, 880,-32768,-32768,-32768,
1341 -32768,-32768,-32768,-32768,-32768, 1028,-32768,-32768,-32768,-32768,
1342 137,-32768, 138, 595, -6,-32768, -2,-32768, 139, 595,
1343 121, 991, 991, 991, 991, 991, 140, 141, 143, 991,
1344 595, 595, 144,-32768, 1028, 1028, 1028,-32768,-32768, 18,
1345 -7,-32768, 0,-32768, 1028, 1028, 1028, 1028,-32768,-32768,
1346 -32768,-32768, 917,-32768,-32768, 25, 202, 203, 131, 595,
1347 234, 595, 991,-32768, 145, 595,-32768, 147,-32768,-32768,
1348 -32768, 595, 595, 595,-32768, 154,-32768, 991, 139, 209,
1349 149, 1028,-32768,-32768,-32768, 157, 159, 160, 161,-32768,
1350 -32768,-32768, 595, 595, 991, 167,-32768, 167,-32768, 168,
1351 595, 170, 991,-32768,-32768,-32768, 991, 595, 163, 991,
1352 1028,-32768, 1028, 1028, 1028, 1028, 171, 158, 168, 175,
1353 207,-32768,-32768, 991, 173, 595,-32768, 191,-32768,-32768,
1354 192, 174, 195, 196, 199, 200, 248, 20, 241,-32768,
1355 -32768, 176,-32768,-32768, 1028,-32768,-32768,-32768,-32768, 595,
1356 -32768, 673, 69, 258,-32768, 205,-32768, 210,-32768, 673,
1357 595,-32768, 260, 213, 240, 595, 289, 290,-32768, 595,
1358 595,-32768,-32768, 312, 315,-32768
1361 static const short yypgoto[] = {-32768,
1362 -32768, 238, 239, 242, 251, -102, -100, -385,-32768, 288,
1363 314, -82, -195, -35,-32768, -26,-32768, -46, 232,-32768,
1364 -81, 172, -203, 291,-32768,-32768,-32768,-32768,-32768,-32768,
1365 -32768, -1,-32768, 35,-32768,-32768, 319,-32768,-32768,-32768,
1366 -32768, 339,-32768, -283, -51, 114, -85,-32768, 329,-32768,
1367 -32768,-32768,-32768,-32768, 30, -4,-32768,-32768, 26,-32768,
1375 static const short yytable[] = { 70,
1376 19, 268, 402, 192, 85, 193, 28, 168, 310, 28,
1377 75, 182, 312, 70, -108, 178, 31, 410, 181, 95,
1378 35, 36, 37, 183, 195, 39, 291, 293, 19, 184,
1379 185, 186, 187, 188, 189, 190, 191, 43, 300, 3,
1380 198, 99, 40, 202, 203, 4, 311, 204, 205, 206,
1381 311, 95, 306, 210, 5, 6, 7, 8, 211, 171,
1382 80, 152, 5, 6, 7, 8, 97, -49, 41, 172,
1383 299, 14, 81, 15, 177, 99, 99, 177, 184, 185,
1384 186, 187, 188, 189, 190, 191, 76, 214, 332, 86,
1385 87, 45, 32, 215, 83, 332, 334, 196, 197, 177,
1386 199, 200, 177, 177, 82, 335, 177, 177, 177, 207,
1387 208, 209, 177, 332, -50, 238, 146, 147, 408, 333,
1388 332, 401, 239, 240, 241, 259, 414, 283, 342, 90,
1389 259, 259, 184, 185, 186, 187, 188, 189, 190, 191,
1390 212, 213, 259, 216, 217, 91, 243, 259, -24, -24,
1391 372, 92, 373, -23, -23, 259, 259, 259, 98, 264,
1392 22, 23, 24, 25, -22, -22, -21, -21, 70, 149,
1393 409, 218, 219, 145, 169, 281, 150, 170, 173, 179,
1394 -28, -27, -26, -25, 70, 282, 177, 318, -31, -32,
1395 221, 222, 247, 248, 325, 265, 267, 270, 271, 272,
1396 241, 273, 274, 329, 330, 331, 275, 276, 280, 284,
1397 303, 294, 259, 336, 337, 338, 339, 285, 259, 286,
1398 316, 287, 343, 344, 295, 296, 297, 298, 345, 259,
1399 259, 304, 307, 308, 313, 322, 323, 347, 324, 328,
1400 351, 301, 353, 360, 361, 317, 177, 319, 320, 321,
1401 362, 357, 363, 177, 364, 365, 366, 388, 259, 311,
1402 259, 380, 371, 374, 259, 376, 387, 377, 400, 395,
1403 259, 259, 259, 389, 391, 404, 243, 405, 411, 382,
1404 416, 383, 384, 385, 386, 192, 177, 193, 390, 393,
1405 394, 259, 259, 396, 397, 261, 262, 398, 399, 259,
1406 192, 358, 193, 412, 418, 413, 259, 263, 417, 420,
1407 421, 425, 269, 406, 426, 136, 137, 78, 177, 138,
1408 277, 278, 279, -34, 259, 14, 177, 15, 139, 175,
1409 177, 42, 89, 381, 4, -34, -34, 341, 237, 44,
1410 20, 34, 350, -34, -34, -34, -34, 177, 259, -34,
1411 16, 0, 378, 0, 359, 0, 0, 17, 0, 259,
1412 0, 0, 0, 0, 259, 0, 0, 0, 259, 259,
1413 0, 0, 0, 0, 0, 0, 0, 309, 0, 0,
1414 0, 0, 0, 315, 0, 0, 0, 0, 0, 0,
1415 0, 0, 0, 0, 326, 327, 0, 0, 0, 0,
1416 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1417 0, 46, 47, 0, 0, 0, 0, 0, 0, 0,
1418 0, 0, 0, 346, 0, 348, 0, 0, 14, 352,
1419 15, 0, 223, 0, 0, 354, 355, 356, 0, 0,
1420 0, 0, 0, 224, 225, 0, 0, 0, 0, 0,
1421 0, 0, 0, 0, 0, 0, 367, 368, 0, 0,
1422 0, 0, 0, 0, 375, 0, 0, 0, 0, 0,
1423 0, 379, 0, 110, 111, 112, 113, 114, 115, 116,
1424 117, 118, 119, 120, 121, 122, 123, 0, 0, 392,
1425 0, 0, 226, 0, 227, 228, 131, 132, 0, 0,
1426 0, 0, 0, 0, 0, 0, 229, 0, 0, 230,
1427 0, 231, 0, 407, 232, 0, 0, 0, 0, 0,
1428 0, 0, 0, 0, 415, 0, 0, 0, 0, 419,
1429 0, 0, 0, 422, 423, 46, 47, 0, 93, 49,
1430 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1431 60, 61, 14, 0, 15, 0, 46, 47, 0, 93,
1432 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
1433 163, 60, 61, 14, 62, 15, 0, 0, 0, 0,
1434 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1435 0, 0, 0, 0, 0, 62, 0, 249, 250, 46,
1436 47, 251, 0, 0, 0, 0, 0, 0, 0, 0,
1437 0, 0, 0, 0, 0, 0, 14, 0, 15, 0,
1438 0, 252, 253, 0, 0, 0, 0, 63, 0, 0,
1439 64, 254, 255, 65, 0, 66, 94, 0, 0, 0,
1440 0, 0, 0, 0, 0, 0, 0, 0, 63, 0,
1441 0, 64, 0, 0, 65, 0, 66, 292, 0, 0,
1442 0, 110, 111, 112, 113, 114, 115, 116, 117, 118,
1443 119, 120, 121, 122, 123, 249, 250, 0, 0, 251,
1444 226, 0, 227, 228, 131, 132, 0, 0, 0, 0,
1445 0, 0, 0, 0, 0, 0, 0, 256, 0, 252,
1446 253, 0, 0, 0, 0, 0, 0, 0, 0, 254,
1447 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1448 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1449 0, 0, 0, 0, 0, 0, 0, 0, 0, 110,
1450 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1451 121, 122, 123, 0, 0, 0, 0, 0, 226, 0,
1452 227, 228, 131, 132, 0, 0, 0, 0, 0, 0,
1453 0, 0, 0, 46, 47, 256, 93, 49, 50, 51,
1454 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1455 14, 0, 15, 0, 0, 0, 0, 0, 0, 0,
1456 0, 0, 0, 0, 174, 0, 0, 0, 0, 0,
1457 46, 47, 62, 93, 49, 50, 51, 52, 53, 54,
1458 55, 56, 57, 58, 59, 60, 61, 14, 0, 15,
1459 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1460 0, 242, 0, 0, 0, 0, 0, 46, 47, 62,
1461 93, 153, 154, 155, 156, 157, 158, 159, 160, 161,
1462 162, 163, 60, 61, 14, 63, 15, 0, 64, 0,
1463 0, 65, 0, 66, 0, 0, 0, 0, 0, 0,
1464 0, 0, 0, 0, 46, 47, 62, 93, 49, 50,
1465 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1466 61, 14, 63, 15, 0, 64, 0, 0, 65, 0,
1467 66, 0, 0, 0, 0, 305, 0, 0, 0, 0,
1468 0, 46, 47, 62, 93, 49, 50, 51, 52, 53,
1469 54, 55, 56, 57, 58, 59, 60, 61, 14, 63,
1470 15, 0, 64, 0, 288, 65, 0, 66, 0, 0,
1471 0, 0, 340, 0, 0, 0, 0, 0, 46, 47,
1472 62, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1473 57, 58, 59, 60, 61, 14, 63, 15, 0, 64,
1474 0, 0, 65, 0, 66, 0, 0, 0, 0, 0,
1475 0, 0, 0, 0, 0, 46, 47, 62, 93, 49,
1476 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1477 60, 61, 14, 63, 15, 0, 64, 0, 0, 65,
1478 0, 66, 0, 0, 0, 0, 0, 0, 0, 0,
1479 0, 0, 46, 47, 62, 93, 153, 154, 155, 156,
1480 157, 158, 159, 160, 161, 162, 163, 60, 61, 14,
1481 63, 15, 0, 64, 0, 0, 65, 0, 66, 0,
1482 0, 0, 0, 0, 0, 0, 0, 0, 0, 46,
1483 47, 62, 180, 49, 50, 51, 52, 53, 54, 55,
1484 56, 57, 58, 59, 60, 61, 14, 63, 15, 0,
1485 64, 0, 0, 65, 0, 66, 0, 0, 0, 0,
1486 0, 0, 0, 0, 0, 0, 0, 0, 62, 0,
1487 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1488 0, 0, 0, 0, 63, 0, 0, 64, 0, 0,
1489 65, 0, 66, 0, 0, 0, 0, 0, 0, 0,
1490 0, 0, 0, 0, 100, 0, 0, 0, 0, 0,
1491 0, 0, 0, 0, 0, 101, 0, 0, 0, 0,
1492 0, 63, 0, 0, 64, 102, 103, 65, 0, 66,
1493 0, 104, 105, 106, 107, 108, 109, 110, 111, 112,
1494 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1495 123, 124, 125, 126, 0, 0, 127, 128, 129, 130,
1496 131, 132, 133, 134, 135
1499 static const short yycheck[] = { 26,
1500 2, 197, 388, 106, 40, 106, 23, 89, 15, 23,
1501 29, 9, 15, 40, 0, 101, 30, 403, 104, 66,
1502 48, 49, 50, 21, 107, 95, 230, 231, 30, 10,
1503 11, 12, 13, 14, 15, 16, 17, 95, 104, 25,
1504 126, 107, 20, 129, 130, 31, 53, 133, 134, 135,
1505 53, 98, 256, 139, 40, 41, 42, 43, 141, 96,
1506 95, 88, 40, 41, 42, 43, 68, 98, 46, 106,
1507 102, 22, 95, 24, 101, 107, 107, 104, 10, 11,
1508 12, 13, 14, 15, 16, 17, 105, 96, 96, 32,
1509 33, 4, 106, 102, 100, 96, 104, 124, 125, 126,
1510 127, 128, 129, 130, 95, 106, 133, 134, 135, 136,
1511 137, 138, 139, 96, 98, 167, 51, 52, 402, 102,
1512 96, 102, 169, 170, 171, 177, 410, 213, 104, 4,
1513 182, 183, 10, 11, 12, 13, 14, 15, 16, 17,
1514 84, 85, 194, 27, 28, 4, 173, 199, 3, 4,
1515 346, 4, 348, 3, 4, 207, 208, 209, 98, 195,
1516 57, 58, 59, 60, 3, 4, 3, 4, 195, 4,
1517 102, 3, 4, 24, 101, 211, 24, 101, 98, 55,
1518 4, 4, 4, 4, 211, 212, 213, 273, 7, 7,
1519 4, 7, 96, 99, 280, 96, 96, 100, 96, 35,
1520 247, 96, 96, 285, 286, 287, 96, 96, 96, 24,
1521 96, 24, 264, 295, 296, 297, 298, 98, 270, 98,
1522 100, 98, 21, 21, 98, 98, 98, 98, 98, 281,
1523 282, 99, 96, 96, 96, 96, 96, 4, 96, 96,
1524 96, 243, 96, 35, 96, 272, 273, 274, 275, 276,
1525 332, 98, 96, 280, 96, 96, 96, 100, 310, 53,
1526 312, 99, 96, 96, 316, 96, 96, 353, 21, 96,
1527 322, 323, 324, 99, 102, 35, 303, 102, 21, 361,
1528 21, 363, 364, 365, 366, 388, 313, 388, 374, 99,
1529 99, 343, 344, 99, 99, 182, 183, 99, 99, 351,
1530 403, 328, 403, 99, 65, 96, 358, 194, 96, 21,
1531 21, 0, 199, 395, 0, 78, 78, 30, 345, 78,
1532 207, 208, 209, 20, 376, 22, 353, 24, 78, 98,
1533 357, 18, 42, 360, 31, 32, 33, 303, 167, 21,
1534 2, 13, 313, 40, 41, 42, 43, 374, 400, 46,
1535 47, -1, 357, -1, 329, -1, -1, 54, -1, 411,
1536 -1, -1, -1, -1, 416, -1, -1, -1, 420, 421,
1537 -1, -1, -1, -1, -1, -1, -1, 264, -1, -1,
1538 -1, -1, -1, 270, -1, -1, -1, -1, -1, -1,
1539 -1, -1, -1, -1, 281, 282, -1, -1, -1, -1,
1540 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1541 -1, 5, 6, -1, -1, -1, -1, -1, -1, -1,
1542 -1, -1, -1, 310, -1, 312, -1, -1, 22, 316,
1543 24, -1, 26, -1, -1, 322, 323, 324, -1, -1,
1544 -1, -1, -1, 37, 38, -1, -1, -1, -1, -1,
1545 -1, -1, -1, -1, -1, -1, 343, 344, -1, -1,
1546 -1, -1, -1, -1, 351, -1, -1, -1, -1, -1,
1547 -1, 358, -1, 67, 68, 69, 70, 71, 72, 73,
1548 74, 75, 76, 77, 78, 79, 80, -1, -1, 376,
1549 -1, -1, 86, -1, 88, 89, 90, 91, -1, -1,
1550 -1, -1, -1, -1, -1, -1, 100, -1, -1, 103,
1551 -1, 105, -1, 400, 108, -1, -1, -1, -1, -1,
1552 -1, -1, -1, -1, 411, -1, -1, -1, -1, 416,
1553 -1, -1, -1, 420, 421, 5, 6, -1, 8, 9,
1554 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1555 20, 21, 22, -1, 24, -1, 5, 6, -1, 8,
1556 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1557 19, 20, 21, 22, 44, 24, -1, -1, -1, -1,
1558 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1559 -1, -1, -1, -1, -1, 44, -1, 3, 4, 5,
1560 6, 7, -1, -1, -1, -1, -1, -1, -1, -1,
1561 -1, -1, -1, -1, -1, -1, 22, -1, 24, -1,
1562 -1, 27, 28, -1, -1, -1, -1, 97, -1, -1,
1563 100, 37, 38, 103, -1, 105, 106, -1, -1, -1,
1564 -1, -1, -1, -1, -1, -1, -1, -1, 97, -1,
1565 -1, 100, -1, -1, 103, -1, 105, 106, -1, -1,
1566 -1, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1567 76, 77, 78, 79, 80, 3, 4, -1, -1, 7,
1568 86, -1, 88, 89, 90, 91, -1, -1, -1, -1,
1569 -1, -1, -1, -1, -1, -1, -1, 103, -1, 27,
1570 28, -1, -1, -1, -1, -1, -1, -1, -1, 37,
1571 38, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1572 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1573 -1, -1, -1, -1, -1, -1, -1, -1, -1, 67,
1574 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1575 78, 79, 80, -1, -1, -1, -1, -1, 86, -1,
1576 88, 89, 90, 91, -1, -1, -1, -1, -1, -1,
1577 -1, -1, -1, 5, 6, 103, 8, 9, 10, 11,
1578 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1579 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
1580 -1, -1, -1, -1, 36, -1, -1, -1, -1, -1,
1581 5, 6, 44, 8, 9, 10, 11, 12, 13, 14,
1582 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1583 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1584 -1, 36, -1, -1, -1, -1, -1, 5, 6, 44,
1585 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1586 18, 19, 20, 21, 22, 97, 24, -1, 100, -1,
1587 -1, 103, -1, 105, -1, -1, -1, -1, -1, -1,
1588 -1, -1, -1, -1, 5, 6, 44, 8, 9, 10,
1589 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1590 21, 22, 97, 24, -1, 100, -1, -1, 103, -1,
1591 105, -1, -1, -1, -1, 36, -1, -1, -1, -1,
1592 -1, 5, 6, 44, 8, 9, 10, 11, 12, 13,
1593 14, 15, 16, 17, 18, 19, 20, 21, 22, 97,
1594 24, -1, 100, -1, 102, 103, -1, 105, -1, -1,
1595 -1, -1, 36, -1, -1, -1, -1, -1, 5, 6,
1596 44, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1597 17, 18, 19, 20, 21, 22, 97, 24, -1, 100,
1598 -1, -1, 103, -1, 105, -1, -1, -1, -1, -1,
1599 -1, -1, -1, -1, -1, 5, 6, 44, 8, 9,
1600 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1601 20, 21, 22, 97, 24, -1, 100, -1, -1, 103,
1602 -1, 105, -1, -1, -1, -1, -1, -1, -1, -1,
1603 -1, -1, 5, 6, 44, 8, 9, 10, 11, 12,
1604 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1605 97, 24, -1, 100, -1, -1, 103, -1, 105, -1,
1606 -1, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1607 6, 44, 8, 9, 10, 11, 12, 13, 14, 15,
1608 16, 17, 18, 19, 20, 21, 22, 97, 24, -1,
1609 100, -1, -1, 103, -1, 105, -1, -1, -1, -1,
1610 -1, -1, -1, -1, -1, -1, -1, -1, 44, -1,
1611 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1612 -1, -1, -1, -1, 97, -1, -1, 100, -1, -1,
1613 103, -1, 105, -1, -1, -1, -1, -1, -1, -1,
1614 -1, -1, -1, -1, 34, -1, -1, -1, -1, -1,
1615 -1, -1, -1, -1, -1, 45, -1, -1, -1, -1,
1616 -1, 97, -1, -1, 100, 55, 56, 103, -1, 105,
1617 -1, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1618 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1619 80, 81, 82, 83, -1, -1, 86, 87, 88, 89,
1622 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1623 #line 3 "/usr/share/bison.simple"
1624 /* This file comes from bison-1.28. */
1626 /* Skeleton output parser for bison,
1627 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1629 This program is free software; you can redistribute it and/or modify
1630 it under the terms of the GNU General Public License as published by
1631 the Free Software Foundation; either version 2, or (at your option)
1634 This program is distributed in the hope that it will be useful,
1635 but WITHOUT ANY WARRANTY; without even the implied warranty of
1636 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1637 GNU General Public License for more details.
1639 You should have received a copy of the GNU General Public License
1640 along with this program; if not, write to the Free Software
1641 Foundation, Inc., 59 Temple Place - Suite 330,
1642 Boston, MA 02111-1307, USA. */
1644 /* As a special exception, when this file is copied by Bison into a
1645 Bison output file, you may use that output file without restriction.
1646 This special exception was added by the Free Software Foundation
1647 in version 1.24 of Bison. */
1649 /* This is the parser code that is written into each bison parser
1650 when the %semantic_parser declaration is not specified in the grammar.
1651 It was written by Richard Stallman by simplifying the hairy parser
1652 used when %semantic_parser is specified. */
1654 #ifndef YYSTACK_USE_ALLOCA
1656 #define YYSTACK_USE_ALLOCA
1657 #else /* alloca not defined */
1659 #define YYSTACK_USE_ALLOCA
1660 #define alloca __builtin_alloca
1661 #else /* not GNU C. */
1662 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1663 #define YYSTACK_USE_ALLOCA
1665 #else /* not sparc */
1666 /* We think this test detects Watcom and Microsoft C. */
1667 /* This used to test MSDOS, but that is a bad idea
1668 since that symbol is in the user namespace. */
1669 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1670 #if 0 /* No need for malloc.h, which pollutes the namespace;
1671 instead, just don't use alloca. */
1674 #else /* not MSDOS, or __TURBOC__ */
1676 /* I don't know what this was needed for, but it pollutes the namespace.
1677 So I turned it off. rms, 2 May 1997. */
1678 /* #include <malloc.h> */
1680 #define YYSTACK_USE_ALLOCA
1681 #else /* not MSDOS, or __TURBOC__, or _AIX */
1683 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1684 and on HPUX 10. Eventually we can turn this on. */
1685 #define YYSTACK_USE_ALLOCA
1686 #define alloca __builtin_alloca
1689 #endif /* not _AIX */
1690 #endif /* not MSDOS, or __TURBOC__ */
1691 #endif /* not sparc */
1692 #endif /* not GNU C */
1693 #endif /* alloca not defined */
1694 #endif /* YYSTACK_USE_ALLOCA not defined */
1696 #ifdef YYSTACK_USE_ALLOCA
1697 #define YYSTACK_ALLOC alloca
1699 #define YYSTACK_ALLOC malloc
1702 /* Note: there must be only one dollar sign in this file.
1703 It is replaced by the list of actions, each action
1704 as one case of the switch. */
1706 #define yyerrok (yyerrstatus = 0)
1707 #define yyclearin (yychar = YYEMPTY)
1710 #define YYACCEPT goto yyacceptlab
1711 #define YYABORT goto yyabortlab
1712 #define YYERROR goto yyerrlab1
1713 /* Like YYERROR except do call yyerror.
1714 This remains here temporarily to ease the
1715 transition to the new meaning of YYERROR, for GCC.
1716 Once GCC version 2 has supplanted version 1, this can go. */
1717 #define YYFAIL goto yyerrlab
1718 #define YYRECOVERING() (!!yyerrstatus)
1719 #define YYBACKUP(token, value) \
1721 if (yychar == YYEMPTY && yylen == 1) \
1722 { yychar = (token), yylval = (value); \
1723 yychar1 = YYTRANSLATE (yychar); \
1728 { yyerror ("syntax error: cannot back up"); YYERROR; } \
1732 #define YYERRCODE 256
1735 #define YYLEX yylex()
1741 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
1743 #define YYLEX yylex(&yylval, &yylloc)
1745 #else /* not YYLSP_NEEDED */
1747 #define YYLEX yylex(&yylval, YYLEX_PARAM)
1749 #define YYLEX yylex(&yylval)
1751 #endif /* not YYLSP_NEEDED */
1754 /* If nonreentrant, generate the variables here */
1758 int yychar; /* the lookahead symbol */
1759 YYSTYPE yylval; /* the semantic value of the */
1760 /* lookahead symbol */
1763 YYLTYPE yylloc; /* location data for the lookahead */
1767 int yynerrs; /* number of parse errors so far */
1768 #endif /* not YYPURE */
1771 int yydebug; /* nonzero means print parse trace */
1772 /* Since this is uninitialized, it does not stop multiple parsers
1776 /* YYINITDEPTH indicates the initial size of the parser's stacks */
1779 #define YYINITDEPTH 200
1782 /* YYMAXDEPTH is the maximum size the stacks can grow to
1783 (effective only if the built-in stack extension method is used). */
1790 #define YYMAXDEPTH 10000
1793 /* Define __yy_memcpy. Note that the size argument
1794 should be passed with type unsigned int, because that is what the non-GCC
1795 definitions require. With GCC, __builtin_memcpy takes an arg
1796 of type size_t, but it can handle unsigned int. */
1798 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1799 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1800 #else /* not GNU C or C++ */
1803 /* This is the most reliable way to avoid incompatibilities
1804 in available built-in functions on various systems. */
1806 __yy_memcpy (to, from, count)
1811 register char *f = from;
1812 register char *t = to;
1813 register int i = count;
1819 #else /* __cplusplus */
1821 /* This is the most reliable way to avoid incompatibilities
1822 in available built-in functions on various systems. */
1824 __yy_memcpy (char *to, char *from, unsigned int count)
1826 register char *t = to;
1827 register char *f = from;
1828 register int i = count;
1837 #line 217 "/usr/share/bison.simple"
1839 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1840 into yyparse. The argument should have type void *.
1841 It should actually point to an object.
1842 Grammar actions can access the variable by casting it
1843 to the proper pointer type. */
1845 #ifdef YYPARSE_PARAM
1847 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1848 #define YYPARSE_PARAM_DECL
1849 #else /* not __cplusplus */
1850 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1851 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1852 #endif /* not __cplusplus */
1853 #else /* not YYPARSE_PARAM */
1854 #define YYPARSE_PARAM_ARG
1855 #define YYPARSE_PARAM_DECL
1856 #endif /* not YYPARSE_PARAM */
1858 /* Prevent warning if -Wstrict-prototypes. */
1860 #ifdef YYPARSE_PARAM
1861 int yyparse (void *);
1868 yyparse(YYPARSE_PARAM_ARG)
1871 register int yystate;
1873 register short *yyssp;
1874 register YYSTYPE *yyvsp;
1875 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1876 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1878 short yyssa[YYINITDEPTH]; /* the state stack */
1879 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1881 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1882 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1885 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1886 YYLTYPE *yyls = yylsa;
1889 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1891 #define YYPOPSTACK (yyvsp--, yyssp--)
1894 int yystacksize = YYINITDEPTH;
1895 int yyfree_stacks = 0;
1906 YYSTYPE yyval; /* the variable used to return */
1907 /* semantic values from the action */
1914 fprintf(stderr, "Starting parse\n");
1920 yychar = YYEMPTY; /* Cause a token to be read. */
1922 /* Initialize stack pointers.
1923 Waste one element of value and location stack
1924 so that they stay on the same level as the state stack.
1925 The wasted elements are never initialized. */
1933 /* Push a new state, which is found in yystate . */
1934 /* In all cases, when you get here, the value and location stacks
1935 have just been pushed. so pushing a state here evens the stacks. */
1940 if (yyssp >= yyss + yystacksize - 1)
1942 /* Give user a chance to reallocate the stack */
1943 /* Use copies of these so that the &'s don't force the real ones into memory. */
1944 YYSTYPE *yyvs1 = yyvs;
1945 short *yyss1 = yyss;
1947 YYLTYPE *yyls1 = yyls;
1950 /* Get the current used size of the three stacks, in elements. */
1951 int size = yyssp - yyss + 1;
1954 /* Each stack pointer address is followed by the size of
1955 the data in use in that stack, in bytes. */
1957 /* This used to be a conditional around just the two extra args,
1958 but that might be undefined if yyoverflow is a macro. */
1959 yyoverflow("parser stack overflow",
1960 &yyss1, size * sizeof (*yyssp),
1961 &yyvs1, size * sizeof (*yyvsp),
1962 &yyls1, size * sizeof (*yylsp),
1965 yyoverflow("parser stack overflow",
1966 &yyss1, size * sizeof (*yyssp),
1967 &yyvs1, size * sizeof (*yyvsp),
1971 yyss = yyss1; yyvs = yyvs1;
1975 #else /* no yyoverflow */
1976 /* Extend the stack our own way. */
1977 if (yystacksize >= YYMAXDEPTH)
1979 yyerror("parser stack overflow");
1991 if (yystacksize > YYMAXDEPTH)
1992 yystacksize = YYMAXDEPTH;
1993 #ifndef YYSTACK_USE_ALLOCA
1996 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
1997 __yy_memcpy ((char *)yyss, (char *)yyss1,
1998 size * (unsigned int) sizeof (*yyssp));
1999 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2000 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2001 size * (unsigned int) sizeof (*yyvsp));
2003 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2004 __yy_memcpy ((char *)yyls, (char *)yyls1,
2005 size * (unsigned int) sizeof (*yylsp));
2007 #endif /* no yyoverflow */
2009 yyssp = yyss + size - 1;
2010 yyvsp = yyvs + size - 1;
2012 yylsp = yyls + size - 1;
2017 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2020 if (yyssp >= yyss + yystacksize - 1)
2026 fprintf(stderr, "Entering state %d\n", yystate);
2032 /* Do appropriate processing given the current state. */
2033 /* Read a lookahead token if we need one and don't already have one. */
2036 /* First try to decide what to do without reference to lookahead token. */
2038 yyn = yypact[yystate];
2042 /* Not known => get a lookahead token if don't already have one. */
2044 /* yychar is either YYEMPTY or YYEOF
2045 or a valid token in external form. */
2047 if (yychar == YYEMPTY)
2051 fprintf(stderr, "Reading a token: ");
2056 /* Convert token to internal form (in yychar1) for indexing tables with */
2058 if (yychar <= 0) /* This means end of input. */
2061 yychar = YYEOF; /* Don't call YYLEX any more */
2065 fprintf(stderr, "Now at end of input.\n");
2070 yychar1 = YYTRANSLATE(yychar);
2075 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2076 /* Give the individual parser a way to print the precise meaning
2077 of a token, for further debugging info. */
2079 YYPRINT (stderr, yychar, yylval);
2081 fprintf (stderr, ")\n");
2087 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2092 /* yyn is what to do for this token type in this state.
2093 Negative => reduce, -yyn is rule number.
2094 Positive => shift, yyn is new state.
2095 New state is final state => don't bother to shift,
2096 just return success.
2097 0, or most negative number => error. */
2112 /* Shift the lookahead token. */
2116 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2119 /* Discard the token being shifted unless it is eof. */
2120 if (yychar != YYEOF)
2128 /* count tokens shifted since error; after three, turn off error status. */
2129 if (yyerrstatus) yyerrstatus--;
2134 /* Do the default action for the current state. */
2137 yyn = yydefact[yystate];
2141 /* Do a reduction. yyn is the number of a rule to reduce with. */
2145 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2152 fprintf (stderr, "Reducing via rule %d (line %d), ",
2155 /* Print the symbols being reduced, and their result. */
2156 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2157 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2158 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2166 #line 984 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2168 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2169 ThrowException("Value too large for type!");
2170 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2174 #line 992 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2176 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2177 ThrowException("Value too large for type!");
2178 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2182 #line 1015 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2184 yyval.StrVal = yyvsp[-1].StrVal;
2188 #line 1018 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2194 #line 1022 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2195 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2198 #line 1023 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2199 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2202 #line 1024 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2203 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2206 #line 1025 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2207 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2210 #line 1026 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2211 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2214 #line 1028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2215 { yyval.UIntVal = CallingConv::C; ;
2218 #line 1029 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2219 { yyval.UIntVal = CallingConv::C; ;
2222 #line 1030 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2223 { yyval.UIntVal = CallingConv::Fast; ;
2226 #line 1031 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2227 { yyval.UIntVal = CallingConv::Cold; ;
2230 #line 1032 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2232 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2233 ThrowException("Calling conv too large!");
2234 yyval.UIntVal = yyvsp[0].UInt64Val;
2238 #line 1040 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2239 { yyval.UIntVal = 0; ;
2242 #line 1041 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2243 { yyval.UIntVal = yyvsp[0].UInt64Val; ;
2246 #line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2247 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2250 #line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2251 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2254 #line 1053 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2256 if (!UpRefs.empty())
2257 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2258 yyval.TypeVal = yyvsp[0].TypeVal;
2262 #line 1064 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2264 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2268 #line 1067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2270 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2274 #line 1070 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2275 { // Named types are also simple types...
2276 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2280 #line 1076 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2281 { // Type UpReference
2282 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2283 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2284 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2285 yyval.TypeVal = new PATypeHolder(OT);
2286 UR_OUT("New Upreference!\n");
2290 #line 1083 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2291 { // Function derived type?
2292 std::vector<const Type*> Params;
2293 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2294 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2295 Params.push_back(*I);
2296 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2297 if (isVarArg) Params.pop_back();
2299 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2300 delete yyvsp[-1].TypeList; // Delete the argument list
2301 delete yyvsp[-3].TypeVal; // Delete the return type handle
2305 #line 1095 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2306 { // Sized array type?
2307 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2308 delete yyvsp[-1].TypeVal;
2312 #line 1099 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2313 { // Packed array type?
2314 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2315 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) {
2316 ThrowException("Unsigned result not equal to signed result");
2318 if(!ElemTy->isPrimitiveType()) {
2319 ThrowException("Elemental type of a PackedType must be primitive");
2321 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2322 delete yyvsp[-1].TypeVal;
2326 #line 1110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2327 { // Structure type?
2328 std::vector<const Type*> Elements;
2329 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2330 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2331 Elements.push_back(*I);
2333 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2334 delete yyvsp[-1].TypeList;
2338 #line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2339 { // Empty structure type?
2340 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2344 #line 1122 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2346 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2347 delete yyvsp[-1].TypeVal;
2351 #line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2353 yyval.TypeList = new std::list<PATypeHolder>();
2354 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2358 #line 1134 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2360 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2364 #line 1140 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2366 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2370 #line 1143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2372 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2376 #line 1146 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2378 yyval.TypeList = new std::list<PATypeHolder>();
2382 #line 1156 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2383 { // Nonempty unsized arr
2384 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2386 ThrowException("Cannot make array constant with type: '" +
2387 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2388 const Type *ETy = ATy->getElementType();
2389 int NumElements = ATy->getNumElements();
2391 // Verify that we have the correct size...
2392 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2393 ThrowException("Type mismatch: constant sized array initialized with " +
2394 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2395 itostr(NumElements) + "!");
2397 // Verify all elements are correct type!
2398 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2399 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2400 ThrowException("Element #" + utostr(i) + " is not of type '" +
2401 ETy->getDescription() +"' as required!\nIt is of type '"+
2402 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2405 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2406 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2410 #line 1181 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2412 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2414 ThrowException("Cannot make array constant with type: '" +
2415 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2417 int NumElements = ATy->getNumElements();
2418 if (NumElements != -1 && NumElements != 0)
2419 ThrowException("Type mismatch: constant sized array initialized with 0"
2420 " arguments, but has size of " + itostr(NumElements) +"!");
2421 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2422 delete yyvsp[-2].TypeVal;
2426 #line 1194 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2428 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2430 ThrowException("Cannot make array constant with type: '" +
2431 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2433 int NumElements = ATy->getNumElements();
2434 const Type *ETy = ATy->getElementType();
2435 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2436 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2437 ThrowException("Can't build string constant of size " +
2438 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2439 " when array has size " + itostr(NumElements) + "!");
2440 std::vector<Constant*> Vals;
2441 if (ETy == Type::SByteTy) {
2442 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2443 Vals.push_back(ConstantSInt::get(ETy, *C));
2444 } else if (ETy == Type::UByteTy) {
2445 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2446 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2448 free(yyvsp[0].StrVal);
2449 ThrowException("Cannot build string arrays of non byte sized elements!");
2451 free(yyvsp[0].StrVal);
2452 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2453 delete yyvsp[-2].TypeVal;
2457 #line 1222 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2458 { // Nonempty unsized arr
2459 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2461 ThrowException("Cannot make packed constant with type: '" +
2462 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2463 const Type *ETy = PTy->getElementType();
2464 int NumElements = PTy->getNumElements();
2466 // Verify that we have the correct size...
2467 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2468 ThrowException("Type mismatch: constant sized packed initialized with " +
2469 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2470 itostr(NumElements) + "!");
2472 // Verify all elements are correct type!
2473 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2474 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2475 ThrowException("Element #" + utostr(i) + " is not of type '" +
2476 ETy->getDescription() +"' as required!\nIt is of type '"+
2477 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2480 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2481 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2485 #line 1247 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2487 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2489 ThrowException("Cannot make struct constant with type: '" +
2490 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2492 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2493 ThrowException("Illegal number of initializers for structure type!");
2495 // Check to ensure that constants are compatible with the type initializer!
2496 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2497 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2498 ThrowException("Expected type '" +
2499 STy->getElementType(i)->getDescription() +
2500 "' for element #" + utostr(i) +
2501 " of structure initializer!");
2503 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2504 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2508 #line 1267 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2510 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2512 ThrowException("Cannot make struct constant with type: '" +
2513 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2515 if (STy->getNumContainedTypes() != 0)
2516 ThrowException("Illegal number of initializers for structure type!");
2518 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2519 delete yyvsp[-2].TypeVal;
2523 #line 1279 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2525 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2527 ThrowException("Cannot make null pointer constant with type: '" +
2528 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2530 yyval.ConstVal = ConstantPointerNull::get(PTy);
2531 delete yyvsp[-1].TypeVal;
2535 #line 1288 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2537 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2538 delete yyvsp[-1].TypeVal;
2542 #line 1292 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2544 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2546 ThrowException("Global const reference must be a pointer type!");
2548 // ConstExprs can exist in the body of a function, thus creating
2549 // GlobalValues whenever they refer to a variable. Because we are in
2550 // the context of a function, getValNonImprovising will search the functions
2551 // symbol table instead of the module symbol table for the global symbol,
2552 // which throws things all off. To get around this, we just tell
2553 // getValNonImprovising that we are at global scope here.
2555 Function *SavedCurFn = CurFun.CurrentFunction;
2556 CurFun.CurrentFunction = 0;
2558 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2560 CurFun.CurrentFunction = SavedCurFn;
2562 // If this is an initializer for a constant pointer, which is referencing a
2563 // (currently) undefined variable, create a stub now that shall be replaced
2564 // in the future with the right type of variable.
2567 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2568 const PointerType *PT = cast<PointerType>(Ty);
2570 // First check to see if the forward references value is already created!
2571 PerModuleInfo::GlobalRefsType::iterator I =
2572 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2574 if (I != CurModule.GlobalRefs.end()) {
2575 V = I->second; // Placeholder already exists, use it...
2576 yyvsp[0].ValIDVal.destroy();
2579 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2581 // Create the forward referenced global.
2583 if (const FunctionType *FTy =
2584 dyn_cast<FunctionType>(PT->getElementType())) {
2585 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2586 CurModule.CurrentModule);
2588 GV = new GlobalVariable(PT->getElementType(), false,
2589 GlobalValue::ExternalLinkage, 0,
2590 Name, CurModule.CurrentModule);
2593 // Keep track of the fact that we have a forward ref to recycle it
2594 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2599 yyval.ConstVal = cast<GlobalValue>(V);
2600 delete yyvsp[-1].TypeVal; // Free the type handle
2604 #line 1351 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2606 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2607 ThrowException("Mismatched types for constant expression!");
2608 yyval.ConstVal = yyvsp[0].ConstVal;
2609 delete yyvsp[-1].TypeVal;
2613 #line 1357 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2615 const Type *Ty = yyvsp[-1].TypeVal->get();
2616 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2617 ThrowException("Cannot create a null initialized value of this type!");
2618 yyval.ConstVal = Constant::getNullValue(Ty);
2619 delete yyvsp[-1].TypeVal;
2623 #line 1365 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2624 { // integral constants
2625 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2626 ThrowException("Constant value doesn't fit in type!");
2627 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
2631 #line 1370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2632 { // integral constants
2633 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2634 ThrowException("Constant value doesn't fit in type!");
2635 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
2639 #line 1375 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2640 { // Boolean constants
2641 yyval.ConstVal = ConstantBool::True;
2645 #line 1378 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2646 { // Boolean constants
2647 yyval.ConstVal = ConstantBool::False;
2651 #line 1381 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2652 { // Float & Double constants
2653 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2654 ThrowException("Floating point constant invalid for type!!");
2655 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
2659 #line 1388 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2661 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2662 ThrowException("cast constant expression from a non-primitive type: '" +
2663 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2664 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2665 ThrowException("cast constant expression to a non-primitive type: '" +
2666 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2667 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2668 delete yyvsp[-1].TypeVal;
2672 #line 1398 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2674 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2675 ThrowException("GetElementPtr requires a pointer operand!");
2677 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2678 // indices to uint struct indices for compatibility.
2679 generic_gep_type_iterator<std::vector<Value*>::iterator>
2680 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2681 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2682 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2683 if (isa<StructType>(*GTI)) // Only change struct indices
2684 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2685 if (CUI->getType() == Type::UByteTy)
2686 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2689 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2691 ThrowException("Index list invalid for constant getelementptr!");
2693 std::vector<Constant*> IdxVec;
2694 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2695 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2696 IdxVec.push_back(C);
2698 ThrowException("Indices to constant getelementptr must be constants!");
2700 delete yyvsp[-1].ValueList;
2702 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
2706 #line 1429 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2708 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2709 ThrowException("Select condition must be of boolean type!");
2710 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2711 ThrowException("Select operand types must match!");
2712 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2716 #line 1436 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2718 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2719 ThrowException("Binary operator types must match!");
2720 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2721 // To retain backward compatibility with these early compilers, we emit a
2722 // cast to the appropriate integer type automatically if we are in the
2723 // broken case. See PR424 for more information.
2724 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2725 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2727 const Type *IntPtrTy = 0;
2728 switch (CurModule.CurrentModule->getPointerSize()) {
2729 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2730 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2731 default: ThrowException("invalid pointer binary constant expr!");
2733 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2734 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2735 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2740 #line 1457 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2742 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2743 ThrowException("Logical operator types must match!");
2744 if (!yyvsp[-3].ConstVal->getType()->isIntegral())
2745 ThrowException("Logical operands must have integral types!");
2746 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2750 #line 1464 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2752 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2753 ThrowException("setcc operand types must match!");
2754 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2758 #line 1469 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2760 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2761 ThrowException("Shift count for shift constant must be unsigned byte!");
2762 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2763 ThrowException("Shift constant expression requires integer operand!");
2764 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2768 #line 1479 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2770 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
2774 #line 1482 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2776 yyval.ConstVector = new std::vector<Constant*>();
2777 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
2781 #line 1489 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2782 { yyval.BoolVal = false; ;
2785 #line 1489 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2786 { yyval.BoolVal = true; ;
2789 #line 1499 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2791 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2792 CurModule.ModuleDone();
2796 #line 1506 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2798 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2799 CurFun.FunctionDone();
2803 #line 1510 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2805 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2809 #line 1513 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2811 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2815 #line 1516 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2817 yyval.ModuleVal = CurModule.CurrentModule;
2818 // Emit an error if there are any unresolved types left.
2819 if (!CurModule.LateResolveTypes.empty()) {
2820 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2821 if (DID.Type == ValID::NameVal)
2822 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2824 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2829 #line 1529 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2831 // Eagerly resolve types. This is not an optimization, this is a
2832 // requirement that is due to the fact that we could have this:
2834 // %list = type { %list * }
2835 // %list = type { %list * } ; repeated type decl
2837 // If types are not resolved eagerly, then the two types will not be
2838 // determined to be the same type!
2840 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2842 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2843 // If this is a named type that is not a redefinition, add it to the slot
2845 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2848 delete yyvsp[0].TypeVal;
2852 #line 1549 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2853 { // Function prototypes can be in const pool
2857 #line 1551 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2859 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
2860 ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
2864 #line 1555 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2866 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
2867 delete yyvsp[0].TypeVal;
2871 #line 1559 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2876 #line 1561 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2881 #line 1563 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2886 #line 1568 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2887 { yyval.Endianness = Module::BigEndian; ;
2890 #line 1569 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2891 { yyval.Endianness = Module::LittleEndian; ;
2894 #line 1571 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2896 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
2900 #line 1574 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2902 if (yyvsp[0].UInt64Val == 32)
2903 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
2904 else if (yyvsp[0].UInt64Val == 64)
2905 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
2907 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
2911 #line 1582 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2913 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
2914 free(yyvsp[0].StrVal);
2918 #line 1589 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2920 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
2921 free(yyvsp[0].StrVal);
2925 #line 1593 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2927 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
2928 free(yyvsp[0].StrVal);
2932 #line 1597 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2937 #line 1606 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2938 { yyval.StrVal = 0; ;
2941 #line 1608 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2943 if (*yyvsp[-1].TypeVal == Type::VoidTy)
2944 ThrowException("void typed arguments are invalid!");
2945 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
2949 #line 1614 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2951 yyval.ArgList = yyvsp[-2].ArgList;
2952 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
2953 delete yyvsp[0].ArgVal;
2957 #line 1619 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2959 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
2960 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
2961 delete yyvsp[0].ArgVal;
2965 #line 1625 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2967 yyval.ArgList = yyvsp[0].ArgList;
2971 #line 1628 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2973 yyval.ArgList = yyvsp[-2].ArgList;
2974 yyval.ArgList->push_back(std::pair<PATypeHolder*,
2975 char*>(new PATypeHolder(Type::VoidTy), 0));
2979 #line 1633 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2981 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
2982 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
2986 #line 1637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2992 #line 1641 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2994 UnEscapeLexed(yyvsp[-3].StrVal);
2995 std::string FunctionName(yyvsp[-3].StrVal);
2996 free(yyvsp[-3].StrVal); // Free strdup'd memory!
2998 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
2999 ThrowException("LLVM functions cannot return aggregate types!");
3001 std::vector<const Type*> ParamTypeList;
3002 if (yyvsp[-1].ArgList) { // If there are arguments...
3003 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3004 I != yyvsp[-1].ArgList->end(); ++I)
3005 ParamTypeList.push_back(I->first->get());
3008 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3009 if (isVarArg) ParamTypeList.pop_back();
3011 const FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, ParamTypeList, isVarArg);
3012 const PointerType *PFT = PointerType::get(FT);
3013 delete yyvsp[-4].TypeVal;
3016 if (!FunctionName.empty()) {
3017 ID = ValID::create((char*)FunctionName.c_str());
3019 ID = ValID::create((int)CurModule.Values[PFT].size());
3023 // See if this function was forward referenced. If so, recycle the object.
3024 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3025 // Move the function to the end of the list, from whereever it was
3026 // previously inserted.
3027 Fn = cast<Function>(FWRef);
3028 CurModule.CurrentModule->getFunctionList().remove(Fn);
3029 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3030 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3031 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3032 // If this is the case, either we need to be a forward decl, or it needs
3034 if (!CurFun.isDeclare && !Fn->isExternal())
3035 ThrowException("Redefinition of function '" + FunctionName + "'!");
3037 // Make sure to strip off any argument names so we can't get conflicts.
3038 if (Fn->isExternal())
3039 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3043 } else { // Not already defined?
3044 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3045 CurModule.CurrentModule);
3046 InsertValue(Fn, CurModule.Values);
3049 CurFun.FunctionStart(Fn);
3050 Fn->setCallingConv(yyvsp[-5].UIntVal);
3052 // Add all of the arguments we parsed to the function...
3053 if (yyvsp[-1].ArgList) { // Is null if empty...
3054 if (isVarArg) { // Nuke the last entry
3055 assert(yyvsp[-1].ArgList->back().first->get() == Type::VoidTy && yyvsp[-1].ArgList->back().second == 0&&
3056 "Not a varargs marker!");
3057 delete yyvsp[-1].ArgList->back().first;
3058 yyvsp[-1].ArgList->pop_back(); // Delete the last entry
3060 Function::arg_iterator ArgIt = Fn->arg_begin();
3061 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3062 I != yyvsp[-1].ArgList->end(); ++I, ++ArgIt) {
3063 delete I->first; // Delete the typeholder...
3065 setValueName(ArgIt, I->second); // Insert arg into symtab...
3069 delete yyvsp[-1].ArgList; // We're now done with the argument list
3074 #line 1723 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3076 yyval.FunctionVal = CurFun.CurrentFunction;
3078 // Make sure that we keep track of the linkage type even if there was a
3079 // previous "declare".
3080 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3084 #line 1733 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3086 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3090 #line 1737 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3091 { CurFun.isDeclare = true; ;
3094 #line 1737 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3096 yyval.FunctionVal = CurFun.CurrentFunction;
3097 CurFun.FunctionDone();
3101 #line 1746 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3102 { // A reference to a direct constant
3103 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3107 #line 1749 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3109 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3113 #line 1752 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3114 { // Perhaps it's an FP constant?
3115 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3119 #line 1755 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3121 yyval.ValIDVal = ValID::create(ConstantBool::True);
3125 #line 1758 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3127 yyval.ValIDVal = ValID::create(ConstantBool::False);
3131 #line 1761 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3133 yyval.ValIDVal = ValID::createNull();
3137 #line 1764 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3139 yyval.ValIDVal = ValID::createUndef();
3143 #line 1767 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3144 { // Nonempty unsized packed vector
3145 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3146 int NumElements = yyvsp[-1].ConstVector->size();
3148 PackedType* pt = PackedType::get(ETy, NumElements);
3149 PATypeHolder* PTy = new PATypeHolder(
3157 // Verify all elements are correct type!
3158 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3159 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3160 ThrowException("Element #" + utostr(i) + " is not of type '" +
3161 ETy->getDescription() +"' as required!\nIt is of type '" +
3162 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3165 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3166 delete PTy; delete yyvsp[-1].ConstVector;
3170 #line 1791 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3172 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3176 #line 1798 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3177 { // Is it an integer reference...?
3178 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3182 #line 1801 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3183 { // Is it a named reference...?
3184 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3188 #line 1812 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3190 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3194 #line 1816 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3196 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3200 #line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3201 { // Do not allow functions with 0 basic blocks
3202 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3206 #line 1827 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3208 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3209 InsertValue(yyvsp[0].TermInstVal);
3211 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3212 InsertValue(yyvsp[-2].BasicBlockVal);
3213 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3217 #line 1836 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3219 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3220 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3224 #line 1840 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3226 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3228 // Make sure to move the basic block to the correct location in the
3229 // function, instead of leaving it inserted wherever it was first
3231 Function::BasicBlockListType &BBL =
3232 CurFun.CurrentFunction->getBasicBlockList();
3233 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3237 #line 1850 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3239 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3241 // Make sure to move the basic block to the correct location in the
3242 // function, instead of leaving it inserted wherever it was first
3244 Function::BasicBlockListType &BBL =
3245 CurFun.CurrentFunction->getBasicBlockList();
3246 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3250 #line 1861 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3251 { // Return with a result...
3252 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3256 #line 1864 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3257 { // Return with no result...
3258 yyval.TermInstVal = new ReturnInst();
3262 #line 1867 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3263 { // Unconditional Branch...
3264 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3268 #line 1870 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3270 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3274 #line 1873 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3276 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3277 yyval.TermInstVal = S;
3279 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3280 E = yyvsp[-1].JumpTable->end();
3281 for (; I != E; ++I) {
3282 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3283 S->addCase(CI, I->second);
3285 ThrowException("Switch case is constant, but not a simple integer!");
3287 delete yyvsp[-1].JumpTable;
3291 #line 1887 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3293 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3294 yyval.TermInstVal = S;
3298 #line 1892 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3300 const PointerType *PFTy;
3301 const FunctionType *Ty;
3303 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3304 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3305 // Pull out the types of all of the arguments...
3306 std::vector<const Type*> ParamTypes;
3307 if (yyvsp[-7].ValueList) {
3308 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3310 ParamTypes.push_back((*I)->getType());
3313 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3314 if (isVarArg) ParamTypes.pop_back();
3316 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3317 PFTy = PointerType::get(Ty);
3320 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3322 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3323 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3325 // Create the call node...
3326 if (!yyvsp[-7].ValueList) { // Has no arguments?
3327 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3328 } else { // Has arguments?
3329 // Loop through FunctionType's arguments and ensure they are specified
3332 FunctionType::param_iterator I = Ty->param_begin();
3333 FunctionType::param_iterator E = Ty->param_end();
3334 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3336 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3337 if ((*ArgI)->getType() != *I)
3338 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3339 (*I)->getDescription() + "'!");
3341 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3342 ThrowException("Invalid number of parameters detected!");
3344 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3346 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3348 delete yyvsp[-10].TypeVal;
3349 delete yyvsp[-7].ValueList;
3353 #line 1944 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3355 yyval.TermInstVal = new UnwindInst();
3359 #line 1947 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3361 yyval.TermInstVal = new UnreachableInst();
3365 #line 1953 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3367 yyval.JumpTable = yyvsp[-5].JumpTable;
3368 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3370 ThrowException("May only switch on a constant pool value!");
3372 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3376 #line 1961 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3378 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3379 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3382 ThrowException("May only switch on a constant pool value!");
3384 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3388 #line 1971 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3390 // Is this definition named?? if so, assign the name...
3391 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3392 InsertValue(yyvsp[0].InstVal);
3393 yyval.InstVal = yyvsp[0].InstVal;
3397 #line 1978 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3398 { // Used for PHI nodes
3399 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3400 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3401 delete yyvsp[-5].TypeVal;
3405 #line 1983 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3407 yyval.PHIList = yyvsp[-6].PHIList;
3408 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3409 getBBVal(yyvsp[-1].ValIDVal)));
3413 #line 1990 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3414 { // Used for call statements, and memory insts...
3415 yyval.ValueList = new std::vector<Value*>();
3416 yyval.ValueList->push_back(yyvsp[0].ValueVal);
3420 #line 1994 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3422 yyval.ValueList = yyvsp[-2].ValueList;
3423 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
3427 #line 2000 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3428 { yyval.ValueList = 0; ;
3431 #line 2002 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3433 yyval.BoolVal = true;
3437 #line 2005 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3439 yyval.BoolVal = false;
3443 #line 2011 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3445 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3446 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3448 "Arithmetic operator requires integer, FP, or packed operands!");
3449 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3450 ThrowException("Rem not supported on packed types!");
3451 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3452 if (yyval.InstVal == 0)
3453 ThrowException("binary operator returned null!");
3454 delete yyvsp[-3].TypeVal;
3458 #line 2023 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3460 if (!(*yyvsp[-3].TypeVal)->isIntegral())
3461 ThrowException("Logical operator requires integral operands!");
3462 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3463 if (yyval.InstVal == 0)
3464 ThrowException("binary operator returned null!");
3465 delete yyvsp[-3].TypeVal;
3469 #line 2031 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3471 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3473 "PackedTypes currently not supported in setcc instructions!");
3475 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3476 if (yyval.InstVal == 0)
3477 ThrowException("binary operator returned null!");
3478 delete yyvsp[-3].TypeVal;
3482 #line 2041 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3484 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3485 << " Replacing with 'xor'.\n";
3487 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3489 ThrowException("Expected integral type for not instruction!");
3491 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3492 if (yyval.InstVal == 0)
3493 ThrowException("Could not create a xor instruction!");
3497 #line 2053 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3499 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3500 ThrowException("Shift amount must be ubyte!");
3501 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3502 ThrowException("Shift constant expression requires integer operand!");
3503 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3507 #line 2060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3509 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3510 ThrowException("cast instruction to a non-primitive type: '" +
3511 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3512 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3513 delete yyvsp[0].TypeVal;
3517 #line 2067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3519 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3520 ThrowException("select condition must be boolean!");
3521 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3522 ThrowException("select value types should match!");
3523 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3527 #line 2074 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3530 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3531 delete yyvsp[0].TypeVal;
3535 #line 2079 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3537 ObsoleteVarArgs = true;
3538 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3539 Function* NF = CurModule.CurrentModule->
3540 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3543 //foo = alloca 1 of t
3547 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3548 CurBB->getInstList().push_back(foo);
3549 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3550 CurBB->getInstList().push_back(bar);
3551 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3552 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3553 delete yyvsp[0].TypeVal;
3557 #line 2098 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3559 ObsoleteVarArgs = true;
3560 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3561 Function* NF = CurModule.CurrentModule->
3562 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3564 //b = vanext a, t ->
3565 //foo = alloca 1 of t
3568 //tmp = vaarg foo, t
3570 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3571 CurBB->getInstList().push_back(foo);
3572 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3573 CurBB->getInstList().push_back(bar);
3574 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3575 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3576 CurBB->getInstList().push_back(tmp);
3577 yyval.InstVal = new LoadInst(foo);
3578 delete yyvsp[0].TypeVal;
3582 #line 2120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3584 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3585 if (!Ty->isFirstClassType())
3586 ThrowException("PHI node operands must be of first class type!");
3587 yyval.InstVal = new PHINode(Ty);
3588 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3589 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3590 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3591 ThrowException("All elements of a PHI node must be of the same type!");
3592 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3593 yyvsp[0].PHIList->pop_front();
3595 delete yyvsp[0].PHIList; // Free the list...
3599 #line 2134 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3601 const PointerType *PFTy;
3602 const FunctionType *Ty;
3604 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3605 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3606 // Pull out the types of all of the arguments...
3607 std::vector<const Type*> ParamTypes;
3608 if (yyvsp[-1].ValueList) {
3609 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3611 ParamTypes.push_back((*I)->getType());
3614 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3615 if (isVarArg) ParamTypes.pop_back();
3617 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3618 ThrowException("LLVM functions cannot return aggregate types!");
3620 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3621 PFTy = PointerType::get(Ty);
3624 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3626 // Create the call node...
3627 if (!yyvsp[-1].ValueList) { // Has no arguments?
3628 // Make sure no arguments is a good thing!
3629 if (Ty->getNumParams() != 0)
3630 ThrowException("No arguments passed to a function that "
3631 "expects arguments!");
3633 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3634 } else { // Has arguments?
3635 // Loop through FunctionType's arguments and ensure they are specified
3638 FunctionType::param_iterator I = Ty->param_begin();
3639 FunctionType::param_iterator E = Ty->param_end();
3640 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3642 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3643 if ((*ArgI)->getType() != *I)
3644 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3645 (*I)->getDescription() + "'!");
3647 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3648 ThrowException("Invalid number of parameters detected!");
3650 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3652 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3653 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3654 delete yyvsp[-4].TypeVal;
3655 delete yyvsp[-1].ValueList;
3659 #line 2191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3661 yyval.InstVal = yyvsp[0].InstVal;
3665 #line 2197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3667 yyval.ValueList = yyvsp[0].ValueList;
3671 #line 2199 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3673 yyval.ValueList = new std::vector<Value*>();
3677 #line 2203 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3679 yyval.BoolVal = true;
3683 #line 2206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3685 yyval.BoolVal = false;
3689 #line 2212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3691 if (yyvsp[0].UIntVal & (yyvsp[0].UIntVal-1))
3692 ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) +
3693 "' is not a power of 2!");
3694 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3695 delete yyvsp[-1].TypeVal;
3699 #line 2219 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3701 if (yyvsp[0].UIntVal & (yyvsp[0].UIntVal-1))
3702 ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) +
3703 "' is not a power of 2!");
3704 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3705 delete yyvsp[-4].TypeVal;
3709 #line 2226 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3711 if (yyvsp[0].UIntVal & (yyvsp[0].UIntVal-1))
3712 ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) +
3713 "' is not a power of 2!");
3714 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3715 delete yyvsp[-1].TypeVal;
3719 #line 2233 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3721 if (yyvsp[0].UIntVal & (yyvsp[0].UIntVal-1))
3722 ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) +
3723 "' is not a power of 2!");
3724 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3725 delete yyvsp[-4].TypeVal;
3729 #line 2240 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3731 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3732 ThrowException("Trying to free nonpointer type " +
3733 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3734 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
3738 #line 2247 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3740 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3741 ThrowException("Can't load from nonpointer type: " +
3742 (*yyvsp[-1].TypeVal)->getDescription());
3743 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3744 ThrowException("Can't load from pointer of non-first-class type: " +
3745 (*yyvsp[-1].TypeVal)->getDescription());
3746 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3747 delete yyvsp[-1].TypeVal;
3751 #line 2257 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3753 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3755 ThrowException("Can't store to a nonpointer type: " +
3756 (*yyvsp[-1].TypeVal)->getDescription());
3757 const Type *ElTy = PT->getElementType();
3758 if (ElTy != yyvsp[-3].ValueVal->getType())
3759 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3760 "' into space of type '" + ElTy->getDescription() + "'!");
3762 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3763 delete yyvsp[-1].TypeVal;
3767 #line 2270 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3769 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3770 ThrowException("getelementptr insn requires pointer operand!");
3772 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3773 // indices to uint struct indices for compatibility.
3774 generic_gep_type_iterator<std::vector<Value*>::iterator>
3775 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3776 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3777 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3778 if (isa<StructType>(*GTI)) // Only change struct indices
3779 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3780 if (CUI->getType() == Type::UByteTy)
3781 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3783 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3784 ThrowException("Invalid getelementptr indices for type '" +
3785 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3786 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3787 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
3791 /* the action file gets copied in in place of this dollarsign */
3792 #line 543 "/usr/share/bison.simple"
3803 short *ssp1 = yyss - 1;
3804 fprintf (stderr, "state stack now");
3805 while (ssp1 != yyssp)
3806 fprintf (stderr, " %d", *++ssp1);
3807 fprintf (stderr, "\n");
3817 yylsp->first_line = yylloc.first_line;
3818 yylsp->first_column = yylloc.first_column;
3819 yylsp->last_line = (yylsp-1)->last_line;
3820 yylsp->last_column = (yylsp-1)->last_column;
3825 yylsp->last_line = (yylsp+yylen-1)->last_line;
3826 yylsp->last_column = (yylsp+yylen-1)->last_column;
3830 /* Now "shift" the result of the reduction.
3831 Determine what state that goes to,
3832 based on the state we popped back to
3833 and the rule number reduced by. */
3837 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
3838 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
3839 yystate = yytable[yystate];
3841 yystate = yydefgoto[yyn - YYNTBASE];
3845 yyerrlab: /* here on detecting error */
3848 /* If not already recovering from an error, report this error. */
3852 #ifdef YYERROR_VERBOSE
3853 yyn = yypact[yystate];
3855 if (yyn > YYFLAG && yyn < YYLAST)
3862 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
3863 for (x = (yyn < 0 ? -yyn : 0);
3864 x < (sizeof(yytname) / sizeof(char *)); x++)
3865 if (yycheck[x + yyn] == x)
3866 size += strlen(yytname[x]) + 15, count++;
3867 msg = (char *) malloc(size + 15);
3870 strcpy(msg, "parse error");
3875 for (x = (yyn < 0 ? -yyn : 0);
3876 x < (sizeof(yytname) / sizeof(char *)); x++)
3877 if (yycheck[x + yyn] == x)
3879 strcat(msg, count == 0 ? ", expecting `" : " or `");
3880 strcat(msg, yytname[x]);
3889 yyerror ("parse error; also virtual memory exceeded");
3892 #endif /* YYERROR_VERBOSE */
3893 yyerror("parse error");
3897 yyerrlab1: /* here on error raised explicitly by an action */
3899 if (yyerrstatus == 3)
3901 /* if just tried and failed to reuse lookahead token after an error, discard it. */
3903 /* return failure if at end of input */
3904 if (yychar == YYEOF)
3909 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
3915 /* Else will try to reuse lookahead token
3916 after shifting the error token. */
3918 yyerrstatus = 3; /* Each real token shifted decrements this */
3922 yyerrdefault: /* current state does not do anything special for the error token. */
3925 /* This is wrong; only states that explicitly want error tokens
3926 should shift them. */
3927 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
3928 if (yyn) goto yydefault;
3931 yyerrpop: /* pop the current state because it cannot handle the error token */
3933 if (yyssp == yyss) YYABORT;
3943 short *ssp1 = yyss - 1;
3944 fprintf (stderr, "Error: state stack now");
3945 while (ssp1 != yyssp)
3946 fprintf (stderr, " %d", *++ssp1);
3947 fprintf (stderr, "\n");
3953 yyn = yypact[yystate];
3958 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
3977 fprintf(stderr, "Shifting error token, ");
3989 /* YYACCEPT comes here. */
4001 /* YYABORT comes here. */
4012 #line 2293 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4014 int yyerror(const char *ErrorMsg) {
4016 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4017 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4018 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4019 if (yychar == YYEMPTY || yychar == 0)
4020 errMsg += "end-of-file.";
4022 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4023 ThrowException(errMsg);