2 /* A Bison parser, made from /Users/sabre/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
62 #define POINTERSIZE 305
71 #define SIDEEFFECT 314
74 #define FASTCC_TOK 317
75 #define COLDCC_TOK 318
81 #define UNREACHABLE 324
101 #define GETELEMENTPTR 344
108 #define EXTRACTELEMENT 351
109 #define INSERTELEMENT 352
110 #define VAARG_old 353
111 #define VANEXT_old 354
113 #line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
115 #include "ParserInternals.h"
116 #include "llvm/CallingConv.h"
117 #include "llvm/InlineAsm.h"
118 #include "llvm/Instructions.h"
119 #include "llvm/Module.h"
120 #include "llvm/SymbolTable.h"
121 #include "llvm/Assembly/AutoUpgrade.h"
122 #include "llvm/Support/GetElementPtrTypeIterator.h"
123 #include "llvm/ADT/STLExtras.h"
124 #include "llvm/Support/MathExtras.h"
130 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
131 int yylex(); // declaration" of xxx warnings.
135 std::string CurFilename;
137 using namespace llvm;
139 static Module *ParserResult;
141 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
142 // relating to upreferences in the input stream.
144 //#define DEBUG_UPREFS 1
146 #define UR_OUT(X) std::cerr << X
151 #define YYERROR_VERBOSE 1
153 static bool ObsoleteVarArgs;
154 static bool NewVarArgs;
155 static BasicBlock *CurBB;
156 static GlobalVariable *CurGV;
159 // This contains info used when building the body of a function. It is
160 // destroyed when the function is completed.
162 typedef std::vector<Value *> ValueList; // Numbered defs
164 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
165 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
167 static struct PerModuleInfo {
168 Module *CurrentModule;
169 std::map<const Type *, ValueList> Values; // Module level numbered definitions
170 std::map<const Type *,ValueList> LateResolveValues;
171 std::vector<PATypeHolder> Types;
172 std::map<ValID, PATypeHolder> LateResolveTypes;
174 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
175 /// how they were referenced and one which line of the input they came from so
176 /// that we can resolve them later and print error messages as appropriate.
177 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
179 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
180 // references to global values. Global values may be referenced before they
181 // are defined, and if so, the temporary object that they represent is held
182 // here. This is used for forward references of GlobalValues.
184 typedef std::map<std::pair<const PointerType *,
185 ValID>, GlobalValue*> GlobalRefsType;
186 GlobalRefsType GlobalRefs;
189 // If we could not resolve some functions at function compilation time
190 // (calls to functions before they are defined), resolve them now... Types
191 // are resolved when the constant pool has been completely parsed.
193 ResolveDefinitions(LateResolveValues);
195 // Check to make sure that all global value forward references have been
198 if (!GlobalRefs.empty()) {
199 std::string UndefinedReferences = "Unresolved global references exist:\n";
201 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
203 UndefinedReferences += " " + I->first.first->getDescription() + " " +
204 I->first.second.getName() + "\n";
206 ThrowException(UndefinedReferences);
209 // Look for intrinsic functions and CallInst that need to be upgraded
210 for (Module::iterator FI = CurrentModule->begin(),FE = CurrentModule->end();
212 UpgradeCallsToIntrinsic(FI++);
214 Values.clear(); // Clear out function local definitions
219 // GetForwardRefForGlobal - Check to see if there is a forward reference
220 // for this global. If so, remove it from the GlobalRefs map and return it.
221 // If not, just return null.
222 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
223 // Check to see if there is a forward reference to this global variable...
224 // if there is, eliminate it and patch the reference to use the new def'n.
225 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
226 GlobalValue *Ret = 0;
227 if (I != GlobalRefs.end()) {
235 static struct PerFunctionInfo {
236 Function *CurrentFunction; // Pointer to current function being created
238 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
239 std::map<const Type*, ValueList> LateResolveValues;
240 bool isDeclare; // Is this function a forward declararation?
242 /// BBForwardRefs - When we see forward references to basic blocks, keep
243 /// track of them here.
244 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
245 std::vector<BasicBlock*> NumberedBlocks;
248 inline PerFunctionInfo() {
253 inline void FunctionStart(Function *M) {
258 void FunctionDone() {
259 NumberedBlocks.clear();
261 // Any forward referenced blocks left?
262 if (!BBForwardRefs.empty())
263 ThrowException("Undefined reference to label " +
264 BBForwardRefs.begin()->first->getName());
266 // Resolve all forward references now.
267 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
269 Values.clear(); // Clear out function local definitions
273 } CurFun; // Info for the current function...
275 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
278 //===----------------------------------------------------------------------===//
279 // Code to handle definitions of all the types
280 //===----------------------------------------------------------------------===//
282 static int InsertValue(Value *V,
283 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
284 if (V->hasName()) return -1; // Is this a numbered definition?
286 // Yes, insert the value into the value table...
287 ValueList &List = ValueTab[V->getType()];
289 return List.size()-1;
292 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
294 case ValID::NumberVal: // Is it a numbered definition?
295 // Module constants occupy the lowest numbered slots...
296 if ((unsigned)D.Num < CurModule.Types.size())
297 return CurModule.Types[(unsigned)D.Num];
299 case ValID::NameVal: // Is it a named definition?
300 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
301 D.destroy(); // Free old strdup'd memory...
306 ThrowException("Internal parser error: Invalid symbol type reference!");
309 // If we reached here, we referenced either a symbol that we don't know about
310 // or an id number that hasn't been read yet. We may be referencing something
311 // forward, so just create an entry to be resolved later and get to it...
313 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
316 if (inFunctionScope()) {
317 if (D.Type == ValID::NameVal)
318 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
320 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
323 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
324 if (I != CurModule.LateResolveTypes.end())
327 Type *Typ = OpaqueType::get();
328 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
332 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
333 SymbolTable &SymTab =
334 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
335 CurModule.CurrentModule->getSymbolTable();
336 return SymTab.lookup(Ty, Name);
339 // getValNonImprovising - Look up the value specified by the provided type and
340 // the provided ValID. If the value exists and has already been defined, return
341 // it. Otherwise return null.
343 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
344 if (isa<FunctionType>(Ty))
345 ThrowException("Functions are not values and "
346 "must be referenced as pointers");
349 case ValID::NumberVal: { // Is it a numbered definition?
350 unsigned Num = (unsigned)D.Num;
352 // Module constants occupy the lowest numbered slots...
353 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
354 if (VI != CurModule.Values.end()) {
355 if (Num < VI->second.size())
356 return VI->second[Num];
357 Num -= VI->second.size();
360 // Make sure that our type is within bounds
361 VI = CurFun.Values.find(Ty);
362 if (VI == CurFun.Values.end()) return 0;
364 // Check that the number is within bounds...
365 if (VI->second.size() <= Num) return 0;
367 return VI->second[Num];
370 case ValID::NameVal: { // Is it a named definition?
371 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
372 if (N == 0) return 0;
374 D.destroy(); // Free old strdup'd memory...
378 // Check to make sure that "Ty" is an integral type, and that our
379 // value will fit into the specified type...
380 case ValID::ConstSIntVal: // Is it a constant pool reference??
381 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
382 ThrowException("Signed integral constant '" +
383 itostr(D.ConstPool64) + "' is invalid for type '" +
384 Ty->getDescription() + "'!");
385 return ConstantSInt::get(Ty, D.ConstPool64);
387 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
388 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
389 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
390 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
391 "' is invalid or out of range!");
392 } else { // This is really a signed reference. Transmogrify.
393 return ConstantSInt::get(Ty, D.ConstPool64);
396 return ConstantUInt::get(Ty, D.UConstPool64);
399 case ValID::ConstFPVal: // Is it a floating point const pool reference?
400 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
401 ThrowException("FP constant invalid for type!!");
402 return ConstantFP::get(Ty, D.ConstPoolFP);
404 case ValID::ConstNullVal: // Is it a null value?
405 if (!isa<PointerType>(Ty))
406 ThrowException("Cannot create a a non pointer null!");
407 return ConstantPointerNull::get(cast<PointerType>(Ty));
409 case ValID::ConstUndefVal: // Is it an undef value?
410 return UndefValue::get(Ty);
412 case ValID::ConstZeroVal: // Is it a zero value?
413 return Constant::getNullValue(Ty);
415 case ValID::ConstantVal: // Fully resolved constant?
416 if (D.ConstantValue->getType() != Ty)
417 ThrowException("Constant expression type different from required type!");
418 return D.ConstantValue;
420 case ValID::InlineAsmVal: { // Inline asm expression
421 const PointerType *PTy = dyn_cast<PointerType>(Ty);
422 const FunctionType *FTy =
423 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
424 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
425 ThrowException("Invalid type for asm constraint string!");
426 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
427 D.IAD->HasSideEffects);
428 D.destroy(); // Free InlineAsmDescriptor.
432 assert(0 && "Unhandled case!");
436 assert(0 && "Unhandled case!");
440 // getVal - This function is identical to getValNonImprovising, except that if a
441 // value is not already defined, it "improvises" by creating a placeholder var
442 // that looks and acts just like the requested variable. When the value is
443 // defined later, all uses of the placeholder variable are replaced with the
446 static Value *getVal(const Type *Ty, const ValID &ID) {
447 if (Ty == Type::LabelTy)
448 ThrowException("Cannot use a basic block here");
450 // See if the value has already been defined.
451 Value *V = getValNonImprovising(Ty, ID);
454 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
455 ThrowException("Invalid use of a composite type!");
457 // If we reached here, we referenced either a symbol that we don't know about
458 // or an id number that hasn't been read yet. We may be referencing something
459 // forward, so just create an entry to be resolved later and get to it...
461 V = new Argument(Ty);
463 // Remember where this forward reference came from. FIXME, shouldn't we try
464 // to recycle these things??
465 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
468 if (inFunctionScope())
469 InsertValue(V, CurFun.LateResolveValues);
471 InsertValue(V, CurModule.LateResolveValues);
475 /// getBBVal - This is used for two purposes:
476 /// * If isDefinition is true, a new basic block with the specified ID is being
478 /// * If isDefinition is true, this is a reference to a basic block, which may
479 /// or may not be a forward reference.
481 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
482 assert(inFunctionScope() && "Can't get basic block at global scope!");
487 default: ThrowException("Illegal label reference " + ID.getName());
488 case ValID::NumberVal: // Is it a numbered definition?
489 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
490 CurFun.NumberedBlocks.resize(ID.Num+1);
491 BB = CurFun.NumberedBlocks[ID.Num];
493 case ValID::NameVal: // Is it a named definition?
495 if (Value *N = CurFun.CurrentFunction->
496 getSymbolTable().lookup(Type::LabelTy, Name))
497 BB = cast<BasicBlock>(N);
501 // See if the block has already been defined.
503 // If this is the definition of the block, make sure the existing value was
504 // just a forward reference. If it was a forward reference, there will be
505 // an entry for it in the PlaceHolderInfo map.
506 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
507 // The existing value was a definition, not a forward reference.
508 ThrowException("Redefinition of label " + ID.getName());
510 ID.destroy(); // Free strdup'd memory.
514 // Otherwise this block has not been seen before.
515 BB = new BasicBlock("", CurFun.CurrentFunction);
516 if (ID.Type == ValID::NameVal) {
517 BB->setName(ID.Name);
519 CurFun.NumberedBlocks[ID.Num] = BB;
522 // If this is not a definition, keep track of it so we can use it as a forward
525 // Remember where this forward reference came from.
526 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
528 // The forward declaration could have been inserted anywhere in the
529 // function: insert it into the correct place now.
530 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
531 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
538 //===----------------------------------------------------------------------===//
539 // Code to handle forward references in instructions
540 //===----------------------------------------------------------------------===//
542 // This code handles the late binding needed with statements that reference
543 // values not defined yet... for example, a forward branch, or the PHI node for
546 // This keeps a table (CurFun.LateResolveValues) of all such forward references
547 // and back patchs after we are done.
550 // ResolveDefinitions - If we could not resolve some defs at parsing
551 // time (forward branches, phi functions for loops, etc...) resolve the
555 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
556 std::map<const Type*,ValueList> *FutureLateResolvers) {
557 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
558 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
559 E = LateResolvers.end(); LRI != E; ++LRI) {
560 ValueList &List = LRI->second;
561 while (!List.empty()) {
562 Value *V = List.back();
565 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
566 CurModule.PlaceHolderInfo.find(V);
567 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
569 ValID &DID = PHI->second.first;
571 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
573 V->replaceAllUsesWith(TheRealValue);
575 CurModule.PlaceHolderInfo.erase(PHI);
576 } else if (FutureLateResolvers) {
577 // Functions have their unresolved items forwarded to the module late
579 InsertValue(V, *FutureLateResolvers);
581 if (DID.Type == ValID::NameVal)
582 ThrowException("Reference to an invalid definition: '" +DID.getName()+
583 "' of type '" + V->getType()->getDescription() + "'",
586 ThrowException("Reference to an invalid definition: #" +
587 itostr(DID.Num) + " of type '" +
588 V->getType()->getDescription() + "'",
594 LateResolvers.clear();
597 // ResolveTypeTo - A brand new type was just declared. This means that (if
598 // name is not null) things referencing Name can be resolved. Otherwise, things
599 // refering to the number can be resolved. Do this now.
601 static void ResolveTypeTo(char *Name, const Type *ToTy) {
603 if (Name) D = ValID::create(Name);
604 else D = ValID::create((int)CurModule.Types.size());
606 std::map<ValID, PATypeHolder>::iterator I =
607 CurModule.LateResolveTypes.find(D);
608 if (I != CurModule.LateResolveTypes.end()) {
609 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
610 CurModule.LateResolveTypes.erase(I);
614 // setValueName - Set the specified value to the name given. The name may be
615 // null potentially, in which case this is a noop. The string passed in is
616 // assumed to be a malloc'd string buffer, and is free'd by this function.
618 static void setValueName(Value *V, char *NameStr) {
620 std::string Name(NameStr); // Copy string
621 free(NameStr); // Free old string
623 if (V->getType() == Type::VoidTy)
624 ThrowException("Can't assign name '" + Name+"' to value with void type!");
626 assert(inFunctionScope() && "Must be in function scope!");
627 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
628 if (ST.lookup(V->getType(), Name))
629 ThrowException("Redefinition of value named '" + Name + "' in the '" +
630 V->getType()->getDescription() + "' type plane!");
637 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
638 /// this is a declaration, otherwise it is a definition.
639 static GlobalVariable *
640 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
641 bool isConstantGlobal, const Type *Ty,
642 Constant *Initializer) {
643 if (isa<FunctionType>(Ty))
644 ThrowException("Cannot declare global vars of function type!");
646 const PointerType *PTy = PointerType::get(Ty);
650 Name = NameStr; // Copy string
651 free(NameStr); // Free old string
654 // See if this global value was forward referenced. If so, recycle the
658 ID = ValID::create((char*)Name.c_str());
660 ID = ValID::create((int)CurModule.Values[PTy].size());
663 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
664 // Move the global to the end of the list, from whereever it was
665 // previously inserted.
666 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
667 CurModule.CurrentModule->getGlobalList().remove(GV);
668 CurModule.CurrentModule->getGlobalList().push_back(GV);
669 GV->setInitializer(Initializer);
670 GV->setLinkage(Linkage);
671 GV->setConstant(isConstantGlobal);
672 InsertValue(GV, CurModule.Values);
676 // If this global has a name, check to see if there is already a definition
677 // of this global in the module. If so, merge as appropriate. Note that
678 // this is really just a hack around problems in the CFE. :(
680 // We are a simple redefinition of a value, check to see if it is defined
681 // the same as the old one.
682 if (GlobalVariable *EGV =
683 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
684 // We are allowed to redefine a global variable in two circumstances:
685 // 1. If at least one of the globals is uninitialized or
686 // 2. If both initializers have the same value.
688 if (!EGV->hasInitializer() || !Initializer ||
689 EGV->getInitializer() == Initializer) {
691 // Make sure the existing global version gets the initializer! Make
692 // sure that it also gets marked const if the new version is.
693 if (Initializer && !EGV->hasInitializer())
694 EGV->setInitializer(Initializer);
695 if (isConstantGlobal)
696 EGV->setConstant(true);
697 EGV->setLinkage(Linkage);
701 ThrowException("Redefinition of global variable named '" + Name +
702 "' in the '" + Ty->getDescription() + "' type plane!");
706 // Otherwise there is no existing GV to use, create one now.
708 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
709 CurModule.CurrentModule);
710 InsertValue(GV, CurModule.Values);
714 // setTypeName - Set the specified type to the name given. The name may be
715 // null potentially, in which case this is a noop. The string passed in is
716 // assumed to be a malloc'd string buffer, and is freed by this function.
718 // This function returns true if the type has already been defined, but is
719 // allowed to be redefined in the specified context. If the name is a new name
720 // for the type plane, it is inserted and false is returned.
721 static bool setTypeName(const Type *T, char *NameStr) {
722 assert(!inFunctionScope() && "Can't give types function-local names!");
723 if (NameStr == 0) return false;
725 std::string Name(NameStr); // Copy string
726 free(NameStr); // Free old string
728 // We don't allow assigning names to void type
729 if (T == Type::VoidTy)
730 ThrowException("Can't assign name '" + Name + "' to the void type!");
732 // Set the type name, checking for conflicts as we do so.
733 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
735 if (AlreadyExists) { // Inserting a name that is already defined???
736 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
737 assert(Existing && "Conflict but no matching type?");
739 // There is only one case where this is allowed: when we are refining an
740 // opaque type. In this case, Existing will be an opaque type.
741 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
742 // We ARE replacing an opaque type!
743 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
747 // Otherwise, this is an attempt to redefine a type. That's okay if
748 // the redefinition is identical to the original. This will be so if
749 // Existing and T point to the same Type object. In this one case we
750 // allow the equivalent redefinition.
751 if (Existing == T) return true; // Yes, it's equal.
753 // Any other kind of (non-equivalent) redefinition is an error.
754 ThrowException("Redefinition of type named '" + Name + "' in the '" +
755 T->getDescription() + "' type plane!");
761 //===----------------------------------------------------------------------===//
762 // Code for handling upreferences in type names...
765 // TypeContains - Returns true if Ty directly contains E in it.
767 static bool TypeContains(const Type *Ty, const Type *E) {
768 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
769 E) != Ty->subtype_end();
774 // NestingLevel - The number of nesting levels that need to be popped before
775 // this type is resolved.
776 unsigned NestingLevel;
778 // LastContainedTy - This is the type at the current binding level for the
779 // type. Every time we reduce the nesting level, this gets updated.
780 const Type *LastContainedTy;
782 // UpRefTy - This is the actual opaque type that the upreference is
786 UpRefRecord(unsigned NL, OpaqueType *URTy)
787 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
791 // UpRefs - A list of the outstanding upreferences that need to be resolved.
792 static std::vector<UpRefRecord> UpRefs;
794 /// HandleUpRefs - Every time we finish a new layer of types, this function is
795 /// called. It loops through the UpRefs vector, which is a list of the
796 /// currently active types. For each type, if the up reference is contained in
797 /// the newly completed type, we decrement the level count. When the level
798 /// count reaches zero, the upreferenced type is the type that is passed in:
799 /// thus we can complete the cycle.
801 static PATypeHolder HandleUpRefs(const Type *ty) {
802 if (!ty->isAbstract()) return ty;
804 UR_OUT("Type '" << Ty->getDescription() <<
805 "' newly formed. Resolving upreferences.\n" <<
806 UpRefs.size() << " upreferences active!\n");
808 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
809 // to zero), we resolve them all together before we resolve them to Ty. At
810 // the end of the loop, if there is anything to resolve to Ty, it will be in
812 OpaqueType *TypeToResolve = 0;
814 for (unsigned i = 0; i != UpRefs.size(); ++i) {
815 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
816 << UpRefs[i].second->getDescription() << ") = "
817 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
818 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
819 // Decrement level of upreference
820 unsigned Level = --UpRefs[i].NestingLevel;
821 UpRefs[i].LastContainedTy = Ty;
822 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
823 if (Level == 0) { // Upreference should be resolved!
824 if (!TypeToResolve) {
825 TypeToResolve = UpRefs[i].UpRefTy;
827 UR_OUT(" * Resolving upreference for "
828 << UpRefs[i].second->getDescription() << "\n";
829 std::string OldName = UpRefs[i].UpRefTy->getDescription());
830 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
831 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
832 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
834 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
835 --i; // Do not skip the next element...
841 UR_OUT(" * Resolving upreference for "
842 << UpRefs[i].second->getDescription() << "\n";
843 std::string OldName = TypeToResolve->getDescription());
844 TypeToResolve->refineAbstractTypeTo(Ty);
851 // common code from the two 'RunVMAsmParser' functions
852 static Module * RunParser(Module * M) {
854 llvmAsmlineno = 1; // Reset the current line number...
855 ObsoleteVarArgs = false;
858 CurModule.CurrentModule = M;
859 yyparse(); // Parse the file, potentially throwing exception
861 Module *Result = ParserResult;
864 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
867 if ((F = Result->getNamedFunction("llvm.va_start"))
868 && F->getFunctionType()->getNumParams() == 0)
869 ObsoleteVarArgs = true;
870 if((F = Result->getNamedFunction("llvm.va_copy"))
871 && F->getFunctionType()->getNumParams() == 1)
872 ObsoleteVarArgs = true;
875 if (ObsoleteVarArgs && NewVarArgs)
876 ThrowException("This file is corrupt: it uses both new and old style varargs");
878 if(ObsoleteVarArgs) {
879 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
880 if (F->arg_size() != 0)
881 ThrowException("Obsolete va_start takes 0 argument!");
885 //bar = alloca typeof(foo)
889 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
890 const Type* ArgTy = F->getFunctionType()->getReturnType();
891 const Type* ArgTyPtr = PointerType::get(ArgTy);
892 Function* NF = Result->getOrInsertFunction("llvm.va_start",
893 RetTy, ArgTyPtr, (Type *)0);
895 while (!F->use_empty()) {
896 CallInst* CI = cast<CallInst>(F->use_back());
897 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
898 new CallInst(NF, bar, "", CI);
899 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
900 CI->replaceAllUsesWith(foo);
901 CI->getParent()->getInstList().erase(CI);
903 Result->getFunctionList().erase(F);
906 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
907 if(F->arg_size() != 1)
908 ThrowException("Obsolete va_end takes 1 argument!");
912 //bar = alloca 1 of typeof(foo)
914 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
915 const Type* ArgTy = F->getFunctionType()->getParamType(0);
916 const Type* ArgTyPtr = PointerType::get(ArgTy);
917 Function* NF = Result->getOrInsertFunction("llvm.va_end",
918 RetTy, ArgTyPtr, (Type *)0);
920 while (!F->use_empty()) {
921 CallInst* CI = cast<CallInst>(F->use_back());
922 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
923 new StoreInst(CI->getOperand(1), bar, CI);
924 new CallInst(NF, bar, "", CI);
925 CI->getParent()->getInstList().erase(CI);
927 Result->getFunctionList().erase(F);
930 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
931 if(F->arg_size() != 1)
932 ThrowException("Obsolete va_copy takes 1 argument!");
935 //a = alloca 1 of typeof(foo)
936 //b = alloca 1 of typeof(foo)
941 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
942 const Type* ArgTy = F->getFunctionType()->getReturnType();
943 const Type* ArgTyPtr = PointerType::get(ArgTy);
944 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
945 RetTy, ArgTyPtr, ArgTyPtr,
948 while (!F->use_empty()) {
949 CallInst* CI = cast<CallInst>(F->use_back());
950 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
951 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
952 new StoreInst(CI->getOperand(1), b, CI);
953 new CallInst(NF, a, b, "", CI);
954 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
955 CI->replaceAllUsesWith(foo);
956 CI->getParent()->getInstList().erase(CI);
958 Result->getFunctionList().erase(F);
966 //===----------------------------------------------------------------------===//
967 // RunVMAsmParser - Define an interface to this parser
968 //===----------------------------------------------------------------------===//
970 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
973 CurFilename = Filename;
974 return RunParser(new Module(CurFilename));
977 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
978 set_scan_string(AsmString);
980 CurFilename = "from_memory";
982 return RunParser(new Module (CurFilename));
989 #line 890 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
991 llvm::Module *ModuleVal;
992 llvm::Function *FunctionVal;
993 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
994 llvm::BasicBlock *BasicBlockVal;
995 llvm::TerminatorInst *TermInstVal;
996 llvm::Instruction *InstVal;
997 llvm::Constant *ConstVal;
999 const llvm::Type *PrimType;
1000 llvm::PATypeHolder *TypeVal;
1001 llvm::Value *ValueVal;
1003 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1004 std::vector<llvm::Value*> *ValueList;
1005 std::list<llvm::PATypeHolder> *TypeList;
1006 // Represent the RHS of PHI node
1007 std::list<std::pair<llvm::Value*,
1008 llvm::BasicBlock*> > *PHIList;
1009 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1010 std::vector<llvm::Constant*> *ConstVector;
1012 llvm::GlobalValue::LinkageTypes Linkage;
1020 char *StrVal; // This memory is strdup'd!
1021 llvm::ValID ValIDVal; // strdup'd memory maybe!
1023 llvm::Instruction::BinaryOps BinaryOpVal;
1024 llvm::Instruction::TermOps TermOpVal;
1025 llvm::Instruction::MemoryOps MemOpVal;
1026 llvm::Instruction::OtherOps OtherOpVal;
1027 llvm::Module::Endianness Endianness;
1040 #define YYFLAG -32768
1041 #define YYNTBASE 115
1043 #define YYTRANSLATE(x) ((unsigned)(x) <= 354 ? yytranslate[x] : 186)
1045 static const char yytranslate[] = { 0,
1046 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 2, 2, 2, 2, 104,
1050 105, 113, 2, 102, 2, 2, 2, 2, 2, 2,
1051 2, 2, 2, 2, 2, 2, 2, 2, 2, 109,
1052 101, 110, 2, 2, 2, 2, 2, 2, 2, 2,
1053 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1055 106, 103, 108, 2, 2, 2, 2, 2, 114, 2,
1056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1057 2, 2, 2, 2, 2, 2, 2, 2, 2, 107,
1058 2, 2, 111, 2, 112, 2, 2, 2, 2, 2,
1059 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1060 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1061 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1062 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1063 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1064 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1065 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1066 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1067 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1071 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1072 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1073 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1074 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1075 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1076 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1077 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1078 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1079 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1080 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1085 static const short yyprhs[] = { 0,
1086 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1087 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1088 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1089 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1090 78, 80, 82, 84, 87, 88, 91, 92, 96, 99,
1091 100, 102, 103, 107, 109, 112, 114, 116, 118, 120,
1092 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1093 142, 144, 146, 148, 150, 152, 154, 157, 162, 168,
1094 174, 178, 181, 184, 186, 190, 192, 196, 198, 199,
1095 204, 208, 212, 217, 222, 226, 229, 232, 235, 238,
1096 241, 244, 247, 250, 253, 256, 263, 269, 278, 285,
1097 292, 299, 306, 313, 317, 319, 321, 323, 325, 328,
1098 331, 336, 339, 341, 346, 349, 354, 355, 363, 364,
1099 372, 376, 381, 382, 384, 386, 388, 392, 396, 400,
1100 404, 408, 410, 411, 413, 415, 417, 418, 421, 425,
1101 427, 429, 433, 435, 436, 445, 447, 449, 453, 455,
1102 457, 460, 461, 465, 466, 468, 470, 472, 474, 476,
1103 478, 480, 482, 484, 488, 490, 496, 498, 500, 502,
1104 504, 507, 510, 513, 517, 520, 521, 523, 526, 529,
1105 533, 543, 553, 562, 576, 578, 580, 587, 593, 596,
1106 603, 611, 613, 617, 619, 620, 623, 625, 631, 637,
1107 643, 646, 651, 656, 663, 668, 673, 678, 683, 690,
1108 693, 701, 703, 706, 707, 709, 710, 714, 721, 725,
1112 static const short yyrhs[] = { 5,
1113 0, 6, 0, 3, 0, 4, 0, 71, 0, 72,
1114 0, 73, 0, 74, 0, 75, 0, 76, 0, 77,
1115 0, 78, 0, 79, 0, 80, 0, 81, 0, 82,
1116 0, 83, 0, 84, 0, 94, 0, 95, 0, 16,
1117 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1118 0, 13, 0, 11, 0, 121, 0, 122, 0, 18,
1119 0, 19, 0, 155, 101, 0, 0, 41, 0, 42,
1120 0, 43, 0, 44, 0, 0, 0, 62, 0, 63,
1121 0, 64, 0, 61, 4, 0, 0, 54, 4, 0,
1122 0, 102, 54, 4, 0, 34, 24, 0, 0, 130,
1123 0, 0, 102, 133, 132, 0, 130, 0, 54, 4,
1124 0, 136, 0, 8, 0, 138, 0, 8, 0, 138,
1125 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1126 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
1127 0, 19, 0, 20, 0, 21, 0, 45, 0, 137,
1128 0, 169, 0, 103, 4, 0, 135, 104, 140, 105,
1129 0, 106, 4, 107, 138, 108, 0, 109, 4, 107,
1130 138, 110, 0, 111, 139, 112, 0, 111, 112, 0,
1131 138, 113, 0, 138, 0, 139, 102, 138, 0, 139,
1132 0, 139, 102, 37, 0, 37, 0, 0, 136, 106,
1133 143, 108, 0, 136, 106, 108, 0, 136, 114, 24,
1134 0, 136, 109, 143, 110, 0, 136, 111, 143, 112,
1135 0, 136, 111, 112, 0, 136, 38, 0, 136, 39,
1136 0, 136, 169, 0, 136, 142, 0, 136, 26, 0,
1137 121, 116, 0, 122, 4, 0, 9, 27, 0, 9,
1138 28, 0, 124, 7, 0, 92, 104, 141, 36, 136,
1139 105, 0, 90, 104, 141, 183, 105, 0, 93, 104,
1140 141, 102, 141, 102, 141, 105, 0, 117, 104, 141,
1141 102, 141, 105, 0, 118, 104, 141, 102, 141, 105,
1142 0, 119, 104, 141, 102, 141, 105, 0, 120, 104,
1143 141, 102, 141, 105, 0, 97, 104, 141, 102, 141,
1144 105, 0, 143, 102, 141, 0, 141, 0, 32, 0,
1145 33, 0, 146, 0, 146, 164, 0, 146, 165, 0,
1146 146, 59, 58, 150, 0, 146, 25, 0, 147, 0,
1147 147, 125, 20, 134, 0, 147, 165, 0, 147, 59,
1148 58, 150, 0, 0, 147, 125, 126, 144, 141, 148,
1149 132, 0, 0, 147, 125, 47, 144, 136, 149, 132,
1150 0, 147, 48, 152, 0, 147, 55, 101, 153, 0,
1151 0, 24, 0, 53, 0, 52, 0, 50, 101, 151,
1152 0, 51, 101, 4, 0, 49, 101, 24, 0, 106,
1153 154, 108, 0, 154, 102, 24, 0, 24, 0, 0,
1154 22, 0, 24, 0, 155, 0, 0, 136, 156, 0,
1155 158, 102, 157, 0, 157, 0, 158, 0, 158, 102,
1156 37, 0, 37, 0, 0, 127, 134, 155, 104, 159,
1157 105, 131, 128, 0, 29, 0, 111, 0, 126, 160,
1158 161, 0, 30, 0, 112, 0, 172, 163, 0, 0,
1159 31, 166, 160, 0, 0, 60, 0, 3, 0, 4,
1160 0, 7, 0, 27, 0, 28, 0, 38, 0, 39,
1161 0, 26, 0, 109, 143, 110, 0, 142, 0, 58,
1162 167, 24, 102, 24, 0, 115, 0, 155, 0, 169,
1163 0, 168, 0, 136, 170, 0, 172, 173, 0, 162,
1164 173, 0, 174, 125, 175, 0, 174, 177, 0, 0,
1165 23, 0, 65, 171, 0, 65, 8, 0, 66, 21,
1166 170, 0, 66, 9, 170, 102, 21, 170, 102, 21,
1167 170, 0, 67, 123, 170, 102, 21, 170, 106, 176,
1168 108, 0, 67, 123, 170, 102, 21, 170, 106, 108,
1169 0, 68, 127, 134, 170, 104, 180, 105, 36, 21,
1170 170, 69, 21, 170, 0, 69, 0, 70, 0, 176,
1171 123, 168, 102, 21, 170, 0, 123, 168, 102, 21,
1172 170, 0, 125, 182, 0, 136, 106, 170, 102, 170,
1173 108, 0, 178, 102, 106, 170, 102, 170, 108, 0,
1174 171, 0, 179, 102, 171, 0, 179, 0, 0, 57,
1175 56, 0, 56, 0, 117, 136, 170, 102, 170, 0,
1176 118, 136, 170, 102, 170, 0, 119, 136, 170, 102,
1177 170, 0, 46, 171, 0, 120, 171, 102, 171, 0,
1178 92, 171, 36, 136, 0, 93, 171, 102, 171, 102,
1179 171, 0, 96, 171, 102, 136, 0, 99, 171, 102,
1180 136, 0, 100, 171, 102, 136, 0, 97, 171, 102,
1181 171, 0, 98, 171, 102, 171, 102, 171, 0, 91,
1182 178, 0, 181, 127, 134, 170, 104, 180, 105, 0,
1183 185, 0, 102, 179, 0, 0, 35, 0, 0, 85,
1184 136, 129, 0, 85, 136, 102, 15, 170, 129, 0,
1185 86, 136, 129, 0, 86, 136, 102, 15, 170, 129,
1186 0, 87, 171, 0, 184, 88, 136, 170, 0, 184,
1187 89, 171, 102, 136, 170, 0, 90, 136, 170, 183,
1194 static const short yyrline[] = { 0,
1195 1010, 1011, 1018, 1019, 1028, 1028, 1028, 1028, 1028, 1029,
1196 1029, 1029, 1030, 1030, 1030, 1030, 1030, 1030, 1032, 1032,
1197 1036, 1036, 1036, 1036, 1037, 1037, 1037, 1037, 1038, 1038,
1198 1039, 1039, 1042, 1045, 1049, 1049, 1050, 1051, 1052, 1055,
1199 1055, 1056, 1057, 1058, 1067, 1067, 1073, 1073, 1081, 1088,
1200 1088, 1094, 1094, 1096, 1100, 1113, 1113, 1114, 1114, 1116,
1201 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1126, 1126, 1126,
1202 1126, 1126, 1126, 1127, 1130, 1133, 1139, 1146, 1158, 1162,
1203 1173, 1182, 1185, 1193, 1197, 1202, 1203, 1206, 1209, 1219,
1204 1244, 1257, 1286, 1311, 1331, 1343, 1352, 1356, 1415, 1421,
1205 1429, 1434, 1439, 1442, 1445, 1452, 1462, 1493, 1500, 1521,
1206 1531, 1536, 1543, 1553, 1556, 1563, 1563, 1573, 1580, 1584,
1207 1587, 1590, 1593, 1606, 1626, 1628, 1630, 1633, 1636, 1640,
1208 1643, 1645, 1647, 1651, 1663, 1664, 1666, 1669, 1677, 1682,
1209 1684, 1688, 1692, 1700, 1700, 1701, 1701, 1703, 1709, 1714,
1210 1720, 1723, 1728, 1732, 1736, 1822, 1822, 1824, 1832, 1832,
1211 1834, 1838, 1838, 1847, 1850, 1854, 1857, 1860, 1863, 1866,
1212 1869, 1872, 1875, 1878, 1902, 1905, 1918, 1921, 1926, 1926,
1213 1932, 1936, 1939, 1947, 1956, 1960, 1970, 1981, 1984, 1987,
1214 1990, 1993, 2007, 2011, 2064, 2067, 2073, 2081, 2091, 2098,
1215 2103, 2110, 2114, 2120, 2120, 2122, 2125, 2131, 2143, 2154,
1216 2164, 2176, 2183, 2190, 2197, 2202, 2221, 2243, 2251, 2263,
1217 2277, 2334, 2340, 2342, 2346, 2349, 2355, 2359, 2363, 2367,
1218 2371, 2378, 2388, 2401
1223 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1225 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1226 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1227 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1228 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1229 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1230 "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1231 "OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
1232 "BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1233 "CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE",
1234 "ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT",
1235 "SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK",
1236 "CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","VAARG_old",
1237 "VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'",
1238 "'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps","SetCondOps",
1239 "ShiftOps","SIntType","UIntType","IntType","FPType","OptAssign","OptLinkage",
1240 "OptCallingConv","OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes",
1241 "GlobalVarAttribute","TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI",
1242 "ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList",
1243 "ConstPool","@1","@2","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
1244 "LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1245 "FunctionHeader","END","Function","FunctionProto","@3","OptSideEffect","ConstValueRef",
1246 "SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1247 "BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","ValueRefListE",
1248 "OptTailCall","InstVal","IndexList","OptVolatile","MemoryInst", NULL
1252 static const short yyr1[] = { 0,
1253 115, 115, 116, 116, 117, 117, 117, 117, 117, 118,
1254 118, 118, 119, 119, 119, 119, 119, 119, 120, 120,
1255 121, 121, 121, 121, 122, 122, 122, 122, 123, 123,
1256 124, 124, 125, 125, 126, 126, 126, 126, 126, 127,
1257 127, 127, 127, 127, 128, 128, 129, 129, 130, 131,
1258 131, 132, 132, 133, 133, 134, 134, 135, 135, 136,
1259 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
1260 137, 137, 137, 138, 138, 138, 138, 138, 138, 138,
1261 138, 138, 138, 139, 139, 140, 140, 140, 140, 141,
1262 141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
1263 141, 141, 141, 141, 141, 142, 142, 142, 142, 142,
1264 142, 142, 142, 143, 143, 144, 144, 145, 146, 146,
1265 146, 146, 146, 147, 147, 147, 148, 147, 149, 147,
1266 147, 147, 147, 150, 151, 151, 152, 152, 152, 153,
1267 154, 154, 154, 155, 155, 156, 156, 157, 158, 158,
1268 159, 159, 159, 159, 160, 161, 161, 162, 163, 163,
1269 164, 166, 165, 167, 167, 168, 168, 168, 168, 168,
1270 168, 168, 168, 168, 168, 168, 169, 169, 170, 170,
1271 171, 172, 172, 173, 174, 174, 174, 175, 175, 175,
1272 175, 175, 175, 175, 175, 175, 176, 176, 177, 178,
1273 178, 179, 179, 180, 180, 181, 181, 182, 182, 182,
1274 182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
1275 182, 182, 183, 183, 184, 184, 185, 185, 185, 185,
1279 static const short yyr2[] = { 0,
1280 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1281 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1282 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1283 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1284 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1285 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1286 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1287 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1288 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1289 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1290 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1291 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
1292 4, 2, 1, 4, 2, 4, 0, 7, 0, 7,
1293 3, 4, 0, 1, 1, 1, 3, 3, 3, 3,
1294 3, 1, 0, 1, 1, 1, 0, 2, 3, 1,
1295 1, 3, 1, 0, 8, 1, 1, 3, 1, 1,
1296 2, 0, 3, 0, 1, 1, 1, 1, 1, 1,
1297 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
1298 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
1299 9, 9, 8, 13, 1, 1, 6, 5, 2, 6,
1300 7, 1, 3, 1, 0, 2, 1, 5, 5, 5,
1301 2, 4, 4, 6, 4, 4, 4, 4, 6, 2,
1302 7, 1, 2, 0, 1, 0, 3, 6, 3, 6,
1306 static const short yydefact[] = { 133,
1307 39, 123, 122, 162, 35, 36, 37, 38, 0, 40,
1308 186, 119, 120, 186, 144, 145, 0, 0, 0, 39,
1309 0, 125, 40, 0, 0, 41, 42, 43, 0, 0,
1310 187, 183, 34, 159, 160, 161, 182, 0, 0, 0,
1311 131, 0, 0, 0, 0, 0, 33, 163, 134, 121,
1312 44, 1, 2, 57, 61, 62, 63, 64, 65, 66,
1313 67, 68, 69, 70, 71, 72, 73, 74, 0, 0,
1314 0, 0, 177, 0, 0, 56, 75, 60, 178, 76,
1315 156, 157, 158, 226, 185, 0, 0, 0, 143, 132,
1316 126, 124, 116, 117, 0, 0, 77, 0, 0, 59,
1317 82, 84, 0, 0, 89, 83, 225, 0, 207, 0,
1318 0, 0, 0, 40, 195, 196, 5, 6, 7, 8,
1319 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1320 0, 0, 0, 0, 0, 0, 0, 19, 20, 0,
1321 0, 0, 0, 0, 0, 0, 0, 0, 184, 40,
1322 199, 0, 222, 139, 136, 135, 137, 138, 142, 0,
1323 129, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1324 70, 71, 0, 0, 0, 0, 127, 0, 0, 0,
1325 81, 154, 88, 86, 0, 0, 211, 206, 189, 188,
1326 0, 0, 24, 28, 23, 27, 22, 26, 21, 25,
1327 29, 30, 0, 0, 47, 47, 231, 0, 0, 220,
1328 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1329 0, 0, 0, 0, 0, 140, 52, 103, 104, 3,
1330 4, 101, 102, 105, 100, 96, 97, 0, 0, 0,
1331 0, 0, 0, 0, 0, 0, 0, 0, 0, 99,
1332 98, 52, 58, 58, 85, 153, 147, 150, 151, 0,
1333 0, 78, 166, 167, 168, 173, 169, 170, 171, 172,
1334 164, 0, 175, 180, 179, 181, 0, 190, 0, 0,
1335 0, 227, 0, 229, 224, 0, 0, 0, 0, 0,
1336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1337 0, 141, 0, 130, 0, 0, 0, 0, 91, 115,
1338 0, 0, 95, 0, 92, 0, 0, 0, 0, 128,
1339 79, 80, 146, 148, 0, 50, 87, 165, 0, 0,
1340 0, 0, 0, 0, 0, 0, 0, 234, 0, 0,
1341 213, 0, 215, 218, 0, 216, 217, 0, 0, 0,
1342 212, 0, 232, 0, 0, 0, 54, 52, 224, 0,
1343 0, 0, 0, 90, 93, 94, 0, 0, 0, 0,
1344 152, 149, 51, 45, 0, 174, 0, 0, 205, 47,
1345 48, 47, 202, 223, 0, 0, 0, 0, 208, 209,
1346 210, 205, 0, 49, 55, 53, 0, 0, 0, 0,
1347 114, 0, 0, 0, 0, 0, 155, 0, 0, 0,
1348 204, 0, 0, 228, 230, 0, 0, 0, 214, 219,
1349 0, 233, 107, 0, 0, 0, 0, 0, 0, 0,
1350 46, 176, 0, 0, 0, 203, 200, 0, 221, 106,
1351 0, 113, 109, 110, 111, 112, 0, 193, 0, 0,
1352 0, 201, 0, 191, 0, 192, 0, 0, 108, 0,
1353 0, 0, 0, 0, 0, 198, 0, 0, 197, 194,
1357 static const short yydefgoto[] = { 73,
1358 232, 246, 247, 248, 249, 173, 174, 203, 175, 20,
1359 10, 29, 407, 282, 357, 374, 304, 358, 74, 75,
1360 186, 77, 78, 103, 185, 310, 273, 311, 95, 471,
1361 1, 2, 252, 227, 50, 157, 41, 90, 160, 79,
1362 324, 258, 259, 260, 30, 83, 11, 36, 12, 13,
1363 23, 329, 274, 80, 276, 383, 14, 32, 33, 149,
1364 450, 85, 210, 411, 412, 150, 151, 338, 152, 153
1367 static const short yypact[] = {-32768,
1368 30, 99,-32768,-32768,-32768,-32768,-32768,-32768, -47, 46,
1369 33,-32768,-32768, -13,-32768,-32768, 75, -32, 26, 21,
1370 -3,-32768, 46, 63, 100,-32768,-32768,-32768, 974, -21,
1371 -32768,-32768, 105,-32768,-32768,-32768,-32768, 10, 27, 32,
1372 -32768, 38, 63, 974, 103, 103,-32768,-32768,-32768,-32768,
1373 -32768,-32768,-32768, 18,-32768,-32768,-32768,-32768,-32768,-32768,
1374 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 135, 148,
1375 155, 490,-32768, 105, 67,-32768,-32768, -64,-32768,-32768,
1376 -32768,-32768,-32768, 1136,-32768, 149, 85, 172, 154,-32768,
1377 -32768,-32768,-32768,-32768, 1012, 1050,-32768, 73, 76,-32768,
1378 -32768, -64, -17, 80, 784,-32768,-32768, 1012,-32768, 129,
1379 1088, 23, 221, 46,-32768,-32768,-32768,-32768,-32768,-32768,
1380 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1381 1012, 1012, 1012, 1012, 1012, 1012, 1012,-32768,-32768, 1012,
1382 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,-32768, 46,
1383 -32768, 60,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -14,
1384 -32768, 123, 153, 182, 159, 186, 162, 187, 164, 188,
1385 189, 190, 166, 194, 193, 372,-32768, 1012, 1012, 1012,
1386 -32768, 822,-32768, 101, 102, 622,-32768,-32768, 18,-32768,
1387 622, 622,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1388 -32768,-32768, 622, 974, 104, 107,-32768, 622, 98, 108,
1389 169, 109, 110, 118, 119, 120, 121, 622, 622, 622,
1390 122, 974, 1012, 1012, 201,-32768, 124,-32768,-32768,-32768,
1391 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 136, 137, 138,
1392 141, 860, 1050, 531, 215, 142, 143, 144, 146,-32768,
1393 -32768, 124, -75, -53, -64,-32768, 105,-32768, 150, 139,
1394 898,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1395 191, 1050,-32768,-32768,-32768,-32768, 151,-32768, 152, 622,
1396 5,-32768, 16,-32768, 158, 622, 156, 1012, 1012, 1012,
1397 1012, 1012, 1012, 1012, 161, 165, 168, 1012, 622, 622,
1398 170,-32768, -18,-32768, 1050, 1050, 1050, 1050,-32768,-32768,
1399 -11, -65,-32768, -16,-32768, 1050, 1050, 1050, 1050,-32768,
1400 -32768,-32768,-32768,-32768, 936, 222,-32768,-32768, 233, -10,
1401 245, 250, 171, 622, 269, 622, 1012,-32768, 178, 622,
1402 -32768, 179,-32768,-32768, 180,-32768,-32768, 622, 622, 622,
1403 -32768, 181,-32768, 1012, 259, 280,-32768, 124, 158, 255,
1404 184, 192, 1050,-32768,-32768,-32768, 197, 198, 199, 200,
1405 -32768,-32768,-32768, 238, 202,-32768, 622, 622, 1012, 204,
1406 -32768, 204,-32768, 205, 622, 206, 1012, 1012,-32768,-32768,
1407 -32768, 1012, 622,-32768,-32768,-32768, 207, 1012, 1050, 1050,
1408 -32768, 1050, 1050, 1050, 1050, 289,-32768, 271, 218, 223,
1409 205, 216, 270,-32768,-32768, 1012, 219, 622,-32768,-32768,
1410 225,-32768,-32768, 228, 226, 230, 231, 232, 235, 236,
1411 -32768,-32768, 321, 12, 308,-32768,-32768, 237,-32768,-32768,
1412 1050,-32768,-32768,-32768,-32768,-32768, 622,-32768, 682, 66,
1413 328,-32768, 246,-32768, 248,-32768, 682, 622,-32768, 332,
1414 253, 287, 622, 336, 340,-32768, 622, 622,-32768,-32768,
1418 static const short yypgoto[] = {-32768,
1419 -32768, 281, 282, 283, 284, -112, -111, -415,-32768, 339,
1420 359, -102,-32768, -201, 54,-32768, -243,-32768, -40,-32768,
1421 -29,-32768, -66, 276,-32768, -89, 208, -230, 337,-32768,
1422 -32768,-32768,-32768,-32768, 342,-32768,-32768,-32768,-32768, 1,
1423 -32768, 57,-32768,-32768, 365,-32768,-32768,-32768,-32768, 384,
1424 -32768,-32768, -356, -31, 140, -90,-32768, 375,-32768,-32768,
1425 -32768,-32768,-32768, 53, -1,-32768,-32768, 34,-32768,-32768
1432 static const short yytable[] = { 76,
1433 201, 202, 21, 92, 284, 102, 177, 81, 320, 31,
1434 24, 204, 312, 314, 76, 355, 34, 187, 449, 334,
1435 190, 193, 194, 195, 196, 197, 198, 199, 200, -118,
1436 336, 191, 321, 21, 457, 356, 363, 106, 102, -58,
1437 44, 330, 207, 192, 365, 211, 212, 222, 106, 213,
1438 214, 215, 216, 217, 3, 31, 322, 221, 335, 106,
1439 4, 5, 6, 7, 8, 161, 176, 45, 42, 335,
1440 5, 6, 7, 8, 104, 193, 194, 195, 196, 197,
1441 198, 199, 200, 43, 180, 363, 49, 225, 9, 82,
1442 363, 363, 455, 226, 181, 366, 364, 47, 35, 376,
1443 461, 205, 206, 51, 208, 209, 25, 26, 27, 28,
1444 86, 253, 254, 255, 396, 218, 219, 220, -34, 448,
1445 15, -59, 16, 38, 39, 40, 15, 87, 16, 4,
1446 -34, -34, 88, 301, 93, 94, 155, 156, 97, -34,
1447 -34, -34, -34, 89, 251, -34, 17, 223, 224, 228,
1448 229, 98, 257, 18, 275, -24, -24, 19, 99, 275,
1449 275, -23, -23, 280, -22, -22, -21, -21, 230, 231,
1450 105, 275, 154, 456, 76, 158, 275, 159, 414, 178,
1451 415, 299, 179, 182, 188, -28, 275, 275, 275, -27,
1452 -26, -25, 76, 300, 255, -31, -32, 233, 342, 234,
1453 344, 345, 261, 286, 288, 281, 262, 351, 283, 287,
1454 289, 290, 176, 176, 176, 359, 360, 361, 362, 291,
1455 292, 293, 294, 298, 302, 303, 367, 368, 369, 370,
1456 193, 194, 195, 196, 197, 198, 199, 200, 315, 305,
1457 306, 307, 176, 326, 308, 316, 317, 318, 275, 319,
1458 328, 325, 331, 332, 275, 355, 375, 323, 341, 337,
1459 343, 340, 348, 346, 347, 377, 349, 275, 275, 350,
1460 378, 354, 381, 401, 379, 176, 176, 176, 176, 385,
1461 387, 388, 394, 395, 392, 399, 176, 176, 176, 176,
1462 398, 406, 431, 400, 432, 257, 419, 420, 402, 403,
1463 404, 405, 275, 408, 275, 413, 416, 418, 275, 425,
1464 426, 423, 427, 428, 429, 430, 275, 275, 275, 433,
1465 435, 201, 202, 335, 393, 436, 437, 441, 434, 439,
1466 277, 278, 440, 176, 442, 443, 444, 201, 202, 445,
1467 446, 447, 279, 451, 452, 275, 275, 285, 458, 460,
1468 459, 453, 463, 275, 464, 465, 467, 295, 296, 297,
1469 468, 275, 472, 473, 145, 146, 147, 148, 424, 176,
1470 176, 84, 176, 176, 176, 176, 52, 53, 46, 373,
1471 184, 372, 96, 250, 91, 22, 275, 48, 37, 384,
1472 421, 0, 397, 15, 0, 16, 0, 235, 0, 0,
1473 0, 0, 0, 0, 0, 0, 0, 0, 0, 236,
1474 237, 176, 0, 0, 0, 275, 0, 0, 0, 333,
1475 0, 0, 0, 0, 0, 339, 275, 0, 0, 0,
1476 0, 275, 0, 0, 0, 275, 275, 0, 352, 353,
1477 0, 0, 117, 118, 119, 120, 121, 122, 123, 124,
1478 125, 126, 127, 128, 129, 130, 0, 0, 0, 0,
1479 0, 238, 0, 239, 240, 138, 139, 0, 241, 0,
1480 0, 0, 0, 380, 0, 382, 0, 242, 0, 386,
1481 243, 0, 244, 0, 0, 245, 0, 389, 390, 391,
1482 0, 0, 0, 0, 52, 53, 0, 100, 55, 56,
1483 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1484 67, 15, 0, 16, 0, 0, 409, 410, 0, 0,
1485 0, 0, 0, 0, 417, 0, 0, 0, 0, 0,
1486 0, 0, 422, 0, 68, 52, 53, 0, 100, 162,
1487 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
1488 66, 67, 15, 0, 16, 0, 0, 438, 0, 0,
1489 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1490 0, 0, 0, 0, 0, 68, 0, 0, 0, 0,
1491 0, 0, 0, 0, 0, 0, 454, 0, 0, 0,
1492 0, 0, 69, 0, 0, 70, 0, 462, 71, 0,
1493 72, 101, 466, 0, 0, 0, 469, 470, 0, 0,
1494 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1495 0, 0, 0, 0, 263, 264, 52, 53, 265, 0,
1496 0, 0, 0, 69, 0, 0, 70, 0, 0, 71,
1497 0, 72, 313, 15, 0, 16, 0, 266, 267, 268,
1498 0, 0, 0, 0, 0, 0, 0, 0, 0, 269,
1499 270, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1500 0, 0, 0, 0, 0, 0, 0, 0, 0, 271,
1501 0, 0, 0, 0, 263, 264, 0, 0, 265, 0,
1502 0, 0, 117, 118, 119, 120, 121, 122, 123, 124,
1503 125, 126, 127, 128, 129, 130, 0, 266, 267, 268,
1504 0, 238, 0, 239, 240, 138, 139, 0, 241, 269,
1505 270, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1506 272, 0, 0, 0, 0, 0, 0, 0, 0, 271,
1507 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1508 0, 0, 117, 118, 119, 120, 121, 122, 123, 124,
1509 125, 126, 127, 128, 129, 130, 0, 0, 0, 0,
1510 0, 238, 0, 239, 240, 138, 139, 0, 241, 0,
1511 0, 0, 0, 0, 0, 0, 0, 0, 52, 53,
1512 272, 100, 55, 56, 57, 58, 59, 60, 61, 62,
1513 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
1514 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1515 183, 0, 0, 0, 0, 0, 52, 53, 68, 100,
1516 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1517 65, 66, 67, 15, 0, 16, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 0, 0, 0, 256, 0,
1519 0, 0, 0, 0, 52, 53, 68, 100, 162, 163,
1520 164, 165, 166, 167, 168, 169, 170, 171, 172, 66,
1521 67, 15, 0, 16, 0, 0, 69, 0, 0, 70,
1522 0, 0, 71, 0, 72, 0, 0, 0, 0, 0,
1523 0, 0, 52, 53, 68, 100, 55, 56, 57, 58,
1524 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
1525 0, 16, 0, 0, 69, 0, 0, 70, 0, 0,
1526 71, 0, 72, 0, 327, 0, 0, 0, 0, 0,
1527 52, 53, 68, 100, 55, 56, 57, 58, 59, 60,
1528 61, 62, 63, 64, 65, 66, 67, 15, 0, 16,
1529 0, 0, 69, 0, 0, 70, 0, 309, 71, 0,
1530 72, 0, 371, 0, 0, 0, 0, 0, 52, 53,
1531 68, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1532 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
1533 69, 0, 0, 70, 0, 0, 71, 0, 72, 0,
1534 0, 0, 0, 0, 0, 0, 52, 53, 68, 100,
1535 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1536 65, 66, 67, 15, 0, 16, 0, 0, 69, 0,
1537 0, 70, 0, 0, 71, 0, 72, 0, 0, 0,
1538 0, 0, 0, 0, 52, 53, 68, 100, 162, 163,
1539 164, 165, 166, 167, 168, 169, 170, 171, 172, 66,
1540 67, 15, 0, 16, 0, 0, 69, 0, 0, 70,
1541 0, 0, 71, 0, 72, 0, 0, 0, 0, 0,
1542 0, 0, 52, 53, 68, 189, 55, 56, 57, 58,
1543 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
1544 0, 16, 0, 0, 69, 0, 0, 70, 0, 0,
1545 71, 0, 72, 0, 0, 0, 0, 0, 0, 0,
1546 0, 0, 68, 0, 0, 0, 0, 0, 0, 0,
1547 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1548 0, 0, 69, 0, 0, 70, 0, 0, 71, 0,
1549 72, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1550 107, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1551 0, 108, 0, 0, 0, 0, 0, 0, 0, 0,
1552 69, 109, 110, 70, 0, 0, 71, 0, 72, 0,
1553 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1554 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1555 131, 132, 133, 0, 0, 134, 135, 136, 137, 138,
1556 139, 140, 141, 142, 143, 144
1559 static const short yycheck[] = { 29,
1560 113, 113, 2, 44, 206, 72, 96, 29, 252, 23,
1561 58, 114, 243, 244, 44, 34, 30, 108, 434, 15,
1562 111, 10, 11, 12, 13, 14, 15, 16, 17, 0,
1563 15, 9, 108, 33, 450, 54, 102, 113, 105, 104,
1564 20, 272, 133, 21, 110, 136, 137, 150, 113, 140,
1565 141, 142, 143, 144, 25, 23, 110, 148, 54, 113,
1566 31, 41, 42, 43, 44, 95, 96, 47, 101, 54,
1567 41, 42, 43, 44, 74, 10, 11, 12, 13, 14,
1568 15, 16, 17, 58, 102, 102, 24, 102, 59, 111,
1569 102, 102, 449, 108, 112, 112, 108, 101, 112, 110,
1570 457, 131, 132, 4, 134, 135, 61, 62, 63, 64,
1571 101, 178, 179, 180, 358, 145, 146, 147, 20, 108,
1572 22, 104, 24, 49, 50, 51, 22, 101, 24, 31,
1573 32, 33, 101, 224, 32, 33, 52, 53, 4, 41,
1574 42, 43, 44, 106, 176, 47, 48, 88, 89, 27,
1575 28, 4, 182, 55, 186, 3, 4, 59, 4, 191,
1576 192, 3, 4, 204, 3, 4, 3, 4, 3, 4,
1577 104, 203, 24, 108, 204, 4, 208, 24, 380, 107,
1578 382, 222, 107, 104, 56, 4, 218, 219, 220, 4,
1579 4, 4, 222, 223, 261, 7, 7, 4, 289, 7,
1580 291, 292, 102, 106, 36, 102, 105, 298, 102, 102,
1581 102, 102, 242, 243, 244, 305, 306, 307, 308, 102,
1582 102, 102, 102, 102, 24, 102, 316, 317, 318, 319,
1583 10, 11, 12, 13, 14, 15, 16, 17, 24, 104,
1584 104, 104, 272, 105, 104, 104, 104, 104, 280, 104,
1585 60, 102, 102, 102, 286, 34, 24, 257, 288, 102,
1586 290, 106, 102, 293, 294, 21, 102, 299, 300, 102,
1587 21, 102, 4, 363, 104, 305, 306, 307, 308, 102,
1588 102, 102, 24, 4, 104, 102, 316, 317, 318, 319,
1589 36, 54, 4, 102, 24, 325, 387, 388, 102, 102,
1590 102, 102, 334, 102, 336, 102, 102, 102, 340, 399,
1591 400, 105, 402, 403, 404, 405, 348, 349, 350, 102,
1592 105, 434, 434, 54, 354, 416, 108, 102, 106, 105,
1593 191, 192, 105, 363, 105, 105, 105, 450, 450, 105,
1594 105, 21, 203, 36, 108, 377, 378, 208, 21, 102,
1595 105, 441, 21, 385, 102, 69, 21, 218, 219, 220,
1596 21, 393, 0, 0, 84, 84, 84, 84, 398, 399,
1597 400, 33, 402, 403, 404, 405, 5, 6, 20, 326,
1598 105, 325, 46, 176, 43, 2, 418, 23, 14, 337,
1599 392, -1, 359, 22, -1, 24, -1, 26, -1, -1,
1600 -1, -1, -1, -1, -1, -1, -1, -1, -1, 38,
1601 39, 441, -1, -1, -1, 447, -1, -1, -1, 280,
1602 -1, -1, -1, -1, -1, 286, 458, -1, -1, -1,
1603 -1, 463, -1, -1, -1, 467, 468, -1, 299, 300,
1604 -1, -1, 71, 72, 73, 74, 75, 76, 77, 78,
1605 79, 80, 81, 82, 83, 84, -1, -1, -1, -1,
1606 -1, 90, -1, 92, 93, 94, 95, -1, 97, -1,
1607 -1, -1, -1, 334, -1, 336, -1, 106, -1, 340,
1608 109, -1, 111, -1, -1, 114, -1, 348, 349, 350,
1609 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
1610 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1611 21, 22, -1, 24, -1, -1, 377, 378, -1, -1,
1612 -1, -1, -1, -1, 385, -1, -1, -1, -1, -1,
1613 -1, -1, 393, -1, 45, 5, 6, -1, 8, 9,
1614 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1615 20, 21, 22, -1, 24, -1, -1, 418, -1, -1,
1616 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1617 -1, -1, -1, -1, -1, 45, -1, -1, -1, -1,
1618 -1, -1, -1, -1, -1, -1, 447, -1, -1, -1,
1619 -1, -1, 103, -1, -1, 106, -1, 458, 109, -1,
1620 111, 112, 463, -1, -1, -1, 467, 468, -1, -1,
1621 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1622 -1, -1, -1, -1, 3, 4, 5, 6, 7, -1,
1623 -1, -1, -1, 103, -1, -1, 106, -1, -1, 109,
1624 -1, 111, 112, 22, -1, 24, -1, 26, 27, 28,
1625 -1, -1, -1, -1, -1, -1, -1, -1, -1, 38,
1626 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1627 -1, -1, -1, -1, -1, -1, -1, -1, -1, 58,
1628 -1, -1, -1, -1, 3, 4, -1, -1, 7, -1,
1629 -1, -1, 71, 72, 73, 74, 75, 76, 77, 78,
1630 79, 80, 81, 82, 83, 84, -1, 26, 27, 28,
1631 -1, 90, -1, 92, 93, 94, 95, -1, 97, 38,
1632 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1633 109, -1, -1, -1, -1, -1, -1, -1, -1, 58,
1634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1635 -1, -1, 71, 72, 73, 74, 75, 76, 77, 78,
1636 79, 80, 81, 82, 83, 84, -1, -1, -1, -1,
1637 -1, 90, -1, 92, 93, 94, 95, -1, 97, -1,
1638 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1639 109, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1640 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1641 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1642 37, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1643 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1644 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1645 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
1646 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1647 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1648 21, 22, -1, 24, -1, -1, 103, -1, -1, 106,
1649 -1, -1, 109, -1, 111, -1, -1, -1, -1, -1,
1650 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1651 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1652 -1, 24, -1, -1, 103, -1, -1, 106, -1, -1,
1653 109, -1, 111, -1, 37, -1, -1, -1, -1, -1,
1654 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1655 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1656 -1, -1, 103, -1, -1, 106, -1, 108, 109, -1,
1657 111, -1, 37, -1, -1, -1, -1, -1, 5, 6,
1658 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1659 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1660 103, -1, -1, 106, -1, -1, 109, -1, 111, -1,
1661 -1, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1662 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1663 19, 20, 21, 22, -1, 24, -1, -1, 103, -1,
1664 -1, 106, -1, -1, 109, -1, 111, -1, -1, -1,
1665 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1666 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1667 21, 22, -1, 24, -1, -1, 103, -1, -1, 106,
1668 -1, -1, 109, -1, 111, -1, -1, -1, -1, -1,
1669 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1670 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1671 -1, 24, -1, -1, 103, -1, -1, 106, -1, -1,
1672 109, -1, 111, -1, -1, -1, -1, -1, -1, -1,
1673 -1, -1, 45, -1, -1, -1, -1, -1, -1, -1,
1674 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1675 -1, -1, 103, -1, -1, 106, -1, -1, 109, -1,
1676 111, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1677 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1678 -1, 46, -1, -1, -1, -1, -1, -1, -1, -1,
1679 103, 56, 57, 106, -1, -1, 109, -1, 111, -1,
1680 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1681 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1682 85, 86, 87, -1, -1, 90, 91, 92, 93, 94,
1683 95, 96, 97, 98, 99, 100
1685 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1686 #line 3 "/usr/share/bison.simple"
1687 /* This file comes from bison-1.28. */
1689 /* Skeleton output parser for bison,
1690 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1692 This program is free software; you can redistribute it and/or modify
1693 it under the terms of the GNU General Public License as published by
1694 the Free Software Foundation; either version 2, or (at your option)
1697 This program is distributed in the hope that it will be useful,
1698 but WITHOUT ANY WARRANTY; without even the implied warranty of
1699 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1700 GNU General Public License for more details.
1702 You should have received a copy of the GNU General Public License
1703 along with this program; if not, write to the Free Software
1704 Foundation, Inc., 59 Temple Place - Suite 330,
1705 Boston, MA 02111-1307, USA. */
1707 /* As a special exception, when this file is copied by Bison into a
1708 Bison output file, you may use that output file without restriction.
1709 This special exception was added by the Free Software Foundation
1710 in version 1.24 of Bison. */
1712 /* This is the parser code that is written into each bison parser
1713 when the %semantic_parser declaration is not specified in the grammar.
1714 It was written by Richard Stallman by simplifying the hairy parser
1715 used when %semantic_parser is specified. */
1717 #ifndef YYSTACK_USE_ALLOCA
1719 #define YYSTACK_USE_ALLOCA
1720 #else /* alloca not defined */
1722 #define YYSTACK_USE_ALLOCA
1723 #define alloca __builtin_alloca
1724 #else /* not GNU C. */
1725 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1726 #define YYSTACK_USE_ALLOCA
1728 #else /* not sparc */
1729 /* We think this test detects Watcom and Microsoft C. */
1730 /* This used to test MSDOS, but that is a bad idea
1731 since that symbol is in the user namespace. */
1732 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1733 #if 0 /* No need for malloc.h, which pollutes the namespace;
1734 instead, just don't use alloca. */
1737 #else /* not MSDOS, or __TURBOC__ */
1739 /* I don't know what this was needed for, but it pollutes the namespace.
1740 So I turned it off. rms, 2 May 1997. */
1741 /* #include <malloc.h> */
1743 #define YYSTACK_USE_ALLOCA
1744 #else /* not MSDOS, or __TURBOC__, or _AIX */
1746 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1747 and on HPUX 10. Eventually we can turn this on. */
1748 #define YYSTACK_USE_ALLOCA
1749 #define alloca __builtin_alloca
1752 #endif /* not _AIX */
1753 #endif /* not MSDOS, or __TURBOC__ */
1754 #endif /* not sparc */
1755 #endif /* not GNU C */
1756 #endif /* alloca not defined */
1757 #endif /* YYSTACK_USE_ALLOCA not defined */
1759 #ifdef YYSTACK_USE_ALLOCA
1760 #define YYSTACK_ALLOC alloca
1762 #define YYSTACK_ALLOC malloc
1765 /* Note: there must be only one dollar sign in this file.
1766 It is replaced by the list of actions, each action
1767 as one case of the switch. */
1769 #define yyerrok (yyerrstatus = 0)
1770 #define yyclearin (yychar = YYEMPTY)
1773 #define YYACCEPT goto yyacceptlab
1774 #define YYABORT goto yyabortlab
1775 #define YYERROR goto yyerrlab1
1776 /* Like YYERROR except do call yyerror.
1777 This remains here temporarily to ease the
1778 transition to the new meaning of YYERROR, for GCC.
1779 Once GCC version 2 has supplanted version 1, this can go. */
1780 #define YYFAIL goto yyerrlab
1781 #define YYRECOVERING() (!!yyerrstatus)
1782 #define YYBACKUP(token, value) \
1784 if (yychar == YYEMPTY && yylen == 1) \
1785 { yychar = (token), yylval = (value); \
1786 yychar1 = YYTRANSLATE (yychar); \
1791 { yyerror ("syntax error: cannot back up"); YYERROR; } \
1795 #define YYERRCODE 256
1798 #define YYLEX yylex()
1804 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
1806 #define YYLEX yylex(&yylval, &yylloc)
1808 #else /* not YYLSP_NEEDED */
1810 #define YYLEX yylex(&yylval, YYLEX_PARAM)
1812 #define YYLEX yylex(&yylval)
1814 #endif /* not YYLSP_NEEDED */
1817 /* If nonreentrant, generate the variables here */
1821 int yychar; /* the lookahead symbol */
1822 YYSTYPE yylval; /* the semantic value of the */
1823 /* lookahead symbol */
1826 YYLTYPE yylloc; /* location data for the lookahead */
1830 int yynerrs; /* number of parse errors so far */
1831 #endif /* not YYPURE */
1834 int yydebug; /* nonzero means print parse trace */
1835 /* Since this is uninitialized, it does not stop multiple parsers
1839 /* YYINITDEPTH indicates the initial size of the parser's stacks */
1842 #define YYINITDEPTH 200
1845 /* YYMAXDEPTH is the maximum size the stacks can grow to
1846 (effective only if the built-in stack extension method is used). */
1853 #define YYMAXDEPTH 10000
1856 /* Define __yy_memcpy. Note that the size argument
1857 should be passed with type unsigned int, because that is what the non-GCC
1858 definitions require. With GCC, __builtin_memcpy takes an arg
1859 of type size_t, but it can handle unsigned int. */
1861 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1862 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1863 #else /* not GNU C or C++ */
1866 /* This is the most reliable way to avoid incompatibilities
1867 in available built-in functions on various systems. */
1869 __yy_memcpy (to, from, count)
1874 register char *f = from;
1875 register char *t = to;
1876 register int i = count;
1882 #else /* __cplusplus */
1884 /* This is the most reliable way to avoid incompatibilities
1885 in available built-in functions on various systems. */
1887 __yy_memcpy (char *to, char *from, unsigned int count)
1889 register char *t = to;
1890 register char *f = from;
1891 register int i = count;
1900 #line 217 "/usr/share/bison.simple"
1902 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1903 into yyparse. The argument should have type void *.
1904 It should actually point to an object.
1905 Grammar actions can access the variable by casting it
1906 to the proper pointer type. */
1908 #ifdef YYPARSE_PARAM
1910 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1911 #define YYPARSE_PARAM_DECL
1912 #else /* not __cplusplus */
1913 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1914 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1915 #endif /* not __cplusplus */
1916 #else /* not YYPARSE_PARAM */
1917 #define YYPARSE_PARAM_ARG
1918 #define YYPARSE_PARAM_DECL
1919 #endif /* not YYPARSE_PARAM */
1921 /* Prevent warning if -Wstrict-prototypes. */
1923 #ifdef YYPARSE_PARAM
1924 int yyparse (void *);
1931 yyparse(YYPARSE_PARAM_ARG)
1934 register int yystate;
1936 register short *yyssp;
1937 register YYSTYPE *yyvsp;
1938 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1939 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1941 short yyssa[YYINITDEPTH]; /* the state stack */
1942 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1944 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1945 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1948 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1949 YYLTYPE *yyls = yylsa;
1952 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1954 #define YYPOPSTACK (yyvsp--, yyssp--)
1957 int yystacksize = YYINITDEPTH;
1958 int yyfree_stacks = 0;
1969 YYSTYPE yyval; /* the variable used to return */
1970 /* semantic values from the action */
1977 fprintf(stderr, "Starting parse\n");
1983 yychar = YYEMPTY; /* Cause a token to be read. */
1985 /* Initialize stack pointers.
1986 Waste one element of value and location stack
1987 so that they stay on the same level as the state stack.
1988 The wasted elements are never initialized. */
1996 /* Push a new state, which is found in yystate . */
1997 /* In all cases, when you get here, the value and location stacks
1998 have just been pushed. so pushing a state here evens the stacks. */
2003 if (yyssp >= yyss + yystacksize - 1)
2005 /* Give user a chance to reallocate the stack */
2006 /* Use copies of these so that the &'s don't force the real ones into memory. */
2007 YYSTYPE *yyvs1 = yyvs;
2008 short *yyss1 = yyss;
2010 YYLTYPE *yyls1 = yyls;
2013 /* Get the current used size of the three stacks, in elements. */
2014 int size = yyssp - yyss + 1;
2017 /* Each stack pointer address is followed by the size of
2018 the data in use in that stack, in bytes. */
2020 /* This used to be a conditional around just the two extra args,
2021 but that might be undefined if yyoverflow is a macro. */
2022 yyoverflow("parser stack overflow",
2023 &yyss1, size * sizeof (*yyssp),
2024 &yyvs1, size * sizeof (*yyvsp),
2025 &yyls1, size * sizeof (*yylsp),
2028 yyoverflow("parser stack overflow",
2029 &yyss1, size * sizeof (*yyssp),
2030 &yyvs1, size * sizeof (*yyvsp),
2034 yyss = yyss1; yyvs = yyvs1;
2038 #else /* no yyoverflow */
2039 /* Extend the stack our own way. */
2040 if (yystacksize >= YYMAXDEPTH)
2042 yyerror("parser stack overflow");
2054 if (yystacksize > YYMAXDEPTH)
2055 yystacksize = YYMAXDEPTH;
2056 #ifndef YYSTACK_USE_ALLOCA
2059 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2060 __yy_memcpy ((char *)yyss, (char *)yyss1,
2061 size * (unsigned int) sizeof (*yyssp));
2062 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2063 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2064 size * (unsigned int) sizeof (*yyvsp));
2066 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2067 __yy_memcpy ((char *)yyls, (char *)yyls1,
2068 size * (unsigned int) sizeof (*yylsp));
2070 #endif /* no yyoverflow */
2072 yyssp = yyss + size - 1;
2073 yyvsp = yyvs + size - 1;
2075 yylsp = yyls + size - 1;
2080 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2083 if (yyssp >= yyss + yystacksize - 1)
2089 fprintf(stderr, "Entering state %d\n", yystate);
2095 /* Do appropriate processing given the current state. */
2096 /* Read a lookahead token if we need one and don't already have one. */
2099 /* First try to decide what to do without reference to lookahead token. */
2101 yyn = yypact[yystate];
2105 /* Not known => get a lookahead token if don't already have one. */
2107 /* yychar is either YYEMPTY or YYEOF
2108 or a valid token in external form. */
2110 if (yychar == YYEMPTY)
2114 fprintf(stderr, "Reading a token: ");
2119 /* Convert token to internal form (in yychar1) for indexing tables with */
2121 if (yychar <= 0) /* This means end of input. */
2124 yychar = YYEOF; /* Don't call YYLEX any more */
2128 fprintf(stderr, "Now at end of input.\n");
2133 yychar1 = YYTRANSLATE(yychar);
2138 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2139 /* Give the individual parser a way to print the precise meaning
2140 of a token, for further debugging info. */
2142 YYPRINT (stderr, yychar, yylval);
2144 fprintf (stderr, ")\n");
2150 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2155 /* yyn is what to do for this token type in this state.
2156 Negative => reduce, -yyn is rule number.
2157 Positive => shift, yyn is new state.
2158 New state is final state => don't bother to shift,
2159 just return success.
2160 0, or most negative number => error. */
2175 /* Shift the lookahead token. */
2179 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2182 /* Discard the token being shifted unless it is eof. */
2183 if (yychar != YYEOF)
2191 /* count tokens shifted since error; after three, turn off error status. */
2192 if (yyerrstatus) yyerrstatus--;
2197 /* Do the default action for the current state. */
2200 yyn = yydefact[yystate];
2204 /* Do a reduction. yyn is the number of a rule to reduce with. */
2208 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2215 fprintf (stderr, "Reducing via rule %d (line %d), ",
2218 /* Print the symbols being reduced, and their result. */
2219 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2220 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2221 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2229 #line 1011 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2231 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2232 ThrowException("Value too large for type!");
2233 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2237 #line 1019 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2239 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2240 ThrowException("Value too large for type!");
2241 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2245 #line 1042 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2247 yyval.StrVal = yyvsp[-1].StrVal;
2251 #line 1045 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2257 #line 1049 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2258 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2261 #line 1050 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2262 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2265 #line 1051 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2266 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2269 #line 1052 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2270 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2273 #line 1053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2274 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2277 #line 1055 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2278 { yyval.UIntVal = CallingConv::C; ;
2281 #line 1056 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2282 { yyval.UIntVal = CallingConv::C; ;
2285 #line 1057 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2286 { yyval.UIntVal = CallingConv::Fast; ;
2289 #line 1058 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2290 { yyval.UIntVal = CallingConv::Cold; ;
2293 #line 1059 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2295 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2296 ThrowException("Calling conv too large!");
2297 yyval.UIntVal = yyvsp[0].UInt64Val;
2301 #line 1067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2302 { yyval.UIntVal = 0; ;
2305 #line 1068 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2307 yyval.UIntVal = yyvsp[0].UInt64Val;
2308 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2309 ThrowException("Alignment must be a power of two!");
2313 #line 1073 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2314 { yyval.UIntVal = 0; ;
2317 #line 1074 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2319 yyval.UIntVal = yyvsp[0].UInt64Val;
2320 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2321 ThrowException("Alignment must be a power of two!");
2325 #line 1081 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2327 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2328 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2329 ThrowException("Invalid character in section name!");
2330 yyval.StrVal = yyvsp[0].StrVal;
2334 #line 1088 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2335 { yyval.StrVal = 0; ;
2338 #line 1089 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2339 { yyval.StrVal = yyvsp[0].StrVal; ;
2342 #line 1094 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2346 #line 1095 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2350 #line 1096 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2352 CurGV->setSection(yyvsp[0].StrVal);
2353 free(yyvsp[0].StrVal);
2357 #line 1100 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2359 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2360 ThrowException("Alignment must be a power of two!");
2361 CurGV->setAlignment(yyvsp[0].UInt64Val);
2365 #line 1113 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2366 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2369 #line 1114 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2370 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2373 #line 1116 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2375 if (!UpRefs.empty())
2376 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2377 yyval.TypeVal = yyvsp[0].TypeVal;
2381 #line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2383 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2387 #line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2389 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2393 #line 1133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2394 { // Named types are also simple types...
2395 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2399 #line 1139 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2400 { // Type UpReference
2401 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2402 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2403 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2404 yyval.TypeVal = new PATypeHolder(OT);
2405 UR_OUT("New Upreference!\n");
2409 #line 1146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2410 { // Function derived type?
2411 std::vector<const Type*> Params;
2412 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2413 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2414 Params.push_back(*I);
2415 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2416 if (isVarArg) Params.pop_back();
2418 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2419 delete yyvsp[-1].TypeList; // Delete the argument list
2420 delete yyvsp[-3].TypeVal; // Delete the return type handle
2424 #line 1158 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2425 { // Sized array type?
2426 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2427 delete yyvsp[-1].TypeVal;
2431 #line 1162 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2432 { // Packed array type?
2433 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2434 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2435 ThrowException("Unsigned result not equal to signed result");
2436 if (!ElemTy->isPrimitiveType())
2437 ThrowException("Elemental type of a PackedType must be primitive");
2438 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2439 ThrowException("Vector length should be a power of 2!");
2440 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2441 delete yyvsp[-1].TypeVal;
2445 #line 1173 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2446 { // Structure type?
2447 std::vector<const Type*> Elements;
2448 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2449 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2450 Elements.push_back(*I);
2452 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2453 delete yyvsp[-1].TypeList;
2457 #line 1182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2458 { // Empty structure type?
2459 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2463 #line 1185 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2465 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2466 delete yyvsp[-1].TypeVal;
2470 #line 1193 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2472 yyval.TypeList = new std::list<PATypeHolder>();
2473 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2477 #line 1197 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2479 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2483 #line 1203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2485 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2489 #line 1206 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2491 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2495 #line 1209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2497 yyval.TypeList = new std::list<PATypeHolder>();
2501 #line 1219 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2502 { // Nonempty unsized arr
2503 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2505 ThrowException("Cannot make array constant with type: '" +
2506 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2507 const Type *ETy = ATy->getElementType();
2508 int NumElements = ATy->getNumElements();
2510 // Verify that we have the correct size...
2511 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2512 ThrowException("Type mismatch: constant sized array initialized with " +
2513 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2514 itostr(NumElements) + "!");
2516 // Verify all elements are correct type!
2517 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2518 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2519 ThrowException("Element #" + utostr(i) + " is not of type '" +
2520 ETy->getDescription() +"' as required!\nIt is of type '"+
2521 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2524 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2525 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2529 #line 1244 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2531 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2533 ThrowException("Cannot make array constant with type: '" +
2534 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2536 int NumElements = ATy->getNumElements();
2537 if (NumElements != -1 && NumElements != 0)
2538 ThrowException("Type mismatch: constant sized array initialized with 0"
2539 " arguments, but has size of " + itostr(NumElements) +"!");
2540 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2541 delete yyvsp[-2].TypeVal;
2545 #line 1257 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2547 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2549 ThrowException("Cannot make array constant with type: '" +
2550 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2552 int NumElements = ATy->getNumElements();
2553 const Type *ETy = ATy->getElementType();
2554 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2555 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2556 ThrowException("Can't build string constant of size " +
2557 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2558 " when array has size " + itostr(NumElements) + "!");
2559 std::vector<Constant*> Vals;
2560 if (ETy == Type::SByteTy) {
2561 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
2562 Vals.push_back(ConstantSInt::get(ETy, *C));
2563 } else if (ETy == Type::UByteTy) {
2564 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2565 C != (unsigned char*)EndStr; ++C)
2566 Vals.push_back(ConstantUInt::get(ETy, *C));
2568 free(yyvsp[0].StrVal);
2569 ThrowException("Cannot build string arrays of non byte sized elements!");
2571 free(yyvsp[0].StrVal);
2572 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2573 delete yyvsp[-2].TypeVal;
2577 #line 1286 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2578 { // Nonempty unsized arr
2579 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2581 ThrowException("Cannot make packed constant with type: '" +
2582 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2583 const Type *ETy = PTy->getElementType();
2584 int NumElements = PTy->getNumElements();
2586 // Verify that we have the correct size...
2587 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2588 ThrowException("Type mismatch: constant sized packed initialized with " +
2589 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2590 itostr(NumElements) + "!");
2592 // Verify all elements are correct type!
2593 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2594 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2595 ThrowException("Element #" + utostr(i) + " is not of type '" +
2596 ETy->getDescription() +"' as required!\nIt is of type '"+
2597 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2600 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2601 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2605 #line 1311 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2607 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2609 ThrowException("Cannot make struct constant with type: '" +
2610 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2612 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2613 ThrowException("Illegal number of initializers for structure type!");
2615 // Check to ensure that constants are compatible with the type initializer!
2616 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2617 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2618 ThrowException("Expected type '" +
2619 STy->getElementType(i)->getDescription() +
2620 "' for element #" + utostr(i) +
2621 " of structure initializer!");
2623 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2624 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2628 #line 1331 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2630 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2632 ThrowException("Cannot make struct constant with type: '" +
2633 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2635 if (STy->getNumContainedTypes() != 0)
2636 ThrowException("Illegal number of initializers for structure type!");
2638 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2639 delete yyvsp[-2].TypeVal;
2643 #line 1343 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2645 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2647 ThrowException("Cannot make null pointer constant with type: '" +
2648 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2650 yyval.ConstVal = ConstantPointerNull::get(PTy);
2651 delete yyvsp[-1].TypeVal;
2655 #line 1352 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2657 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2658 delete yyvsp[-1].TypeVal;
2662 #line 1356 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2664 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2666 ThrowException("Global const reference must be a pointer type!");
2668 // ConstExprs can exist in the body of a function, thus creating
2669 // GlobalValues whenever they refer to a variable. Because we are in
2670 // the context of a function, getValNonImprovising will search the functions
2671 // symbol table instead of the module symbol table for the global symbol,
2672 // which throws things all off. To get around this, we just tell
2673 // getValNonImprovising that we are at global scope here.
2675 Function *SavedCurFn = CurFun.CurrentFunction;
2676 CurFun.CurrentFunction = 0;
2678 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2680 CurFun.CurrentFunction = SavedCurFn;
2682 // If this is an initializer for a constant pointer, which is referencing a
2683 // (currently) undefined variable, create a stub now that shall be replaced
2684 // in the future with the right type of variable.
2687 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2688 const PointerType *PT = cast<PointerType>(Ty);
2690 // First check to see if the forward references value is already created!
2691 PerModuleInfo::GlobalRefsType::iterator I =
2692 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2694 if (I != CurModule.GlobalRefs.end()) {
2695 V = I->second; // Placeholder already exists, use it...
2696 yyvsp[0].ValIDVal.destroy();
2699 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2701 // Create the forward referenced global.
2703 if (const FunctionType *FTy =
2704 dyn_cast<FunctionType>(PT->getElementType())) {
2705 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2706 CurModule.CurrentModule);
2708 GV = new GlobalVariable(PT->getElementType(), false,
2709 GlobalValue::ExternalLinkage, 0,
2710 Name, CurModule.CurrentModule);
2713 // Keep track of the fact that we have a forward ref to recycle it
2714 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2719 yyval.ConstVal = cast<GlobalValue>(V);
2720 delete yyvsp[-1].TypeVal; // Free the type handle
2724 #line 1415 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2726 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2727 ThrowException("Mismatched types for constant expression!");
2728 yyval.ConstVal = yyvsp[0].ConstVal;
2729 delete yyvsp[-1].TypeVal;
2733 #line 1421 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2735 const Type *Ty = yyvsp[-1].TypeVal->get();
2736 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2737 ThrowException("Cannot create a null initialized value of this type!");
2738 yyval.ConstVal = Constant::getNullValue(Ty);
2739 delete yyvsp[-1].TypeVal;
2743 #line 1429 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2744 { // integral constants
2745 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2746 ThrowException("Constant value doesn't fit in type!");
2747 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
2751 #line 1434 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2752 { // integral constants
2753 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2754 ThrowException("Constant value doesn't fit in type!");
2755 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
2759 #line 1439 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2760 { // Boolean constants
2761 yyval.ConstVal = ConstantBool::True;
2765 #line 1442 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2766 { // Boolean constants
2767 yyval.ConstVal = ConstantBool::False;
2771 #line 1445 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2772 { // Float & Double constants
2773 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2774 ThrowException("Floating point constant invalid for type!!");
2775 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
2779 #line 1452 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2781 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2782 ThrowException("cast constant expression from a non-primitive type: '" +
2783 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2784 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2785 ThrowException("cast constant expression to a non-primitive type: '" +
2786 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2787 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2788 delete yyvsp[-1].TypeVal;
2792 #line 1462 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2794 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2795 ThrowException("GetElementPtr requires a pointer operand!");
2797 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2798 // indices to uint struct indices for compatibility.
2799 generic_gep_type_iterator<std::vector<Value*>::iterator>
2800 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2801 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2802 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2803 if (isa<StructType>(*GTI)) // Only change struct indices
2804 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2805 if (CUI->getType() == Type::UByteTy)
2806 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2809 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2811 ThrowException("Index list invalid for constant getelementptr!");
2813 std::vector<Constant*> IdxVec;
2814 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2815 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2816 IdxVec.push_back(C);
2818 ThrowException("Indices to constant getelementptr must be constants!");
2820 delete yyvsp[-1].ValueList;
2822 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
2826 #line 1493 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2828 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2829 ThrowException("Select condition must be of boolean type!");
2830 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2831 ThrowException("Select operand types must match!");
2832 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2836 #line 1500 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2838 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2839 ThrowException("Binary operator types must match!");
2840 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2841 // To retain backward compatibility with these early compilers, we emit a
2842 // cast to the appropriate integer type automatically if we are in the
2843 // broken case. See PR424 for more information.
2844 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2845 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2847 const Type *IntPtrTy = 0;
2848 switch (CurModule.CurrentModule->getPointerSize()) {
2849 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2850 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2851 default: ThrowException("invalid pointer binary constant expr!");
2853 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2854 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2855 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2860 #line 1521 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2862 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2863 ThrowException("Logical operator types must match!");
2864 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2865 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2866 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2867 ThrowException("Logical operator requires integral operands!");
2869 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2873 #line 1531 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2875 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2876 ThrowException("setcc operand types must match!");
2877 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2881 #line 1536 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2883 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2884 ThrowException("Shift count for shift constant must be unsigned byte!");
2885 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2886 ThrowException("Shift constant expression requires integer operand!");
2887 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2891 #line 1543 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2893 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()))
2894 ThrowException("First operand of extractelement must be "
2896 if (yyvsp[-1].ConstVal->getType() != Type::UIntTy)
2897 ThrowException("Second operand of extractelement must be uint!");
2898 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2902 #line 1553 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2904 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
2908 #line 1556 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2910 yyval.ConstVector = new std::vector<Constant*>();
2911 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
2915 #line 1563 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2916 { yyval.BoolVal = false; ;
2919 #line 1563 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2920 { yyval.BoolVal = true; ;
2923 #line 1573 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2925 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2926 CurModule.ModuleDone();
2930 #line 1580 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2932 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2933 CurFun.FunctionDone();
2937 #line 1584 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2939 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2943 #line 1587 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2945 yyval.ModuleVal = yyvsp[-3].ModuleVal;
2949 #line 1590 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2951 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2955 #line 1593 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2957 yyval.ModuleVal = CurModule.CurrentModule;
2958 // Emit an error if there are any unresolved types left.
2959 if (!CurModule.LateResolveTypes.empty()) {
2960 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2961 if (DID.Type == ValID::NameVal)
2962 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2964 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2969 #line 1606 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2971 // Eagerly resolve types. This is not an optimization, this is a
2972 // requirement that is due to the fact that we could have this:
2974 // %list = type { %list * }
2975 // %list = type { %list * } ; repeated type decl
2977 // If types are not resolved eagerly, then the two types will not be
2978 // determined to be the same type!
2980 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2982 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2983 // If this is a named type that is not a redefinition, add it to the slot
2985 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2988 delete yyvsp[0].TypeVal;
2992 #line 1626 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2993 { // Function prototypes can be in const pool
2997 #line 1628 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2998 { // Asm blocks can be in the const pool
3002 #line 1630 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3004 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3005 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3009 #line 1633 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3015 #line 1636 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3017 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3018 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3019 delete yyvsp[0].TypeVal;
3023 #line 1640 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3029 #line 1643 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3034 #line 1645 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3039 #line 1647 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3044 #line 1651 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3046 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3047 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3048 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3049 free(yyvsp[0].StrVal);
3051 if (AsmSoFar.empty())
3052 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3054 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
3058 #line 1663 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3059 { yyval.Endianness = Module::BigEndian; ;
3062 #line 1664 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3063 { yyval.Endianness = Module::LittleEndian; ;
3066 #line 1666 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3068 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3072 #line 1669 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3074 if (yyvsp[0].UInt64Val == 32)
3075 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3076 else if (yyvsp[0].UInt64Val == 64)
3077 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3079 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3083 #line 1677 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3085 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3086 free(yyvsp[0].StrVal);
3090 #line 1684 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3092 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3093 free(yyvsp[0].StrVal);
3097 #line 1688 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3099 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3100 free(yyvsp[0].StrVal);
3104 #line 1692 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3109 #line 1701 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3110 { yyval.StrVal = 0; ;
3113 #line 1703 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3115 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3116 ThrowException("void typed arguments are invalid!");
3117 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3121 #line 1709 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3123 yyval.ArgList = yyvsp[-2].ArgList;
3124 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3125 delete yyvsp[0].ArgVal;
3129 #line 1714 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3131 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3132 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3133 delete yyvsp[0].ArgVal;
3137 #line 1720 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3139 yyval.ArgList = yyvsp[0].ArgList;
3143 #line 1723 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3145 yyval.ArgList = yyvsp[-2].ArgList;
3146 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3147 char*>(new PATypeHolder(Type::VoidTy), 0));
3151 #line 1728 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3153 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3154 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3158 #line 1732 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3164 #line 1737 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3166 UnEscapeLexed(yyvsp[-5].StrVal);
3167 std::string FunctionName(yyvsp[-5].StrVal);
3168 free(yyvsp[-5].StrVal); // Free strdup'd memory!
3170 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
3171 ThrowException("LLVM functions cannot return aggregate types!");
3173 std::vector<const Type*> ParamTypeList;
3174 if (yyvsp[-3].ArgList) { // If there are arguments...
3175 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3176 I != yyvsp[-3].ArgList->end(); ++I)
3177 ParamTypeList.push_back(I->first->get());
3180 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3181 if (isVarArg) ParamTypeList.pop_back();
3183 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
3184 const PointerType *PFT = PointerType::get(FT);
3185 delete yyvsp[-6].TypeVal;
3188 if (!FunctionName.empty()) {
3189 ID = ValID::create((char*)FunctionName.c_str());
3191 ID = ValID::create((int)CurModule.Values[PFT].size());
3195 // See if this function was forward referenced. If so, recycle the object.
3196 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3197 // Move the function to the end of the list, from whereever it was
3198 // previously inserted.
3199 Fn = cast<Function>(FWRef);
3200 CurModule.CurrentModule->getFunctionList().remove(Fn);
3201 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3202 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3203 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3204 // If this is the case, either we need to be a forward decl, or it needs
3206 if (!CurFun.isDeclare && !Fn->isExternal())
3207 ThrowException("Redefinition of function '" + FunctionName + "'!");
3209 // Make sure to strip off any argument names so we can't get conflicts.
3210 if (Fn->isExternal())
3211 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3215 } else { // Not already defined?
3216 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3217 CurModule.CurrentModule);
3218 InsertValue(Fn, CurModule.Values);
3221 CurFun.FunctionStart(Fn);
3222 Fn->setCallingConv(yyvsp[-7].UIntVal);
3223 Fn->setAlignment(yyvsp[0].UIntVal);
3224 if (yyvsp[-1].StrVal) {
3225 Fn->setSection(yyvsp[-1].StrVal);
3226 free(yyvsp[-1].StrVal);
3229 // Add all of the arguments we parsed to the function...
3230 if (yyvsp[-3].ArgList) { // Is null if empty...
3231 if (isVarArg) { // Nuke the last entry
3232 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
3233 "Not a varargs marker!");
3234 delete yyvsp[-3].ArgList->back().first;
3235 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
3237 Function::arg_iterator ArgIt = Fn->arg_begin();
3238 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3239 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
3240 delete I->first; // Delete the typeholder...
3242 setValueName(ArgIt, I->second); // Insert arg into symtab...
3246 delete yyvsp[-3].ArgList; // We're now done with the argument list
3251 #line 1824 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3253 yyval.FunctionVal = CurFun.CurrentFunction;
3255 // Make sure that we keep track of the linkage type even if there was a
3256 // previous "declare".
3257 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3261 #line 1834 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3263 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3267 #line 1838 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3268 { CurFun.isDeclare = true; ;
3271 #line 1838 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3273 yyval.FunctionVal = CurFun.CurrentFunction;
3274 CurFun.FunctionDone();
3278 #line 1847 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3280 yyval.BoolVal = false;
3284 #line 1850 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3286 yyval.BoolVal = true;
3290 #line 1854 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3291 { // A reference to a direct constant
3292 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3296 #line 1857 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3298 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3302 #line 1860 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3303 { // Perhaps it's an FP constant?
3304 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3308 #line 1863 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3310 yyval.ValIDVal = ValID::create(ConstantBool::True);
3314 #line 1866 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3316 yyval.ValIDVal = ValID::create(ConstantBool::False);
3320 #line 1869 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3322 yyval.ValIDVal = ValID::createNull();
3326 #line 1872 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3328 yyval.ValIDVal = ValID::createUndef();
3332 #line 1875 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3333 { // A vector zero constant.
3334 yyval.ValIDVal = ValID::createZeroInit();
3338 #line 1878 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3339 { // Nonempty unsized packed vector
3340 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3341 int NumElements = yyvsp[-1].ConstVector->size();
3343 PackedType* pt = PackedType::get(ETy, NumElements);
3344 PATypeHolder* PTy = new PATypeHolder(
3352 // Verify all elements are correct type!
3353 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3354 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3355 ThrowException("Element #" + utostr(i) + " is not of type '" +
3356 ETy->getDescription() +"' as required!\nIt is of type '" +
3357 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3360 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3361 delete PTy; delete yyvsp[-1].ConstVector;
3365 #line 1902 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3367 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3371 #line 1905 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3373 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3374 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3375 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3376 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3377 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3378 free(yyvsp[-2].StrVal);
3379 free(yyvsp[0].StrVal);
3383 #line 1918 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3384 { // Is it an integer reference...?
3385 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3389 #line 1921 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3390 { // Is it a named reference...?
3391 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3395 #line 1932 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3397 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3401 #line 1936 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3403 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3407 #line 1939 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3408 { // Do not allow functions with 0 basic blocks
3409 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3413 #line 1947 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3415 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3416 InsertValue(yyvsp[0].TermInstVal);
3418 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3419 InsertValue(yyvsp[-2].BasicBlockVal);
3420 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3424 #line 1956 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3426 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3427 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3431 #line 1960 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3433 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3435 // Make sure to move the basic block to the correct location in the
3436 // function, instead of leaving it inserted wherever it was first
3438 Function::BasicBlockListType &BBL =
3439 CurFun.CurrentFunction->getBasicBlockList();
3440 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3444 #line 1970 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3446 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3448 // Make sure to move the basic block to the correct location in the
3449 // function, instead of leaving it inserted wherever it was first
3451 Function::BasicBlockListType &BBL =
3452 CurFun.CurrentFunction->getBasicBlockList();
3453 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3457 #line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3458 { // Return with a result...
3459 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3463 #line 1984 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3464 { // Return with no result...
3465 yyval.TermInstVal = new ReturnInst();
3469 #line 1987 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3470 { // Unconditional Branch...
3471 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3475 #line 1990 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3477 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3481 #line 1993 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3483 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3484 yyval.TermInstVal = S;
3486 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3487 E = yyvsp[-1].JumpTable->end();
3488 for (; I != E; ++I) {
3489 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3490 S->addCase(CI, I->second);
3492 ThrowException("Switch case is constant, but not a simple integer!");
3494 delete yyvsp[-1].JumpTable;
3498 #line 2007 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3500 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3501 yyval.TermInstVal = S;
3505 #line 2012 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3507 const PointerType *PFTy;
3508 const FunctionType *Ty;
3510 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3511 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3512 // Pull out the types of all of the arguments...
3513 std::vector<const Type*> ParamTypes;
3514 if (yyvsp[-7].ValueList) {
3515 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3517 ParamTypes.push_back((*I)->getType());
3520 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3521 if (isVarArg) ParamTypes.pop_back();
3523 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3524 PFTy = PointerType::get(Ty);
3527 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3529 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3530 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3532 // Create the call node...
3533 if (!yyvsp[-7].ValueList) { // Has no arguments?
3534 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3535 } else { // Has arguments?
3536 // Loop through FunctionType's arguments and ensure they are specified
3539 FunctionType::param_iterator I = Ty->param_begin();
3540 FunctionType::param_iterator E = Ty->param_end();
3541 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3543 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3544 if ((*ArgI)->getType() != *I)
3545 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3546 (*I)->getDescription() + "'!");
3548 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3549 ThrowException("Invalid number of parameters detected!");
3551 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3553 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3555 delete yyvsp[-10].TypeVal;
3556 delete yyvsp[-7].ValueList;
3560 #line 2064 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3562 yyval.TermInstVal = new UnwindInst();
3566 #line 2067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3568 yyval.TermInstVal = new UnreachableInst();
3572 #line 2073 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3574 yyval.JumpTable = yyvsp[-5].JumpTable;
3575 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3577 ThrowException("May only switch on a constant pool value!");
3579 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3583 #line 2081 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3585 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3586 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3589 ThrowException("May only switch on a constant pool value!");
3591 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3595 #line 2091 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3597 // Is this definition named?? if so, assign the name...
3598 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3599 InsertValue(yyvsp[0].InstVal);
3600 yyval.InstVal = yyvsp[0].InstVal;
3604 #line 2098 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3605 { // Used for PHI nodes
3606 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3607 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3608 delete yyvsp[-5].TypeVal;
3612 #line 2103 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3614 yyval.PHIList = yyvsp[-6].PHIList;
3615 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3616 getBBVal(yyvsp[-1].ValIDVal)));
3620 #line 2110 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3621 { // Used for call statements, and memory insts...
3622 yyval.ValueList = new std::vector<Value*>();
3623 yyval.ValueList->push_back(yyvsp[0].ValueVal);
3627 #line 2114 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3629 yyval.ValueList = yyvsp[-2].ValueList;
3630 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
3634 #line 2120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3635 { yyval.ValueList = 0; ;
3638 #line 2122 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3640 yyval.BoolVal = true;
3644 #line 2125 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3646 yyval.BoolVal = false;
3650 #line 2131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3652 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3653 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3655 "Arithmetic operator requires integer, FP, or packed operands!");
3656 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3657 ThrowException("Rem not supported on packed types!");
3658 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3659 if (yyval.InstVal == 0)
3660 ThrowException("binary operator returned null!");
3661 delete yyvsp[-3].TypeVal;
3665 #line 2143 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3667 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3668 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3669 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3670 ThrowException("Logical operator requires integral operands!");
3672 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3673 if (yyval.InstVal == 0)
3674 ThrowException("binary operator returned null!");
3675 delete yyvsp[-3].TypeVal;
3679 #line 2154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3681 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3683 "PackedTypes currently not supported in setcc instructions!");
3685 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3686 if (yyval.InstVal == 0)
3687 ThrowException("binary operator returned null!");
3688 delete yyvsp[-3].TypeVal;
3692 #line 2164 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3694 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3695 << " Replacing with 'xor'.\n";
3697 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3699 ThrowException("Expected integral type for not instruction!");
3701 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3702 if (yyval.InstVal == 0)
3703 ThrowException("Could not create a xor instruction!");
3707 #line 2176 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3709 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3710 ThrowException("Shift amount must be ubyte!");
3711 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3712 ThrowException("Shift constant expression requires integer operand!");
3713 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3717 #line 2183 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3719 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3720 ThrowException("cast instruction to a non-primitive type: '" +
3721 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3722 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3723 delete yyvsp[0].TypeVal;
3727 #line 2190 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3729 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3730 ThrowException("select condition must be boolean!");
3731 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3732 ThrowException("select value types should match!");
3733 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3737 #line 2197 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3740 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3741 delete yyvsp[0].TypeVal;
3745 #line 2202 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3747 ObsoleteVarArgs = true;
3748 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3749 Function* NF = CurModule.CurrentModule->
3750 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3753 //foo = alloca 1 of t
3757 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3758 CurBB->getInstList().push_back(foo);
3759 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3760 CurBB->getInstList().push_back(bar);
3761 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3762 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3763 delete yyvsp[0].TypeVal;
3767 #line 2221 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3769 ObsoleteVarArgs = true;
3770 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3771 Function* NF = CurModule.CurrentModule->
3772 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3774 //b = vanext a, t ->
3775 //foo = alloca 1 of t
3778 //tmp = vaarg foo, t
3780 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3781 CurBB->getInstList().push_back(foo);
3782 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3783 CurBB->getInstList().push_back(bar);
3784 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3785 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3786 CurBB->getInstList().push_back(tmp);
3787 yyval.InstVal = new LoadInst(foo);
3788 delete yyvsp[0].TypeVal;
3792 #line 2243 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3794 if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
3795 ThrowException("First operand of extractelement must be "
3797 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3798 ThrowException("Second operand of extractelement must be uint!");
3799 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3803 #line 2251 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3805 if (!isa<PackedType>(yyvsp[-4].ValueVal->getType()))
3806 ThrowException("First operand of insertelement must be "
3808 if (yyvsp[-2].ValueVal->getType() !=
3809 cast<PackedType>(yyvsp[-4].ValueVal->getType())->getElementType())
3810 ThrowException("Second operand of insertelement must be "
3811 "packed element type!");
3812 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3813 ThrowException("Third operand of insertelement must be uint!");
3814 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3818 #line 2263 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3820 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3821 if (!Ty->isFirstClassType())
3822 ThrowException("PHI node operands must be of first class type!");
3823 yyval.InstVal = new PHINode(Ty);
3824 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3825 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3826 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3827 ThrowException("All elements of a PHI node must be of the same type!");
3828 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3829 yyvsp[0].PHIList->pop_front();
3831 delete yyvsp[0].PHIList; // Free the list...
3835 #line 2277 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3837 const PointerType *PFTy;
3838 const FunctionType *Ty;
3840 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3841 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3842 // Pull out the types of all of the arguments...
3843 std::vector<const Type*> ParamTypes;
3844 if (yyvsp[-1].ValueList) {
3845 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3847 ParamTypes.push_back((*I)->getType());
3850 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3851 if (isVarArg) ParamTypes.pop_back();
3853 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3854 ThrowException("LLVM functions cannot return aggregate types!");
3856 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3857 PFTy = PointerType::get(Ty);
3860 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3862 // Create the call node...
3863 if (!yyvsp[-1].ValueList) { // Has no arguments?
3864 // Make sure no arguments is a good thing!
3865 if (Ty->getNumParams() != 0)
3866 ThrowException("No arguments passed to a function that "
3867 "expects arguments!");
3869 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3870 } else { // Has arguments?
3871 // Loop through FunctionType's arguments and ensure they are specified
3874 FunctionType::param_iterator I = Ty->param_begin();
3875 FunctionType::param_iterator E = Ty->param_end();
3876 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3878 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3879 if ((*ArgI)->getType() != *I)
3880 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3881 (*I)->getDescription() + "'!");
3883 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3884 ThrowException("Invalid number of parameters detected!");
3886 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3888 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3889 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3890 delete yyvsp[-4].TypeVal;
3891 delete yyvsp[-1].ValueList;
3895 #line 2334 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3897 yyval.InstVal = yyvsp[0].InstVal;
3901 #line 2340 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3903 yyval.ValueList = yyvsp[0].ValueList;
3907 #line 2342 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3909 yyval.ValueList = new std::vector<Value*>();
3913 #line 2346 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3915 yyval.BoolVal = true;
3919 #line 2349 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3921 yyval.BoolVal = false;
3925 #line 2355 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3927 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3928 delete yyvsp[-1].TypeVal;
3932 #line 2359 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3934 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3935 delete yyvsp[-4].TypeVal;
3939 #line 2363 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3941 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3942 delete yyvsp[-1].TypeVal;
3946 #line 2367 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3948 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3949 delete yyvsp[-4].TypeVal;
3953 #line 2371 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3955 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3956 ThrowException("Trying to free nonpointer type " +
3957 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3958 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
3962 #line 2378 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3964 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3965 ThrowException("Can't load from nonpointer type: " +
3966 (*yyvsp[-1].TypeVal)->getDescription());
3967 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3968 ThrowException("Can't load from pointer of non-first-class type: " +
3969 (*yyvsp[-1].TypeVal)->getDescription());
3970 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3971 delete yyvsp[-1].TypeVal;
3975 #line 2388 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3977 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3979 ThrowException("Can't store to a nonpointer type: " +
3980 (*yyvsp[-1].TypeVal)->getDescription());
3981 const Type *ElTy = PT->getElementType();
3982 if (ElTy != yyvsp[-3].ValueVal->getType())
3983 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3984 "' into space of type '" + ElTy->getDescription() + "'!");
3986 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3987 delete yyvsp[-1].TypeVal;
3991 #line 2401 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3993 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3994 ThrowException("getelementptr insn requires pointer operand!");
3996 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3997 // indices to uint struct indices for compatibility.
3998 generic_gep_type_iterator<std::vector<Value*>::iterator>
3999 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4000 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4001 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4002 if (isa<StructType>(*GTI)) // Only change struct indices
4003 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4004 if (CUI->getType() == Type::UByteTy)
4005 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4007 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4008 ThrowException("Invalid getelementptr indices for type '" +
4009 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4010 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4011 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
4015 /* the action file gets copied in in place of this dollarsign */
4016 #line 543 "/usr/share/bison.simple"
4027 short *ssp1 = yyss - 1;
4028 fprintf (stderr, "state stack now");
4029 while (ssp1 != yyssp)
4030 fprintf (stderr, " %d", *++ssp1);
4031 fprintf (stderr, "\n");
4041 yylsp->first_line = yylloc.first_line;
4042 yylsp->first_column = yylloc.first_column;
4043 yylsp->last_line = (yylsp-1)->last_line;
4044 yylsp->last_column = (yylsp-1)->last_column;
4049 yylsp->last_line = (yylsp+yylen-1)->last_line;
4050 yylsp->last_column = (yylsp+yylen-1)->last_column;
4054 /* Now "shift" the result of the reduction.
4055 Determine what state that goes to,
4056 based on the state we popped back to
4057 and the rule number reduced by. */
4061 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4062 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4063 yystate = yytable[yystate];
4065 yystate = yydefgoto[yyn - YYNTBASE];
4069 yyerrlab: /* here on detecting error */
4072 /* If not already recovering from an error, report this error. */
4076 #ifdef YYERROR_VERBOSE
4077 yyn = yypact[yystate];
4079 if (yyn > YYFLAG && yyn < YYLAST)
4086 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4087 for (x = (yyn < 0 ? -yyn : 0);
4088 x < (sizeof(yytname) / sizeof(char *)); x++)
4089 if (yycheck[x + yyn] == x)
4090 size += strlen(yytname[x]) + 15, count++;
4091 msg = (char *) malloc(size + 15);
4094 strcpy(msg, "parse error");
4099 for (x = (yyn < 0 ? -yyn : 0);
4100 x < (sizeof(yytname) / sizeof(char *)); x++)
4101 if (yycheck[x + yyn] == x)
4103 strcat(msg, count == 0 ? ", expecting `" : " or `");
4104 strcat(msg, yytname[x]);
4113 yyerror ("parse error; also virtual memory exceeded");
4116 #endif /* YYERROR_VERBOSE */
4117 yyerror("parse error");
4121 yyerrlab1: /* here on error raised explicitly by an action */
4123 if (yyerrstatus == 3)
4125 /* if just tried and failed to reuse lookahead token after an error, discard it. */
4127 /* return failure if at end of input */
4128 if (yychar == YYEOF)
4133 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4139 /* Else will try to reuse lookahead token
4140 after shifting the error token. */
4142 yyerrstatus = 3; /* Each real token shifted decrements this */
4146 yyerrdefault: /* current state does not do anything special for the error token. */
4149 /* This is wrong; only states that explicitly want error tokens
4150 should shift them. */
4151 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4152 if (yyn) goto yydefault;
4155 yyerrpop: /* pop the current state because it cannot handle the error token */
4157 if (yyssp == yyss) YYABORT;
4167 short *ssp1 = yyss - 1;
4168 fprintf (stderr, "Error: state stack now");
4169 while (ssp1 != yyssp)
4170 fprintf (stderr, " %d", *++ssp1);
4171 fprintf (stderr, "\n");
4177 yyn = yypact[yystate];
4182 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4201 fprintf(stderr, "Shifting error token, ");
4213 /* YYACCEPT comes here. */
4225 /* YYABORT comes here. */
4236 #line 2424 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4238 int yyerror(const char *ErrorMsg) {
4240 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4241 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4242 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4243 if (yychar == YYEMPTY || yychar == 0)
4244 errMsg += "end-of-file.";
4246 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4247 ThrowException(errMsg);