2 /* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL 257
15 #define EUINT64VAL 258
35 #define STRINGCONSTANT 278
36 #define IMPLEMENTATION 279
37 #define ZEROINITIALIZER 280
62 #define POINTERSIZE 305
71 #define SIDEEFFECT 314
74 #define CSRETCC_TOK 317
75 #define FASTCC_TOK 318
76 #define COLDCC_TOK 319
82 #define UNREACHABLE 325
102 #define GETELEMENTPTR 345
109 #define EXTRACTELEMENT 352
110 #define INSERTELEMENT 353
111 #define SHUFFLEVECTOR 354
112 #define VAARG_old 355
113 #define VANEXT_old 356
115 #line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
117 #include "ParserInternals.h"
118 #include "llvm/CallingConv.h"
119 #include "llvm/InlineAsm.h"
120 #include "llvm/Instructions.h"
121 #include "llvm/Module.h"
122 #include "llvm/SymbolTable.h"
123 #include "llvm/Assembly/AutoUpgrade.h"
124 #include "llvm/Support/GetElementPtrTypeIterator.h"
125 #include "llvm/ADT/STLExtras.h"
126 #include "llvm/Support/MathExtras.h"
132 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
133 int yylex(); // declaration" of xxx warnings.
137 std::string CurFilename;
139 using namespace llvm;
141 static Module *ParserResult;
143 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
144 // relating to upreferences in the input stream.
146 //#define DEBUG_UPREFS 1
148 #define UR_OUT(X) std::cerr << X
153 #define YYERROR_VERBOSE 1
155 static bool ObsoleteVarArgs;
156 static bool NewVarArgs;
157 static BasicBlock *CurBB;
158 static GlobalVariable *CurGV;
161 // This contains info used when building the body of a function. It is
162 // destroyed when the function is completed.
164 typedef std::vector<Value *> ValueList; // Numbered defs
166 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
167 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
169 static struct PerModuleInfo {
170 Module *CurrentModule;
171 std::map<const Type *, ValueList> Values; // Module level numbered definitions
172 std::map<const Type *,ValueList> LateResolveValues;
173 std::vector<PATypeHolder> Types;
174 std::map<ValID, PATypeHolder> LateResolveTypes;
176 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
177 /// how they were referenced and on which line of the input they came from so
178 /// that we can resolve them later and print error messages as appropriate.
179 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
181 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
182 // references to global values. Global values may be referenced before they
183 // are defined, and if so, the temporary object that they represent is held
184 // here. This is used for forward references of GlobalValues.
186 typedef std::map<std::pair<const PointerType *,
187 ValID>, GlobalValue*> GlobalRefsType;
188 GlobalRefsType GlobalRefs;
191 // If we could not resolve some functions at function compilation time
192 // (calls to functions before they are defined), resolve them now... Types
193 // are resolved when the constant pool has been completely parsed.
195 ResolveDefinitions(LateResolveValues);
197 // Check to make sure that all global value forward references have been
200 if (!GlobalRefs.empty()) {
201 std::string UndefinedReferences = "Unresolved global references exist:\n";
203 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
205 UndefinedReferences += " " + I->first.first->getDescription() + " " +
206 I->first.second.getName() + "\n";
208 ThrowException(UndefinedReferences);
211 // Look for intrinsic functions and CallInst that need to be upgraded
212 for (Module::iterator FI = CurrentModule->begin(),
213 FE = CurrentModule->end(); FI != FE; )
214 UpgradeCallsToIntrinsic(FI++);
216 Values.clear(); // Clear out function local definitions
221 // GetForwardRefForGlobal - Check to see if there is a forward reference
222 // for this global. If so, remove it from the GlobalRefs map and return it.
223 // If not, just return null.
224 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
225 // Check to see if there is a forward reference to this global variable...
226 // if there is, eliminate it and patch the reference to use the new def'n.
227 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
228 GlobalValue *Ret = 0;
229 if (I != GlobalRefs.end()) {
237 static struct PerFunctionInfo {
238 Function *CurrentFunction; // Pointer to current function being created
240 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
241 std::map<const Type*, ValueList> LateResolveValues;
242 bool isDeclare; // Is this function a forward declararation?
244 /// BBForwardRefs - When we see forward references to basic blocks, keep
245 /// track of them here.
246 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
247 std::vector<BasicBlock*> NumberedBlocks;
250 inline PerFunctionInfo() {
255 inline void FunctionStart(Function *M) {
260 void FunctionDone() {
261 NumberedBlocks.clear();
263 // Any forward referenced blocks left?
264 if (!BBForwardRefs.empty())
265 ThrowException("Undefined reference to label " +
266 BBForwardRefs.begin()->first->getName());
268 // Resolve all forward references now.
269 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
271 Values.clear(); // Clear out function local definitions
275 } CurFun; // Info for the current function...
277 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
280 //===----------------------------------------------------------------------===//
281 // Code to handle definitions of all the types
282 //===----------------------------------------------------------------------===//
284 static int InsertValue(Value *V,
285 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
286 if (V->hasName()) return -1; // Is this a numbered definition?
288 // Yes, insert the value into the value table...
289 ValueList &List = ValueTab[V->getType()];
291 return List.size()-1;
294 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
296 case ValID::NumberVal: // Is it a numbered definition?
297 // Module constants occupy the lowest numbered slots...
298 if ((unsigned)D.Num < CurModule.Types.size())
299 return CurModule.Types[(unsigned)D.Num];
301 case ValID::NameVal: // Is it a named definition?
302 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
303 D.destroy(); // Free old strdup'd memory...
308 ThrowException("Internal parser error: Invalid symbol type reference!");
311 // If we reached here, we referenced either a symbol that we don't know about
312 // or an id number that hasn't been read yet. We may be referencing something
313 // forward, so just create an entry to be resolved later and get to it...
315 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
318 if (inFunctionScope()) {
319 if (D.Type == ValID::NameVal)
320 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
322 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
325 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
326 if (I != CurModule.LateResolveTypes.end())
329 Type *Typ = OpaqueType::get();
330 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
334 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
335 SymbolTable &SymTab =
336 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
337 CurModule.CurrentModule->getSymbolTable();
338 return SymTab.lookup(Ty, Name);
341 // getValNonImprovising - Look up the value specified by the provided type and
342 // the provided ValID. If the value exists and has already been defined, return
343 // it. Otherwise return null.
345 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
346 if (isa<FunctionType>(Ty))
347 ThrowException("Functions are not values and "
348 "must be referenced as pointers");
351 case ValID::NumberVal: { // Is it a numbered definition?
352 unsigned Num = (unsigned)D.Num;
354 // Module constants occupy the lowest numbered slots...
355 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
356 if (VI != CurModule.Values.end()) {
357 if (Num < VI->second.size())
358 return VI->second[Num];
359 Num -= VI->second.size();
362 // Make sure that our type is within bounds
363 VI = CurFun.Values.find(Ty);
364 if (VI == CurFun.Values.end()) return 0;
366 // Check that the number is within bounds...
367 if (VI->second.size() <= Num) return 0;
369 return VI->second[Num];
372 case ValID::NameVal: { // Is it a named definition?
373 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
374 if (N == 0) return 0;
376 D.destroy(); // Free old strdup'd memory...
380 // Check to make sure that "Ty" is an integral type, and that our
381 // value will fit into the specified type...
382 case ValID::ConstSIntVal: // Is it a constant pool reference??
383 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
384 ThrowException("Signed integral constant '" +
385 itostr(D.ConstPool64) + "' is invalid for type '" +
386 Ty->getDescription() + "'!");
387 return ConstantSInt::get(Ty, D.ConstPool64);
389 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
390 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
391 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
392 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
393 "' is invalid or out of range!");
394 } else { // This is really a signed reference. Transmogrify.
395 return ConstantSInt::get(Ty, D.ConstPool64);
398 return ConstantUInt::get(Ty, D.UConstPool64);
401 case ValID::ConstFPVal: // Is it a floating point const pool reference?
402 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
403 ThrowException("FP constant invalid for type!!");
404 return ConstantFP::get(Ty, D.ConstPoolFP);
406 case ValID::ConstNullVal: // Is it a null value?
407 if (!isa<PointerType>(Ty))
408 ThrowException("Cannot create a a non pointer null!");
409 return ConstantPointerNull::get(cast<PointerType>(Ty));
411 case ValID::ConstUndefVal: // Is it an undef value?
412 return UndefValue::get(Ty);
414 case ValID::ConstZeroVal: // Is it a zero value?
415 return Constant::getNullValue(Ty);
417 case ValID::ConstantVal: // Fully resolved constant?
418 if (D.ConstantValue->getType() != Ty)
419 ThrowException("Constant expression type different from required type!");
420 return D.ConstantValue;
422 case ValID::InlineAsmVal: { // Inline asm expression
423 const PointerType *PTy = dyn_cast<PointerType>(Ty);
424 const FunctionType *FTy =
425 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
426 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
427 ThrowException("Invalid type for asm constraint string!");
428 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
429 D.IAD->HasSideEffects);
430 D.destroy(); // Free InlineAsmDescriptor.
434 assert(0 && "Unhandled case!");
438 assert(0 && "Unhandled case!");
442 // getVal - This function is identical to getValNonImprovising, except that if a
443 // value is not already defined, it "improvises" by creating a placeholder var
444 // that looks and acts just like the requested variable. When the value is
445 // defined later, all uses of the placeholder variable are replaced with the
448 static Value *getVal(const Type *Ty, const ValID &ID) {
449 if (Ty == Type::LabelTy)
450 ThrowException("Cannot use a basic block here");
452 // See if the value has already been defined.
453 Value *V = getValNonImprovising(Ty, ID);
456 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
457 ThrowException("Invalid use of a composite type!");
459 // If we reached here, we referenced either a symbol that we don't know about
460 // or an id number that hasn't been read yet. We may be referencing something
461 // forward, so just create an entry to be resolved later and get to it...
463 V = new Argument(Ty);
465 // Remember where this forward reference came from. FIXME, shouldn't we try
466 // to recycle these things??
467 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
470 if (inFunctionScope())
471 InsertValue(V, CurFun.LateResolveValues);
473 InsertValue(V, CurModule.LateResolveValues);
477 /// getBBVal - This is used for two purposes:
478 /// * If isDefinition is true, a new basic block with the specified ID is being
480 /// * If isDefinition is true, this is a reference to a basic block, which may
481 /// or may not be a forward reference.
483 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
484 assert(inFunctionScope() && "Can't get basic block at global scope!");
489 default: ThrowException("Illegal label reference " + ID.getName());
490 case ValID::NumberVal: // Is it a numbered definition?
491 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
492 CurFun.NumberedBlocks.resize(ID.Num+1);
493 BB = CurFun.NumberedBlocks[ID.Num];
495 case ValID::NameVal: // Is it a named definition?
497 if (Value *N = CurFun.CurrentFunction->
498 getSymbolTable().lookup(Type::LabelTy, Name))
499 BB = cast<BasicBlock>(N);
503 // See if the block has already been defined.
505 // If this is the definition of the block, make sure the existing value was
506 // just a forward reference. If it was a forward reference, there will be
507 // an entry for it in the PlaceHolderInfo map.
508 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
509 // The existing value was a definition, not a forward reference.
510 ThrowException("Redefinition of label " + ID.getName());
512 ID.destroy(); // Free strdup'd memory.
516 // Otherwise this block has not been seen before.
517 BB = new BasicBlock("", CurFun.CurrentFunction);
518 if (ID.Type == ValID::NameVal) {
519 BB->setName(ID.Name);
521 CurFun.NumberedBlocks[ID.Num] = BB;
524 // If this is not a definition, keep track of it so we can use it as a forward
527 // Remember where this forward reference came from.
528 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
530 // The forward declaration could have been inserted anywhere in the
531 // function: insert it into the correct place now.
532 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
533 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
540 //===----------------------------------------------------------------------===//
541 // Code to handle forward references in instructions
542 //===----------------------------------------------------------------------===//
544 // This code handles the late binding needed with statements that reference
545 // values not defined yet... for example, a forward branch, or the PHI node for
548 // This keeps a table (CurFun.LateResolveValues) of all such forward references
549 // and back patchs after we are done.
552 // ResolveDefinitions - If we could not resolve some defs at parsing
553 // time (forward branches, phi functions for loops, etc...) resolve the
557 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
558 std::map<const Type*,ValueList> *FutureLateResolvers) {
559 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
560 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
561 E = LateResolvers.end(); LRI != E; ++LRI) {
562 ValueList &List = LRI->second;
563 while (!List.empty()) {
564 Value *V = List.back();
567 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
568 CurModule.PlaceHolderInfo.find(V);
569 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
571 ValID &DID = PHI->second.first;
573 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
575 V->replaceAllUsesWith(TheRealValue);
577 CurModule.PlaceHolderInfo.erase(PHI);
578 } else if (FutureLateResolvers) {
579 // Functions have their unresolved items forwarded to the module late
581 InsertValue(V, *FutureLateResolvers);
583 if (DID.Type == ValID::NameVal)
584 ThrowException("Reference to an invalid definition: '" +DID.getName()+
585 "' of type '" + V->getType()->getDescription() + "'",
588 ThrowException("Reference to an invalid definition: #" +
589 itostr(DID.Num) + " of type '" +
590 V->getType()->getDescription() + "'",
596 LateResolvers.clear();
599 // ResolveTypeTo - A brand new type was just declared. This means that (if
600 // name is not null) things referencing Name can be resolved. Otherwise, things
601 // refering to the number can be resolved. Do this now.
603 static void ResolveTypeTo(char *Name, const Type *ToTy) {
605 if (Name) D = ValID::create(Name);
606 else D = ValID::create((int)CurModule.Types.size());
608 std::map<ValID, PATypeHolder>::iterator I =
609 CurModule.LateResolveTypes.find(D);
610 if (I != CurModule.LateResolveTypes.end()) {
611 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
612 CurModule.LateResolveTypes.erase(I);
616 // setValueName - Set the specified value to the name given. The name may be
617 // null potentially, in which case this is a noop. The string passed in is
618 // assumed to be a malloc'd string buffer, and is free'd by this function.
620 static void setValueName(Value *V, char *NameStr) {
622 std::string Name(NameStr); // Copy string
623 free(NameStr); // Free old string
625 if (V->getType() == Type::VoidTy)
626 ThrowException("Can't assign name '" + Name+"' to value with void type!");
628 assert(inFunctionScope() && "Must be in function scope!");
629 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
630 if (ST.lookup(V->getType(), Name))
631 ThrowException("Redefinition of value named '" + Name + "' in the '" +
632 V->getType()->getDescription() + "' type plane!");
639 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
640 /// this is a declaration, otherwise it is a definition.
641 static GlobalVariable *
642 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
643 bool isConstantGlobal, const Type *Ty,
644 Constant *Initializer) {
645 if (isa<FunctionType>(Ty))
646 ThrowException("Cannot declare global vars of function type!");
648 const PointerType *PTy = PointerType::get(Ty);
652 Name = NameStr; // Copy string
653 free(NameStr); // Free old string
656 // See if this global value was forward referenced. If so, recycle the
660 ID = ValID::create((char*)Name.c_str());
662 ID = ValID::create((int)CurModule.Values[PTy].size());
665 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
666 // Move the global to the end of the list, from whereever it was
667 // previously inserted.
668 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
669 CurModule.CurrentModule->getGlobalList().remove(GV);
670 CurModule.CurrentModule->getGlobalList().push_back(GV);
671 GV->setInitializer(Initializer);
672 GV->setLinkage(Linkage);
673 GV->setConstant(isConstantGlobal);
674 InsertValue(GV, CurModule.Values);
678 // If this global has a name, check to see if there is already a definition
679 // of this global in the module. If so, merge as appropriate. Note that
680 // this is really just a hack around problems in the CFE. :(
682 // We are a simple redefinition of a value, check to see if it is defined
683 // the same as the old one.
684 if (GlobalVariable *EGV =
685 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
686 // We are allowed to redefine a global variable in two circumstances:
687 // 1. If at least one of the globals is uninitialized or
688 // 2. If both initializers have the same value.
690 if (!EGV->hasInitializer() || !Initializer ||
691 EGV->getInitializer() == Initializer) {
693 // Make sure the existing global version gets the initializer! Make
694 // sure that it also gets marked const if the new version is.
695 if (Initializer && !EGV->hasInitializer())
696 EGV->setInitializer(Initializer);
697 if (isConstantGlobal)
698 EGV->setConstant(true);
699 EGV->setLinkage(Linkage);
703 ThrowException("Redefinition of global variable named '" + Name +
704 "' in the '" + Ty->getDescription() + "' type plane!");
708 // Otherwise there is no existing GV to use, create one now.
710 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
711 CurModule.CurrentModule);
712 InsertValue(GV, CurModule.Values);
716 // setTypeName - Set the specified type to the name given. The name may be
717 // null potentially, in which case this is a noop. The string passed in is
718 // assumed to be a malloc'd string buffer, and is freed by this function.
720 // This function returns true if the type has already been defined, but is
721 // allowed to be redefined in the specified context. If the name is a new name
722 // for the type plane, it is inserted and false is returned.
723 static bool setTypeName(const Type *T, char *NameStr) {
724 assert(!inFunctionScope() && "Can't give types function-local names!");
725 if (NameStr == 0) return false;
727 std::string Name(NameStr); // Copy string
728 free(NameStr); // Free old string
730 // We don't allow assigning names to void type
731 if (T == Type::VoidTy)
732 ThrowException("Can't assign name '" + Name + "' to the void type!");
734 // Set the type name, checking for conflicts as we do so.
735 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
737 if (AlreadyExists) { // Inserting a name that is already defined???
738 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
739 assert(Existing && "Conflict but no matching type?");
741 // There is only one case where this is allowed: when we are refining an
742 // opaque type. In this case, Existing will be an opaque type.
743 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
744 // We ARE replacing an opaque type!
745 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
749 // Otherwise, this is an attempt to redefine a type. That's okay if
750 // the redefinition is identical to the original. This will be so if
751 // Existing and T point to the same Type object. In this one case we
752 // allow the equivalent redefinition.
753 if (Existing == T) return true; // Yes, it's equal.
755 // Any other kind of (non-equivalent) redefinition is an error.
756 ThrowException("Redefinition of type named '" + Name + "' in the '" +
757 T->getDescription() + "' type plane!");
763 //===----------------------------------------------------------------------===//
764 // Code for handling upreferences in type names...
767 // TypeContains - Returns true if Ty directly contains E in it.
769 static bool TypeContains(const Type *Ty, const Type *E) {
770 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
771 E) != Ty->subtype_end();
776 // NestingLevel - The number of nesting levels that need to be popped before
777 // this type is resolved.
778 unsigned NestingLevel;
780 // LastContainedTy - This is the type at the current binding level for the
781 // type. Every time we reduce the nesting level, this gets updated.
782 const Type *LastContainedTy;
784 // UpRefTy - This is the actual opaque type that the upreference is
788 UpRefRecord(unsigned NL, OpaqueType *URTy)
789 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
793 // UpRefs - A list of the outstanding upreferences that need to be resolved.
794 static std::vector<UpRefRecord> UpRefs;
796 /// HandleUpRefs - Every time we finish a new layer of types, this function is
797 /// called. It loops through the UpRefs vector, which is a list of the
798 /// currently active types. For each type, if the up reference is contained in
799 /// the newly completed type, we decrement the level count. When the level
800 /// count reaches zero, the upreferenced type is the type that is passed in:
801 /// thus we can complete the cycle.
803 static PATypeHolder HandleUpRefs(const Type *ty) {
804 if (!ty->isAbstract()) return ty;
806 UR_OUT("Type '" << Ty->getDescription() <<
807 "' newly formed. Resolving upreferences.\n" <<
808 UpRefs.size() << " upreferences active!\n");
810 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
811 // to zero), we resolve them all together before we resolve them to Ty. At
812 // the end of the loop, if there is anything to resolve to Ty, it will be in
814 OpaqueType *TypeToResolve = 0;
816 for (unsigned i = 0; i != UpRefs.size(); ++i) {
817 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
818 << UpRefs[i].second->getDescription() << ") = "
819 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
820 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
821 // Decrement level of upreference
822 unsigned Level = --UpRefs[i].NestingLevel;
823 UpRefs[i].LastContainedTy = Ty;
824 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
825 if (Level == 0) { // Upreference should be resolved!
826 if (!TypeToResolve) {
827 TypeToResolve = UpRefs[i].UpRefTy;
829 UR_OUT(" * Resolving upreference for "
830 << UpRefs[i].second->getDescription() << "\n";
831 std::string OldName = UpRefs[i].UpRefTy->getDescription());
832 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
833 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
834 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
836 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
837 --i; // Do not skip the next element...
843 UR_OUT(" * Resolving upreference for "
844 << UpRefs[i].second->getDescription() << "\n";
845 std::string OldName = TypeToResolve->getDescription());
846 TypeToResolve->refineAbstractTypeTo(Ty);
853 // common code from the two 'RunVMAsmParser' functions
854 static Module * RunParser(Module * M) {
856 llvmAsmlineno = 1; // Reset the current line number...
857 ObsoleteVarArgs = false;
860 CurModule.CurrentModule = M;
861 yyparse(); // Parse the file, potentially throwing exception
863 Module *Result = ParserResult;
866 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
869 if ((F = Result->getNamedFunction("llvm.va_start"))
870 && F->getFunctionType()->getNumParams() == 0)
871 ObsoleteVarArgs = true;
872 if((F = Result->getNamedFunction("llvm.va_copy"))
873 && F->getFunctionType()->getNumParams() == 1)
874 ObsoleteVarArgs = true;
877 if (ObsoleteVarArgs && NewVarArgs)
878 ThrowException("This file is corrupt: it uses both new and old style varargs");
880 if(ObsoleteVarArgs) {
881 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
882 if (F->arg_size() != 0)
883 ThrowException("Obsolete va_start takes 0 argument!");
887 //bar = alloca typeof(foo)
891 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
892 const Type* ArgTy = F->getFunctionType()->getReturnType();
893 const Type* ArgTyPtr = PointerType::get(ArgTy);
894 Function* NF = Result->getOrInsertFunction("llvm.va_start",
895 RetTy, ArgTyPtr, (Type *)0);
897 while (!F->use_empty()) {
898 CallInst* CI = cast<CallInst>(F->use_back());
899 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
900 new CallInst(NF, bar, "", CI);
901 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
902 CI->replaceAllUsesWith(foo);
903 CI->getParent()->getInstList().erase(CI);
905 Result->getFunctionList().erase(F);
908 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
909 if(F->arg_size() != 1)
910 ThrowException("Obsolete va_end takes 1 argument!");
914 //bar = alloca 1 of typeof(foo)
916 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
917 const Type* ArgTy = F->getFunctionType()->getParamType(0);
918 const Type* ArgTyPtr = PointerType::get(ArgTy);
919 Function* NF = Result->getOrInsertFunction("llvm.va_end",
920 RetTy, ArgTyPtr, (Type *)0);
922 while (!F->use_empty()) {
923 CallInst* CI = cast<CallInst>(F->use_back());
924 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
925 new StoreInst(CI->getOperand(1), bar, CI);
926 new CallInst(NF, bar, "", CI);
927 CI->getParent()->getInstList().erase(CI);
929 Result->getFunctionList().erase(F);
932 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
933 if(F->arg_size() != 1)
934 ThrowException("Obsolete va_copy takes 1 argument!");
937 //a = alloca 1 of typeof(foo)
938 //b = alloca 1 of typeof(foo)
943 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
944 const Type* ArgTy = F->getFunctionType()->getReturnType();
945 const Type* ArgTyPtr = PointerType::get(ArgTy);
946 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
947 RetTy, ArgTyPtr, ArgTyPtr,
950 while (!F->use_empty()) {
951 CallInst* CI = cast<CallInst>(F->use_back());
952 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
953 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
954 new StoreInst(CI->getOperand(1), b, CI);
955 new CallInst(NF, a, b, "", CI);
956 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
957 CI->replaceAllUsesWith(foo);
958 CI->getParent()->getInstList().erase(CI);
960 Result->getFunctionList().erase(F);
968 //===----------------------------------------------------------------------===//
969 // RunVMAsmParser - Define an interface to this parser
970 //===----------------------------------------------------------------------===//
972 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
975 CurFilename = Filename;
976 return RunParser(new Module(CurFilename));
979 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
980 set_scan_string(AsmString);
982 CurFilename = "from_memory";
984 return RunParser(new Module (CurFilename));
991 #line 890 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
993 llvm::Module *ModuleVal;
994 llvm::Function *FunctionVal;
995 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
996 llvm::BasicBlock *BasicBlockVal;
997 llvm::TerminatorInst *TermInstVal;
998 llvm::Instruction *InstVal;
999 llvm::Constant *ConstVal;
1001 const llvm::Type *PrimType;
1002 llvm::PATypeHolder *TypeVal;
1003 llvm::Value *ValueVal;
1005 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1006 std::vector<llvm::Value*> *ValueList;
1007 std::list<llvm::PATypeHolder> *TypeList;
1008 // Represent the RHS of PHI node
1009 std::list<std::pair<llvm::Value*,
1010 llvm::BasicBlock*> > *PHIList;
1011 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1012 std::vector<llvm::Constant*> *ConstVector;
1014 llvm::GlobalValue::LinkageTypes Linkage;
1022 char *StrVal; // This memory is strdup'd!
1023 llvm::ValID ValIDVal; // strdup'd memory maybe!
1025 llvm::Instruction::BinaryOps BinaryOpVal;
1026 llvm::Instruction::TermOps TermOpVal;
1027 llvm::Instruction::MemoryOps MemOpVal;
1028 llvm::Instruction::OtherOps OtherOpVal;
1029 llvm::Module::Endianness Endianness;
1042 #define YYFLAG -32768
1043 #define YYNTBASE 117
1045 #define YYTRANSLATE(x) ((unsigned)(x) <= 356 ? yytranslate[x] : 188)
1047 static const char yytranslate[] = { 0,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1050 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1051 2, 2, 2, 2, 2, 2, 2, 2, 2, 106,
1052 107, 115, 2, 104, 2, 2, 2, 2, 2, 2,
1053 2, 2, 2, 2, 2, 2, 2, 2, 2, 111,
1054 103, 112, 2, 2, 2, 2, 2, 2, 2, 2,
1055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1057 108, 105, 110, 2, 2, 2, 2, 2, 116, 2,
1058 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1059 2, 2, 2, 2, 2, 2, 2, 2, 2, 109,
1060 2, 2, 113, 2, 114, 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, 2, 2, 2, 2, 2,
1072 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1073 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1074 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1075 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1076 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1077 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1078 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1079 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1080 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1081 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1082 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1083 97, 98, 99, 100, 101, 102
1087 static const short yyprhs[] = { 0,
1088 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1089 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1090 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1091 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1092 78, 80, 82, 84, 86, 89, 90, 93, 94, 98,
1093 101, 102, 104, 105, 109, 111, 114, 116, 118, 120,
1094 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1095 142, 144, 146, 148, 150, 152, 154, 156, 159, 164,
1096 170, 176, 180, 183, 186, 188, 192, 194, 198, 200,
1097 201, 206, 210, 214, 219, 224, 228, 231, 234, 237,
1098 240, 243, 246, 249, 252, 255, 258, 265, 271, 280,
1099 287, 294, 301, 308, 315, 324, 333, 337, 339, 341,
1100 343, 345, 348, 351, 356, 359, 361, 366, 369, 374,
1101 375, 383, 384, 392, 396, 401, 402, 404, 406, 408,
1102 412, 416, 420, 424, 428, 430, 431, 433, 435, 437,
1103 438, 441, 445, 447, 449, 453, 455, 456, 465, 467,
1104 469, 473, 475, 477, 480, 481, 485, 486, 488, 490,
1105 492, 494, 496, 498, 500, 502, 504, 508, 510, 516,
1106 518, 520, 522, 524, 527, 530, 533, 537, 540, 541,
1107 543, 546, 549, 553, 563, 573, 582, 596, 598, 600,
1108 607, 613, 616, 623, 631, 633, 637, 639, 640, 643,
1109 645, 651, 657, 663, 666, 671, 676, 683, 688, 693,
1110 698, 703, 710, 717, 720, 728, 730, 733, 734, 736,
1111 737, 741, 748, 752, 759, 762, 767, 774
1114 static const short yyrhs[] = { 5,
1115 0, 6, 0, 3, 0, 4, 0, 72, 0, 73,
1116 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1117 0, 79, 0, 80, 0, 81, 0, 82, 0, 83,
1118 0, 84, 0, 85, 0, 95, 0, 96, 0, 16,
1119 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1120 0, 13, 0, 11, 0, 123, 0, 124, 0, 18,
1121 0, 19, 0, 157, 103, 0, 0, 41, 0, 42,
1122 0, 43, 0, 44, 0, 0, 0, 62, 0, 63,
1123 0, 64, 0, 65, 0, 61, 4, 0, 0, 54,
1124 4, 0, 0, 104, 54, 4, 0, 34, 24, 0,
1125 0, 132, 0, 0, 104, 135, 134, 0, 132, 0,
1126 54, 4, 0, 138, 0, 8, 0, 140, 0, 8,
1127 0, 140, 0, 9, 0, 10, 0, 11, 0, 12,
1128 0, 13, 0, 14, 0, 15, 0, 16, 0, 17,
1129 0, 18, 0, 19, 0, 20, 0, 21, 0, 45,
1130 0, 139, 0, 171, 0, 105, 4, 0, 137, 106,
1131 142, 107, 0, 108, 4, 109, 140, 110, 0, 111,
1132 4, 109, 140, 112, 0, 113, 141, 114, 0, 113,
1133 114, 0, 140, 115, 0, 140, 0, 141, 104, 140,
1134 0, 141, 0, 141, 104, 37, 0, 37, 0, 0,
1135 138, 108, 145, 110, 0, 138, 108, 110, 0, 138,
1136 116, 24, 0, 138, 111, 145, 112, 0, 138, 113,
1137 145, 114, 0, 138, 113, 114, 0, 138, 38, 0,
1138 138, 39, 0, 138, 171, 0, 138, 144, 0, 138,
1139 26, 0, 123, 118, 0, 124, 4, 0, 9, 27,
1140 0, 9, 28, 0, 126, 7, 0, 93, 106, 143,
1141 36, 138, 107, 0, 91, 106, 143, 185, 107, 0,
1142 94, 106, 143, 104, 143, 104, 143, 107, 0, 119,
1143 106, 143, 104, 143, 107, 0, 120, 106, 143, 104,
1144 143, 107, 0, 121, 106, 143, 104, 143, 107, 0,
1145 122, 106, 143, 104, 143, 107, 0, 98, 106, 143,
1146 104, 143, 107, 0, 99, 106, 143, 104, 143, 104,
1147 143, 107, 0, 100, 106, 143, 104, 143, 104, 143,
1148 107, 0, 145, 104, 143, 0, 143, 0, 32, 0,
1149 33, 0, 148, 0, 148, 166, 0, 148, 167, 0,
1150 148, 59, 58, 152, 0, 148, 25, 0, 149, 0,
1151 149, 127, 20, 136, 0, 149, 167, 0, 149, 59,
1152 58, 152, 0, 0, 149, 127, 128, 146, 143, 150,
1153 134, 0, 0, 149, 127, 47, 146, 138, 151, 134,
1154 0, 149, 48, 154, 0, 149, 55, 103, 155, 0,
1155 0, 24, 0, 53, 0, 52, 0, 50, 103, 153,
1156 0, 51, 103, 4, 0, 49, 103, 24, 0, 108,
1157 156, 110, 0, 156, 104, 24, 0, 24, 0, 0,
1158 22, 0, 24, 0, 157, 0, 0, 138, 158, 0,
1159 160, 104, 159, 0, 159, 0, 160, 0, 160, 104,
1160 37, 0, 37, 0, 0, 129, 136, 157, 106, 161,
1161 107, 133, 130, 0, 29, 0, 113, 0, 128, 162,
1162 163, 0, 30, 0, 114, 0, 174, 165, 0, 0,
1163 31, 168, 162, 0, 0, 60, 0, 3, 0, 4,
1164 0, 7, 0, 27, 0, 28, 0, 38, 0, 39,
1165 0, 26, 0, 111, 145, 112, 0, 144, 0, 58,
1166 169, 24, 104, 24, 0, 117, 0, 157, 0, 171,
1167 0, 170, 0, 138, 172, 0, 174, 175, 0, 164,
1168 175, 0, 176, 127, 177, 0, 176, 179, 0, 0,
1169 23, 0, 66, 173, 0, 66, 8, 0, 67, 21,
1170 172, 0, 67, 9, 172, 104, 21, 172, 104, 21,
1171 172, 0, 68, 125, 172, 104, 21, 172, 108, 178,
1172 110, 0, 68, 125, 172, 104, 21, 172, 108, 110,
1173 0, 69, 129, 136, 172, 106, 182, 107, 36, 21,
1174 172, 70, 21, 172, 0, 70, 0, 71, 0, 178,
1175 125, 170, 104, 21, 172, 0, 125, 170, 104, 21,
1176 172, 0, 127, 184, 0, 138, 108, 172, 104, 172,
1177 110, 0, 180, 104, 108, 172, 104, 172, 110, 0,
1178 173, 0, 181, 104, 173, 0, 181, 0, 0, 57,
1179 56, 0, 56, 0, 119, 138, 172, 104, 172, 0,
1180 120, 138, 172, 104, 172, 0, 121, 138, 172, 104,
1181 172, 0, 46, 173, 0, 122, 173, 104, 173, 0,
1182 93, 173, 36, 138, 0, 94, 173, 104, 173, 104,
1183 173, 0, 97, 173, 104, 138, 0, 101, 173, 104,
1184 138, 0, 102, 173, 104, 138, 0, 98, 173, 104,
1185 173, 0, 99, 173, 104, 173, 104, 173, 0, 100,
1186 173, 104, 173, 104, 173, 0, 92, 180, 0, 183,
1187 129, 136, 172, 106, 182, 107, 0, 187, 0, 104,
1188 181, 0, 0, 35, 0, 0, 86, 138, 131, 0,
1189 86, 138, 104, 15, 172, 131, 0, 87, 138, 131,
1190 0, 87, 138, 104, 15, 172, 131, 0, 88, 173,
1191 0, 186, 89, 138, 172, 0, 186, 90, 173, 104,
1192 138, 172, 0, 91, 138, 172, 185, 0
1198 static const short yyrline[] = { 0,
1199 1010, 1011, 1018, 1019, 1028, 1028, 1028, 1028, 1028, 1029,
1200 1029, 1029, 1030, 1030, 1030, 1030, 1030, 1030, 1032, 1032,
1201 1036, 1036, 1036, 1036, 1037, 1037, 1037, 1037, 1038, 1038,
1202 1039, 1039, 1042, 1045, 1049, 1049, 1050, 1051, 1052, 1055,
1203 1055, 1056, 1057, 1058, 1059, 1068, 1068, 1074, 1074, 1082,
1204 1089, 1089, 1095, 1095, 1097, 1101, 1114, 1114, 1115, 1115,
1205 1117, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1127, 1127,
1206 1127, 1127, 1127, 1127, 1128, 1131, 1134, 1140, 1147, 1159,
1207 1163, 1174, 1183, 1186, 1194, 1198, 1203, 1204, 1207, 1210,
1208 1220, 1245, 1258, 1287, 1312, 1332, 1344, 1353, 1357, 1416,
1209 1422, 1430, 1435, 1440, 1443, 1446, 1453, 1463, 1494, 1501,
1210 1522, 1532, 1537, 1544, 1549, 1554, 1562, 1565, 1572, 1572,
1211 1582, 1589, 1593, 1596, 1599, 1602, 1615, 1635, 1637, 1639,
1212 1642, 1645, 1649, 1652, 1654, 1656, 1660, 1672, 1673, 1675,
1213 1678, 1686, 1691, 1693, 1697, 1701, 1709, 1709, 1710, 1710,
1214 1712, 1718, 1723, 1729, 1732, 1737, 1741, 1745, 1831, 1831,
1215 1833, 1841, 1841, 1843, 1847, 1847, 1856, 1859, 1863, 1866,
1216 1869, 1872, 1875, 1878, 1881, 1884, 1887, 1911, 1914, 1927,
1217 1930, 1935, 1935, 1941, 1945, 1948, 1956, 1965, 1969, 1979,
1218 1990, 1993, 1996, 1999, 2002, 2016, 2020, 2073, 2076, 2082,
1219 2090, 2100, 2107, 2112, 2119, 2123, 2129, 2129, 2131, 2134,
1220 2140, 2152, 2163, 2173, 2185, 2192, 2199, 2206, 2211, 2230,
1221 2252, 2257, 2262, 2267, 2281, 2338, 2344, 2346, 2350, 2353,
1222 2359, 2363, 2367, 2371, 2375, 2382, 2392, 2405
1227 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1229 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1230 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1231 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1232 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1233 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1234 "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1235 "OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
1236 "BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1237 "CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE",
1238 "UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE",
1239 "SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
1240 "GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT",
1241 "INSERTELEMENT","SHUFFLEVECTOR","VAARG_old","VANEXT_old","'='","','","'\\\\'",
1242 "'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL",
1243 "ArithmeticOps","LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType",
1244 "FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString",
1245 "OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV",
1246 "Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1247 "ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","AsmBlock",
1248 "BigOrLittle","TargetDefinition","LibrariesDefinition","LibList","Name","OptName",
1249 "ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END",
1250 "Function","FunctionProto","@3","OptSideEffect","ConstValueRef","SymbolicValueRef",
1251 "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1252 "JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal",
1253 "IndexList","OptVolatile","MemoryInst", NULL
1257 static const short yyr1[] = { 0,
1258 117, 117, 118, 118, 119, 119, 119, 119, 119, 120,
1259 120, 120, 121, 121, 121, 121, 121, 121, 122, 122,
1260 123, 123, 123, 123, 124, 124, 124, 124, 125, 125,
1261 126, 126, 127, 127, 128, 128, 128, 128, 128, 129,
1262 129, 129, 129, 129, 129, 130, 130, 131, 131, 132,
1263 133, 133, 134, 134, 135, 135, 136, 136, 137, 137,
1264 138, 139, 139, 139, 139, 139, 139, 139, 139, 139,
1265 139, 139, 139, 139, 140, 140, 140, 140, 140, 140,
1266 140, 140, 140, 140, 141, 141, 142, 142, 142, 142,
1267 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
1268 143, 143, 143, 143, 143, 143, 144, 144, 144, 144,
1269 144, 144, 144, 144, 144, 144, 145, 145, 146, 146,
1270 147, 148, 148, 148, 148, 148, 149, 149, 149, 150,
1271 149, 151, 149, 149, 149, 149, 152, 153, 153, 154,
1272 154, 154, 155, 156, 156, 156, 157, 157, 158, 158,
1273 159, 160, 160, 161, 161, 161, 161, 162, 163, 163,
1274 164, 165, 165, 166, 168, 167, 169, 169, 170, 170,
1275 170, 170, 170, 170, 170, 170, 170, 170, 170, 171,
1276 171, 172, 172, 173, 174, 174, 175, 176, 176, 176,
1277 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
1278 178, 179, 180, 180, 181, 181, 182, 182, 183, 183,
1279 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
1280 184, 184, 184, 184, 184, 184, 185, 185, 186, 186,
1281 187, 187, 187, 187, 187, 187, 187, 187
1284 static const short yyr2[] = { 0,
1285 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1286 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1287 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1288 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1289 1, 1, 1, 1, 2, 0, 2, 0, 3, 2,
1290 0, 1, 0, 3, 1, 2, 1, 1, 1, 1,
1291 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1292 1, 1, 1, 1, 1, 1, 1, 2, 4, 5,
1293 5, 3, 2, 2, 1, 3, 1, 3, 1, 0,
1294 4, 3, 3, 4, 4, 3, 2, 2, 2, 2,
1295 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1296 6, 6, 6, 6, 8, 8, 3, 1, 1, 1,
1297 1, 2, 2, 4, 2, 1, 4, 2, 4, 0,
1298 7, 0, 7, 3, 4, 0, 1, 1, 1, 3,
1299 3, 3, 3, 3, 1, 0, 1, 1, 1, 0,
1300 2, 3, 1, 1, 3, 1, 0, 8, 1, 1,
1301 3, 1, 1, 2, 0, 3, 0, 1, 1, 1,
1302 1, 1, 1, 1, 1, 1, 3, 1, 5, 1,
1303 1, 1, 1, 2, 2, 2, 3, 2, 0, 1,
1304 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
1305 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
1306 5, 5, 5, 2, 4, 4, 6, 4, 4, 4,
1307 4, 6, 6, 2, 7, 1, 2, 0, 1, 0,
1308 3, 6, 3, 6, 2, 4, 6, 4
1311 static const short yydefact[] = { 136,
1312 39, 126, 125, 165, 35, 36, 37, 38, 0, 40,
1313 189, 122, 123, 189, 147, 148, 0, 0, 0, 39,
1314 0, 128, 40, 0, 0, 41, 42, 43, 44, 0,
1315 0, 190, 186, 34, 162, 163, 164, 185, 0, 0,
1316 0, 134, 0, 0, 0, 0, 0, 33, 166, 137,
1317 124, 45, 1, 2, 58, 62, 63, 64, 65, 66,
1318 67, 68, 69, 70, 71, 72, 73, 74, 75, 0,
1319 0, 0, 0, 180, 0, 0, 57, 76, 61, 181,
1320 77, 159, 160, 161, 230, 188, 0, 0, 0, 146,
1321 135, 129, 127, 119, 120, 0, 0, 78, 0, 0,
1322 60, 83, 85, 0, 0, 90, 84, 229, 0, 210,
1323 0, 0, 0, 0, 40, 198, 199, 5, 6, 7,
1324 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1325 18, 0, 0, 0, 0, 0, 0, 0, 19, 20,
1326 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1327 187, 40, 202, 0, 226, 142, 139, 138, 140, 141,
1328 145, 0, 132, 62, 63, 64, 65, 66, 67, 68,
1329 69, 70, 71, 72, 0, 0, 0, 0, 130, 0,
1330 0, 0, 82, 157, 89, 87, 0, 0, 214, 209,
1331 192, 191, 0, 0, 24, 28, 23, 27, 22, 26,
1332 21, 25, 29, 30, 0, 0, 48, 48, 235, 0,
1333 0, 224, 0, 0, 0, 0, 0, 0, 0, 0,
1334 0, 0, 0, 0, 0, 0, 0, 0, 143, 53,
1335 104, 105, 3, 4, 102, 103, 106, 101, 97, 98,
1336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1337 0, 0, 0, 0, 100, 99, 53, 59, 59, 86,
1338 156, 150, 153, 154, 0, 0, 79, 169, 170, 171,
1339 176, 172, 173, 174, 175, 167, 0, 178, 183, 182,
1340 184, 0, 193, 0, 0, 0, 231, 0, 233, 228,
1341 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1342 0, 0, 0, 0, 0, 0, 0, 144, 0, 133,
1343 0, 0, 0, 0, 0, 0, 92, 118, 0, 0,
1344 96, 0, 93, 0, 0, 0, 0, 131, 80, 81,
1345 149, 151, 0, 51, 88, 168, 0, 0, 0, 0,
1346 0, 0, 0, 0, 0, 238, 0, 0, 216, 0,
1347 218, 221, 0, 0, 219, 220, 0, 0, 0, 215,
1348 0, 236, 0, 0, 0, 55, 53, 228, 0, 0,
1349 0, 0, 0, 0, 91, 94, 95, 0, 0, 0,
1350 0, 155, 152, 52, 46, 0, 177, 0, 0, 208,
1351 48, 49, 48, 205, 227, 0, 0, 0, 0, 0,
1352 211, 212, 213, 208, 0, 50, 56, 54, 0, 0,
1353 0, 0, 0, 0, 117, 0, 0, 0, 0, 0,
1354 158, 0, 0, 0, 207, 0, 0, 232, 234, 0,
1355 0, 0, 217, 222, 223, 0, 237, 108, 0, 0,
1356 0, 0, 0, 0, 0, 0, 0, 47, 179, 0,
1357 0, 0, 206, 203, 0, 225, 107, 0, 114, 0,
1358 0, 110, 111, 112, 113, 0, 196, 0, 0, 0,
1359 204, 0, 0, 0, 194, 0, 195, 0, 0, 109,
1360 115, 116, 0, 0, 0, 0, 0, 0, 201, 0,
1361 0, 200, 197, 0, 0, 0
1364 static const short yydefgoto[] = { 74,
1365 235, 251, 252, 253, 254, 175, 176, 205, 177, 20,
1366 10, 30, 421, 287, 366, 385, 310, 367, 75, 76,
1367 178, 78, 79, 104, 187, 318, 278, 319, 96, 494,
1368 1, 2, 257, 230, 51, 159, 42, 91, 162, 80,
1369 332, 263, 264, 265, 31, 84, 11, 37, 12, 13,
1370 23, 337, 279, 81, 281, 394, 14, 33, 34, 151,
1371 469, 86, 212, 425, 426, 152, 153, 346, 154, 155
1374 static const short yypact[] = {-32768,
1375 181, 372,-32768,-32768,-32768,-32768,-32768,-32768, -32, 94,
1376 38,-32768,-32768, -14,-32768,-32768, 45, -40, 18, 44,
1377 -25,-32768, 94, 57, 79,-32768,-32768,-32768,-32768, 1012,
1378 -21,-32768,-32768, 22,-32768,-32768,-32768,-32768, -6, -4,
1379 27,-32768, 26, 57, 1012, 77, 77,-32768,-32768,-32768,
1380 -32768,-32768,-32768,-32768, 46,-32768,-32768,-32768,-32768,-32768,
1381 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 167,
1382 170, 171, 524,-32768, 22, 71,-32768,-32768, -17,-32768,
1383 -32768,-32768,-32768,-32768, 1176,-32768, 154, 76, 175, 156,
1384 -32768,-32768,-32768,-32768,-32768, 1050, 1088,-32768, 73, 74,
1385 -32768,-32768, -17, -83, 78, 819,-32768,-32768, 1050,-32768,
1386 129, 1126, 56, 128, 94,-32768,-32768,-32768,-32768,-32768,
1387 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1388 -32768, 1050, 1050, 1050, 1050, 1050, 1050, 1050,-32768,-32768,
1389 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050,
1390 -32768, 94,-32768, 43,-32768,-32768,-32768,-32768,-32768,-32768,
1391 -32768, -82,-32768, 119, 146, 183, 157, 190, 159, 194,
1392 166, 196, 195, 197, 169, 199, 198, 406,-32768, 1050,
1393 1050, 1050,-32768, 857,-32768, 97, 100, 617,-32768,-32768,
1394 46,-32768, 617, 617,-32768,-32768,-32768,-32768,-32768,-32768,
1395 -32768,-32768,-32768,-32768, 617, 1012, 104, 105,-32768, 617,
1396 103, 109, 178, 111, 122, 123, 131, 132, 133, 134,
1397 617, 617, 617, 135, 1012, 1050, 1050, 209,-32768, 137,
1398 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1399 136, 138, 139, 140, 141, 144, 895, 1088, 566, 219,
1400 145, 147, 148, 149,-32768,-32768, 137, -48, -88, -17,
1401 -32768, 22,-32768, 152, 150, 936,-32768,-32768,-32768,-32768,
1402 -32768,-32768,-32768,-32768,-32768, 192, 1088,-32768,-32768,-32768,
1403 -32768, 155,-32768, 158, 617, -5,-32768, 5,-32768, 172,
1404 617, 153, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050,
1405 173, 174, 176, 1050, 617, 617, 177,-32768, -20,-32768,
1406 1088, 1088, 1088, 1088, 1088, 1088,-32768,-32768, -62, -11,
1407 -32768, -79,-32768, 1088, 1088, 1088, 1088,-32768,-32768,-32768,
1408 -32768,-32768, 974, 224,-32768,-32768, 236, 23, 251, 252,
1409 180, 617, 271, 617, 1050,-32768, 179, 617,-32768, 184,
1410 -32768,-32768, 185, 186,-32768,-32768, 617, 617, 617,-32768,
1411 191,-32768, 1050, 258, 280,-32768, 137, 172, 256, 200,
1412 201, 202, 203, 1088,-32768,-32768,-32768, 204, 205, 206,
1413 207,-32768,-32768,-32768, 242, 208,-32768, 617, 617, 1050,
1414 210,-32768, 210,-32768, 216, 617, 222, 1050, 1050, 1050,
1415 -32768,-32768,-32768, 1050, 617,-32768,-32768,-32768, 220, 1050,
1416 1088, 1088, 1088, 1088,-32768, 1088, 1088, 1088, 1088, 294,
1417 -32768, 275, 225, 226, 216, 221, 259,-32768,-32768, 1050,
1418 227, 617,-32768,-32768,-32768, 223,-32768,-32768, 228, 232,
1419 234, 238, 239, 237, 240, 243, 244,-32768,-32768, 324,
1420 41, 310,-32768,-32768, 245,-32768,-32768, 1088,-32768, 1088,
1421 1088,-32768,-32768,-32768,-32768, 617,-32768, 715, 58, 328,
1422 -32768, 246, 247, 250,-32768, 248,-32768, 715, 617,-32768,
1423 -32768,-32768, 338, 260, 297, 617, 350, 351,-32768, 617,
1424 617,-32768,-32768, 376, 377,-32768
1427 static const short yypgoto[] = {-32768,
1428 -32768, 296, 298, 299, 300, -113, -111, -439,-32768, 345,
1429 362, -92,-32768, -203, 52,-32768, -244,-32768, -39,-32768,
1430 -30,-32768, -56, 281,-32768, -95, 215, -230, 341,-32768,
1431 -32768,-32768,-32768,-32768, 353,-32768,-32768,-32768,-32768, 9,
1432 -32768, 62,-32768,-32768, 375,-32768,-32768,-32768,-32768, 397,
1433 -32768,-32768, -388, -57, 168, -105,-32768, 387,-32768,-32768,
1434 -32768,-32768,-32768, 61, -2,-32768,-32768, 39,-32768,-32768
1441 static const short yytable[] = { 77,
1442 203, 179, 204, 189, 289, 93, 192, 82, 32, 342,
1443 21, 468, 328, 364, 77, 35, 103, 320, 322, 344,
1444 182, 228, 206, 330, 374, 24, 107, 229, 209, 478,
1445 183, 213, 214, 365, 377, 215, 216, 217, 218, 219,
1446 220, 374, 21, 15, 224, 16, 338, 375, 343, 103,
1447 195, 196, 197, 198, 199, 200, 201, 202, 343, 225,
1448 32, 329, 43, 45, 193, 163, 107, 195, 196, 197,
1449 198, 199, 200, 201, 202, 44, 194, 48, 188, 476,
1450 50, 188, 52, 105, 5, 6, 7, 8, -59, 484,
1451 46, 83, 374, 39, 40, 41, 87, 107, 88, 36,
1452 376, 207, 208, 188, 210, 211, 188, 188, 94, 95,
1453 188, 188, 188, 188, 188, 188, 221, 222, 223, 188,
1454 256, 307, 408, 258, 259, 260, 374, 157, 158, 89,
1455 280, 226, 227, 90, 387, 280, 280, 195, 196, 197,
1456 198, 199, 200, 201, 202, 231, 232, 280, -24, -24,
1457 467, -60, 280, 262, 25, 26, 27, 28, 29, -23,
1458 -23, -22, -22, 280, 280, 280, 285, 477, -21, -21,
1459 98, 233, 234, 99, 100, 77, 106, 156, 160, 161,
1460 -121, 180, 181, 184, 190, 305, -28, 428, 350, 429,
1461 352, 353, 354, -27, 77, 306, 188, -26, 360, -25,
1462 266, -31, 236, -32, 237, 3, 267, 286, 288, 260,
1463 291, 4, 292, 293, 294, 368, 369, 370, 371, 372,
1464 373, 5, 6, 7, 8, 295, 296, 280, 378, 379,
1465 380, 381, 308, 280, 297, 298, 299, 300, 304, 9,
1466 309, 311, 323, 312, 313, 314, 315, 280, 280, 316,
1467 324, 336, 325, 326, 327, 333, 334, 364, 339, 386,
1468 348, 340, 349, 188, 351, 188, 188, 188, 355, 356,
1469 331, 388, 389, 188, 392, 345, 357, 358, 415, 359,
1470 363, 406, 396, 407, 280, 390, 280, 398, 399, 400,
1471 280, 410, 433, 434, 435, 420, 404, 448, 449, 280,
1472 280, 280, 262, 411, 412, 413, 414, 416, 417, 418,
1473 419, 422, 343, 427, 188, 440, 441, 442, 443, 430,
1474 444, 445, 446, 447, 453, 432, 438, 452, 450, 456,
1475 280, 280, 405, 451, 457, 458, 454, 203, 280, 204,
1476 459, 460, 461, 462, 466, 470, 463, 280, 479, 464,
1477 465, 483, 480, 481, 471, 203, 482, 204, 486, 188,
1478 282, 283, 472, 487, 473, 474, 488, 188, 188, 188,
1479 490, 491, 284, 188, 280, 495, 496, 290, 85, 439,
1480 147, 47, 148, 149, 150, 384, 186, 97, 301, 302,
1481 303, -34, 255, 15, 383, 16, 92, 49, 22, 188,
1482 38, 436, 4, -34, -34, 395, 409, 0, 280, 0,
1483 53, 54, -34, -34, -34, -34, 0, 0, -34, 17,
1484 0, 280, 0, 0, 0, 0, 18, 15, 280, 16,
1485 19, 238, 280, 280, 0, 0, 0, 0, 0, 0,
1486 0, 0, 0, 239, 240, 0, 0, 0, 0, 0,
1487 0, 0, 341, 0, 0, 0, 0, 0, 347, 0,
1488 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1489 0, 0, 361, 362, 0, 0, 0, 118, 119, 120,
1490 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1491 131, 0, 0, 0, 0, 0, 241, 0, 242, 243,
1492 139, 140, 0, 244, 245, 246, 0, 0, 0, 391,
1493 0, 393, 0, 247, 0, 397, 248, 0, 249, 0,
1494 0, 250, 0, 0, 401, 402, 403, 0, 53, 54,
1495 0, 101, 56, 57, 58, 59, 60, 61, 62, 63,
1496 64, 65, 66, 67, 68, 15, 0, 16, 0, 0,
1497 0, 0, 0, 0, 0, 423, 424, 0, 0, 0,
1498 0, 0, 0, 431, 0, 0, 0, 0, 69, 0,
1499 53, 54, 437, 101, 164, 165, 166, 167, 168, 169,
1500 170, 171, 172, 173, 174, 67, 68, 15, 0, 16,
1501 0, 0, 0, 0, 0, 0, 0, 0, 0, 455,
1502 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1503 69, 0, 0, 0, 0, 0, 0, 0, 0, 268,
1504 269, 53, 54, 270, 0, 0, 0, 0, 70, 0,
1505 0, 71, 0, 475, 72, 0, 73, 102, 15, 0,
1506 16, 0, 271, 272, 273, 0, 485, 0, 0, 0,
1507 0, 0, 0, 489, 274, 275, 0, 492, 493, 0,
1508 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1509 70, 0, 0, 71, 276, 0, 72, 0, 73, 321,
1510 0, 0, 0, 0, 0, 0, 0, 0, 118, 119,
1511 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
1512 130, 131, 0, 0, 0, 0, 0, 241, 0, 242,
1513 243, 139, 140, 0, 244, 245, 246, 268, 269, 0,
1514 0, 270, 0, 0, 0, 0, 0, 277, 0, 0,
1515 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1516 271, 272, 273, 0, 0, 0, 0, 0, 0, 0,
1517 0, 0, 274, 275, 0, 0, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1519 0, 0, 276, 0, 0, 0, 0, 0, 0, 0,
1520 0, 0, 0, 0, 0, 0, 118, 119, 120, 121,
1521 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
1522 0, 0, 0, 0, 0, 241, 0, 242, 243, 139,
1523 140, 0, 244, 245, 246, 0, 0, 0, 0, 0,
1524 0, 0, 0, 53, 54, 277, 101, 56, 57, 58,
1525 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1526 15, 0, 16, 0, 0, 0, 0, 0, 0, 0,
1527 0, 0, 0, 0, 0, 185, 0, 0, 0, 0,
1528 0, 53, 54, 69, 101, 56, 57, 58, 59, 60,
1529 61, 62, 63, 64, 65, 66, 67, 68, 15, 0,
1530 16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1531 0, 0, 0, 261, 0, 0, 0, 0, 0, 53,
1532 54, 69, 101, 164, 165, 166, 167, 168, 169, 170,
1533 171, 172, 173, 174, 67, 68, 15, 0, 16, 0,
1534 0, 0, 0, 70, 0, 0, 71, 0, 0, 72,
1535 0, 73, 0, 0, 0, 0, 0, 0, 0, 69,
1536 53, 54, 0, 101, 56, 57, 58, 59, 60, 61,
1537 62, 63, 64, 65, 66, 67, 68, 15, 0, 16,
1538 0, 70, 0, 0, 71, 0, 0, 72, 0, 73,
1539 0, 0, 335, 0, 0, 0, 0, 0, 53, 54,
1540 69, 101, 56, 57, 58, 59, 60, 61, 62, 63,
1541 64, 65, 66, 67, 68, 15, 0, 16, 0, 70,
1542 0, 0, 71, 0, 317, 72, 0, 73, 0, 0,
1543 382, 0, 0, 0, 0, 0, 53, 54, 69, 55,
1544 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1545 66, 67, 68, 15, 0, 16, 0, 0, 0, 0,
1546 70, 0, 0, 71, 0, 0, 72, 0, 73, 0,
1547 0, 0, 0, 0, 53, 54, 69, 101, 56, 57,
1548 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
1549 68, 15, 0, 16, 0, 0, 0, 0, 70, 0,
1550 0, 71, 0, 0, 72, 0, 73, 0, 0, 0,
1551 0, 0, 53, 54, 69, 101, 164, 165, 166, 167,
1552 168, 169, 170, 171, 172, 173, 174, 67, 68, 15,
1553 0, 16, 0, 0, 0, 0, 70, 0, 0, 71,
1554 0, 0, 72, 0, 73, 0, 0, 0, 0, 0,
1555 53, 54, 69, 191, 56, 57, 58, 59, 60, 61,
1556 62, 63, 64, 65, 66, 67, 68, 15, 0, 16,
1557 0, 0, 0, 0, 70, 0, 0, 71, 0, 0,
1558 72, 0, 73, 0, 0, 0, 0, 0, 0, 0,
1559 69, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1560 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1561 0, 0, 70, 0, 0, 71, 0, 0, 72, 0,
1562 73, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1563 108, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1564 0, 109, 0, 0, 0, 0, 0, 0, 0, 0,
1565 70, 110, 111, 71, 0, 0, 72, 0, 73, 0,
1566 0, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1567 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1568 131, 132, 133, 134, 0, 0, 135, 136, 137, 138,
1569 139, 140, 141, 142, 143, 144, 145, 146
1572 static const short yycheck[] = { 30,
1573 114, 97, 114, 109, 208, 45, 112, 29, 23, 15,
1574 2, 451, 257, 34, 45, 30, 73, 248, 249, 15,
1575 104, 104, 115, 112, 104, 58, 115, 110, 134, 469,
1576 114, 137, 138, 54, 114, 141, 142, 143, 144, 145,
1577 146, 104, 34, 22, 150, 24, 277, 110, 54, 106,
1578 10, 11, 12, 13, 14, 15, 16, 17, 54, 152,
1579 23, 110, 103, 20, 9, 96, 115, 10, 11, 12,
1580 13, 14, 15, 16, 17, 58, 21, 103, 109, 468,
1581 24, 112, 4, 75, 41, 42, 43, 44, 106, 478,
1582 47, 113, 104, 49, 50, 51, 103, 115, 103, 114,
1583 112, 132, 133, 134, 135, 136, 137, 138, 32, 33,
1584 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
1585 178, 227, 367, 180, 181, 182, 104, 52, 53, 103,
1586 188, 89, 90, 108, 112, 193, 194, 10, 11, 12,
1587 13, 14, 15, 16, 17, 27, 28, 205, 3, 4,
1588 110, 106, 210, 184, 61, 62, 63, 64, 65, 3,
1589 4, 3, 4, 221, 222, 223, 206, 110, 3, 4,
1590 4, 3, 4, 4, 4, 206, 106, 24, 4, 24,
1591 0, 109, 109, 106, 56, 225, 4, 391, 294, 393,
1592 296, 297, 298, 4, 225, 226, 227, 4, 304, 4,
1593 104, 7, 4, 7, 7, 25, 107, 104, 104, 266,
1594 108, 31, 104, 36, 104, 311, 312, 313, 314, 315,
1595 316, 41, 42, 43, 44, 104, 104, 285, 324, 325,
1596 326, 327, 24, 291, 104, 104, 104, 104, 104, 59,
1597 104, 106, 24, 106, 106, 106, 106, 305, 306, 106,
1598 106, 60, 106, 106, 106, 104, 107, 34, 104, 24,
1599 108, 104, 293, 294, 295, 296, 297, 298, 299, 300,
1600 262, 21, 21, 304, 4, 104, 104, 104, 374, 104,
1601 104, 24, 104, 4, 342, 106, 344, 104, 104, 104,
1602 348, 36, 398, 399, 400, 54, 106, 4, 24, 357,
1603 358, 359, 333, 104, 104, 104, 104, 104, 104, 104,
1604 104, 104, 54, 104, 345, 411, 412, 413, 414, 104,
1605 416, 417, 418, 419, 430, 104, 107, 107, 104, 107,
1606 388, 389, 363, 108, 107, 104, 110, 451, 396, 451,
1607 107, 104, 104, 107, 21, 36, 107, 405, 21, 107,
1608 107, 104, 107, 107, 110, 469, 107, 469, 21, 390,
1609 193, 194, 458, 104, 460, 461, 70, 398, 399, 400,
1610 21, 21, 205, 404, 432, 0, 0, 210, 34, 410,
1611 85, 20, 85, 85, 85, 334, 106, 47, 221, 222,
1612 223, 20, 178, 22, 333, 24, 44, 23, 2, 430,
1613 14, 404, 31, 32, 33, 345, 368, -1, 466, -1,
1614 5, 6, 41, 42, 43, 44, -1, -1, 47, 48,
1615 -1, 479, -1, -1, -1, -1, 55, 22, 486, 24,
1616 59, 26, 490, 491, -1, -1, -1, -1, -1, -1,
1617 -1, -1, -1, 38, 39, -1, -1, -1, -1, -1,
1618 -1, -1, 285, -1, -1, -1, -1, -1, 291, -1,
1619 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1620 -1, -1, 305, 306, -1, -1, -1, 72, 73, 74,
1621 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1622 85, -1, -1, -1, -1, -1, 91, -1, 93, 94,
1623 95, 96, -1, 98, 99, 100, -1, -1, -1, 342,
1624 -1, 344, -1, 108, -1, 348, 111, -1, 113, -1,
1625 -1, 116, -1, -1, 357, 358, 359, -1, 5, 6,
1626 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1627 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1628 -1, -1, -1, -1, -1, 388, 389, -1, -1, -1,
1629 -1, -1, -1, 396, -1, -1, -1, -1, 45, -1,
1630 5, 6, 405, 8, 9, 10, 11, 12, 13, 14,
1631 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1632 -1, -1, -1, -1, -1, -1, -1, -1, -1, 432,
1633 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1634 45, -1, -1, -1, -1, -1, -1, -1, -1, 3,
1635 4, 5, 6, 7, -1, -1, -1, -1, 105, -1,
1636 -1, 108, -1, 466, 111, -1, 113, 114, 22, -1,
1637 24, -1, 26, 27, 28, -1, 479, -1, -1, -1,
1638 -1, -1, -1, 486, 38, 39, -1, 490, 491, -1,
1639 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1640 105, -1, -1, 108, 58, -1, 111, -1, 113, 114,
1641 -1, -1, -1, -1, -1, -1, -1, -1, 72, 73,
1642 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1643 84, 85, -1, -1, -1, -1, -1, 91, -1, 93,
1644 94, 95, 96, -1, 98, 99, 100, 3, 4, -1,
1645 -1, 7, -1, -1, -1, -1, -1, 111, -1, -1,
1646 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1647 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
1648 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
1649 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1650 -1, -1, 58, -1, -1, -1, -1, -1, -1, -1,
1651 -1, -1, -1, -1, -1, -1, 72, 73, 74, 75,
1652 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1653 -1, -1, -1, -1, -1, 91, -1, 93, 94, 95,
1654 96, -1, 98, 99, 100, -1, -1, -1, -1, -1,
1655 -1, -1, -1, 5, 6, 111, 8, 9, 10, 11,
1656 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1657 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
1658 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
1659 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
1660 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1661 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1662 -1, -1, -1, 37, -1, -1, -1, -1, -1, 5,
1663 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1664 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1665 -1, -1, -1, 105, -1, -1, 108, -1, -1, 111,
1666 -1, 113, -1, -1, -1, -1, -1, -1, -1, 45,
1667 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1668 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1669 -1, 105, -1, -1, 108, -1, -1, 111, -1, 113,
1670 -1, -1, 37, -1, -1, -1, -1, -1, 5, 6,
1671 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1672 17, 18, 19, 20, 21, 22, -1, 24, -1, 105,
1673 -1, -1, 108, -1, 110, 111, -1, 113, -1, -1,
1674 37, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1675 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1676 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1677 105, -1, -1, 108, -1, -1, 111, -1, 113, -1,
1678 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1679 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1680 21, 22, -1, 24, -1, -1, -1, -1, 105, -1,
1681 -1, 108, -1, -1, 111, -1, 113, -1, -1, -1,
1682 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1683 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1684 -1, 24, -1, -1, -1, -1, 105, -1, -1, 108,
1685 -1, -1, 111, -1, 113, -1, -1, -1, -1, -1,
1686 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1687 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1688 -1, -1, -1, -1, 105, -1, -1, 108, -1, -1,
1689 111, -1, 113, -1, -1, -1, -1, -1, -1, -1,
1690 45, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1691 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1692 -1, -1, 105, -1, -1, 108, -1, -1, 111, -1,
1693 113, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1694 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1695 -1, 46, -1, -1, -1, -1, -1, -1, -1, -1,
1696 105, 56, 57, 108, -1, -1, 111, -1, 113, -1,
1697 -1, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1698 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1699 85, 86, 87, 88, -1, -1, 91, 92, 93, 94,
1700 95, 96, 97, 98, 99, 100, 101, 102
1702 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1703 #line 3 "/usr/share/bison.simple"
1704 /* This file comes from bison-1.28. */
1706 /* Skeleton output parser for bison,
1707 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1709 This program is free software; you can redistribute it and/or modify
1710 it under the terms of the GNU General Public License as published by
1711 the Free Software Foundation; either version 2, or (at your option)
1714 This program is distributed in the hope that it will be useful,
1715 but WITHOUT ANY WARRANTY; without even the implied warranty of
1716 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717 GNU General Public License for more details.
1719 You should have received a copy of the GNU General Public License
1720 along with this program; if not, write to the Free Software
1721 Foundation, Inc., 59 Temple Place - Suite 330,
1722 Boston, MA 02111-1307, USA. */
1724 /* As a special exception, when this file is copied by Bison into a
1725 Bison output file, you may use that output file without restriction.
1726 This special exception was added by the Free Software Foundation
1727 in version 1.24 of Bison. */
1729 /* This is the parser code that is written into each bison parser
1730 when the %semantic_parser declaration is not specified in the grammar.
1731 It was written by Richard Stallman by simplifying the hairy parser
1732 used when %semantic_parser is specified. */
1734 #ifndef YYSTACK_USE_ALLOCA
1736 #define YYSTACK_USE_ALLOCA
1737 #else /* alloca not defined */
1739 #define YYSTACK_USE_ALLOCA
1740 #define alloca __builtin_alloca
1741 #else /* not GNU C. */
1742 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1743 #define YYSTACK_USE_ALLOCA
1745 #else /* not sparc */
1746 /* We think this test detects Watcom and Microsoft C. */
1747 /* This used to test MSDOS, but that is a bad idea
1748 since that symbol is in the user namespace. */
1749 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1750 #if 0 /* No need for malloc.h, which pollutes the namespace;
1751 instead, just don't use alloca. */
1754 #else /* not MSDOS, or __TURBOC__ */
1756 /* I don't know what this was needed for, but it pollutes the namespace.
1757 So I turned it off. rms, 2 May 1997. */
1758 /* #include <malloc.h> */
1760 #define YYSTACK_USE_ALLOCA
1761 #else /* not MSDOS, or __TURBOC__, or _AIX */
1763 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1764 and on HPUX 10. Eventually we can turn this on. */
1765 #define YYSTACK_USE_ALLOCA
1766 #define alloca __builtin_alloca
1769 #endif /* not _AIX */
1770 #endif /* not MSDOS, or __TURBOC__ */
1771 #endif /* not sparc */
1772 #endif /* not GNU C */
1773 #endif /* alloca not defined */
1774 #endif /* YYSTACK_USE_ALLOCA not defined */
1776 #ifdef YYSTACK_USE_ALLOCA
1777 #define YYSTACK_ALLOC alloca
1779 #define YYSTACK_ALLOC malloc
1782 /* Note: there must be only one dollar sign in this file.
1783 It is replaced by the list of actions, each action
1784 as one case of the switch. */
1786 #define yyerrok (yyerrstatus = 0)
1787 #define yyclearin (yychar = YYEMPTY)
1790 #define YYACCEPT goto yyacceptlab
1791 #define YYABORT goto yyabortlab
1792 #define YYERROR goto yyerrlab1
1793 /* Like YYERROR except do call yyerror.
1794 This remains here temporarily to ease the
1795 transition to the new meaning of YYERROR, for GCC.
1796 Once GCC version 2 has supplanted version 1, this can go. */
1797 #define YYFAIL goto yyerrlab
1798 #define YYRECOVERING() (!!yyerrstatus)
1799 #define YYBACKUP(token, value) \
1801 if (yychar == YYEMPTY && yylen == 1) \
1802 { yychar = (token), yylval = (value); \
1803 yychar1 = YYTRANSLATE (yychar); \
1808 { yyerror ("syntax error: cannot back up"); YYERROR; } \
1812 #define YYERRCODE 256
1815 #define YYLEX yylex()
1821 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
1823 #define YYLEX yylex(&yylval, &yylloc)
1825 #else /* not YYLSP_NEEDED */
1827 #define YYLEX yylex(&yylval, YYLEX_PARAM)
1829 #define YYLEX yylex(&yylval)
1831 #endif /* not YYLSP_NEEDED */
1834 /* If nonreentrant, generate the variables here */
1838 int yychar; /* the lookahead symbol */
1839 YYSTYPE yylval; /* the semantic value of the */
1840 /* lookahead symbol */
1843 YYLTYPE yylloc; /* location data for the lookahead */
1847 int yynerrs; /* number of parse errors so far */
1848 #endif /* not YYPURE */
1851 int yydebug; /* nonzero means print parse trace */
1852 /* Since this is uninitialized, it does not stop multiple parsers
1856 /* YYINITDEPTH indicates the initial size of the parser's stacks */
1859 #define YYINITDEPTH 200
1862 /* YYMAXDEPTH is the maximum size the stacks can grow to
1863 (effective only if the built-in stack extension method is used). */
1870 #define YYMAXDEPTH 10000
1873 /* Define __yy_memcpy. Note that the size argument
1874 should be passed with type unsigned int, because that is what the non-GCC
1875 definitions require. With GCC, __builtin_memcpy takes an arg
1876 of type size_t, but it can handle unsigned int. */
1878 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1879 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1880 #else /* not GNU C or C++ */
1883 /* This is the most reliable way to avoid incompatibilities
1884 in available built-in functions on various systems. */
1886 __yy_memcpy (to, from, count)
1891 register char *f = from;
1892 register char *t = to;
1893 register int i = count;
1899 #else /* __cplusplus */
1901 /* This is the most reliable way to avoid incompatibilities
1902 in available built-in functions on various systems. */
1904 __yy_memcpy (char *to, char *from, unsigned int count)
1906 register char *t = to;
1907 register char *f = from;
1908 register int i = count;
1917 #line 217 "/usr/share/bison.simple"
1919 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1920 into yyparse. The argument should have type void *.
1921 It should actually point to an object.
1922 Grammar actions can access the variable by casting it
1923 to the proper pointer type. */
1925 #ifdef YYPARSE_PARAM
1927 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1928 #define YYPARSE_PARAM_DECL
1929 #else /* not __cplusplus */
1930 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1931 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1932 #endif /* not __cplusplus */
1933 #else /* not YYPARSE_PARAM */
1934 #define YYPARSE_PARAM_ARG
1935 #define YYPARSE_PARAM_DECL
1936 #endif /* not YYPARSE_PARAM */
1938 /* Prevent warning if -Wstrict-prototypes. */
1940 #ifdef YYPARSE_PARAM
1941 int yyparse (void *);
1948 yyparse(YYPARSE_PARAM_ARG)
1951 register int yystate;
1953 register short *yyssp;
1954 register YYSTYPE *yyvsp;
1955 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1956 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1958 short yyssa[YYINITDEPTH]; /* the state stack */
1959 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1961 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1962 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1965 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1966 YYLTYPE *yyls = yylsa;
1969 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1971 #define YYPOPSTACK (yyvsp--, yyssp--)
1974 int yystacksize = YYINITDEPTH;
1975 int yyfree_stacks = 0;
1986 YYSTYPE yyval; /* the variable used to return */
1987 /* semantic values from the action */
1994 fprintf(stderr, "Starting parse\n");
2000 yychar = YYEMPTY; /* Cause a token to be read. */
2002 /* Initialize stack pointers.
2003 Waste one element of value and location stack
2004 so that they stay on the same level as the state stack.
2005 The wasted elements are never initialized. */
2013 /* Push a new state, which is found in yystate . */
2014 /* In all cases, when you get here, the value and location stacks
2015 have just been pushed. so pushing a state here evens the stacks. */
2020 if (yyssp >= yyss + yystacksize - 1)
2022 /* Give user a chance to reallocate the stack */
2023 /* Use copies of these so that the &'s don't force the real ones into memory. */
2024 YYSTYPE *yyvs1 = yyvs;
2025 short *yyss1 = yyss;
2027 YYLTYPE *yyls1 = yyls;
2030 /* Get the current used size of the three stacks, in elements. */
2031 int size = yyssp - yyss + 1;
2034 /* Each stack pointer address is followed by the size of
2035 the data in use in that stack, in bytes. */
2037 /* This used to be a conditional around just the two extra args,
2038 but that might be undefined if yyoverflow is a macro. */
2039 yyoverflow("parser stack overflow",
2040 &yyss1, size * sizeof (*yyssp),
2041 &yyvs1, size * sizeof (*yyvsp),
2042 &yyls1, size * sizeof (*yylsp),
2045 yyoverflow("parser stack overflow",
2046 &yyss1, size * sizeof (*yyssp),
2047 &yyvs1, size * sizeof (*yyvsp),
2051 yyss = yyss1; yyvs = yyvs1;
2055 #else /* no yyoverflow */
2056 /* Extend the stack our own way. */
2057 if (yystacksize >= YYMAXDEPTH)
2059 yyerror("parser stack overflow");
2071 if (yystacksize > YYMAXDEPTH)
2072 yystacksize = YYMAXDEPTH;
2073 #ifndef YYSTACK_USE_ALLOCA
2076 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2077 __yy_memcpy ((char *)yyss, (char *)yyss1,
2078 size * (unsigned int) sizeof (*yyssp));
2079 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2080 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2081 size * (unsigned int) sizeof (*yyvsp));
2083 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2084 __yy_memcpy ((char *)yyls, (char *)yyls1,
2085 size * (unsigned int) sizeof (*yylsp));
2087 #endif /* no yyoverflow */
2089 yyssp = yyss + size - 1;
2090 yyvsp = yyvs + size - 1;
2092 yylsp = yyls + size - 1;
2097 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2100 if (yyssp >= yyss + yystacksize - 1)
2106 fprintf(stderr, "Entering state %d\n", yystate);
2112 /* Do appropriate processing given the current state. */
2113 /* Read a lookahead token if we need one and don't already have one. */
2116 /* First try to decide what to do without reference to lookahead token. */
2118 yyn = yypact[yystate];
2122 /* Not known => get a lookahead token if don't already have one. */
2124 /* yychar is either YYEMPTY or YYEOF
2125 or a valid token in external form. */
2127 if (yychar == YYEMPTY)
2131 fprintf(stderr, "Reading a token: ");
2136 /* Convert token to internal form (in yychar1) for indexing tables with */
2138 if (yychar <= 0) /* This means end of input. */
2141 yychar = YYEOF; /* Don't call YYLEX any more */
2145 fprintf(stderr, "Now at end of input.\n");
2150 yychar1 = YYTRANSLATE(yychar);
2155 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2156 /* Give the individual parser a way to print the precise meaning
2157 of a token, for further debugging info. */
2159 YYPRINT (stderr, yychar, yylval);
2161 fprintf (stderr, ")\n");
2167 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2172 /* yyn is what to do for this token type in this state.
2173 Negative => reduce, -yyn is rule number.
2174 Positive => shift, yyn is new state.
2175 New state is final state => don't bother to shift,
2176 just return success.
2177 0, or most negative number => error. */
2192 /* Shift the lookahead token. */
2196 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2199 /* Discard the token being shifted unless it is eof. */
2200 if (yychar != YYEOF)
2208 /* count tokens shifted since error; after three, turn off error status. */
2209 if (yyerrstatus) yyerrstatus--;
2214 /* Do the default action for the current state. */
2217 yyn = yydefact[yystate];
2221 /* Do a reduction. yyn is the number of a rule to reduce with. */
2225 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2232 fprintf (stderr, "Reducing via rule %d (line %d), ",
2235 /* Print the symbols being reduced, and their result. */
2236 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2237 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2238 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2246 #line 1011 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2248 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2249 ThrowException("Value too large for type!");
2250 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2254 #line 1019 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2256 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2257 ThrowException("Value too large for type!");
2258 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2262 #line 1042 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2264 yyval.StrVal = yyvsp[-1].StrVal;
2268 #line 1045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2274 #line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2275 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2278 #line 1050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2279 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2282 #line 1051 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2283 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2286 #line 1052 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2287 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2290 #line 1053 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2291 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2294 #line 1055 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2295 { yyval.UIntVal = CallingConv::C; ;
2298 #line 1056 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2299 { yyval.UIntVal = CallingConv::C; ;
2302 #line 1057 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2303 { yyval.UIntVal = CallingConv::CSRet; ;
2306 #line 1058 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2307 { yyval.UIntVal = CallingConv::Fast; ;
2310 #line 1059 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2311 { yyval.UIntVal = CallingConv::Cold; ;
2314 #line 1060 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2316 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2317 ThrowException("Calling conv too large!");
2318 yyval.UIntVal = yyvsp[0].UInt64Val;
2322 #line 1068 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2323 { yyval.UIntVal = 0; ;
2326 #line 1069 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2328 yyval.UIntVal = yyvsp[0].UInt64Val;
2329 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2330 ThrowException("Alignment must be a power of two!");
2334 #line 1074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2335 { yyval.UIntVal = 0; ;
2338 #line 1075 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2340 yyval.UIntVal = yyvsp[0].UInt64Val;
2341 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2342 ThrowException("Alignment must be a power of two!");
2346 #line 1082 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2348 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2349 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2350 ThrowException("Invalid character in section name!");
2351 yyval.StrVal = yyvsp[0].StrVal;
2355 #line 1089 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2356 { yyval.StrVal = 0; ;
2359 #line 1090 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2360 { yyval.StrVal = yyvsp[0].StrVal; ;
2363 #line 1095 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2367 #line 1096 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2371 #line 1097 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2373 CurGV->setSection(yyvsp[0].StrVal);
2374 free(yyvsp[0].StrVal);
2378 #line 1101 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2380 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2381 ThrowException("Alignment must be a power of two!");
2382 CurGV->setAlignment(yyvsp[0].UInt64Val);
2386 #line 1114 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2387 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2390 #line 1115 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2391 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2394 #line 1117 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2396 if (!UpRefs.empty())
2397 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2398 yyval.TypeVal = yyvsp[0].TypeVal;
2402 #line 1128 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2404 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2408 #line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2410 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2414 #line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2415 { // Named types are also simple types...
2416 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2420 #line 1140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2421 { // Type UpReference
2422 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2423 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2424 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2425 yyval.TypeVal = new PATypeHolder(OT);
2426 UR_OUT("New Upreference!\n");
2430 #line 1147 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2431 { // Function derived type?
2432 std::vector<const Type*> Params;
2433 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2434 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2435 Params.push_back(*I);
2436 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2437 if (isVarArg) Params.pop_back();
2439 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2440 delete yyvsp[-1].TypeList; // Delete the argument list
2441 delete yyvsp[-3].TypeVal; // Delete the return type handle
2445 #line 1159 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2446 { // Sized array type?
2447 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2448 delete yyvsp[-1].TypeVal;
2452 #line 1163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2453 { // Packed array type?
2454 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2455 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2456 ThrowException("Unsigned result not equal to signed result");
2457 if (!ElemTy->isPrimitiveType())
2458 ThrowException("Elemental type of a PackedType must be primitive");
2459 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2460 ThrowException("Vector length should be a power of 2!");
2461 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2462 delete yyvsp[-1].TypeVal;
2466 #line 1174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2467 { // Structure type?
2468 std::vector<const Type*> Elements;
2469 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2470 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2471 Elements.push_back(*I);
2473 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2474 delete yyvsp[-1].TypeList;
2478 #line 1183 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2479 { // Empty structure type?
2480 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2484 #line 1186 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2486 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2487 delete yyvsp[-1].TypeVal;
2491 #line 1194 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2493 yyval.TypeList = new std::list<PATypeHolder>();
2494 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2498 #line 1198 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2500 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2504 #line 1204 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2506 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2510 #line 1207 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2512 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2516 #line 1210 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2518 yyval.TypeList = new std::list<PATypeHolder>();
2522 #line 1220 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2523 { // Nonempty unsized arr
2524 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2526 ThrowException("Cannot make array constant with type: '" +
2527 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2528 const Type *ETy = ATy->getElementType();
2529 int NumElements = ATy->getNumElements();
2531 // Verify that we have the correct size...
2532 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2533 ThrowException("Type mismatch: constant sized array initialized with " +
2534 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2535 itostr(NumElements) + "!");
2537 // Verify all elements are correct type!
2538 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2539 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2540 ThrowException("Element #" + utostr(i) + " is not of type '" +
2541 ETy->getDescription() +"' as required!\nIt is of type '"+
2542 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2545 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2546 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2550 #line 1245 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2552 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2554 ThrowException("Cannot make array constant with type: '" +
2555 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2557 int NumElements = ATy->getNumElements();
2558 if (NumElements != -1 && NumElements != 0)
2559 ThrowException("Type mismatch: constant sized array initialized with 0"
2560 " arguments, but has size of " + itostr(NumElements) +"!");
2561 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2562 delete yyvsp[-2].TypeVal;
2566 #line 1258 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2568 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2570 ThrowException("Cannot make array constant with type: '" +
2571 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2573 int NumElements = ATy->getNumElements();
2574 const Type *ETy = ATy->getElementType();
2575 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2576 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2577 ThrowException("Can't build string constant of size " +
2578 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2579 " when array has size " + itostr(NumElements) + "!");
2580 std::vector<Constant*> Vals;
2581 if (ETy == Type::SByteTy) {
2582 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
2583 Vals.push_back(ConstantSInt::get(ETy, *C));
2584 } else if (ETy == Type::UByteTy) {
2585 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2586 C != (unsigned char*)EndStr; ++C)
2587 Vals.push_back(ConstantUInt::get(ETy, *C));
2589 free(yyvsp[0].StrVal);
2590 ThrowException("Cannot build string arrays of non byte sized elements!");
2592 free(yyvsp[0].StrVal);
2593 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2594 delete yyvsp[-2].TypeVal;
2598 #line 1287 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2599 { // Nonempty unsized arr
2600 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2602 ThrowException("Cannot make packed constant with type: '" +
2603 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2604 const Type *ETy = PTy->getElementType();
2605 int NumElements = PTy->getNumElements();
2607 // Verify that we have the correct size...
2608 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2609 ThrowException("Type mismatch: constant sized packed initialized with " +
2610 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2611 itostr(NumElements) + "!");
2613 // Verify all elements are correct type!
2614 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2615 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2616 ThrowException("Element #" + utostr(i) + " is not of type '" +
2617 ETy->getDescription() +"' as required!\nIt is of type '"+
2618 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2621 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2622 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2626 #line 1312 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2628 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2630 ThrowException("Cannot make struct constant with type: '" +
2631 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2633 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2634 ThrowException("Illegal number of initializers for structure type!");
2636 // Check to ensure that constants are compatible with the type initializer!
2637 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2638 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2639 ThrowException("Expected type '" +
2640 STy->getElementType(i)->getDescription() +
2641 "' for element #" + utostr(i) +
2642 " of structure initializer!");
2644 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2645 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2649 #line 1332 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2651 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2653 ThrowException("Cannot make struct constant with type: '" +
2654 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2656 if (STy->getNumContainedTypes() != 0)
2657 ThrowException("Illegal number of initializers for structure type!");
2659 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2660 delete yyvsp[-2].TypeVal;
2664 #line 1344 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2666 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2668 ThrowException("Cannot make null pointer constant with type: '" +
2669 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2671 yyval.ConstVal = ConstantPointerNull::get(PTy);
2672 delete yyvsp[-1].TypeVal;
2676 #line 1353 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2678 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2679 delete yyvsp[-1].TypeVal;
2683 #line 1357 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2685 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2687 ThrowException("Global const reference must be a pointer type!");
2689 // ConstExprs can exist in the body of a function, thus creating
2690 // GlobalValues whenever they refer to a variable. Because we are in
2691 // the context of a function, getValNonImprovising will search the functions
2692 // symbol table instead of the module symbol table for the global symbol,
2693 // which throws things all off. To get around this, we just tell
2694 // getValNonImprovising that we are at global scope here.
2696 Function *SavedCurFn = CurFun.CurrentFunction;
2697 CurFun.CurrentFunction = 0;
2699 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2701 CurFun.CurrentFunction = SavedCurFn;
2703 // If this is an initializer for a constant pointer, which is referencing a
2704 // (currently) undefined variable, create a stub now that shall be replaced
2705 // in the future with the right type of variable.
2708 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2709 const PointerType *PT = cast<PointerType>(Ty);
2711 // First check to see if the forward references value is already created!
2712 PerModuleInfo::GlobalRefsType::iterator I =
2713 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2715 if (I != CurModule.GlobalRefs.end()) {
2716 V = I->second; // Placeholder already exists, use it...
2717 yyvsp[0].ValIDVal.destroy();
2720 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2722 // Create the forward referenced global.
2724 if (const FunctionType *FTy =
2725 dyn_cast<FunctionType>(PT->getElementType())) {
2726 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2727 CurModule.CurrentModule);
2729 GV = new GlobalVariable(PT->getElementType(), false,
2730 GlobalValue::ExternalLinkage, 0,
2731 Name, CurModule.CurrentModule);
2734 // Keep track of the fact that we have a forward ref to recycle it
2735 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2740 yyval.ConstVal = cast<GlobalValue>(V);
2741 delete yyvsp[-1].TypeVal; // Free the type handle
2745 #line 1416 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2747 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2748 ThrowException("Mismatched types for constant expression!");
2749 yyval.ConstVal = yyvsp[0].ConstVal;
2750 delete yyvsp[-1].TypeVal;
2754 #line 1422 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2756 const Type *Ty = yyvsp[-1].TypeVal->get();
2757 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2758 ThrowException("Cannot create a null initialized value of this type!");
2759 yyval.ConstVal = Constant::getNullValue(Ty);
2760 delete yyvsp[-1].TypeVal;
2764 #line 1430 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2765 { // integral constants
2766 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2767 ThrowException("Constant value doesn't fit in type!");
2768 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
2772 #line 1435 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2773 { // integral constants
2774 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2775 ThrowException("Constant value doesn't fit in type!");
2776 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
2780 #line 1440 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2781 { // Boolean constants
2782 yyval.ConstVal = ConstantBool::True;
2786 #line 1443 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2787 { // Boolean constants
2788 yyval.ConstVal = ConstantBool::False;
2792 #line 1446 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2793 { // Float & Double constants
2794 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2795 ThrowException("Floating point constant invalid for type!!");
2796 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
2800 #line 1453 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2802 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2803 ThrowException("cast constant expression from a non-primitive type: '" +
2804 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2805 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2806 ThrowException("cast constant expression to a non-primitive type: '" +
2807 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2808 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2809 delete yyvsp[-1].TypeVal;
2813 #line 1463 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2815 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2816 ThrowException("GetElementPtr requires a pointer operand!");
2818 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2819 // indices to uint struct indices for compatibility.
2820 generic_gep_type_iterator<std::vector<Value*>::iterator>
2821 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2822 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2823 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2824 if (isa<StructType>(*GTI)) // Only change struct indices
2825 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2826 if (CUI->getType() == Type::UByteTy)
2827 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2830 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2832 ThrowException("Index list invalid for constant getelementptr!");
2834 std::vector<Constant*> IdxVec;
2835 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2836 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2837 IdxVec.push_back(C);
2839 ThrowException("Indices to constant getelementptr must be constants!");
2841 delete yyvsp[-1].ValueList;
2843 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
2847 #line 1494 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2849 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2850 ThrowException("Select condition must be of boolean type!");
2851 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2852 ThrowException("Select operand types must match!");
2853 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2857 #line 1501 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2859 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2860 ThrowException("Binary operator types must match!");
2861 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2862 // To retain backward compatibility with these early compilers, we emit a
2863 // cast to the appropriate integer type automatically if we are in the
2864 // broken case. See PR424 for more information.
2865 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2866 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2868 const Type *IntPtrTy = 0;
2869 switch (CurModule.CurrentModule->getPointerSize()) {
2870 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2871 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2872 default: ThrowException("invalid pointer binary constant expr!");
2874 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2875 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2876 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2881 #line 1522 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2883 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2884 ThrowException("Logical operator types must match!");
2885 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2886 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2887 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2888 ThrowException("Logical operator requires integral operands!");
2890 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2894 #line 1532 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2896 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2897 ThrowException("setcc operand types must match!");
2898 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2902 #line 1537 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2904 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2905 ThrowException("Shift count for shift constant must be unsigned byte!");
2906 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2907 ThrowException("Shift constant expression requires integer operand!");
2908 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2912 #line 1544 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2914 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2915 ThrowException("Invalid extractelement operands!");
2916 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2920 #line 1549 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2922 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2923 ThrowException("Invalid insertelement operands!");
2924 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2928 #line 1554 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2930 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2931 ThrowException("Invalid shufflevector operands!");
2932 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2936 #line 1562 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2938 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
2942 #line 1565 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2944 yyval.ConstVector = new std::vector<Constant*>();
2945 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
2949 #line 1572 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2950 { yyval.BoolVal = false; ;
2953 #line 1572 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2954 { yyval.BoolVal = true; ;
2957 #line 1582 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2959 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2960 CurModule.ModuleDone();
2964 #line 1589 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2966 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2967 CurFun.FunctionDone();
2971 #line 1593 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2973 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2977 #line 1596 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2979 yyval.ModuleVal = yyvsp[-3].ModuleVal;
2983 #line 1599 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2985 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2989 #line 1602 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2991 yyval.ModuleVal = CurModule.CurrentModule;
2992 // Emit an error if there are any unresolved types left.
2993 if (!CurModule.LateResolveTypes.empty()) {
2994 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2995 if (DID.Type == ValID::NameVal)
2996 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2998 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
3003 #line 1615 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3005 // Eagerly resolve types. This is not an optimization, this is a
3006 // requirement that is due to the fact that we could have this:
3008 // %list = type { %list * }
3009 // %list = type { %list * } ; repeated type decl
3011 // If types are not resolved eagerly, then the two types will not be
3012 // determined to be the same type!
3014 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3016 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3017 // If this is a named type that is not a redefinition, add it to the slot
3019 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3022 delete yyvsp[0].TypeVal;
3026 #line 1635 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3027 { // Function prototypes can be in const pool
3031 #line 1637 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3032 { // Asm blocks can be in the const pool
3036 #line 1639 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3038 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3039 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3043 #line 1642 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3049 #line 1645 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3051 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3052 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3053 delete yyvsp[0].TypeVal;
3057 #line 1649 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3063 #line 1652 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3068 #line 1654 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3073 #line 1656 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3078 #line 1660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3080 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3081 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3082 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3083 free(yyvsp[0].StrVal);
3085 if (AsmSoFar.empty())
3086 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3088 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
3092 #line 1672 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3093 { yyval.Endianness = Module::BigEndian; ;
3096 #line 1673 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3097 { yyval.Endianness = Module::LittleEndian; ;
3100 #line 1675 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3102 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3106 #line 1678 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3108 if (yyvsp[0].UInt64Val == 32)
3109 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3110 else if (yyvsp[0].UInt64Val == 64)
3111 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3113 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3117 #line 1686 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3119 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3120 free(yyvsp[0].StrVal);
3124 #line 1693 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3126 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3127 free(yyvsp[0].StrVal);
3131 #line 1697 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3133 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3134 free(yyvsp[0].StrVal);
3138 #line 1701 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3143 #line 1710 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3144 { yyval.StrVal = 0; ;
3147 #line 1712 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3149 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3150 ThrowException("void typed arguments are invalid!");
3151 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3155 #line 1718 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3157 yyval.ArgList = yyvsp[-2].ArgList;
3158 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3159 delete yyvsp[0].ArgVal;
3163 #line 1723 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3165 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3166 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3167 delete yyvsp[0].ArgVal;
3171 #line 1729 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3173 yyval.ArgList = yyvsp[0].ArgList;
3177 #line 1732 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3179 yyval.ArgList = yyvsp[-2].ArgList;
3180 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3181 char*>(new PATypeHolder(Type::VoidTy), 0));
3185 #line 1737 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3187 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3188 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3192 #line 1741 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3198 #line 1746 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3200 UnEscapeLexed(yyvsp[-5].StrVal);
3201 std::string FunctionName(yyvsp[-5].StrVal);
3202 free(yyvsp[-5].StrVal); // Free strdup'd memory!
3204 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
3205 ThrowException("LLVM functions cannot return aggregate types!");
3207 std::vector<const Type*> ParamTypeList;
3208 if (yyvsp[-3].ArgList) { // If there are arguments...
3209 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3210 I != yyvsp[-3].ArgList->end(); ++I)
3211 ParamTypeList.push_back(I->first->get());
3214 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3215 if (isVarArg) ParamTypeList.pop_back();
3217 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
3218 const PointerType *PFT = PointerType::get(FT);
3219 delete yyvsp[-6].TypeVal;
3222 if (!FunctionName.empty()) {
3223 ID = ValID::create((char*)FunctionName.c_str());
3225 ID = ValID::create((int)CurModule.Values[PFT].size());
3229 // See if this function was forward referenced. If so, recycle the object.
3230 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3231 // Move the function to the end of the list, from whereever it was
3232 // previously inserted.
3233 Fn = cast<Function>(FWRef);
3234 CurModule.CurrentModule->getFunctionList().remove(Fn);
3235 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3236 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3237 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3238 // If this is the case, either we need to be a forward decl, or it needs
3240 if (!CurFun.isDeclare && !Fn->isExternal())
3241 ThrowException("Redefinition of function '" + FunctionName + "'!");
3243 // Make sure to strip off any argument names so we can't get conflicts.
3244 if (Fn->isExternal())
3245 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3249 } else { // Not already defined?
3250 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3251 CurModule.CurrentModule);
3252 InsertValue(Fn, CurModule.Values);
3255 CurFun.FunctionStart(Fn);
3256 Fn->setCallingConv(yyvsp[-7].UIntVal);
3257 Fn->setAlignment(yyvsp[0].UIntVal);
3258 if (yyvsp[-1].StrVal) {
3259 Fn->setSection(yyvsp[-1].StrVal);
3260 free(yyvsp[-1].StrVal);
3263 // Add all of the arguments we parsed to the function...
3264 if (yyvsp[-3].ArgList) { // Is null if empty...
3265 if (isVarArg) { // Nuke the last entry
3266 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
3267 "Not a varargs marker!");
3268 delete yyvsp[-3].ArgList->back().first;
3269 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
3271 Function::arg_iterator ArgIt = Fn->arg_begin();
3272 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3273 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
3274 delete I->first; // Delete the typeholder...
3276 setValueName(ArgIt, I->second); // Insert arg into symtab...
3280 delete yyvsp[-3].ArgList; // We're now done with the argument list
3285 #line 1833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3287 yyval.FunctionVal = CurFun.CurrentFunction;
3289 // Make sure that we keep track of the linkage type even if there was a
3290 // previous "declare".
3291 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3295 #line 1843 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3297 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3301 #line 1847 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3302 { CurFun.isDeclare = true; ;
3305 #line 1847 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3307 yyval.FunctionVal = CurFun.CurrentFunction;
3308 CurFun.FunctionDone();
3312 #line 1856 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3314 yyval.BoolVal = false;
3318 #line 1859 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3320 yyval.BoolVal = true;
3324 #line 1863 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3325 { // A reference to a direct constant
3326 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3330 #line 1866 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3332 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3336 #line 1869 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3337 { // Perhaps it's an FP constant?
3338 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3342 #line 1872 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3344 yyval.ValIDVal = ValID::create(ConstantBool::True);
3348 #line 1875 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3350 yyval.ValIDVal = ValID::create(ConstantBool::False);
3354 #line 1878 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3356 yyval.ValIDVal = ValID::createNull();
3360 #line 1881 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3362 yyval.ValIDVal = ValID::createUndef();
3366 #line 1884 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3367 { // A vector zero constant.
3368 yyval.ValIDVal = ValID::createZeroInit();
3372 #line 1887 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3373 { // Nonempty unsized packed vector
3374 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3375 int NumElements = yyvsp[-1].ConstVector->size();
3377 PackedType* pt = PackedType::get(ETy, NumElements);
3378 PATypeHolder* PTy = new PATypeHolder(
3386 // Verify all elements are correct type!
3387 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3388 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3389 ThrowException("Element #" + utostr(i) + " is not of type '" +
3390 ETy->getDescription() +"' as required!\nIt is of type '" +
3391 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3394 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3395 delete PTy; delete yyvsp[-1].ConstVector;
3399 #line 1911 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3401 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3405 #line 1914 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3407 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3408 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3409 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3410 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3411 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3412 free(yyvsp[-2].StrVal);
3413 free(yyvsp[0].StrVal);
3417 #line 1927 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3418 { // Is it an integer reference...?
3419 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3423 #line 1930 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3424 { // Is it a named reference...?
3425 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3429 #line 1941 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3431 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3435 #line 1945 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3437 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3441 #line 1948 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3442 { // Do not allow functions with 0 basic blocks
3443 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3447 #line 1956 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3449 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3450 InsertValue(yyvsp[0].TermInstVal);
3452 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3453 InsertValue(yyvsp[-2].BasicBlockVal);
3454 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3458 #line 1965 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3460 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3461 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3465 #line 1969 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3467 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3469 // Make sure to move the basic block to the correct location in the
3470 // function, instead of leaving it inserted wherever it was first
3472 Function::BasicBlockListType &BBL =
3473 CurFun.CurrentFunction->getBasicBlockList();
3474 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3478 #line 1979 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3480 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3482 // Make sure to move the basic block to the correct location in the
3483 // function, instead of leaving it inserted wherever it was first
3485 Function::BasicBlockListType &BBL =
3486 CurFun.CurrentFunction->getBasicBlockList();
3487 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3491 #line 1990 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3492 { // Return with a result...
3493 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3497 #line 1993 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3498 { // Return with no result...
3499 yyval.TermInstVal = new ReturnInst();
3503 #line 1996 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3504 { // Unconditional Branch...
3505 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3509 #line 1999 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3511 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3515 #line 2002 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3517 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3518 yyval.TermInstVal = S;
3520 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3521 E = yyvsp[-1].JumpTable->end();
3522 for (; I != E; ++I) {
3523 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3524 S->addCase(CI, I->second);
3526 ThrowException("Switch case is constant, but not a simple integer!");
3528 delete yyvsp[-1].JumpTable;
3532 #line 2016 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3534 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3535 yyval.TermInstVal = S;
3539 #line 2021 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3541 const PointerType *PFTy;
3542 const FunctionType *Ty;
3544 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3545 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3546 // Pull out the types of all of the arguments...
3547 std::vector<const Type*> ParamTypes;
3548 if (yyvsp[-7].ValueList) {
3549 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3551 ParamTypes.push_back((*I)->getType());
3554 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3555 if (isVarArg) ParamTypes.pop_back();
3557 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3558 PFTy = PointerType::get(Ty);
3561 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3563 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3564 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3566 // Create the call node...
3567 if (!yyvsp[-7].ValueList) { // Has no arguments?
3568 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3569 } else { // Has arguments?
3570 // Loop through FunctionType's arguments and ensure they are specified
3573 FunctionType::param_iterator I = Ty->param_begin();
3574 FunctionType::param_iterator E = Ty->param_end();
3575 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3577 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3578 if ((*ArgI)->getType() != *I)
3579 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3580 (*I)->getDescription() + "'!");
3582 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3583 ThrowException("Invalid number of parameters detected!");
3585 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3587 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3589 delete yyvsp[-10].TypeVal;
3590 delete yyvsp[-7].ValueList;
3594 #line 2073 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3596 yyval.TermInstVal = new UnwindInst();
3600 #line 2076 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3602 yyval.TermInstVal = new UnreachableInst();
3606 #line 2082 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3608 yyval.JumpTable = yyvsp[-5].JumpTable;
3609 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3611 ThrowException("May only switch on a constant pool value!");
3613 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3617 #line 2090 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3619 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3620 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3623 ThrowException("May only switch on a constant pool value!");
3625 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3629 #line 2100 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3631 // Is this definition named?? if so, assign the name...
3632 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3633 InsertValue(yyvsp[0].InstVal);
3634 yyval.InstVal = yyvsp[0].InstVal;
3638 #line 2107 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3639 { // Used for PHI nodes
3640 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3641 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3642 delete yyvsp[-5].TypeVal;
3646 #line 2112 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3648 yyval.PHIList = yyvsp[-6].PHIList;
3649 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3650 getBBVal(yyvsp[-1].ValIDVal)));
3654 #line 2119 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3655 { // Used for call statements, and memory insts...
3656 yyval.ValueList = new std::vector<Value*>();
3657 yyval.ValueList->push_back(yyvsp[0].ValueVal);
3661 #line 2123 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3663 yyval.ValueList = yyvsp[-2].ValueList;
3664 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
3668 #line 2129 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3669 { yyval.ValueList = 0; ;
3672 #line 2131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3674 yyval.BoolVal = true;
3678 #line 2134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3680 yyval.BoolVal = false;
3684 #line 2140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3686 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3687 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3689 "Arithmetic operator requires integer, FP, or packed operands!");
3690 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3691 ThrowException("Rem not supported on packed types!");
3692 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3693 if (yyval.InstVal == 0)
3694 ThrowException("binary operator returned null!");
3695 delete yyvsp[-3].TypeVal;
3699 #line 2152 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3701 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3702 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3703 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3704 ThrowException("Logical operator requires integral operands!");
3706 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3707 if (yyval.InstVal == 0)
3708 ThrowException("binary operator returned null!");
3709 delete yyvsp[-3].TypeVal;
3713 #line 2163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3715 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3717 "PackedTypes currently not supported in setcc instructions!");
3719 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3720 if (yyval.InstVal == 0)
3721 ThrowException("binary operator returned null!");
3722 delete yyvsp[-3].TypeVal;
3726 #line 2173 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3728 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3729 << " Replacing with 'xor'.\n";
3731 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3733 ThrowException("Expected integral type for not instruction!");
3735 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3736 if (yyval.InstVal == 0)
3737 ThrowException("Could not create a xor instruction!");
3741 #line 2185 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3743 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3744 ThrowException("Shift amount must be ubyte!");
3745 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3746 ThrowException("Shift constant expression requires integer operand!");
3747 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3751 #line 2192 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3753 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3754 ThrowException("cast instruction to a non-primitive type: '" +
3755 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3756 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3757 delete yyvsp[0].TypeVal;
3761 #line 2199 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3763 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3764 ThrowException("select condition must be boolean!");
3765 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3766 ThrowException("select value types should match!");
3767 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3771 #line 2206 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3774 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3775 delete yyvsp[0].TypeVal;
3779 #line 2211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3781 ObsoleteVarArgs = true;
3782 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3783 Function* NF = CurModule.CurrentModule->
3784 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3787 //foo = alloca 1 of t
3791 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3792 CurBB->getInstList().push_back(foo);
3793 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3794 CurBB->getInstList().push_back(bar);
3795 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3796 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3797 delete yyvsp[0].TypeVal;
3801 #line 2230 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3803 ObsoleteVarArgs = true;
3804 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3805 Function* NF = CurModule.CurrentModule->
3806 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3808 //b = vanext a, t ->
3809 //foo = alloca 1 of t
3812 //tmp = vaarg foo, t
3814 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3815 CurBB->getInstList().push_back(foo);
3816 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3817 CurBB->getInstList().push_back(bar);
3818 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3819 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3820 CurBB->getInstList().push_back(tmp);
3821 yyval.InstVal = new LoadInst(foo);
3822 delete yyvsp[0].TypeVal;
3826 #line 2252 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3828 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3829 ThrowException("Invalid extractelement operands!");
3830 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3834 #line 2257 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3836 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3837 ThrowException("Invalid insertelement operands!");
3838 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3842 #line 2262 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3844 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3845 ThrowException("Invalid shufflevector operands!");
3846 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3850 #line 2267 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3852 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3853 if (!Ty->isFirstClassType())
3854 ThrowException("PHI node operands must be of first class type!");
3855 yyval.InstVal = new PHINode(Ty);
3856 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3857 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3858 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3859 ThrowException("All elements of a PHI node must be of the same type!");
3860 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3861 yyvsp[0].PHIList->pop_front();
3863 delete yyvsp[0].PHIList; // Free the list...
3867 #line 2281 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3869 const PointerType *PFTy;
3870 const FunctionType *Ty;
3872 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3873 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3874 // Pull out the types of all of the arguments...
3875 std::vector<const Type*> ParamTypes;
3876 if (yyvsp[-1].ValueList) {
3877 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3879 ParamTypes.push_back((*I)->getType());
3882 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3883 if (isVarArg) ParamTypes.pop_back();
3885 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3886 ThrowException("LLVM functions cannot return aggregate types!");
3888 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3889 PFTy = PointerType::get(Ty);
3892 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3894 // Create the call node...
3895 if (!yyvsp[-1].ValueList) { // Has no arguments?
3896 // Make sure no arguments is a good thing!
3897 if (Ty->getNumParams() != 0)
3898 ThrowException("No arguments passed to a function that "
3899 "expects arguments!");
3901 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3902 } else { // Has arguments?
3903 // Loop through FunctionType's arguments and ensure they are specified
3906 FunctionType::param_iterator I = Ty->param_begin();
3907 FunctionType::param_iterator E = Ty->param_end();
3908 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3910 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3911 if ((*ArgI)->getType() != *I)
3912 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3913 (*I)->getDescription() + "'!");
3915 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3916 ThrowException("Invalid number of parameters detected!");
3918 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3920 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3921 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3922 delete yyvsp[-4].TypeVal;
3923 delete yyvsp[-1].ValueList;
3927 #line 2338 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3929 yyval.InstVal = yyvsp[0].InstVal;
3933 #line 2344 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3935 yyval.ValueList = yyvsp[0].ValueList;
3939 #line 2346 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3941 yyval.ValueList = new std::vector<Value*>();
3945 #line 2350 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3947 yyval.BoolVal = true;
3951 #line 2353 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3953 yyval.BoolVal = false;
3957 #line 2359 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3959 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3960 delete yyvsp[-1].TypeVal;
3964 #line 2363 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3966 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3967 delete yyvsp[-4].TypeVal;
3971 #line 2367 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3973 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3974 delete yyvsp[-1].TypeVal;
3978 #line 2371 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3980 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3981 delete yyvsp[-4].TypeVal;
3985 #line 2375 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3987 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3988 ThrowException("Trying to free nonpointer type " +
3989 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3990 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
3994 #line 2382 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3996 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3997 ThrowException("Can't load from nonpointer type: " +
3998 (*yyvsp[-1].TypeVal)->getDescription());
3999 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4000 ThrowException("Can't load from pointer of non-first-class type: " +
4001 (*yyvsp[-1].TypeVal)->getDescription());
4002 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
4003 delete yyvsp[-1].TypeVal;
4007 #line 2392 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4009 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4011 ThrowException("Can't store to a nonpointer type: " +
4012 (*yyvsp[-1].TypeVal)->getDescription());
4013 const Type *ElTy = PT->getElementType();
4014 if (ElTy != yyvsp[-3].ValueVal->getType())
4015 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4016 "' into space of type '" + ElTy->getDescription() + "'!");
4018 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
4019 delete yyvsp[-1].TypeVal;
4023 #line 2405 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4025 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4026 ThrowException("getelementptr insn requires pointer operand!");
4028 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4029 // indices to uint struct indices for compatibility.
4030 generic_gep_type_iterator<std::vector<Value*>::iterator>
4031 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4032 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4033 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4034 if (isa<StructType>(*GTI)) // Only change struct indices
4035 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4036 if (CUI->getType() == Type::UByteTy)
4037 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4039 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4040 ThrowException("Invalid getelementptr indices for type '" +
4041 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4042 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4043 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
4047 /* the action file gets copied in in place of this dollarsign */
4048 #line 543 "/usr/share/bison.simple"
4059 short *ssp1 = yyss - 1;
4060 fprintf (stderr, "state stack now");
4061 while (ssp1 != yyssp)
4062 fprintf (stderr, " %d", *++ssp1);
4063 fprintf (stderr, "\n");
4073 yylsp->first_line = yylloc.first_line;
4074 yylsp->first_column = yylloc.first_column;
4075 yylsp->last_line = (yylsp-1)->last_line;
4076 yylsp->last_column = (yylsp-1)->last_column;
4081 yylsp->last_line = (yylsp+yylen-1)->last_line;
4082 yylsp->last_column = (yylsp+yylen-1)->last_column;
4086 /* Now "shift" the result of the reduction.
4087 Determine what state that goes to,
4088 based on the state we popped back to
4089 and the rule number reduced by. */
4093 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4094 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4095 yystate = yytable[yystate];
4097 yystate = yydefgoto[yyn - YYNTBASE];
4101 yyerrlab: /* here on detecting error */
4104 /* If not already recovering from an error, report this error. */
4108 #ifdef YYERROR_VERBOSE
4109 yyn = yypact[yystate];
4111 if (yyn > YYFLAG && yyn < YYLAST)
4118 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4119 for (x = (yyn < 0 ? -yyn : 0);
4120 x < (sizeof(yytname) / sizeof(char *)); x++)
4121 if (yycheck[x + yyn] == x)
4122 size += strlen(yytname[x]) + 15, count++;
4123 msg = (char *) malloc(size + 15);
4126 strcpy(msg, "parse error");
4131 for (x = (yyn < 0 ? -yyn : 0);
4132 x < (sizeof(yytname) / sizeof(char *)); x++)
4133 if (yycheck[x + yyn] == x)
4135 strcat(msg, count == 0 ? ", expecting `" : " or `");
4136 strcat(msg, yytname[x]);
4145 yyerror ("parse error; also virtual memory exceeded");
4148 #endif /* YYERROR_VERBOSE */
4149 yyerror("parse error");
4153 yyerrlab1: /* here on error raised explicitly by an action */
4155 if (yyerrstatus == 3)
4157 /* if just tried and failed to reuse lookahead token after an error, discard it. */
4159 /* return failure if at end of input */
4160 if (yychar == YYEOF)
4165 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4171 /* Else will try to reuse lookahead token
4172 after shifting the error token. */
4174 yyerrstatus = 3; /* Each real token shifted decrements this */
4178 yyerrdefault: /* current state does not do anything special for the error token. */
4181 /* This is wrong; only states that explicitly want error tokens
4182 should shift them. */
4183 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4184 if (yyn) goto yydefault;
4187 yyerrpop: /* pop the current state because it cannot handle the error token */
4189 if (yyssp == yyss) YYABORT;
4199 short *ssp1 = yyss - 1;
4200 fprintf (stderr, "Error: state stack now");
4201 while (ssp1 != yyssp)
4202 fprintf (stderr, " %d", *++ssp1);
4203 fprintf (stderr, "\n");
4209 yyn = yypact[yystate];
4214 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4233 fprintf(stderr, "Shifting error token, ");
4245 /* YYACCEPT comes here. */
4257 /* YYABORT comes here. */
4268 #line 2428 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4270 int yyerror(const char *ErrorMsg) {
4272 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4273 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4274 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4275 if (yychar == YYEMPTY || yychar == 0)
4276 errMsg += "end-of-file.";
4278 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4279 ThrowException(errMsg);