2 /* A Bison parser, made from /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 "/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 "/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] : 170)
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, 97,
1020 98, 106, 2, 107, 2, 2, 2, 2, 2, 2,
1021 2, 2, 2, 2, 2, 2, 2, 2, 2, 102,
1022 95, 103, 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 99, 96, 101, 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, 100,
1028 2, 2, 104, 2, 105, 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, 89, 91, 93, 95, 97,
1060 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1061 119, 121, 123, 125, 127, 129, 132, 137, 143, 149,
1062 153, 156, 159, 161, 165, 167, 171, 173, 174, 179,
1063 183, 187, 192, 197, 201, 204, 207, 210, 213, 216,
1064 219, 222, 225, 228, 231, 238, 244, 253, 260, 267,
1065 274, 281, 285, 287, 289, 291, 293, 296, 299, 302,
1066 304, 309, 312, 318, 324, 328, 333, 334, 336, 338,
1067 342, 346, 350, 354, 358, 360, 361, 363, 365, 367,
1068 368, 371, 375, 377, 379, 383, 385, 386, 393, 395,
1069 397, 401, 403, 405, 408, 409, 413, 415, 417, 419,
1070 421, 423, 425, 427, 431, 433, 435, 437, 439, 441,
1071 444, 447, 450, 454, 457, 458, 460, 463, 466, 470,
1072 480, 490, 499, 513, 515, 517, 524, 530, 533, 540,
1073 548, 550, 554, 556, 557, 560, 562, 568, 574, 580,
1074 583, 588, 593, 600, 605, 610, 615, 618, 626, 628,
1075 631, 632, 634, 635, 638, 644, 650, 659, 662, 668,
1076 674, 683, 686, 691, 698
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, 140, 95, 0, 0, 40, 0, 41,
1087 0, 42, 0, 43, 0, 0, 0, 58, 0, 59,
1088 0, 60, 0, 57, 4, 0, 124, 0, 8, 0,
1089 126, 0, 8, 0, 126, 0, 9, 0, 10, 0,
1090 11, 0, 12, 0, 13, 0, 14, 0, 15, 0,
1091 16, 0, 17, 0, 18, 0, 19, 0, 20, 0,
1092 21, 0, 44, 0, 125, 0, 153, 0, 96, 4,
1093 0, 123, 97, 128, 98, 0, 99, 4, 100, 126,
1094 101, 0, 102, 4, 100, 126, 103, 0, 104, 127,
1095 105, 0, 104, 105, 0, 126, 106, 0, 126, 0,
1096 127, 107, 126, 0, 127, 0, 127, 107, 36, 0,
1097 36, 0, 0, 124, 99, 131, 101, 0, 124, 99,
1098 101, 0, 124, 108, 24, 0, 124, 102, 131, 103,
1099 0, 124, 104, 131, 105, 0, 124, 104, 105, 0,
1100 124, 37, 0, 124, 38, 0, 124, 153, 0, 124,
1101 130, 0, 124, 26, 0, 115, 110, 0, 116, 4,
1102 0, 9, 27, 0, 9, 28, 0, 118, 7, 0,
1103 88, 97, 129, 35, 124, 98, 0, 86, 97, 129,
1104 167, 98, 0, 89, 97, 129, 107, 129, 107, 129,
1105 98, 0, 111, 97, 129, 107, 129, 98, 0, 112,
1106 97, 129, 107, 129, 98, 0, 113, 97, 129, 107,
1107 129, 98, 0, 114, 97, 129, 107, 129, 98, 0,
1108 131, 107, 129, 0, 129, 0, 32, 0, 33, 0,
1109 134, 0, 134, 149, 0, 134, 150, 0, 134, 25,
1110 0, 135, 0, 135, 119, 20, 122, 0, 135, 150,
1111 0, 135, 119, 120, 132, 129, 0, 135, 119, 46,
1112 132, 124, 0, 135, 47, 137, 0, 135, 54, 95,
1113 138, 0, 0, 52, 0, 51, 0, 49, 95, 136,
1114 0, 50, 95, 4, 0, 48, 95, 24, 0, 99,
1115 139, 101, 0, 139, 107, 24, 0, 24, 0, 0,
1116 22, 0, 24, 0, 140, 0, 0, 124, 141, 0,
1117 143, 107, 142, 0, 142, 0, 143, 0, 143, 107,
1118 36, 0, 36, 0, 0, 121, 122, 140, 97, 144,
1119 98, 0, 29, 0, 104, 0, 120, 145, 146, 0,
1120 30, 0, 105, 0, 156, 148, 0, 0, 31, 151,
1121 145, 0, 3, 0, 4, 0, 7, 0, 27, 0,
1122 28, 0, 37, 0, 38, 0, 102, 131, 103, 0,
1123 130, 0, 109, 0, 140, 0, 153, 0, 152, 0,
1124 124, 154, 0, 156, 157, 0, 147, 157, 0, 158,
1125 119, 159, 0, 158, 161, 0, 0, 23, 0, 61,
1126 155, 0, 61, 8, 0, 62, 21, 154, 0, 62,
1127 9, 154, 107, 21, 154, 107, 21, 154, 0, 63,
1128 117, 154, 107, 21, 154, 99, 160, 101, 0, 63,
1129 117, 154, 107, 21, 154, 99, 101, 0, 64, 121,
1130 122, 154, 97, 164, 98, 35, 21, 154, 65, 21,
1131 154, 0, 65, 0, 66, 0, 160, 117, 152, 107,
1132 21, 154, 0, 117, 152, 107, 21, 154, 0, 119,
1133 166, 0, 124, 99, 154, 107, 154, 101, 0, 162,
1134 107, 99, 154, 107, 154, 101, 0, 155, 0, 163,
1135 107, 155, 0, 163, 0, 0, 56, 55, 0, 55,
1136 0, 111, 124, 154, 107, 154, 0, 112, 124, 154,
1137 107, 154, 0, 113, 124, 154, 107, 154, 0, 45,
1138 155, 0, 114, 155, 107, 155, 0, 88, 155, 35,
1139 124, 0, 89, 155, 107, 155, 107, 155, 0, 92,
1140 155, 107, 124, 0, 93, 155, 107, 124, 0, 94,
1141 155, 107, 124, 0, 87, 162, 0, 165, 121, 122,
1142 154, 97, 164, 98, 0, 169, 0, 107, 163, 0,
1143 0, 34, 0, 0, 81, 124, 0, 81, 124, 107,
1144 53, 4, 0, 81, 124, 107, 15, 154, 0, 81,
1145 124, 107, 15, 154, 107, 53, 4, 0, 82, 124,
1146 0, 82, 124, 107, 53, 4, 0, 82, 124, 107,
1147 15, 154, 0, 82, 124, 107, 15, 154, 107, 53,
1148 4, 0, 83, 155, 0, 168, 84, 124, 154, 0,
1149 168, 85, 155, 107, 124, 154, 0, 86, 124, 154,
1156 static const short yyrline[] = { 0,
1157 983, 984, 991, 992, 1001, 1001, 1001, 1001, 1001, 1002,
1158 1002, 1002, 1003, 1003, 1003, 1003, 1003, 1003, 1005, 1005,
1159 1009, 1009, 1009, 1009, 1010, 1010, 1010, 1010, 1011, 1011,
1160 1012, 1012, 1015, 1018, 1022, 1022, 1023, 1024, 1025, 1028,
1161 1028, 1029, 1030, 1031, 1045, 1045, 1046, 1046, 1048, 1057,
1162 1057, 1057, 1057, 1057, 1057, 1057, 1058, 1058, 1058, 1058,
1163 1058, 1058, 1059, 1062, 1065, 1071, 1078, 1090, 1094, 1105,
1164 1114, 1117, 1125, 1129, 1134, 1135, 1138, 1141, 1151, 1176,
1165 1189, 1217, 1242, 1262, 1274, 1283, 1287, 1346, 1352, 1360,
1166 1365, 1370, 1373, 1376, 1383, 1393, 1424, 1431, 1452, 1459,
1167 1464, 1474, 1477, 1484, 1484, 1494, 1501, 1505, 1508, 1511,
1168 1524, 1544, 1546, 1550, 1554, 1556, 1558, 1563, 1564, 1566,
1169 1569, 1577, 1582, 1584, 1588, 1592, 1600, 1600, 1601, 1601,
1170 1603, 1609, 1614, 1620, 1623, 1628, 1632, 1636, 1716, 1716,
1171 1718, 1726, 1726, 1728, 1732, 1732, 1741, 1744, 1747, 1750,
1172 1753, 1756, 1759, 1762, 1786, 1793, 1796, 1801, 1801, 1807,
1173 1811, 1814, 1822, 1831, 1835, 1845, 1856, 1859, 1862, 1865,
1174 1868, 1882, 1886, 1939, 1942, 1948, 1956, 1966, 1973, 1978,
1175 1985, 1989, 1995, 1995, 1997, 2000, 2006, 2018, 2026, 2036,
1176 2048, 2055, 2062, 2069, 2074, 2093, 2115, 2129, 2186, 2192,
1177 2194, 2198, 2201, 2207, 2211, 2215, 2219, 2223, 2227, 2231,
1178 2235, 2239, 2246, 2256, 2269
1183 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1185 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1186 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1187 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1188 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1189 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","VOLATILE","TO","DOTDOTDOT",
1190 "NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING","OPAQUE",
1191 "NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN",
1192 "DEPLIBS","CALL","TAIL","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR",
1193 "SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND",
1194 "OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA",
1195 "FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR",
1196 "VAARG","VAARG_old","VANEXT_old","'='","'\\\\'","'('","')'","'['","'x'","']'",
1197 "'<'","'>'","'{'","'}'","'*'","','","'c'","INTVAL","EINT64VAL","ArithmeticOps",
1198 "LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType",
1199 "OptAssign","OptLinkage","OptCallingConv","TypesV","UpRTypesV","Types","PrimType",
1200 "UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType",
1201 "Module","FunctionList","ConstPool","BigOrLittle","TargetDefinition","LibrariesDefinition",
1202 "LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1203 "FunctionHeader","END","Function","FunctionProto","@1","ConstValueRef","SymbolicValueRef",
1204 "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1205 "JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal",
1206 "IndexList","OptVolatile","MemoryInst", NULL
1210 static const short yyr1[] = { 0,
1211 109, 109, 110, 110, 111, 111, 111, 111, 111, 112,
1212 112, 112, 113, 113, 113, 113, 113, 113, 114, 114,
1213 115, 115, 115, 115, 116, 116, 116, 116, 117, 117,
1214 118, 118, 119, 119, 120, 120, 120, 120, 120, 121,
1215 121, 121, 121, 121, 122, 122, 123, 123, 124, 125,
1216 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
1217 125, 125, 126, 126, 126, 126, 126, 126, 126, 126,
1218 126, 126, 127, 127, 128, 128, 128, 128, 129, 129,
1219 129, 129, 129, 129, 129, 129, 129, 129, 129, 129,
1220 129, 129, 129, 129, 130, 130, 130, 130, 130, 130,
1221 130, 131, 131, 132, 132, 133, 134, 134, 134, 134,
1222 135, 135, 135, 135, 135, 135, 135, 136, 136, 137,
1223 137, 137, 138, 139, 139, 139, 140, 140, 141, 141,
1224 142, 143, 143, 144, 144, 144, 144, 145, 146, 146,
1225 147, 148, 148, 149, 151, 150, 152, 152, 152, 152,
1226 152, 152, 152, 152, 152, 153, 153, 154, 154, 155,
1227 156, 156, 157, 158, 158, 158, 159, 159, 159, 159,
1228 159, 159, 159, 159, 159, 160, 160, 161, 162, 162,
1229 163, 163, 164, 164, 165, 165, 166, 166, 166, 166,
1230 166, 166, 166, 166, 166, 166, 166, 166, 166, 167,
1231 167, 168, 168, 169, 169, 169, 169, 169, 169, 169,
1232 169, 169, 169, 169, 169
1235 static const short yyr2[] = { 0,
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, 1, 1, 1, 1, 1, 1, 1, 1,
1239 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1240 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,
1241 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1242 1, 1, 1, 1, 1, 2, 4, 5, 5, 3,
1243 2, 2, 1, 3, 1, 3, 1, 0, 4, 3,
1244 3, 4, 4, 3, 2, 2, 2, 2, 2, 2,
1245 2, 2, 2, 2, 6, 5, 8, 6, 6, 6,
1246 6, 3, 1, 1, 1, 1, 2, 2, 2, 1,
1247 4, 2, 5, 5, 3, 4, 0, 1, 1, 3,
1248 3, 3, 3, 3, 1, 0, 1, 1, 1, 0,
1249 2, 3, 1, 1, 3, 1, 0, 6, 1, 1,
1250 3, 1, 1, 2, 0, 3, 1, 1, 1, 1,
1251 1, 1, 1, 3, 1, 1, 1, 1, 1, 2,
1252 2, 2, 3, 2, 0, 1, 2, 2, 3, 9,
1253 9, 8, 13, 1, 1, 6, 5, 2, 6, 7,
1254 1, 3, 1, 0, 2, 1, 5, 5, 5, 2,
1255 4, 4, 6, 4, 4, 4, 2, 7, 1, 2,
1256 0, 1, 0, 2, 5, 5, 8, 2, 5, 5,
1260 static const short yydefact[] = { 117,
1261 39, 110, 109, 145, 35, 36, 37, 38, 40, 165,
1262 107, 108, 165, 127, 128, 0, 0, 39, 0, 112,
1263 40, 0, 41, 42, 43, 0, 0, 166, 162, 34,
1264 142, 143, 144, 161, 0, 0, 0, 115, 0, 0,
1265 0, 0, 33, 146, 44, 1, 2, 46, 50, 51,
1266 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1267 62, 63, 0, 0, 0, 0, 156, 0, 0, 45,
1268 64, 49, 157, 65, 139, 140, 141, 203, 164, 0,
1269 0, 0, 126, 116, 111, 104, 105, 0, 0, 66,
1270 0, 0, 48, 71, 73, 0, 0, 78, 72, 202,
1271 0, 186, 0, 0, 0, 0, 40, 174, 175, 5,
1272 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1273 16, 17, 18, 0, 0, 0, 0, 0, 0, 0,
1274 19, 20, 0, 0, 0, 0, 0, 0, 0, 163,
1275 40, 178, 0, 199, 122, 119, 118, 120, 121, 125,
1276 0, 114, 50, 51, 52, 53, 54, 55, 56, 57,
1277 58, 59, 60, 0, 0, 0, 0, 113, 0, 0,
1278 70, 0, 137, 77, 75, 0, 0, 190, 185, 168,
1279 167, 0, 0, 24, 28, 23, 27, 22, 26, 21,
1280 25, 29, 30, 0, 0, 204, 208, 212, 0, 0,
1281 197, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1282 0, 0, 0, 123, 0, 92, 93, 3, 4, 90,
1283 91, 94, 89, 85, 86, 0, 0, 0, 0, 0,
1284 0, 0, 0, 0, 0, 0, 88, 87, 47, 47,
1285 74, 136, 130, 133, 134, 0, 0, 67, 147, 148,
1286 149, 150, 151, 152, 153, 0, 155, 159, 158, 160,
1287 0, 169, 0, 0, 0, 0, 201, 0, 0, 0,
1288 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1289 0, 124, 0, 0, 0, 80, 103, 0, 0, 84,
1290 0, 81, 0, 0, 0, 0, 68, 69, 129, 131,
1291 0, 138, 76, 0, 0, 0, 0, 0, 0, 0,
1292 0, 0, 215, 0, 0, 192, 0, 194, 195, 196,
1293 0, 0, 0, 191, 0, 213, 0, 201, 0, 0,
1294 79, 0, 82, 83, 0, 0, 0, 0, 135, 132,
1295 154, 0, 0, 184, 206, 205, 210, 209, 181, 200,
1296 0, 0, 0, 187, 188, 189, 184, 0, 0, 0,
1297 0, 102, 0, 0, 0, 0, 0, 0, 183, 0,
1298 0, 0, 0, 0, 0, 193, 0, 214, 96, 0,
1299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1300 182, 179, 0, 198, 95, 0, 98, 99, 100, 101,
1301 0, 172, 0, 0, 0, 207, 211, 180, 0, 170,
1302 0, 171, 0, 0, 97, 0, 0, 0, 0, 0,
1303 0, 177, 0, 0, 176, 173, 0, 0, 0
1306 static const short yydefgoto[] = { 67,
1307 220, 233, 234, 235, 236, 164, 165, 194, 166, 18,
1308 9, 26, 68, 69, 167, 71, 72, 96, 176, 287,
1309 257, 288, 88, 427, 1, 2, 148, 38, 84, 151,
1310 73, 300, 244, 245, 246, 27, 77, 10, 33, 11,
1311 12, 21, 258, 74, 260, 349, 13, 29, 30, 140,
1312 404, 79, 201, 369, 370, 141, 142, 313, 143, 144
1315 static const short yypact[] = {-32768,
1316 40, 341,-32768,-32768,-32768,-32768,-32768,-32768, 62, 12,
1317 -32768,-32768, -20,-32768,-32768, 110, -67, 48, -50,-32768,
1318 62, 65,-32768,-32768,-32768, 1073, -18,-32768,-32768, 71,
1319 -32768,-32768,-32768,-32768, -19, -8, 2,-32768, -15, 1073,
1320 31, 31,-32768,-32768,-32768,-32768,-32768, 8,-32768,-32768,
1321 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1322 -32768,-32768, 123, 152, 163, 120,-32768, 71, 17,-32768,
1323 -32768, -36,-32768,-32768,-32768,-32768,-32768, 1228,-32768, 148,
1324 72, 170, 164,-32768,-32768,-32768,-32768, 1136, 1173,-32768,
1325 89, 90,-32768,-32768, -36, 58, 94, 835,-32768,-32768,
1326 1136,-32768, 137, 1236, 27, 138, 62,-32768,-32768,-32768,
1327 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1328 -32768,-32768,-32768, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
1329 -32768,-32768, 1136, 1136, 1136, 1136, 1136, 1136, 1136,-32768,
1330 62,-32768, 77,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1331 -35,-32768, 118, 167, 190, 173, 191, 175, 192, 177,
1332 193, 196, 197, 180, 194, 198, 519,-32768, 1136, 1136,
1333 -32768, 1136, 872,-32768, 92, 108, 662,-32768,-32768, 8,
1334 -32768, 662, 662,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1335 -32768,-32768,-32768, 662, 1073, 100, 101,-32768, 662, 115,
1336 102, 182, 111, 113, 114, 119, 662, 662, 662, 121,
1337 1073, 1136, 1136,-32768, 203,-32768,-32768,-32768,-32768,-32768,
1338 -32768,-32768,-32768,-32768,-32768, 132, 133, 134, 935, 1173,
1339 620, 208, 139, 140, 143, 144,-32768,-32768, -74, -29,
1340 -36,-32768, 71,-32768, 127, 117, 972,-32768,-32768,-32768,
1341 -32768,-32768,-32768,-32768,-32768, 1173,-32768,-32768,-32768,-32768,
1342 128,-32768, 136, 662, -6, -2, 146, 662, 155, 1136,
1343 1136, 1136, 1136, 1136, 149, 151, 153, 1136, 662, 662,
1344 154,-32768, 1173, 1173, 1173,-32768,-32768, -28, -57,-32768,
1345 61,-32768, 1173, 1173, 1173, 1173,-32768,-32768,-32768,-32768,
1346 1036,-32768,-32768, -11, 230, 238, 165, 662, 262, 662,
1347 263, 1136,-32768, 162, 662,-32768, 166,-32768,-32768,-32768,
1348 662, 662, 662,-32768, 171,-32768, 1136, 146, 235, 169,
1349 -32768, 1173,-32768,-32768, 172, 183, 184, 185,-32768,-32768,
1350 -32768, 662, 662, 1136, 186,-32768, 187,-32768,-32768, 188,
1351 662, 189, 1136,-32768,-32768,-32768, 1136, 662, 174, 1136,
1352 1173,-32768, 1173, 1173, 1173, 1173, 199, 200, 188, 176,
1353 218, 231, 1136, 202, 662,-32768, 206,-32768,-32768, 209,
1354 201, 211, 212, 213, 214, 266, 5, 254, 293, 294,
1355 -32768,-32768, 215,-32768,-32768, 1173,-32768,-32768,-32768,-32768,
1356 662,-32768, 740, 42, 279,-32768,-32768,-32768, 216,-32768,
1357 210,-32768, 740, 662,-32768, 298, 219, 250, 662, 300,
1358 301,-32768, 662, 662,-32768,-32768, 323, 325,-32768
1361 static const short yypgoto[] = {-32768,
1362 -32768, 251, 252, 255, 259, -102, -99, -362,-32768, 302,
1363 310, -81, -38,-32768, -26,-32768, -54, 240,-32768, -83,
1364 178, -207, 297,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1365 -1,-32768, 39,-32768,-32768, 320,-32768,-32768,-32768,-32768,
1366 340,-32768, -372, 56, 161, -96,-32768, 333,-32768,-32768,
1367 -32768,-32768,-32768, 36, -7,-32768,-32768, 21,-32768,-32768
1374 static const short yytable[] = { 70,
1375 19, 85, 28, 192, 178, 168, 193, 181, 308, 31,
1376 75, 95, 310, 70, 184, 185, 186, 187, 188, 189,
1377 190, 191, 289, 291, 403, 195, 297, 39, 19, 198,
1378 411, 99, 202, 203, 28, 182, 204, 205, 206, -106,
1379 417, 413, 210, 95, 43, 333, 309, 183, 304, 332,
1380 311, 184, 185, 186, 187, 188, 189, 190, 191, 211,
1381 -47, 152, 86, 87, 3, 214, 97, 40, 45, 99,
1382 4, 215, 331, 298, 177, 80, 99, 177, 332, 5,
1383 6, 7, 8, 83, 32, 76, 81, 5, 6, 7,
1384 8, 341, 14, 41, 15, 332, 82, 196, 197, 177,
1385 199, 200, 177, 177, -48, 402, 177, 177, 177, 207,
1386 208, 209, 177, 98, 239, 240, 281, 241, 22, 23,
1387 24, 25, 146, 147, 46, 47, 90, 93, 49, 50,
1388 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1389 61, 14, 412, 15, 216, 217, 243, 184, 185, 186,
1390 187, 188, 189, 190, 191, 91, 264, 35, 36, 37,
1391 212, 213, 171, 62, 172, 334, 92, 332, 70, -24,
1392 -24, 145, 279, 149, 317, -23, -23, -22, -22, -21,
1393 -21, 324, 218, 219, 70, 280, 177, 150, 169, 170,
1394 173, 179, 241, -28, -27, -26, -25, 221, 247, 328,
1395 329, 330, -31, -32, 222, 248, 265, 266, 269, 335,
1396 336, 337, 338, 268, 302, 63, 270, 271, 64, 272,
1397 273, 65, 238, 66, 94, 274, 282, 278, 283, 284,
1398 285, 292, 259, 301, 305, 293, 294, 259, 259, 295,
1399 296, 299, 306, 316, 177, 318, 319, 320, 362, 259,
1400 342, 177, 312, 315, 259, 321, 376, 322, 343, 323,
1401 327, 344, 259, 259, 259, 346, 348, 357, 351, 360,
1402 389, 379, 353, 388, 243, 361, 391, 381, 363, 382,
1403 383, 384, 385, 390, 192, 177, 401, 193, 405, 364,
1404 365, 366, 371, 372, 373, 375, 406, 407, 387, 414,
1405 358, 192, 392, 394, 193, 386, 395, 396, 397, 398,
1406 399, 400, 409, 415, 421, 408, 416, 177, 419, 259,
1407 423, 424, 428, 259, 429, 420, 177, 42, 136, 137,
1408 177, 78, 138, 380, 259, 259, 139, 175, 89, 340,
1409 44, 20, 261, 262, 237, 34, 177, 350, 359, 377,
1410 0, 0, 0, 0, 263, 0, 0, 0, 0, 267,
1411 -34, 0, 14, 259, 15, 259, 0, 275, 276, 277,
1412 259, 4, -34, -34, 0, 0, 259, 259, 259, 0,
1413 -34, -34, -34, -34, 0, 0, -34, 16, 0, 0,
1414 0, 0, 0, 0, 17, 0, 0, 259, 259, 0,
1415 0, 0, 0, 0, 0, 0, 259, 0, 0, 0,
1416 0, 0, 0, 259, 0, 0, 0, 0, 0, 0,
1417 0, 0, 0, 0, 307, 0, 0, 0, 314, 0,
1418 259, 0, 0, 0, 0, 0, 0, 0, 0, 325,
1419 326, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1420 0, 0, 0, 0, 0, 0, 259, 0, 0, 0,
1421 0, 0, 0, 0, 0, 0, 0, 0, 345, 259,
1422 347, 0, 0, 0, 259, 352, 0, 0, 259, 259,
1423 0, 354, 355, 356, 0, 0, 0, 0, 0, 0,
1424 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1425 0, 0, 367, 368, 0, 0, 0, 0, 0, 0,
1426 0, 374, 0, 0, 0, 0, 0, 0, 378, 0,
1427 0, 0, 0, 46, 47, 0, 0, 0, 0, 0,
1428 0, 0, 0, 0, 0, 393, 0, 0, 0, 0,
1429 14, 0, 15, 0, 223, 0, 0, 0, 0, 0,
1430 0, 0, 0, 0, 0, 224, 225, 0, 0, 0,
1431 0, 410, 0, 0, 0, 0, 0, 0, 0, 0,
1432 0, 0, 0, 0, 418, 0, 0, 0, 0, 422,
1433 0, 0, 0, 425, 426, 110, 111, 112, 113, 114,
1434 115, 116, 117, 118, 119, 120, 121, 122, 123, 0,
1435 0, 0, 0, 0, 226, 0, 227, 228, 131, 132,
1436 0, 0, 0, 0, 0, 0, 0, 229, 0, 0,
1437 230, 0, 231, 0, 46, 47, 232, 93, 153, 154,
1438 155, 156, 157, 158, 159, 160, 161, 162, 163, 60,
1439 61, 14, 0, 15, 0, 0, 0, 0, 0, 0,
1440 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1441 0, 0, 0, 62, 249, 250, 46, 47, 251, 0,
1442 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1443 0, 0, 0, 14, 0, 15, 0, 0, 252, 253,
1444 0, 0, 0, 0, 0, 0, 0, 0, 254, 255,
1445 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1446 0, 0, 0, 0, 0, 63, 0, 0, 64, 0,
1447 0, 65, 0, 66, 290, 0, 0, 0, 110, 111,
1448 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
1449 122, 123, 249, 250, 0, 0, 251, 226, 0, 227,
1450 228, 131, 132, 0, 0, 0, 0, 0, 0, 0,
1451 0, 0, 0, 256, 0, 0, 252, 253, 0, 0,
1452 0, 0, 0, 0, 0, 0, 254, 255, 0, 0,
1453 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1454 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1455 0, 0, 0, 0, 0, 0, 110, 111, 112, 113,
1456 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1457 0, 0, 0, 0, 0, 226, 0, 227, 228, 131,
1458 132, 0, 0, 0, 0, 0, 0, 0, 0, 46,
1459 47, 256, 93, 49, 50, 51, 52, 53, 54, 55,
1460 56, 57, 58, 59, 60, 61, 14, 0, 15, 0,
1461 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1462 174, 0, 0, 0, 0, 0, 46, 47, 62, 93,
1463 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1464 59, 60, 61, 14, 0, 15, 0, 0, 0, 0,
1465 0, 0, 0, 0, 0, 0, 0, 242, 0, 0,
1466 0, 0, 0, 0, 0, 62, 0, 0, 0, 0,
1467 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1468 63, 0, 0, 64, 0, 0, 65, 0, 66, 46,
1469 47, 0, 93, 153, 154, 155, 156, 157, 158, 159,
1470 160, 161, 162, 163, 60, 61, 14, 0, 15, 0,
1471 0, 0, 0, 0, 0, 0, 0, 63, 0, 0,
1472 64, 0, 0, 65, 0, 66, 46, 47, 62, 93,
1473 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1474 59, 60, 61, 14, 0, 15, 0, 0, 0, 0,
1475 0, 0, 0, 0, 0, 0, 0, 303, 0, 0,
1476 0, 0, 0, 0, 0, 62, 0, 0, 0, 0,
1477 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1478 63, 0, 0, 64, 0, 286, 65, 0, 66, 0,
1479 46, 47, 0, 93, 49, 50, 51, 52, 53, 54,
1480 55, 56, 57, 58, 59, 60, 61, 14, 0, 15,
1481 0, 0, 0, 0, 0, 0, 0, 63, 0, 0,
1482 64, 339, 0, 65, 0, 66, 0, 46, 47, 62,
1483 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1484 58, 59, 60, 61, 14, 0, 15, 0, 0, 0,
1485 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1486 0, 0, 0, 0, 0, 0, 62, 0, 0, 0,
1487 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1488 0, 63, 0, 0, 64, 0, 0, 65, 0, 66,
1489 46, 47, 0, 93, 49, 50, 51, 52, 53, 54,
1490 55, 56, 57, 58, 59, 60, 61, 14, 0, 15,
1491 0, 0, 0, 0, 0, 0, 0, 0, 63, 0,
1492 0, 64, 0, 0, 65, 0, 66, 46, 47, 62,
1493 93, 153, 154, 155, 156, 157, 158, 159, 160, 161,
1494 162, 163, 60, 61, 14, 0, 15, 0, 0, 0,
1495 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1496 0, 0, 0, 0, 0, 0, 62, 0, 0, 0,
1497 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1498 0, 63, 0, 0, 64, 0, 0, 65, 0, 66,
1499 46, 47, 0, 180, 49, 50, 51, 52, 53, 54,
1500 55, 56, 57, 58, 59, 60, 61, 14, 0, 15,
1501 0, 100, 0, 0, 0, 0, 0, 0, 63, 0,
1502 0, 64, 101, 0, 65, 0, 66, 0, 0, 62,
1503 0, 0, 102, 103, 0, 0, 0, 0, 104, 105,
1504 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
1505 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1506 126, 0, 0, 127, 128, 129, 130, 131, 132, 133,
1507 134, 135, 0, 0, 0, 0, 0, 0, 0, 0,
1508 0, 63, 0, 0, 64, 0, 0, 65, 0, 66
1511 static const short yycheck[] = { 26,
1512 2, 40, 23, 106, 101, 89, 106, 104, 15, 30,
1513 29, 66, 15, 40, 10, 11, 12, 13, 14, 15,
1514 16, 17, 230, 231, 387, 107, 101, 95, 30, 126,
1515 403, 106, 129, 130, 23, 9, 133, 134, 135, 0,
1516 413, 404, 139, 98, 95, 103, 53, 21, 256, 107,
1517 53, 10, 11, 12, 13, 14, 15, 16, 17, 141,
1518 97, 88, 32, 33, 25, 101, 68, 20, 4, 106,
1519 31, 107, 101, 103, 101, 95, 106, 104, 107, 40,
1520 41, 42, 43, 99, 105, 104, 95, 40, 41, 42,
1521 43, 103, 22, 46, 24, 107, 95, 124, 125, 126,
1522 127, 128, 129, 130, 97, 101, 133, 134, 135, 136,
1523 137, 138, 139, 97, 169, 170, 213, 172, 57, 58,
1524 59, 60, 51, 52, 5, 6, 4, 8, 9, 10,
1525 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1526 21, 22, 101, 24, 27, 28, 173, 10, 11, 12,
1527 13, 14, 15, 16, 17, 4, 195, 48, 49, 50,
1528 84, 85, 105, 44, 107, 105, 4, 107, 195, 3,
1529 4, 24, 211, 4, 271, 3, 4, 3, 4, 3,
1530 4, 278, 3, 4, 211, 212, 213, 24, 100, 100,
1531 97, 55, 247, 4, 4, 4, 4, 4, 107, 283,
1532 284, 285, 7, 7, 7, 98, 107, 107, 107, 293,
1533 294, 295, 296, 99, 98, 96, 35, 107, 99, 107,
1534 107, 102, 167, 104, 105, 107, 24, 107, 97, 97,
1535 97, 24, 177, 107, 107, 97, 97, 182, 183, 97,
1536 97, 243, 107, 270, 271, 272, 273, 274, 332, 194,
1537 21, 278, 107, 99, 199, 107, 353, 107, 21, 107,
1538 107, 97, 207, 208, 209, 4, 4, 97, 107, 35,
1539 53, 98, 107, 98, 301, 107, 373, 361, 107, 363,
1540 364, 365, 366, 53, 387, 312, 21, 387, 35, 107,
1541 107, 107, 107, 107, 107, 107, 4, 4, 99, 21,
1542 327, 404, 101, 98, 404, 107, 98, 107, 98, 98,
1543 98, 98, 396, 98, 65, 101, 107, 344, 21, 264,
1544 21, 21, 0, 268, 0, 107, 353, 18, 78, 78,
1545 357, 30, 78, 360, 279, 280, 78, 98, 42, 301,
1546 21, 2, 182, 183, 167, 13, 373, 312, 328, 357,
1547 -1, -1, -1, -1, 194, -1, -1, -1, -1, 199,
1548 20, -1, 22, 308, 24, 310, -1, 207, 208, 209,
1549 315, 31, 32, 33, -1, -1, 321, 322, 323, -1,
1550 40, 41, 42, 43, -1, -1, 46, 47, -1, -1,
1551 -1, -1, -1, -1, 54, -1, -1, 342, 343, -1,
1552 -1, -1, -1, -1, -1, -1, 351, -1, -1, -1,
1553 -1, -1, -1, 358, -1, -1, -1, -1, -1, -1,
1554 -1, -1, -1, -1, 264, -1, -1, -1, 268, -1,
1555 375, -1, -1, -1, -1, -1, -1, -1, -1, 279,
1556 280, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1557 -1, -1, -1, -1, -1, -1, 401, -1, -1, -1,
1558 -1, -1, -1, -1, -1, -1, -1, -1, 308, 414,
1559 310, -1, -1, -1, 419, 315, -1, -1, 423, 424,
1560 -1, 321, 322, 323, -1, -1, -1, -1, -1, -1,
1561 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1562 -1, -1, 342, 343, -1, -1, -1, -1, -1, -1,
1563 -1, 351, -1, -1, -1, -1, -1, -1, 358, -1,
1564 -1, -1, -1, 5, 6, -1, -1, -1, -1, -1,
1565 -1, -1, -1, -1, -1, 375, -1, -1, -1, -1,
1566 22, -1, 24, -1, 26, -1, -1, -1, -1, -1,
1567 -1, -1, -1, -1, -1, 37, 38, -1, -1, -1,
1568 -1, 401, -1, -1, -1, -1, -1, -1, -1, -1,
1569 -1, -1, -1, -1, 414, -1, -1, -1, -1, 419,
1570 -1, -1, -1, 423, 424, 67, 68, 69, 70, 71,
1571 72, 73, 74, 75, 76, 77, 78, 79, 80, -1,
1572 -1, -1, -1, -1, 86, -1, 88, 89, 90, 91,
1573 -1, -1, -1, -1, -1, -1, -1, 99, -1, -1,
1574 102, -1, 104, -1, 5, 6, 108, 8, 9, 10,
1575 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1576 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1577 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1578 -1, -1, -1, 44, 3, 4, 5, 6, 7, -1,
1579 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1580 -1, -1, -1, 22, -1, 24, -1, -1, 27, 28,
1581 -1, -1, -1, -1, -1, -1, -1, -1, 37, 38,
1582 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1583 -1, -1, -1, -1, -1, 96, -1, -1, 99, -1,
1584 -1, 102, -1, 104, 105, -1, -1, -1, 67, 68,
1585 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1586 79, 80, 3, 4, -1, -1, 7, 86, -1, 88,
1587 89, 90, 91, -1, -1, -1, -1, -1, -1, -1,
1588 -1, -1, -1, 102, -1, -1, 27, 28, -1, -1,
1589 -1, -1, -1, -1, -1, -1, 37, 38, -1, -1,
1590 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1591 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1592 -1, -1, -1, -1, -1, -1, 67, 68, 69, 70,
1593 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1594 -1, -1, -1, -1, -1, 86, -1, 88, 89, 90,
1595 91, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1596 6, 102, 8, 9, 10, 11, 12, 13, 14, 15,
1597 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1598 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1599 36, -1, -1, -1, -1, -1, 5, 6, 44, 8,
1600 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1601 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1602 -1, -1, -1, -1, -1, -1, -1, 36, -1, -1,
1603 -1, -1, -1, -1, -1, 44, -1, -1, -1, -1,
1604 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1605 96, -1, -1, 99, -1, -1, 102, -1, 104, 5,
1606 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
1607 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1608 -1, -1, -1, -1, -1, -1, -1, 96, -1, -1,
1609 99, -1, -1, 102, -1, 104, 5, 6, 44, 8,
1610 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1611 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1612 -1, -1, -1, -1, -1, -1, -1, 36, -1, -1,
1613 -1, -1, -1, -1, -1, 44, -1, -1, -1, -1,
1614 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1615 96, -1, -1, 99, -1, 101, 102, -1, 104, -1,
1616 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1617 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1618 -1, -1, -1, -1, -1, -1, -1, 96, -1, -1,
1619 99, 36, -1, 102, -1, 104, -1, 5, 6, 44,
1620 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1621 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1623 -1, -1, -1, -1, -1, -1, 44, -1, -1, -1,
1624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1625 -1, 96, -1, -1, 99, -1, -1, 102, -1, 104,
1626 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1627 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1628 -1, -1, -1, -1, -1, -1, -1, -1, 96, -1,
1629 -1, 99, -1, -1, 102, -1, 104, 5, 6, 44,
1630 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1631 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1632 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1633 -1, -1, -1, -1, -1, -1, 44, -1, -1, -1,
1634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1635 -1, 96, -1, -1, 99, -1, -1, 102, -1, 104,
1636 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1637 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1638 -1, 34, -1, -1, -1, -1, -1, -1, 96, -1,
1639 -1, 99, 45, -1, 102, -1, 104, -1, -1, 44,
1640 -1, -1, 55, 56, -1, -1, -1, -1, 61, 62,
1641 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
1642 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1643 83, -1, -1, 86, 87, 88, 89, 90, 91, 92,
1644 93, 94, -1, -1, -1, -1, -1, -1, -1, -1,
1645 -1, 96, -1, -1, 99, -1, -1, 102, -1, 104
1647 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1648 #line 3 "/usr/share/bison.simple"
1649 /* This file comes from bison-1.28. */
1651 /* Skeleton output parser for bison,
1652 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1654 This program is free software; you can redistribute it and/or modify
1655 it under the terms of the GNU General Public License as published by
1656 the Free Software Foundation; either version 2, or (at your option)
1659 This program is distributed in the hope that it will be useful,
1660 but WITHOUT ANY WARRANTY; without even the implied warranty of
1661 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1662 GNU General Public License for more details.
1664 You should have received a copy of the GNU General Public License
1665 along with this program; if not, write to the Free Software
1666 Foundation, Inc., 59 Temple Place - Suite 330,
1667 Boston, MA 02111-1307, USA. */
1669 /* As a special exception, when this file is copied by Bison into a
1670 Bison output file, you may use that output file without restriction.
1671 This special exception was added by the Free Software Foundation
1672 in version 1.24 of Bison. */
1674 /* This is the parser code that is written into each bison parser
1675 when the %semantic_parser declaration is not specified in the grammar.
1676 It was written by Richard Stallman by simplifying the hairy parser
1677 used when %semantic_parser is specified. */
1679 #ifndef YYSTACK_USE_ALLOCA
1681 #define YYSTACK_USE_ALLOCA
1682 #else /* alloca not defined */
1684 #define YYSTACK_USE_ALLOCA
1685 #define alloca __builtin_alloca
1686 #else /* not GNU C. */
1687 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1688 #define YYSTACK_USE_ALLOCA
1690 #else /* not sparc */
1691 /* We think this test detects Watcom and Microsoft C. */
1692 /* This used to test MSDOS, but that is a bad idea
1693 since that symbol is in the user namespace. */
1694 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1695 #if 0 /* No need for malloc.h, which pollutes the namespace;
1696 instead, just don't use alloca. */
1699 #else /* not MSDOS, or __TURBOC__ */
1701 /* I don't know what this was needed for, but it pollutes the namespace.
1702 So I turned it off. rms, 2 May 1997. */
1703 /* #include <malloc.h> */
1705 #define YYSTACK_USE_ALLOCA
1706 #else /* not MSDOS, or __TURBOC__, or _AIX */
1708 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1709 and on HPUX 10. Eventually we can turn this on. */
1710 #define YYSTACK_USE_ALLOCA
1711 #define alloca __builtin_alloca
1714 #endif /* not _AIX */
1715 #endif /* not MSDOS, or __TURBOC__ */
1716 #endif /* not sparc */
1717 #endif /* not GNU C */
1718 #endif /* alloca not defined */
1719 #endif /* YYSTACK_USE_ALLOCA not defined */
1721 #ifdef YYSTACK_USE_ALLOCA
1722 #define YYSTACK_ALLOC alloca
1724 #define YYSTACK_ALLOC malloc
1727 /* Note: there must be only one dollar sign in this file.
1728 It is replaced by the list of actions, each action
1729 as one case of the switch. */
1731 #define yyerrok (yyerrstatus = 0)
1732 #define yyclearin (yychar = YYEMPTY)
1735 #define YYACCEPT goto yyacceptlab
1736 #define YYABORT goto yyabortlab
1737 #define YYERROR goto yyerrlab1
1738 /* Like YYERROR except do call yyerror.
1739 This remains here temporarily to ease the
1740 transition to the new meaning of YYERROR, for GCC.
1741 Once GCC version 2 has supplanted version 1, this can go. */
1742 #define YYFAIL goto yyerrlab
1743 #define YYRECOVERING() (!!yyerrstatus)
1744 #define YYBACKUP(token, value) \
1746 if (yychar == YYEMPTY && yylen == 1) \
1747 { yychar = (token), yylval = (value); \
1748 yychar1 = YYTRANSLATE (yychar); \
1753 { yyerror ("syntax error: cannot back up"); YYERROR; } \
1757 #define YYERRCODE 256
1760 #define YYLEX yylex()
1766 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
1768 #define YYLEX yylex(&yylval, &yylloc)
1770 #else /* not YYLSP_NEEDED */
1772 #define YYLEX yylex(&yylval, YYLEX_PARAM)
1774 #define YYLEX yylex(&yylval)
1776 #endif /* not YYLSP_NEEDED */
1779 /* If nonreentrant, generate the variables here */
1783 int yychar; /* the lookahead symbol */
1784 YYSTYPE yylval; /* the semantic value of the */
1785 /* lookahead symbol */
1788 YYLTYPE yylloc; /* location data for the lookahead */
1792 int yynerrs; /* number of parse errors so far */
1793 #endif /* not YYPURE */
1796 int yydebug; /* nonzero means print parse trace */
1797 /* Since this is uninitialized, it does not stop multiple parsers
1801 /* YYINITDEPTH indicates the initial size of the parser's stacks */
1804 #define YYINITDEPTH 200
1807 /* YYMAXDEPTH is the maximum size the stacks can grow to
1808 (effective only if the built-in stack extension method is used). */
1815 #define YYMAXDEPTH 10000
1818 /* Define __yy_memcpy. Note that the size argument
1819 should be passed with type unsigned int, because that is what the non-GCC
1820 definitions require. With GCC, __builtin_memcpy takes an arg
1821 of type size_t, but it can handle unsigned int. */
1823 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1824 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1825 #else /* not GNU C or C++ */
1828 /* This is the most reliable way to avoid incompatibilities
1829 in available built-in functions on various systems. */
1831 __yy_memcpy (to, from, count)
1836 register char *f = from;
1837 register char *t = to;
1838 register int i = count;
1844 #else /* __cplusplus */
1846 /* This is the most reliable way to avoid incompatibilities
1847 in available built-in functions on various systems. */
1849 __yy_memcpy (char *to, char *from, unsigned int count)
1851 register char *t = to;
1852 register char *f = from;
1853 register int i = count;
1862 #line 217 "/usr/share/bison.simple"
1864 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1865 into yyparse. The argument should have type void *.
1866 It should actually point to an object.
1867 Grammar actions can access the variable by casting it
1868 to the proper pointer type. */
1870 #ifdef YYPARSE_PARAM
1872 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1873 #define YYPARSE_PARAM_DECL
1874 #else /* not __cplusplus */
1875 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1876 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1877 #endif /* not __cplusplus */
1878 #else /* not YYPARSE_PARAM */
1879 #define YYPARSE_PARAM_ARG
1880 #define YYPARSE_PARAM_DECL
1881 #endif /* not YYPARSE_PARAM */
1883 /* Prevent warning if -Wstrict-prototypes. */
1885 #ifdef YYPARSE_PARAM
1886 int yyparse (void *);
1893 yyparse(YYPARSE_PARAM_ARG)
1896 register int yystate;
1898 register short *yyssp;
1899 register YYSTYPE *yyvsp;
1900 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1901 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1903 short yyssa[YYINITDEPTH]; /* the state stack */
1904 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1906 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1907 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1910 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1911 YYLTYPE *yyls = yylsa;
1914 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1916 #define YYPOPSTACK (yyvsp--, yyssp--)
1919 int yystacksize = YYINITDEPTH;
1920 int yyfree_stacks = 0;
1931 YYSTYPE yyval; /* the variable used to return */
1932 /* semantic values from the action */
1939 fprintf(stderr, "Starting parse\n");
1945 yychar = YYEMPTY; /* Cause a token to be read. */
1947 /* Initialize stack pointers.
1948 Waste one element of value and location stack
1949 so that they stay on the same level as the state stack.
1950 The wasted elements are never initialized. */
1958 /* Push a new state, which is found in yystate . */
1959 /* In all cases, when you get here, the value and location stacks
1960 have just been pushed. so pushing a state here evens the stacks. */
1965 if (yyssp >= yyss + yystacksize - 1)
1967 /* Give user a chance to reallocate the stack */
1968 /* Use copies of these so that the &'s don't force the real ones into memory. */
1969 YYSTYPE *yyvs1 = yyvs;
1970 short *yyss1 = yyss;
1972 YYLTYPE *yyls1 = yyls;
1975 /* Get the current used size of the three stacks, in elements. */
1976 int size = yyssp - yyss + 1;
1979 /* Each stack pointer address is followed by the size of
1980 the data in use in that stack, in bytes. */
1982 /* This used to be a conditional around just the two extra args,
1983 but that might be undefined if yyoverflow is a macro. */
1984 yyoverflow("parser stack overflow",
1985 &yyss1, size * sizeof (*yyssp),
1986 &yyvs1, size * sizeof (*yyvsp),
1987 &yyls1, size * sizeof (*yylsp),
1990 yyoverflow("parser stack overflow",
1991 &yyss1, size * sizeof (*yyssp),
1992 &yyvs1, size * sizeof (*yyvsp),
1996 yyss = yyss1; yyvs = yyvs1;
2000 #else /* no yyoverflow */
2001 /* Extend the stack our own way. */
2002 if (yystacksize >= YYMAXDEPTH)
2004 yyerror("parser stack overflow");
2016 if (yystacksize > YYMAXDEPTH)
2017 yystacksize = YYMAXDEPTH;
2018 #ifndef YYSTACK_USE_ALLOCA
2021 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2022 __yy_memcpy ((char *)yyss, (char *)yyss1,
2023 size * (unsigned int) sizeof (*yyssp));
2024 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2025 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2026 size * (unsigned int) sizeof (*yyvsp));
2028 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2029 __yy_memcpy ((char *)yyls, (char *)yyls1,
2030 size * (unsigned int) sizeof (*yylsp));
2032 #endif /* no yyoverflow */
2034 yyssp = yyss + size - 1;
2035 yyvsp = yyvs + size - 1;
2037 yylsp = yyls + size - 1;
2042 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2045 if (yyssp >= yyss + yystacksize - 1)
2051 fprintf(stderr, "Entering state %d\n", yystate);
2057 /* Do appropriate processing given the current state. */
2058 /* Read a lookahead token if we need one and don't already have one. */
2061 /* First try to decide what to do without reference to lookahead token. */
2063 yyn = yypact[yystate];
2067 /* Not known => get a lookahead token if don't already have one. */
2069 /* yychar is either YYEMPTY or YYEOF
2070 or a valid token in external form. */
2072 if (yychar == YYEMPTY)
2076 fprintf(stderr, "Reading a token: ");
2081 /* Convert token to internal form (in yychar1) for indexing tables with */
2083 if (yychar <= 0) /* This means end of input. */
2086 yychar = YYEOF; /* Don't call YYLEX any more */
2090 fprintf(stderr, "Now at end of input.\n");
2095 yychar1 = YYTRANSLATE(yychar);
2100 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2101 /* Give the individual parser a way to print the precise meaning
2102 of a token, for further debugging info. */
2104 YYPRINT (stderr, yychar, yylval);
2106 fprintf (stderr, ")\n");
2112 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2117 /* yyn is what to do for this token type in this state.
2118 Negative => reduce, -yyn is rule number.
2119 Positive => shift, yyn is new state.
2120 New state is final state => don't bother to shift,
2121 just return success.
2122 0, or most negative number => error. */
2137 /* Shift the lookahead token. */
2141 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2144 /* Discard the token being shifted unless it is eof. */
2145 if (yychar != YYEOF)
2153 /* count tokens shifted since error; after three, turn off error status. */
2154 if (yyerrstatus) yyerrstatus--;
2159 /* Do the default action for the current state. */
2162 yyn = yydefact[yystate];
2166 /* Do a reduction. yyn is the number of a rule to reduce with. */
2170 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2177 fprintf (stderr, "Reducing via rule %d (line %d), ",
2180 /* Print the symbols being reduced, and their result. */
2181 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2182 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2183 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2191 #line 984 "/llvm/lib/AsmParser/llvmAsmParser.y"
2193 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2194 ThrowException("Value too large for type!");
2195 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2199 #line 992 "/llvm/lib/AsmParser/llvmAsmParser.y"
2201 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2202 ThrowException("Value too large for type!");
2203 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2207 #line 1015 "/llvm/lib/AsmParser/llvmAsmParser.y"
2209 yyval.StrVal = yyvsp[-1].StrVal;
2213 #line 1018 "/llvm/lib/AsmParser/llvmAsmParser.y"
2219 #line 1022 "/llvm/lib/AsmParser/llvmAsmParser.y"
2220 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2223 #line 1023 "/llvm/lib/AsmParser/llvmAsmParser.y"
2224 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2227 #line 1024 "/llvm/lib/AsmParser/llvmAsmParser.y"
2228 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2231 #line 1025 "/llvm/lib/AsmParser/llvmAsmParser.y"
2232 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2235 #line 1026 "/llvm/lib/AsmParser/llvmAsmParser.y"
2236 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2239 #line 1028 "/llvm/lib/AsmParser/llvmAsmParser.y"
2240 { yyval.UIntVal = CallingConv::C; ;
2243 #line 1029 "/llvm/lib/AsmParser/llvmAsmParser.y"
2244 { yyval.UIntVal = CallingConv::C; ;
2247 #line 1030 "/llvm/lib/AsmParser/llvmAsmParser.y"
2248 { yyval.UIntVal = CallingConv::Fast; ;
2251 #line 1031 "/llvm/lib/AsmParser/llvmAsmParser.y"
2252 { yyval.UIntVal = CallingConv::Cold; ;
2255 #line 1032 "/llvm/lib/AsmParser/llvmAsmParser.y"
2257 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2258 ThrowException("Calling conv too large!");
2259 yyval.UIntVal = yyvsp[0].UInt64Val;
2263 #line 1045 "/llvm/lib/AsmParser/llvmAsmParser.y"
2264 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2267 #line 1046 "/llvm/lib/AsmParser/llvmAsmParser.y"
2268 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2271 #line 1048 "/llvm/lib/AsmParser/llvmAsmParser.y"
2273 if (!UpRefs.empty())
2274 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2275 yyval.TypeVal = yyvsp[0].TypeVal;
2279 #line 1059 "/llvm/lib/AsmParser/llvmAsmParser.y"
2281 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2285 #line 1062 "/llvm/lib/AsmParser/llvmAsmParser.y"
2287 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2291 #line 1065 "/llvm/lib/AsmParser/llvmAsmParser.y"
2292 { // Named types are also simple types...
2293 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2297 #line 1071 "/llvm/lib/AsmParser/llvmAsmParser.y"
2298 { // Type UpReference
2299 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2300 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2301 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2302 yyval.TypeVal = new PATypeHolder(OT);
2303 UR_OUT("New Upreference!\n");
2307 #line 1078 "/llvm/lib/AsmParser/llvmAsmParser.y"
2308 { // Function derived type?
2309 std::vector<const Type*> Params;
2310 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2311 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2312 Params.push_back(*I);
2313 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2314 if (isVarArg) Params.pop_back();
2316 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2317 delete yyvsp[-1].TypeList; // Delete the argument list
2318 delete yyvsp[-3].TypeVal; // Delete the return type handle
2322 #line 1090 "/llvm/lib/AsmParser/llvmAsmParser.y"
2323 { // Sized array type?
2324 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2325 delete yyvsp[-1].TypeVal;
2329 #line 1094 "/llvm/lib/AsmParser/llvmAsmParser.y"
2330 { // Packed array type?
2331 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2332 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) {
2333 ThrowException("Unsigned result not equal to signed result");
2335 if(!ElemTy->isPrimitiveType()) {
2336 ThrowException("Elemental type of a PackedType must be primitive");
2338 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2339 delete yyvsp[-1].TypeVal;
2343 #line 1105 "/llvm/lib/AsmParser/llvmAsmParser.y"
2344 { // Structure type?
2345 std::vector<const Type*> Elements;
2346 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2347 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2348 Elements.push_back(*I);
2350 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2351 delete yyvsp[-1].TypeList;
2355 #line 1114 "/llvm/lib/AsmParser/llvmAsmParser.y"
2356 { // Empty structure type?
2357 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2361 #line 1117 "/llvm/lib/AsmParser/llvmAsmParser.y"
2363 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2364 delete yyvsp[-1].TypeVal;
2368 #line 1125 "/llvm/lib/AsmParser/llvmAsmParser.y"
2370 yyval.TypeList = new std::list<PATypeHolder>();
2371 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2375 #line 1129 "/llvm/lib/AsmParser/llvmAsmParser.y"
2377 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2381 #line 1135 "/llvm/lib/AsmParser/llvmAsmParser.y"
2383 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2387 #line 1138 "/llvm/lib/AsmParser/llvmAsmParser.y"
2389 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2393 #line 1141 "/llvm/lib/AsmParser/llvmAsmParser.y"
2395 yyval.TypeList = new std::list<PATypeHolder>();
2399 #line 1151 "/llvm/lib/AsmParser/llvmAsmParser.y"
2400 { // Nonempty unsized arr
2401 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2403 ThrowException("Cannot make array constant with type: '" +
2404 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2405 const Type *ETy = ATy->getElementType();
2406 int NumElements = ATy->getNumElements();
2408 // Verify that we have the correct size...
2409 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2410 ThrowException("Type mismatch: constant sized array initialized with " +
2411 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2412 itostr(NumElements) + "!");
2414 // Verify all elements are correct type!
2415 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2416 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2417 ThrowException("Element #" + utostr(i) + " is not of type '" +
2418 ETy->getDescription() +"' as required!\nIt is of type '"+
2419 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2422 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2423 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2427 #line 1176 "/llvm/lib/AsmParser/llvmAsmParser.y"
2429 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2431 ThrowException("Cannot make array constant with type: '" +
2432 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2434 int NumElements = ATy->getNumElements();
2435 if (NumElements != -1 && NumElements != 0)
2436 ThrowException("Type mismatch: constant sized array initialized with 0"
2437 " arguments, but has size of " + itostr(NumElements) +"!");
2438 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2439 delete yyvsp[-2].TypeVal;
2443 #line 1189 "/llvm/lib/AsmParser/llvmAsmParser.y"
2445 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2447 ThrowException("Cannot make array constant with type: '" +
2448 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2450 int NumElements = ATy->getNumElements();
2451 const Type *ETy = ATy->getElementType();
2452 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2453 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2454 ThrowException("Can't build string constant of size " +
2455 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2456 " when array has size " + itostr(NumElements) + "!");
2457 std::vector<Constant*> Vals;
2458 if (ETy == Type::SByteTy) {
2459 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2460 Vals.push_back(ConstantSInt::get(ETy, *C));
2461 } else if (ETy == Type::UByteTy) {
2462 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2463 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2465 free(yyvsp[0].StrVal);
2466 ThrowException("Cannot build string arrays of non byte sized elements!");
2468 free(yyvsp[0].StrVal);
2469 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2470 delete yyvsp[-2].TypeVal;
2474 #line 1217 "/llvm/lib/AsmParser/llvmAsmParser.y"
2475 { // Nonempty unsized arr
2476 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2478 ThrowException("Cannot make packed constant with type: '" +
2479 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2480 const Type *ETy = PTy->getElementType();
2481 int NumElements = PTy->getNumElements();
2483 // Verify that we have the correct size...
2484 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2485 ThrowException("Type mismatch: constant sized packed initialized with " +
2486 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2487 itostr(NumElements) + "!");
2489 // Verify all elements are correct type!
2490 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2491 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2492 ThrowException("Element #" + utostr(i) + " is not of type '" +
2493 ETy->getDescription() +"' as required!\nIt is of type '"+
2494 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2497 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2498 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2502 #line 1242 "/llvm/lib/AsmParser/llvmAsmParser.y"
2504 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2506 ThrowException("Cannot make struct constant with type: '" +
2507 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2509 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2510 ThrowException("Illegal number of initializers for structure type!");
2512 // Check to ensure that constants are compatible with the type initializer!
2513 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2514 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2515 ThrowException("Expected type '" +
2516 STy->getElementType(i)->getDescription() +
2517 "' for element #" + utostr(i) +
2518 " of structure initializer!");
2520 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2521 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2525 #line 1262 "/llvm/lib/AsmParser/llvmAsmParser.y"
2527 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2529 ThrowException("Cannot make struct constant with type: '" +
2530 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2532 if (STy->getNumContainedTypes() != 0)
2533 ThrowException("Illegal number of initializers for structure type!");
2535 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2536 delete yyvsp[-2].TypeVal;
2540 #line 1274 "/llvm/lib/AsmParser/llvmAsmParser.y"
2542 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2544 ThrowException("Cannot make null pointer constant with type: '" +
2545 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2547 yyval.ConstVal = ConstantPointerNull::get(PTy);
2548 delete yyvsp[-1].TypeVal;
2552 #line 1283 "/llvm/lib/AsmParser/llvmAsmParser.y"
2554 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2555 delete yyvsp[-1].TypeVal;
2559 #line 1287 "/llvm/lib/AsmParser/llvmAsmParser.y"
2561 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2563 ThrowException("Global const reference must be a pointer type!");
2565 // ConstExprs can exist in the body of a function, thus creating
2566 // GlobalValues whenever they refer to a variable. Because we are in
2567 // the context of a function, getValNonImprovising will search the functions
2568 // symbol table instead of the module symbol table for the global symbol,
2569 // which throws things all off. To get around this, we just tell
2570 // getValNonImprovising that we are at global scope here.
2572 Function *SavedCurFn = CurFun.CurrentFunction;
2573 CurFun.CurrentFunction = 0;
2575 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2577 CurFun.CurrentFunction = SavedCurFn;
2579 // If this is an initializer for a constant pointer, which is referencing a
2580 // (currently) undefined variable, create a stub now that shall be replaced
2581 // in the future with the right type of variable.
2584 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2585 const PointerType *PT = cast<PointerType>(Ty);
2587 // First check to see if the forward references value is already created!
2588 PerModuleInfo::GlobalRefsType::iterator I =
2589 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2591 if (I != CurModule.GlobalRefs.end()) {
2592 V = I->second; // Placeholder already exists, use it...
2593 yyvsp[0].ValIDVal.destroy();
2596 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2598 // Create the forward referenced global.
2600 if (const FunctionType *FTy =
2601 dyn_cast<FunctionType>(PT->getElementType())) {
2602 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2603 CurModule.CurrentModule);
2605 GV = new GlobalVariable(PT->getElementType(), false,
2606 GlobalValue::ExternalLinkage, 0,
2607 Name, CurModule.CurrentModule);
2610 // Keep track of the fact that we have a forward ref to recycle it
2611 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2616 yyval.ConstVal = cast<GlobalValue>(V);
2617 delete yyvsp[-1].TypeVal; // Free the type handle
2621 #line 1346 "/llvm/lib/AsmParser/llvmAsmParser.y"
2623 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2624 ThrowException("Mismatched types for constant expression!");
2625 yyval.ConstVal = yyvsp[0].ConstVal;
2626 delete yyvsp[-1].TypeVal;
2630 #line 1352 "/llvm/lib/AsmParser/llvmAsmParser.y"
2632 const Type *Ty = yyvsp[-1].TypeVal->get();
2633 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2634 ThrowException("Cannot create a null initialized value of this type!");
2635 yyval.ConstVal = Constant::getNullValue(Ty);
2636 delete yyvsp[-1].TypeVal;
2640 #line 1360 "/llvm/lib/AsmParser/llvmAsmParser.y"
2641 { // integral constants
2642 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2643 ThrowException("Constant value doesn't fit in type!");
2644 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
2648 #line 1365 "/llvm/lib/AsmParser/llvmAsmParser.y"
2649 { // integral constants
2650 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2651 ThrowException("Constant value doesn't fit in type!");
2652 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
2656 #line 1370 "/llvm/lib/AsmParser/llvmAsmParser.y"
2657 { // Boolean constants
2658 yyval.ConstVal = ConstantBool::True;
2662 #line 1373 "/llvm/lib/AsmParser/llvmAsmParser.y"
2663 { // Boolean constants
2664 yyval.ConstVal = ConstantBool::False;
2668 #line 1376 "/llvm/lib/AsmParser/llvmAsmParser.y"
2669 { // Float & Double constants
2670 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2671 ThrowException("Floating point constant invalid for type!!");
2672 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
2676 #line 1383 "/llvm/lib/AsmParser/llvmAsmParser.y"
2678 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2679 ThrowException("cast constant expression from a non-primitive type: '" +
2680 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2681 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2682 ThrowException("cast constant expression to a non-primitive type: '" +
2683 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2684 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2685 delete yyvsp[-1].TypeVal;
2689 #line 1393 "/llvm/lib/AsmParser/llvmAsmParser.y"
2691 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2692 ThrowException("GetElementPtr requires a pointer operand!");
2694 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2695 // indices to uint struct indices for compatibility.
2696 generic_gep_type_iterator<std::vector<Value*>::iterator>
2697 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2698 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2699 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2700 if (isa<StructType>(*GTI)) // Only change struct indices
2701 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2702 if (CUI->getType() == Type::UByteTy)
2703 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2706 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2708 ThrowException("Index list invalid for constant getelementptr!");
2710 std::vector<Constant*> IdxVec;
2711 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2712 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2713 IdxVec.push_back(C);
2715 ThrowException("Indices to constant getelementptr must be constants!");
2717 delete yyvsp[-1].ValueList;
2719 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
2723 #line 1424 "/llvm/lib/AsmParser/llvmAsmParser.y"
2725 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2726 ThrowException("Select condition must be of boolean type!");
2727 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2728 ThrowException("Select operand types must match!");
2729 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2733 #line 1431 "/llvm/lib/AsmParser/llvmAsmParser.y"
2735 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2736 ThrowException("Binary operator types must match!");
2737 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2738 // To retain backward compatibility with these early compilers, we emit a
2739 // cast to the appropriate integer type automatically if we are in the
2740 // broken case. See PR424 for more information.
2741 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2742 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2744 const Type *IntPtrTy = 0;
2745 switch (CurModule.CurrentModule->getPointerSize()) {
2746 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2747 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2748 default: ThrowException("invalid pointer binary constant expr!");
2750 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2751 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2752 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2757 #line 1452 "/llvm/lib/AsmParser/llvmAsmParser.y"
2759 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2760 ThrowException("Logical operator types must match!");
2761 if (!yyvsp[-3].ConstVal->getType()->isIntegral())
2762 ThrowException("Logical operands must have integral types!");
2763 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2767 #line 1459 "/llvm/lib/AsmParser/llvmAsmParser.y"
2769 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2770 ThrowException("setcc operand types must match!");
2771 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2775 #line 1464 "/llvm/lib/AsmParser/llvmAsmParser.y"
2777 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2778 ThrowException("Shift count for shift constant must be unsigned byte!");
2779 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2780 ThrowException("Shift constant expression requires integer operand!");
2781 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2785 #line 1474 "/llvm/lib/AsmParser/llvmAsmParser.y"
2787 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
2791 #line 1477 "/llvm/lib/AsmParser/llvmAsmParser.y"
2793 yyval.ConstVector = new std::vector<Constant*>();
2794 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
2798 #line 1484 "/llvm/lib/AsmParser/llvmAsmParser.y"
2799 { yyval.BoolVal = false; ;
2802 #line 1484 "/llvm/lib/AsmParser/llvmAsmParser.y"
2803 { yyval.BoolVal = true; ;
2806 #line 1494 "/llvm/lib/AsmParser/llvmAsmParser.y"
2808 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2809 CurModule.ModuleDone();
2813 #line 1501 "/llvm/lib/AsmParser/llvmAsmParser.y"
2815 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2816 CurFun.FunctionDone();
2820 #line 1505 "/llvm/lib/AsmParser/llvmAsmParser.y"
2822 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2826 #line 1508 "/llvm/lib/AsmParser/llvmAsmParser.y"
2828 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2832 #line 1511 "/llvm/lib/AsmParser/llvmAsmParser.y"
2834 yyval.ModuleVal = CurModule.CurrentModule;
2835 // Emit an error if there are any unresolved types left.
2836 if (!CurModule.LateResolveTypes.empty()) {
2837 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2838 if (DID.Type == ValID::NameVal)
2839 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2841 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2846 #line 1524 "/llvm/lib/AsmParser/llvmAsmParser.y"
2848 // Eagerly resolve types. This is not an optimization, this is a
2849 // requirement that is due to the fact that we could have this:
2851 // %list = type { %list * }
2852 // %list = type { %list * } ; repeated type decl
2854 // If types are not resolved eagerly, then the two types will not be
2855 // determined to be the same type!
2857 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2859 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2860 // If this is a named type that is not a redefinition, add it to the slot
2862 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2865 delete yyvsp[0].TypeVal;
2869 #line 1544 "/llvm/lib/AsmParser/llvmAsmParser.y"
2870 { // Function prototypes can be in const pool
2874 #line 1546 "/llvm/lib/AsmParser/llvmAsmParser.y"
2876 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
2877 ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
2881 #line 1550 "/llvm/lib/AsmParser/llvmAsmParser.y"
2883 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
2884 delete yyvsp[0].TypeVal;
2888 #line 1554 "/llvm/lib/AsmParser/llvmAsmParser.y"
2893 #line 1556 "/llvm/lib/AsmParser/llvmAsmParser.y"
2898 #line 1558 "/llvm/lib/AsmParser/llvmAsmParser.y"
2903 #line 1563 "/llvm/lib/AsmParser/llvmAsmParser.y"
2904 { yyval.Endianness = Module::BigEndian; ;
2907 #line 1564 "/llvm/lib/AsmParser/llvmAsmParser.y"
2908 { yyval.Endianness = Module::LittleEndian; ;
2911 #line 1566 "/llvm/lib/AsmParser/llvmAsmParser.y"
2913 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
2917 #line 1569 "/llvm/lib/AsmParser/llvmAsmParser.y"
2919 if (yyvsp[0].UInt64Val == 32)
2920 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
2921 else if (yyvsp[0].UInt64Val == 64)
2922 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
2924 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
2928 #line 1577 "/llvm/lib/AsmParser/llvmAsmParser.y"
2930 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
2931 free(yyvsp[0].StrVal);
2935 #line 1584 "/llvm/lib/AsmParser/llvmAsmParser.y"
2937 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
2938 free(yyvsp[0].StrVal);
2942 #line 1588 "/llvm/lib/AsmParser/llvmAsmParser.y"
2944 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
2945 free(yyvsp[0].StrVal);
2949 #line 1592 "/llvm/lib/AsmParser/llvmAsmParser.y"
2954 #line 1601 "/llvm/lib/AsmParser/llvmAsmParser.y"
2955 { yyval.StrVal = 0; ;
2958 #line 1603 "/llvm/lib/AsmParser/llvmAsmParser.y"
2960 if (*yyvsp[-1].TypeVal == Type::VoidTy)
2961 ThrowException("void typed arguments are invalid!");
2962 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
2966 #line 1609 "/llvm/lib/AsmParser/llvmAsmParser.y"
2968 yyval.ArgList = yyvsp[-2].ArgList;
2969 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
2970 delete yyvsp[0].ArgVal;
2974 #line 1614 "/llvm/lib/AsmParser/llvmAsmParser.y"
2976 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
2977 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
2978 delete yyvsp[0].ArgVal;
2982 #line 1620 "/llvm/lib/AsmParser/llvmAsmParser.y"
2984 yyval.ArgList = yyvsp[0].ArgList;
2988 #line 1623 "/llvm/lib/AsmParser/llvmAsmParser.y"
2990 yyval.ArgList = yyvsp[-2].ArgList;
2991 yyval.ArgList->push_back(std::pair<PATypeHolder*,
2992 char*>(new PATypeHolder(Type::VoidTy), 0));
2996 #line 1628 "/llvm/lib/AsmParser/llvmAsmParser.y"
2998 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
2999 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3003 #line 1632 "/llvm/lib/AsmParser/llvmAsmParser.y"
3009 #line 1636 "/llvm/lib/AsmParser/llvmAsmParser.y"
3011 UnEscapeLexed(yyvsp[-3].StrVal);
3012 std::string FunctionName(yyvsp[-3].StrVal);
3013 free(yyvsp[-3].StrVal); // Free strdup'd memory!
3015 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3016 ThrowException("LLVM functions cannot return aggregate types!");
3018 std::vector<const Type*> ParamTypeList;
3019 if (yyvsp[-1].ArgList) { // If there are arguments...
3020 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3021 I != yyvsp[-1].ArgList->end(); ++I)
3022 ParamTypeList.push_back(I->first->get());
3025 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3026 if (isVarArg) ParamTypeList.pop_back();
3028 const FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, ParamTypeList, isVarArg);
3029 const PointerType *PFT = PointerType::get(FT);
3030 delete yyvsp[-4].TypeVal;
3033 if (!FunctionName.empty()) {
3034 ID = ValID::create((char*)FunctionName.c_str());
3036 ID = ValID::create((int)CurModule.Values[PFT].size());
3040 // See if this function was forward referenced. If so, recycle the object.
3041 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3042 // Move the function to the end of the list, from whereever it was
3043 // previously inserted.
3044 Fn = cast<Function>(FWRef);
3045 CurModule.CurrentModule->getFunctionList().remove(Fn);
3046 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3047 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3048 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3049 // If this is the case, either we need to be a forward decl, or it needs
3051 if (!CurFun.isDeclare && !Fn->isExternal())
3052 ThrowException("Redefinition of function '" + FunctionName + "'!");
3054 // Make sure to strip off any argument names so we can't get conflicts.
3055 if (Fn->isExternal())
3056 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3060 } else { // Not already defined?
3061 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3062 CurModule.CurrentModule);
3063 InsertValue(Fn, CurModule.Values);
3066 CurFun.FunctionStart(Fn);
3067 Fn->setCallingConv(yyvsp[-5].UIntVal);
3069 // Add all of the arguments we parsed to the function...
3070 if (yyvsp[-1].ArgList) { // Is null if empty...
3071 if (isVarArg) { // Nuke the last entry
3072 assert(yyvsp[-1].ArgList->back().first->get() == Type::VoidTy && yyvsp[-1].ArgList->back().second == 0&&
3073 "Not a varargs marker!");
3074 delete yyvsp[-1].ArgList->back().first;
3075 yyvsp[-1].ArgList->pop_back(); // Delete the last entry
3077 Function::arg_iterator ArgIt = Fn->arg_begin();
3078 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3079 I != yyvsp[-1].ArgList->end(); ++I, ++ArgIt) {
3080 delete I->first; // Delete the typeholder...
3082 setValueName(ArgIt, I->second); // Insert arg into symtab...
3086 delete yyvsp[-1].ArgList; // We're now done with the argument list
3091 #line 1718 "/llvm/lib/AsmParser/llvmAsmParser.y"
3093 yyval.FunctionVal = CurFun.CurrentFunction;
3095 // Make sure that we keep track of the linkage type even if there was a
3096 // previous "declare".
3097 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3101 #line 1728 "/llvm/lib/AsmParser/llvmAsmParser.y"
3103 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3107 #line 1732 "/llvm/lib/AsmParser/llvmAsmParser.y"
3108 { CurFun.isDeclare = true; ;
3111 #line 1732 "/llvm/lib/AsmParser/llvmAsmParser.y"
3113 yyval.FunctionVal = CurFun.CurrentFunction;
3114 CurFun.FunctionDone();
3118 #line 1741 "/llvm/lib/AsmParser/llvmAsmParser.y"
3119 { // A reference to a direct constant
3120 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3124 #line 1744 "/llvm/lib/AsmParser/llvmAsmParser.y"
3126 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3130 #line 1747 "/llvm/lib/AsmParser/llvmAsmParser.y"
3131 { // Perhaps it's an FP constant?
3132 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3136 #line 1750 "/llvm/lib/AsmParser/llvmAsmParser.y"
3138 yyval.ValIDVal = ValID::create(ConstantBool::True);
3142 #line 1753 "/llvm/lib/AsmParser/llvmAsmParser.y"
3144 yyval.ValIDVal = ValID::create(ConstantBool::False);
3148 #line 1756 "/llvm/lib/AsmParser/llvmAsmParser.y"
3150 yyval.ValIDVal = ValID::createNull();
3154 #line 1759 "/llvm/lib/AsmParser/llvmAsmParser.y"
3156 yyval.ValIDVal = ValID::createUndef();
3160 #line 1762 "/llvm/lib/AsmParser/llvmAsmParser.y"
3161 { // Nonempty unsized packed vector
3162 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3163 int NumElements = yyvsp[-1].ConstVector->size();
3165 PackedType* pt = PackedType::get(ETy, NumElements);
3166 PATypeHolder* PTy = new PATypeHolder(
3174 // Verify all elements are correct type!
3175 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3176 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3177 ThrowException("Element #" + utostr(i) + " is not of type '" +
3178 ETy->getDescription() +"' as required!\nIt is of type '" +
3179 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3182 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3183 delete PTy; delete yyvsp[-1].ConstVector;
3187 #line 1786 "/llvm/lib/AsmParser/llvmAsmParser.y"
3189 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3193 #line 1793 "/llvm/lib/AsmParser/llvmAsmParser.y"
3194 { // Is it an integer reference...?
3195 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3199 #line 1796 "/llvm/lib/AsmParser/llvmAsmParser.y"
3200 { // Is it a named reference...?
3201 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3205 #line 1807 "/llvm/lib/AsmParser/llvmAsmParser.y"
3207 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3211 #line 1811 "/llvm/lib/AsmParser/llvmAsmParser.y"
3213 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3217 #line 1814 "/llvm/lib/AsmParser/llvmAsmParser.y"
3218 { // Do not allow functions with 0 basic blocks
3219 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3223 #line 1822 "/llvm/lib/AsmParser/llvmAsmParser.y"
3225 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3226 InsertValue(yyvsp[0].TermInstVal);
3228 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3229 InsertValue(yyvsp[-2].BasicBlockVal);
3230 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3234 #line 1831 "/llvm/lib/AsmParser/llvmAsmParser.y"
3236 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3237 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3241 #line 1835 "/llvm/lib/AsmParser/llvmAsmParser.y"
3243 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3245 // Make sure to move the basic block to the correct location in the
3246 // function, instead of leaving it inserted wherever it was first
3248 Function::BasicBlockListType &BBL =
3249 CurFun.CurrentFunction->getBasicBlockList();
3250 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3254 #line 1845 "/llvm/lib/AsmParser/llvmAsmParser.y"
3256 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3258 // Make sure to move the basic block to the correct location in the
3259 // function, instead of leaving it inserted wherever it was first
3261 Function::BasicBlockListType &BBL =
3262 CurFun.CurrentFunction->getBasicBlockList();
3263 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3267 #line 1856 "/llvm/lib/AsmParser/llvmAsmParser.y"
3268 { // Return with a result...
3269 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3273 #line 1859 "/llvm/lib/AsmParser/llvmAsmParser.y"
3274 { // Return with no result...
3275 yyval.TermInstVal = new ReturnInst();
3279 #line 1862 "/llvm/lib/AsmParser/llvmAsmParser.y"
3280 { // Unconditional Branch...
3281 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3285 #line 1865 "/llvm/lib/AsmParser/llvmAsmParser.y"
3287 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3291 #line 1868 "/llvm/lib/AsmParser/llvmAsmParser.y"
3293 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3294 yyval.TermInstVal = S;
3296 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3297 E = yyvsp[-1].JumpTable->end();
3298 for (; I != E; ++I) {
3299 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3300 S->addCase(CI, I->second);
3302 ThrowException("Switch case is constant, but not a simple integer!");
3304 delete yyvsp[-1].JumpTable;
3308 #line 1882 "/llvm/lib/AsmParser/llvmAsmParser.y"
3310 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3311 yyval.TermInstVal = S;
3315 #line 1887 "/llvm/lib/AsmParser/llvmAsmParser.y"
3317 const PointerType *PFTy;
3318 const FunctionType *Ty;
3320 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3321 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3322 // Pull out the types of all of the arguments...
3323 std::vector<const Type*> ParamTypes;
3324 if (yyvsp[-7].ValueList) {
3325 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3327 ParamTypes.push_back((*I)->getType());
3330 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3331 if (isVarArg) ParamTypes.pop_back();
3333 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3334 PFTy = PointerType::get(Ty);
3337 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3339 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3340 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3342 // Create the call node...
3343 if (!yyvsp[-7].ValueList) { // Has no arguments?
3344 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3345 } else { // Has arguments?
3346 // Loop through FunctionType's arguments and ensure they are specified
3349 FunctionType::param_iterator I = Ty->param_begin();
3350 FunctionType::param_iterator E = Ty->param_end();
3351 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3353 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3354 if ((*ArgI)->getType() != *I)
3355 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3356 (*I)->getDescription() + "'!");
3358 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3359 ThrowException("Invalid number of parameters detected!");
3361 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3363 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3365 delete yyvsp[-10].TypeVal;
3366 delete yyvsp[-7].ValueList;
3370 #line 1939 "/llvm/lib/AsmParser/llvmAsmParser.y"
3372 yyval.TermInstVal = new UnwindInst();
3376 #line 1942 "/llvm/lib/AsmParser/llvmAsmParser.y"
3378 yyval.TermInstVal = new UnreachableInst();
3382 #line 1948 "/llvm/lib/AsmParser/llvmAsmParser.y"
3384 yyval.JumpTable = yyvsp[-5].JumpTable;
3385 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3387 ThrowException("May only switch on a constant pool value!");
3389 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3393 #line 1956 "/llvm/lib/AsmParser/llvmAsmParser.y"
3395 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3396 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3399 ThrowException("May only switch on a constant pool value!");
3401 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3405 #line 1966 "/llvm/lib/AsmParser/llvmAsmParser.y"
3407 // Is this definition named?? if so, assign the name...
3408 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3409 InsertValue(yyvsp[0].InstVal);
3410 yyval.InstVal = yyvsp[0].InstVal;
3414 #line 1973 "/llvm/lib/AsmParser/llvmAsmParser.y"
3415 { // Used for PHI nodes
3416 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3417 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3418 delete yyvsp[-5].TypeVal;
3422 #line 1978 "/llvm/lib/AsmParser/llvmAsmParser.y"
3424 yyval.PHIList = yyvsp[-6].PHIList;
3425 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3426 getBBVal(yyvsp[-1].ValIDVal)));
3430 #line 1985 "/llvm/lib/AsmParser/llvmAsmParser.y"
3431 { // Used for call statements, and memory insts...
3432 yyval.ValueList = new std::vector<Value*>();
3433 yyval.ValueList->push_back(yyvsp[0].ValueVal);
3437 #line 1989 "/llvm/lib/AsmParser/llvmAsmParser.y"
3439 yyval.ValueList = yyvsp[-2].ValueList;
3440 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
3444 #line 1995 "/llvm/lib/AsmParser/llvmAsmParser.y"
3445 { yyval.ValueList = 0; ;
3448 #line 1997 "/llvm/lib/AsmParser/llvmAsmParser.y"
3450 yyval.BoolVal = true;
3454 #line 2000 "/llvm/lib/AsmParser/llvmAsmParser.y"
3456 yyval.BoolVal = false;
3460 #line 2006 "/llvm/lib/AsmParser/llvmAsmParser.y"
3462 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3463 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3465 "Arithmetic operator requires integer, FP, or packed operands!");
3466 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3467 ThrowException("Rem not supported on packed types!");
3468 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3469 if (yyval.InstVal == 0)
3470 ThrowException("binary operator returned null!");
3471 delete yyvsp[-3].TypeVal;
3475 #line 2018 "/llvm/lib/AsmParser/llvmAsmParser.y"
3477 if (!(*yyvsp[-3].TypeVal)->isIntegral())
3478 ThrowException("Logical operator requires integral operands!");
3479 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3480 if (yyval.InstVal == 0)
3481 ThrowException("binary operator returned null!");
3482 delete yyvsp[-3].TypeVal;
3486 #line 2026 "/llvm/lib/AsmParser/llvmAsmParser.y"
3488 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3490 "PackedTypes currently not supported in setcc instructions!");
3492 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3493 if (yyval.InstVal == 0)
3494 ThrowException("binary operator returned null!");
3495 delete yyvsp[-3].TypeVal;
3499 #line 2036 "/llvm/lib/AsmParser/llvmAsmParser.y"
3501 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3502 << " Replacing with 'xor'.\n";
3504 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3506 ThrowException("Expected integral type for not instruction!");
3508 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3509 if (yyval.InstVal == 0)
3510 ThrowException("Could not create a xor instruction!");
3514 #line 2048 "/llvm/lib/AsmParser/llvmAsmParser.y"
3516 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3517 ThrowException("Shift amount must be ubyte!");
3518 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3519 ThrowException("Shift constant expression requires integer operand!");
3520 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3524 #line 2055 "/llvm/lib/AsmParser/llvmAsmParser.y"
3526 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3527 ThrowException("cast instruction to a non-primitive type: '" +
3528 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3529 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3530 delete yyvsp[0].TypeVal;
3534 #line 2062 "/llvm/lib/AsmParser/llvmAsmParser.y"
3536 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3537 ThrowException("select condition must be boolean!");
3538 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3539 ThrowException("select value types should match!");
3540 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3544 #line 2069 "/llvm/lib/AsmParser/llvmAsmParser.y"
3547 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3548 delete yyvsp[0].TypeVal;
3552 #line 2074 "/llvm/lib/AsmParser/llvmAsmParser.y"
3554 ObsoleteVarArgs = true;
3555 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3556 Function* NF = CurModule.CurrentModule->
3557 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3560 //foo = alloca 1 of t
3564 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3565 CurBB->getInstList().push_back(foo);
3566 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3567 CurBB->getInstList().push_back(bar);
3568 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3569 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3570 delete yyvsp[0].TypeVal;
3574 #line 2093 "/llvm/lib/AsmParser/llvmAsmParser.y"
3576 ObsoleteVarArgs = true;
3577 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3578 Function* NF = CurModule.CurrentModule->
3579 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3581 //b = vanext a, t ->
3582 //foo = alloca 1 of t
3585 //tmp = vaarg foo, t
3587 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3588 CurBB->getInstList().push_back(foo);
3589 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3590 CurBB->getInstList().push_back(bar);
3591 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3592 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3593 CurBB->getInstList().push_back(tmp);
3594 yyval.InstVal = new LoadInst(foo);
3595 delete yyvsp[0].TypeVal;
3599 #line 2115 "/llvm/lib/AsmParser/llvmAsmParser.y"
3601 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3602 if (!Ty->isFirstClassType())
3603 ThrowException("PHI node operands must be of first class type!");
3604 yyval.InstVal = new PHINode(Ty);
3605 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3606 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3607 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3608 ThrowException("All elements of a PHI node must be of the same type!");
3609 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3610 yyvsp[0].PHIList->pop_front();
3612 delete yyvsp[0].PHIList; // Free the list...
3616 #line 2129 "/llvm/lib/AsmParser/llvmAsmParser.y"
3618 const PointerType *PFTy;
3619 const FunctionType *Ty;
3621 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3622 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3623 // Pull out the types of all of the arguments...
3624 std::vector<const Type*> ParamTypes;
3625 if (yyvsp[-1].ValueList) {
3626 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3628 ParamTypes.push_back((*I)->getType());
3631 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3632 if (isVarArg) ParamTypes.pop_back();
3634 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3635 ThrowException("LLVM functions cannot return aggregate types!");
3637 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3638 PFTy = PointerType::get(Ty);
3641 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3643 // Create the call node...
3644 if (!yyvsp[-1].ValueList) { // Has no arguments?
3645 // Make sure no arguments is a good thing!
3646 if (Ty->getNumParams() != 0)
3647 ThrowException("No arguments passed to a function that "
3648 "expects arguments!");
3650 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3651 } else { // Has arguments?
3652 // Loop through FunctionType's arguments and ensure they are specified
3655 FunctionType::param_iterator I = Ty->param_begin();
3656 FunctionType::param_iterator E = Ty->param_end();
3657 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3659 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3660 if ((*ArgI)->getType() != *I)
3661 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3662 (*I)->getDescription() + "'!");
3664 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3665 ThrowException("Invalid number of parameters detected!");
3667 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3669 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3670 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3671 delete yyvsp[-4].TypeVal;
3672 delete yyvsp[-1].ValueList;
3676 #line 2186 "/llvm/lib/AsmParser/llvmAsmParser.y"
3678 yyval.InstVal = yyvsp[0].InstVal;
3682 #line 2192 "/llvm/lib/AsmParser/llvmAsmParser.y"
3684 yyval.ValueList = yyvsp[0].ValueList;
3688 #line 2194 "/llvm/lib/AsmParser/llvmAsmParser.y"
3690 yyval.ValueList = new std::vector<Value*>();
3694 #line 2198 "/llvm/lib/AsmParser/llvmAsmParser.y"
3696 yyval.BoolVal = true;
3700 #line 2201 "/llvm/lib/AsmParser/llvmAsmParser.y"
3702 yyval.BoolVal = false;
3706 #line 2207 "/llvm/lib/AsmParser/llvmAsmParser.y"
3708 yyval.InstVal = new MallocInst(*yyvsp[0].TypeVal);
3709 delete yyvsp[0].TypeVal;
3713 #line 2211 "/llvm/lib/AsmParser/llvmAsmParser.y"
3715 yyval.InstVal = new MallocInst(*yyvsp[-3].TypeVal, 0, yyvsp[0].UInt64Val);
3716 delete yyvsp[-3].TypeVal;
3720 #line 2215 "/llvm/lib/AsmParser/llvmAsmParser.y"
3722 yyval.InstVal = new MallocInst(*yyvsp[-3].TypeVal, getVal(yyvsp[-1].PrimType, yyvsp[0].ValIDVal));
3723 delete yyvsp[-3].TypeVal;
3727 #line 2219 "/llvm/lib/AsmParser/llvmAsmParser.y"
3729 yyval.InstVal = new MallocInst(*yyvsp[-6].TypeVal, getVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal), yyvsp[0].UInt64Val);
3730 delete yyvsp[-6].TypeVal;
3734 #line 2223 "/llvm/lib/AsmParser/llvmAsmParser.y"
3736 yyval.InstVal = new AllocaInst(*yyvsp[0].TypeVal);
3737 delete yyvsp[0].TypeVal;
3741 #line 2227 "/llvm/lib/AsmParser/llvmAsmParser.y"
3743 yyval.InstVal = new AllocaInst(*yyvsp[-3].TypeVal, 0, yyvsp[0].UInt64Val);
3744 delete yyvsp[-3].TypeVal;
3748 #line 2231 "/llvm/lib/AsmParser/llvmAsmParser.y"
3750 yyval.InstVal = new AllocaInst(*yyvsp[-3].TypeVal, getVal(yyvsp[-1].PrimType, yyvsp[0].ValIDVal));
3751 delete yyvsp[-3].TypeVal;
3755 #line 2235 "/llvm/lib/AsmParser/llvmAsmParser.y"
3757 yyval.InstVal = new AllocaInst(*yyvsp[-6].TypeVal, getVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal), yyvsp[0].UInt64Val);
3758 delete yyvsp[-6].TypeVal;
3762 #line 2239 "/llvm/lib/AsmParser/llvmAsmParser.y"
3764 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3765 ThrowException("Trying to free nonpointer type " +
3766 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3767 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
3771 #line 2246 "/llvm/lib/AsmParser/llvmAsmParser.y"
3773 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3774 ThrowException("Can't load from nonpointer type: " +
3775 (*yyvsp[-1].TypeVal)->getDescription());
3776 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3777 ThrowException("Can't load from pointer of non-first-class type: " +
3778 (*yyvsp[-1].TypeVal)->getDescription());
3779 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3780 delete yyvsp[-1].TypeVal;
3784 #line 2256 "/llvm/lib/AsmParser/llvmAsmParser.y"
3786 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3788 ThrowException("Can't store to a nonpointer type: " +
3789 (*yyvsp[-1].TypeVal)->getDescription());
3790 const Type *ElTy = PT->getElementType();
3791 if (ElTy != yyvsp[-3].ValueVal->getType())
3792 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3793 "' into space of type '" + ElTy->getDescription() + "'!");
3795 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3796 delete yyvsp[-1].TypeVal;
3800 #line 2269 "/llvm/lib/AsmParser/llvmAsmParser.y"
3802 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3803 ThrowException("getelementptr insn requires pointer operand!");
3805 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3806 // indices to uint struct indices for compatibility.
3807 generic_gep_type_iterator<std::vector<Value*>::iterator>
3808 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3809 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3810 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3811 if (isa<StructType>(*GTI)) // Only change struct indices
3812 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3813 if (CUI->getType() == Type::UByteTy)
3814 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3816 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3817 ThrowException("Invalid getelementptr indices for type '" +
3818 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3819 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3820 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
3824 /* the action file gets copied in in place of this dollarsign */
3825 #line 543 "/usr/share/bison.simple"
3836 short *ssp1 = yyss - 1;
3837 fprintf (stderr, "state stack now");
3838 while (ssp1 != yyssp)
3839 fprintf (stderr, " %d", *++ssp1);
3840 fprintf (stderr, "\n");
3850 yylsp->first_line = yylloc.first_line;
3851 yylsp->first_column = yylloc.first_column;
3852 yylsp->last_line = (yylsp-1)->last_line;
3853 yylsp->last_column = (yylsp-1)->last_column;
3858 yylsp->last_line = (yylsp+yylen-1)->last_line;
3859 yylsp->last_column = (yylsp+yylen-1)->last_column;
3863 /* Now "shift" the result of the reduction.
3864 Determine what state that goes to,
3865 based on the state we popped back to
3866 and the rule number reduced by. */
3870 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
3871 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
3872 yystate = yytable[yystate];
3874 yystate = yydefgoto[yyn - YYNTBASE];
3878 yyerrlab: /* here on detecting error */
3881 /* If not already recovering from an error, report this error. */
3885 #ifdef YYERROR_VERBOSE
3886 yyn = yypact[yystate];
3888 if (yyn > YYFLAG && yyn < YYLAST)
3895 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
3896 for (x = (yyn < 0 ? -yyn : 0);
3897 x < (sizeof(yytname) / sizeof(char *)); x++)
3898 if (yycheck[x + yyn] == x)
3899 size += strlen(yytname[x]) + 15, count++;
3900 msg = (char *) malloc(size + 15);
3903 strcpy(msg, "parse error");
3908 for (x = (yyn < 0 ? -yyn : 0);
3909 x < (sizeof(yytname) / sizeof(char *)); x++)
3910 if (yycheck[x + yyn] == x)
3912 strcat(msg, count == 0 ? ", expecting `" : " or `");
3913 strcat(msg, yytname[x]);
3922 yyerror ("parse error; also virtual memory exceeded");
3925 #endif /* YYERROR_VERBOSE */
3926 yyerror("parse error");
3930 yyerrlab1: /* here on error raised explicitly by an action */
3932 if (yyerrstatus == 3)
3934 /* if just tried and failed to reuse lookahead token after an error, discard it. */
3936 /* return failure if at end of input */
3937 if (yychar == YYEOF)
3942 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
3948 /* Else will try to reuse lookahead token
3949 after shifting the error token. */
3951 yyerrstatus = 3; /* Each real token shifted decrements this */
3955 yyerrdefault: /* current state does not do anything special for the error token. */
3958 /* This is wrong; only states that explicitly want error tokens
3959 should shift them. */
3960 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
3961 if (yyn) goto yydefault;
3964 yyerrpop: /* pop the current state because it cannot handle the error token */
3966 if (yyssp == yyss) YYABORT;
3976 short *ssp1 = yyss - 1;
3977 fprintf (stderr, "Error: state stack now");
3978 while (ssp1 != yyssp)
3979 fprintf (stderr, " %d", *++ssp1);
3980 fprintf (stderr, "\n");
3986 yyn = yypact[yystate];
3991 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4010 fprintf(stderr, "Shifting error token, ");
4022 /* YYACCEPT comes here. */
4034 /* YYABORT comes here. */
4045 #line 2292 "/llvm/lib/AsmParser/llvmAsmParser.y"
4047 int yyerror(const char *ErrorMsg) {
4049 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4050 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4051 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4052 if (yychar == YYEMPTY || yychar == 0)
4053 errMsg += "end-of-file.";
4055 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4056 ThrowException(errMsg);