2 /* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL 257
15 #define EUINT64VAL 258
28 #define STRINGCONSTANT 271
29 #define IMPLEMENTATION 272
30 #define ZEROINITIALIZER 273
51 #define EXTERN_WEAK 294
57 #define POINTERSIZE 300
66 #define SIDEEFFECT 309
69 #define CSRETCC_TOK 312
70 #define FASTCC_TOK 313
71 #define COLDCC_TOK 314
72 #define X86_STDCALLCC_TOK 315
73 #define X86_FASTCALLCC_TOK 316
74 #define DATALAYOUT 317
80 #define UNREACHABLE 323
120 #define GETELEMENTPTR 363
139 #define EXTRACTELEMENT 382
140 #define INSERTELEMENT 383
141 #define SHUFFLEVECTOR 384
144 #line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
146 #include "ParserInternals.h"
147 #include "llvm/CallingConv.h"
148 #include "llvm/InlineAsm.h"
149 #include "llvm/Instructions.h"
150 #include "llvm/Module.h"
151 #include "llvm/SymbolTable.h"
152 #include "llvm/Support/GetElementPtrTypeIterator.h"
153 #include "llvm/Support/CommandLine.h"
154 #include "llvm/ADT/STLExtras.h"
155 #include "llvm/Support/MathExtras.h"
156 #include "llvm/Support/Streams.h"
164 // The following is a gross hack. In order to rid the libAsmParser library of
165 // exceptions, we have to have a way of getting the yyparse function to go into
166 // an error situation. So, whenever we want an error to occur, the GenerateError
167 // function (see bottom of file) sets TriggerError. Then, at the end of each
168 // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
169 // (a goto) to put YACC in error state. Furthermore, several calls to
170 // GenerateError are made from inside productions and they must simulate the
171 // previous exception behavior by exiting the production immediately. We have
172 // replaced these with the GEN_ERROR macro which calls GeneratError and then
173 // immediately invokes YYERROR. This would be so much cleaner if it was a
174 // recursive descent parser.
175 static bool TriggerError = false;
176 #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
177 #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
179 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
180 int yylex(); // declaration" of xxx warnings.
184 std::string CurFilename;
187 Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
188 cl::Hidden, cl::init(false));
191 using namespace llvm;
193 static Module *ParserResult;
195 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
196 // relating to upreferences in the input stream.
198 //#define DEBUG_UPREFS 1
200 #define UR_OUT(X) cerr << X
205 #define YYERROR_VERBOSE 1
207 static GlobalVariable *CurGV;
210 // This contains info used when building the body of a function. It is
211 // destroyed when the function is completed.
213 typedef std::vector<Value *> ValueList; // Numbered defs
216 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
217 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
219 static struct PerModuleInfo {
220 Module *CurrentModule;
221 std::map<const Type *, ValueList> Values; // Module level numbered definitions
222 std::map<const Type *,ValueList> LateResolveValues;
223 std::vector<PATypeHolder> Types;
224 std::map<ValID, PATypeHolder> LateResolveTypes;
226 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
227 /// how they were referenced and on which line of the input they came from so
228 /// that we can resolve them later and print error messages as appropriate.
229 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
231 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
232 // references to global values. Global values may be referenced before they
233 // are defined, and if so, the temporary object that they represent is held
234 // here. This is used for forward references of GlobalValues.
236 typedef std::map<std::pair<const PointerType *,
237 ValID>, GlobalValue*> GlobalRefsType;
238 GlobalRefsType GlobalRefs;
241 // If we could not resolve some functions at function compilation time
242 // (calls to functions before they are defined), resolve them now... Types
243 // are resolved when the constant pool has been completely parsed.
245 ResolveDefinitions(LateResolveValues);
249 // Check to make sure that all global value forward references have been
252 if (!GlobalRefs.empty()) {
253 std::string UndefinedReferences = "Unresolved global references exist:\n";
255 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
257 UndefinedReferences += " " + I->first.first->getDescription() + " " +
258 I->first.second.getName() + "\n";
260 GenerateError(UndefinedReferences);
264 Values.clear(); // Clear out function local definitions
269 // GetForwardRefForGlobal - Check to see if there is a forward reference
270 // for this global. If so, remove it from the GlobalRefs map and return it.
271 // If not, just return null.
272 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
273 // Check to see if there is a forward reference to this global variable...
274 // if there is, eliminate it and patch the reference to use the new def'n.
275 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
276 GlobalValue *Ret = 0;
277 if (I != GlobalRefs.end()) {
284 bool TypeIsUnresolved(PATypeHolder* PATy) {
285 // If it isn't abstract, its resolved
286 const Type* Ty = PATy->get();
287 if (!Ty->isAbstract())
289 // Traverse the type looking for abstract types. If it isn't abstract then
290 // we don't need to traverse that leg of the type.
291 std::vector<const Type*> WorkList, SeenList;
292 WorkList.push_back(Ty);
293 while (!WorkList.empty()) {
294 const Type* Ty = WorkList.back();
295 SeenList.push_back(Ty);
297 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
298 // Check to see if this is an unresolved type
299 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
300 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
301 for ( ; I != E; ++I) {
302 if (I->second.get() == OpTy)
305 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
306 const Type* TheTy = SeqTy->getElementType();
307 if (TheTy->isAbstract() && TheTy != Ty) {
308 std::vector<const Type*>::iterator I = SeenList.begin(),
314 WorkList.push_back(TheTy);
316 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
317 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
318 const Type* TheTy = StrTy->getElementType(i);
319 if (TheTy->isAbstract() && TheTy != Ty) {
320 std::vector<const Type*>::iterator I = SeenList.begin(),
326 WorkList.push_back(TheTy);
337 static struct PerFunctionInfo {
338 Function *CurrentFunction; // Pointer to current function being created
340 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
341 std::map<const Type*, ValueList> LateResolveValues;
342 bool isDeclare; // Is this function a forward declararation?
343 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
345 /// BBForwardRefs - When we see forward references to basic blocks, keep
346 /// track of them here.
347 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
348 std::vector<BasicBlock*> NumberedBlocks;
351 inline PerFunctionInfo() {
354 Linkage = GlobalValue::ExternalLinkage;
357 inline void FunctionStart(Function *M) {
362 void FunctionDone() {
363 NumberedBlocks.clear();
365 // Any forward referenced blocks left?
366 if (!BBForwardRefs.empty()) {
367 GenerateError("Undefined reference to label " +
368 BBForwardRefs.begin()->first->getName());
372 // Resolve all forward references now.
373 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
375 Values.clear(); // Clear out function local definitions
378 Linkage = GlobalValue::ExternalLinkage;
380 } CurFun; // Info for the current function...
382 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
385 //===----------------------------------------------------------------------===//
386 // Code to handle definitions of all the types
387 //===----------------------------------------------------------------------===//
389 static int InsertValue(Value *V,
390 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
391 if (V->hasName()) return -1; // Is this a numbered definition?
393 // Yes, insert the value into the value table...
394 ValueList &List = ValueTab[V->getType()];
396 return List.size()-1;
399 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
401 case ValID::NumberVal: // Is it a numbered definition?
402 // Module constants occupy the lowest numbered slots...
403 if ((unsigned)D.Num < CurModule.Types.size())
404 return CurModule.Types[(unsigned)D.Num];
406 case ValID::NameVal: // Is it a named definition?
407 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
408 D.destroy(); // Free old strdup'd memory...
413 GenerateError("Internal parser error: Invalid symbol type reference!");
417 // If we reached here, we referenced either a symbol that we don't know about
418 // or an id number that hasn't been read yet. We may be referencing something
419 // forward, so just create an entry to be resolved later and get to it...
421 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
424 if (inFunctionScope()) {
425 if (D.Type == ValID::NameVal) {
426 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
429 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
434 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
435 if (I != CurModule.LateResolveTypes.end())
438 Type *Typ = OpaqueType::get();
439 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
443 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
444 SymbolTable &SymTab =
445 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
446 CurModule.CurrentModule->getValueSymbolTable();
447 return SymTab.lookup(Ty, Name);
450 // getValNonImprovising - Look up the value specified by the provided type and
451 // the provided ValID. If the value exists and has already been defined, return
452 // it. Otherwise return null.
454 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
455 if (isa<FunctionType>(Ty)) {
456 GenerateError("Functions are not values and "
457 "must be referenced as pointers");
462 case ValID::NumberVal: { // Is it a numbered definition?
463 unsigned Num = (unsigned)D.Num;
465 // Module constants occupy the lowest numbered slots...
466 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
467 if (VI != CurModule.Values.end()) {
468 if (Num < VI->second.size())
469 return VI->second[Num];
470 Num -= VI->second.size();
473 // Make sure that our type is within bounds
474 VI = CurFun.Values.find(Ty);
475 if (VI == CurFun.Values.end()) return 0;
477 // Check that the number is within bounds...
478 if (VI->second.size() <= Num) return 0;
480 return VI->second[Num];
483 case ValID::NameVal: { // Is it a named definition?
484 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
485 if (N == 0) return 0;
487 D.destroy(); // Free old strdup'd memory...
491 // Check to make sure that "Ty" is an integral type, and that our
492 // value will fit into the specified type...
493 case ValID::ConstSIntVal: // Is it a constant pool reference??
494 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
495 GenerateError("Signed integral constant '" +
496 itostr(D.ConstPool64) + "' is invalid for type '" +
497 Ty->getDescription() + "'!");
500 return ConstantInt::get(Ty, D.ConstPool64);
502 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
503 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
504 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
505 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
506 "' is invalid or out of range!");
508 } else { // This is really a signed reference. Transmogrify.
509 return ConstantInt::get(Ty, D.ConstPool64);
512 return ConstantInt::get(Ty, D.UConstPool64);
515 case ValID::ConstFPVal: // Is it a floating point const pool reference?
516 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
517 GenerateError("FP constant invalid for type!!");
520 return ConstantFP::get(Ty, D.ConstPoolFP);
522 case ValID::ConstNullVal: // Is it a null value?
523 if (!isa<PointerType>(Ty)) {
524 GenerateError("Cannot create a a non pointer null!");
527 return ConstantPointerNull::get(cast<PointerType>(Ty));
529 case ValID::ConstUndefVal: // Is it an undef value?
530 return UndefValue::get(Ty);
532 case ValID::ConstZeroVal: // Is it a zero value?
533 return Constant::getNullValue(Ty);
535 case ValID::ConstantVal: // Fully resolved constant?
536 if (D.ConstantValue->getType() != Ty) {
537 GenerateError("Constant expression type different from required type!");
540 return D.ConstantValue;
542 case ValID::InlineAsmVal: { // Inline asm expression
543 const PointerType *PTy = dyn_cast<PointerType>(Ty);
544 const FunctionType *FTy =
545 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
546 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
547 GenerateError("Invalid type for asm constraint string!");
550 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
551 D.IAD->HasSideEffects);
552 D.destroy(); // Free InlineAsmDescriptor.
556 assert(0 && "Unhandled case!");
560 assert(0 && "Unhandled case!");
564 // getVal - This function is identical to getValNonImprovising, except that if a
565 // value is not already defined, it "improvises" by creating a placeholder var
566 // that looks and acts just like the requested variable. When the value is
567 // defined later, all uses of the placeholder variable are replaced with the
570 static Value *getVal(const Type *Ty, const ValID &ID) {
571 if (Ty == Type::LabelTy) {
572 GenerateError("Cannot use a basic block here");
576 // See if the value has already been defined.
577 Value *V = getValNonImprovising(Ty, ID);
579 if (TriggerError) return 0;
581 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
582 GenerateError("Invalid use of a composite type!");
586 // If we reached here, we referenced either a symbol that we don't know about
587 // or an id number that hasn't been read yet. We may be referencing something
588 // forward, so just create an entry to be resolved later and get to it...
590 V = new Argument(Ty);
592 // Remember where this forward reference came from. FIXME, shouldn't we try
593 // to recycle these things??
594 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
597 if (inFunctionScope())
598 InsertValue(V, CurFun.LateResolveValues);
600 InsertValue(V, CurModule.LateResolveValues);
604 /// getBBVal - This is used for two purposes:
605 /// * If isDefinition is true, a new basic block with the specified ID is being
607 /// * If isDefinition is true, this is a reference to a basic block, which may
608 /// or may not be a forward reference.
610 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
611 assert(inFunctionScope() && "Can't get basic block at global scope!");
617 GenerateError("Illegal label reference " + ID.getName());
619 case ValID::NumberVal: // Is it a numbered definition?
620 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
621 CurFun.NumberedBlocks.resize(ID.Num+1);
622 BB = CurFun.NumberedBlocks[ID.Num];
624 case ValID::NameVal: // Is it a named definition?
626 if (Value *N = CurFun.CurrentFunction->
627 getValueSymbolTable().lookup(Type::LabelTy, Name))
628 BB = cast<BasicBlock>(N);
632 // See if the block has already been defined.
634 // If this is the definition of the block, make sure the existing value was
635 // just a forward reference. If it was a forward reference, there will be
636 // an entry for it in the PlaceHolderInfo map.
637 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
638 // The existing value was a definition, not a forward reference.
639 GenerateError("Redefinition of label " + ID.getName());
643 ID.destroy(); // Free strdup'd memory.
647 // Otherwise this block has not been seen before.
648 BB = new BasicBlock("", CurFun.CurrentFunction);
649 if (ID.Type == ValID::NameVal) {
650 BB->setName(ID.Name);
652 CurFun.NumberedBlocks[ID.Num] = BB;
655 // If this is not a definition, keep track of it so we can use it as a forward
658 // Remember where this forward reference came from.
659 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
661 // The forward declaration could have been inserted anywhere in the
662 // function: insert it into the correct place now.
663 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
664 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
671 //===----------------------------------------------------------------------===//
672 // Code to handle forward references in instructions
673 //===----------------------------------------------------------------------===//
675 // This code handles the late binding needed with statements that reference
676 // values not defined yet... for example, a forward branch, or the PHI node for
679 // This keeps a table (CurFun.LateResolveValues) of all such forward references
680 // and back patchs after we are done.
683 // ResolveDefinitions - If we could not resolve some defs at parsing
684 // time (forward branches, phi functions for loops, etc...) resolve the
688 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
689 std::map<const Type*,ValueList> *FutureLateResolvers) {
690 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
691 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
692 E = LateResolvers.end(); LRI != E; ++LRI) {
693 ValueList &List = LRI->second;
694 while (!List.empty()) {
695 Value *V = List.back();
698 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
699 CurModule.PlaceHolderInfo.find(V);
700 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
702 ValID &DID = PHI->second.first;
704 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
708 V->replaceAllUsesWith(TheRealValue);
710 CurModule.PlaceHolderInfo.erase(PHI);
711 } else if (FutureLateResolvers) {
712 // Functions have their unresolved items forwarded to the module late
714 InsertValue(V, *FutureLateResolvers);
716 if (DID.Type == ValID::NameVal) {
717 GenerateError("Reference to an invalid definition: '" +DID.getName()+
718 "' of type '" + V->getType()->getDescription() + "'",
722 GenerateError("Reference to an invalid definition: #" +
723 itostr(DID.Num) + " of type '" +
724 V->getType()->getDescription() + "'",
732 LateResolvers.clear();
735 // ResolveTypeTo - A brand new type was just declared. This means that (if
736 // name is not null) things referencing Name can be resolved. Otherwise, things
737 // refering to the number can be resolved. Do this now.
739 static void ResolveTypeTo(char *Name, const Type *ToTy) {
741 if (Name) D = ValID::create(Name);
742 else D = ValID::create((int)CurModule.Types.size());
744 std::map<ValID, PATypeHolder>::iterator I =
745 CurModule.LateResolveTypes.find(D);
746 if (I != CurModule.LateResolveTypes.end()) {
747 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
748 CurModule.LateResolveTypes.erase(I);
752 // setValueName - Set the specified value to the name given. The name may be
753 // null potentially, in which case this is a noop. The string passed in is
754 // assumed to be a malloc'd string buffer, and is free'd by this function.
756 static void setValueName(Value *V, char *NameStr) {
758 std::string Name(NameStr); // Copy string
759 free(NameStr); // Free old string
761 if (V->getType() == Type::VoidTy) {
762 GenerateError("Can't assign name '" + Name+"' to value with void type!");
766 assert(inFunctionScope() && "Must be in function scope!");
767 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
768 if (ST.lookup(V->getType(), Name)) {
769 GenerateError("Redefinition of value '" + Name + "' of type '" +
770 V->getType()->getDescription() + "'!");
779 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
780 /// this is a declaration, otherwise it is a definition.
781 static GlobalVariable *
782 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
783 bool isConstantGlobal, const Type *Ty,
784 Constant *Initializer) {
785 if (isa<FunctionType>(Ty)) {
786 GenerateError("Cannot declare global vars of function type!");
790 const PointerType *PTy = PointerType::get(Ty);
794 Name = NameStr; // Copy string
795 free(NameStr); // Free old string
798 // See if this global value was forward referenced. If so, recycle the
802 ID = ValID::create((char*)Name.c_str());
804 ID = ValID::create((int)CurModule.Values[PTy].size());
807 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
808 // Move the global to the end of the list, from whereever it was
809 // previously inserted.
810 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
811 CurModule.CurrentModule->getGlobalList().remove(GV);
812 CurModule.CurrentModule->getGlobalList().push_back(GV);
813 GV->setInitializer(Initializer);
814 GV->setLinkage(Linkage);
815 GV->setConstant(isConstantGlobal);
816 InsertValue(GV, CurModule.Values);
820 // If this global has a name, check to see if there is already a definition
821 // of this global in the module. If so, it is an error.
823 // We are a simple redefinition of a value, check to see if it is defined
824 // the same as the old one.
825 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
826 GenerateError("Redefinition of global variable named '" + Name +
827 "' of type '" + Ty->getDescription() + "'!");
832 // Otherwise there is no existing GV to use, create one now.
834 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
835 CurModule.CurrentModule);
836 InsertValue(GV, CurModule.Values);
840 // setTypeName - Set the specified type to the name given. The name may be
841 // null potentially, in which case this is a noop. The string passed in is
842 // assumed to be a malloc'd string buffer, and is freed by this function.
844 // This function returns true if the type has already been defined, but is
845 // allowed to be redefined in the specified context. If the name is a new name
846 // for the type plane, it is inserted and false is returned.
847 static bool setTypeName(const Type *T, char *NameStr) {
848 assert(!inFunctionScope() && "Can't give types function-local names!");
849 if (NameStr == 0) return false;
851 std::string Name(NameStr); // Copy string
852 free(NameStr); // Free old string
854 // We don't allow assigning names to void type
855 if (T == Type::VoidTy) {
856 GenerateError("Can't assign name '" + Name + "' to the void type!");
860 // Set the type name, checking for conflicts as we do so.
861 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
863 if (AlreadyExists) { // Inserting a name that is already defined???
864 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
865 assert(Existing && "Conflict but no matching type?");
867 // There is only one case where this is allowed: when we are refining an
868 // opaque type. In this case, Existing will be an opaque type.
869 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
870 // We ARE replacing an opaque type!
871 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
875 // Otherwise, this is an attempt to redefine a type. That's okay if
876 // the redefinition is identical to the original. This will be so if
877 // Existing and T point to the same Type object. In this one case we
878 // allow the equivalent redefinition.
879 if (Existing == T) return true; // Yes, it's equal.
881 // Any other kind of (non-equivalent) redefinition is an error.
882 GenerateError("Redefinition of type named '" + Name + "' of type '" +
883 T->getDescription() + "'!");
889 //===----------------------------------------------------------------------===//
890 // Code for handling upreferences in type names...
893 // TypeContains - Returns true if Ty directly contains E in it.
895 static bool TypeContains(const Type *Ty, const Type *E) {
896 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
897 E) != Ty->subtype_end();
902 // NestingLevel - The number of nesting levels that need to be popped before
903 // this type is resolved.
904 unsigned NestingLevel;
906 // LastContainedTy - This is the type at the current binding level for the
907 // type. Every time we reduce the nesting level, this gets updated.
908 const Type *LastContainedTy;
910 // UpRefTy - This is the actual opaque type that the upreference is
914 UpRefRecord(unsigned NL, OpaqueType *URTy)
915 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
919 // UpRefs - A list of the outstanding upreferences that need to be resolved.
920 static std::vector<UpRefRecord> UpRefs;
922 /// HandleUpRefs - Every time we finish a new layer of types, this function is
923 /// called. It loops through the UpRefs vector, which is a list of the
924 /// currently active types. For each type, if the up reference is contained in
925 /// the newly completed type, we decrement the level count. When the level
926 /// count reaches zero, the upreferenced type is the type that is passed in:
927 /// thus we can complete the cycle.
929 static PATypeHolder HandleUpRefs(const Type *ty) {
930 // If Ty isn't abstract, or if there are no up-references in it, then there is
931 // nothing to resolve here.
932 if (!ty->isAbstract() || UpRefs.empty()) return ty;
935 UR_OUT("Type '" << Ty->getDescription() <<
936 "' newly formed. Resolving upreferences.\n" <<
937 UpRefs.size() << " upreferences active!\n");
939 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
940 // to zero), we resolve them all together before we resolve them to Ty. At
941 // the end of the loop, if there is anything to resolve to Ty, it will be in
943 OpaqueType *TypeToResolve = 0;
945 for (unsigned i = 0; i != UpRefs.size(); ++i) {
946 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
947 << UpRefs[i].second->getDescription() << ") = "
948 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
949 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
950 // Decrement level of upreference
951 unsigned Level = --UpRefs[i].NestingLevel;
952 UpRefs[i].LastContainedTy = Ty;
953 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
954 if (Level == 0) { // Upreference should be resolved!
955 if (!TypeToResolve) {
956 TypeToResolve = UpRefs[i].UpRefTy;
958 UR_OUT(" * Resolving upreference for "
959 << UpRefs[i].second->getDescription() << "\n";
960 std::string OldName = UpRefs[i].UpRefTy->getDescription());
961 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
962 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
963 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
965 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
966 --i; // Do not skip the next element...
972 UR_OUT(" * Resolving upreference for "
973 << UpRefs[i].second->getDescription() << "\n";
974 std::string OldName = TypeToResolve->getDescription());
975 TypeToResolve->refineAbstractTypeTo(Ty);
981 //===----------------------------------------------------------------------===//
982 // RunVMAsmParser - Define an interface to this parser
983 //===----------------------------------------------------------------------===//
985 static Module* RunParser(Module * M);
987 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
990 CurFilename = Filename;
991 return RunParser(new Module(CurFilename));
994 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
995 set_scan_string(AsmString);
997 CurFilename = "from_memory";
999 return RunParser(new Module (CurFilename));
1001 return RunParser(M);
1006 #line 876 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1008 llvm::Module *ModuleVal;
1009 llvm::Function *FunctionVal;
1010 llvm::BasicBlock *BasicBlockVal;
1011 llvm::TerminatorInst *TermInstVal;
1012 llvm::Instruction *InstVal;
1013 llvm::Constant *ConstVal;
1015 const llvm::Type *PrimType;
1016 std::list<llvm::PATypeHolder> *TypeList;
1017 llvm::PATypeHolder *TypeVal;
1018 llvm::Value *ValueVal;
1019 std::vector<llvm::Value*> *ValueList;
1020 llvm::ArgListType *ArgList;
1021 llvm::TypeWithAttrs TypeWithAttrs;
1022 llvm::TypeWithAttrsList *TypeWithAttrsList;
1023 llvm::ValueRefList *ValueRefList;
1025 // Represent the RHS of PHI node
1026 std::list<std::pair<llvm::Value*,
1027 llvm::BasicBlock*> > *PHIList;
1028 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1029 std::vector<llvm::Constant*> *ConstVector;
1031 llvm::GlobalValue::LinkageTypes Linkage;
1032 llvm::FunctionType::ParameterAttributes ParamAttrs;
1040 char *StrVal; // This memory is strdup'd!
1041 llvm::ValID ValIDVal; // strdup'd memory maybe!
1043 llvm::Instruction::BinaryOps BinaryOpVal;
1044 llvm::Instruction::TermOps TermOpVal;
1045 llvm::Instruction::MemoryOps MemOpVal;
1046 llvm::Instruction::CastOps CastOpVal;
1047 llvm::Instruction::OtherOps OtherOpVal;
1048 llvm::Module::Endianness Endianness;
1049 llvm::ICmpInst::Predicate IPredicate;
1050 llvm::FCmpInst::Predicate FPredicate;
1063 #define YYFLAG -32768
1064 #define YYNTBASE 146
1066 #define YYTRANSLATE(x) ((unsigned)(x) <= 385 ? yytranslate[x] : 223)
1068 static const short yytranslate[] = { 0,
1069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1071 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1072 2, 2, 2, 2, 2, 2, 2, 2, 2, 136,
1073 137, 134, 2, 133, 2, 2, 2, 2, 2, 2,
1074 2, 2, 2, 2, 2, 2, 2, 2, 2, 141,
1075 132, 142, 2, 2, 2, 2, 2, 2, 2, 2,
1076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1077 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1078 138, 135, 140, 2, 2, 2, 2, 2, 145, 2,
1079 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1080 2, 2, 2, 2, 2, 2, 2, 2, 2, 139,
1081 2, 2, 143, 2, 144, 2, 2, 2, 2, 2,
1082 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1084 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1088 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1089 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1090 2, 2, 2, 2, 2, 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, 1, 3, 4, 5, 6,
1095 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1096 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1097 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1098 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1099 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1100 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1101 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1102 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1103 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1104 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1105 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1106 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1107 127, 128, 129, 130, 131
1111 static const short yyprhs[] = { 0,
1112 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1113 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1114 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1115 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1116 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1117 100, 102, 104, 106, 108, 110, 112, 114, 116, 119,
1118 120, 122, 124, 126, 128, 130, 132, 134, 136, 137,
1119 139, 141, 142, 144, 146, 148, 150, 151, 153, 155,
1120 157, 159, 161, 163, 166, 168, 170, 171, 174, 176,
1121 178, 179, 182, 183, 186, 187, 191, 194, 195, 197,
1122 198, 202, 204, 207, 209, 211, 213, 215, 217, 219,
1123 221, 224, 226, 229, 235, 241, 247, 253, 257, 260,
1124 266, 271, 274, 276, 278, 280, 284, 286, 290, 292,
1125 293, 295, 299, 304, 308, 312, 317, 322, 326, 333,
1126 339, 342, 345, 348, 351, 354, 357, 360, 363, 366,
1127 369, 376, 382, 391, 398, 405, 413, 421, 428, 435,
1128 444, 453, 457, 459, 461, 463, 465, 466, 468, 471,
1129 472, 476, 477, 481, 485, 487, 491, 495, 496, 502,
1130 503, 510, 511, 518, 521, 525, 527, 529, 531, 535,
1131 539, 543, 547, 551, 555, 557, 558, 560, 562, 564,
1132 565, 571, 575, 577, 581, 583, 584, 594, 596, 598,
1133 602, 604, 606, 609, 612, 613, 615, 617, 619, 621,
1134 623, 625, 627, 629, 631, 635, 637, 643, 645, 647,
1135 649, 651, 654, 657, 660, 664, 667, 668, 670, 673,
1136 676, 680, 690, 700, 709, 724, 726, 728, 735, 741,
1137 744, 751, 759, 763, 769, 770, 771, 775, 778, 780,
1138 786, 792, 799, 806, 811, 816, 823, 828, 833, 840,
1139 847, 850, 859, 861, 863, 864, 868, 875, 879, 886,
1143 static const short yyrhs[] = { 5,
1144 0, 6, 0, 70, 0, 71, 0, 72, 0, 73,
1145 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1146 0, 79, 0, 80, 0, 81, 0, 110, 0, 111,
1147 0, 112, 0, 113, 0, 114, 0, 115, 0, 116,
1148 0, 117, 0, 118, 0, 119, 0, 120, 0, 121,
1149 0, 124, 0, 125, 0, 126, 0, 84, 0, 85,
1150 0, 86, 0, 87, 0, 88, 0, 89, 0, 90,
1151 0, 91, 0, 92, 0, 93, 0, 94, 0, 95,
1152 0, 96, 0, 97, 0, 98, 0, 99, 0, 100,
1153 0, 101, 0, 102, 0, 103, 0, 90, 0, 91,
1154 0, 92, 0, 93, 0, 20, 0, 21, 0, 10,
1155 0, 11, 0, 12, 0, 195, 132, 0, 0, 34,
1156 0, 36, 0, 35, 0, 37, 0, 39, 0, 38,
1157 0, 40, 0, 42, 0, 0, 38, 0, 40, 0,
1158 0, 34, 0, 35, 0, 36, 0, 39, 0, 0,
1159 57, 0, 58, 0, 59, 0, 60, 0, 61, 0,
1160 62, 0, 56, 4, 0, 111, 0, 112, 0, 0,
1161 162, 161, 0, 131, 0, 161, 0, 0, 164, 163,
1162 0, 0, 49, 4, 0, 0, 133, 49, 4, 0,
1163 28, 17, 0, 0, 167, 0, 0, 133, 170, 169,
1164 0, 167, 0, 49, 4, 0, 9, 0, 10, 0,
1165 11, 0, 12, 0, 13, 0, 41, 0, 171, 0,
1166 172, 134, 0, 207, 0, 135, 4, 0, 172, 136,
1167 176, 137, 164, 0, 8, 136, 176, 137, 164, 0,
1168 138, 4, 139, 172, 140, 0, 141, 4, 139, 172,
1169 142, 0, 143, 177, 144, 0, 143, 144, 0, 141,
1170 143, 177, 144, 142, 0, 141, 143, 144, 142, 0,
1171 172, 162, 0, 172, 0, 8, 0, 173, 0, 175,
1172 133, 173, 0, 175, 0, 175, 133, 31, 0, 31,
1173 0, 0, 172, 0, 177, 133, 172, 0, 172, 138,
1174 180, 140, 0, 172, 138, 140, 0, 172, 145, 17,
1175 0, 172, 141, 180, 142, 0, 172, 143, 180, 144,
1176 0, 172, 143, 144, 0, 172, 141, 143, 180, 144,
1177 142, 0, 172, 141, 143, 144, 142, 0, 172, 32,
1178 0, 172, 33, 0, 172, 207, 0, 172, 179, 0,
1179 172, 19, 0, 153, 3, 0, 153, 4, 0, 9,
1180 20, 0, 9, 21, 0, 154, 7, 0, 149, 136,
1181 178, 30, 172, 137, 0, 109, 136, 178, 218, 137,
1182 0, 123, 136, 178, 133, 178, 133, 178, 137, 0,
1183 147, 136, 178, 133, 178, 137, 0, 148, 136, 178,
1184 133, 178, 137, 0, 82, 151, 136, 178, 133, 178,
1185 137, 0, 83, 152, 136, 178, 133, 178, 137, 0,
1186 150, 136, 178, 133, 178, 137, 0, 128, 136, 178,
1187 133, 178, 137, 0, 129, 136, 178, 133, 178, 133,
1188 178, 137, 0, 130, 136, 178, 133, 178, 133, 178,
1189 137, 0, 180, 133, 178, 0, 178, 0, 26, 0,
1190 27, 0, 183, 0, 0, 184, 0, 183, 184, 0,
1191 0, 25, 185, 203, 0, 0, 24, 186, 204, 0,
1192 54, 53, 190, 0, 18, 0, 155, 14, 172, 0,
1193 155, 14, 8, 0, 0, 155, 181, 178, 187, 169,
1194 0, 0, 155, 156, 181, 178, 188, 169, 0, 0,
1195 155, 157, 181, 172, 189, 169, 0, 43, 192, 0,
1196 50, 132, 193, 0, 17, 0, 48, 0, 47, 0,
1197 45, 132, 191, 0, 46, 132, 4, 0, 44, 132,
1198 17, 0, 63, 132, 17, 0, 138, 194, 140, 0,
1199 194, 133, 17, 0, 17, 0, 0, 15, 0, 17,
1200 0, 195, 0, 0, 197, 133, 172, 162, 196, 0,
1201 172, 162, 196, 0, 197, 0, 197, 133, 31, 0,
1202 31, 0, 0, 160, 174, 195, 136, 198, 137, 164,
1203 168, 165, 0, 22, 0, 143, 0, 159, 199, 200,
1204 0, 23, 0, 144, 0, 210, 202, 0, 158, 199,
1205 0, 0, 55, 0, 3, 0, 4, 0, 7, 0,
1206 20, 0, 21, 0, 32, 0, 33, 0, 19, 0,
1207 141, 180, 142, 0, 179, 0, 53, 205, 17, 133,
1208 17, 0, 146, 0, 195, 0, 207, 0, 206, 0,
1209 172, 208, 0, 210, 211, 0, 201, 211, 0, 212,
1210 155, 213, 0, 212, 215, 0, 0, 16, 0, 64,
1211 209, 0, 64, 8, 0, 65, 13, 208, 0, 65,
1212 9, 208, 133, 13, 208, 133, 13, 208, 0, 66,
1213 153, 208, 133, 13, 208, 138, 214, 140, 0, 66,
1214 153, 208, 133, 13, 208, 138, 140, 0, 67, 160,
1215 174, 208, 136, 217, 137, 164, 30, 13, 208, 68,
1216 13, 208, 0, 68, 0, 69, 0, 214, 153, 206,
1217 133, 13, 208, 0, 153, 206, 133, 13, 208, 0,
1218 155, 220, 0, 172, 138, 208, 133, 208, 140, 0,
1219 216, 133, 138, 208, 133, 208, 140, 0, 172, 208,
1220 162, 0, 217, 133, 172, 208, 162, 0, 0, 0,
1221 218, 133, 209, 0, 52, 51, 0, 51, 0, 147,
1222 172, 208, 133, 208, 0, 148, 172, 208, 133, 208,
1223 0, 82, 151, 172, 208, 133, 208, 0, 83, 152,
1224 172, 208, 133, 208, 0, 150, 209, 133, 209, 0,
1225 149, 209, 30, 172, 0, 123, 209, 133, 209, 133,
1226 209, 0, 127, 209, 133, 172, 0, 128, 209, 133,
1227 209, 0, 129, 209, 133, 209, 133, 209, 0, 130,
1228 209, 133, 209, 133, 209, 0, 122, 216, 0, 219,
1229 160, 174, 208, 136, 217, 137, 164, 0, 222, 0,
1230 29, 0, 0, 104, 172, 166, 0, 104, 172, 133,
1231 10, 208, 166, 0, 105, 172, 166, 0, 105, 172,
1232 133, 10, 208, 166, 0, 106, 209, 0, 221, 107,
1233 172, 208, 0, 221, 108, 209, 133, 172, 208, 0,
1234 109, 172, 208, 218, 0
1240 static const short yyrline[] = { 0,
1241 1019, 1020, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
1242 1030, 1031, 1031, 1031, 1032, 1032, 1032, 1032, 1032, 1032,
1243 1032, 1033, 1033, 1033, 1033, 1033, 1034, 1034, 1034, 1036,
1244 1036, 1037, 1037, 1038, 1038, 1039, 1039, 1040, 1040, 1044,
1245 1044, 1045, 1045, 1046, 1046, 1047, 1047, 1048, 1048, 1049,
1246 1049, 1050, 1050, 1051, 1052, 1057, 1058, 1058, 1061, 1065,
1247 1071, 1072, 1073, 1074, 1075, 1079, 1080, 1081, 1085, 1086,
1248 1087, 1091, 1092, 1093, 1094, 1095, 1098, 1098, 1099, 1100,
1249 1101, 1102, 1103, 1104, 1112, 1113, 1116, 1117, 1122, 1123,
1250 1126, 1127, 1134, 1134, 1141, 1141, 1150, 1158, 1158, 1164,
1251 1164, 1166, 1171, 1184, 1184, 1184, 1184, 1184, 1187, 1191,
1252 1195, 1202, 1207, 1215, 1233, 1251, 1256, 1268, 1278, 1282,
1253 1292, 1299, 1306, 1313, 1318, 1323, 1330, 1331, 1338, 1345,
1254 1353, 1358, 1369, 1397, 1413, 1442, 1470, 1495, 1514, 1539,
1255 1558, 1570, 1577, 1640, 1650, 1660, 1666, 1672, 1676, 1680,
1256 1688, 1702, 1723, 1731, 1737, 1748, 1753, 1758, 1767, 1773,
1257 1779, 1788, 1792, 1800, 1800, 1811, 1816, 1824, 1825, 1829,
1258 1829, 1833, 1833, 1836, 1839, 1851, 1875, 1886, 1892, 1895,
1259 1900, 1903, 1909, 1913, 1916, 1922, 1935, 1936, 1938, 1942,
1260 1951, 1955, 1960, 1962, 1967, 1972, 1981, 1981, 1982, 1982,
1261 1984, 1994, 2005, 2009, 2018, 2027, 2032, 2137, 2137, 2139,
1262 2147, 2147, 2149, 2154, 2165, 2169, 2174, 2178, 2182, 2186,
1263 2190, 2194, 2198, 2202, 2206, 2231, 2235, 2249, 2253, 2259,
1264 2259, 2265, 2274, 2278, 2287, 2298, 2307, 2319, 2332, 2336,
1265 2340, 2345, 2354, 2373, 2382, 2449, 2453, 2460, 2471, 2484,
1266 2493, 2504, 2514, 2522, 2530, 2533, 2534, 2541, 2545, 2550,
1267 2571, 2588, 2601, 2614, 2623, 2636, 2644, 2651, 2657, 2663,
1268 2669, 2684, 2747, 2752, 2756, 2763, 2770, 2778, 2785, 2793,
1274 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1276 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1277 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","INTTYPE","FLOAT","DOUBLE",
1278 "LABEL","TYPE","VAR_ID","LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER",
1279 "TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT",
1280 "SECTION","VOLATILE","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE",
1281 "WEAK","APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL",
1282 "TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL",
1283 "TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK",
1284 "COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR",
1285 "SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV",
1286 "UREM","SREM","FREM","AND","OR","XOR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE",
1287 "SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO",
1288 "UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1289 "ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1290 "INTTOPTR","PTRTOINT","PHI_TOK","SELECT","SHL","LSHR","ASHR","VAARG","EXTRACTELEMENT",
1291 "INSERTELEMENT","SHUFFLEVECTOR","NORETURN","'='","','","'*'","'\\\\'","'('",
1292 "')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","INTVAL","ArithmeticOps",
1293 "LogicalOps","CastOps","ShiftOps","IPredicates","FPredicates","IntType","FPType",
1294 "OptAssign","GVInternalLinkage","GVExternalLinkage","FunctionDeclareLinkage",
1295 "FunctionDefineLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr",
1296 "OptFuncAttrs","OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes",
1297 "GlobalVarAttribute","PrimType","Types","ArgType","ResultTypes","ArgTypeList",
1298 "ArgTypeListI","TypeListI","ConstVal","ConstExpr","ConstVector","GlobalType",
1299 "Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","BigOrLittle",
1300 "TargetDefinition","LibrariesDefinition","LibList","Name","OptName","ArgListH",
1301 "ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END","Function","FunctionProto",
1302 "OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1303 "BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1304 "Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal","OptVolatile",
1309 static const short yyr1[] = { 0,
1310 146, 146, 147, 147, 147, 147, 147, 147, 147, 147,
1311 147, 148, 148, 148, 149, 149, 149, 149, 149, 149,
1312 149, 149, 149, 149, 149, 149, 150, 150, 150, 151,
1313 151, 151, 151, 151, 151, 151, 151, 151, 151, 152,
1314 152, 152, 152, 152, 152, 152, 152, 152, 152, 152,
1315 152, 152, 152, 152, 152, 153, 154, 154, 155, 155,
1316 156, 156, 156, 156, 156, 157, 157, 157, 158, 158,
1317 158, 159, 159, 159, 159, 159, 160, 160, 160, 160,
1318 160, 160, 160, 160, 161, 161, 162, 162, 163, 163,
1319 164, 164, 165, 165, 166, 166, 167, 168, 168, 169,
1320 169, 170, 170, 171, 171, 171, 171, 171, 172, 172,
1321 172, 172, 172, 172, 172, 172, 172, 172, 172, 172,
1322 172, 173, 174, 174, 175, 175, 176, 176, 176, 176,
1323 177, 177, 178, 178, 178, 178, 178, 178, 178, 178,
1324 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
1325 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
1326 179, 180, 180, 181, 181, 182, 182, 183, 183, 185,
1327 184, 186, 184, 184, 184, 184, 184, 187, 184, 188,
1328 184, 189, 184, 184, 184, 190, 191, 191, 192, 192,
1329 192, 192, 193, 194, 194, 194, 195, 195, 196, 196,
1330 197, 197, 198, 198, 198, 198, 199, 200, 200, 201,
1331 202, 202, 203, 204, 205, 205, 206, 206, 206, 206,
1332 206, 206, 206, 206, 206, 206, 206, 207, 207, 208,
1333 208, 209, 210, 210, 211, 212, 212, 212, 213, 213,
1334 213, 213, 213, 213, 213, 213, 213, 214, 214, 215,
1335 216, 216, 217, 217, 217, 218, 218, 219, 219, 220,
1336 220, 220, 220, 220, 220, 220, 220, 220, 220, 220,
1337 220, 220, 220, 221, 221, 222, 222, 222, 222, 222,
1341 static const short yyr2[] = { 0,
1342 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1343 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1344 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1345 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1346 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1347 1, 1, 1, 1, 1, 1, 1, 1, 2, 0,
1348 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1349 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1350 1, 1, 1, 2, 1, 1, 0, 2, 1, 1,
1351 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
1352 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1353 2, 1, 2, 5, 5, 5, 5, 3, 2, 5,
1354 4, 2, 1, 1, 1, 3, 1, 3, 1, 0,
1355 1, 3, 4, 3, 3, 4, 4, 3, 6, 5,
1356 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1357 6, 5, 8, 6, 6, 7, 7, 6, 6, 8,
1358 8, 3, 1, 1, 1, 1, 0, 1, 2, 0,
1359 3, 0, 3, 3, 1, 3, 3, 0, 5, 0,
1360 6, 0, 6, 2, 3, 1, 1, 1, 3, 3,
1361 3, 3, 3, 3, 1, 0, 1, 1, 1, 0,
1362 5, 3, 1, 3, 1, 0, 9, 1, 1, 3,
1363 1, 1, 2, 2, 0, 1, 1, 1, 1, 1,
1364 1, 1, 1, 1, 3, 1, 5, 1, 1, 1,
1365 1, 2, 2, 2, 3, 2, 0, 1, 2, 2,
1366 3, 9, 9, 8, 14, 1, 1, 6, 5, 2,
1367 6, 7, 3, 5, 0, 0, 3, 2, 1, 5,
1368 5, 6, 6, 4, 4, 6, 4, 4, 6, 6,
1369 2, 8, 1, 1, 0, 3, 6, 3, 6, 2,
1373 static const short yydefact[] = { 60,
1374 197, 198, 175, 172, 170, 0, 0, 0, 0, 60,
1375 168, 0, 69, 72, 0, 0, 0, 0, 184, 0,
1376 0, 0, 164, 165, 61, 63, 62, 64, 66, 65,
1377 67, 68, 0, 0, 0, 169, 59, 70, 71, 77,
1378 173, 73, 74, 75, 76, 77, 237, 171, 237, 0,
1379 0, 0, 0, 196, 185, 186, 174, 1, 2, 177,
1380 104, 105, 106, 107, 108, 109, 0, 0, 0, 0,
1381 228, 110, 176, 229, 112, 0, 0, 0, 104, 105,
1382 106, 107, 0, 0, 0, 178, 0, 78, 79, 80,
1383 81, 82, 83, 0, 214, 0, 238, 234, 60, 211,
1384 212, 213, 233, 191, 188, 187, 189, 190, 192, 195,
1385 0, 130, 113, 0, 0, 0, 119, 131, 0, 111,
1386 130, 180, 182, 148, 149, 146, 147, 150, 145, 141,
1387 142, 3, 4, 5, 6, 7, 8, 9, 10, 11,
1388 12, 13, 14, 0, 0, 0, 15, 16, 17, 18,
1389 19, 20, 21, 22, 23, 24, 25, 26, 0, 27,
1390 28, 29, 0, 0, 0, 0, 0, 0, 0, 0,
1391 0, 0, 0, 144, 143, 100, 84, 124, 123, 0,
1392 208, 209, 210, 275, 236, 0, 193, 129, 87, 125,
1393 127, 0, 0, 0, 0, 0, 0, 118, 0, 100,
1394 100, 30, 31, 32, 33, 34, 35, 36, 37, 38,
1395 39, 0, 54, 55, 50, 51, 52, 53, 40, 41,
1396 42, 43, 44, 45, 46, 47, 48, 49, 0, 0,
1397 0, 0, 0, 0, 134, 163, 0, 0, 0, 138,
1398 0, 135, 0, 0, 0, 0, 0, 179, 0, 274,
1399 259, 0, 0, 0, 0, 77, 246, 247, 0, 0,
1400 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1401 0, 0, 0, 0, 235, 77, 250, 0, 273, 194,
1402 122, 0, 91, 0, 0, 121, 0, 132, 91, 181,
1403 183, 0, 0, 256, 0, 0, 0, 0, 0, 133,
1404 119, 131, 0, 136, 137, 0, 0, 0, 0, 0,
1405 0, 102, 100, 206, 258, 240, 0, 239, 0, 0,
1406 56, 0, 0, 0, 0, 95, 95, 280, 0, 0,
1407 271, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1408 0, 0, 0, 85, 86, 88, 128, 126, 115, 116,
1409 117, 120, 114, 0, 0, 0, 0, 0, 0, 0,
1410 162, 140, 0, 0, 0, 0, 0, 97, 103, 101,
1411 205, 87, 203, 0, 217, 218, 219, 224, 220, 221,
1412 222, 223, 215, 0, 226, 231, 230, 232, 0, 241,
1413 0, 0, 0, 0, 0, 276, 0, 278, 256, 0,
1414 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1415 0, 0, 0, 89, 90, 92, 0, 0, 0, 152,
1416 0, 0, 0, 0, 139, 0, 0, 0, 0, 200,
1417 0, 91, 216, 0, 0, 0, 0, 0, 0, 0,
1418 0, 0, 0, 283, 0, 0, 0, 267, 268, 0,
1419 0, 0, 0, 265, 264, 0, 281, 0, 0, 0,
1420 257, 0, 159, 0, 0, 154, 155, 151, 158, 199,
1421 202, 204, 87, 98, 0, 225, 0, 0, 255, 0,
1422 0, 95, 96, 95, 0, 0, 0, 0, 0, 260,
1423 261, 255, 0, 156, 157, 0, 0, 0, 200, 99,
1424 93, 0, 0, 0, 0, 0, 262, 263, 0, 277,
1425 279, 0, 0, 266, 269, 270, 0, 282, 153, 160,
1426 161, 201, 0, 207, 227, 0, 0, 87, 0, 91,
1427 251, 0, 91, 94, 0, 244, 0, 0, 253, 0,
1428 0, 252, 272, 242, 0, 243, 0, 87, 0, 0,
1429 0, 254, 0, 0, 0, 0, 249, 0, 0, 248,
1433 static const short yydefgoto[] = { 71,
1434 170, 171, 172, 173, 212, 229, 83, 84, 9, 33,
1435 34, 40, 46, 94, 346, 281, 416, 349, 524, 396,
1436 312, 501, 248, 313, 72, 85, 190, 180, 191, 192,
1437 119, 236, 385, 237, 35, 563, 10, 11, 14, 13,
1438 176, 200, 201, 57, 107, 19, 55, 111, 74, 471,
1439 373, 374, 95, 183, 47, 102, 48, 41, 434, 386,
1440 75, 388, 318, 49, 98, 99, 275, 538, 185, 331,
1441 506, 356, 276, 277, 278, 279
1444 static const short yypact[] = { 25,
1445 -32768,-32768,-32768,-32768,-32768, 41, -96, 30, 537, 95,
1446 -32768, -80, 58, 134, -54, -41, -24, -21,-32768, -15,
1447 110, 349,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1448 -32768,-32768, 114, 114, 964,-32768,-32768,-32768,-32768, 176,
1449 -32768,-32768,-32768,-32768,-32768, 176, 151,-32768, -2, 195,
1450 103, 210, 200, 206,-32768,-32768,-32768,-32768,-32768, 121,
1451 -32768,-32768,-32768,-32768,-32768,-32768, 257, 258, 4, 22,
1452 -32768,-32768, -4,-32768,-32768, 964, 1217, 121, 183, 222,
1453 256, 259, 224, 262, 596,-32768, 260,-32768,-32768,-32768,
1454 -32768,-32768,-32768, 1230,-32768, -7,-32768,-32768, 147,-32768,
1455 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1456 -9, 518,-32768, 126, 131, 174,-32768, -4, -77,-32768,
1457 518,-32768, -4,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1458 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1459 -32768,-32768,-32768, 283, 917, 135,-32768,-32768,-32768,-32768,
1460 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 136,-32768,
1461 -32768,-32768, 137, 140, 141, 822, 1244, 677, 264, 146,
1462 148, 149, 152,-32768,-32768, 150,-32768, 121, -4, 147,
1463 -32768,-32768,-32768, 1324,-32768, 270,-32768,-32768, -4,-32768,
1464 156, 153, 1217, 1217, 154, -71, 1217,-32768, 157, 150,
1465 150,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1466 -32768, 155,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1467 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 159, 964,
1468 964, 964, 964, 964,-32768,-32768, -5, 737, -89,-32768,
1469 -62,-32768, 964, 964, 964, 964, 17,-32768, 161,-32768,
1470 -32768, 242, 1278, 105, 288, 176,-32768,-32768, 283, 917,
1471 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217,
1472 1217, 1217, 1217, 1217,-32768, 176,-32768, 122,-32768,-32768,
1473 143, 1134,-32768, 12, -27,-32768, 158, -4,-32768,-32768,
1474 -32768, 964, 964,-32768, 166, 171, 172, 173, 964,-32768,
1475 165, 596, -52,-32768,-32768, 175, 178, 284, 180, 299,
1476 318,-32768, 150, 1177,-32768, 121, 776,-32768, 915, 915,
1477 -32768, 915, 1230, 1217, 1217, 20, 66,-32768, 776, 54,
1478 190, 191, 193, 196, 198, 203, 776, 776, 308, 208,
1479 1230, 1217, 1217,-32768,-32768,-32768,-32768,-32768, -42,-32768,
1480 -32768,-32768, -42, 214, 215, -11, 964, 964, 964, 964,
1481 -32768,-32768, 201, 964, 964, 1217, 964,-32768,-32768,-32768,
1482 -32768, -4, 216, 213,-32768,-32768,-32768,-32768,-32768,-32768,
1483 -32768,-32768, 296, 964,-32768,-32768,-32768,-32768, 219,-32768,
1484 220, 915, 776, 776, 28,-32768, 31,-32768,-32768, 915,
1485 218, 1217, 1217, 1217, 1217, 1217, 230, 232, 1217, 1217,
1486 915, 776, 244,-32768,-32768,-32768, 964, 964, 1217,-32768,
1487 245, 248, 246, 253,-32768, 252, 254, 40, 261, 5,
1488 1190,-32768,-32768, 377, -45, 382, 383, 263, 271, 272,
1489 915, 399, 915, 273, 274, 915, 277, -4,-32768, 278,
1490 279, 915, 915, -4,-32768, 280,-32768, 1217, 276, 281,
1491 -32768, 964,-32768, 964, 964,-32768,-32768,-32768,-32768,-32768,
1492 -32768,-32768, -4, -10, 282,-32768, 915, 915, 1217, 915,
1493 915, 289,-32768, 289, 915, 292, 1217, 1217, 1217,-32768,
1494 -32768, 1217, 776,-32768,-32768, 290, 291, 293, 5,-32768,
1495 365, 400, 301, 294, 776, 0,-32768,-32768, 372,-32768,
1496 -32768, 295, 915,-32768,-32768,-32768, 61,-32768,-32768,-32768,
1497 -32768,-32768, 425,-32768,-32768, 430, -1,-32768, 1217,-32768,
1498 -32768, 298,-32768,-32768, 915,-32768, 1043, 3, 143, 776,
1499 -6,-32768, -42,-32768, 311,-32768, 1043,-32768, 432, 433,
1500 314, 143, 915, 915, 435, 384,-32768, 915, 437,-32768,
1501 915,-32768, 453, 455,-32768
1504 static const short yypgoto[] = {-32768,
1505 275, 285, 287, 297, 197, 202, -252,-32768, 359,-32768,
1506 -32768,-32768,-32768, -230, -330, -370,-32768, -277,-32768, -323,
1507 2,-32768, -184,-32768,-32768, -22, 181, -294,-32768, 343,
1508 352, -25, -78, -162, 225,-32768,-32768, 462,-32768,-32768,
1509 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1, -26,
1510 -32768,-32768, 428,-32768,-32768,-32768,-32768,-32768,-32768, -463,
1511 8, 104, -209,-32768, 426,-32768,-32768,-32768,-32768,-32768,
1512 -14, 78,-32768,-32768,-32768,-32768
1519 static const short yytable[] = { 73,
1520 12, 430, 322, 398, 239, 241, 174, 115, 321, 86,
1521 12, 353, 321, 97, 181, 290, 291, 310, 415, 1,
1522 100, 2, 415, 549, -167, 323, 58, 59, 392, 78,
1523 61, 62, 63, 64, 65, 20, 1, 441, 2, 1,
1524 443, 2, 3, 299, 310, 341, 411, 118, 4, 5,
1525 122, 37, 304, 328, 123, 197, 332, 333, 334, 335,
1526 336, 197, 66, 339, 340, 311, 198, 6, 344, 345,
1527 299, 179, 287, 545, 7, 303, 442, 50, 8, 442,
1528 299, 305, 21, 551, 15, 16, 17, 299, 414, 189,
1529 51, 363, 175, 118, -166, 38, 476, 39, 189, 12,
1530 344, 345, 499, 18, 344, 345, 120, 52, 121, 1,
1531 53, 2, 3, 319, 351, 344, 345, 320, 4, 5,
1532 414, 419, 54, 186, 414, 420, 56, 299, 370, 120,
1533 187, 121, 529, 413, 300, 182, 530, 6, 536, 23,
1534 24, 101, 546, 415, 7, 120, 116, 121, 8, 105,
1535 106, 350, 395, 120, 474, 121, 67, 539, 510, 68,
1536 511, 1, 69, 2, 70, 117, 97, 42, 43, 44,
1537 284, 285, 45, 120, 288, 121, 468, 552, 58, 59,
1538 249, 78, 61, 62, 63, 64, 65, 120, 1, 121,
1539 2, 400, 447, 529, 449, 450, 451, 533, 397, 120,
1540 455, 121, 124, 125, 294, 295, 296, 297, 298, 461,
1541 415, 104, 415, 108, 66, 302, 109, 306, 307, 308,
1542 309, 435, 110, 174, -56, -56, 126, 127, 342, 343,
1543 317, 87, 88, 89, 90, 91, 92, 93, 326, 327,
1544 317, 329, 330, 317, 317, 317, 317, 317, 337, 338,
1545 317, 317, 541, 344, 345, 543, 112, 76, 77, 189,
1546 113, 114, -57, 177, 193, -58, 354, 355, 128, 194,
1547 230, 231, 232, 361, 537, 233, 234, 514, 515, 516,
1548 242, 243, 247, 244, 245, 547, 280, 246, 282, 283,
1549 292, 372, 315, 289, 293, 286, 314, 321, 357, 352,
1550 179, 393, 394, 358, 359, 360, 362, 364, 67, 175,
1551 365, 68, 367, 366, 69, 368, 70, 195, 179, 412,
1552 317, 369, 401, 402, 387, 403, 387, 387, 404, 387,
1553 405, 421, 422, 423, 424, 406, 387, 409, 426, 427,
1554 410, 429, 425, 428, 387, 387, 417, 418, 431, 432,
1555 433, 436, 437, 58, 59, 446, 60, 61, 62, 63,
1556 64, 65, 452, 1, 453, 2, 202, 203, 204, 205,
1557 206, 207, 208, 209, 210, 211, 458, 462, 464, 317,
1558 448, 317, 317, 317, 463, 465, 454, 317, 466, 66,
1559 467, 459, 460, 475, 477, 478, 317, 469, 479, 387,
1560 387, 387, 483, 480, 481, 419, 485, 387, 473, 487,
1561 488, 489, 494, 523, 502, 492, 525, 495, 387, 387,
1562 442, 509, 389, 390, 513, 391, 519, 520, 534, 521,
1563 470, 527, 399, 526, 531, 493, 496, 542, 497, 498,
1564 407, 408, 535, 550, 553, 554, 555, 558, 387, 561,
1565 387, 559, 564, 387, 565, 324, 505, 184, 271, 387,
1566 387, 325, 348, 199, 317, 317, 317, 196, 272, 505,
1567 273, 36, 522, 96, 103, 500, 444, 517, 0, 0,
1568 274, 0, 0, 67, 387, 387, 68, 387, 387, 69,
1569 0, 70, 387, 0, 0, 438, 439, 440, 0, 470,
1570 387, 0, 0, 445, 0, 0, 540, 0, 0, 0,
1571 0, 0, 387, 0, 456, 457, 0, 0, 0, 0,
1572 387, 0, 58, 59, 0, 78, 61, 62, 63, 64,
1573 65, 0, 1, 0, 2, 0, 0, 0, 0, 0,
1574 0, 0, 387, 0, 482, 0, 484, 387, 188, 486,
1575 22, 0, 0, 0, 0, 490, 491, 0, 66, 0,
1576 387, 387, 23, 24, 0, 387, 0, 0, 387, 0,
1577 25, 26, 27, 28, 29, 30, 31, 0, 32, 0,
1578 503, 504, 0, 507, 508, 0, 0, 0, 512, 0,
1579 0, 0, 0, 0, 0, 0, 518, 0, 0, 0,
1580 58, 59, 0, 0, 0, 0, 0, 0, 528, 0,
1581 1, 0, 2, 0, 129, 0, 532, 0, 0, 0,
1582 0, 0, 0, 0, 0, 0, 0, 130, 131, 0,
1583 0, 0, 0, 0, 0, 0, 0, 0, 544, 0,
1584 0, 0, 0, 548, 0, 0, 0, 0, 0, 0,
1585 0, 0, 67, 0, 0, 68, 556, 557, 69, 0,
1586 70, 560, 0, 0, 562, 132, 133, 134, 135, 136,
1587 137, 138, 139, 140, 141, 142, 143, 144, 145, 0,
1588 0, 58, 59, 0, 78, 79, 80, 81, 82, 65,
1589 0, 1, 0, 2, 0, 0, 0, 0, 0, 0,
1590 0, 0, 0, 0, 146, 147, 148, 149, 150, 151,
1591 152, 153, 154, 155, 156, 157, 158, 66, 159, 160,
1592 161, 162, 0, 163, 164, 165, 0, 0, 0, 120,
1593 0, 121, 0, 166, 0, 0, 167, 0, 168, 0,
1594 169, 58, 59, 0, 78, 79, 80, 81, 82, 65,
1595 0, 1, 0, 2, 0, 0, 0, 0, 0, 0,
1596 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1597 0, 0, 0, 0, 0, 0, 0, 66, 375, 376,
1598 58, 59, 377, 0, 0, 0, 0, 0, 0, 0,
1599 1, 0, 2, 0, 378, 379, 380, 0, 0, 0,
1600 0, 0, 0, 0, 0, 0, 0, 381, 382, 0,
1601 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
1602 240, 0, 0, 0, 0, 0, 58, 59, 383, 78,
1603 79, 80, 81, 82, 65, 0, 1, 0, 2, 0,
1604 0, 0, 0, 0, 0, 132, 133, 134, 135, 136,
1605 137, 138, 139, 140, 141, 142, 143, 144, 145, 0,
1606 0, 0, 66, 0, 0, 0, 0, 0, 0, 0,
1607 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
1608 301, 0, 0, 0, 146, 147, 148, 149, 150, 151,
1609 152, 153, 154, 155, 156, 157, 158, 0, 159, 160,
1610 161, 162, 0, 163, 164, 165, 0, 0, 0, 120,
1611 0, 121, 0, 0, 0, 0, 384, 375, 376, 58,
1612 59, 377, 0, 0, 0, 0, 0, 0, 0, 1,
1613 0, 2, 0, 378, 379, 380, 213, 214, 0, 0,
1614 0, 0, 0, 0, 0, 0, 381, 382, 0, 0,
1615 0, 0, 0, 0, 0, 0, 67, 0, 0, 68,
1616 0, 235, 69, 0, 70, 0, 0, 383, 58, 59,
1617 0, 78, 79, 80, 81, 82, 65, 0, 1, 0,
1618 2, 0, 0, 0, 132, 133, 134, 135, 136, 137,
1619 138, 139, 140, 141, 142, 143, 144, 145, 0, 0,
1620 0, 0, 0, 0, 66, 0, 215, 216, 217, 218,
1621 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
1622 0, 0, 0, 146, 147, 148, 149, 150, 151, 152,
1623 153, 154, 155, 156, 157, 158, 0, 159, 160, 161,
1624 162, 0, 163, 164, 165, 375, 376, 0, 0, 377,
1625 0, 0, 0, 0, 0, 384, 0, 0, 0, 0,
1626 0, 378, 379, 380, 0, 0, 0, 0, 0, 0,
1627 0, 0, 0, 0, 381, 382, 0, 0, 0, 0,
1628 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1629 0, 0, 0, 0, 0, 383, 0, 0, 67, 0,
1630 0, 68, 0, 0, 69, 0, 70, 0, 0, 0,
1631 0, 0, 132, 133, 134, 135, 136, 137, 138, 139,
1632 140, 141, 142, 143, 144, 145, 0, 0, 0, 0,
1633 0, 0, 0, 0, 0, 0, 0, 0, 58, 59,
1634 0, 78, 61, 62, 63, 64, 65, 0, 1, 0,
1635 2, 146, 147, 148, 149, 150, 151, 152, 153, 154,
1636 155, 156, 157, 158, 347, 159, 160, 161, 162, 0,
1637 163, 164, 165, 0, 66, 0, 0, 0, 0, 0,
1638 0, 58, 59, 384, 78, 61, 62, 63, 64, 65,
1639 0, 1, 0, 2, 58, 59, 0, 78, 61, 62,
1640 63, 64, 65, 0, 1, 0, 2, 371, 0, 0,
1641 0, 0, 0, 0, 0, 0, 0, 66, 0, 0,
1642 472, 58, 59, 0, 78, 61, 62, 63, 64, 65,
1643 66, 1, 0, 2, 58, 59, 0, 178, 61, 62,
1644 63, 64, 65, 0, 1, 0, 2, 0, 58, 59,
1645 0, 78, 79, 80, 81, 82, 65, 66, 1, 0,
1646 2, 0, 0, 0, 0, 0, 0, 0, 67, 0,
1647 66, 68, 0, 0, 69, 0, 70, 0, 0, 0,
1648 0, 0, 58, 59, 66, 316, 61, 62, 63, 64,
1649 65, 0, 1, 0, 2, 0, 0, 0, 0, 0,
1650 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1651 0, 67, 0, 0, 68, 0, 0, 69, 66, 70,
1652 0, 0, 0, 0, 67, 0, 0, 68, 0, 0,
1653 69, 0, 70, 0, 0, 0, 0, 0, 0, 0,
1654 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1655 0, 67, 250, 0, 68, 0, 0, 69, 0, 70,
1656 0, 0, 0, 0, 67, 0, 0, 68, 0, 0,
1657 69, 0, 70, 0, 251, 252, 0, 0, 67, 0,
1658 0, 68, 0, 0, 69, 0, 238, 253, 254, 255,
1659 256, 257, 258, 132, 133, 134, 135, 136, 137, 138,
1660 139, 140, 141, 142, 143, 259, 260, 0, 0, 0,
1661 0, 0, 67, 0, 0, 68, 0, 0, 69, 0,
1662 70, 0, 0, 0, 0, 0, 0, 261, 262, 263,
1663 0, 0, 264, 147, 148, 149, 150, 151, 152, 153,
1664 154, 155, 156, 157, 158, 265, 266, 160, 161, 162,
1668 static const short yycheck[] = { 22,
1669 0, 372, 255, 327, 167, 168, 85, 4, 10, 35,
1670 10, 289, 10, 16, 22, 200, 201, 28, 349, 15,
1671 23, 17, 353, 30, 0, 256, 5, 6, 323, 8,
1672 9, 10, 11, 12, 13, 132, 15, 10, 17, 15,
1673 10, 17, 18, 133, 28, 276, 341, 70, 24, 25,
1674 76, 132, 142, 263, 77, 133, 266, 267, 268, 269,
1675 270, 133, 41, 273, 274, 49, 144, 43, 111, 112,
1676 133, 94, 144, 537, 50, 238, 49, 132, 54, 49,
1677 133, 144, 53, 547, 44, 45, 46, 133, 131, 112,
1678 132, 144, 85, 116, 0, 38, 142, 40, 121, 99,
1679 111, 112, 473, 63, 111, 112, 134, 132, 136, 15,
1680 132, 17, 18, 9, 142, 111, 112, 13, 24, 25,
1681 131, 133, 138, 133, 131, 137, 17, 133, 313, 134,
1682 140, 136, 133, 343, 140, 143, 137, 43, 140, 26,
1683 27, 144, 140, 474, 50, 134, 143, 136, 54, 47,
1684 48, 140, 133, 134, 432, 136, 135, 528, 482, 138,
1685 484, 15, 141, 17, 143, 144, 16, 34, 35, 36,
1686 193, 194, 39, 134, 197, 136, 137, 548, 5, 6,
1687 180, 8, 9, 10, 11, 12, 13, 134, 15, 136,
1688 17, 138, 402, 133, 404, 405, 406, 137, 133, 134,
1689 410, 136, 20, 21, 230, 231, 232, 233, 234, 419,
1690 541, 17, 543, 4, 41, 238, 17, 243, 244, 245,
1691 246, 384, 17, 302, 3, 4, 3, 4, 107, 108,
1692 253, 56, 57, 58, 59, 60, 61, 62, 261, 262,
1693 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
1694 273, 274, 530, 111, 112, 533, 136, 33, 34, 282,
1695 4, 4, 7, 4, 139, 7, 292, 293, 7, 139,
1696 136, 136, 136, 299, 527, 136, 136, 487, 488, 489,
1697 17, 136, 133, 136, 136, 538, 17, 136, 133, 137,
1698 136, 314, 51, 137, 136, 142, 136, 10, 133, 142,
1699 323, 324, 325, 133, 133, 133, 142, 133, 135, 302,
1700 133, 138, 133, 30, 141, 17, 143, 144, 341, 342,
1701 343, 4, 133, 133, 317, 133, 319, 320, 133, 322,
1702 133, 357, 358, 359, 360, 133, 329, 30, 364, 365,
1703 133, 367, 142, 366, 337, 338, 133, 133, 133, 137,
1704 55, 133, 133, 5, 6, 138, 8, 9, 10, 11,
1705 12, 13, 133, 15, 133, 17, 84, 85, 86, 87,
1706 88, 89, 90, 91, 92, 93, 133, 133, 133, 402,
1707 403, 404, 405, 406, 137, 133, 409, 410, 137, 41,
1708 137, 417, 418, 17, 13, 13, 419, 137, 136, 392,
1709 393, 394, 4, 133, 133, 133, 133, 400, 431, 133,
1710 133, 133, 137, 49, 133, 136, 17, 137, 411, 412,
1711 49, 133, 319, 320, 133, 322, 137, 137, 4, 137,
1712 430, 138, 329, 133, 140, 458, 462, 140, 464, 465,
1713 337, 338, 13, 133, 13, 13, 133, 13, 441, 13,
1714 443, 68, 0, 446, 0, 259, 479, 99, 184, 452,
1715 453, 260, 282, 121, 487, 488, 489, 116, 184, 492,
1716 184, 10, 499, 46, 49, 474, 399, 492, -1, -1,
1717 184, -1, -1, 135, 477, 478, 138, 480, 481, 141,
1718 -1, 143, 485, -1, -1, 392, 393, 394, -1, 499,
1719 493, -1, -1, 400, -1, -1, 529, -1, -1, -1,
1720 -1, -1, 505, -1, 411, 412, -1, -1, -1, -1,
1721 513, -1, 5, 6, -1, 8, 9, 10, 11, 12,
1722 13, -1, 15, -1, 17, -1, -1, -1, -1, -1,
1723 -1, -1, 535, -1, 441, -1, 443, 540, 31, 446,
1724 14, -1, -1, -1, -1, 452, 453, -1, 41, -1,
1725 553, 554, 26, 27, -1, 558, -1, -1, 561, -1,
1726 34, 35, 36, 37, 38, 39, 40, -1, 42, -1,
1727 477, 478, -1, 480, 481, -1, -1, -1, 485, -1,
1728 -1, -1, -1, -1, -1, -1, 493, -1, -1, -1,
1729 5, 6, -1, -1, -1, -1, -1, -1, 505, -1,
1730 15, -1, 17, -1, 19, -1, 513, -1, -1, -1,
1731 -1, -1, -1, -1, -1, -1, -1, 32, 33, -1,
1732 -1, -1, -1, -1, -1, -1, -1, -1, 535, -1,
1733 -1, -1, -1, 540, -1, -1, -1, -1, -1, -1,
1734 -1, -1, 135, -1, -1, 138, 553, 554, 141, -1,
1735 143, 558, -1, -1, 561, 70, 71, 72, 73, 74,
1736 75, 76, 77, 78, 79, 80, 81, 82, 83, -1,
1737 -1, 5, 6, -1, 8, 9, 10, 11, 12, 13,
1738 -1, 15, -1, 17, -1, -1, -1, -1, -1, -1,
1739 -1, -1, -1, -1, 109, 110, 111, 112, 113, 114,
1740 115, 116, 117, 118, 119, 120, 121, 41, 123, 124,
1741 125, 126, -1, 128, 129, 130, -1, -1, -1, 134,
1742 -1, 136, -1, 138, -1, -1, 141, -1, 143, -1,
1743 145, 5, 6, -1, 8, 9, 10, 11, 12, 13,
1744 -1, 15, -1, 17, -1, -1, -1, -1, -1, -1,
1745 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1746 -1, -1, -1, -1, -1, -1, -1, 41, 3, 4,
1747 5, 6, 7, -1, -1, -1, -1, -1, -1, -1,
1748 15, -1, 17, -1, 19, 20, 21, -1, -1, -1,
1749 -1, -1, -1, -1, -1, -1, -1, 32, 33, -1,
1750 -1, 135, -1, -1, 138, -1, -1, 141, -1, 143,
1751 144, -1, -1, -1, -1, -1, 5, 6, 53, 8,
1752 9, 10, 11, 12, 13, -1, 15, -1, 17, -1,
1753 -1, -1, -1, -1, -1, 70, 71, 72, 73, 74,
1754 75, 76, 77, 78, 79, 80, 81, 82, 83, -1,
1755 -1, -1, 41, -1, -1, -1, -1, -1, -1, -1,
1756 -1, 135, -1, -1, 138, -1, -1, 141, -1, 143,
1757 144, -1, -1, -1, 109, 110, 111, 112, 113, 114,
1758 115, 116, 117, 118, 119, 120, 121, -1, 123, 124,
1759 125, 126, -1, 128, 129, 130, -1, -1, -1, 134,
1760 -1, 136, -1, -1, -1, -1, 141, 3, 4, 5,
1761 6, 7, -1, -1, -1, -1, -1, -1, -1, 15,
1762 -1, 17, -1, 19, 20, 21, 20, 21, -1, -1,
1763 -1, -1, -1, -1, -1, -1, 32, 33, -1, -1,
1764 -1, -1, -1, -1, -1, -1, 135, -1, -1, 138,
1765 -1, 140, 141, -1, 143, -1, -1, 53, 5, 6,
1766 -1, 8, 9, 10, 11, 12, 13, -1, 15, -1,
1767 17, -1, -1, -1, 70, 71, 72, 73, 74, 75,
1768 76, 77, 78, 79, 80, 81, 82, 83, -1, -1,
1769 -1, -1, -1, -1, 41, -1, 90, 91, 92, 93,
1770 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
1771 -1, -1, -1, 109, 110, 111, 112, 113, 114, 115,
1772 116, 117, 118, 119, 120, 121, -1, 123, 124, 125,
1773 126, -1, 128, 129, 130, 3, 4, -1, -1, 7,
1774 -1, -1, -1, -1, -1, 141, -1, -1, -1, -1,
1775 -1, 19, 20, 21, -1, -1, -1, -1, -1, -1,
1776 -1, -1, -1, -1, 32, 33, -1, -1, -1, -1,
1777 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1778 -1, -1, -1, -1, -1, 53, -1, -1, 135, -1,
1779 -1, 138, -1, -1, 141, -1, 143, -1, -1, -1,
1780 -1, -1, 70, 71, 72, 73, 74, 75, 76, 77,
1781 78, 79, 80, 81, 82, 83, -1, -1, -1, -1,
1782 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1783 -1, 8, 9, 10, 11, 12, 13, -1, 15, -1,
1784 17, 109, 110, 111, 112, 113, 114, 115, 116, 117,
1785 118, 119, 120, 121, 31, 123, 124, 125, 126, -1,
1786 128, 129, 130, -1, 41, -1, -1, -1, -1, -1,
1787 -1, 5, 6, 141, 8, 9, 10, 11, 12, 13,
1788 -1, 15, -1, 17, 5, 6, -1, 8, 9, 10,
1789 11, 12, 13, -1, 15, -1, 17, 31, -1, -1,
1790 -1, -1, -1, -1, -1, -1, -1, 41, -1, -1,
1791 31, 5, 6, -1, 8, 9, 10, 11, 12, 13,
1792 41, 15, -1, 17, 5, 6, -1, 8, 9, 10,
1793 11, 12, 13, -1, 15, -1, 17, -1, 5, 6,
1794 -1, 8, 9, 10, 11, 12, 13, 41, 15, -1,
1795 17, -1, -1, -1, -1, -1, -1, -1, 135, -1,
1796 41, 138, -1, -1, 141, -1, 143, -1, -1, -1,
1797 -1, -1, 5, 6, 41, 8, 9, 10, 11, 12,
1798 13, -1, 15, -1, 17, -1, -1, -1, -1, -1,
1799 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1800 -1, 135, -1, -1, 138, -1, -1, 141, 41, 143,
1801 -1, -1, -1, -1, 135, -1, -1, 138, -1, -1,
1802 141, -1, 143, -1, -1, -1, -1, -1, -1, -1,
1803 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1804 -1, 135, 29, -1, 138, -1, -1, 141, -1, 143,
1805 -1, -1, -1, -1, 135, -1, -1, 138, -1, -1,
1806 141, -1, 143, -1, 51, 52, -1, -1, 135, -1,
1807 -1, 138, -1, -1, 141, -1, 143, 64, 65, 66,
1808 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1809 77, 78, 79, 80, 81, 82, 83, -1, -1, -1,
1810 -1, -1, 135, -1, -1, 138, -1, -1, 141, -1,
1811 143, -1, -1, -1, -1, -1, -1, 104, 105, 106,
1812 -1, -1, 109, 110, 111, 112, 113, 114, 115, 116,
1813 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
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 1020 "/Volumes/ProjectsDisk/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 1036 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2370 { yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2373 #line 1036 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2374 { yyval.IPredicate = ICmpInst::ICMP_NE; ;
2377 #line 1037 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2378 { yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2381 #line 1037 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2382 { yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2385 #line 1038 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2386 { yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2389 #line 1038 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2390 { yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2393 #line 1039 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2394 { yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2397 #line 1039 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2398 { yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2401 #line 1040 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2402 { yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2405 #line 1040 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2406 { yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2409 #line 1044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2410 { yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2413 #line 1044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2414 { yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2417 #line 1045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2418 { yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2421 #line 1045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2422 { yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2425 #line 1046 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2426 { yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2429 #line 1046 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2430 { yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2433 #line 1047 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2434 { yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2437 #line 1047 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2438 { yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2441 #line 1048 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2442 { yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2445 #line 1048 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2446 { yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2449 #line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2450 { yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2453 #line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2454 { yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2457 #line 1050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2458 { yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2461 #line 1050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2462 { yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2465 #line 1051 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2466 { yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2469 #line 1052 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2470 { yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2473 #line 1061 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2475 yyval.StrVal = yyvsp[-1].StrVal;
2480 #line 1065 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2487 #line 1071 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2488 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2491 #line 1072 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2492 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2495 #line 1073 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2496 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2499 #line 1074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2500 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2503 #line 1075 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2504 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2507 #line 1079 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2508 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2511 #line 1080 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2512 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2515 #line 1081 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2516 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2519 #line 1085 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2520 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2523 #line 1086 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2524 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2527 #line 1087 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2528 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2531 #line 1091 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2532 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2535 #line 1092 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2536 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2539 #line 1093 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2540 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2543 #line 1094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2544 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2547 #line 1095 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2548 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2551 #line 1098 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2552 { yyval.UIntVal = CallingConv::C; ;
2555 #line 1099 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2556 { yyval.UIntVal = CallingConv::C; ;
2559 #line 1100 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2560 { yyval.UIntVal = CallingConv::CSRet; ;
2563 #line 1101 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2564 { yyval.UIntVal = CallingConv::Fast; ;
2567 #line 1102 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2568 { yyval.UIntVal = CallingConv::Cold; ;
2571 #line 1103 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2572 { yyval.UIntVal = CallingConv::X86_StdCall; ;
2575 #line 1104 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2576 { yyval.UIntVal = CallingConv::X86_FastCall; ;
2579 #line 1105 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2581 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2582 GEN_ERROR("Calling conv too large!");
2583 yyval.UIntVal = yyvsp[0].UInt64Val;
2588 #line 1112 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2589 { yyval.ParamAttrs = FunctionType::ZExtAttribute; ;
2592 #line 1113 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2593 { yyval.ParamAttrs = FunctionType::SExtAttribute; ;
2596 #line 1116 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2597 { yyval.ParamAttrs = FunctionType::NoAttributeSet; ;
2600 #line 1117 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2602 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
2606 #line 1122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2607 { yyval.ParamAttrs = FunctionType::NoReturnAttribute; ;
2610 #line 1126 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2611 { yyval.ParamAttrs = FunctionType::NoAttributeSet; ;
2614 #line 1127 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2616 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
2620 #line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2621 { yyval.UIntVal = 0; ;
2624 #line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2626 yyval.UIntVal = yyvsp[0].UInt64Val;
2627 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2628 GEN_ERROR("Alignment must be a power of two!");
2633 #line 1141 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2634 { yyval.UIntVal = 0; ;
2637 #line 1142 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2639 yyval.UIntVal = yyvsp[0].UInt64Val;
2640 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2641 GEN_ERROR("Alignment must be a power of two!");
2646 #line 1150 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2648 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2649 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2650 GEN_ERROR("Invalid character in section name!");
2651 yyval.StrVal = yyvsp[0].StrVal;
2656 #line 1158 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2657 { yyval.StrVal = 0; ;
2660 #line 1159 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2661 { yyval.StrVal = yyvsp[0].StrVal; ;
2664 #line 1164 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2668 #line 1165 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2672 #line 1166 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2674 CurGV->setSection(yyvsp[0].StrVal);
2675 free(yyvsp[0].StrVal);
2680 #line 1171 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2682 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2683 GEN_ERROR("Alignment must be a power of two!");
2684 CurGV->setAlignment(yyvsp[0].UInt64Val);
2689 #line 1187 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2691 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2696 #line 1191 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2698 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2703 #line 1195 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2705 if (*yyvsp[-1].TypeVal == Type::LabelTy)
2706 GEN_ERROR("Cannot form a pointer to a basic block");
2707 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2708 delete yyvsp[-1].TypeVal;
2713 #line 1202 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2714 { // Named types are also simple types...
2715 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
2717 yyval.TypeVal = new PATypeHolder(tmp);
2721 #line 1207 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2722 { // Type UpReference
2723 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
2724 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2725 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2726 yyval.TypeVal = new PATypeHolder(OT);
2727 UR_OUT("New Upreference!\n");
2732 #line 1215 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2734 std::vector<const Type*> Params;
2735 std::vector<FunctionType::ParameterAttributes> Attrs;
2736 Attrs.push_back(yyvsp[0].ParamAttrs);
2737 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
2738 Params.push_back(I->Ty->get());
2739 if (I->Ty->get() != Type::VoidTy)
2740 Attrs.push_back(I->Attrs);
2742 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2743 if (isVarArg) Params.pop_back();
2745 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, Attrs);
2746 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2747 delete yyvsp[-4].TypeVal; // Delete the return type handle
2748 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
2753 #line 1233 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2755 std::vector<const Type*> Params;
2756 std::vector<FunctionType::ParameterAttributes> Attrs;
2757 Attrs.push_back(yyvsp[0].ParamAttrs);
2758 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
2759 Params.push_back(I->Ty->get());
2760 if (I->Ty->get() != Type::VoidTy)
2761 Attrs.push_back(I->Attrs);
2763 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2764 if (isVarArg) Params.pop_back();
2766 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, Attrs);
2767 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2768 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
2773 #line 1251 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2774 { // Sized array type?
2775 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2776 delete yyvsp[-1].TypeVal;
2781 #line 1256 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2782 { // Packed array type?
2783 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2784 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2785 GEN_ERROR("Unsigned result not equal to signed result");
2786 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
2787 GEN_ERROR("Element type of a PackedType must be primitive");
2788 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2789 GEN_ERROR("Vector length should be a power of 2!");
2790 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2791 delete yyvsp[-1].TypeVal;
2796 #line 1268 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2797 { // Structure type?
2798 std::vector<const Type*> Elements;
2799 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2800 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2801 Elements.push_back(*I);
2803 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2804 delete yyvsp[-1].TypeList;
2809 #line 1278 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2810 { // Empty structure type?
2811 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2816 #line 1282 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2818 std::vector<const Type*> Elements;
2819 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
2820 E = yyvsp[-2].TypeList->end(); I != E; ++I)
2821 Elements.push_back(*I);
2823 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
2824 delete yyvsp[-2].TypeList;
2829 #line 1292 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2830 { // Empty structure type?
2831 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
2836 #line 1299 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2838 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
2839 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
2843 #line 1306 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2845 if (!UpRefs.empty())
2846 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2847 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
2848 GEN_ERROR("LLVM functions cannot return aggregate types!");
2849 yyval.TypeVal = yyvsp[0].TypeVal;
2853 #line 1313 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2855 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
2859 #line 1318 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2861 yyval.TypeWithAttrsList = new TypeWithAttrsList();
2862 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
2867 #line 1323 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2869 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
2874 #line 1331 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2876 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
2877 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
2878 TWA.Ty = new PATypeHolder(Type::VoidTy);
2879 yyval.TypeWithAttrsList->push_back(TWA);
2884 #line 1338 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2886 yyval.TypeWithAttrsList = new TypeWithAttrsList;
2887 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
2888 TWA.Ty = new PATypeHolder(Type::VoidTy);
2889 yyval.TypeWithAttrsList->push_back(TWA);
2894 #line 1345 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2896 yyval.TypeWithAttrsList = new TypeWithAttrsList();
2901 #line 1353 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2903 yyval.TypeList = new std::list<PATypeHolder>();
2904 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2909 #line 1358 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2911 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2916 #line 1369 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2917 { // Nonempty unsized arr
2918 if (!UpRefs.empty())
2919 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
2920 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2922 GEN_ERROR("Cannot make array constant with type: '" +
2923 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2924 const Type *ETy = ATy->getElementType();
2925 int NumElements = ATy->getNumElements();
2927 // Verify that we have the correct size...
2928 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2929 GEN_ERROR("Type mismatch: constant sized array initialized with " +
2930 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2931 itostr(NumElements) + "!");
2933 // Verify all elements are correct type!
2934 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2935 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2936 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
2937 ETy->getDescription() +"' as required!\nIt is of type '"+
2938 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2941 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2942 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2947 #line 1397 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2949 if (!UpRefs.empty())
2950 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
2951 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2953 GEN_ERROR("Cannot make array constant with type: '" +
2954 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2956 int NumElements = ATy->getNumElements();
2957 if (NumElements != -1 && NumElements != 0)
2958 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
2959 " arguments, but has size of " + itostr(NumElements) +"!");
2960 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2961 delete yyvsp[-2].TypeVal;
2966 #line 1413 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2968 if (!UpRefs.empty())
2969 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
2970 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2972 GEN_ERROR("Cannot make array constant with type: '" +
2973 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2975 int NumElements = ATy->getNumElements();
2976 const Type *ETy = ATy->getElementType();
2977 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2978 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2979 GEN_ERROR("Can't build string constant of size " +
2980 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2981 " when array has size " + itostr(NumElements) + "!");
2982 std::vector<Constant*> Vals;
2983 if (ETy == Type::Int8Ty) {
2984 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2985 C != (unsigned char*)EndStr; ++C)
2986 Vals.push_back(ConstantInt::get(ETy, *C));
2988 free(yyvsp[0].StrVal);
2989 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
2991 free(yyvsp[0].StrVal);
2992 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2993 delete yyvsp[-2].TypeVal;
2998 #line 1442 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2999 { // Nonempty unsized arr
3000 if (!UpRefs.empty())
3001 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3002 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
3004 GEN_ERROR("Cannot make packed constant with type: '" +
3005 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
3006 const Type *ETy = PTy->getElementType();
3007 int NumElements = PTy->getNumElements();
3009 // Verify that we have the correct size...
3010 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
3011 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
3012 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
3013 itostr(NumElements) + "!");
3015 // Verify all elements are correct type!
3016 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3017 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3018 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3019 ETy->getDescription() +"' as required!\nIt is of type '"+
3020 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3023 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
3024 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3029 #line 1470 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3031 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
3033 GEN_ERROR("Cannot make struct constant with type: '" +
3034 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
3036 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
3037 GEN_ERROR("Illegal number of initializers for structure type!");
3039 // Check to ensure that constants are compatible with the type initializer!
3040 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3041 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
3042 GEN_ERROR("Expected type '" +
3043 STy->getElementType(i)->getDescription() +
3044 "' for element #" + utostr(i) +
3045 " of structure initializer!");
3047 // Check to ensure that Type is not packed
3048 if (STy->isPacked())
3049 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3051 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3052 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3057 #line 1495 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3059 if (!UpRefs.empty())
3060 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3061 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
3063 GEN_ERROR("Cannot make struct constant with type: '" +
3064 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
3066 if (STy->getNumContainedTypes() != 0)
3067 GEN_ERROR("Illegal number of initializers for structure type!");
3069 // Check to ensure that Type is not packed
3070 if (STy->isPacked())
3071 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3073 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3074 delete yyvsp[-2].TypeVal;
3079 #line 1514 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3081 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
3083 GEN_ERROR("Cannot make struct constant with type: '" +
3084 (*yyvsp[-5].TypeVal)->getDescription() + "'!");
3086 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
3087 GEN_ERROR("Illegal number of initializers for structure type!");
3089 // Check to ensure that constants are compatible with the type initializer!
3090 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3091 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
3092 GEN_ERROR("Expected type '" +
3093 STy->getElementType(i)->getDescription() +
3094 "' for element #" + utostr(i) +
3095 " of structure initializer!");
3097 // Check to ensure that Type is packed
3098 if (!STy->isPacked())
3099 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3101 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3102 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
3107 #line 1539 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3109 if (!UpRefs.empty())
3110 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3111 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
3113 GEN_ERROR("Cannot make struct constant with type: '" +
3114 (*yyvsp[-4].TypeVal)->getDescription() + "'!");
3116 if (STy->getNumContainedTypes() != 0)
3117 GEN_ERROR("Illegal number of initializers for structure type!");
3119 // Check to ensure that Type is packed
3120 if (!STy->isPacked())
3121 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3123 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3124 delete yyvsp[-4].TypeVal;
3129 #line 1558 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3131 if (!UpRefs.empty())
3132 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3133 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3135 GEN_ERROR("Cannot make null pointer constant with type: '" +
3136 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
3138 yyval.ConstVal = ConstantPointerNull::get(PTy);
3139 delete yyvsp[-1].TypeVal;
3144 #line 1570 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3146 if (!UpRefs.empty())
3147 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3148 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3149 delete yyvsp[-1].TypeVal;
3154 #line 1577 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3156 if (!UpRefs.empty())
3157 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3158 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3160 GEN_ERROR("Global const reference must be a pointer type!");
3162 // ConstExprs can exist in the body of a function, thus creating
3163 // GlobalValues whenever they refer to a variable. Because we are in
3164 // the context of a function, getValNonImprovising will search the functions
3165 // symbol table instead of the module symbol table for the global symbol,
3166 // which throws things all off. To get around this, we just tell
3167 // getValNonImprovising that we are at global scope here.
3169 Function *SavedCurFn = CurFun.CurrentFunction;
3170 CurFun.CurrentFunction = 0;
3172 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
3175 CurFun.CurrentFunction = SavedCurFn;
3177 // If this is an initializer for a constant pointer, which is referencing a
3178 // (currently) undefined variable, create a stub now that shall be replaced
3179 // in the future with the right type of variable.
3182 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3183 const PointerType *PT = cast<PointerType>(Ty);
3185 // First check to see if the forward references value is already created!
3186 PerModuleInfo::GlobalRefsType::iterator I =
3187 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
3189 if (I != CurModule.GlobalRefs.end()) {
3190 V = I->second; // Placeholder already exists, use it...
3191 yyvsp[0].ValIDVal.destroy();
3194 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
3196 // Create the forward referenced global.
3198 if (const FunctionType *FTy =
3199 dyn_cast<FunctionType>(PT->getElementType())) {
3200 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3201 CurModule.CurrentModule);
3203 GV = new GlobalVariable(PT->getElementType(), false,
3204 GlobalValue::ExternalLinkage, 0,
3205 Name, CurModule.CurrentModule);
3208 // Keep track of the fact that we have a forward ref to recycle it
3209 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
3214 yyval.ConstVal = cast<GlobalValue>(V);
3215 delete yyvsp[-1].TypeVal; // Free the type handle
3220 #line 1640 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3222 if (!UpRefs.empty())
3223 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3224 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
3225 GEN_ERROR("Mismatched types for constant expression: " +
3226 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3227 yyval.ConstVal = yyvsp[0].ConstVal;
3228 delete yyvsp[-1].TypeVal;
3233 #line 1650 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3235 if (!UpRefs.empty())
3236 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3237 const Type *Ty = yyvsp[-1].TypeVal->get();
3238 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3239 GEN_ERROR("Cannot create a null initialized value of this type!");
3240 yyval.ConstVal = Constant::getNullValue(Ty);
3241 delete yyvsp[-1].TypeVal;
3246 #line 1660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3247 { // integral constants
3248 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
3249 GEN_ERROR("Constant value doesn't fit in type!");
3250 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
3255 #line 1666 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3256 { // integral constants
3257 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
3258 GEN_ERROR("Constant value doesn't fit in type!");
3259 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
3264 #line 1672 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3265 { // Boolean constants
3266 yyval.ConstVal = ConstantInt::getTrue();
3271 #line 1676 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3272 { // Boolean constants
3273 yyval.ConstVal = ConstantInt::getFalse();
3278 #line 1680 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3279 { // Float & Double constants
3280 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
3281 GEN_ERROR("Floating point constant invalid for type!!");
3282 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
3287 #line 1688 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3289 if (!UpRefs.empty())
3290 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3291 Constant *Val = yyvsp[-3].ConstVal;
3292 const Type *Ty = yyvsp[-1].TypeVal->get();
3293 if (!Val->getType()->isFirstClassType())
3294 GEN_ERROR("cast constant expression from a non-primitive type: '" +
3295 Val->getType()->getDescription() + "'!");
3296 if (!Ty->isFirstClassType())
3297 GEN_ERROR("cast constant expression to a non-primitive type: '" +
3298 Ty->getDescription() + "'!");
3299 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3300 delete yyvsp[-1].TypeVal;
3304 #line 1702 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3306 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
3307 GEN_ERROR("GetElementPtr requires a pointer operand!");
3310 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
3312 GEN_ERROR("Index list invalid for constant getelementptr!");
3314 std::vector<Constant*> IdxVec;
3315 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3316 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
3317 IdxVec.push_back(C);
3319 GEN_ERROR("Indices to constant getelementptr must be constants!");
3321 delete yyvsp[-1].ValueList;
3323 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
3328 #line 1723 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3330 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
3331 GEN_ERROR("Select condition must be of boolean type!");
3332 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3333 GEN_ERROR("Select operand types must match!");
3334 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3339 #line 1731 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3341 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3342 GEN_ERROR("Binary operator types must match!");
3344 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3348 #line 1737 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3350 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3351 GEN_ERROR("Logical operator types must match!");
3352 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
3353 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3354 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
3355 GEN_ERROR("Logical operator requires integral operands!");
3357 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3362 #line 1748 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3364 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3365 GEN_ERROR("icmp operand types must match!");
3366 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3370 #line 1753 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3372 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3373 GEN_ERROR("fcmp operand types must match!");
3374 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3378 #line 1758 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3380 if (yyvsp[-1].ConstVal->getType() != Type::Int8Ty)
3381 GEN_ERROR("Shift count for shift constant must be i8 type!");
3382 if (!yyvsp[-3].ConstVal->getType()->isInteger())
3383 GEN_ERROR("Shift constant expression requires integer operand!");
3385 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3390 #line 1767 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3392 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3393 GEN_ERROR("Invalid extractelement operands!");
3394 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3399 #line 1773 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3401 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3402 GEN_ERROR("Invalid insertelement operands!");
3403 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3408 #line 1779 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3410 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3411 GEN_ERROR("Invalid shufflevector operands!");
3412 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3417 #line 1788 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3419 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
3424 #line 1792 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3426 yyval.ConstVector = new std::vector<Constant*>();
3427 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
3432 #line 1800 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3433 { yyval.BoolVal = false; ;
3436 #line 1800 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3437 { yyval.BoolVal = true; ;
3440 #line 1811 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3442 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
3443 CurModule.ModuleDone();
3448 #line 1816 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3450 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
3451 CurModule.ModuleDone();
3456 #line 1829 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3457 { CurFun.isDeclare = false ;
3460 #line 1829 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3462 CurFun.FunctionDone();
3467 #line 1833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3468 { CurFun.isDeclare = true; ;
3471 #line 1833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3477 #line 1836 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3483 #line 1839 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3485 // Emit an error if there are any unresolved types left.
3486 if (!CurModule.LateResolveTypes.empty()) {
3487 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
3488 if (DID.Type == ValID::NameVal) {
3489 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3491 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3498 #line 1851 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3500 if (!UpRefs.empty())
3501 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3502 // Eagerly resolve types. This is not an optimization, this is a
3503 // requirement that is due to the fact that we could have this:
3505 // %list = type { %list * }
3506 // %list = type { %list * } ; repeated type decl
3508 // If types are not resolved eagerly, then the two types will not be
3509 // determined to be the same type!
3511 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3513 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3515 // If this is a named type that is not a redefinition, add it to the slot
3517 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3520 delete yyvsp[0].TypeVal;
3525 #line 1875 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3527 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
3529 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3531 // If this is a named type that is not a redefinition, add it to the slot
3533 CurModule.Types.push_back(yyvsp[0].PrimType);
3539 #line 1886 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3540 { /* "Externally Visible" Linkage */
3541 if (yyvsp[0].ConstVal == 0)
3542 GEN_ERROR("Global value initializer is not a constant!");
3543 CurGV = ParseGlobalVariable(yyvsp[-2].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal,
3544 yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3549 #line 1892 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3555 #line 1895 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3557 if (yyvsp[0].ConstVal == 0)
3558 GEN_ERROR("Global value initializer is not a constant!");
3559 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3564 #line 1900 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3570 #line 1903 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3572 if (!UpRefs.empty())
3573 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3574 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3576 delete yyvsp[0].TypeVal;
3580 #line 1909 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3587 #line 1913 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3593 #line 1916 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3599 #line 1922 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3601 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3602 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3603 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3604 free(yyvsp[0].StrVal);
3606 if (AsmSoFar.empty())
3607 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3609 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
3614 #line 1935 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3615 { yyval.Endianness = Module::BigEndian; ;
3618 #line 1936 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3619 { yyval.Endianness = Module::LittleEndian; ;
3622 #line 1938 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3624 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3629 #line 1942 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3631 if (yyvsp[0].UInt64Val == 32)
3632 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3633 else if (yyvsp[0].UInt64Val == 64)
3634 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3636 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3641 #line 1951 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3643 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3644 free(yyvsp[0].StrVal);
3648 #line 1955 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3650 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
3651 free(yyvsp[0].StrVal);
3655 #line 1962 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3657 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3658 free(yyvsp[0].StrVal);
3663 #line 1967 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3665 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3666 free(yyvsp[0].StrVal);
3671 #line 1972 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3677 #line 1982 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3678 { yyval.StrVal = 0; ;
3681 #line 1984 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3683 if (!UpRefs.empty())
3684 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3685 if (*yyvsp[-2].TypeVal == Type::VoidTy)
3686 GEN_ERROR("void typed arguments are invalid!");
3687 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3688 yyval.ArgList = yyvsp[-4].ArgList;
3689 yyvsp[-4].ArgList->push_back(E);
3694 #line 1994 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3696 if (!UpRefs.empty())
3697 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3698 if (*yyvsp[-2].TypeVal == Type::VoidTy)
3699 GEN_ERROR("void typed arguments are invalid!");
3700 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3701 yyval.ArgList = new ArgListType;
3702 yyval.ArgList->push_back(E);
3707 #line 2005 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3709 yyval.ArgList = yyvsp[0].ArgList;
3714 #line 2009 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3716 yyval.ArgList = yyvsp[-2].ArgList;
3717 struct ArgListEntry E;
3718 E.Ty = new PATypeHolder(Type::VoidTy);
3720 E.Attrs = FunctionType::NoAttributeSet;
3721 yyval.ArgList->push_back(E);
3726 #line 2018 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3728 yyval.ArgList = new ArgListType;
3729 struct ArgListEntry E;
3730 E.Ty = new PATypeHolder(Type::VoidTy);
3732 E.Attrs = FunctionType::NoAttributeSet;
3733 yyval.ArgList->push_back(E);
3738 #line 2027 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3745 #line 2033 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3747 UnEscapeLexed(yyvsp[-6].StrVal);
3748 std::string FunctionName(yyvsp[-6].StrVal);
3749 free(yyvsp[-6].StrVal); // Free strdup'd memory!
3751 // Check the function result for abstractness if this is a define. We should
3752 // have no abstract types at this point
3753 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
3754 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
3756 std::vector<const Type*> ParamTypeList;
3757 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
3758 ParamAttrs.push_back(yyvsp[-2].ParamAttrs);
3759 if (yyvsp[-4].ArgList) { // If there are arguments...
3760 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I) {
3761 const Type* Ty = I->Ty->get();
3762 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
3763 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
3764 ParamTypeList.push_back(Ty);
3765 if (Ty != Type::VoidTy)
3766 ParamAttrs.push_back(I->Attrs);
3770 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3771 if (isVarArg) ParamTypeList.pop_back();
3773 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg,
3775 const PointerType *PFT = PointerType::get(FT);
3776 delete yyvsp[-7].TypeVal;
3779 if (!FunctionName.empty()) {
3780 ID = ValID::create((char*)FunctionName.c_str());
3782 ID = ValID::create((int)CurModule.Values[PFT].size());
3786 // See if this function was forward referenced. If so, recycle the object.
3787 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3788 // Move the function to the end of the list, from whereever it was
3789 // previously inserted.
3790 Fn = cast<Function>(FWRef);
3791 CurModule.CurrentModule->getFunctionList().remove(Fn);
3792 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3793 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3794 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3795 // If this is the case, either we need to be a forward decl, or it needs
3797 if (!CurFun.isDeclare && !Fn->isExternal())
3798 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
3800 // Make sure to strip off any argument names so we can't get conflicts.
3801 if (Fn->isExternal())
3802 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3805 } else { // Not already defined?
3806 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3807 CurModule.CurrentModule);
3809 InsertValue(Fn, CurModule.Values);
3812 CurFun.FunctionStart(Fn);
3814 if (CurFun.isDeclare) {
3815 // If we have declaration, always overwrite linkage. This will allow us to
3816 // correctly handle cases, when pointer to function is passed as argument to
3817 // another function.
3818 Fn->setLinkage(CurFun.Linkage);
3820 Fn->setCallingConv(yyvsp[-8].UIntVal);
3821 Fn->setAlignment(yyvsp[0].UIntVal);
3822 if (yyvsp[-1].StrVal) {
3823 Fn->setSection(yyvsp[-1].StrVal);
3824 free(yyvsp[-1].StrVal);
3827 // Add all of the arguments we parsed to the function...
3828 if (yyvsp[-4].ArgList) { // Is null if empty...
3829 if (isVarArg) { // Nuke the last entry
3830 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0&&
3831 "Not a varargs marker!");
3832 delete yyvsp[-4].ArgList->back().Ty;
3833 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
3835 Function::arg_iterator ArgIt = Fn->arg_begin();
3837 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++ArgIt) {
3838 delete I->Ty; // Delete the typeholder...
3839 setValueName(ArgIt, I->Name); // Insert arg into symtab...
3845 delete yyvsp[-4].ArgList; // We're now done with the argument list
3851 #line 2139 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3853 yyval.FunctionVal = CurFun.CurrentFunction;
3855 // Make sure that we keep track of the linkage type even if there was a
3856 // previous "declare".
3857 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3861 #line 2149 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3863 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3868 #line 2154 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3870 CurFun.CurrentFunction->setLinkage(yyvsp[-1].Linkage);
3871 yyval.FunctionVal = CurFun.CurrentFunction;
3872 CurFun.FunctionDone();
3877 #line 2165 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3879 yyval.BoolVal = false;
3884 #line 2169 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3886 yyval.BoolVal = true;
3891 #line 2174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3892 { // A reference to a direct constant
3893 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3898 #line 2178 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3900 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3905 #line 2182 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3906 { // Perhaps it's an FP constant?
3907 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3912 #line 2186 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3914 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
3919 #line 2190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3921 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
3926 #line 2194 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3928 yyval.ValIDVal = ValID::createNull();
3933 #line 2198 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3935 yyval.ValIDVal = ValID::createUndef();
3940 #line 2202 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3941 { // A vector zero constant.
3942 yyval.ValIDVal = ValID::createZeroInit();
3947 #line 2206 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3948 { // Nonempty unsized packed vector
3949 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3950 int NumElements = yyvsp[-1].ConstVector->size();
3952 PackedType* pt = PackedType::get(ETy, NumElements);
3953 PATypeHolder* PTy = new PATypeHolder(
3961 // Verify all elements are correct type!
3962 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3963 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3964 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3965 ETy->getDescription() +"' as required!\nIt is of type '" +
3966 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3969 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3970 delete PTy; delete yyvsp[-1].ConstVector;
3975 #line 2231 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3977 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3982 #line 2235 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3984 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3985 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3986 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3987 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3988 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3989 free(yyvsp[-2].StrVal);
3990 free(yyvsp[0].StrVal);
3995 #line 2249 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3996 { // Is it an integer reference...?
3997 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
4002 #line 2253 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4003 { // Is it a named reference...?
4004 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
4009 #line 2265 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4011 if (!UpRefs.empty())
4012 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4013 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4014 delete yyvsp[-1].TypeVal;
4019 #line 2274 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4021 yyval.FunctionVal = yyvsp[-1].FunctionVal;
4026 #line 2278 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4027 { // Do not allow functions with 0 basic blocks
4028 yyval.FunctionVal = yyvsp[-1].FunctionVal;
4033 #line 2287 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4035 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
4037 InsertValue(yyvsp[0].TermInstVal);
4039 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4040 InsertValue(yyvsp[-2].BasicBlockVal);
4041 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
4046 #line 2298 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4048 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
4049 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4050 if (CI2->getParent() == 0)
4051 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4052 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4053 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
4058 #line 2307 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4060 yyval.BasicBlockVal = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
4063 // Make sure to move the basic block to the correct location in the
4064 // function, instead of leaving it inserted wherever it was first
4066 Function::BasicBlockListType &BBL =
4067 CurFun.CurrentFunction->getBasicBlockList();
4068 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
4073 #line 2319 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4075 yyval.BasicBlockVal = getBBVal(ValID::create(yyvsp[0].StrVal), true);
4078 // Make sure to move the basic block to the correct location in the
4079 // function, instead of leaving it inserted wherever it was first
4081 Function::BasicBlockListType &BBL =
4082 CurFun.CurrentFunction->getBasicBlockList();
4083 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
4088 #line 2332 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4089 { // Return with a result...
4090 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4095 #line 2336 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4096 { // Return with no result...
4097 yyval.TermInstVal = new ReturnInst();
4102 #line 2340 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4103 { // Unconditional Branch...
4104 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4106 yyval.TermInstVal = new BranchInst(tmpBB);
4110 #line 2345 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4112 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4114 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4116 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4118 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4122 #line 2354 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4124 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4126 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4128 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4129 yyval.TermInstVal = S;
4131 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4132 E = yyvsp[-1].JumpTable->end();
4133 for (; I != E; ++I) {
4134 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4135 S->addCase(CI, I->second);
4137 GEN_ERROR("Switch case is constant, but not a simple integer!");
4139 delete yyvsp[-1].JumpTable;
4144 #line 2373 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4146 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
4148 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
4150 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
4151 yyval.TermInstVal = S;
4156 #line 2383 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4159 // Handle the short syntax
4160 const PointerType *PFTy = 0;
4161 const FunctionType *Ty = 0;
4162 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
4163 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4164 // Pull out the types of all of the arguments...
4165 std::vector<const Type*> ParamTypes;
4166 FunctionType::ParamAttrsList ParamAttrs;
4167 ParamAttrs.push_back(yyvsp[-6].ParamAttrs);
4168 for (ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); I != E; ++I) {
4169 const Type *Ty = I->Val->getType();
4170 if (Ty == Type::VoidTy)
4171 GEN_ERROR("Short call syntax cannot be used with varargs");
4172 ParamTypes.push_back(Ty);
4173 ParamAttrs.push_back(I->Attrs);
4176 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, ParamAttrs);
4177 PFTy = PointerType::get(Ty);
4180 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
4182 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
4184 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
4187 // Check the arguments
4189 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
4190 // Make sure no arguments is a good thing!
4191 if (Ty->getNumParams() != 0)
4192 GEN_ERROR("No arguments passed to a function that "
4193 "expects arguments!");
4194 } else { // Has arguments?
4195 // Loop through FunctionType's arguments and ensure they are specified
4197 FunctionType::param_iterator I = Ty->param_begin();
4198 FunctionType::param_iterator E = Ty->param_end();
4199 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
4201 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4202 if (ArgI->Val->getType() != *I)
4203 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4204 (*I)->getDescription() + "'!");
4205 Args.push_back(ArgI->Val);
4208 if (Ty->isVarArg()) {
4210 for (; ArgI != ArgE; ++ArgI)
4211 Args.push_back(ArgI->Val); // push the remaining varargs
4212 } else if (I != E || ArgI != ArgE)
4213 GEN_ERROR("Invalid number of parameters detected!");
4216 // Create the InvokeInst
4217 InvokeInst *II = new InvokeInst(V, Normal, Except, Args);
4218 II->setCallingConv(yyvsp[-12].UIntVal);
4219 yyval.TermInstVal = II;
4220 delete yyvsp[-8].ValueRefList;
4225 #line 2449 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4227 yyval.TermInstVal = new UnwindInst();
4232 #line 2453 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4234 yyval.TermInstVal = new UnreachableInst();
4239 #line 2460 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4241 yyval.JumpTable = yyvsp[-5].JumpTable;
4242 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4245 GEN_ERROR("May only switch on a constant pool value!");
4247 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4249 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4253 #line 2471 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4255 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4256 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4260 GEN_ERROR("May only switch on a constant pool value!");
4262 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4264 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4268 #line 2484 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4270 // Is this definition named?? if so, assign the name...
4271 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
4273 InsertValue(yyvsp[0].InstVal);
4274 yyval.InstVal = yyvsp[0].InstVal;
4279 #line 2493 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4280 { // Used for PHI nodes
4281 if (!UpRefs.empty())
4282 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4283 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4284 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
4286 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4288 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4289 delete yyvsp[-5].TypeVal;
4293 #line 2504 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4295 yyval.PHIList = yyvsp[-6].PHIList;
4296 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
4298 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4300 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4304 #line 2514 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4306 if (!UpRefs.empty())
4307 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4308 // Used for call and invoke instructions
4309 yyval.ValueRefList = new ValueRefList();
4310 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4311 yyval.ValueRefList->push_back(E);
4315 #line 2522 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4317 if (!UpRefs.empty())
4318 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4319 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4320 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4321 yyval.ValueRefList->push_back(E);
4326 #line 2530 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4327 { yyval.ValueRefList = new ValueRefList(); ;
4330 #line 2533 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4331 { yyval.ValueList = new std::vector<Value*>(); ;
4334 #line 2534 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4336 yyval.ValueList = yyvsp[-2].ValueList;
4337 yyval.ValueList->push_back(yyvsp[0].ValueVal);
4342 #line 2541 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4344 yyval.BoolVal = true;
4349 #line 2545 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4351 yyval.BoolVal = false;
4356 #line 2550 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4358 if (!UpRefs.empty())
4359 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4360 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4361 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4363 "Arithmetic operator requires integer, FP, or packed operands!");
4364 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) &&
4365 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4366 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4367 yyvsp[-4].BinaryOpVal == Instruction::FRem))
4368 GEN_ERROR("U/S/FRem not supported on packed types!");
4369 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4371 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4373 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4374 if (yyval.InstVal == 0)
4375 GEN_ERROR("binary operator returned null!");
4376 delete yyvsp[-3].TypeVal;
4380 #line 2571 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4382 if (!UpRefs.empty())
4383 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4384 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
4385 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
4386 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
4387 GEN_ERROR("Logical operator requires integral operands!");
4389 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4391 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4393 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4394 if (yyval.InstVal == 0)
4395 GEN_ERROR("binary operator returned null!");
4396 delete yyvsp[-3].TypeVal;
4400 #line 2588 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4402 if (!UpRefs.empty())
4403 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4404 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4405 GEN_ERROR("Packed types not supported by icmp instruction");
4406 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4408 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4410 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4411 if (yyval.InstVal == 0)
4412 GEN_ERROR("icmp operator returned null!");
4416 #line 2601 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4418 if (!UpRefs.empty())
4419 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4420 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4421 GEN_ERROR("Packed types not supported by fcmp instruction");
4422 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4424 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4426 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4427 if (yyval.InstVal == 0)
4428 GEN_ERROR("fcmp operator returned null!");
4432 #line 2614 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4434 if (yyvsp[0].ValueVal->getType() != Type::Int8Ty)
4435 GEN_ERROR("Shift amount must be i8 type!");
4436 if (!yyvsp[-2].ValueVal->getType()->isInteger())
4437 GEN_ERROR("Shift constant expression requires integer operand!");
4439 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4444 #line 2623 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4446 if (!UpRefs.empty())
4447 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4448 Value* Val = yyvsp[-2].ValueVal;
4449 const Type* Ty = yyvsp[0].TypeVal->get();
4450 if (!Val->getType()->isFirstClassType())
4451 GEN_ERROR("cast from a non-primitive type: '" +
4452 Val->getType()->getDescription() + "'!");
4453 if (!Ty->isFirstClassType())
4454 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
4455 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, yyvsp[0].TypeVal->get());
4456 delete yyvsp[0].TypeVal;
4460 #line 2636 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4462 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
4463 GEN_ERROR("select condition must be boolean!");
4464 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
4465 GEN_ERROR("select value types should match!");
4466 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4471 #line 2644 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4473 if (!UpRefs.empty())
4474 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4475 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4476 delete yyvsp[0].TypeVal;
4481 #line 2651 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4483 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4484 GEN_ERROR("Invalid extractelement operands!");
4485 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4490 #line 2657 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4492 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4493 GEN_ERROR("Invalid insertelement operands!");
4494 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4499 #line 2663 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4501 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4502 GEN_ERROR("Invalid shufflevector operands!");
4503 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4508 #line 2669 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4510 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
4511 if (!Ty->isFirstClassType())
4512 GEN_ERROR("PHI node operands must be of first class type!");
4513 yyval.InstVal = new PHINode(Ty);
4514 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4515 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4516 if (yyvsp[0].PHIList->front().first->getType() != Ty)
4517 GEN_ERROR("All elements of a PHI node must be of the same type!");
4518 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4519 yyvsp[0].PHIList->pop_front();
4521 delete yyvsp[0].PHIList; // Free the list...
4526 #line 2685 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4529 // Handle the short syntax
4530 const PointerType *PFTy = 0;
4531 const FunctionType *Ty = 0;
4532 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
4533 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4534 // Pull out the types of all of the arguments...
4535 std::vector<const Type*> ParamTypes;
4536 FunctionType::ParamAttrsList ParamAttrs;
4537 ParamAttrs.push_back(yyvsp[0].ParamAttrs);
4538 for (ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); I != E; ++I) {
4539 const Type *Ty = I->Val->getType();
4540 if (Ty == Type::VoidTy)
4541 GEN_ERROR("Short call syntax cannot be used with varargs");
4542 ParamTypes.push_back(Ty);
4543 ParamAttrs.push_back(I->Attrs);
4546 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, ParamAttrs);
4547 PFTy = PointerType::get(Ty);
4550 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
4553 // Check the arguments
4555 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
4556 // Make sure no arguments is a good thing!
4557 if (Ty->getNumParams() != 0)
4558 GEN_ERROR("No arguments passed to a function that "
4559 "expects arguments!");
4560 } else { // Has arguments?
4561 // Loop through FunctionType's arguments and ensure they are specified
4564 FunctionType::param_iterator I = Ty->param_begin();
4565 FunctionType::param_iterator E = Ty->param_end();
4566 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
4568 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4569 if (ArgI->Val->getType() != *I)
4570 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4571 (*I)->getDescription() + "'!");
4572 Args.push_back(ArgI->Val);
4574 if (Ty->isVarArg()) {
4576 for (; ArgI != ArgE; ++ArgI)
4577 Args.push_back(ArgI->Val); // push the remaining varargs
4578 } else if (I != E || ArgI != ArgE)
4579 GEN_ERROR("Invalid number of parameters detected!");
4581 // Create the call node
4582 CallInst *CI = new CallInst(V, Args);
4583 CI->setTailCall(yyvsp[-7].BoolVal);
4584 CI->setCallingConv(yyvsp[-6].UIntVal);
4586 delete yyvsp[-2].ValueRefList;
4591 #line 2747 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4593 yyval.InstVal = yyvsp[0].InstVal;
4598 #line 2752 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4600 yyval.BoolVal = true;
4605 #line 2756 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4607 yyval.BoolVal = false;
4612 #line 2763 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4614 if (!UpRefs.empty())
4615 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4616 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4617 delete yyvsp[-1].TypeVal;
4622 #line 2770 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4624 if (!UpRefs.empty())
4625 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4626 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4628 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4629 delete yyvsp[-4].TypeVal;
4633 #line 2778 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4635 if (!UpRefs.empty())
4636 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4637 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4638 delete yyvsp[-1].TypeVal;
4643 #line 2785 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4645 if (!UpRefs.empty())
4646 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4647 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4649 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4650 delete yyvsp[-4].TypeVal;
4654 #line 2793 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4656 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
4657 GEN_ERROR("Trying to free nonpointer type " +
4658 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4659 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
4664 #line 2801 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4666 if (!UpRefs.empty())
4667 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4668 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4669 GEN_ERROR("Can't load from nonpointer type: " +
4670 (*yyvsp[-1].TypeVal)->getDescription());
4671 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4672 GEN_ERROR("Can't load from pointer of non-first-class type: " +
4673 (*yyvsp[-1].TypeVal)->getDescription());
4674 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4676 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
4677 delete yyvsp[-1].TypeVal;
4681 #line 2815 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4683 if (!UpRefs.empty())
4684 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4685 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4687 GEN_ERROR("Can't store to a nonpointer type: " +
4688 (*yyvsp[-1].TypeVal)->getDescription());
4689 const Type *ElTy = PT->getElementType();
4690 if (ElTy != yyvsp[-3].ValueVal->getType())
4691 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4692 "' into space of type '" + ElTy->getDescription() + "'!");
4694 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4696 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
4697 delete yyvsp[-1].TypeVal;
4701 #line 2832 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4703 if (!UpRefs.empty())
4704 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4705 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4706 GEN_ERROR("getelementptr insn requires pointer operand!");
4708 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4709 GEN_ERROR("Invalid getelementptr indices for type '" +
4710 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4711 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
4713 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
4714 delete yyvsp[-2].TypeVal;
4715 delete yyvsp[0].ValueList;
4719 /* the action file gets copied in in place of this dollarsign */
4720 #line 543 "/usr/share/bison.simple"
4731 short *ssp1 = yyss - 1;
4732 fprintf (stderr, "state stack now");
4733 while (ssp1 != yyssp)
4734 fprintf (stderr, " %d", *++ssp1);
4735 fprintf (stderr, "\n");
4745 yylsp->first_line = yylloc.first_line;
4746 yylsp->first_column = yylloc.first_column;
4747 yylsp->last_line = (yylsp-1)->last_line;
4748 yylsp->last_column = (yylsp-1)->last_column;
4753 yylsp->last_line = (yylsp+yylen-1)->last_line;
4754 yylsp->last_column = (yylsp+yylen-1)->last_column;
4758 /* Now "shift" the result of the reduction.
4759 Determine what state that goes to,
4760 based on the state we popped back to
4761 and the rule number reduced by. */
4765 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4766 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4767 yystate = yytable[yystate];
4769 yystate = yydefgoto[yyn - YYNTBASE];
4773 yyerrlab: /* here on detecting error */
4776 /* If not already recovering from an error, report this error. */
4780 #ifdef YYERROR_VERBOSE
4781 yyn = yypact[yystate];
4783 if (yyn > YYFLAG && yyn < YYLAST)
4790 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4791 for (x = (yyn < 0 ? -yyn : 0);
4792 x < (sizeof(yytname) / sizeof(char *)); x++)
4793 if (yycheck[x + yyn] == x)
4794 size += strlen(yytname[x]) + 15, count++;
4795 msg = (char *) malloc(size + 15);
4798 strcpy(msg, "parse error");
4803 for (x = (yyn < 0 ? -yyn : 0);
4804 x < (sizeof(yytname) / sizeof(char *)); x++)
4805 if (yycheck[x + yyn] == x)
4807 strcat(msg, count == 0 ? ", expecting `" : " or `");
4808 strcat(msg, yytname[x]);
4817 yyerror ("parse error; also virtual memory exceeded");
4820 #endif /* YYERROR_VERBOSE */
4821 yyerror("parse error");
4825 yyerrlab1: /* here on error raised explicitly by an action */
4827 if (yyerrstatus == 3)
4829 /* if just tried and failed to reuse lookahead token after an error, discard it. */
4831 /* return failure if at end of input */
4832 if (yychar == YYEOF)
4837 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4843 /* Else will try to reuse lookahead token
4844 after shifting the error token. */
4846 yyerrstatus = 3; /* Each real token shifted decrements this */
4850 yyerrdefault: /* current state does not do anything special for the error token. */
4853 /* This is wrong; only states that explicitly want error tokens
4854 should shift them. */
4855 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4856 if (yyn) goto yydefault;
4859 yyerrpop: /* pop the current state because it cannot handle the error token */
4861 if (yyssp == yyss) YYABORT;
4871 short *ssp1 = yyss - 1;
4872 fprintf (stderr, "Error: state stack now");
4873 while (ssp1 != yyssp)
4874 fprintf (stderr, " %d", *++ssp1);
4875 fprintf (stderr, "\n");
4881 yyn = yypact[yystate];
4886 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4905 fprintf(stderr, "Shifting error token, ");
4917 /* YYACCEPT comes here. */
4929 /* YYABORT comes here. */
4940 #line 2849 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4943 // common code from the two 'RunVMAsmParser' functions
4944 static Module* RunParser(Module * M) {
4946 llvmAsmlineno = 1; // Reset the current line number...
4947 CurModule.CurrentModule = M;
4952 // Check to make sure the parser succeeded
4955 delete ParserResult;
4959 // Check to make sure that parsing produced a result
4963 // Reset ParserResult variable while saving its value for the result.
4964 Module *Result = ParserResult;
4970 void llvm::GenerateError(const std::string &message, int LineNo) {
4971 if (LineNo == -1) LineNo = llvmAsmlineno;
4972 // TODO: column number in exception
4974 TheParseError->setError(CurFilename, message, LineNo);
4978 int yyerror(const char *ErrorMsg) {
4980 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4981 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4982 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4983 if (yychar == YYEMPTY || yychar == 0)
4984 errMsg += "end-of-file.";
4986 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4987 GenerateError(errMsg);