2 /* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL 257
15 #define EUINT64VAL 258
27 #define STRINGCONSTANT 270
28 #define IMPLEMENTATION 271
29 #define ZEROINITIALIZER 272
50 #define EXTERN_WEAK 293
56 #define POINTERSIZE 299
65 #define SIDEEFFECT 308
68 #define CSRETCC_TOK 311
69 #define FASTCC_TOK 312
70 #define COLDCC_TOK 313
71 #define X86_STDCALLCC_TOK 314
72 #define X86_FASTCALLCC_TOK 315
73 #define DATALAYOUT 316
79 #define UNREACHABLE 322
119 #define GETELEMENTPTR 362
138 #define EXTRACTELEMENT 381
139 #define INSERTELEMENT 382
140 #define SHUFFLEVECTOR 383
145 #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
147 #include "ParserInternals.h"
148 #include "llvm/CallingConv.h"
149 #include "llvm/InlineAsm.h"
150 #include "llvm/Instructions.h"
151 #include "llvm/Module.h"
152 #include "llvm/SymbolTable.h"
153 #include "llvm/Support/GetElementPtrTypeIterator.h"
154 #include "llvm/Support/CommandLine.h"
155 #include "llvm/ADT/STLExtras.h"
156 #include "llvm/Support/MathExtras.h"
157 #include "llvm/Support/Streams.h"
165 // The following is a gross hack. In order to rid the libAsmParser library of
166 // exceptions, we have to have a way of getting the yyparse function to go into
167 // an error situation. So, whenever we want an error to occur, the GenerateError
168 // function (see bottom of file) sets TriggerError. Then, at the end of each
169 // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
170 // (a goto) to put YACC in error state. Furthermore, several calls to
171 // GenerateError are made from inside productions and they must simulate the
172 // previous exception behavior by exiting the production immediately. We have
173 // replaced these with the GEN_ERROR macro which calls GeneratError and then
174 // immediately invokes YYERROR. This would be so much cleaner if it was a
175 // recursive descent parser.
176 static bool TriggerError = false;
177 #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
178 #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
180 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
181 int yylex(); // declaration" of xxx warnings.
185 std::string CurFilename;
188 Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
189 cl::Hidden, cl::init(false));
192 using namespace llvm;
194 static Module *ParserResult;
196 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
197 // relating to upreferences in the input stream.
199 //#define DEBUG_UPREFS 1
201 #define UR_OUT(X) cerr << X
206 #define YYERROR_VERBOSE 1
208 static GlobalVariable *CurGV;
211 // This contains info used when building the body of a function. It is
212 // destroyed when the function is completed.
214 typedef std::vector<Value *> ValueList; // Numbered defs
217 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
218 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
220 static struct PerModuleInfo {
221 Module *CurrentModule;
222 std::map<const Type *, ValueList> Values; // Module level numbered definitions
223 std::map<const Type *,ValueList> LateResolveValues;
224 std::vector<PATypeHolder> Types;
225 std::map<ValID, PATypeHolder> LateResolveTypes;
227 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
228 /// how they were referenced and on which line of the input they came from so
229 /// that we can resolve them later and print error messages as appropriate.
230 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
232 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
233 // references to global values. Global values may be referenced before they
234 // are defined, and if so, the temporary object that they represent is held
235 // here. This is used for forward references of GlobalValues.
237 typedef std::map<std::pair<const PointerType *,
238 ValID>, GlobalValue*> GlobalRefsType;
239 GlobalRefsType GlobalRefs;
242 // If we could not resolve some functions at function compilation time
243 // (calls to functions before they are defined), resolve them now... Types
244 // are resolved when the constant pool has been completely parsed.
246 ResolveDefinitions(LateResolveValues);
250 // Check to make sure that all global value forward references have been
253 if (!GlobalRefs.empty()) {
254 std::string UndefinedReferences = "Unresolved global references exist:\n";
256 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
258 UndefinedReferences += " " + I->first.first->getDescription() + " " +
259 I->first.second.getName() + "\n";
261 GenerateError(UndefinedReferences);
265 Values.clear(); // Clear out function local definitions
270 // GetForwardRefForGlobal - Check to see if there is a forward reference
271 // for this global. If so, remove it from the GlobalRefs map and return it.
272 // If not, just return null.
273 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
274 // Check to see if there is a forward reference to this global variable...
275 // if there is, eliminate it and patch the reference to use the new def'n.
276 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
277 GlobalValue *Ret = 0;
278 if (I != GlobalRefs.end()) {
285 bool TypeIsUnresolved(PATypeHolder* PATy) {
286 // If it isn't abstract, its resolved
287 const Type* Ty = PATy->get();
288 if (!Ty->isAbstract())
290 // Traverse the type looking for abstract types. If it isn't abstract then
291 // we don't need to traverse that leg of the type.
292 std::vector<const Type*> WorkList, SeenList;
293 WorkList.push_back(Ty);
294 while (!WorkList.empty()) {
295 const Type* Ty = WorkList.back();
296 SeenList.push_back(Ty);
298 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
299 // Check to see if this is an unresolved type
300 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
301 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
302 for ( ; I != E; ++I) {
303 if (I->second.get() == OpTy)
306 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
307 const Type* TheTy = SeqTy->getElementType();
308 if (TheTy->isAbstract() && TheTy != Ty) {
309 std::vector<const Type*>::iterator I = SeenList.begin(),
315 WorkList.push_back(TheTy);
317 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
318 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
319 const Type* TheTy = StrTy->getElementType(i);
320 if (TheTy->isAbstract() && TheTy != Ty) {
321 std::vector<const Type*>::iterator I = SeenList.begin(),
327 WorkList.push_back(TheTy);
338 static struct PerFunctionInfo {
339 Function *CurrentFunction; // Pointer to current function being created
341 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
342 std::map<const Type*, ValueList> LateResolveValues;
343 bool isDeclare; // Is this function a forward declararation?
344 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
345 GlobalValue::VisibilityTypes Visibility;
347 /// BBForwardRefs - When we see forward references to basic blocks, keep
348 /// track of them here.
349 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
350 std::vector<BasicBlock*> NumberedBlocks;
353 inline PerFunctionInfo() {
356 Linkage = GlobalValue::ExternalLinkage;
357 Visibility = GlobalValue::DefaultVisibility;
360 inline void FunctionStart(Function *M) {
365 void FunctionDone() {
366 NumberedBlocks.clear();
368 // Any forward referenced blocks left?
369 if (!BBForwardRefs.empty()) {
370 GenerateError("Undefined reference to label " +
371 BBForwardRefs.begin()->first->getName());
375 // Resolve all forward references now.
376 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
378 Values.clear(); // Clear out function local definitions
381 Linkage = GlobalValue::ExternalLinkage;
382 Visibility = GlobalValue::DefaultVisibility;
384 } CurFun; // Info for the current function...
386 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
389 //===----------------------------------------------------------------------===//
390 // Code to handle definitions of all the types
391 //===----------------------------------------------------------------------===//
393 static int InsertValue(Value *V,
394 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
395 if (V->hasName()) return -1; // Is this a numbered definition?
397 // Yes, insert the value into the value table...
398 ValueList &List = ValueTab[V->getType()];
400 return List.size()-1;
403 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
405 case ValID::NumberVal: // Is it a numbered definition?
406 // Module constants occupy the lowest numbered slots...
407 if ((unsigned)D.Num < CurModule.Types.size())
408 return CurModule.Types[(unsigned)D.Num];
410 case ValID::NameVal: // Is it a named definition?
411 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
412 D.destroy(); // Free old strdup'd memory...
417 GenerateError("Internal parser error: Invalid symbol type reference!");
421 // If we reached here, we referenced either a symbol that we don't know about
422 // or an id number that hasn't been read yet. We may be referencing something
423 // forward, so just create an entry to be resolved later and get to it...
425 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
428 if (inFunctionScope()) {
429 if (D.Type == ValID::NameVal) {
430 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
433 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
438 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
439 if (I != CurModule.LateResolveTypes.end())
442 Type *Typ = OpaqueType::get();
443 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
447 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
448 SymbolTable &SymTab =
449 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
450 CurModule.CurrentModule->getValueSymbolTable();
451 return SymTab.lookup(Ty, Name);
454 // getValNonImprovising - Look up the value specified by the provided type and
455 // the provided ValID. If the value exists and has already been defined, return
456 // it. Otherwise return null.
458 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
459 if (isa<FunctionType>(Ty)) {
460 GenerateError("Functions are not values and "
461 "must be referenced as pointers");
466 case ValID::NumberVal: { // Is it a numbered definition?
467 unsigned Num = (unsigned)D.Num;
469 // Module constants occupy the lowest numbered slots...
470 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
471 if (VI != CurModule.Values.end()) {
472 if (Num < VI->second.size())
473 return VI->second[Num];
474 Num -= VI->second.size();
477 // Make sure that our type is within bounds
478 VI = CurFun.Values.find(Ty);
479 if (VI == CurFun.Values.end()) return 0;
481 // Check that the number is within bounds...
482 if (VI->second.size() <= Num) return 0;
484 return VI->second[Num];
487 case ValID::NameVal: { // Is it a named definition?
488 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
489 if (N == 0) return 0;
491 D.destroy(); // Free old strdup'd memory...
495 // Check to make sure that "Ty" is an integral type, and that our
496 // value will fit into the specified type...
497 case ValID::ConstSIntVal: // Is it a constant pool reference??
498 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
499 GenerateError("Signed integral constant '" +
500 itostr(D.ConstPool64) + "' is invalid for type '" +
501 Ty->getDescription() + "'!");
504 return ConstantInt::get(Ty, D.ConstPool64);
506 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
507 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
508 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
509 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
510 "' is invalid or out of range!");
512 } else { // This is really a signed reference. Transmogrify.
513 return ConstantInt::get(Ty, D.ConstPool64);
516 return ConstantInt::get(Ty, D.UConstPool64);
519 case ValID::ConstFPVal: // Is it a floating point const pool reference?
520 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
521 GenerateError("FP constant invalid for type!!");
524 return ConstantFP::get(Ty, D.ConstPoolFP);
526 case ValID::ConstNullVal: // Is it a null value?
527 if (!isa<PointerType>(Ty)) {
528 GenerateError("Cannot create a a non pointer null!");
531 return ConstantPointerNull::get(cast<PointerType>(Ty));
533 case ValID::ConstUndefVal: // Is it an undef value?
534 return UndefValue::get(Ty);
536 case ValID::ConstZeroVal: // Is it a zero value?
537 return Constant::getNullValue(Ty);
539 case ValID::ConstantVal: // Fully resolved constant?
540 if (D.ConstantValue->getType() != Ty) {
541 GenerateError("Constant expression type different from required type!");
544 return D.ConstantValue;
546 case ValID::InlineAsmVal: { // Inline asm expression
547 const PointerType *PTy = dyn_cast<PointerType>(Ty);
548 const FunctionType *FTy =
549 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
550 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
551 GenerateError("Invalid type for asm constraint string!");
554 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
555 D.IAD->HasSideEffects);
556 D.destroy(); // Free InlineAsmDescriptor.
560 assert(0 && "Unhandled case!");
564 assert(0 && "Unhandled case!");
568 // getVal - This function is identical to getValNonImprovising, except that if a
569 // value is not already defined, it "improvises" by creating a placeholder var
570 // that looks and acts just like the requested variable. When the value is
571 // defined later, all uses of the placeholder variable are replaced with the
574 static Value *getVal(const Type *Ty, const ValID &ID) {
575 if (Ty == Type::LabelTy) {
576 GenerateError("Cannot use a basic block here");
580 // See if the value has already been defined.
581 Value *V = getValNonImprovising(Ty, ID);
583 if (TriggerError) return 0;
585 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
586 GenerateError("Invalid use of a composite type!");
590 // If we reached here, we referenced either a symbol that we don't know about
591 // or an id number that hasn't been read yet. We may be referencing something
592 // forward, so just create an entry to be resolved later and get to it...
594 V = new Argument(Ty);
596 // Remember where this forward reference came from. FIXME, shouldn't we try
597 // to recycle these things??
598 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
601 if (inFunctionScope())
602 InsertValue(V, CurFun.LateResolveValues);
604 InsertValue(V, CurModule.LateResolveValues);
608 /// getBBVal - This is used for two purposes:
609 /// * If isDefinition is true, a new basic block with the specified ID is being
611 /// * If isDefinition is true, this is a reference to a basic block, which may
612 /// or may not be a forward reference.
614 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
615 assert(inFunctionScope() && "Can't get basic block at global scope!");
621 GenerateError("Illegal label reference " + ID.getName());
623 case ValID::NumberVal: // Is it a numbered definition?
624 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
625 CurFun.NumberedBlocks.resize(ID.Num+1);
626 BB = CurFun.NumberedBlocks[ID.Num];
628 case ValID::NameVal: // Is it a named definition?
630 if (Value *N = CurFun.CurrentFunction->
631 getValueSymbolTable().lookup(Type::LabelTy, Name))
632 BB = cast<BasicBlock>(N);
636 // See if the block has already been defined.
638 // If this is the definition of the block, make sure the existing value was
639 // just a forward reference. If it was a forward reference, there will be
640 // an entry for it in the PlaceHolderInfo map.
641 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
642 // The existing value was a definition, not a forward reference.
643 GenerateError("Redefinition of label " + ID.getName());
647 ID.destroy(); // Free strdup'd memory.
651 // Otherwise this block has not been seen before.
652 BB = new BasicBlock("", CurFun.CurrentFunction);
653 if (ID.Type == ValID::NameVal) {
654 BB->setName(ID.Name);
656 CurFun.NumberedBlocks[ID.Num] = BB;
659 // If this is not a definition, keep track of it so we can use it as a forward
662 // Remember where this forward reference came from.
663 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
665 // The forward declaration could have been inserted anywhere in the
666 // function: insert it into the correct place now.
667 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
668 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
675 //===----------------------------------------------------------------------===//
676 // Code to handle forward references in instructions
677 //===----------------------------------------------------------------------===//
679 // This code handles the late binding needed with statements that reference
680 // values not defined yet... for example, a forward branch, or the PHI node for
683 // This keeps a table (CurFun.LateResolveValues) of all such forward references
684 // and back patchs after we are done.
687 // ResolveDefinitions - If we could not resolve some defs at parsing
688 // time (forward branches, phi functions for loops, etc...) resolve the
692 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
693 std::map<const Type*,ValueList> *FutureLateResolvers) {
694 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
695 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
696 E = LateResolvers.end(); LRI != E; ++LRI) {
697 ValueList &List = LRI->second;
698 while (!List.empty()) {
699 Value *V = List.back();
702 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
703 CurModule.PlaceHolderInfo.find(V);
704 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
706 ValID &DID = PHI->second.first;
708 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
712 V->replaceAllUsesWith(TheRealValue);
714 CurModule.PlaceHolderInfo.erase(PHI);
715 } else if (FutureLateResolvers) {
716 // Functions have their unresolved items forwarded to the module late
718 InsertValue(V, *FutureLateResolvers);
720 if (DID.Type == ValID::NameVal) {
721 GenerateError("Reference to an invalid definition: '" +DID.getName()+
722 "' of type '" + V->getType()->getDescription() + "'",
726 GenerateError("Reference to an invalid definition: #" +
727 itostr(DID.Num) + " of type '" +
728 V->getType()->getDescription() + "'",
736 LateResolvers.clear();
739 // ResolveTypeTo - A brand new type was just declared. This means that (if
740 // name is not null) things referencing Name can be resolved. Otherwise, things
741 // refering to the number can be resolved. Do this now.
743 static void ResolveTypeTo(char *Name, const Type *ToTy) {
745 if (Name) D = ValID::create(Name);
746 else D = ValID::create((int)CurModule.Types.size());
748 std::map<ValID, PATypeHolder>::iterator I =
749 CurModule.LateResolveTypes.find(D);
750 if (I != CurModule.LateResolveTypes.end()) {
751 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
752 CurModule.LateResolveTypes.erase(I);
756 // setValueName - Set the specified value to the name given. The name may be
757 // null potentially, in which case this is a noop. The string passed in is
758 // assumed to be a malloc'd string buffer, and is free'd by this function.
760 static void setValueName(Value *V, char *NameStr) {
762 std::string Name(NameStr); // Copy string
763 free(NameStr); // Free old string
765 if (V->getType() == Type::VoidTy) {
766 GenerateError("Can't assign name '" + Name+"' to value with void type!");
770 assert(inFunctionScope() && "Must be in function scope!");
771 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
772 if (ST.lookup(V->getType(), Name)) {
773 GenerateError("Redefinition of value '" + Name + "' of type '" +
774 V->getType()->getDescription() + "'!");
783 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
784 /// this is a declaration, otherwise it is a definition.
785 static GlobalVariable *
786 ParseGlobalVariable(char *NameStr,
787 GlobalValue::LinkageTypes Linkage,
788 GlobalValue::VisibilityTypes Visibility,
789 bool isConstantGlobal, const Type *Ty,
790 Constant *Initializer) {
791 if (isa<FunctionType>(Ty)) {
792 GenerateError("Cannot declare global vars of function type!");
796 const PointerType *PTy = PointerType::get(Ty);
800 Name = NameStr; // Copy string
801 free(NameStr); // Free old string
804 // See if this global value was forward referenced. If so, recycle the
808 ID = ValID::create((char*)Name.c_str());
810 ID = ValID::create((int)CurModule.Values[PTy].size());
813 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
814 // Move the global to the end of the list, from whereever it was
815 // previously inserted.
816 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
817 CurModule.CurrentModule->getGlobalList().remove(GV);
818 CurModule.CurrentModule->getGlobalList().push_back(GV);
819 GV->setInitializer(Initializer);
820 GV->setLinkage(Linkage);
821 GV->setVisibility(Visibility);
822 GV->setConstant(isConstantGlobal);
823 InsertValue(GV, CurModule.Values);
827 // If this global has a name, check to see if there is already a definition
828 // of this global in the module. If so, it is an error.
830 // We are a simple redefinition of a value, check to see if it is defined
831 // the same as the old one.
832 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
833 GenerateError("Redefinition of global variable named '" + Name +
834 "' of type '" + Ty->getDescription() + "'!");
839 // Otherwise there is no existing GV to use, create one now.
841 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
842 CurModule.CurrentModule);
843 GV->setVisibility(Visibility);
844 InsertValue(GV, CurModule.Values);
848 // setTypeName - Set the specified type to the name given. The name may be
849 // null potentially, in which case this is a noop. The string passed in is
850 // assumed to be a malloc'd string buffer, and is freed by this function.
852 // This function returns true if the type has already been defined, but is
853 // allowed to be redefined in the specified context. If the name is a new name
854 // for the type plane, it is inserted and false is returned.
855 static bool setTypeName(const Type *T, char *NameStr) {
856 assert(!inFunctionScope() && "Can't give types function-local names!");
857 if (NameStr == 0) return false;
859 std::string Name(NameStr); // Copy string
860 free(NameStr); // Free old string
862 // We don't allow assigning names to void type
863 if (T == Type::VoidTy) {
864 GenerateError("Can't assign name '" + Name + "' to the void type!");
868 // Set the type name, checking for conflicts as we do so.
869 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
871 if (AlreadyExists) { // Inserting a name that is already defined???
872 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
873 assert(Existing && "Conflict but no matching type?");
875 // There is only one case where this is allowed: when we are refining an
876 // opaque type. In this case, Existing will be an opaque type.
877 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
878 // We ARE replacing an opaque type!
879 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
883 // Otherwise, this is an attempt to redefine a type. That's okay if
884 // the redefinition is identical to the original. This will be so if
885 // Existing and T point to the same Type object. In this one case we
886 // allow the equivalent redefinition.
887 if (Existing == T) return true; // Yes, it's equal.
889 // Any other kind of (non-equivalent) redefinition is an error.
890 GenerateError("Redefinition of type named '" + Name + "' of type '" +
891 T->getDescription() + "'!");
897 //===----------------------------------------------------------------------===//
898 // Code for handling upreferences in type names...
901 // TypeContains - Returns true if Ty directly contains E in it.
903 static bool TypeContains(const Type *Ty, const Type *E) {
904 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
905 E) != Ty->subtype_end();
910 // NestingLevel - The number of nesting levels that need to be popped before
911 // this type is resolved.
912 unsigned NestingLevel;
914 // LastContainedTy - This is the type at the current binding level for the
915 // type. Every time we reduce the nesting level, this gets updated.
916 const Type *LastContainedTy;
918 // UpRefTy - This is the actual opaque type that the upreference is
922 UpRefRecord(unsigned NL, OpaqueType *URTy)
923 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
927 // UpRefs - A list of the outstanding upreferences that need to be resolved.
928 static std::vector<UpRefRecord> UpRefs;
930 /// HandleUpRefs - Every time we finish a new layer of types, this function is
931 /// called. It loops through the UpRefs vector, which is a list of the
932 /// currently active types. For each type, if the up reference is contained in
933 /// the newly completed type, we decrement the level count. When the level
934 /// count reaches zero, the upreferenced type is the type that is passed in:
935 /// thus we can complete the cycle.
937 static PATypeHolder HandleUpRefs(const Type *ty) {
938 // If Ty isn't abstract, or if there are no up-references in it, then there is
939 // nothing to resolve here.
940 if (!ty->isAbstract() || UpRefs.empty()) return ty;
943 UR_OUT("Type '" << Ty->getDescription() <<
944 "' newly formed. Resolving upreferences.\n" <<
945 UpRefs.size() << " upreferences active!\n");
947 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
948 // to zero), we resolve them all together before we resolve them to Ty. At
949 // the end of the loop, if there is anything to resolve to Ty, it will be in
951 OpaqueType *TypeToResolve = 0;
953 for (unsigned i = 0; i != UpRefs.size(); ++i) {
954 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
955 << UpRefs[i].second->getDescription() << ") = "
956 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
957 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
958 // Decrement level of upreference
959 unsigned Level = --UpRefs[i].NestingLevel;
960 UpRefs[i].LastContainedTy = Ty;
961 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
962 if (Level == 0) { // Upreference should be resolved!
963 if (!TypeToResolve) {
964 TypeToResolve = UpRefs[i].UpRefTy;
966 UR_OUT(" * Resolving upreference for "
967 << UpRefs[i].second->getDescription() << "\n";
968 std::string OldName = UpRefs[i].UpRefTy->getDescription());
969 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
970 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
971 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
973 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
974 --i; // Do not skip the next element...
980 UR_OUT(" * Resolving upreference for "
981 << UpRefs[i].second->getDescription() << "\n";
982 std::string OldName = TypeToResolve->getDescription());
983 TypeToResolve->refineAbstractTypeTo(Ty);
989 //===----------------------------------------------------------------------===//
990 // RunVMAsmParser - Define an interface to this parser
991 //===----------------------------------------------------------------------===//
993 static Module* RunParser(Module * M);
995 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
998 CurFilename = Filename;
999 return RunParser(new Module(CurFilename));
1002 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1003 set_scan_string(AsmString);
1005 CurFilename = "from_memory";
1007 return RunParser(new Module (CurFilename));
1009 return RunParser(M);
1014 #line 883 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1016 llvm::Module *ModuleVal;
1017 llvm::Function *FunctionVal;
1018 llvm::BasicBlock *BasicBlockVal;
1019 llvm::TerminatorInst *TermInstVal;
1020 llvm::Instruction *InstVal;
1021 llvm::Constant *ConstVal;
1023 const llvm::Type *PrimType;
1024 std::list<llvm::PATypeHolder> *TypeList;
1025 llvm::PATypeHolder *TypeVal;
1026 llvm::Value *ValueVal;
1027 std::vector<llvm::Value*> *ValueList;
1028 llvm::ArgListType *ArgList;
1029 llvm::TypeWithAttrs TypeWithAttrs;
1030 llvm::TypeWithAttrsList *TypeWithAttrsList;
1031 llvm::ValueRefList *ValueRefList;
1033 // Represent the RHS of PHI node
1034 std::list<std::pair<llvm::Value*,
1035 llvm::BasicBlock*> > *PHIList;
1036 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1037 std::vector<llvm::Constant*> *ConstVector;
1039 llvm::GlobalValue::LinkageTypes Linkage;
1040 llvm::GlobalValue::VisibilityTypes Visibility;
1041 llvm::FunctionType::ParameterAttributes ParamAttrs;
1049 char *StrVal; // This memory is strdup'd!
1050 llvm::ValID ValIDVal; // strdup'd memory maybe!
1052 llvm::Instruction::BinaryOps BinaryOpVal;
1053 llvm::Instruction::TermOps TermOpVal;
1054 llvm::Instruction::MemoryOps MemOpVal;
1055 llvm::Instruction::CastOps CastOpVal;
1056 llvm::Instruction::OtherOps OtherOpVal;
1057 llvm::Module::Endianness Endianness;
1058 llvm::ICmpInst::Predicate IPredicate;
1059 llvm::FCmpInst::Predicate FPredicate;
1072 #define YYFLAG -32768
1073 #define YYNTBASE 147
1075 #define YYTRANSLATE(x) ((unsigned)(x) <= 386 ? yytranslate[x] : 225)
1077 static const short yytranslate[] = { 0,
1078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1079 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1080 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1081 2, 2, 2, 2, 2, 2, 2, 2, 2, 137,
1082 138, 135, 2, 134, 2, 2, 2, 2, 2, 2,
1083 2, 2, 2, 2, 2, 2, 2, 2, 2, 142,
1084 133, 143, 2, 2, 2, 2, 2, 2, 2, 2,
1085 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1086 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1087 139, 136, 141, 2, 2, 2, 2, 2, 146, 2,
1088 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1089 2, 2, 2, 2, 2, 2, 2, 2, 2, 140,
1090 2, 2, 144, 2, 145, 2, 2, 2, 2, 2,
1091 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1092 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1093 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1094 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1095 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1096 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1097 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1098 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1099 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1103 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1104 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1105 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1106 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1107 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1108 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1109 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1110 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1111 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1112 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1113 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1114 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1115 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1116 127, 128, 129, 130, 131, 132
1120 static const short yyprhs[] = { 0,
1121 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1122 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1123 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1124 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1125 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1126 100, 102, 104, 106, 108, 110, 112, 114, 116, 119,
1127 120, 122, 124, 126, 128, 130, 132, 134, 136, 137,
1128 139, 140, 142, 144, 145, 147, 149, 151, 153, 154,
1129 156, 158, 160, 162, 164, 166, 169, 171, 173, 174,
1130 177, 179, 181, 182, 185, 186, 189, 190, 194, 197,
1131 198, 200, 201, 205, 207, 210, 212, 214, 216, 218,
1132 220, 222, 225, 227, 230, 236, 242, 248, 254, 258,
1133 261, 267, 272, 275, 277, 279, 281, 285, 287, 291,
1134 293, 294, 296, 300, 305, 309, 313, 318, 323, 327,
1135 334, 340, 343, 346, 349, 352, 355, 358, 361, 364,
1136 367, 370, 377, 383, 392, 399, 406, 414, 422, 429,
1137 436, 445, 454, 458, 460, 462, 464, 466, 467, 469,
1138 472, 473, 477, 478, 482, 486, 488, 492, 496, 497,
1139 504, 505, 513, 514, 522, 525, 529, 531, 533, 535,
1140 539, 543, 547, 551, 555, 559, 561, 562, 564, 566,
1141 568, 569, 575, 579, 581, 585, 587, 588, 598, 600,
1142 602, 607, 609, 611, 614, 618, 619, 621, 623, 625,
1143 627, 629, 631, 633, 635, 637, 641, 643, 649, 651,
1144 653, 655, 657, 660, 663, 666, 670, 673, 674, 676,
1145 679, 682, 686, 696, 706, 715, 730, 732, 734, 741,
1146 747, 750, 757, 765, 769, 775, 776, 777, 781, 784,
1147 786, 792, 798, 805, 812, 817, 822, 829, 834, 839,
1148 846, 853, 856, 865, 867, 869, 870, 874, 881, 885,
1152 static const short yyrhs[] = { 5,
1153 0, 6, 0, 69, 0, 70, 0, 71, 0, 72,
1154 0, 73, 0, 74, 0, 75, 0, 76, 0, 77,
1155 0, 78, 0, 79, 0, 80, 0, 109, 0, 110,
1156 0, 111, 0, 112, 0, 113, 0, 114, 0, 115,
1157 0, 116, 0, 117, 0, 118, 0, 119, 0, 120,
1158 0, 123, 0, 124, 0, 125, 0, 83, 0, 84,
1159 0, 85, 0, 86, 0, 87, 0, 88, 0, 89,
1160 0, 90, 0, 91, 0, 92, 0, 93, 0, 94,
1161 0, 95, 0, 96, 0, 97, 0, 98, 0, 99,
1162 0, 100, 0, 101, 0, 102, 0, 89, 0, 90,
1163 0, 91, 0, 92, 0, 19, 0, 20, 0, 9,
1164 0, 10, 0, 11, 0, 197, 133, 0, 0, 33,
1165 0, 35, 0, 34, 0, 36, 0, 38, 0, 37,
1166 0, 39, 0, 41, 0, 0, 132, 0, 0, 37,
1167 0, 39, 0, 0, 33, 0, 34, 0, 35, 0,
1168 38, 0, 0, 56, 0, 57, 0, 58, 0, 59,
1169 0, 60, 0, 61, 0, 55, 4, 0, 110, 0,
1170 111, 0, 0, 164, 163, 0, 130, 0, 163, 0,
1171 0, 166, 165, 0, 0, 48, 4, 0, 0, 134,
1172 48, 4, 0, 27, 16, 0, 0, 169, 0, 0,
1173 134, 172, 171, 0, 169, 0, 48, 4, 0, 9,
1174 0, 10, 0, 11, 0, 12, 0, 40, 0, 173,
1175 0, 174, 135, 0, 209, 0, 136, 4, 0, 174,
1176 137, 178, 138, 166, 0, 8, 137, 178, 138, 166,
1177 0, 139, 4, 140, 174, 141, 0, 142, 4, 140,
1178 174, 143, 0, 144, 179, 145, 0, 144, 145, 0,
1179 142, 144, 179, 145, 143, 0, 142, 144, 145, 143,
1180 0, 174, 164, 0, 174, 0, 8, 0, 175, 0,
1181 177, 134, 175, 0, 177, 0, 177, 134, 30, 0,
1182 30, 0, 0, 174, 0, 179, 134, 174, 0, 174,
1183 139, 182, 141, 0, 174, 139, 141, 0, 174, 146,
1184 16, 0, 174, 142, 182, 143, 0, 174, 144, 182,
1185 145, 0, 174, 144, 145, 0, 174, 142, 144, 182,
1186 145, 143, 0, 174, 142, 144, 145, 143, 0, 174,
1187 31, 0, 174, 32, 0, 174, 209, 0, 174, 181,
1188 0, 174, 18, 0, 154, 3, 0, 154, 4, 0,
1189 9, 19, 0, 9, 20, 0, 155, 7, 0, 150,
1190 137, 180, 29, 174, 138, 0, 108, 137, 180, 220,
1191 138, 0, 122, 137, 180, 134, 180, 134, 180, 138,
1192 0, 148, 137, 180, 134, 180, 138, 0, 149, 137,
1193 180, 134, 180, 138, 0, 81, 152, 137, 180, 134,
1194 180, 138, 0, 82, 153, 137, 180, 134, 180, 138,
1195 0, 151, 137, 180, 134, 180, 138, 0, 127, 137,
1196 180, 134, 180, 138, 0, 128, 137, 180, 134, 180,
1197 134, 180, 138, 0, 129, 137, 180, 134, 180, 134,
1198 180, 138, 0, 182, 134, 180, 0, 180, 0, 25,
1199 0, 26, 0, 185, 0, 0, 186, 0, 185, 186,
1200 0, 0, 24, 187, 205, 0, 0, 23, 188, 206,
1201 0, 53, 52, 192, 0, 17, 0, 156, 13, 174,
1202 0, 156, 13, 8, 0, 0, 156, 159, 183, 180,
1203 189, 171, 0, 0, 156, 157, 159, 183, 180, 190,
1204 171, 0, 0, 156, 158, 159, 183, 174, 191, 171,
1205 0, 42, 194, 0, 49, 133, 195, 0, 16, 0,
1206 47, 0, 46, 0, 44, 133, 193, 0, 45, 133,
1207 4, 0, 43, 133, 16, 0, 62, 133, 16, 0,
1208 139, 196, 141, 0, 196, 134, 16, 0, 16, 0,
1209 0, 14, 0, 16, 0, 197, 0, 0, 199, 134,
1210 174, 164, 198, 0, 174, 164, 198, 0, 199, 0,
1211 199, 134, 30, 0, 30, 0, 0, 162, 176, 197,
1212 137, 200, 138, 166, 170, 167, 0, 21, 0, 144,
1213 0, 161, 159, 201, 202, 0, 22, 0, 145, 0,
1214 212, 204, 0, 160, 159, 201, 0, 0, 54, 0,
1215 3, 0, 4, 0, 7, 0, 19, 0, 20, 0,
1216 31, 0, 32, 0, 18, 0, 142, 182, 143, 0,
1217 181, 0, 52, 207, 16, 134, 16, 0, 147, 0,
1218 197, 0, 209, 0, 208, 0, 174, 210, 0, 212,
1219 213, 0, 203, 213, 0, 214, 156, 215, 0, 214,
1220 217, 0, 0, 15, 0, 63, 211, 0, 63, 8,
1221 0, 64, 12, 210, 0, 64, 9, 210, 134, 12,
1222 210, 134, 12, 210, 0, 65, 154, 210, 134, 12,
1223 210, 139, 216, 141, 0, 65, 154, 210, 134, 12,
1224 210, 139, 141, 0, 66, 162, 176, 210, 137, 219,
1225 138, 166, 29, 12, 210, 67, 12, 210, 0, 67,
1226 0, 68, 0, 216, 154, 208, 134, 12, 210, 0,
1227 154, 208, 134, 12, 210, 0, 156, 222, 0, 174,
1228 139, 210, 134, 210, 141, 0, 218, 134, 139, 210,
1229 134, 210, 141, 0, 174, 210, 164, 0, 219, 134,
1230 174, 210, 164, 0, 0, 0, 220, 134, 211, 0,
1231 51, 50, 0, 50, 0, 148, 174, 210, 134, 210,
1232 0, 149, 174, 210, 134, 210, 0, 81, 152, 174,
1233 210, 134, 210, 0, 82, 153, 174, 210, 134, 210,
1234 0, 151, 211, 134, 211, 0, 150, 211, 29, 174,
1235 0, 122, 211, 134, 211, 134, 211, 0, 126, 211,
1236 134, 174, 0, 127, 211, 134, 211, 0, 128, 211,
1237 134, 211, 134, 211, 0, 129, 211, 134, 211, 134,
1238 211, 0, 121, 218, 0, 221, 162, 176, 210, 137,
1239 219, 138, 166, 0, 224, 0, 28, 0, 0, 103,
1240 174, 168, 0, 103, 174, 134, 9, 210, 168, 0,
1241 104, 174, 168, 0, 104, 174, 134, 9, 210, 168,
1242 0, 105, 211, 0, 223, 106, 174, 210, 0, 223,
1243 107, 211, 134, 174, 210, 0, 108, 174, 210, 220,
1250 static const short yyrline[] = { 0,
1251 1031, 1032, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042,
1252 1042, 1043, 1043, 1043, 1044, 1044, 1044, 1044, 1044, 1044,
1253 1044, 1045, 1045, 1045, 1045, 1045, 1046, 1046, 1046, 1048,
1254 1048, 1049, 1049, 1050, 1050, 1051, 1051, 1052, 1052, 1056,
1255 1056, 1057, 1057, 1058, 1058, 1059, 1059, 1060, 1060, 1061,
1256 1061, 1062, 1062, 1063, 1064, 1069, 1070, 1070, 1073, 1077,
1257 1083, 1084, 1085, 1086, 1087, 1091, 1092, 1093, 1097, 1098,
1258 1102, 1103, 1104, 1108, 1109, 1110, 1111, 1112, 1115, 1115,
1259 1116, 1117, 1118, 1119, 1120, 1121, 1129, 1130, 1133, 1134,
1260 1139, 1140, 1143, 1144, 1151, 1151, 1158, 1158, 1167, 1175,
1261 1175, 1181, 1181, 1183, 1188, 1201, 1201, 1201, 1201, 1204,
1262 1208, 1212, 1219, 1224, 1232, 1250, 1268, 1273, 1285, 1295,
1263 1299, 1309, 1316, 1323, 1330, 1335, 1340, 1347, 1348, 1355,
1264 1362, 1370, 1375, 1386, 1414, 1430, 1459, 1487, 1512, 1531,
1265 1556, 1575, 1587, 1594, 1657, 1667, 1677, 1683, 1689, 1694,
1266 1699, 1707, 1721, 1742, 1750, 1756, 1767, 1772, 1777, 1786,
1267 1792, 1798, 1807, 1811, 1819, 1819, 1830, 1835, 1843, 1844,
1268 1848, 1848, 1852, 1852, 1855, 1858, 1870, 1894, 1905, 1911,
1269 1914, 1919, 1922, 1928, 1932, 1935, 1941, 1954, 1955, 1957,
1270 1961, 1970, 1974, 1979, 1981, 1986, 1991, 2000, 2000, 2001,
1271 2001, 2003, 2013, 2024, 2028, 2037, 2046, 2051, 2157, 2157,
1272 2159, 2168, 2168, 2170, 2175, 2187, 2191, 2196, 2200, 2204,
1273 2208, 2212, 2216, 2220, 2224, 2228, 2253, 2257, 2271, 2275,
1274 2281, 2281, 2287, 2296, 2300, 2309, 2320, 2329, 2341, 2354,
1275 2358, 2362, 2367, 2377, 2396, 2405, 2472, 2476, 2483, 2494,
1276 2507, 2516, 2527, 2537, 2545, 2553, 2556, 2557, 2564, 2568,
1277 2573, 2594, 2611, 2624, 2637, 2646, 2659, 2667, 2674, 2680,
1278 2686, 2692, 2707, 2770, 2775, 2779, 2786, 2793, 2801, 2808,
1279 2816, 2824, 2838, 2855
1284 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1286 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1287 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","INTTYPE","FLOAT","DOUBLE","LABEL",
1288 "TYPE","VAR_ID","LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER",
1289 "TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT",
1290 "SECTION","VOLATILE","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE",
1291 "WEAK","APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL",
1292 "TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL",
1293 "TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK",
1294 "COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR",
1295 "SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV",
1296 "UREM","SREM","FREM","AND","OR","XOR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE",
1297 "SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO",
1298 "UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1299 "ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1300 "INTTOPTR","PTRTOINT","PHI_TOK","SELECT","SHL","LSHR","ASHR","VAARG","EXTRACTELEMENT",
1301 "INSERTELEMENT","SHUFFLEVECTOR","NORETURN","DEFAULT","HIDDEN","'='","','","'*'",
1302 "'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","INTVAL",
1303 "ArithmeticOps","LogicalOps","CastOps","ShiftOps","IPredicates","FPredicates",
1304 "IntType","FPType","OptAssign","GVInternalLinkage","GVExternalLinkage","GVVisibilityStyle",
1305 "FunctionDeclareLinkage","FunctionDefineLinkage","OptCallingConv","ParamAttr",
1306 "OptParamAttrs","FuncAttr","OptFuncAttrs","OptAlign","OptCAlign","SectionString",
1307 "OptSection","GlobalVarAttributes","GlobalVarAttribute","PrimType","Types","ArgType",
1308 "ResultTypes","ArgTypeList","ArgTypeListI","TypeListI","ConstVal","ConstExpr",
1309 "ConstVector","GlobalType","Module","DefinitionList","Definition","@1","@2",
1310 "@3","@4","@5","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
1311 "LibList","Name","OptName","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader",
1312 "END","Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef",
1313 "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1314 "JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal",
1315 "OptVolatile","MemoryInst", NULL
1319 static const short yyr1[] = { 0,
1320 147, 147, 148, 148, 148, 148, 148, 148, 148, 148,
1321 148, 149, 149, 149, 150, 150, 150, 150, 150, 150,
1322 150, 150, 150, 150, 150, 150, 151, 151, 151, 152,
1323 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
1324 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1325 153, 153, 153, 153, 153, 154, 155, 155, 156, 156,
1326 157, 157, 157, 157, 157, 158, 158, 158, 159, 159,
1327 160, 160, 160, 161, 161, 161, 161, 161, 162, 162,
1328 162, 162, 162, 162, 162, 162, 163, 163, 164, 164,
1329 165, 165, 166, 166, 167, 167, 168, 168, 169, 170,
1330 170, 171, 171, 172, 172, 173, 173, 173, 173, 174,
1331 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
1332 174, 174, 175, 176, 176, 177, 177, 178, 178, 178,
1333 178, 179, 179, 180, 180, 180, 180, 180, 180, 180,
1334 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
1335 180, 181, 181, 181, 181, 181, 181, 181, 181, 181,
1336 181, 181, 182, 182, 183, 183, 184, 184, 185, 185,
1337 187, 186, 188, 186, 186, 186, 186, 186, 189, 186,
1338 190, 186, 191, 186, 186, 186, 192, 193, 193, 194,
1339 194, 194, 194, 195, 196, 196, 196, 197, 197, 198,
1340 198, 199, 199, 200, 200, 200, 200, 201, 202, 202,
1341 203, 204, 204, 205, 206, 207, 207, 208, 208, 208,
1342 208, 208, 208, 208, 208, 208, 208, 208, 209, 209,
1343 210, 210, 211, 212, 212, 213, 214, 214, 214, 215,
1344 215, 215, 215, 215, 215, 215, 215, 215, 216, 216,
1345 217, 218, 218, 219, 219, 219, 220, 220, 221, 221,
1346 222, 222, 222, 222, 222, 222, 222, 222, 222, 222,
1347 222, 222, 222, 222, 223, 223, 224, 224, 224, 224,
1351 static const short yyr2[] = { 0,
1352 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1353 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1356 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1357 1, 1, 1, 1, 1, 1, 1, 1, 2, 0,
1358 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1359 0, 1, 1, 0, 1, 1, 1, 1, 0, 1,
1360 1, 1, 1, 1, 1, 2, 1, 1, 0, 2,
1361 1, 1, 0, 2, 0, 2, 0, 3, 2, 0,
1362 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1363 1, 2, 1, 2, 5, 5, 5, 5, 3, 2,
1364 5, 4, 2, 1, 1, 1, 3, 1, 3, 1,
1365 0, 1, 3, 4, 3, 3, 4, 4, 3, 6,
1366 5, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1367 2, 6, 5, 8, 6, 6, 7, 7, 6, 6,
1368 8, 8, 3, 1, 1, 1, 1, 0, 1, 2,
1369 0, 3, 0, 3, 3, 1, 3, 3, 0, 6,
1370 0, 7, 0, 7, 2, 3, 1, 1, 1, 3,
1371 3, 3, 3, 3, 3, 1, 0, 1, 1, 1,
1372 0, 5, 3, 1, 3, 1, 0, 9, 1, 1,
1373 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
1374 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1375 1, 1, 2, 2, 2, 3, 2, 0, 1, 2,
1376 2, 3, 9, 9, 8, 14, 1, 1, 6, 5,
1377 2, 6, 7, 3, 5, 0, 0, 3, 2, 1,
1378 5, 5, 6, 6, 4, 4, 6, 4, 4, 6,
1379 6, 2, 8, 1, 1, 0, 3, 6, 3, 6,
1383 static const short yydefact[] = { 60,
1384 198, 199, 176, 173, 171, 0, 0, 0, 69, 60,
1385 169, 0, 71, 74, 0, 0, 0, 0, 185, 0,
1386 0, 0, 61, 63, 62, 64, 66, 65, 67, 68,
1387 70, 69, 69, 0, 170, 59, 72, 73, 69, 174,
1388 75, 76, 77, 78, 69, 238, 172, 238, 0, 0,
1389 0, 0, 197, 186, 187, 175, 1, 2, 178, 106,
1390 107, 108, 109, 110, 0, 0, 0, 0, 229, 111,
1391 177, 230, 113, 0, 0, 165, 166, 0, 79, 79,
1392 239, 235, 60, 212, 213, 214, 234, 192, 189, 188,
1393 190, 191, 193, 196, 0, 131, 114, 0, 0, 0,
1394 0, 120, 132, 0, 112, 131, 0, 0, 106, 107,
1395 108, 0, 0, 0, 179, 0, 80, 81, 82, 83,
1396 84, 85, 0, 215, 0, 276, 237, 0, 194, 130,
1397 89, 126, 128, 0, 0, 0, 0, 0, 0, 119,
1398 0, 181, 183, 149, 150, 147, 148, 151, 146, 142,
1399 143, 3, 4, 5, 6, 7, 8, 9, 10, 11,
1400 12, 13, 14, 0, 0, 0, 15, 16, 17, 18,
1401 19, 20, 21, 22, 23, 24, 25, 26, 0, 27,
1402 28, 29, 0, 0, 0, 0, 0, 0, 0, 0,
1403 0, 0, 0, 145, 144, 102, 86, 125, 124, 0,
1404 209, 210, 211, 275, 260, 0, 0, 0, 0, 79,
1405 247, 248, 0, 0, 0, 0, 0, 0, 0, 0,
1406 0, 0, 0, 0, 0, 0, 0, 0, 236, 79,
1407 251, 0, 274, 195, 123, 0, 93, 0, 0, 122,
1408 0, 133, 93, 102, 102, 30, 31, 32, 33, 34,
1409 35, 36, 37, 38, 39, 0, 54, 55, 50, 51,
1410 52, 53, 40, 41, 42, 43, 44, 45, 46, 47,
1411 48, 49, 0, 0, 0, 0, 0, 0, 135, 164,
1412 0, 0, 0, 139, 0, 136, 0, 0, 0, 0,
1413 0, 180, 0, 259, 241, 0, 240, 0, 0, 56,
1414 0, 0, 0, 0, 97, 97, 281, 0, 0, 272,
1415 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1416 0, 0, 87, 88, 90, 129, 127, 116, 117, 118,
1417 121, 115, 182, 184, 0, 0, 257, 0, 0, 0,
1418 0, 0, 134, 120, 132, 0, 137, 138, 0, 0,
1419 0, 0, 0, 0, 104, 102, 207, 218, 219, 220,
1420 225, 221, 222, 223, 224, 216, 0, 227, 232, 231,
1421 233, 0, 242, 0, 0, 0, 0, 0, 277, 0,
1422 279, 257, 0, 0, 0, 0, 0, 0, 0, 0,
1423 0, 0, 0, 0, 0, 0, 91, 92, 94, 0,
1424 0, 0, 0, 0, 0, 0, 163, 141, 0, 0,
1425 0, 0, 0, 99, 105, 103, 206, 89, 204, 0,
1426 217, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1427 0, 284, 0, 0, 0, 268, 269, 0, 0, 0,
1428 0, 266, 265, 0, 282, 0, 0, 0, 0, 153,
1429 0, 0, 0, 0, 140, 0, 0, 0, 0, 201,
1430 0, 93, 0, 226, 0, 0, 256, 0, 0, 97,
1431 98, 97, 0, 0, 0, 0, 0, 261, 262, 256,
1432 0, 0, 0, 258, 0, 160, 0, 0, 155, 156,
1433 152, 159, 200, 203, 205, 89, 100, 0, 0, 0,
1434 0, 0, 263, 264, 0, 278, 280, 0, 0, 267,
1435 270, 271, 0, 283, 157, 158, 0, 0, 0, 201,
1436 101, 95, 228, 0, 0, 89, 0, 93, 252, 0,
1437 93, 154, 161, 162, 202, 0, 208, 0, 245, 0,
1438 0, 254, 0, 0, 253, 273, 96, 243, 0, 244,
1439 0, 89, 0, 0, 0, 255, 0, 0, 0, 0,
1440 250, 0, 0, 249, 0, 246, 0, 0, 0
1443 static const short yydefgoto[] = { 69,
1444 190, 191, 192, 193, 256, 273, 112, 113, 9, 32,
1445 33, 34, 39, 45, 123, 325, 235, 399, 328, 537,
1446 379, 355, 522, 292, 356, 70, 114, 132, 200, 133,
1447 134, 104, 280, 368, 281, 78, 567, 10, 11, 14,
1448 13, 196, 244, 245, 56, 91, 19, 54, 95, 72,
1449 494, 419, 420, 124, 203, 46, 86, 47, 40, 422,
1450 369, 73, 371, 297, 48, 82, 83, 229, 541, 127,
1451 310, 502, 402, 230, 231, 232, 233
1454 static const short yypact[] = { 399,
1455 -32768,-32768,-32768,-32768,-32768, 12, -43, -5, 66, 525,
1456 -32768, 47, 142, 122, 58, 63, 82, 88,-32768, -33,
1457 119, 789,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1458 -32768, -13, -13, 222,-32768,-32768,-32768,-32768, -13,-32768,
1459 -32768,-32768,-32768,-32768, -13, 123,-32768, -6, 208, 218,
1460 223, 224, 243,-32768,-32768,-32768,-32768,-32768, 124,-32768,
1461 -32768,-32768,-32768,-32768, 267, 276, 8, 23,-32768,-32768,
1462 121,-32768,-32768, 222, 222,-32768,-32768, 1043, 129, 129,
1463 -32768,-32768, 239,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1464 -32768,-32768,-32768,-32768, -45, 547,-32768, 143, 147, 118,
1465 124,-32768, 121, -94,-32768, 547, 1043, 1127, 42, 284,
1466 285, 263, 286, 600,-32768, 290,-32768,-32768,-32768,-32768,
1467 -32768,-32768, 1140,-32768, -8, 1278,-32768, 279,-32768,-32768,
1468 121,-32768, 162, 159, 1127, 1127, 156, -70, 1127,-32768,
1469 167,-32768, 121,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1470 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1471 -32768,-32768,-32768, 536, 499, 172,-32768,-32768,-32768,-32768,
1472 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 175,-32768,
1473 -32768,-32768, 176, 178, 179, 691, 1183, 137, 302, 182,
1474 183, 186, 190,-32768,-32768, 166,-32768, 124, 121, 239,
1475 -32768,-32768,-32768,-32768,-32768, 251, 1195, 56, 319, 129,
1476 -32768,-32768, 536, 499, 1127, 1127, 1127, 1127, 1127, 1127,
1477 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,-32768, 129,
1478 -32768, 163,-32768,-32768, 164, 772,-32768, 41, -27,-32768,
1479 187, 121,-32768, 166, 166,-32768,-32768,-32768,-32768,-32768,
1480 -32768,-32768,-32768,-32768,-32768, 192,-32768,-32768,-32768,-32768,
1481 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1482 -32768,-32768, 194, 1043, 1043, 1043, 1043, 1043,-32768,-32768,
1483 20, 498, -91,-32768, -67,-32768, 1043, 1043, 1043, 1043,
1484 -12,-32768, 195,-32768, 124, 744,-32768, 871, 871,-32768,
1485 871, 1140, 1127, 1127, -17, 29,-32768, 744, 60, 200,
1486 201, 202, 203, 204, 205, 744, 744, 311, 207, 1140,
1487 1127, 1127,-32768,-32768,-32768,-32768,-32768, -86,-32768,-32768,
1488 -32768, -86,-32768,-32768, 1043, 1043,-32768, 210, 215, 216,
1489 217, 1043,-32768, 199, 600, -50,-32768,-32768, 220, 225,
1490 328, 226, 346, 359,-32768, 166, 1026,-32768,-32768,-32768,
1491 -32768,-32768,-32768,-32768,-32768, 310, 1043,-32768,-32768,-32768,
1492 -32768, 231,-32768, 232, 871, 744, 744, 2,-32768, 5,
1493 -32768,-32768, 871, 230, 1127, 1127, 1127, 1127, 1127, 236,
1494 242, 1127, 1127, 871, 744, 246,-32768,-32768,-32768, 247,
1495 248, 6, 1043, 1043, 1043, 1043,-32768,-32768, 234, 1043,
1496 1043, 1127, 1043,-32768,-32768,-32768,-32768, 121, 249, 250,
1497 -32768, 368, -46, 373, 374, 254, 253, 260, 871, 393,
1498 871, 269, 271, 871, 272, 121,-32768, 273, 275, 871,
1499 871, 121,-32768, 277,-32768, 1127, 1043, 1043, 1127,-32768,
1500 278, 280, 283, 287,-32768, 288, 293, 114, 295, 3,
1501 1089,-32768, 291,-32768, 871, 871, 1127, 871, 871, 300,
1502 -32768, 300, 871, 303, 1127, 1127, 1127,-32768,-32768, 1127,
1503 744, 301, 304,-32768, 1043,-32768, 1043, 1043,-32768,-32768,
1504 -32768,-32768,-32768,-32768,-32768, 121, 64, 394, 306, 299,
1505 744, 35,-32768,-32768, 376,-32768,-32768, 305, 871,-32768,
1506 -32768,-32768, 112,-32768,-32768,-32768, 307, 312, 313, 3,
1507 -32768, 395,-32768, 432, -4,-32768, 1127,-32768,-32768, 308,
1508 -32768,-32768,-32768,-32768,-32768, 450,-32768, 871,-32768, 998,
1509 9, 164, 744, 1,-32768, -86,-32768,-32768, 321,-32768,
1510 998,-32768, 444, 445, 324, 164, 871, 871, 447, 397,
1511 -32768, 871, 455,-32768, 871,-32768, 468, 469,-32768
1514 static const short yypgoto[] = {-32768,
1515 345, 347, 348, 349, 259, 262, -208,-32768, 398,-32768,
1516 -32768, 48,-32768,-32768, -172, -305, -411,-32768, -217,-32768,
1517 -300, -20,-32768, -223,-32768,-32768, -14, 252, -260,-32768,
1518 377, 382, -58, -112, -184, 211,-32768,-32768, 477,-32768,
1519 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 0,
1520 -30,-32768,-32768, 411,-32768,-32768,-32768,-32768,-32768,-32768,
1521 -492, -73, 103, -151,-32768, 446,-32768,-32768,-32768,-32768,
1522 -32768, 13, 113,-32768,-32768,-32768,-32768
1529 static const short yytable[] = { 12,
1530 301, 194, 283, 285, 300, 381, 460, 71, 81, 12,
1531 429, 99, 201, 431, 353, 84, 1, 300, 2, 115,
1532 333, 334, 398, 323, 324, 332, 398, 57, 58, 553,
1533 101, 60, 61, 62, 63, 354, 1, 302, 2, 139,
1534 195, 375, 342, 397, -56, -56, 21, 549, 142, 430,
1535 140, 347, 430, 103, 15, 16, 17, 320, 555, 394,
1536 144, 145, 64, 139, 298, 307, 342, 299, 311, 312,
1537 313, 314, 315, 18, 241, 318, 319, 348, 22, 74,
1538 75, 131, 12, 342, 520, 103, 79, 342, 128, 20,
1539 353, 131, 80, 143, 409, 129, 464, 346, 23, 24,
1540 25, 26, 27, 28, 29, 53, 30, 105, 199, 106,
1541 323, 324, 323, 324, 542, 330, 378, 105, 31, 106,
1542 238, 239, 57, 58, 242, 101, 60, 61, 62, 63,
1543 397, 1, 416, 2, 55, 202, 539, 81, 85, 449,
1544 556, 57, 58, 450, 101, 109, 110, 111, 63, 550,
1545 1, 100, 2, 342, 41, 42, 43, 64, 65, 44,
1546 343, 66, 380, 105, 67, 106, 68, 102, 527, 506,
1547 396, 507, 528, 323, 324, 105, 64, 106, 37, 36,
1548 38, 329, 423, 116, 117, 118, 119, 120, 121, 122,
1549 49, 398, 296, 397, 105, 50, 106, 31, 383, 293,
1550 305, 306, 296, 308, 309, 296, 296, 296, 296, 296,
1551 316, 317, 296, 296, 51, 337, 338, 339, 340, 341,
1552 52, 131, 370, 88, 370, 370, 92, 370, 349, 350,
1553 351, 352, 194, 435, 370, 437, 438, 439, 398, 93,
1554 398, 443, 370, 370, 497, 527, 76, 77, 105, 531,
1555 106, 491, 1, 65, 2, 105, 66, 106, 94, 67,
1556 96, 68, 137, 89, 90, 146, 147, 345, 321, 322,
1557 97, 195, 65, 323, 324, 66, 400, 401, 67, 98,
1558 68, 284, 135, 407, 107, 108, 136, 199, 376, 377,
1559 -57, -58, 148, 197, 234, 236, 237, 484, 240, 291,
1560 294, 370, 370, 370, 243, 199, 395, 296, 274, 370,
1561 544, 275, 276, 546, 277, 278, 540, 286, 287, 288,
1562 370, 370, 289, 510, 511, 512, 290, 300, 335, 331,
1563 336, 357, 551, 384, 385, 386, 387, 388, 389, 392,
1564 393, 408, 418, 403, 451, 452, 453, 454, 404, 405,
1565 406, 456, 457, 410, 459, 370, 412, 370, 411, 413,
1566 370, 414, 415, 421, 424, 425, 370, 370, 434, 440,
1567 296, 436, 296, 296, 296, 441, 455, 442, 296, 446,
1568 447, 448, 461, 463, 465, 466, 468, 462, 482, 483,
1569 467, 370, 370, 469, 370, 370, 471, 458, -168, 370,
1570 372, 373, 449, 374, 473, 475, 476, 370, 477, 523,
1571 382, 485, 1, 480, 2, 3, 487, 486, 390, 391,
1572 488, 4, 5, 430, 498, 489, 517, 370, 518, 519,
1573 490, 481, 492, 505, 296, 370, 509, 525, 515, 524,
1574 6, 516, 536, 538, 532, 529, 496, 7, 545, 533,
1575 534, 8, 501, 547, 554, 557, 558, 559, 562, 493,
1576 296, 296, 296, 563, 370, 501, 565, 568, 569, 370,
1577 225, 303, 226, 227, 228, 304, 521, 426, 427, 428,
1578 126, 138, 141, 370, 370, 433, 35, 327, 370, 535,
1579 125, 370, 513, 87, 432, 0, 444, 445, 0, 0,
1580 0, 0, 57, 58, 0, 101, 109, 110, 111, 63,
1581 0, 1, 543, 2, 0, 0, 0, 257, 258, 493,
1582 0, 0, 0, 0, -167, 0, 0, 0, 0, 0,
1583 0, 470, 0, 472, 0, 0, 474, 64, 1, 0,
1584 2, 3, 478, 479, 0, 0, 0, 4, 5, 0,
1585 0, 57, 58, 0, 101, 60, 61, 62, 63, 0,
1586 1, 0, 2, 0, 0, 0, 6, 499, 500, 0,
1587 503, 504, 0, 7, 0, 508, 130, 8, 0, 0,
1588 0, 0, 0, 514, 0, 0, 64, 259, 260, 261,
1589 262, 263, 264, 265, 266, 267, 268, 269, 270, 271,
1590 272, 0, 0, 526, 57, 58, 0, 0, 0, 0,
1591 0, 530, 0, 1, 0, 2, 0, 149, 246, 247,
1592 248, 249, 250, 251, 252, 253, 254, 255, 0, 0,
1593 150, 151, 0, 65, 0, 0, 66, 0, 0, 67,
1594 548, 68, 344, 0, 0, 552, 0, 0, 0, 0,
1595 0, 0, 0, 0, 0, 0, 0, 0, 0, 560,
1596 561, 0, 0, 0, 564, 0, 0, 566, 152, 153,
1597 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
1598 164, 165, 65, 0, 0, 66, 0, 0, 67, 0,
1599 68, 0, 0, 0, 0, 57, 58, 0, 101, 109,
1600 110, 111, 63, 0, 1, 0, 2, 166, 167, 168,
1601 169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
1602 0, 179, 180, 181, 182, 0, 183, 184, 185, 0,
1603 64, 0, 0, 0, 105, 0, 106, 0, 186, 0,
1604 0, 187, 0, 188, 0, 189, 358, 359, 57, 58,
1605 360, 0, 0, 0, 0, 0, 0, 1, 0, 2,
1606 0, 361, 362, 363, 0, 0, 0, 0, 0, 0,
1607 0, 0, 0, 0, 364, 365, 57, 58, 0, 101,
1608 60, 61, 62, 63, 0, 1, 0, 2, 0, 0,
1609 0, 0, 0, 57, 58, 366, 59, 60, 61, 62,
1610 63, 326, 1, 0, 2, 0, 0, 0, 0, 0,
1611 0, 64, 152, 153, 154, 155, 156, 157, 158, 159,
1612 160, 161, 162, 163, 164, 165, 65, 0, 64, 66,
1613 0, 279, 67, 0, 68, 0, 0, 0, 0, 0,
1614 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1615 0, 166, 167, 168, 169, 170, 171, 172, 173, 174,
1616 175, 176, 177, 178, 0, 179, 180, 181, 182, 0,
1617 183, 184, 185, 358, 359, 57, 58, 360, 105, 0,
1618 106, 0, 0, 0, 1, 367, 2, 0, 361, 362,
1619 363, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1620 0, 364, 365, 0, 0, 0, 0, 65, 0, 0,
1621 66, 0, 0, 67, 0, 68, 0, 0, 0, 0,
1622 0, 0, 366, 0, 65, 0, 0, 66, 0, 0,
1623 67, 0, 68, 0, 0, 0, 0, 0, 0, 152,
1624 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
1625 163, 164, 165, 0, 0, 0, 0, 0, 0, 0,
1626 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1627 0, 0, 0, 0, 0, 0, 0, 0, 166, 167,
1628 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
1629 178, 0, 179, 180, 181, 182, 0, 183, 184, 185,
1630 358, 359, 0, 0, 360, 0, 0, 0, 0, 0,
1631 0, 0, 367, 0, 0, 361, 362, 363, 0, 0,
1632 0, 0, 0, 0, 0, 0, 0, 0, 364, 365,
1633 57, 58, 0, 101, 60, 61, 62, 63, 0, 1,
1634 0, 2, 0, 0, 0, 0, 0, 57, 58, 366,
1635 101, 109, 110, 111, 63, 417, 1, 0, 2, 0,
1636 0, 0, 0, 0, 0, 64, 152, 153, 154, 155,
1637 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
1638 0, 0, 64, 0, 0, 0, 0, 0, 0, 0,
1639 0, 0, 0, 57, 58, 0, 101, 60, 61, 62,
1640 63, 0, 1, 0, 2, 166, 167, 168, 169, 170,
1641 171, 172, 173, 174, 175, 176, 177, 178, 495, 179,
1642 180, 181, 182, 0, 183, 184, 185, 0, 64, 0,
1643 0, 57, 58, 0, 101, 60, 61, 62, 63, 367,
1644 1, 0, 2, 0, 57, 58, 0, 198, 60, 61,
1645 62, 63, 0, 1, 0, 2, 0, 0, 0, 0,
1646 0, 65, 0, 0, 66, 0, 64, 67, 0, 68,
1647 0, 0, 0, 0, 0, 0, 0, 0, 65, 64,
1648 0, 66, 0, 0, 67, 0, 68, 57, 58, 0,
1649 101, 109, 110, 111, 63, 0, 1, 0, 2, 57,
1650 58, 0, 295, 60, 61, 62, 63, 0, 1, 0,
1651 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1652 0, 0, 64, 0, 65, 0, 0, 66, 0, 0,
1653 67, 0, 68, 0, 64, 0, 0, 0, 0, 0,
1654 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1655 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1656 0, 0, 65, 0, 0, 66, 0, 0, 67, 0,
1657 68, 0, 0, 0, 0, 65, 0, 0, 66, 0,
1658 0, 67, 0, 68, 0, 0, 0, 0, 0, 0,
1659 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1660 0, 0, 0, 0, 0, 204, 0, 0, 0, 0,
1661 0, 0, 0, 0, 0, 0, 0, 0, 65, 0,
1662 0, 66, 0, 0, 67, 0, 282, 205, 206, 0,
1663 65, 0, 0, 66, 0, 0, 67, 0, 68, 0,
1664 207, 208, 209, 210, 211, 212, 152, 153, 154, 155,
1665 156, 157, 158, 159, 160, 161, 162, 163, 213, 214,
1666 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1667 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1668 215, 216, 217, 0, 0, 218, 167, 168, 169, 170,
1669 171, 172, 173, 174, 175, 176, 177, 178, 219, 220,
1670 180, 181, 182, 221, 222, 223, 224
1673 static const short yycheck[] = { 0,
1674 209, 114, 187, 188, 9, 306, 418, 22, 15, 10,
1675 9, 4, 21, 9, 27, 22, 14, 9, 16, 78,
1676 244, 245, 328, 110, 111, 243, 332, 5, 6, 29,
1677 8, 9, 10, 11, 12, 48, 14, 210, 16, 134,
1678 114, 302, 134, 130, 3, 4, 52, 540, 107, 48,
1679 145, 143, 48, 68, 43, 44, 45, 230, 551, 320,
1680 19, 20, 40, 134, 9, 217, 134, 12, 220, 221,
1681 222, 223, 224, 62, 145, 227, 228, 145, 13, 32,
1682 33, 96, 83, 134, 496, 100, 39, 134, 134, 133,
1683 27, 106, 45, 108, 145, 141, 143, 282, 33, 34,
1684 35, 36, 37, 38, 39, 139, 41, 135, 123, 137,
1685 110, 111, 110, 111, 526, 143, 134, 135, 132, 137,
1686 135, 136, 5, 6, 139, 8, 9, 10, 11, 12,
1687 130, 14, 356, 16, 16, 144, 141, 15, 145, 134,
1688 552, 5, 6, 138, 8, 9, 10, 11, 12, 141,
1689 14, 144, 16, 134, 33, 34, 35, 40, 136, 38,
1690 141, 139, 134, 135, 142, 137, 144, 145, 134, 470,
1691 322, 472, 138, 110, 111, 135, 40, 137, 37, 133,
1692 39, 141, 367, 55, 56, 57, 58, 59, 60, 61,
1693 133, 497, 207, 130, 135, 133, 137, 132, 139, 200,
1694 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
1695 225, 226, 227, 228, 133, 274, 275, 276, 277, 278,
1696 133, 236, 296, 16, 298, 299, 4, 301, 287, 288,
1697 289, 290, 345, 385, 308, 387, 388, 389, 544, 16,
1698 546, 393, 316, 317, 462, 134, 25, 26, 135, 138,
1699 137, 138, 14, 136, 16, 135, 139, 137, 16, 142,
1700 137, 144, 145, 46, 47, 3, 4, 282, 106, 107,
1701 4, 345, 136, 110, 111, 139, 335, 336, 142, 4,
1702 144, 145, 140, 342, 74, 75, 140, 302, 303, 304,
1703 7, 7, 7, 4, 16, 134, 138, 449, 143, 134,
1704 50, 375, 376, 377, 138, 320, 321, 322, 137, 383,
1705 528, 137, 137, 531, 137, 137, 525, 16, 137, 137,
1706 394, 395, 137, 475, 476, 477, 137, 9, 137, 143,
1707 137, 137, 541, 134, 134, 134, 134, 134, 134, 29,
1708 134, 143, 357, 134, 403, 404, 405, 406, 134, 134,
1709 134, 410, 411, 134, 413, 429, 29, 431, 134, 134,
1710 434, 16, 4, 54, 134, 134, 440, 441, 139, 134,
1711 385, 386, 387, 388, 389, 134, 143, 392, 393, 134,
1712 134, 134, 134, 16, 12, 12, 134, 138, 447, 448,
1713 137, 465, 466, 134, 468, 469, 4, 412, 0, 473,
1714 298, 299, 134, 301, 134, 134, 134, 481, 134, 16,
1715 308, 134, 14, 137, 16, 17, 134, 138, 316, 317,
1716 134, 23, 24, 48, 134, 138, 485, 501, 487, 488,
1717 138, 446, 138, 134, 449, 509, 134, 139, 138, 134,
1718 42, 138, 48, 12, 138, 141, 461, 49, 141, 138,
1719 138, 53, 467, 4, 134, 12, 12, 134, 12, 460,
1720 475, 476, 477, 67, 538, 480, 12, 0, 0, 543,
1721 126, 213, 126, 126, 126, 214, 497, 375, 376, 377,
1722 83, 100, 106, 557, 558, 383, 10, 236, 562, 520,
1723 80, 565, 480, 48, 382, -1, 394, 395, -1, -1,
1724 -1, -1, 5, 6, -1, 8, 9, 10, 11, 12,
1725 -1, 14, 527, 16, -1, -1, -1, 19, 20, 520,
1726 -1, -1, -1, -1, 0, -1, -1, -1, -1, -1,
1727 -1, 429, -1, 431, -1, -1, 434, 40, 14, -1,
1728 16, 17, 440, 441, -1, -1, -1, 23, 24, -1,
1729 -1, 5, 6, -1, 8, 9, 10, 11, 12, -1,
1730 14, -1, 16, -1, -1, -1, 42, 465, 466, -1,
1731 468, 469, -1, 49, -1, 473, 30, 53, -1, -1,
1732 -1, -1, -1, 481, -1, -1, 40, 89, 90, 91,
1733 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
1734 102, -1, -1, 501, 5, 6, -1, -1, -1, -1,
1735 -1, 509, -1, 14, -1, 16, -1, 18, 83, 84,
1736 85, 86, 87, 88, 89, 90, 91, 92, -1, -1,
1737 31, 32, -1, 136, -1, -1, 139, -1, -1, 142,
1738 538, 144, 145, -1, -1, 543, -1, -1, -1, -1,
1739 -1, -1, -1, -1, -1, -1, -1, -1, -1, 557,
1740 558, -1, -1, -1, 562, -1, -1, 565, 69, 70,
1741 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1742 81, 82, 136, -1, -1, 139, -1, -1, 142, -1,
1743 144, -1, -1, -1, -1, 5, 6, -1, 8, 9,
1744 10, 11, 12, -1, 14, -1, 16, 108, 109, 110,
1745 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1746 -1, 122, 123, 124, 125, -1, 127, 128, 129, -1,
1747 40, -1, -1, -1, 135, -1, 137, -1, 139, -1,
1748 -1, 142, -1, 144, -1, 146, 3, 4, 5, 6,
1749 7, -1, -1, -1, -1, -1, -1, 14, -1, 16,
1750 -1, 18, 19, 20, -1, -1, -1, -1, -1, -1,
1751 -1, -1, -1, -1, 31, 32, 5, 6, -1, 8,
1752 9, 10, 11, 12, -1, 14, -1, 16, -1, -1,
1753 -1, -1, -1, 5, 6, 52, 8, 9, 10, 11,
1754 12, 30, 14, -1, 16, -1, -1, -1, -1, -1,
1755 -1, 40, 69, 70, 71, 72, 73, 74, 75, 76,
1756 77, 78, 79, 80, 81, 82, 136, -1, 40, 139,
1757 -1, 141, 142, -1, 144, -1, -1, -1, -1, -1,
1758 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1759 -1, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1760 117, 118, 119, 120, -1, 122, 123, 124, 125, -1,
1761 127, 128, 129, 3, 4, 5, 6, 7, 135, -1,
1762 137, -1, -1, -1, 14, 142, 16, -1, 18, 19,
1763 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1764 -1, 31, 32, -1, -1, -1, -1, 136, -1, -1,
1765 139, -1, -1, 142, -1, 144, -1, -1, -1, -1,
1766 -1, -1, 52, -1, 136, -1, -1, 139, -1, -1,
1767 142, -1, 144, -1, -1, -1, -1, -1, -1, 69,
1768 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1769 80, 81, 82, -1, -1, -1, -1, -1, -1, -1,
1770 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1771 -1, -1, -1, -1, -1, -1, -1, -1, 108, 109,
1772 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
1773 120, -1, 122, 123, 124, 125, -1, 127, 128, 129,
1774 3, 4, -1, -1, 7, -1, -1, -1, -1, -1,
1775 -1, -1, 142, -1, -1, 18, 19, 20, -1, -1,
1776 -1, -1, -1, -1, -1, -1, -1, -1, 31, 32,
1777 5, 6, -1, 8, 9, 10, 11, 12, -1, 14,
1778 -1, 16, -1, -1, -1, -1, -1, 5, 6, 52,
1779 8, 9, 10, 11, 12, 30, 14, -1, 16, -1,
1780 -1, -1, -1, -1, -1, 40, 69, 70, 71, 72,
1781 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1782 -1, -1, 40, -1, -1, -1, -1, -1, -1, -1,
1783 -1, -1, -1, 5, 6, -1, 8, 9, 10, 11,
1784 12, -1, 14, -1, 16, 108, 109, 110, 111, 112,
1785 113, 114, 115, 116, 117, 118, 119, 120, 30, 122,
1786 123, 124, 125, -1, 127, 128, 129, -1, 40, -1,
1787 -1, 5, 6, -1, 8, 9, 10, 11, 12, 142,
1788 14, -1, 16, -1, 5, 6, -1, 8, 9, 10,
1789 11, 12, -1, 14, -1, 16, -1, -1, -1, -1,
1790 -1, 136, -1, -1, 139, -1, 40, 142, -1, 144,
1791 -1, -1, -1, -1, -1, -1, -1, -1, 136, 40,
1792 -1, 139, -1, -1, 142, -1, 144, 5, 6, -1,
1793 8, 9, 10, 11, 12, -1, 14, -1, 16, 5,
1794 6, -1, 8, 9, 10, 11, 12, -1, 14, -1,
1795 16, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1796 -1, -1, 40, -1, 136, -1, -1, 139, -1, -1,
1797 142, -1, 144, -1, 40, -1, -1, -1, -1, -1,
1798 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1799 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1800 -1, -1, 136, -1, -1, 139, -1, -1, 142, -1,
1801 144, -1, -1, -1, -1, 136, -1, -1, 139, -1,
1802 -1, 142, -1, 144, -1, -1, -1, -1, -1, -1,
1803 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1804 -1, -1, -1, -1, -1, 28, -1, -1, -1, -1,
1805 -1, -1, -1, -1, -1, -1, -1, -1, 136, -1,
1806 -1, 139, -1, -1, 142, -1, 144, 50, 51, -1,
1807 136, -1, -1, 139, -1, -1, 142, -1, 144, -1,
1808 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
1809 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1810 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1811 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1812 103, 104, 105, -1, -1, 108, 109, 110, 111, 112,
1813 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1814 123, 124, 125, 126, 127, 128, 129
1816 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1817 #line 3 "/usr/share/bison.simple"
1818 /* This file comes from bison-1.28. */
1820 /* Skeleton output parser for bison,
1821 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1823 This program is free software; you can redistribute it and/or modify
1824 it under the terms of the GNU General Public License as published by
1825 the Free Software Foundation; either version 2, or (at your option)
1828 This program is distributed in the hope that it will be useful,
1829 but WITHOUT ANY WARRANTY; without even the implied warranty of
1830 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1831 GNU General Public License for more details.
1833 You should have received a copy of the GNU General Public License
1834 along with this program; if not, write to the Free Software
1835 Foundation, Inc., 59 Temple Place - Suite 330,
1836 Boston, MA 02111-1307, USA. */
1838 /* As a special exception, when this file is copied by Bison into a
1839 Bison output file, you may use that output file without restriction.
1840 This special exception was added by the Free Software Foundation
1841 in version 1.24 of Bison. */
1843 /* This is the parser code that is written into each bison parser
1844 when the %semantic_parser declaration is not specified in the grammar.
1845 It was written by Richard Stallman by simplifying the hairy parser
1846 used when %semantic_parser is specified. */
1848 #ifndef YYSTACK_USE_ALLOCA
1850 #define YYSTACK_USE_ALLOCA
1851 #else /* alloca not defined */
1853 #define YYSTACK_USE_ALLOCA
1854 #define alloca __builtin_alloca
1855 #else /* not GNU C. */
1856 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1857 #define YYSTACK_USE_ALLOCA
1859 #else /* not sparc */
1860 /* We think this test detects Watcom and Microsoft C. */
1861 /* This used to test MSDOS, but that is a bad idea
1862 since that symbol is in the user namespace. */
1863 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1864 #if 0 /* No need for malloc.h, which pollutes the namespace;
1865 instead, just don't use alloca. */
1868 #else /* not MSDOS, or __TURBOC__ */
1870 /* I don't know what this was needed for, but it pollutes the namespace.
1871 So I turned it off. rms, 2 May 1997. */
1872 /* #include <malloc.h> */
1874 #define YYSTACK_USE_ALLOCA
1875 #else /* not MSDOS, or __TURBOC__, or _AIX */
1877 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1878 and on HPUX 10. Eventually we can turn this on. */
1879 #define YYSTACK_USE_ALLOCA
1880 #define alloca __builtin_alloca
1883 #endif /* not _AIX */
1884 #endif /* not MSDOS, or __TURBOC__ */
1885 #endif /* not sparc */
1886 #endif /* not GNU C */
1887 #endif /* alloca not defined */
1888 #endif /* YYSTACK_USE_ALLOCA not defined */
1890 #ifdef YYSTACK_USE_ALLOCA
1891 #define YYSTACK_ALLOC alloca
1893 #define YYSTACK_ALLOC malloc
1896 /* Note: there must be only one dollar sign in this file.
1897 It is replaced by the list of actions, each action
1898 as one case of the switch. */
1900 #define yyerrok (yyerrstatus = 0)
1901 #define yyclearin (yychar = YYEMPTY)
1904 #define YYACCEPT goto yyacceptlab
1905 #define YYABORT goto yyabortlab
1906 #define YYERROR goto yyerrlab1
1907 /* Like YYERROR except do call yyerror.
1908 This remains here temporarily to ease the
1909 transition to the new meaning of YYERROR, for GCC.
1910 Once GCC version 2 has supplanted version 1, this can go. */
1911 #define YYFAIL goto yyerrlab
1912 #define YYRECOVERING() (!!yyerrstatus)
1913 #define YYBACKUP(token, value) \
1915 if (yychar == YYEMPTY && yylen == 1) \
1916 { yychar = (token), yylval = (value); \
1917 yychar1 = YYTRANSLATE (yychar); \
1922 { yyerror ("syntax error: cannot back up"); YYERROR; } \
1926 #define YYERRCODE 256
1929 #define YYLEX yylex()
1935 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
1937 #define YYLEX yylex(&yylval, &yylloc)
1939 #else /* not YYLSP_NEEDED */
1941 #define YYLEX yylex(&yylval, YYLEX_PARAM)
1943 #define YYLEX yylex(&yylval)
1945 #endif /* not YYLSP_NEEDED */
1948 /* If nonreentrant, generate the variables here */
1952 int yychar; /* the lookahead symbol */
1953 YYSTYPE yylval; /* the semantic value of the */
1954 /* lookahead symbol */
1957 YYLTYPE yylloc; /* location data for the lookahead */
1961 int yynerrs; /* number of parse errors so far */
1962 #endif /* not YYPURE */
1965 int yydebug; /* nonzero means print parse trace */
1966 /* Since this is uninitialized, it does not stop multiple parsers
1970 /* YYINITDEPTH indicates the initial size of the parser's stacks */
1973 #define YYINITDEPTH 200
1976 /* YYMAXDEPTH is the maximum size the stacks can grow to
1977 (effective only if the built-in stack extension method is used). */
1984 #define YYMAXDEPTH 10000
1987 /* Define __yy_memcpy. Note that the size argument
1988 should be passed with type unsigned int, because that is what the non-GCC
1989 definitions require. With GCC, __builtin_memcpy takes an arg
1990 of type size_t, but it can handle unsigned int. */
1992 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1993 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1994 #else /* not GNU C or C++ */
1997 /* This is the most reliable way to avoid incompatibilities
1998 in available built-in functions on various systems. */
2000 __yy_memcpy (to, from, count)
2005 register char *f = from;
2006 register char *t = to;
2007 register int i = count;
2013 #else /* __cplusplus */
2015 /* This is the most reliable way to avoid incompatibilities
2016 in available built-in functions on various systems. */
2018 __yy_memcpy (char *to, char *from, unsigned int count)
2020 register char *t = to;
2021 register char *f = from;
2022 register int i = count;
2031 #line 217 "/usr/share/bison.simple"
2033 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2034 into yyparse. The argument should have type void *.
2035 It should actually point to an object.
2036 Grammar actions can access the variable by casting it
2037 to the proper pointer type. */
2039 #ifdef YYPARSE_PARAM
2041 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2042 #define YYPARSE_PARAM_DECL
2043 #else /* not __cplusplus */
2044 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2045 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2046 #endif /* not __cplusplus */
2047 #else /* not YYPARSE_PARAM */
2048 #define YYPARSE_PARAM_ARG
2049 #define YYPARSE_PARAM_DECL
2050 #endif /* not YYPARSE_PARAM */
2052 /* Prevent warning if -Wstrict-prototypes. */
2054 #ifdef YYPARSE_PARAM
2055 int yyparse (void *);
2062 yyparse(YYPARSE_PARAM_ARG)
2065 register int yystate;
2067 register short *yyssp;
2068 register YYSTYPE *yyvsp;
2069 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2070 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2072 short yyssa[YYINITDEPTH]; /* the state stack */
2073 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2075 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2076 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2079 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2080 YYLTYPE *yyls = yylsa;
2083 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2085 #define YYPOPSTACK (yyvsp--, yyssp--)
2088 int yystacksize = YYINITDEPTH;
2089 int yyfree_stacks = 0;
2100 YYSTYPE yyval; /* the variable used to return */
2101 /* semantic values from the action */
2108 fprintf(stderr, "Starting parse\n");
2114 yychar = YYEMPTY; /* Cause a token to be read. */
2116 /* Initialize stack pointers.
2117 Waste one element of value and location stack
2118 so that they stay on the same level as the state stack.
2119 The wasted elements are never initialized. */
2127 /* Push a new state, which is found in yystate . */
2128 /* In all cases, when you get here, the value and location stacks
2129 have just been pushed. so pushing a state here evens the stacks. */
2134 if (yyssp >= yyss + yystacksize - 1)
2136 /* Give user a chance to reallocate the stack */
2137 /* Use copies of these so that the &'s don't force the real ones into memory. */
2138 YYSTYPE *yyvs1 = yyvs;
2139 short *yyss1 = yyss;
2141 YYLTYPE *yyls1 = yyls;
2144 /* Get the current used size of the three stacks, in elements. */
2145 int size = yyssp - yyss + 1;
2148 /* Each stack pointer address is followed by the size of
2149 the data in use in that stack, in bytes. */
2151 /* This used to be a conditional around just the two extra args,
2152 but that might be undefined if yyoverflow is a macro. */
2153 yyoverflow("parser stack overflow",
2154 &yyss1, size * sizeof (*yyssp),
2155 &yyvs1, size * sizeof (*yyvsp),
2156 &yyls1, size * sizeof (*yylsp),
2159 yyoverflow("parser stack overflow",
2160 &yyss1, size * sizeof (*yyssp),
2161 &yyvs1, size * sizeof (*yyvsp),
2165 yyss = yyss1; yyvs = yyvs1;
2169 #else /* no yyoverflow */
2170 /* Extend the stack our own way. */
2171 if (yystacksize >= YYMAXDEPTH)
2173 yyerror("parser stack overflow");
2185 if (yystacksize > YYMAXDEPTH)
2186 yystacksize = YYMAXDEPTH;
2187 #ifndef YYSTACK_USE_ALLOCA
2190 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2191 __yy_memcpy ((char *)yyss, (char *)yyss1,
2192 size * (unsigned int) sizeof (*yyssp));
2193 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2194 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2195 size * (unsigned int) sizeof (*yyvsp));
2197 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2198 __yy_memcpy ((char *)yyls, (char *)yyls1,
2199 size * (unsigned int) sizeof (*yylsp));
2201 #endif /* no yyoverflow */
2203 yyssp = yyss + size - 1;
2204 yyvsp = yyvs + size - 1;
2206 yylsp = yyls + size - 1;
2211 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2214 if (yyssp >= yyss + yystacksize - 1)
2220 fprintf(stderr, "Entering state %d\n", yystate);
2226 /* Do appropriate processing given the current state. */
2227 /* Read a lookahead token if we need one and don't already have one. */
2230 /* First try to decide what to do without reference to lookahead token. */
2232 yyn = yypact[yystate];
2236 /* Not known => get a lookahead token if don't already have one. */
2238 /* yychar is either YYEMPTY or YYEOF
2239 or a valid token in external form. */
2241 if (yychar == YYEMPTY)
2245 fprintf(stderr, "Reading a token: ");
2250 /* Convert token to internal form (in yychar1) for indexing tables with */
2252 if (yychar <= 0) /* This means end of input. */
2255 yychar = YYEOF; /* Don't call YYLEX any more */
2259 fprintf(stderr, "Now at end of input.\n");
2264 yychar1 = YYTRANSLATE(yychar);
2269 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2270 /* Give the individual parser a way to print the precise meaning
2271 of a token, for further debugging info. */
2273 YYPRINT (stderr, yychar, yylval);
2275 fprintf (stderr, ")\n");
2281 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2286 /* yyn is what to do for this token type in this state.
2287 Negative => reduce, -yyn is rule number.
2288 Positive => shift, yyn is new state.
2289 New state is final state => don't bother to shift,
2290 just return success.
2291 0, or most negative number => error. */
2306 /* Shift the lookahead token. */
2310 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2313 /* Discard the token being shifted unless it is eof. */
2314 if (yychar != YYEOF)
2322 /* count tokens shifted since error; after three, turn off error status. */
2323 if (yyerrstatus) yyerrstatus--;
2328 /* Do the default action for the current state. */
2331 yyn = yydefact[yystate];
2335 /* Do a reduction. yyn is the number of a rule to reduce with. */
2339 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2346 fprintf (stderr, "Reducing via rule %d (line %d), ",
2349 /* Print the symbols being reduced, and their result. */
2350 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2351 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2352 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2360 #line 1032 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2362 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2363 GEN_ERROR("Value too large for type!");
2364 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2369 #line 1048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2370 { yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2373 #line 1048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2374 { yyval.IPredicate = ICmpInst::ICMP_NE; ;
2377 #line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2378 { yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2381 #line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2382 { yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2385 #line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2386 { yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2389 #line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2390 { yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2393 #line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2394 { yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2397 #line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2398 { yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2401 #line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2402 { yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2405 #line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2406 { yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2409 #line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2410 { yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2413 #line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2414 { yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2417 #line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2418 { yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2421 #line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2422 { yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2425 #line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2426 { yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2429 #line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2430 { yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2433 #line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2434 { yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2437 #line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2438 { yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2441 #line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2442 { yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2445 #line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2446 { yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2449 #line 1061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2450 { yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2453 #line 1061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2454 { yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2457 #line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2458 { yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2461 #line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2462 { yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2465 #line 1063 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2466 { yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2469 #line 1064 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2470 { yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2473 #line 1073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2475 yyval.StrVal = yyvsp[-1].StrVal;
2480 #line 1077 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2487 #line 1083 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2488 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2491 #line 1084 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2492 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2495 #line 1085 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2496 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2499 #line 1086 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2500 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2503 #line 1087 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2504 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2507 #line 1091 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2508 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2511 #line 1092 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2512 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2515 #line 1093 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2516 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2519 #line 1097 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2520 { yyval.Visibility = GlobalValue::DefaultVisibility; ;
2523 #line 1098 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2524 { yyval.Visibility = GlobalValue::HiddenVisibility; ;
2527 #line 1102 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2528 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2531 #line 1103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2532 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2535 #line 1104 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2536 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2539 #line 1108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2540 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2543 #line 1109 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2544 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2547 #line 1110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2548 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2551 #line 1111 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2552 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2555 #line 1112 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2556 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2559 #line 1115 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2560 { yyval.UIntVal = CallingConv::C; ;
2563 #line 1116 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2564 { yyval.UIntVal = CallingConv::C; ;
2567 #line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2568 { yyval.UIntVal = CallingConv::CSRet; ;
2571 #line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2572 { yyval.UIntVal = CallingConv::Fast; ;
2575 #line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2576 { yyval.UIntVal = CallingConv::Cold; ;
2579 #line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2580 { yyval.UIntVal = CallingConv::X86_StdCall; ;
2583 #line 1121 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2584 { yyval.UIntVal = CallingConv::X86_FastCall; ;
2587 #line 1122 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2589 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2590 GEN_ERROR("Calling conv too large!");
2591 yyval.UIntVal = yyvsp[0].UInt64Val;
2596 #line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2597 { yyval.ParamAttrs = FunctionType::ZExtAttribute; ;
2600 #line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2601 { yyval.ParamAttrs = FunctionType::SExtAttribute; ;
2604 #line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2605 { yyval.ParamAttrs = FunctionType::NoAttributeSet; ;
2608 #line 1134 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2610 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
2614 #line 1139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2615 { yyval.ParamAttrs = FunctionType::NoReturnAttribute; ;
2618 #line 1143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2619 { yyval.ParamAttrs = FunctionType::NoAttributeSet; ;
2622 #line 1144 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2624 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
2628 #line 1151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2629 { yyval.UIntVal = 0; ;
2632 #line 1152 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2634 yyval.UIntVal = yyvsp[0].UInt64Val;
2635 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2636 GEN_ERROR("Alignment must be a power of two!");
2641 #line 1158 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2642 { yyval.UIntVal = 0; ;
2645 #line 1159 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2647 yyval.UIntVal = yyvsp[0].UInt64Val;
2648 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2649 GEN_ERROR("Alignment must be a power of two!");
2654 #line 1167 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2656 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2657 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2658 GEN_ERROR("Invalid character in section name!");
2659 yyval.StrVal = yyvsp[0].StrVal;
2664 #line 1175 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2665 { yyval.StrVal = 0; ;
2668 #line 1176 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2669 { yyval.StrVal = yyvsp[0].StrVal; ;
2672 #line 1181 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2676 #line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2680 #line 1183 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2682 CurGV->setSection(yyvsp[0].StrVal);
2683 free(yyvsp[0].StrVal);
2688 #line 1188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2690 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2691 GEN_ERROR("Alignment must be a power of two!");
2692 CurGV->setAlignment(yyvsp[0].UInt64Val);
2697 #line 1204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2699 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2704 #line 1208 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2706 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2711 #line 1212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2713 if (*yyvsp[-1].TypeVal == Type::LabelTy)
2714 GEN_ERROR("Cannot form a pointer to a basic block");
2715 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2716 delete yyvsp[-1].TypeVal;
2721 #line 1219 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2722 { // Named types are also simple types...
2723 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
2725 yyval.TypeVal = new PATypeHolder(tmp);
2729 #line 1224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2730 { // Type UpReference
2731 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
2732 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2733 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2734 yyval.TypeVal = new PATypeHolder(OT);
2735 UR_OUT("New Upreference!\n");
2740 #line 1232 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2742 std::vector<const Type*> Params;
2743 std::vector<FunctionType::ParameterAttributes> Attrs;
2744 Attrs.push_back(yyvsp[0].ParamAttrs);
2745 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
2746 Params.push_back(I->Ty->get());
2747 if (I->Ty->get() != Type::VoidTy)
2748 Attrs.push_back(I->Attrs);
2750 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2751 if (isVarArg) Params.pop_back();
2753 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, Attrs);
2754 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2755 delete yyvsp[-4].TypeVal; // Delete the return type handle
2756 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
2761 #line 1250 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2763 std::vector<const Type*> Params;
2764 std::vector<FunctionType::ParameterAttributes> Attrs;
2765 Attrs.push_back(yyvsp[0].ParamAttrs);
2766 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
2767 Params.push_back(I->Ty->get());
2768 if (I->Ty->get() != Type::VoidTy)
2769 Attrs.push_back(I->Attrs);
2771 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2772 if (isVarArg) Params.pop_back();
2774 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, Attrs);
2775 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2776 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
2781 #line 1268 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2782 { // Sized array type?
2783 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2784 delete yyvsp[-1].TypeVal;
2789 #line 1273 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2790 { // Packed array type?
2791 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2792 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2793 GEN_ERROR("Unsigned result not equal to signed result");
2794 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
2795 GEN_ERROR("Element type of a PackedType must be primitive");
2796 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2797 GEN_ERROR("Vector length should be a power of 2!");
2798 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2799 delete yyvsp[-1].TypeVal;
2804 #line 1285 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2805 { // Structure type?
2806 std::vector<const Type*> Elements;
2807 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2808 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2809 Elements.push_back(*I);
2811 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2812 delete yyvsp[-1].TypeList;
2817 #line 1295 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2818 { // Empty structure type?
2819 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2824 #line 1299 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2826 std::vector<const Type*> Elements;
2827 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
2828 E = yyvsp[-2].TypeList->end(); I != E; ++I)
2829 Elements.push_back(*I);
2831 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
2832 delete yyvsp[-2].TypeList;
2837 #line 1309 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2838 { // Empty structure type?
2839 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
2844 #line 1316 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2846 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
2847 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
2851 #line 1323 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2853 if (!UpRefs.empty())
2854 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2855 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
2856 GEN_ERROR("LLVM functions cannot return aggregate types!");
2857 yyval.TypeVal = yyvsp[0].TypeVal;
2861 #line 1330 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2863 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
2867 #line 1335 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2869 yyval.TypeWithAttrsList = new TypeWithAttrsList();
2870 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
2875 #line 1340 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2877 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
2882 #line 1348 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2884 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
2885 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
2886 TWA.Ty = new PATypeHolder(Type::VoidTy);
2887 yyval.TypeWithAttrsList->push_back(TWA);
2892 #line 1355 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2894 yyval.TypeWithAttrsList = new TypeWithAttrsList;
2895 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
2896 TWA.Ty = new PATypeHolder(Type::VoidTy);
2897 yyval.TypeWithAttrsList->push_back(TWA);
2902 #line 1362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2904 yyval.TypeWithAttrsList = new TypeWithAttrsList();
2909 #line 1370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2911 yyval.TypeList = new std::list<PATypeHolder>();
2912 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2917 #line 1375 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2919 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2924 #line 1386 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2925 { // Nonempty unsized arr
2926 if (!UpRefs.empty())
2927 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
2928 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2930 GEN_ERROR("Cannot make array constant with type: '" +
2931 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2932 const Type *ETy = ATy->getElementType();
2933 int NumElements = ATy->getNumElements();
2935 // Verify that we have the correct size...
2936 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2937 GEN_ERROR("Type mismatch: constant sized array initialized with " +
2938 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2939 itostr(NumElements) + "!");
2941 // Verify all elements are correct type!
2942 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2943 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2944 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
2945 ETy->getDescription() +"' as required!\nIt is of type '"+
2946 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2949 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2950 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2955 #line 1414 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2957 if (!UpRefs.empty())
2958 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
2959 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2961 GEN_ERROR("Cannot make array constant with type: '" +
2962 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2964 int NumElements = ATy->getNumElements();
2965 if (NumElements != -1 && NumElements != 0)
2966 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
2967 " arguments, but has size of " + itostr(NumElements) +"!");
2968 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2969 delete yyvsp[-2].TypeVal;
2974 #line 1430 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2976 if (!UpRefs.empty())
2977 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
2978 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2980 GEN_ERROR("Cannot make array constant with type: '" +
2981 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2983 int NumElements = ATy->getNumElements();
2984 const Type *ETy = ATy->getElementType();
2985 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2986 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2987 GEN_ERROR("Can't build string constant of size " +
2988 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2989 " when array has size " + itostr(NumElements) + "!");
2990 std::vector<Constant*> Vals;
2991 if (ETy == Type::Int8Ty) {
2992 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2993 C != (unsigned char*)EndStr; ++C)
2994 Vals.push_back(ConstantInt::get(ETy, *C));
2996 free(yyvsp[0].StrVal);
2997 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
2999 free(yyvsp[0].StrVal);
3000 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3001 delete yyvsp[-2].TypeVal;
3006 #line 1459 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3007 { // Nonempty unsized arr
3008 if (!UpRefs.empty())
3009 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3010 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
3012 GEN_ERROR("Cannot make packed constant with type: '" +
3013 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
3014 const Type *ETy = PTy->getElementType();
3015 int NumElements = PTy->getNumElements();
3017 // Verify that we have the correct size...
3018 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
3019 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
3020 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
3021 itostr(NumElements) + "!");
3023 // Verify all elements are correct type!
3024 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3025 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3026 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3027 ETy->getDescription() +"' as required!\nIt is of type '"+
3028 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3031 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
3032 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3037 #line 1487 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3039 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
3041 GEN_ERROR("Cannot make struct constant with type: '" +
3042 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
3044 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
3045 GEN_ERROR("Illegal number of initializers for structure type!");
3047 // Check to ensure that constants are compatible with the type initializer!
3048 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3049 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
3050 GEN_ERROR("Expected type '" +
3051 STy->getElementType(i)->getDescription() +
3052 "' for element #" + utostr(i) +
3053 " of structure initializer!");
3055 // Check to ensure that Type is not packed
3056 if (STy->isPacked())
3057 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3059 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3060 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3065 #line 1512 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3067 if (!UpRefs.empty())
3068 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3069 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
3071 GEN_ERROR("Cannot make struct constant with type: '" +
3072 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
3074 if (STy->getNumContainedTypes() != 0)
3075 GEN_ERROR("Illegal number of initializers for structure type!");
3077 // Check to ensure that Type is not packed
3078 if (STy->isPacked())
3079 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3081 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3082 delete yyvsp[-2].TypeVal;
3087 #line 1531 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3089 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
3091 GEN_ERROR("Cannot make struct constant with type: '" +
3092 (*yyvsp[-5].TypeVal)->getDescription() + "'!");
3094 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
3095 GEN_ERROR("Illegal number of initializers for structure type!");
3097 // Check to ensure that constants are compatible with the type initializer!
3098 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3099 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
3100 GEN_ERROR("Expected type '" +
3101 STy->getElementType(i)->getDescription() +
3102 "' for element #" + utostr(i) +
3103 " of structure initializer!");
3105 // Check to ensure that Type is packed
3106 if (!STy->isPacked())
3107 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3109 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3110 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
3115 #line 1556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3117 if (!UpRefs.empty())
3118 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3119 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
3121 GEN_ERROR("Cannot make struct constant with type: '" +
3122 (*yyvsp[-4].TypeVal)->getDescription() + "'!");
3124 if (STy->getNumContainedTypes() != 0)
3125 GEN_ERROR("Illegal number of initializers for structure type!");
3127 // Check to ensure that Type is packed
3128 if (!STy->isPacked())
3129 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3131 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3132 delete yyvsp[-4].TypeVal;
3137 #line 1575 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3139 if (!UpRefs.empty())
3140 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3141 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3143 GEN_ERROR("Cannot make null pointer constant with type: '" +
3144 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
3146 yyval.ConstVal = ConstantPointerNull::get(PTy);
3147 delete yyvsp[-1].TypeVal;
3152 #line 1587 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3154 if (!UpRefs.empty())
3155 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3156 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3157 delete yyvsp[-1].TypeVal;
3162 #line 1594 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3164 if (!UpRefs.empty())
3165 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3166 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3168 GEN_ERROR("Global const reference must be a pointer type!");
3170 // ConstExprs can exist in the body of a function, thus creating
3171 // GlobalValues whenever they refer to a variable. Because we are in
3172 // the context of a function, getValNonImprovising will search the functions
3173 // symbol table instead of the module symbol table for the global symbol,
3174 // which throws things all off. To get around this, we just tell
3175 // getValNonImprovising that we are at global scope here.
3177 Function *SavedCurFn = CurFun.CurrentFunction;
3178 CurFun.CurrentFunction = 0;
3180 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
3183 CurFun.CurrentFunction = SavedCurFn;
3185 // If this is an initializer for a constant pointer, which is referencing a
3186 // (currently) undefined variable, create a stub now that shall be replaced
3187 // in the future with the right type of variable.
3190 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3191 const PointerType *PT = cast<PointerType>(Ty);
3193 // First check to see if the forward references value is already created!
3194 PerModuleInfo::GlobalRefsType::iterator I =
3195 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
3197 if (I != CurModule.GlobalRefs.end()) {
3198 V = I->second; // Placeholder already exists, use it...
3199 yyvsp[0].ValIDVal.destroy();
3202 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
3204 // Create the forward referenced global.
3206 if (const FunctionType *FTy =
3207 dyn_cast<FunctionType>(PT->getElementType())) {
3208 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3209 CurModule.CurrentModule);
3211 GV = new GlobalVariable(PT->getElementType(), false,
3212 GlobalValue::ExternalLinkage, 0,
3213 Name, CurModule.CurrentModule);
3216 // Keep track of the fact that we have a forward ref to recycle it
3217 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
3222 yyval.ConstVal = cast<GlobalValue>(V);
3223 delete yyvsp[-1].TypeVal; // Free the type handle
3228 #line 1657 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3230 if (!UpRefs.empty())
3231 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3232 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
3233 GEN_ERROR("Mismatched types for constant expression: " +
3234 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3235 yyval.ConstVal = yyvsp[0].ConstVal;
3236 delete yyvsp[-1].TypeVal;
3241 #line 1667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3243 if (!UpRefs.empty())
3244 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3245 const Type *Ty = yyvsp[-1].TypeVal->get();
3246 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3247 GEN_ERROR("Cannot create a null initialized value of this type!");
3248 yyval.ConstVal = Constant::getNullValue(Ty);
3249 delete yyvsp[-1].TypeVal;
3254 #line 1677 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3255 { // integral constants
3256 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
3257 GEN_ERROR("Constant value doesn't fit in type!");
3258 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
3263 #line 1683 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3264 { // integral constants
3265 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
3266 GEN_ERROR("Constant value doesn't fit in type!");
3267 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
3272 #line 1689 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3273 { // Boolean constants
3274 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3275 yyval.ConstVal = ConstantInt::getTrue();
3280 #line 1694 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3281 { // Boolean constants
3282 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3283 yyval.ConstVal = ConstantInt::getFalse();
3288 #line 1699 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3289 { // Float & Double constants
3290 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
3291 GEN_ERROR("Floating point constant invalid for type!!");
3292 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
3297 #line 1707 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3299 if (!UpRefs.empty())
3300 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3301 Constant *Val = yyvsp[-3].ConstVal;
3302 const Type *Ty = yyvsp[-1].TypeVal->get();
3303 if (!Val->getType()->isFirstClassType())
3304 GEN_ERROR("cast constant expression from a non-primitive type: '" +
3305 Val->getType()->getDescription() + "'!");
3306 if (!Ty->isFirstClassType())
3307 GEN_ERROR("cast constant expression to a non-primitive type: '" +
3308 Ty->getDescription() + "'!");
3309 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3310 delete yyvsp[-1].TypeVal;
3314 #line 1721 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3316 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
3317 GEN_ERROR("GetElementPtr requires a pointer operand!");
3320 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
3322 GEN_ERROR("Index list invalid for constant getelementptr!");
3324 std::vector<Constant*> IdxVec;
3325 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3326 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
3327 IdxVec.push_back(C);
3329 GEN_ERROR("Indices to constant getelementptr must be constants!");
3331 delete yyvsp[-1].ValueList;
3333 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
3338 #line 1742 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3340 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
3341 GEN_ERROR("Select condition must be of boolean type!");
3342 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3343 GEN_ERROR("Select operand types must match!");
3344 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3349 #line 1750 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3351 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3352 GEN_ERROR("Binary operator types must match!");
3354 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3358 #line 1756 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3360 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3361 GEN_ERROR("Logical operator types must match!");
3362 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3363 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3364 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
3365 GEN_ERROR("Logical operator requires integral operands!");
3367 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3372 #line 1767 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3374 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3375 GEN_ERROR("icmp operand types must match!");
3376 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3380 #line 1772 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3382 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3383 GEN_ERROR("fcmp operand types must match!");
3384 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3388 #line 1777 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3390 if (yyvsp[-1].ConstVal->getType() != Type::Int8Ty)
3391 GEN_ERROR("Shift count for shift constant must be i8 type!");
3392 if (!yyvsp[-3].ConstVal->getType()->isInteger())
3393 GEN_ERROR("Shift constant expression requires integer operand!");
3395 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3400 #line 1786 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3402 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3403 GEN_ERROR("Invalid extractelement operands!");
3404 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3409 #line 1792 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3411 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3412 GEN_ERROR("Invalid insertelement operands!");
3413 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3418 #line 1798 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3420 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3421 GEN_ERROR("Invalid shufflevector operands!");
3422 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3427 #line 1807 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3429 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
3434 #line 1811 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3436 yyval.ConstVector = new std::vector<Constant*>();
3437 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
3442 #line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3443 { yyval.BoolVal = false; ;
3446 #line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3447 { yyval.BoolVal = true; ;
3450 #line 1830 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3452 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
3453 CurModule.ModuleDone();
3458 #line 1835 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3460 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
3461 CurModule.ModuleDone();
3466 #line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3467 { CurFun.isDeclare = false ;
3470 #line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3472 CurFun.FunctionDone();
3477 #line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3478 { CurFun.isDeclare = true; ;
3481 #line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3487 #line 1855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3493 #line 1858 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3495 // Emit an error if there are any unresolved types left.
3496 if (!CurModule.LateResolveTypes.empty()) {
3497 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
3498 if (DID.Type == ValID::NameVal) {
3499 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3501 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3508 #line 1870 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3510 if (!UpRefs.empty())
3511 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3512 // Eagerly resolve types. This is not an optimization, this is a
3513 // requirement that is due to the fact that we could have this:
3515 // %list = type { %list * }
3516 // %list = type { %list * } ; repeated type decl
3518 // If types are not resolved eagerly, then the two types will not be
3519 // determined to be the same type!
3521 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3523 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3525 // If this is a named type that is not a redefinition, add it to the slot
3527 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3530 delete yyvsp[0].TypeVal;
3535 #line 1894 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3537 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
3539 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3541 // If this is a named type that is not a redefinition, add it to the slot
3543 CurModule.Types.push_back(yyvsp[0].PrimType);
3549 #line 1905 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3550 { /* "Externally Visible" Linkage */
3551 if (yyvsp[0].ConstVal == 0)
3552 GEN_ERROR("Global value initializer is not a constant!");
3553 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3554 yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3559 #line 1911 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3565 #line 1914 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3567 if (yyvsp[0].ConstVal == 0)
3568 GEN_ERROR("Global value initializer is not a constant!");
3569 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3574 #line 1919 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3580 #line 1922 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3582 if (!UpRefs.empty())
3583 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3584 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3586 delete yyvsp[0].TypeVal;
3590 #line 1928 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3597 #line 1932 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3603 #line 1935 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3609 #line 1941 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3611 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3612 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3613 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3614 free(yyvsp[0].StrVal);
3616 if (AsmSoFar.empty())
3617 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3619 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
3624 #line 1954 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3625 { yyval.Endianness = Module::BigEndian; ;
3628 #line 1955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3629 { yyval.Endianness = Module::LittleEndian; ;
3632 #line 1957 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3634 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3639 #line 1961 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3641 if (yyvsp[0].UInt64Val == 32)
3642 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3643 else if (yyvsp[0].UInt64Val == 64)
3644 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3646 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3651 #line 1970 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3653 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3654 free(yyvsp[0].StrVal);
3658 #line 1974 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3660 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
3661 free(yyvsp[0].StrVal);
3665 #line 1981 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3667 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3668 free(yyvsp[0].StrVal);
3673 #line 1986 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3675 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3676 free(yyvsp[0].StrVal);
3681 #line 1991 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3687 #line 2001 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3688 { yyval.StrVal = 0; ;
3691 #line 2003 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3693 if (!UpRefs.empty())
3694 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3695 if (*yyvsp[-2].TypeVal == Type::VoidTy)
3696 GEN_ERROR("void typed arguments are invalid!");
3697 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3698 yyval.ArgList = yyvsp[-4].ArgList;
3699 yyvsp[-4].ArgList->push_back(E);
3704 #line 2013 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3706 if (!UpRefs.empty())
3707 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3708 if (*yyvsp[-2].TypeVal == Type::VoidTy)
3709 GEN_ERROR("void typed arguments are invalid!");
3710 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3711 yyval.ArgList = new ArgListType;
3712 yyval.ArgList->push_back(E);
3717 #line 2024 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3719 yyval.ArgList = yyvsp[0].ArgList;
3724 #line 2028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3726 yyval.ArgList = yyvsp[-2].ArgList;
3727 struct ArgListEntry E;
3728 E.Ty = new PATypeHolder(Type::VoidTy);
3730 E.Attrs = FunctionType::NoAttributeSet;
3731 yyval.ArgList->push_back(E);
3736 #line 2037 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3738 yyval.ArgList = new ArgListType;
3739 struct ArgListEntry E;
3740 E.Ty = new PATypeHolder(Type::VoidTy);
3742 E.Attrs = FunctionType::NoAttributeSet;
3743 yyval.ArgList->push_back(E);
3748 #line 2046 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3755 #line 2052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3757 UnEscapeLexed(yyvsp[-6].StrVal);
3758 std::string FunctionName(yyvsp[-6].StrVal);
3759 free(yyvsp[-6].StrVal); // Free strdup'd memory!
3761 // Check the function result for abstractness if this is a define. We should
3762 // have no abstract types at this point
3763 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
3764 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
3766 std::vector<const Type*> ParamTypeList;
3767 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
3768 ParamAttrs.push_back(yyvsp[-2].ParamAttrs);
3769 if (yyvsp[-4].ArgList) { // If there are arguments...
3770 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I) {
3771 const Type* Ty = I->Ty->get();
3772 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
3773 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
3774 ParamTypeList.push_back(Ty);
3775 if (Ty != Type::VoidTy)
3776 ParamAttrs.push_back(I->Attrs);
3780 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3781 if (isVarArg) ParamTypeList.pop_back();
3783 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg,
3785 const PointerType *PFT = PointerType::get(FT);
3786 delete yyvsp[-7].TypeVal;
3789 if (!FunctionName.empty()) {
3790 ID = ValID::create((char*)FunctionName.c_str());
3792 ID = ValID::create((int)CurModule.Values[PFT].size());
3796 // See if this function was forward referenced. If so, recycle the object.
3797 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3798 // Move the function to the end of the list, from whereever it was
3799 // previously inserted.
3800 Fn = cast<Function>(FWRef);
3801 CurModule.CurrentModule->getFunctionList().remove(Fn);
3802 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3803 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3804 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3805 // If this is the case, either we need to be a forward decl, or it needs
3807 if (!CurFun.isDeclare && !Fn->isExternal())
3808 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
3810 // Make sure to strip off any argument names so we can't get conflicts.
3811 if (Fn->isExternal())
3812 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3815 } else { // Not already defined?
3816 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3817 CurModule.CurrentModule);
3819 InsertValue(Fn, CurModule.Values);
3822 CurFun.FunctionStart(Fn);
3824 if (CurFun.isDeclare) {
3825 // If we have declaration, always overwrite linkage. This will allow us to
3826 // correctly handle cases, when pointer to function is passed as argument to
3827 // another function.
3828 Fn->setLinkage(CurFun.Linkage);
3829 Fn->setVisibility(CurFun.Visibility);
3831 Fn->setCallingConv(yyvsp[-8].UIntVal);
3832 Fn->setAlignment(yyvsp[0].UIntVal);
3833 if (yyvsp[-1].StrVal) {
3834 Fn->setSection(yyvsp[-1].StrVal);
3835 free(yyvsp[-1].StrVal);
3838 // Add all of the arguments we parsed to the function...
3839 if (yyvsp[-4].ArgList) { // Is null if empty...
3840 if (isVarArg) { // Nuke the last entry
3841 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0&&
3842 "Not a varargs marker!");
3843 delete yyvsp[-4].ArgList->back().Ty;
3844 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
3846 Function::arg_iterator ArgIt = Fn->arg_begin();
3848 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++ArgIt) {
3849 delete I->Ty; // Delete the typeholder...
3850 setValueName(ArgIt, I->Name); // Insert arg into symtab...
3856 delete yyvsp[-4].ArgList; // We're now done with the argument list
3862 #line 2159 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3864 yyval.FunctionVal = CurFun.CurrentFunction;
3866 // Make sure that we keep track of the linkage type even if there was a
3867 // previous "declare".
3868 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
3869 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
3873 #line 2170 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3875 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3880 #line 2175 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3882 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
3883 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
3884 yyval.FunctionVal = CurFun.CurrentFunction;
3885 CurFun.FunctionDone();
3890 #line 2187 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3892 yyval.BoolVal = false;
3897 #line 2191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3899 yyval.BoolVal = true;
3904 #line 2196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3905 { // A reference to a direct constant
3906 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3911 #line 2200 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3913 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3918 #line 2204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3919 { // Perhaps it's an FP constant?
3920 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3925 #line 2208 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3927 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
3932 #line 2212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3934 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
3939 #line 2216 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3941 yyval.ValIDVal = ValID::createNull();
3946 #line 2220 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3948 yyval.ValIDVal = ValID::createUndef();
3953 #line 2224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3954 { // A vector zero constant.
3955 yyval.ValIDVal = ValID::createZeroInit();
3960 #line 2228 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3961 { // Nonempty unsized packed vector
3962 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3963 int NumElements = yyvsp[-1].ConstVector->size();
3965 PackedType* pt = PackedType::get(ETy, NumElements);
3966 PATypeHolder* PTy = new PATypeHolder(
3974 // Verify all elements are correct type!
3975 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3976 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3977 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3978 ETy->getDescription() +"' as required!\nIt is of type '" +
3979 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3982 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3983 delete PTy; delete yyvsp[-1].ConstVector;
3988 #line 2253 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3990 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3995 #line 2257 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3997 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3998 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3999 End = UnEscapeLexed(yyvsp[0].StrVal, true);
4000 std::string Constraints = std::string(yyvsp[0].StrVal, End);
4001 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
4002 free(yyvsp[-2].StrVal);
4003 free(yyvsp[0].StrVal);
4008 #line 2271 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4009 { // Is it an integer reference...?
4010 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
4015 #line 2275 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4016 { // Is it a named reference...?
4017 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
4022 #line 2287 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4024 if (!UpRefs.empty())
4025 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4026 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4027 delete yyvsp[-1].TypeVal;
4032 #line 2296 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4034 yyval.FunctionVal = yyvsp[-1].FunctionVal;
4039 #line 2300 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4040 { // Do not allow functions with 0 basic blocks
4041 yyval.FunctionVal = yyvsp[-1].FunctionVal;
4046 #line 2309 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4048 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
4050 InsertValue(yyvsp[0].TermInstVal);
4052 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4053 InsertValue(yyvsp[-2].BasicBlockVal);
4054 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
4059 #line 2320 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4061 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
4062 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4063 if (CI2->getParent() == 0)
4064 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4065 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4066 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
4071 #line 2329 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4073 yyval.BasicBlockVal = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
4076 // Make sure to move the basic block to the correct location in the
4077 // function, instead of leaving it inserted wherever it was first
4079 Function::BasicBlockListType &BBL =
4080 CurFun.CurrentFunction->getBasicBlockList();
4081 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
4086 #line 2341 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4088 yyval.BasicBlockVal = getBBVal(ValID::create(yyvsp[0].StrVal), true);
4091 // Make sure to move the basic block to the correct location in the
4092 // function, instead of leaving it inserted wherever it was first
4094 Function::BasicBlockListType &BBL =
4095 CurFun.CurrentFunction->getBasicBlockList();
4096 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
4101 #line 2354 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4102 { // Return with a result...
4103 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4108 #line 2358 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4109 { // Return with no result...
4110 yyval.TermInstVal = new ReturnInst();
4115 #line 2362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4116 { // Unconditional Branch...
4117 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4119 yyval.TermInstVal = new BranchInst(tmpBB);
4123 #line 2367 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4125 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4126 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4128 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4130 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4132 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4136 #line 2377 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4138 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4140 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4142 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4143 yyval.TermInstVal = S;
4145 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4146 E = yyvsp[-1].JumpTable->end();
4147 for (; I != E; ++I) {
4148 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4149 S->addCase(CI, I->second);
4151 GEN_ERROR("Switch case is constant, but not a simple integer!");
4153 delete yyvsp[-1].JumpTable;
4158 #line 2396 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4160 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
4162 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
4164 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
4165 yyval.TermInstVal = S;
4170 #line 2406 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4173 // Handle the short syntax
4174 const PointerType *PFTy = 0;
4175 const FunctionType *Ty = 0;
4176 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
4177 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4178 // Pull out the types of all of the arguments...
4179 std::vector<const Type*> ParamTypes;
4180 FunctionType::ParamAttrsList ParamAttrs;
4181 ParamAttrs.push_back(yyvsp[-6].ParamAttrs);
4182 for (ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); I != E; ++I) {
4183 const Type *Ty = I->Val->getType();
4184 if (Ty == Type::VoidTy)
4185 GEN_ERROR("Short call syntax cannot be used with varargs");
4186 ParamTypes.push_back(Ty);
4187 ParamAttrs.push_back(I->Attrs);
4190 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, ParamAttrs);
4191 PFTy = PointerType::get(Ty);
4194 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
4196 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
4198 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
4201 // Check the arguments
4203 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
4204 // Make sure no arguments is a good thing!
4205 if (Ty->getNumParams() != 0)
4206 GEN_ERROR("No arguments passed to a function that "
4207 "expects arguments!");
4208 } else { // Has arguments?
4209 // Loop through FunctionType's arguments and ensure they are specified
4211 FunctionType::param_iterator I = Ty->param_begin();
4212 FunctionType::param_iterator E = Ty->param_end();
4213 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
4215 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4216 if (ArgI->Val->getType() != *I)
4217 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4218 (*I)->getDescription() + "'!");
4219 Args.push_back(ArgI->Val);
4222 if (Ty->isVarArg()) {
4224 for (; ArgI != ArgE; ++ArgI)
4225 Args.push_back(ArgI->Val); // push the remaining varargs
4226 } else if (I != E || ArgI != ArgE)
4227 GEN_ERROR("Invalid number of parameters detected!");
4230 // Create the InvokeInst
4231 InvokeInst *II = new InvokeInst(V, Normal, Except, Args);
4232 II->setCallingConv(yyvsp[-12].UIntVal);
4233 yyval.TermInstVal = II;
4234 delete yyvsp[-8].ValueRefList;
4239 #line 2472 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4241 yyval.TermInstVal = new UnwindInst();
4246 #line 2476 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4248 yyval.TermInstVal = new UnreachableInst();
4253 #line 2483 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4255 yyval.JumpTable = yyvsp[-5].JumpTable;
4256 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4259 GEN_ERROR("May only switch on a constant pool value!");
4261 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4263 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4267 #line 2494 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4269 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4270 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4274 GEN_ERROR("May only switch on a constant pool value!");
4276 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4278 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4282 #line 2507 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4284 // Is this definition named?? if so, assign the name...
4285 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
4287 InsertValue(yyvsp[0].InstVal);
4288 yyval.InstVal = yyvsp[0].InstVal;
4293 #line 2516 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4294 { // Used for PHI nodes
4295 if (!UpRefs.empty())
4296 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4297 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4298 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
4300 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4302 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4303 delete yyvsp[-5].TypeVal;
4307 #line 2527 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4309 yyval.PHIList = yyvsp[-6].PHIList;
4310 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
4312 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4314 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4318 #line 2537 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4320 if (!UpRefs.empty())
4321 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4322 // Used for call and invoke instructions
4323 yyval.ValueRefList = new ValueRefList();
4324 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4325 yyval.ValueRefList->push_back(E);
4329 #line 2545 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4331 if (!UpRefs.empty())
4332 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4333 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4334 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4335 yyval.ValueRefList->push_back(E);
4340 #line 2553 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4341 { yyval.ValueRefList = new ValueRefList(); ;
4344 #line 2556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4345 { yyval.ValueList = new std::vector<Value*>(); ;
4348 #line 2557 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4350 yyval.ValueList = yyvsp[-2].ValueList;
4351 yyval.ValueList->push_back(yyvsp[0].ValueVal);
4356 #line 2564 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4358 yyval.BoolVal = true;
4363 #line 2568 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4365 yyval.BoolVal = false;
4370 #line 2573 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4372 if (!UpRefs.empty())
4373 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4374 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4375 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4377 "Arithmetic operator requires integer, FP, or packed operands!");
4378 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) &&
4379 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4380 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4381 yyvsp[-4].BinaryOpVal == Instruction::FRem))
4382 GEN_ERROR("U/S/FRem not supported on packed types!");
4383 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4385 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4387 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4388 if (yyval.InstVal == 0)
4389 GEN_ERROR("binary operator returned null!");
4390 delete yyvsp[-3].TypeVal;
4394 #line 2594 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4396 if (!UpRefs.empty())
4397 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4398 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4399 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
4400 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
4401 GEN_ERROR("Logical operator requires integral operands!");
4403 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4405 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4407 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4408 if (yyval.InstVal == 0)
4409 GEN_ERROR("binary operator returned null!");
4410 delete yyvsp[-3].TypeVal;
4414 #line 2611 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4416 if (!UpRefs.empty())
4417 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4418 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4419 GEN_ERROR("Packed types not supported by icmp instruction");
4420 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4422 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4424 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4425 if (yyval.InstVal == 0)
4426 GEN_ERROR("icmp operator returned null!");
4430 #line 2624 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4432 if (!UpRefs.empty())
4433 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4434 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4435 GEN_ERROR("Packed types not supported by fcmp instruction");
4436 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4438 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4440 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4441 if (yyval.InstVal == 0)
4442 GEN_ERROR("fcmp operator returned null!");
4446 #line 2637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4448 if (yyvsp[0].ValueVal->getType() != Type::Int8Ty)
4449 GEN_ERROR("Shift amount must be i8 type!");
4450 if (!yyvsp[-2].ValueVal->getType()->isInteger())
4451 GEN_ERROR("Shift constant expression requires integer operand!");
4453 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4458 #line 2646 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4460 if (!UpRefs.empty())
4461 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4462 Value* Val = yyvsp[-2].ValueVal;
4463 const Type* Ty = yyvsp[0].TypeVal->get();
4464 if (!Val->getType()->isFirstClassType())
4465 GEN_ERROR("cast from a non-primitive type: '" +
4466 Val->getType()->getDescription() + "'!");
4467 if (!Ty->isFirstClassType())
4468 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
4469 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, yyvsp[0].TypeVal->get());
4470 delete yyvsp[0].TypeVal;
4474 #line 2659 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4476 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
4477 GEN_ERROR("select condition must be boolean!");
4478 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
4479 GEN_ERROR("select value types should match!");
4480 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4485 #line 2667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4487 if (!UpRefs.empty())
4488 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4489 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4490 delete yyvsp[0].TypeVal;
4495 #line 2674 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4497 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4498 GEN_ERROR("Invalid extractelement operands!");
4499 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4504 #line 2680 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4506 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4507 GEN_ERROR("Invalid insertelement operands!");
4508 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4513 #line 2686 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4515 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4516 GEN_ERROR("Invalid shufflevector operands!");
4517 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4522 #line 2692 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4524 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
4525 if (!Ty->isFirstClassType())
4526 GEN_ERROR("PHI node operands must be of first class type!");
4527 yyval.InstVal = new PHINode(Ty);
4528 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4529 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4530 if (yyvsp[0].PHIList->front().first->getType() != Ty)
4531 GEN_ERROR("All elements of a PHI node must be of the same type!");
4532 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4533 yyvsp[0].PHIList->pop_front();
4535 delete yyvsp[0].PHIList; // Free the list...
4540 #line 2708 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4543 // Handle the short syntax
4544 const PointerType *PFTy = 0;
4545 const FunctionType *Ty = 0;
4546 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
4547 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4548 // Pull out the types of all of the arguments...
4549 std::vector<const Type*> ParamTypes;
4550 FunctionType::ParamAttrsList ParamAttrs;
4551 ParamAttrs.push_back(yyvsp[0].ParamAttrs);
4552 for (ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); I != E; ++I) {
4553 const Type *Ty = I->Val->getType();
4554 if (Ty == Type::VoidTy)
4555 GEN_ERROR("Short call syntax cannot be used with varargs");
4556 ParamTypes.push_back(Ty);
4557 ParamAttrs.push_back(I->Attrs);
4560 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, ParamAttrs);
4561 PFTy = PointerType::get(Ty);
4564 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
4567 // Check the arguments
4569 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
4570 // Make sure no arguments is a good thing!
4571 if (Ty->getNumParams() != 0)
4572 GEN_ERROR("No arguments passed to a function that "
4573 "expects arguments!");
4574 } else { // Has arguments?
4575 // Loop through FunctionType's arguments and ensure they are specified
4578 FunctionType::param_iterator I = Ty->param_begin();
4579 FunctionType::param_iterator E = Ty->param_end();
4580 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
4582 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4583 if (ArgI->Val->getType() != *I)
4584 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4585 (*I)->getDescription() + "'!");
4586 Args.push_back(ArgI->Val);
4588 if (Ty->isVarArg()) {
4590 for (; ArgI != ArgE; ++ArgI)
4591 Args.push_back(ArgI->Val); // push the remaining varargs
4592 } else if (I != E || ArgI != ArgE)
4593 GEN_ERROR("Invalid number of parameters detected!");
4595 // Create the call node
4596 CallInst *CI = new CallInst(V, Args);
4597 CI->setTailCall(yyvsp[-7].BoolVal);
4598 CI->setCallingConv(yyvsp[-6].UIntVal);
4600 delete yyvsp[-2].ValueRefList;
4605 #line 2770 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4607 yyval.InstVal = yyvsp[0].InstVal;
4612 #line 2775 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4614 yyval.BoolVal = true;
4619 #line 2779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4621 yyval.BoolVal = false;
4626 #line 2786 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4628 if (!UpRefs.empty())
4629 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4630 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4631 delete yyvsp[-1].TypeVal;
4636 #line 2793 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4638 if (!UpRefs.empty())
4639 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4640 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4642 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4643 delete yyvsp[-4].TypeVal;
4647 #line 2801 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4649 if (!UpRefs.empty())
4650 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4651 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4652 delete yyvsp[-1].TypeVal;
4657 #line 2808 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4659 if (!UpRefs.empty())
4660 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4661 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4663 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4664 delete yyvsp[-4].TypeVal;
4668 #line 2816 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4670 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
4671 GEN_ERROR("Trying to free nonpointer type " +
4672 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4673 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
4678 #line 2824 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4680 if (!UpRefs.empty())
4681 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4682 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4683 GEN_ERROR("Can't load from nonpointer type: " +
4684 (*yyvsp[-1].TypeVal)->getDescription());
4685 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4686 GEN_ERROR("Can't load from pointer of non-first-class type: " +
4687 (*yyvsp[-1].TypeVal)->getDescription());
4688 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4690 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
4691 delete yyvsp[-1].TypeVal;
4695 #line 2838 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4697 if (!UpRefs.empty())
4698 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4699 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4701 GEN_ERROR("Can't store to a nonpointer type: " +
4702 (*yyvsp[-1].TypeVal)->getDescription());
4703 const Type *ElTy = PT->getElementType();
4704 if (ElTy != yyvsp[-3].ValueVal->getType())
4705 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4706 "' into space of type '" + ElTy->getDescription() + "'!");
4708 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4710 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
4711 delete yyvsp[-1].TypeVal;
4715 #line 2855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4717 if (!UpRefs.empty())
4718 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4719 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4720 GEN_ERROR("getelementptr insn requires pointer operand!");
4722 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4723 GEN_ERROR("Invalid getelementptr indices for type '" +
4724 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4725 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
4727 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
4728 delete yyvsp[-2].TypeVal;
4729 delete yyvsp[0].ValueList;
4733 /* the action file gets copied in in place of this dollarsign */
4734 #line 543 "/usr/share/bison.simple"
4745 short *ssp1 = yyss - 1;
4746 fprintf (stderr, "state stack now");
4747 while (ssp1 != yyssp)
4748 fprintf (stderr, " %d", *++ssp1);
4749 fprintf (stderr, "\n");
4759 yylsp->first_line = yylloc.first_line;
4760 yylsp->first_column = yylloc.first_column;
4761 yylsp->last_line = (yylsp-1)->last_line;
4762 yylsp->last_column = (yylsp-1)->last_column;
4767 yylsp->last_line = (yylsp+yylen-1)->last_line;
4768 yylsp->last_column = (yylsp+yylen-1)->last_column;
4772 /* Now "shift" the result of the reduction.
4773 Determine what state that goes to,
4774 based on the state we popped back to
4775 and the rule number reduced by. */
4779 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4780 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4781 yystate = yytable[yystate];
4783 yystate = yydefgoto[yyn - YYNTBASE];
4787 yyerrlab: /* here on detecting error */
4790 /* If not already recovering from an error, report this error. */
4794 #ifdef YYERROR_VERBOSE
4795 yyn = yypact[yystate];
4797 if (yyn > YYFLAG && yyn < YYLAST)
4804 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4805 for (x = (yyn < 0 ? -yyn : 0);
4806 x < (sizeof(yytname) / sizeof(char *)); x++)
4807 if (yycheck[x + yyn] == x)
4808 size += strlen(yytname[x]) + 15, count++;
4809 msg = (char *) malloc(size + 15);
4812 strcpy(msg, "parse error");
4817 for (x = (yyn < 0 ? -yyn : 0);
4818 x < (sizeof(yytname) / sizeof(char *)); x++)
4819 if (yycheck[x + yyn] == x)
4821 strcat(msg, count == 0 ? ", expecting `" : " or `");
4822 strcat(msg, yytname[x]);
4831 yyerror ("parse error; also virtual memory exceeded");
4834 #endif /* YYERROR_VERBOSE */
4835 yyerror("parse error");
4839 yyerrlab1: /* here on error raised explicitly by an action */
4841 if (yyerrstatus == 3)
4843 /* if just tried and failed to reuse lookahead token after an error, discard it. */
4845 /* return failure if at end of input */
4846 if (yychar == YYEOF)
4851 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4857 /* Else will try to reuse lookahead token
4858 after shifting the error token. */
4860 yyerrstatus = 3; /* Each real token shifted decrements this */
4864 yyerrdefault: /* current state does not do anything special for the error token. */
4867 /* This is wrong; only states that explicitly want error tokens
4868 should shift them. */
4869 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4870 if (yyn) goto yydefault;
4873 yyerrpop: /* pop the current state because it cannot handle the error token */
4875 if (yyssp == yyss) YYABORT;
4885 short *ssp1 = yyss - 1;
4886 fprintf (stderr, "Error: state stack now");
4887 while (ssp1 != yyssp)
4888 fprintf (stderr, " %d", *++ssp1);
4889 fprintf (stderr, "\n");
4895 yyn = yypact[yystate];
4900 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4919 fprintf(stderr, "Shifting error token, ");
4931 /* YYACCEPT comes here. */
4943 /* YYABORT comes here. */
4954 #line 2872 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4957 // common code from the two 'RunVMAsmParser' functions
4958 static Module* RunParser(Module * M) {
4960 llvmAsmlineno = 1; // Reset the current line number...
4961 CurModule.CurrentModule = M;
4966 // Check to make sure the parser succeeded
4969 delete ParserResult;
4973 // Check to make sure that parsing produced a result
4977 // Reset ParserResult variable while saving its value for the result.
4978 Module *Result = ParserResult;
4984 void llvm::GenerateError(const std::string &message, int LineNo) {
4985 if (LineNo == -1) LineNo = llvmAsmlineno;
4986 // TODO: column number in exception
4988 TheParseError->setError(CurFilename, message, LineNo);
4992 int yyerror(const char *ErrorMsg) {
4994 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4995 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4996 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4997 if (yychar == YYEMPTY || yychar == 0)
4998 errMsg += "end-of-file.";
5000 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
5001 GenerateError(errMsg);