2 /* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL 257
15 #define EUINT64VAL 258
35 #define STRINGCONSTANT 278
36 #define IMPLEMENTATION 279
37 #define ZEROINITIALIZER 280
58 #define EXTERN_WEAK 301
65 #define POINTERSIZE 308
74 #define SIDEEFFECT 317
77 #define CSRETCC_TOK 320
78 #define FASTCC_TOK 321
79 #define COLDCC_TOK 322
80 #define X86_STDCALLCC_TOK 323
81 #define X86_FASTCALLCC_TOK 324
82 #define DATALAYOUT 325
88 #define UNREACHABLE 331
112 #define GETELEMENTPTR 355
119 #define EXTRACTELEMENT 362
120 #define INSERTELEMENT 363
121 #define SHUFFLEVECTOR 364
122 #define VAARG_old 365
123 #define VANEXT_old 366
125 #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
127 #include "ParserInternals.h"
128 #include "llvm/CallingConv.h"
129 #include "llvm/InlineAsm.h"
130 #include "llvm/Instructions.h"
131 #include "llvm/Module.h"
132 #include "llvm/SymbolTable.h"
133 #include "llvm/Assembly/AutoUpgrade.h"
134 #include "llvm/Support/GetElementPtrTypeIterator.h"
135 #include "llvm/ADT/STLExtras.h"
136 #include "llvm/Support/MathExtras.h"
142 // The following is a gross hack. In order to rid the libAsmParser library of
143 // exceptions, we have to have a way of getting the yyparse function to go into
144 // an error situation. So, whenever we want an error to occur, the GenerateError
145 // function (see bottom of file) sets TriggerError. Then, at the end of each
146 // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
147 // (a goto) to put YACC in error state. Furthermore, several calls to
148 // GenerateError are made from inside productions and they must simulate the
149 // previous exception behavior by exiting the production immediately. We have
150 // replaced these with the GEN_ERROR macro which calls GeneratError and then
151 // immediately invokes YYERROR. This would be so much cleaner if it was a
152 // recursive descent parser.
153 static bool TriggerError = false;
154 #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
155 #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
157 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
158 int yylex(); // declaration" of xxx warnings.
162 std::string CurFilename;
164 using namespace llvm;
166 static Module *ParserResult;
168 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
169 // relating to upreferences in the input stream.
171 //#define DEBUG_UPREFS 1
173 #define UR_OUT(X) std::cerr << X
178 #define YYERROR_VERBOSE 1
180 static bool ObsoleteVarArgs;
181 static bool NewVarArgs;
182 static BasicBlock *CurBB;
183 static GlobalVariable *CurGV;
186 // This contains info used when building the body of a function. It is
187 // destroyed when the function is completed.
189 typedef std::vector<Value *> ValueList; // Numbered defs
191 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
192 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
194 static struct PerModuleInfo {
195 Module *CurrentModule;
196 std::map<const Type *, ValueList> Values; // Module level numbered definitions
197 std::map<const Type *,ValueList> LateResolveValues;
198 std::vector<PATypeHolder> Types;
199 std::map<ValID, PATypeHolder> LateResolveTypes;
201 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
202 /// how they were referenced and on which line of the input they came from so
203 /// that we can resolve them later and print error messages as appropriate.
204 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
206 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
207 // references to global values. Global values may be referenced before they
208 // are defined, and if so, the temporary object that they represent is held
209 // here. This is used for forward references of GlobalValues.
211 typedef std::map<std::pair<const PointerType *,
212 ValID>, GlobalValue*> GlobalRefsType;
213 GlobalRefsType GlobalRefs;
216 // If we could not resolve some functions at function compilation time
217 // (calls to functions before they are defined), resolve them now... Types
218 // are resolved when the constant pool has been completely parsed.
220 ResolveDefinitions(LateResolveValues);
224 // Check to make sure that all global value forward references have been
227 if (!GlobalRefs.empty()) {
228 std::string UndefinedReferences = "Unresolved global references exist:\n";
230 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
232 UndefinedReferences += " " + I->first.first->getDescription() + " " +
233 I->first.second.getName() + "\n";
235 GenerateError(UndefinedReferences);
239 // Look for intrinsic functions and CallInst that need to be upgraded
240 for (Module::iterator FI = CurrentModule->begin(),
241 FE = CurrentModule->end(); FI != FE; )
242 UpgradeCallsToIntrinsic(FI++);
244 Values.clear(); // Clear out function local definitions
249 // GetForwardRefForGlobal - Check to see if there is a forward reference
250 // for this global. If so, remove it from the GlobalRefs map and return it.
251 // If not, just return null.
252 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
253 // Check to see if there is a forward reference to this global variable...
254 // if there is, eliminate it and patch the reference to use the new def'n.
255 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
256 GlobalValue *Ret = 0;
257 if (I != GlobalRefs.end()) {
265 static struct PerFunctionInfo {
266 Function *CurrentFunction; // Pointer to current function being created
268 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
269 std::map<const Type*, ValueList> LateResolveValues;
270 bool isDeclare; // Is this function a forward declararation?
271 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
273 /// BBForwardRefs - When we see forward references to basic blocks, keep
274 /// track of them here.
275 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
276 std::vector<BasicBlock*> NumberedBlocks;
279 inline PerFunctionInfo() {
282 Linkage = GlobalValue::ExternalLinkage;
285 inline void FunctionStart(Function *M) {
290 void FunctionDone() {
291 NumberedBlocks.clear();
293 // Any forward referenced blocks left?
294 if (!BBForwardRefs.empty()) {
295 GenerateError("Undefined reference to label " +
296 BBForwardRefs.begin()->first->getName());
300 // Resolve all forward references now.
301 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
303 Values.clear(); // Clear out function local definitions
306 Linkage = GlobalValue::ExternalLinkage;
308 } CurFun; // Info for the current function...
310 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
313 //===----------------------------------------------------------------------===//
314 // Code to handle definitions of all the types
315 //===----------------------------------------------------------------------===//
317 static int InsertValue(Value *V,
318 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
319 if (V->hasName()) return -1; // Is this a numbered definition?
321 // Yes, insert the value into the value table...
322 ValueList &List = ValueTab[V->getType()];
324 return List.size()-1;
327 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
329 case ValID::NumberVal: // Is it a numbered definition?
330 // Module constants occupy the lowest numbered slots...
331 if ((unsigned)D.Num < CurModule.Types.size())
332 return CurModule.Types[(unsigned)D.Num];
334 case ValID::NameVal: // Is it a named definition?
335 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
336 D.destroy(); // Free old strdup'd memory...
341 GenerateError("Internal parser error: Invalid symbol type reference!");
345 // If we reached here, we referenced either a symbol that we don't know about
346 // or an id number that hasn't been read yet. We may be referencing something
347 // forward, so just create an entry to be resolved later and get to it...
349 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
352 if (inFunctionScope()) {
353 if (D.Type == ValID::NameVal) {
354 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
357 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
362 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
363 if (I != CurModule.LateResolveTypes.end())
366 Type *Typ = OpaqueType::get();
367 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
371 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
372 SymbolTable &SymTab =
373 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
374 CurModule.CurrentModule->getSymbolTable();
375 return SymTab.lookup(Ty, Name);
378 // getValNonImprovising - Look up the value specified by the provided type and
379 // the provided ValID. If the value exists and has already been defined, return
380 // it. Otherwise return null.
382 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
383 if (isa<FunctionType>(Ty)) {
384 GenerateError("Functions are not values and "
385 "must be referenced as pointers");
390 case ValID::NumberVal: { // Is it a numbered definition?
391 unsigned Num = (unsigned)D.Num;
393 // Module constants occupy the lowest numbered slots...
394 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
395 if (VI != CurModule.Values.end()) {
396 if (Num < VI->second.size())
397 return VI->second[Num];
398 Num -= VI->second.size();
401 // Make sure that our type is within bounds
402 VI = CurFun.Values.find(Ty);
403 if (VI == CurFun.Values.end()) return 0;
405 // Check that the number is within bounds...
406 if (VI->second.size() <= Num) return 0;
408 return VI->second[Num];
411 case ValID::NameVal: { // Is it a named definition?
412 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
413 if (N == 0) return 0;
415 D.destroy(); // Free old strdup'd memory...
419 // Check to make sure that "Ty" is an integral type, and that our
420 // value will fit into the specified type...
421 case ValID::ConstSIntVal: // Is it a constant pool reference??
422 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
423 GenerateError("Signed integral constant '" +
424 itostr(D.ConstPool64) + "' is invalid for type '" +
425 Ty->getDescription() + "'!");
428 return ConstantInt::get(Ty, D.ConstPool64);
430 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
431 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
432 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
433 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
434 "' is invalid or out of range!");
436 } else { // This is really a signed reference. Transmogrify.
437 return ConstantInt::get(Ty, D.ConstPool64);
440 return ConstantInt::get(Ty, D.UConstPool64);
443 case ValID::ConstFPVal: // Is it a floating point const pool reference?
444 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
445 GenerateError("FP constant invalid for type!!");
448 return ConstantFP::get(Ty, D.ConstPoolFP);
450 case ValID::ConstNullVal: // Is it a null value?
451 if (!isa<PointerType>(Ty)) {
452 GenerateError("Cannot create a a non pointer null!");
455 return ConstantPointerNull::get(cast<PointerType>(Ty));
457 case ValID::ConstUndefVal: // Is it an undef value?
458 return UndefValue::get(Ty);
460 case ValID::ConstZeroVal: // Is it a zero value?
461 return Constant::getNullValue(Ty);
463 case ValID::ConstantVal: // Fully resolved constant?
464 if (D.ConstantValue->getType() != Ty) {
465 GenerateError("Constant expression type different from required type!");
468 return D.ConstantValue;
470 case ValID::InlineAsmVal: { // Inline asm expression
471 const PointerType *PTy = dyn_cast<PointerType>(Ty);
472 const FunctionType *FTy =
473 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
474 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
475 GenerateError("Invalid type for asm constraint string!");
478 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
479 D.IAD->HasSideEffects);
480 D.destroy(); // Free InlineAsmDescriptor.
484 assert(0 && "Unhandled case!");
488 assert(0 && "Unhandled case!");
492 // getVal - This function is identical to getValNonImprovising, except that if a
493 // value is not already defined, it "improvises" by creating a placeholder var
494 // that looks and acts just like the requested variable. When the value is
495 // defined later, all uses of the placeholder variable are replaced with the
498 static Value *getVal(const Type *Ty, const ValID &ID) {
499 if (Ty == Type::LabelTy) {
500 GenerateError("Cannot use a basic block here");
504 // See if the value has already been defined.
505 Value *V = getValNonImprovising(Ty, ID);
507 if (TriggerError) return 0;
509 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
510 GenerateError("Invalid use of a composite type!");
514 // If we reached here, we referenced either a symbol that we don't know about
515 // or an id number that hasn't been read yet. We may be referencing something
516 // forward, so just create an entry to be resolved later and get to it...
518 V = new Argument(Ty);
520 // Remember where this forward reference came from. FIXME, shouldn't we try
521 // to recycle these things??
522 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
525 if (inFunctionScope())
526 InsertValue(V, CurFun.LateResolveValues);
528 InsertValue(V, CurModule.LateResolveValues);
532 /// getBBVal - This is used for two purposes:
533 /// * If isDefinition is true, a new basic block with the specified ID is being
535 /// * If isDefinition is true, this is a reference to a basic block, which may
536 /// or may not be a forward reference.
538 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
539 assert(inFunctionScope() && "Can't get basic block at global scope!");
545 GenerateError("Illegal label reference " + ID.getName());
547 case ValID::NumberVal: // Is it a numbered definition?
548 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
549 CurFun.NumberedBlocks.resize(ID.Num+1);
550 BB = CurFun.NumberedBlocks[ID.Num];
552 case ValID::NameVal: // Is it a named definition?
554 if (Value *N = CurFun.CurrentFunction->
555 getSymbolTable().lookup(Type::LabelTy, Name))
556 BB = cast<BasicBlock>(N);
560 // See if the block has already been defined.
562 // If this is the definition of the block, make sure the existing value was
563 // just a forward reference. If it was a forward reference, there will be
564 // an entry for it in the PlaceHolderInfo map.
565 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
566 // The existing value was a definition, not a forward reference.
567 GenerateError("Redefinition of label " + ID.getName());
571 ID.destroy(); // Free strdup'd memory.
575 // Otherwise this block has not been seen before.
576 BB = new BasicBlock("", CurFun.CurrentFunction);
577 if (ID.Type == ValID::NameVal) {
578 BB->setName(ID.Name);
580 CurFun.NumberedBlocks[ID.Num] = BB;
583 // If this is not a definition, keep track of it so we can use it as a forward
586 // Remember where this forward reference came from.
587 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
589 // The forward declaration could have been inserted anywhere in the
590 // function: insert it into the correct place now.
591 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
592 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
599 //===----------------------------------------------------------------------===//
600 // Code to handle forward references in instructions
601 //===----------------------------------------------------------------------===//
603 // This code handles the late binding needed with statements that reference
604 // values not defined yet... for example, a forward branch, or the PHI node for
607 // This keeps a table (CurFun.LateResolveValues) of all such forward references
608 // and back patchs after we are done.
611 // ResolveDefinitions - If we could not resolve some defs at parsing
612 // time (forward branches, phi functions for loops, etc...) resolve the
616 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
617 std::map<const Type*,ValueList> *FutureLateResolvers) {
618 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
619 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
620 E = LateResolvers.end(); LRI != E; ++LRI) {
621 ValueList &List = LRI->second;
622 while (!List.empty()) {
623 Value *V = List.back();
626 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
627 CurModule.PlaceHolderInfo.find(V);
628 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
630 ValID &DID = PHI->second.first;
632 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
636 V->replaceAllUsesWith(TheRealValue);
638 CurModule.PlaceHolderInfo.erase(PHI);
639 } else if (FutureLateResolvers) {
640 // Functions have their unresolved items forwarded to the module late
642 InsertValue(V, *FutureLateResolvers);
644 if (DID.Type == ValID::NameVal) {
645 GenerateError("Reference to an invalid definition: '" +DID.getName()+
646 "' of type '" + V->getType()->getDescription() + "'",
650 GenerateError("Reference to an invalid definition: #" +
651 itostr(DID.Num) + " of type '" +
652 V->getType()->getDescription() + "'",
660 LateResolvers.clear();
663 // ResolveTypeTo - A brand new type was just declared. This means that (if
664 // name is not null) things referencing Name can be resolved. Otherwise, things
665 // refering to the number can be resolved. Do this now.
667 static void ResolveTypeTo(char *Name, const Type *ToTy) {
669 if (Name) D = ValID::create(Name);
670 else D = ValID::create((int)CurModule.Types.size());
672 std::map<ValID, PATypeHolder>::iterator I =
673 CurModule.LateResolveTypes.find(D);
674 if (I != CurModule.LateResolveTypes.end()) {
675 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
676 CurModule.LateResolveTypes.erase(I);
680 // setValueName - Set the specified value to the name given. The name may be
681 // null potentially, in which case this is a noop. The string passed in is
682 // assumed to be a malloc'd string buffer, and is free'd by this function.
684 static void setValueName(Value *V, char *NameStr) {
686 std::string Name(NameStr); // Copy string
687 free(NameStr); // Free old string
689 if (V->getType() == Type::VoidTy) {
690 GenerateError("Can't assign name '" + Name+"' to value with void type!");
694 assert(inFunctionScope() && "Must be in function scope!");
695 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
696 if (ST.lookup(V->getType(), Name)) {
697 GenerateError("Redefinition of value named '" + Name + "' in the '" +
698 V->getType()->getDescription() + "' type plane!");
707 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
708 /// this is a declaration, otherwise it is a definition.
709 static GlobalVariable *
710 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
711 bool isConstantGlobal, const Type *Ty,
712 Constant *Initializer) {
713 if (isa<FunctionType>(Ty)) {
714 GenerateError("Cannot declare global vars of function type!");
718 const PointerType *PTy = PointerType::get(Ty);
722 Name = NameStr; // Copy string
723 free(NameStr); // Free old string
726 // See if this global value was forward referenced. If so, recycle the
730 ID = ValID::create((char*)Name.c_str());
732 ID = ValID::create((int)CurModule.Values[PTy].size());
735 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
736 // Move the global to the end of the list, from whereever it was
737 // previously inserted.
738 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
739 CurModule.CurrentModule->getGlobalList().remove(GV);
740 CurModule.CurrentModule->getGlobalList().push_back(GV);
741 GV->setInitializer(Initializer);
742 GV->setLinkage(Linkage);
743 GV->setConstant(isConstantGlobal);
744 InsertValue(GV, CurModule.Values);
748 // If this global has a name, check to see if there is already a definition
749 // of this global in the module. If so, merge as appropriate. Note that
750 // this is really just a hack around problems in the CFE. :(
752 // We are a simple redefinition of a value, check to see if it is defined
753 // the same as the old one.
754 if (GlobalVariable *EGV =
755 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
756 // We are allowed to redefine a global variable in two circumstances:
757 // 1. If at least one of the globals is uninitialized or
758 // 2. If both initializers have the same value.
760 if (!EGV->hasInitializer() || !Initializer ||
761 EGV->getInitializer() == Initializer) {
763 // Make sure the existing global version gets the initializer! Make
764 // sure that it also gets marked const if the new version is.
765 if (Initializer && !EGV->hasInitializer())
766 EGV->setInitializer(Initializer);
767 if (isConstantGlobal)
768 EGV->setConstant(true);
769 EGV->setLinkage(Linkage);
773 GenerateError("Redefinition of global variable named '" + Name +
774 "' in the '" + Ty->getDescription() + "' type plane!");
779 // Otherwise there is no existing GV to use, create one now.
781 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
782 CurModule.CurrentModule);
783 InsertValue(GV, CurModule.Values);
787 // setTypeName - Set the specified type to the name given. The name may be
788 // null potentially, in which case this is a noop. The string passed in is
789 // assumed to be a malloc'd string buffer, and is freed by this function.
791 // This function returns true if the type has already been defined, but is
792 // allowed to be redefined in the specified context. If the name is a new name
793 // for the type plane, it is inserted and false is returned.
794 static bool setTypeName(const Type *T, char *NameStr) {
795 assert(!inFunctionScope() && "Can't give types function-local names!");
796 if (NameStr == 0) return false;
798 std::string Name(NameStr); // Copy string
799 free(NameStr); // Free old string
801 // We don't allow assigning names to void type
802 if (T == Type::VoidTy) {
803 GenerateError("Can't assign name '" + Name + "' to the void type!");
807 // Set the type name, checking for conflicts as we do so.
808 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
810 if (AlreadyExists) { // Inserting a name that is already defined???
811 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
812 assert(Existing && "Conflict but no matching type?");
814 // There is only one case where this is allowed: when we are refining an
815 // opaque type. In this case, Existing will be an opaque type.
816 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
817 // We ARE replacing an opaque type!
818 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
822 // Otherwise, this is an attempt to redefine a type. That's okay if
823 // the redefinition is identical to the original. This will be so if
824 // Existing and T point to the same Type object. In this one case we
825 // allow the equivalent redefinition.
826 if (Existing == T) return true; // Yes, it's equal.
828 // Any other kind of (non-equivalent) redefinition is an error.
829 GenerateError("Redefinition of type named '" + Name + "' in the '" +
830 T->getDescription() + "' type plane!");
836 //===----------------------------------------------------------------------===//
837 // Code for handling upreferences in type names...
840 // TypeContains - Returns true if Ty directly contains E in it.
842 static bool TypeContains(const Type *Ty, const Type *E) {
843 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
844 E) != Ty->subtype_end();
849 // NestingLevel - The number of nesting levels that need to be popped before
850 // this type is resolved.
851 unsigned NestingLevel;
853 // LastContainedTy - This is the type at the current binding level for the
854 // type. Every time we reduce the nesting level, this gets updated.
855 const Type *LastContainedTy;
857 // UpRefTy - This is the actual opaque type that the upreference is
861 UpRefRecord(unsigned NL, OpaqueType *URTy)
862 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
866 // UpRefs - A list of the outstanding upreferences that need to be resolved.
867 static std::vector<UpRefRecord> UpRefs;
869 /// HandleUpRefs - Every time we finish a new layer of types, this function is
870 /// called. It loops through the UpRefs vector, which is a list of the
871 /// currently active types. For each type, if the up reference is contained in
872 /// the newly completed type, we decrement the level count. When the level
873 /// count reaches zero, the upreferenced type is the type that is passed in:
874 /// thus we can complete the cycle.
876 static PATypeHolder HandleUpRefs(const Type *ty) {
877 // If Ty isn't abstract, or if there are no up-references in it, then there is
878 // nothing to resolve here.
879 if (!ty->isAbstract() || UpRefs.empty()) return ty;
882 UR_OUT("Type '" << Ty->getDescription() <<
883 "' newly formed. Resolving upreferences.\n" <<
884 UpRefs.size() << " upreferences active!\n");
886 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
887 // to zero), we resolve them all together before we resolve them to Ty. At
888 // the end of the loop, if there is anything to resolve to Ty, it will be in
890 OpaqueType *TypeToResolve = 0;
892 for (unsigned i = 0; i != UpRefs.size(); ++i) {
893 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
894 << UpRefs[i].second->getDescription() << ") = "
895 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
896 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
897 // Decrement level of upreference
898 unsigned Level = --UpRefs[i].NestingLevel;
899 UpRefs[i].LastContainedTy = Ty;
900 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
901 if (Level == 0) { // Upreference should be resolved!
902 if (!TypeToResolve) {
903 TypeToResolve = UpRefs[i].UpRefTy;
905 UR_OUT(" * Resolving upreference for "
906 << UpRefs[i].second->getDescription() << "\n";
907 std::string OldName = UpRefs[i].UpRefTy->getDescription());
908 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
909 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
910 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
912 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
913 --i; // Do not skip the next element...
919 UR_OUT(" * Resolving upreference for "
920 << UpRefs[i].second->getDescription() << "\n";
921 std::string OldName = TypeToResolve->getDescription());
922 TypeToResolve->refineAbstractTypeTo(Ty);
928 /// This function is used to obtain the correct opcode for an instruction when
929 /// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both
930 /// an opcode and an "obsolete" flag. These are generated by the lexer and
931 /// the "obsolete" member will be true when the lexer encounters the token for
932 /// an obsolete opcode. For example, "div" was replaced by [usf]div but we need
933 /// to maintain backwards compatibility for asm files that still have the "div"
934 /// instruction. This function handles converting div -> [usf]div appropriately.
935 /// @brief Convert obsolete opcodes to new values
937 sanitizeOpCode(OpcodeInfo<Instruction::BinaryOps> &OI, const PATypeHolder& PATy)
939 // If its not obsolete, don't do anything
943 // If its a packed type we want to use the element type
944 const Type* Ty = PATy;
945 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
946 Ty = PTy->getElementType();
948 // Depending on the opcode ..
951 GenerateError("Invalid obsolete opCode (check Lexer.l)");
953 case Instruction::UDiv:
954 // Handle cases where the opcode needs to change
955 if (Ty->isFloatingPoint())
956 OI.opcode = Instruction::FDiv;
957 else if (Ty->isSigned())
958 OI.opcode = Instruction::SDiv;
960 case Instruction::URem:
961 if (Ty->isFloatingPoint())
962 OI.opcode = Instruction::FRem;
963 else if (Ty->isSigned())
964 OI.opcode = Instruction::SRem;
967 // Its not obsolete any more, we fixed it.
971 // common code from the two 'RunVMAsmParser' functions
972 static Module* RunParser(Module * M) {
974 llvmAsmlineno = 1; // Reset the current line number...
975 ObsoleteVarArgs = false;
977 CurModule.CurrentModule = M;
979 // Check to make sure the parser succeeded
986 // Check to make sure that parsing produced a result
990 // Reset ParserResult variable while saving its value for the result.
991 Module *Result = ParserResult;
994 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
997 if ((F = Result->getNamedFunction("llvm.va_start"))
998 && F->getFunctionType()->getNumParams() == 0)
999 ObsoleteVarArgs = true;
1000 if((F = Result->getNamedFunction("llvm.va_copy"))
1001 && F->getFunctionType()->getNumParams() == 1)
1002 ObsoleteVarArgs = true;
1005 if (ObsoleteVarArgs && NewVarArgs) {
1007 "This file is corrupt: it uses both new and old style varargs");
1011 if(ObsoleteVarArgs) {
1012 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1013 if (F->arg_size() != 0) {
1014 GenerateError("Obsolete va_start takes 0 argument!");
1020 //bar = alloca typeof(foo)
1024 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1025 const Type* ArgTy = F->getFunctionType()->getReturnType();
1026 const Type* ArgTyPtr = PointerType::get(ArgTy);
1027 Function* NF = Result->getOrInsertFunction("llvm.va_start",
1028 RetTy, ArgTyPtr, (Type *)0);
1030 while (!F->use_empty()) {
1031 CallInst* CI = cast<CallInst>(F->use_back());
1032 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1033 new CallInst(NF, bar, "", CI);
1034 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1035 CI->replaceAllUsesWith(foo);
1036 CI->getParent()->getInstList().erase(CI);
1038 Result->getFunctionList().erase(F);
1041 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1042 if(F->arg_size() != 1) {
1043 GenerateError("Obsolete va_end takes 1 argument!");
1049 //bar = alloca 1 of typeof(foo)
1051 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1052 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1053 const Type* ArgTyPtr = PointerType::get(ArgTy);
1054 Function* NF = Result->getOrInsertFunction("llvm.va_end",
1055 RetTy, ArgTyPtr, (Type *)0);
1057 while (!F->use_empty()) {
1058 CallInst* CI = cast<CallInst>(F->use_back());
1059 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1060 new StoreInst(CI->getOperand(1), bar, CI);
1061 new CallInst(NF, bar, "", CI);
1062 CI->getParent()->getInstList().erase(CI);
1064 Result->getFunctionList().erase(F);
1067 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1068 if(F->arg_size() != 1) {
1069 GenerateError("Obsolete va_copy takes 1 argument!");
1074 //a = alloca 1 of typeof(foo)
1075 //b = alloca 1 of typeof(foo)
1080 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1081 const Type* ArgTy = F->getFunctionType()->getReturnType();
1082 const Type* ArgTyPtr = PointerType::get(ArgTy);
1083 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
1084 RetTy, ArgTyPtr, ArgTyPtr,
1087 while (!F->use_empty()) {
1088 CallInst* CI = cast<CallInst>(F->use_back());
1089 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1090 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1091 new StoreInst(CI->getOperand(1), b, CI);
1092 new CallInst(NF, a, b, "", CI);
1093 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1094 CI->replaceAllUsesWith(foo);
1095 CI->getParent()->getInstList().erase(CI);
1097 Result->getFunctionList().erase(F);
1104 //===----------------------------------------------------------------------===//
1105 // RunVMAsmParser - Define an interface to this parser
1106 //===----------------------------------------------------------------------===//
1108 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1111 CurFilename = Filename;
1112 return RunParser(new Module(CurFilename));
1115 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1116 set_scan_string(AsmString);
1118 CurFilename = "from_memory";
1120 return RunParser(new Module (CurFilename));
1122 return RunParser(M);
1127 #line 1016 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1129 llvm::Module *ModuleVal;
1130 llvm::Function *FunctionVal;
1131 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1132 llvm::BasicBlock *BasicBlockVal;
1133 llvm::TerminatorInst *TermInstVal;
1134 llvm::Instruction *InstVal;
1135 llvm::Constant *ConstVal;
1137 const llvm::Type *PrimType;
1138 llvm::PATypeHolder *TypeVal;
1139 llvm::Value *ValueVal;
1141 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1142 std::vector<llvm::Value*> *ValueList;
1143 std::list<llvm::PATypeHolder> *TypeList;
1144 // Represent the RHS of PHI node
1145 std::list<std::pair<llvm::Value*,
1146 llvm::BasicBlock*> > *PHIList;
1147 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1148 std::vector<llvm::Constant*> *ConstVector;
1150 llvm::GlobalValue::LinkageTypes Linkage;
1158 char *StrVal; // This memory is strdup'd!
1159 llvm::ValID ValIDVal; // strdup'd memory maybe!
1161 BinaryOpInfo BinaryOpVal;
1162 TermOpInfo TermOpVal;
1164 OtherOpInfo OtherOpVal;
1165 llvm::Module::Endianness Endianness;
1178 #define YYFLAG -32768
1179 #define YYNTBASE 127
1181 #define YYTRANSLATE(x) ((unsigned)(x) <= 366 ? yytranslate[x] : 201)
1183 static const short yytranslate[] = { 0,
1184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1187 2, 2, 2, 2, 2, 2, 2, 2, 2, 116,
1188 117, 125, 2, 114, 2, 2, 2, 2, 2, 2,
1189 2, 2, 2, 2, 2, 2, 2, 2, 2, 121,
1190 113, 122, 2, 2, 2, 2, 2, 2, 2, 2,
1191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1193 118, 115, 120, 2, 2, 2, 2, 2, 126, 2,
1194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1195 2, 2, 2, 2, 2, 2, 2, 2, 2, 119,
1196 2, 2, 123, 2, 124, 2, 2, 2, 2, 2,
1197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1199 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1200 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1201 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1202 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1203 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1204 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1205 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1206 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1207 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1208 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1209 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1210 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1211 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1212 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1213 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1214 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1215 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1216 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1217 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1218 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1219 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1220 107, 108, 109, 110, 111, 112
1224 static const short yyprhs[] = { 0,
1225 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1226 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1227 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1228 60, 62, 64, 66, 68, 70, 72, 75, 76, 78,
1229 80, 82, 84, 86, 88, 90, 91, 92, 94, 96,
1230 98, 100, 102, 104, 107, 108, 111, 112, 116, 119,
1231 120, 122, 123, 127, 129, 132, 134, 136, 138, 140,
1232 142, 144, 146, 148, 150, 152, 154, 156, 158, 160,
1233 162, 164, 166, 168, 170, 172, 174, 177, 182, 188,
1234 194, 198, 201, 204, 206, 210, 212, 216, 218, 219,
1235 224, 228, 232, 237, 242, 246, 249, 252, 255, 258,
1236 261, 264, 267, 270, 273, 276, 283, 289, 298, 305,
1237 312, 319, 326, 333, 342, 351, 355, 357, 359, 361,
1238 363, 366, 369, 374, 377, 379, 384, 387, 392, 393,
1239 401, 402, 410, 411, 419, 420, 428, 432, 437, 438,
1240 440, 442, 444, 448, 452, 456, 460, 464, 468, 470,
1241 471, 473, 475, 477, 478, 481, 485, 487, 489, 493,
1242 495, 496, 505, 507, 509, 513, 515, 517, 520, 521,
1243 523, 525, 526, 531, 532, 534, 536, 538, 540, 542,
1244 544, 546, 548, 550, 554, 556, 562, 564, 566, 568,
1245 570, 573, 576, 579, 583, 586, 587, 589, 592, 595,
1246 599, 609, 619, 628, 642, 644, 646, 653, 659, 662,
1247 669, 677, 679, 683, 685, 686, 689, 691, 697, 703,
1248 709, 712, 717, 722, 729, 734, 739, 744, 749, 756,
1249 763, 766, 774, 776, 779, 780, 782, 783, 787, 794,
1250 798, 805, 808, 813, 820
1253 static const short yyrhs[] = { 5,
1254 0, 6, 0, 3, 0, 4, 0, 78, 0, 79,
1255 0, 80, 0, 81, 0, 82, 0, 83, 0, 84,
1256 0, 85, 0, 86, 0, 87, 0, 88, 0, 89,
1257 0, 90, 0, 91, 0, 92, 0, 93, 0, 94,
1258 0, 95, 0, 105, 0, 106, 0, 16, 0, 14,
1259 0, 12, 0, 10, 0, 17, 0, 15, 0, 13,
1260 0, 11, 0, 133, 0, 134, 0, 18, 0, 19,
1261 0, 169, 113, 0, 0, 41, 0, 42, 0, 43,
1262 0, 44, 0, 45, 0, 46, 0, 47, 0, 0,
1263 0, 65, 0, 66, 0, 67, 0, 68, 0, 69,
1264 0, 70, 0, 64, 4, 0, 0, 57, 4, 0,
1265 0, 114, 57, 4, 0, 34, 24, 0, 0, 142,
1266 0, 0, 114, 145, 144, 0, 142, 0, 57, 4,
1267 0, 148, 0, 8, 0, 150, 0, 8, 0, 150,
1268 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1269 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
1270 0, 19, 0, 20, 0, 21, 0, 48, 0, 149,
1271 0, 184, 0, 115, 4, 0, 147, 116, 152, 117,
1272 0, 118, 4, 119, 150, 120, 0, 121, 4, 119,
1273 150, 122, 0, 123, 151, 124, 0, 123, 124, 0,
1274 150, 125, 0, 150, 0, 151, 114, 150, 0, 151,
1275 0, 151, 114, 37, 0, 37, 0, 0, 148, 118,
1276 155, 120, 0, 148, 118, 120, 0, 148, 126, 24,
1277 0, 148, 121, 155, 122, 0, 148, 123, 155, 124,
1278 0, 148, 123, 124, 0, 148, 38, 0, 148, 39,
1279 0, 148, 184, 0, 148, 154, 0, 148, 26, 0,
1280 133, 128, 0, 134, 4, 0, 9, 27, 0, 9,
1281 28, 0, 136, 7, 0, 103, 116, 153, 36, 148,
1282 117, 0, 101, 116, 153, 198, 117, 0, 104, 116,
1283 153, 114, 153, 114, 153, 117, 0, 129, 116, 153,
1284 114, 153, 117, 0, 130, 116, 153, 114, 153, 117,
1285 0, 131, 116, 153, 114, 153, 117, 0, 132, 116,
1286 153, 114, 153, 117, 0, 108, 116, 153, 114, 153,
1287 117, 0, 109, 116, 153, 114, 153, 114, 153, 117,
1288 0, 110, 116, 153, 114, 153, 114, 153, 117, 0,
1289 155, 114, 153, 0, 153, 0, 32, 0, 33, 0,
1290 158, 0, 158, 178, 0, 158, 180, 0, 158, 62,
1291 61, 164, 0, 158, 25, 0, 159, 0, 159, 137,
1292 20, 146, 0, 159, 180, 0, 159, 62, 61, 164,
1293 0, 0, 159, 137, 138, 156, 153, 160, 144, 0,
1294 0, 159, 137, 50, 156, 148, 161, 144, 0, 0,
1295 159, 137, 45, 156, 148, 162, 144, 0, 0, 159,
1296 137, 47, 156, 148, 163, 144, 0, 159, 51, 166,
1297 0, 159, 58, 113, 167, 0, 0, 24, 0, 56,
1298 0, 55, 0, 53, 113, 165, 0, 54, 113, 4,
1299 0, 52, 113, 24, 0, 71, 113, 24, 0, 118,
1300 168, 120, 0, 168, 114, 24, 0, 24, 0, 0,
1301 22, 0, 24, 0, 169, 0, 0, 148, 170, 0,
1302 172, 114, 171, 0, 171, 0, 172, 0, 172, 114,
1303 37, 0, 37, 0, 0, 139, 146, 169, 116, 173,
1304 117, 143, 140, 0, 29, 0, 123, 0, 138, 174,
1305 175, 0, 30, 0, 124, 0, 187, 177, 0, 0,
1306 45, 0, 47, 0, 0, 31, 181, 179, 174, 0,
1307 0, 63, 0, 3, 0, 4, 0, 7, 0, 27,
1308 0, 28, 0, 38, 0, 39, 0, 26, 0, 121,
1309 155, 122, 0, 154, 0, 61, 182, 24, 114, 24,
1310 0, 127, 0, 169, 0, 184, 0, 183, 0, 148,
1311 185, 0, 187, 188, 0, 176, 188, 0, 189, 137,
1312 190, 0, 189, 192, 0, 0, 23, 0, 72, 186,
1313 0, 72, 8, 0, 73, 21, 185, 0, 73, 9,
1314 185, 114, 21, 185, 114, 21, 185, 0, 74, 135,
1315 185, 114, 21, 185, 118, 191, 120, 0, 74, 135,
1316 185, 114, 21, 185, 118, 120, 0, 75, 139, 146,
1317 185, 116, 195, 117, 36, 21, 185, 76, 21, 185,
1318 0, 76, 0, 77, 0, 191, 135, 183, 114, 21,
1319 185, 0, 135, 183, 114, 21, 185, 0, 137, 197,
1320 0, 148, 118, 185, 114, 185, 120, 0, 193, 114,
1321 118, 185, 114, 185, 120, 0, 186, 0, 194, 114,
1322 186, 0, 194, 0, 0, 60, 59, 0, 59, 0,
1323 129, 148, 185, 114, 185, 0, 130, 148, 185, 114,
1324 185, 0, 131, 148, 185, 114, 185, 0, 49, 186,
1325 0, 132, 186, 114, 186, 0, 103, 186, 36, 148,
1326 0, 104, 186, 114, 186, 114, 186, 0, 107, 186,
1327 114, 148, 0, 111, 186, 114, 148, 0, 112, 186,
1328 114, 148, 0, 108, 186, 114, 186, 0, 109, 186,
1329 114, 186, 114, 186, 0, 110, 186, 114, 186, 114,
1330 186, 0, 102, 193, 0, 196, 139, 146, 185, 116,
1331 195, 117, 0, 200, 0, 114, 194, 0, 0, 35,
1332 0, 0, 96, 148, 141, 0, 96, 148, 114, 15,
1333 185, 141, 0, 97, 148, 141, 0, 97, 148, 114,
1334 15, 185, 141, 0, 98, 186, 0, 199, 99, 148,
1335 185, 0, 199, 100, 186, 114, 148, 185, 0, 101,
1342 static const short yyrline[] = { 0,
1343 1139, 1140, 1148, 1149, 1159, 1159, 1159, 1159, 1159, 1159,
1344 1159, 1159, 1159, 1160, 1160, 1160, 1161, 1161, 1161, 1161,
1345 1161, 1161, 1163, 1163, 1167, 1167, 1167, 1167, 1168, 1168,
1346 1168, 1168, 1169, 1169, 1170, 1170, 1173, 1177, 1182, 1182,
1347 1183, 1184, 1185, 1186, 1187, 1188, 1191, 1191, 1192, 1193,
1348 1194, 1195, 1196, 1197, 1207, 1207, 1214, 1214, 1223, 1231,
1349 1231, 1237, 1237, 1239, 1244, 1258, 1258, 1259, 1259, 1261,
1350 1271, 1271, 1271, 1271, 1271, 1271, 1271, 1272, 1272, 1272,
1351 1272, 1272, 1272, 1273, 1277, 1281, 1289, 1297, 1310, 1315,
1352 1327, 1337, 1341, 1352, 1357, 1363, 1364, 1368, 1372, 1383,
1353 1409, 1423, 1453, 1479, 1500, 1513, 1523, 1528, 1589, 1596,
1354 1605, 1611, 1617, 1621, 1625, 1633, 1644, 1676, 1684, 1711,
1355 1722, 1728, 1736, 1742, 1748, 1757, 1761, 1769, 1769, 1779,
1356 1787, 1792, 1796, 1800, 1804, 1819, 1841, 1844, 1847, 1852,
1357 1855, 1859, 1863, 1867, 1871, 1876, 1880, 1883, 1886, 1890,
1358 1903, 1904, 1906, 1910, 1919, 1923, 1928, 1930, 1935, 1940,
1359 1949, 1949, 1950, 1950, 1952, 1959, 1965, 1972, 1976, 1982,
1360 1987, 1992, 2087, 2087, 2089, 2097, 2097, 2099, 2104, 2104,
1361 2105, 2108, 2108, 2118, 2122, 2127, 2131, 2135, 2139, 2143,
1362 2147, 2151, 2155, 2159, 2184, 2188, 2202, 2206, 2212, 2212,
1363 2218, 2223, 2227, 2236, 2247, 2252, 2264, 2277, 2281, 2285,
1364 2290, 2299, 2318, 2327, 2383, 2387, 2394, 2405, 2418, 2427,
1365 2436, 2446, 2450, 2457, 2457, 2459, 2463, 2468, 2490, 2505,
1366 2519, 2532, 2540, 2548, 2556, 2562, 2582, 2605, 2611, 2617,
1367 2623, 2638, 2697, 2704, 2707, 2712, 2716, 2723, 2728, 2734,
1368 2739, 2745, 2753, 2765, 2780
1373 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1375 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1376 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1377 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1378 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1379 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1380 "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1381 "DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE",
1382 "ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK",
1383 "MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK",
1384 "X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE",
1385 "UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM",
1386 "FREM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC",
1387 "ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL",
1388 "SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR","VAARG_old","VANEXT_old",
1389 "'='","','","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'",
1390 "'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps","SetCondOps","ShiftOps",
1391 "SIntType","UIntType","IntType","FPType","OptAssign","OptLinkage","OptCallingConv",
1392 "OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1393 "TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI","ArgTypeListI",
1394 "ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList","ConstPool",
1395 "@1","@2","@3","@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
1396 "LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1397 "FunctionHeader","END","Function","FnDeclareLinkage","FunctionProto","@5","OptSideEffect",
1398 "ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList",
1399 "BasicBlock","InstructionList","BBTerminatorInst","JumpTable","Inst","PHIList",
1400 "ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList","OptVolatile",
1405 static const short yyr1[] = { 0,
1406 127, 127, 128, 128, 129, 129, 129, 129, 129, 129,
1407 129, 129, 129, 130, 130, 130, 131, 131, 131, 131,
1408 131, 131, 132, 132, 133, 133, 133, 133, 134, 134,
1409 134, 134, 135, 135, 136, 136, 137, 137, 138, 138,
1410 138, 138, 138, 138, 138, 138, 139, 139, 139, 139,
1411 139, 139, 139, 139, 140, 140, 141, 141, 142, 143,
1412 143, 144, 144, 145, 145, 146, 146, 147, 147, 148,
1413 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
1414 149, 149, 149, 150, 150, 150, 150, 150, 150, 150,
1415 150, 150, 150, 151, 151, 152, 152, 152, 152, 153,
1416 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1417 153, 153, 153, 153, 153, 154, 154, 154, 154, 154,
1418 154, 154, 154, 154, 154, 155, 155, 156, 156, 157,
1419 158, 158, 158, 158, 158, 159, 159, 159, 160, 159,
1420 161, 159, 162, 159, 163, 159, 159, 159, 159, 164,
1421 165, 165, 166, 166, 166, 166, 167, 168, 168, 168,
1422 169, 169, 170, 170, 171, 172, 172, 173, 173, 173,
1423 173, 174, 175, 175, 176, 177, 177, 178, 179, 179,
1424 179, 181, 180, 182, 182, 183, 183, 183, 183, 183,
1425 183, 183, 183, 183, 183, 183, 184, 184, 185, 185,
1426 186, 187, 187, 188, 189, 189, 189, 190, 190, 190,
1427 190, 190, 190, 190, 190, 190, 191, 191, 192, 193,
1428 193, 194, 194, 195, 195, 196, 196, 197, 197, 197,
1429 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1430 197, 197, 197, 198, 198, 199, 199, 200, 200, 200,
1431 200, 200, 200, 200, 200
1434 static const short yyr2[] = { 0,
1435 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1436 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1437 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1438 1, 1, 1, 1, 1, 1, 2, 0, 1, 1,
1439 1, 1, 1, 1, 1, 0, 0, 1, 1, 1,
1440 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1441 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1442 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1443 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1444 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1445 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1446 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1447 6, 6, 6, 8, 8, 3, 1, 1, 1, 1,
1448 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
1449 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
1450 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
1451 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
1452 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
1453 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
1454 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
1455 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
1456 9, 9, 8, 13, 1, 1, 6, 5, 2, 6,
1457 7, 1, 3, 1, 0, 2, 1, 5, 5, 5,
1458 2, 4, 4, 6, 4, 4, 4, 4, 6, 6,
1459 2, 7, 1, 2, 0, 1, 0, 3, 6, 3,
1463 static const short yydefact[] = { 149,
1464 46, 135, 134, 182, 39, 40, 41, 42, 43, 44,
1465 45, 0, 47, 206, 131, 132, 206, 161, 162, 0,
1466 0, 0, 46, 0, 137, 179, 0, 0, 48, 49,
1467 50, 51, 52, 53, 0, 0, 207, 203, 38, 176,
1468 177, 178, 202, 0, 0, 0, 0, 147, 0, 0,
1469 0, 0, 0, 0, 0, 37, 180, 181, 47, 150,
1470 133, 54, 1, 2, 67, 71, 72, 73, 74, 75,
1471 76, 77, 78, 79, 80, 81, 82, 83, 84, 0,
1472 0, 0, 0, 197, 0, 0, 66, 85, 70, 198,
1473 86, 173, 174, 175, 247, 205, 0, 0, 0, 0,
1474 160, 148, 138, 136, 128, 129, 0, 0, 0, 0,
1475 183, 87, 0, 0, 69, 92, 94, 0, 0, 99,
1476 93, 246, 0, 227, 0, 0, 0, 0, 47, 215,
1477 216, 5, 6, 7, 8, 9, 10, 11, 12, 13,
1478 14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
1479 0, 0, 0, 0, 0, 0, 23, 24, 0, 0,
1480 0, 0, 0, 0, 0, 0, 0, 0, 204, 47,
1481 219, 0, 243, 155, 152, 151, 153, 154, 156, 159,
1482 0, 143, 145, 141, 71, 72, 73, 74, 75, 76,
1483 77, 78, 79, 80, 81, 0, 0, 0, 0, 139,
1484 0, 0, 0, 91, 171, 98, 96, 0, 0, 231,
1485 226, 209, 208, 0, 0, 28, 32, 27, 31, 26,
1486 30, 25, 29, 33, 34, 0, 0, 57, 57, 252,
1487 0, 0, 241, 0, 0, 0, 0, 0, 0, 0,
1488 0, 0, 0, 0, 0, 0, 0, 0, 0, 157,
1489 62, 62, 62, 113, 114, 3, 4, 111, 112, 115,
1490 110, 106, 107, 0, 0, 0, 0, 0, 0, 0,
1491 0, 0, 0, 0, 0, 0, 0, 109, 108, 62,
1492 68, 68, 95, 170, 164, 167, 168, 0, 0, 88,
1493 186, 187, 188, 193, 189, 190, 191, 192, 184, 0,
1494 195, 200, 199, 201, 0, 210, 0, 0, 0, 248,
1495 0, 250, 245, 0, 0, 0, 0, 0, 0, 0,
1496 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1497 158, 0, 144, 146, 142, 0, 0, 0, 0, 0,
1498 0, 101, 127, 0, 0, 105, 0, 102, 0, 0,
1499 0, 0, 140, 89, 90, 163, 165, 0, 60, 97,
1500 185, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1501 255, 0, 0, 233, 0, 235, 238, 0, 0, 236,
1502 237, 0, 0, 0, 232, 0, 253, 0, 0, 0,
1503 64, 62, 245, 0, 0, 0, 0, 0, 0, 100,
1504 103, 104, 0, 0, 0, 0, 169, 166, 61, 55,
1505 0, 194, 0, 0, 225, 57, 58, 57, 222, 244,
1506 0, 0, 0, 0, 0, 228, 229, 230, 225, 0,
1507 59, 65, 63, 0, 0, 0, 0, 0, 0, 126,
1508 0, 0, 0, 0, 0, 172, 0, 0, 0, 224,
1509 0, 0, 249, 251, 0, 0, 0, 234, 239, 240,
1510 0, 254, 117, 0, 0, 0, 0, 0, 0, 0,
1511 0, 0, 56, 196, 0, 0, 0, 223, 220, 0,
1512 242, 116, 0, 123, 0, 0, 119, 120, 121, 122,
1513 0, 213, 0, 0, 0, 221, 0, 0, 0, 211,
1514 0, 212, 0, 0, 118, 124, 125, 0, 0, 0,
1515 0, 0, 0, 218, 0, 0, 217, 214, 0, 0,
1519 static const short yydefgoto[] = { 84,
1520 258, 274, 275, 276, 277, 196, 197, 226, 198, 23,
1521 13, 35, 446, 310, 391, 410, 333, 392, 85, 86,
1522 199, 88, 89, 118, 208, 343, 301, 344, 107, 519,
1523 1, 2, 280, 253, 251, 252, 61, 177, 48, 102,
1524 181, 90, 357, 286, 287, 288, 36, 94, 14, 42,
1525 15, 59, 16, 26, 362, 302, 91, 304, 419, 17,
1526 38, 39, 169, 494, 96, 233, 450, 451, 170, 171,
1530 static const short yypact[] = {-32768,
1531 184, 610,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1532 -32768, -46, 135, -1,-32768,-32768, -18,-32768,-32768, 15,
1533 -72, -24, 51, -62,-32768, 19, 61, 98,-32768,-32768,
1534 -32768,-32768,-32768,-32768, 1070, -20,-32768,-32768, 85,-32768,
1535 -32768,-32768,-32768, 33, 56, 60, 62,-32768, 54, 61,
1536 1070, 90, 90, 90, 90,-32768,-32768,-32768, 135,-32768,
1537 -32768,-32768,-32768,-32768, 58,-32768,-32768,-32768,-32768,-32768,
1538 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 173,
1539 174, 176, 576,-32768, 85, 66,-32768,-32768, -26,-32768,
1540 -32768,-32768,-32768,-32768, 1245,-32768, 157, 83, 179, 162,
1541 166,-32768,-32768,-32768,-32768,-32768, 1111, 1111, 1111, 1152,
1542 -32768,-32768, 75, 76,-32768,-32768, -26, -78, 80, 865,
1543 -32768,-32768, 1111,-32768, 138, 1193, 24, 151, 135,-32768,
1544 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1545 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1111,
1546 1111, 1111, 1111, 1111, 1111, 1111,-32768,-32768, 1111, 1111,
1547 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111,-32768, 135,
1548 -32768, 41,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1549 -10,-32768,-32768,-32768, 115, 145, 202, 147, 203, 149,
1550 204, 152, 206, 212, 213, 154, 217, 215, 419,-32768,
1551 1111, 1111, 1111,-32768, 906,-32768, 118, 116, 643,-32768,
1552 -32768, 58,-32768, 643, 643,-32768,-32768,-32768,-32768,-32768,
1553 -32768,-32768,-32768,-32768,-32768, 643, 1070, 120, 121,-32768,
1554 643, 124, 129, 208, 131, 133, 134, 140, 141, 142,
1555 143, 643, 643, 643, 144, 1070, 1111, 1111, 236,-32768,
1556 148, 148, 148,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1557 -32768,-32768,-32768, 150, 153, 155, 156, 159, 160, 947,
1558 1152, 596, 237, 161, 164, 175, 177,-32768,-32768, 148,
1559 -81, -38, -26,-32768, 85,-32768, 180, 146, 988,-32768,
1560 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 201, 1152,
1561 -32768,-32768,-32768,-32768, 182,-32768, 183, 643, -2,-32768,
1562 6,-32768, 186, 643, 185, 1111, 1111, 1111, 1111, 1111,
1563 1111, 1111, 1111, 187, 188, 190, 1111, 643, 643, 191,
1564 -32768, -23,-32768,-32768,-32768, 1152, 1152, 1152, 1152, 1152,
1565 1152,-32768,-32768, -9, -52,-32768, -76,-32768, 1152, 1152,
1566 1152, 1152,-32768,-32768,-32768,-32768,-32768, 1029, 231,-32768,
1567 -32768, 243, -14, 247, 249, 193, 643, 294, 643, 1111,
1568 -32768, 196, 643,-32768, 197,-32768,-32768, 199, 205,-32768,
1569 -32768, 643, 643, 643,-32768, 200,-32768, 1111, 291, 313,
1570 -32768, 148, 186, 288, 211, 216, 218, 219, 1152,-32768,
1571 -32768,-32768, 220, 226, 232, 233,-32768,-32768,-32768, 269,
1572 234,-32768, 643, 643, 1111, 240,-32768, 240,-32768, 241,
1573 643, 242, 1111, 1111, 1111,-32768,-32768,-32768, 1111, 643,
1574 -32768,-32768,-32768, 214, 1111, 1152, 1152, 1152, 1152,-32768,
1575 1152, 1152, 1152, 1152, 341,-32768, 327, 246, 239, 241,
1576 244, 305,-32768,-32768, 1111, 245, 643,-32768,-32768,-32768,
1577 252,-32768,-32768, 253, 250, 254, 259, 260, 262, 264,
1578 265, 267,-32768,-32768, 342, 14, 340,-32768,-32768, 257,
1579 -32768,-32768, 1152,-32768, 1152, 1152,-32768,-32768,-32768,-32768,
1580 643,-32768, 751, 65, 366,-32768, 274, 278, 279,-32768,
1581 283,-32768, 751, 643,-32768,-32768,-32768, 377, 285, 325,
1582 643, 382, 383,-32768, 643, 643,-32768,-32768, 405, 406,
1586 static const short yypgoto[] = {-32768,
1587 -32768, 312, 314, 315, 316, -127, -126, -462,-32768, 369,
1588 389, -87,-32768, -225, 55,-32768, -245,-32768, -48,-32768,
1589 -35,-32768, -66, 293,-32768, -100, 222, -253, 59,-32768,
1590 -32768,-32768,-32768,-32768,-32768,-32768, 365,-32768,-32768,-32768,
1591 -32768, 4,-32768, 68,-32768,-32768, 357,-32768,-32768,-32768,
1592 -32768,-32768, 415,-32768,-32768, -453, -55, 64, -103,-32768,
1593 401,-32768,-32768,-32768,-32768,-32768, 49, -7,-32768,-32768,
1601 static const short yytable[] = { 87,
1602 224, 225, 104, 312, 37, 24, 334, 335, 92, 200,
1603 389, 40, 367, 493, 27, 87, 117, 345, 347, 210,
1604 369, 37, 213, 216, 217, 218, 219, 220, 221, 222,
1605 223, 503, 214, 390, 353, 203, 50, 399, 354, 501,
1606 49, 227, 24, 121, 215, 204, 363, 402, 230, 509,
1607 56, 234, 235, 117, 368, 236, 237, 238, 239, 240,
1608 241, 399, 368, 57, 245, 58, 44, 45, 46, 401,
1609 51, 182, 183, 184, 216, 217, 218, 219, 220, 221,
1610 222, 223, 246, 355, 60, 47, 121, 209, 119, -68,
1611 209, 5, 6, 7, 8, 52, 10, 53, 121, 399,
1612 54, 62, 93, 249, 399, 41, 18, 412, 19, 250,
1613 400, 108, 109, 110, 228, 229, 209, 231, 232, 209,
1614 209, 105, 106, 209, 209, 209, 209, 209, 209, 242,
1615 243, 244, 209, 492, 281, 282, 283, 175, 176, 247,
1616 248, 254, 255, 279, 330, 97, 433, -28, -28, -27,
1617 -27, -26, -26, 303, -25, -25, 256, 257, 303, 303,
1618 216, 217, 218, 219, 220, 221, 222, 223, 98, 285,
1619 303, 101, 99, -69, 100, 303, 112, 113, 308, 114,
1620 174, 120, 178, -130, 502, 179, 303, 303, 303, 180,
1621 453, 87, 454, 201, 202, 205, 211, 328, 28, 29,
1622 30, 31, 32, 33, 34, -32, -31, -30, 3, -29,
1623 87, 329, 209, 375, 4, 377, 378, 379, -35, -36,
1624 259, 260, 283, 385, 5, 6, 7, 8, 9, 10,
1625 11, 289, 290, 309, 311, 393, 394, 395, 396, 397,
1626 398, 314, 315, 316, 317, 12, 318, 319, 403, 404,
1627 405, 406, 303, 320, 321, 322, 323, 327, 303, 331,
1628 348, 332, 359, 361, 389, 336, 411, 413, 337, 414,
1629 338, 339, 303, 303, 340, 341, 349, 305, 306, 350,
1630 374, 209, 376, 209, 209, 209, 380, 381, 356, 307,
1631 351, 209, 352, 358, 313, 364, 365, 417, 440, 370,
1632 382, 383, 373, 384, 388, 324, 325, 326, 415, 421,
1633 423, 303, 424, 303, 431, 429, 432, 303, 425, 458,
1634 459, 460, 285, 435, 436, 445, 303, 303, 303, 437,
1635 463, 438, 439, 441, 209, 465, 466, 467, 468, 442,
1636 469, 470, 471, 472, 473, 443, 444, 447, 224, 225,
1637 474, 478, 430, 452, 455, 457, 476, 303, 303, 475,
1638 477, 368, 491, 483, 479, 303, 224, 225, 481, 482,
1639 484, 366, 485, 486, 303, 495, 496, 372, 487, 209,
1640 488, 489, 497, 490, 498, 499, 504, 209, 209, 209,
1641 505, 386, 387, 209, 506, 507, 508, 511, 512, 464,
1642 513, 303, 515, 516, 520, 521, 165, 95, 166, 167,
1643 168, 55, 207, 409, 103, 111, 25, 43, 420, 209,
1644 278, 461, 434, 63, 64, 408, 0, 0, 0, 0,
1645 416, 0, 418, 0, 0, 303, 422, 0, 0, 0,
1646 18, 0, 19, 0, 261, 426, 427, 428, 303, 0,
1647 0, 0, 0, 0, 0, 303, 262, 263, 0, 303,
1648 303, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1649 0, 0, 0, 0, 0, 0, 448, 449, 0, 0,
1650 0, 0, 0, 0, 456, 0, 0, 0, 0, 0,
1651 0, 0, 0, 462, 0, 0, 132, 133, 134, 135,
1652 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
1653 146, 147, 148, 149, 0, 0, 0, 0, 0, 264,
1654 480, 265, 266, 157, 158, 0, 267, 268, 269, 0,
1655 0, 0, 0, 0, 0, 0, 270, 0, 0, 271,
1656 0, 272, 0, 0, 273, 0, 0, 0, 0, 0,
1657 0, 0, 0, 0, 500, 0, 0, 0, 0, 0,
1658 0, 0, 0, 0, 0, 0, 0, 510, 0, 0,
1659 0, 0, 0, 0, 514, 0, 0, 0, 517, 518,
1660 63, 64, 0, 115, 66, 67, 68, 69, 70, 71,
1661 72, 73, 74, 75, 76, 77, 78, 18, 0, 19,
1662 63, 64, 0, 115, 185, 186, 187, 188, 189, 190,
1663 191, 192, 193, 194, 195, 77, 78, 18, 0, 19,
1664 0, 0, 0, 79, 0, 0, 0, 0, 0, -38,
1665 0, 18, 0, 19, 0, 0, 0, 0, 0, 0,
1666 4, -38, -38, 79, 0, 291, 292, 63, 64, 293,
1667 -38, -38, -38, -38, -38, -38, -38, 0, 0, -38,
1668 20, 0, 0, 0, 18, 0, 19, 21, 294, 295,
1669 296, 22, 0, 0, 0, 0, 0, 0, 0, 0,
1670 297, 298, 0, 0, 0, 0, 0, 0, 0, 0,
1671 80, 0, 0, 81, 0, 0, 82, 0, 83, 116,
1672 0, 0, 0, 299, 0, 0, 0, 0, 0, 0,
1673 80, 0, 0, 81, 0, 0, 82, 0, 83, 346,
1674 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
1675 142, 143, 144, 145, 146, 147, 148, 149, 0, 0,
1676 0, 0, 0, 264, 0, 265, 266, 157, 158, 0,
1677 267, 268, 269, 291, 292, 0, 0, 293, 0, 0,
1678 0, 0, 0, 300, 0, 0, 0, 0, 0, 0,
1679 0, 0, 0, 0, 0, 0, 294, 295, 296, 0,
1680 0, 0, 0, 0, 0, 0, 0, 0, 297, 298,
1681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1682 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1683 0, 299, 0, 0, 0, 0, 0, 0, 0, 0,
1684 0, 0, 0, 0, 0, 0, 0, 0, 132, 133,
1685 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
1686 144, 145, 146, 147, 148, 149, 0, 0, 0, 0,
1687 0, 264, 0, 265, 266, 157, 158, 0, 267, 268,
1688 269, 0, 0, 0, 0, 0, 0, 0, 0, 63,
1689 64, 300, 115, 66, 67, 68, 69, 70, 71, 72,
1690 73, 74, 75, 76, 77, 78, 18, 0, 19, 0,
1691 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1692 0, 206, 0, 0, 0, 0, 0, 0, 0, 0,
1693 63, 64, 79, 115, 66, 67, 68, 69, 70, 71,
1694 72, 73, 74, 75, 76, 77, 78, 18, 0, 19,
1695 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1696 0, 0, 284, 0, 0, 0, 0, 0, 0, 0,
1697 0, 63, 64, 79, 115, 185, 186, 187, 188, 189,
1698 190, 191, 192, 193, 194, 195, 77, 78, 18, 0,
1699 19, 0, 0, 0, 0, 0, 0, 0, 0, 80,
1700 0, 0, 81, 0, 0, 82, 0, 83, 0, 0,
1701 0, 0, 63, 64, 79, 115, 66, 67, 68, 69,
1702 70, 71, 72, 73, 74, 75, 76, 77, 78, 18,
1703 0, 19, 0, 0, 0, 0, 0, 0, 0, 0,
1704 80, 0, 0, 81, 360, 0, 82, 0, 83, 0,
1705 0, 0, 0, 63, 64, 79, 115, 66, 67, 68,
1706 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1707 18, 0, 19, 0, 0, 0, 0, 0, 0, 0,
1708 0, 80, 0, 0, 81, 407, 342, 82, 0, 83,
1709 0, 0, 0, 0, 63, 64, 79, 65, 66, 67,
1710 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1711 78, 18, 0, 19, 0, 0, 0, 0, 0, 0,
1712 0, 0, 80, 0, 0, 81, 0, 0, 82, 0,
1713 83, 0, 0, 0, 0, 63, 64, 79, 115, 66,
1714 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1715 77, 78, 18, 0, 19, 0, 0, 0, 0, 0,
1716 0, 0, 0, 80, 0, 0, 81, 0, 0, 82,
1717 0, 83, 0, 0, 0, 0, 63, 64, 79, 115,
1718 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
1719 195, 77, 78, 18, 0, 19, 0, 0, 0, 0,
1720 0, 0, 0, 0, 80, 0, 0, 81, 0, 0,
1721 82, 0, 83, 0, 0, 0, 0, 63, 64, 79,
1722 212, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1723 75, 76, 77, 78, 18, 0, 19, 0, 0, 0,
1724 0, 0, 0, 0, 0, 80, 0, 0, 81, 0,
1725 0, 82, 0, 83, 0, 0, 0, 0, 0, 0,
1726 79, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1727 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1728 0, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1729 0, 0, 82, 0, 83, 0, 0, 0, 0, 122,
1730 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1731 0, 0, 0, 123, 0, 0, 0, 0, 0, 0,
1732 0, 0, 0, 124, 125, 0, 0, 80, 0, 0,
1733 81, 0, 0, 82, 0, 83, 126, 127, 128, 129,
1734 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
1735 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
1736 150, 151, 152, 0, 0, 153, 154, 155, 156, 157,
1737 158, 159, 160, 161, 162, 163, 164
1740 static const short yycheck[] = { 35,
1741 128, 128, 51, 229, 23, 2, 252, 253, 29, 110,
1742 34, 30, 15, 476, 61, 51, 83, 271, 272, 123,
1743 15, 23, 126, 10, 11, 12, 13, 14, 15, 16,
1744 17, 494, 9, 57, 280, 114, 61, 114, 120, 493,
1745 113, 129, 39, 125, 21, 124, 300, 124, 152, 503,
1746 113, 155, 156, 120, 57, 159, 160, 161, 162, 163,
1747 164, 114, 57, 45, 168, 47, 52, 53, 54, 122,
1748 20, 107, 108, 109, 10, 11, 12, 13, 14, 15,
1749 16, 17, 170, 122, 24, 71, 125, 123, 85, 116,
1750 126, 41, 42, 43, 44, 45, 46, 47, 125, 114,
1751 50, 4, 123, 114, 114, 124, 22, 122, 24, 120,
1752 120, 53, 54, 55, 150, 151, 152, 153, 154, 155,
1753 156, 32, 33, 159, 160, 161, 162, 163, 164, 165,
1754 166, 167, 168, 120, 201, 202, 203, 55, 56, 99,
1755 100, 27, 28, 199, 248, 113, 392, 3, 4, 3,
1756 4, 3, 4, 209, 3, 4, 3, 4, 214, 215,
1757 10, 11, 12, 13, 14, 15, 16, 17, 113, 205,
1758 226, 118, 113, 116, 113, 231, 4, 4, 227, 4,
1759 24, 116, 4, 0, 120, 24, 242, 243, 244, 24,
1760 416, 227, 418, 119, 119, 116, 59, 246, 64, 65,
1761 66, 67, 68, 69, 70, 4, 4, 4, 25, 4,
1762 246, 247, 248, 317, 31, 319, 320, 321, 7, 7,
1763 4, 7, 289, 327, 41, 42, 43, 44, 45, 46,
1764 47, 114, 117, 114, 114, 336, 337, 338, 339, 340,
1765 341, 118, 114, 36, 114, 62, 114, 114, 349, 350,
1766 351, 352, 308, 114, 114, 114, 114, 114, 314, 24,
1767 24, 114, 117, 63, 34, 116, 24, 21, 116, 21,
1768 116, 116, 328, 329, 116, 116, 116, 214, 215, 116,
1769 316, 317, 318, 319, 320, 321, 322, 323, 285, 226,
1770 116, 327, 116, 114, 231, 114, 114, 4, 399, 114,
1771 114, 114, 118, 114, 114, 242, 243, 244, 116, 114,
1772 114, 367, 114, 369, 24, 116, 4, 373, 114, 423,
1773 424, 425, 358, 36, 114, 57, 382, 383, 384, 114,
1774 117, 114, 114, 114, 370, 436, 437, 438, 439, 114,
1775 441, 442, 443, 444, 4, 114, 114, 114, 476, 476,
1776 24, 455, 388, 114, 114, 114, 118, 413, 414, 114,
1777 117, 57, 21, 114, 120, 421, 494, 494, 117, 117,
1778 117, 308, 114, 114, 430, 36, 120, 314, 117, 415,
1779 117, 117, 483, 117, 485, 486, 21, 423, 424, 425,
1780 117, 328, 329, 429, 117, 117, 114, 21, 114, 435,
1781 76, 457, 21, 21, 0, 0, 95, 39, 95, 95,
1782 95, 23, 120, 359, 50, 59, 2, 17, 370, 455,
1783 199, 429, 393, 5, 6, 358, -1, -1, -1, -1,
1784 367, -1, 369, -1, -1, 491, 373, -1, -1, -1,
1785 22, -1, 24, -1, 26, 382, 383, 384, 504, -1,
1786 -1, -1, -1, -1, -1, 511, 38, 39, -1, 515,
1787 516, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1788 -1, -1, -1, -1, -1, -1, 413, 414, -1, -1,
1789 -1, -1, -1, -1, 421, -1, -1, -1, -1, -1,
1790 -1, -1, -1, 430, -1, -1, 78, 79, 80, 81,
1791 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
1792 92, 93, 94, 95, -1, -1, -1, -1, -1, 101,
1793 457, 103, 104, 105, 106, -1, 108, 109, 110, -1,
1794 -1, -1, -1, -1, -1, -1, 118, -1, -1, 121,
1795 -1, 123, -1, -1, 126, -1, -1, -1, -1, -1,
1796 -1, -1, -1, -1, 491, -1, -1, -1, -1, -1,
1797 -1, -1, -1, -1, -1, -1, -1, 504, -1, -1,
1798 -1, -1, -1, -1, 511, -1, -1, -1, 515, 516,
1799 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1800 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1801 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1802 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1803 -1, -1, -1, 48, -1, -1, -1, -1, -1, 20,
1804 -1, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1805 31, 32, 33, 48, -1, 3, 4, 5, 6, 7,
1806 41, 42, 43, 44, 45, 46, 47, -1, -1, 50,
1807 51, -1, -1, -1, 22, -1, 24, 58, 26, 27,
1808 28, 62, -1, -1, -1, -1, -1, -1, -1, -1,
1809 38, 39, -1, -1, -1, -1, -1, -1, -1, -1,
1810 115, -1, -1, 118, -1, -1, 121, -1, 123, 124,
1811 -1, -1, -1, 61, -1, -1, -1, -1, -1, -1,
1812 115, -1, -1, 118, -1, -1, 121, -1, 123, 124,
1813 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
1814 88, 89, 90, 91, 92, 93, 94, 95, -1, -1,
1815 -1, -1, -1, 101, -1, 103, 104, 105, 106, -1,
1816 108, 109, 110, 3, 4, -1, -1, 7, -1, -1,
1817 -1, -1, -1, 121, -1, -1, -1, -1, -1, -1,
1818 -1, -1, -1, -1, -1, -1, 26, 27, 28, -1,
1819 -1, -1, -1, -1, -1, -1, -1, -1, 38, 39,
1820 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1821 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1822 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
1823 -1, -1, -1, -1, -1, -1, -1, -1, 78, 79,
1824 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
1825 90, 91, 92, 93, 94, 95, -1, -1, -1, -1,
1826 -1, 101, -1, 103, 104, 105, 106, -1, 108, 109,
1827 110, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1828 6, 121, 8, 9, 10, 11, 12, 13, 14, 15,
1829 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1830 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1831 -1, 37, -1, -1, -1, -1, -1, -1, -1, -1,
1832 5, 6, 48, 8, 9, 10, 11, 12, 13, 14,
1833 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1834 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1835 -1, -1, 37, -1, -1, -1, -1, -1, -1, -1,
1836 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
1837 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1838 24, -1, -1, -1, -1, -1, -1, -1, -1, 115,
1839 -1, -1, 118, -1, -1, 121, -1, 123, -1, -1,
1840 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
1841 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1842 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
1843 115, -1, -1, 118, 37, -1, 121, -1, 123, -1,
1844 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
1845 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1846 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
1847 -1, 115, -1, -1, 118, 37, 120, 121, -1, 123,
1848 -1, -1, -1, -1, 5, 6, 48, 8, 9, 10,
1849 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1850 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1851 -1, -1, 115, -1, -1, 118, -1, -1, 121, -1,
1852 123, -1, -1, -1, -1, 5, 6, 48, 8, 9,
1853 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1854 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
1855 -1, -1, -1, 115, -1, -1, 118, -1, -1, 121,
1856 -1, 123, -1, -1, -1, -1, 5, 6, 48, 8,
1857 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1858 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1859 -1, -1, -1, -1, 115, -1, -1, 118, -1, -1,
1860 121, -1, 123, -1, -1, -1, -1, 5, 6, 48,
1861 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1862 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1863 -1, -1, -1, -1, -1, 115, -1, -1, 118, -1,
1864 -1, 121, -1, 123, -1, -1, -1, -1, -1, -1,
1865 48, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1866 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1867 -1, -1, -1, -1, -1, -1, 115, -1, -1, 118,
1868 -1, -1, 121, -1, 123, -1, -1, -1, -1, 35,
1869 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1870 -1, -1, -1, 49, -1, -1, -1, -1, -1, -1,
1871 -1, -1, -1, 59, 60, -1, -1, 115, -1, -1,
1872 118, -1, -1, 121, -1, 123, 72, 73, 74, 75,
1873 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1874 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
1875 96, 97, 98, -1, -1, 101, 102, 103, 104, 105,
1876 106, 107, 108, 109, 110, 111, 112
1878 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1879 #line 3 "/usr/share/bison.simple"
1880 /* This file comes from bison-1.28. */
1882 /* Skeleton output parser for bison,
1883 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1885 This program is free software; you can redistribute it and/or modify
1886 it under the terms of the GNU General Public License as published by
1887 the Free Software Foundation; either version 2, or (at your option)
1890 This program is distributed in the hope that it will be useful,
1891 but WITHOUT ANY WARRANTY; without even the implied warranty of
1892 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1893 GNU General Public License for more details.
1895 You should have received a copy of the GNU General Public License
1896 along with this program; if not, write to the Free Software
1897 Foundation, Inc., 59 Temple Place - Suite 330,
1898 Boston, MA 02111-1307, USA. */
1900 /* As a special exception, when this file is copied by Bison into a
1901 Bison output file, you may use that output file without restriction.
1902 This special exception was added by the Free Software Foundation
1903 in version 1.24 of Bison. */
1905 /* This is the parser code that is written into each bison parser
1906 when the %semantic_parser declaration is not specified in the grammar.
1907 It was written by Richard Stallman by simplifying the hairy parser
1908 used when %semantic_parser is specified. */
1910 #ifndef YYSTACK_USE_ALLOCA
1912 #define YYSTACK_USE_ALLOCA
1913 #else /* alloca not defined */
1915 #define YYSTACK_USE_ALLOCA
1916 #define alloca __builtin_alloca
1917 #else /* not GNU C. */
1918 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1919 #define YYSTACK_USE_ALLOCA
1921 #else /* not sparc */
1922 /* We think this test detects Watcom and Microsoft C. */
1923 /* This used to test MSDOS, but that is a bad idea
1924 since that symbol is in the user namespace. */
1925 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1926 #if 0 /* No need for malloc.h, which pollutes the namespace;
1927 instead, just don't use alloca. */
1930 #else /* not MSDOS, or __TURBOC__ */
1932 /* I don't know what this was needed for, but it pollutes the namespace.
1933 So I turned it off. rms, 2 May 1997. */
1934 /* #include <malloc.h> */
1936 #define YYSTACK_USE_ALLOCA
1937 #else /* not MSDOS, or __TURBOC__, or _AIX */
1939 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1940 and on HPUX 10. Eventually we can turn this on. */
1941 #define YYSTACK_USE_ALLOCA
1942 #define alloca __builtin_alloca
1945 #endif /* not _AIX */
1946 #endif /* not MSDOS, or __TURBOC__ */
1947 #endif /* not sparc */
1948 #endif /* not GNU C */
1949 #endif /* alloca not defined */
1950 #endif /* YYSTACK_USE_ALLOCA not defined */
1952 #ifdef YYSTACK_USE_ALLOCA
1953 #define YYSTACK_ALLOC alloca
1955 #define YYSTACK_ALLOC malloc
1958 /* Note: there must be only one dollar sign in this file.
1959 It is replaced by the list of actions, each action
1960 as one case of the switch. */
1962 #define yyerrok (yyerrstatus = 0)
1963 #define yyclearin (yychar = YYEMPTY)
1966 #define YYACCEPT goto yyacceptlab
1967 #define YYABORT goto yyabortlab
1968 #define YYERROR goto yyerrlab1
1969 /* Like YYERROR except do call yyerror.
1970 This remains here temporarily to ease the
1971 transition to the new meaning of YYERROR, for GCC.
1972 Once GCC version 2 has supplanted version 1, this can go. */
1973 #define YYFAIL goto yyerrlab
1974 #define YYRECOVERING() (!!yyerrstatus)
1975 #define YYBACKUP(token, value) \
1977 if (yychar == YYEMPTY && yylen == 1) \
1978 { yychar = (token), yylval = (value); \
1979 yychar1 = YYTRANSLATE (yychar); \
1984 { yyerror ("syntax error: cannot back up"); YYERROR; } \
1988 #define YYERRCODE 256
1991 #define YYLEX yylex()
1997 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
1999 #define YYLEX yylex(&yylval, &yylloc)
2001 #else /* not YYLSP_NEEDED */
2003 #define YYLEX yylex(&yylval, YYLEX_PARAM)
2005 #define YYLEX yylex(&yylval)
2007 #endif /* not YYLSP_NEEDED */
2010 /* If nonreentrant, generate the variables here */
2014 int yychar; /* the lookahead symbol */
2015 YYSTYPE yylval; /* the semantic value of the */
2016 /* lookahead symbol */
2019 YYLTYPE yylloc; /* location data for the lookahead */
2023 int yynerrs; /* number of parse errors so far */
2024 #endif /* not YYPURE */
2027 int yydebug; /* nonzero means print parse trace */
2028 /* Since this is uninitialized, it does not stop multiple parsers
2032 /* YYINITDEPTH indicates the initial size of the parser's stacks */
2035 #define YYINITDEPTH 200
2038 /* YYMAXDEPTH is the maximum size the stacks can grow to
2039 (effective only if the built-in stack extension method is used). */
2046 #define YYMAXDEPTH 10000
2049 /* Define __yy_memcpy. Note that the size argument
2050 should be passed with type unsigned int, because that is what the non-GCC
2051 definitions require. With GCC, __builtin_memcpy takes an arg
2052 of type size_t, but it can handle unsigned int. */
2054 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2055 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2056 #else /* not GNU C or C++ */
2059 /* This is the most reliable way to avoid incompatibilities
2060 in available built-in functions on various systems. */
2062 __yy_memcpy (to, from, count)
2067 register char *f = from;
2068 register char *t = to;
2069 register int i = count;
2075 #else /* __cplusplus */
2077 /* This is the most reliable way to avoid incompatibilities
2078 in available built-in functions on various systems. */
2080 __yy_memcpy (char *to, char *from, unsigned int count)
2082 register char *t = to;
2083 register char *f = from;
2084 register int i = count;
2093 #line 217 "/usr/share/bison.simple"
2095 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2096 into yyparse. The argument should have type void *.
2097 It should actually point to an object.
2098 Grammar actions can access the variable by casting it
2099 to the proper pointer type. */
2101 #ifdef YYPARSE_PARAM
2103 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2104 #define YYPARSE_PARAM_DECL
2105 #else /* not __cplusplus */
2106 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2107 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2108 #endif /* not __cplusplus */
2109 #else /* not YYPARSE_PARAM */
2110 #define YYPARSE_PARAM_ARG
2111 #define YYPARSE_PARAM_DECL
2112 #endif /* not YYPARSE_PARAM */
2114 /* Prevent warning if -Wstrict-prototypes. */
2116 #ifdef YYPARSE_PARAM
2117 int yyparse (void *);
2124 yyparse(YYPARSE_PARAM_ARG)
2127 register int yystate;
2129 register short *yyssp;
2130 register YYSTYPE *yyvsp;
2131 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2132 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2134 short yyssa[YYINITDEPTH]; /* the state stack */
2135 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2137 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2138 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2141 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2142 YYLTYPE *yyls = yylsa;
2145 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2147 #define YYPOPSTACK (yyvsp--, yyssp--)
2150 int yystacksize = YYINITDEPTH;
2151 int yyfree_stacks = 0;
2162 YYSTYPE yyval; /* the variable used to return */
2163 /* semantic values from the action */
2170 fprintf(stderr, "Starting parse\n");
2176 yychar = YYEMPTY; /* Cause a token to be read. */
2178 /* Initialize stack pointers.
2179 Waste one element of value and location stack
2180 so that they stay on the same level as the state stack.
2181 The wasted elements are never initialized. */
2189 /* Push a new state, which is found in yystate . */
2190 /* In all cases, when you get here, the value and location stacks
2191 have just been pushed. so pushing a state here evens the stacks. */
2196 if (yyssp >= yyss + yystacksize - 1)
2198 /* Give user a chance to reallocate the stack */
2199 /* Use copies of these so that the &'s don't force the real ones into memory. */
2200 YYSTYPE *yyvs1 = yyvs;
2201 short *yyss1 = yyss;
2203 YYLTYPE *yyls1 = yyls;
2206 /* Get the current used size of the three stacks, in elements. */
2207 int size = yyssp - yyss + 1;
2210 /* Each stack pointer address is followed by the size of
2211 the data in use in that stack, in bytes. */
2213 /* This used to be a conditional around just the two extra args,
2214 but that might be undefined if yyoverflow is a macro. */
2215 yyoverflow("parser stack overflow",
2216 &yyss1, size * sizeof (*yyssp),
2217 &yyvs1, size * sizeof (*yyvsp),
2218 &yyls1, size * sizeof (*yylsp),
2221 yyoverflow("parser stack overflow",
2222 &yyss1, size * sizeof (*yyssp),
2223 &yyvs1, size * sizeof (*yyvsp),
2227 yyss = yyss1; yyvs = yyvs1;
2231 #else /* no yyoverflow */
2232 /* Extend the stack our own way. */
2233 if (yystacksize >= YYMAXDEPTH)
2235 yyerror("parser stack overflow");
2247 if (yystacksize > YYMAXDEPTH)
2248 yystacksize = YYMAXDEPTH;
2249 #ifndef YYSTACK_USE_ALLOCA
2252 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2253 __yy_memcpy ((char *)yyss, (char *)yyss1,
2254 size * (unsigned int) sizeof (*yyssp));
2255 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2256 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2257 size * (unsigned int) sizeof (*yyvsp));
2259 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2260 __yy_memcpy ((char *)yyls, (char *)yyls1,
2261 size * (unsigned int) sizeof (*yylsp));
2263 #endif /* no yyoverflow */
2265 yyssp = yyss + size - 1;
2266 yyvsp = yyvs + size - 1;
2268 yylsp = yyls + size - 1;
2273 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2276 if (yyssp >= yyss + yystacksize - 1)
2282 fprintf(stderr, "Entering state %d\n", yystate);
2288 /* Do appropriate processing given the current state. */
2289 /* Read a lookahead token if we need one and don't already have one. */
2292 /* First try to decide what to do without reference to lookahead token. */
2294 yyn = yypact[yystate];
2298 /* Not known => get a lookahead token if don't already have one. */
2300 /* yychar is either YYEMPTY or YYEOF
2301 or a valid token in external form. */
2303 if (yychar == YYEMPTY)
2307 fprintf(stderr, "Reading a token: ");
2312 /* Convert token to internal form (in yychar1) for indexing tables with */
2314 if (yychar <= 0) /* This means end of input. */
2317 yychar = YYEOF; /* Don't call YYLEX any more */
2321 fprintf(stderr, "Now at end of input.\n");
2326 yychar1 = YYTRANSLATE(yychar);
2331 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2332 /* Give the individual parser a way to print the precise meaning
2333 of a token, for further debugging info. */
2335 YYPRINT (stderr, yychar, yylval);
2337 fprintf (stderr, ")\n");
2343 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2348 /* yyn is what to do for this token type in this state.
2349 Negative => reduce, -yyn is rule number.
2350 Positive => shift, yyn is new state.
2351 New state is final state => don't bother to shift,
2352 just return success.
2353 0, or most negative number => error. */
2368 /* Shift the lookahead token. */
2372 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2375 /* Discard the token being shifted unless it is eof. */
2376 if (yychar != YYEOF)
2384 /* count tokens shifted since error; after three, turn off error status. */
2385 if (yyerrstatus) yyerrstatus--;
2390 /* Do the default action for the current state. */
2393 yyn = yydefact[yystate];
2397 /* Do a reduction. yyn is the number of a rule to reduce with. */
2401 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2408 fprintf (stderr, "Reducing via rule %d (line %d), ",
2411 /* Print the symbols being reduced, and their result. */
2412 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2413 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2414 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2422 #line 1140 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2424 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2425 GEN_ERROR("Value too large for type!");
2426 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2431 #line 1149 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2433 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2434 GEN_ERROR("Value too large for type!");
2435 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2440 #line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2442 yyval.StrVal = yyvsp[-1].StrVal;
2447 #line 1177 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2454 #line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2455 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2458 #line 1183 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2459 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2462 #line 1184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2463 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2466 #line 1185 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2467 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2470 #line 1186 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2471 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2474 #line 1187 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2475 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2478 #line 1188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2479 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2482 #line 1189 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2483 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2486 #line 1191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2487 { yyval.UIntVal = CallingConv::C; ;
2490 #line 1192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2491 { yyval.UIntVal = CallingConv::C; ;
2494 #line 1193 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2495 { yyval.UIntVal = CallingConv::CSRet; ;
2498 #line 1194 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2499 { yyval.UIntVal = CallingConv::Fast; ;
2502 #line 1195 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2503 { yyval.UIntVal = CallingConv::Cold; ;
2506 #line 1196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2507 { yyval.UIntVal = CallingConv::X86_StdCall; ;
2510 #line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2511 { yyval.UIntVal = CallingConv::X86_FastCall; ;
2514 #line 1198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2516 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2517 GEN_ERROR("Calling conv too large!");
2518 yyval.UIntVal = yyvsp[0].UInt64Val;
2523 #line 1207 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2524 { yyval.UIntVal = 0; ;
2527 #line 1208 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2529 yyval.UIntVal = yyvsp[0].UInt64Val;
2530 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2531 GEN_ERROR("Alignment must be a power of two!");
2536 #line 1214 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2537 { yyval.UIntVal = 0; ;
2540 #line 1215 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2542 yyval.UIntVal = yyvsp[0].UInt64Val;
2543 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2544 GEN_ERROR("Alignment must be a power of two!");
2549 #line 1223 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2551 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2552 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2553 GEN_ERROR("Invalid character in section name!");
2554 yyval.StrVal = yyvsp[0].StrVal;
2559 #line 1231 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2560 { yyval.StrVal = 0; ;
2563 #line 1232 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2564 { yyval.StrVal = yyvsp[0].StrVal; ;
2567 #line 1237 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2571 #line 1238 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2575 #line 1239 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2577 CurGV->setSection(yyvsp[0].StrVal);
2578 free(yyvsp[0].StrVal);
2583 #line 1244 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2585 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2586 GEN_ERROR("Alignment must be a power of two!");
2587 CurGV->setAlignment(yyvsp[0].UInt64Val);
2592 #line 1258 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2593 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2596 #line 1259 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2597 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2600 #line 1261 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2602 if (!UpRefs.empty())
2603 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2604 yyval.TypeVal = yyvsp[0].TypeVal;
2609 #line 1273 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2611 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2616 #line 1277 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2618 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2623 #line 1281 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2624 { // Named types are also simple types...
2625 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
2627 yyval.TypeVal = new PATypeHolder(tmp);
2631 #line 1289 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2632 { // Type UpReference
2633 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
2634 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2635 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2636 yyval.TypeVal = new PATypeHolder(OT);
2637 UR_OUT("New Upreference!\n");
2642 #line 1297 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2643 { // Function derived type?
2644 std::vector<const Type*> Params;
2645 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2646 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2647 Params.push_back(*I);
2648 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2649 if (isVarArg) Params.pop_back();
2651 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2652 delete yyvsp[-1].TypeList; // Delete the argument list
2653 delete yyvsp[-3].TypeVal; // Delete the return type handle
2658 #line 1310 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2659 { // Sized array type?
2660 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2661 delete yyvsp[-1].TypeVal;
2666 #line 1315 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2667 { // Packed array type?
2668 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2669 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2670 GEN_ERROR("Unsigned result not equal to signed result");
2671 if (!ElemTy->isPrimitiveType())
2672 GEN_ERROR("Elemental type of a PackedType must be primitive");
2673 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2674 GEN_ERROR("Vector length should be a power of 2!");
2675 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2676 delete yyvsp[-1].TypeVal;
2681 #line 1327 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2682 { // Structure type?
2683 std::vector<const Type*> Elements;
2684 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2685 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2686 Elements.push_back(*I);
2688 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2689 delete yyvsp[-1].TypeList;
2694 #line 1337 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2695 { // Empty structure type?
2696 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2701 #line 1341 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2703 if (*yyvsp[-1].TypeVal == Type::LabelTy)
2704 GEN_ERROR("Cannot form a pointer to a basic block");
2705 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2706 delete yyvsp[-1].TypeVal;
2711 #line 1352 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2713 yyval.TypeList = new std::list<PATypeHolder>();
2714 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2719 #line 1357 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2721 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2726 #line 1364 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2728 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2733 #line 1368 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2735 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2740 #line 1372 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2742 yyval.TypeList = new std::list<PATypeHolder>();
2747 #line 1383 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2748 { // Nonempty unsized arr
2749 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2751 GEN_ERROR("Cannot make array constant with type: '" +
2752 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2753 const Type *ETy = ATy->getElementType();
2754 int NumElements = ATy->getNumElements();
2756 // Verify that we have the correct size...
2757 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2758 GEN_ERROR("Type mismatch: constant sized array initialized with " +
2759 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2760 itostr(NumElements) + "!");
2762 // Verify all elements are correct type!
2763 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2764 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2765 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
2766 ETy->getDescription() +"' as required!\nIt is of type '"+
2767 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2770 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2771 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2776 #line 1409 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2778 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2780 GEN_ERROR("Cannot make array constant with type: '" +
2781 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2783 int NumElements = ATy->getNumElements();
2784 if (NumElements != -1 && NumElements != 0)
2785 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
2786 " arguments, but has size of " + itostr(NumElements) +"!");
2787 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2788 delete yyvsp[-2].TypeVal;
2793 #line 1423 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2795 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2797 GEN_ERROR("Cannot make array constant with type: '" +
2798 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2800 int NumElements = ATy->getNumElements();
2801 const Type *ETy = ATy->getElementType();
2802 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2803 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2804 GEN_ERROR("Can't build string constant of size " +
2805 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2806 " when array has size " + itostr(NumElements) + "!");
2807 std::vector<Constant*> Vals;
2808 if (ETy == Type::SByteTy) {
2809 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
2810 Vals.push_back(ConstantInt::get(ETy, *C));
2811 } else if (ETy == Type::UByteTy) {
2812 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2813 C != (unsigned char*)EndStr; ++C)
2814 Vals.push_back(ConstantInt::get(ETy, *C));
2816 free(yyvsp[0].StrVal);
2817 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
2819 free(yyvsp[0].StrVal);
2820 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2821 delete yyvsp[-2].TypeVal;
2826 #line 1453 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2827 { // Nonempty unsized arr
2828 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2830 GEN_ERROR("Cannot make packed constant with type: '" +
2831 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2832 const Type *ETy = PTy->getElementType();
2833 int NumElements = PTy->getNumElements();
2835 // Verify that we have the correct size...
2836 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2837 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
2838 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2839 itostr(NumElements) + "!");
2841 // Verify all elements are correct type!
2842 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2843 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2844 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
2845 ETy->getDescription() +"' as required!\nIt is of type '"+
2846 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2849 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2850 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2855 #line 1479 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2857 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2859 GEN_ERROR("Cannot make struct constant with type: '" +
2860 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2862 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2863 GEN_ERROR("Illegal number of initializers for structure type!");
2865 // Check to ensure that constants are compatible with the type initializer!
2866 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2867 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2868 GEN_ERROR("Expected type '" +
2869 STy->getElementType(i)->getDescription() +
2870 "' for element #" + utostr(i) +
2871 " of structure initializer!");
2873 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2874 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2879 #line 1500 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2881 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2883 GEN_ERROR("Cannot make struct constant with type: '" +
2884 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2886 if (STy->getNumContainedTypes() != 0)
2887 GEN_ERROR("Illegal number of initializers for structure type!");
2889 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2890 delete yyvsp[-2].TypeVal;
2895 #line 1513 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2897 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2899 GEN_ERROR("Cannot make null pointer constant with type: '" +
2900 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2902 yyval.ConstVal = ConstantPointerNull::get(PTy);
2903 delete yyvsp[-1].TypeVal;
2908 #line 1523 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2910 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2911 delete yyvsp[-1].TypeVal;
2916 #line 1528 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2918 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2920 GEN_ERROR("Global const reference must be a pointer type!");
2922 // ConstExprs can exist in the body of a function, thus creating
2923 // GlobalValues whenever they refer to a variable. Because we are in
2924 // the context of a function, getValNonImprovising will search the functions
2925 // symbol table instead of the module symbol table for the global symbol,
2926 // which throws things all off. To get around this, we just tell
2927 // getValNonImprovising that we are at global scope here.
2929 Function *SavedCurFn = CurFun.CurrentFunction;
2930 CurFun.CurrentFunction = 0;
2932 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2935 CurFun.CurrentFunction = SavedCurFn;
2937 // If this is an initializer for a constant pointer, which is referencing a
2938 // (currently) undefined variable, create a stub now that shall be replaced
2939 // in the future with the right type of variable.
2942 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2943 const PointerType *PT = cast<PointerType>(Ty);
2945 // First check to see if the forward references value is already created!
2946 PerModuleInfo::GlobalRefsType::iterator I =
2947 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2949 if (I != CurModule.GlobalRefs.end()) {
2950 V = I->second; // Placeholder already exists, use it...
2951 yyvsp[0].ValIDVal.destroy();
2954 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2956 // Create the forward referenced global.
2958 if (const FunctionType *FTy =
2959 dyn_cast<FunctionType>(PT->getElementType())) {
2960 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2961 CurModule.CurrentModule);
2963 GV = new GlobalVariable(PT->getElementType(), false,
2964 GlobalValue::ExternalLinkage, 0,
2965 Name, CurModule.CurrentModule);
2968 // Keep track of the fact that we have a forward ref to recycle it
2969 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2974 yyval.ConstVal = cast<GlobalValue>(V);
2975 delete yyvsp[-1].TypeVal; // Free the type handle
2980 #line 1589 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2982 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2983 GEN_ERROR("Mismatched types for constant expression!");
2984 yyval.ConstVal = yyvsp[0].ConstVal;
2985 delete yyvsp[-1].TypeVal;
2990 #line 1596 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2992 const Type *Ty = yyvsp[-1].TypeVal->get();
2993 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2994 GEN_ERROR("Cannot create a null initialized value of this type!");
2995 yyval.ConstVal = Constant::getNullValue(Ty);
2996 delete yyvsp[-1].TypeVal;
3001 #line 1605 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3002 { // integral constants
3003 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
3004 GEN_ERROR("Constant value doesn't fit in type!");
3005 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
3010 #line 1611 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3011 { // integral constants
3012 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
3013 GEN_ERROR("Constant value doesn't fit in type!");
3014 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
3019 #line 1617 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3020 { // Boolean constants
3021 yyval.ConstVal = ConstantBool::getTrue();
3026 #line 1621 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3027 { // Boolean constants
3028 yyval.ConstVal = ConstantBool::getFalse();
3033 #line 1625 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3034 { // Float & Double constants
3035 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
3036 GEN_ERROR("Floating point constant invalid for type!!");
3037 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
3042 #line 1633 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3044 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
3045 GEN_ERROR("cast constant expression from a non-primitive type: '" +
3046 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
3047 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
3048 GEN_ERROR("cast constant expression to a non-primitive type: '" +
3049 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
3050 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3051 delete yyvsp[-1].TypeVal;
3056 #line 1644 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3058 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
3059 GEN_ERROR("GetElementPtr requires a pointer operand!");
3061 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3062 // indices to uint struct indices for compatibility.
3063 generic_gep_type_iterator<std::vector<Value*>::iterator>
3064 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
3065 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
3066 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3067 if (isa<StructType>(*GTI)) // Only change struct indices
3068 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*yyvsp[-1].ValueList)[i]))
3069 if (CUI->getType() == Type::UByteTy)
3070 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3073 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
3075 GEN_ERROR("Index list invalid for constant getelementptr!");
3077 std::vector<Constant*> IdxVec;
3078 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3079 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
3080 IdxVec.push_back(C);
3082 GEN_ERROR("Indices to constant getelementptr must be constants!");
3084 delete yyvsp[-1].ValueList;
3086 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
3091 #line 1676 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3093 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
3094 GEN_ERROR("Select condition must be of boolean type!");
3095 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3096 GEN_ERROR("Select operand types must match!");
3097 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3102 #line 1684 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3104 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3105 GEN_ERROR("Binary operator types must match!");
3106 // First, make sure we're dealing with the right opcode by upgrading from
3107 // obsolete versions.
3108 sanitizeOpCode(yyvsp[-5].BinaryOpVal,yyvsp[-3].ConstVal->getType());
3111 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3112 // To retain backward compatibility with these early compilers, we emit a
3113 // cast to the appropriate integer type automatically if we are in the
3114 // broken case. See PR424 for more information.
3115 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
3116 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal.opcode, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3118 const Type *IntPtrTy = 0;
3119 switch (CurModule.CurrentModule->getPointerSize()) {
3120 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3121 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
3122 default: GEN_ERROR("invalid pointer binary constant expr!");
3124 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal.opcode, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
3125 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
3126 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
3132 #line 1711 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3134 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3135 GEN_ERROR("Logical operator types must match!");
3136 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
3137 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3138 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
3139 GEN_ERROR("Logical operator requires integral operands!");
3141 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal.opcode, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3146 #line 1722 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3148 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3149 GEN_ERROR("setcc operand types must match!");
3150 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal.opcode, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3155 #line 1728 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3157 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
3158 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
3159 if (!yyvsp[-3].ConstVal->getType()->isInteger())
3160 GEN_ERROR("Shift constant expression requires integer operand!");
3161 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal.opcode, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3166 #line 1736 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3168 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3169 GEN_ERROR("Invalid extractelement operands!");
3170 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3175 #line 1742 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3177 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3178 GEN_ERROR("Invalid insertelement operands!");
3179 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3184 #line 1748 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3186 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3187 GEN_ERROR("Invalid shufflevector operands!");
3188 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3193 #line 1757 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3195 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
3200 #line 1761 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3202 yyval.ConstVector = new std::vector<Constant*>();
3203 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
3208 #line 1769 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3209 { yyval.BoolVal = false; ;
3212 #line 1769 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3213 { yyval.BoolVal = true; ;
3216 #line 1779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3218 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
3219 CurModule.ModuleDone();
3224 #line 1787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3226 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3227 CurFun.FunctionDone();
3232 #line 1792 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3234 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3239 #line 1796 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3241 yyval.ModuleVal = yyvsp[-3].ModuleVal;
3246 #line 1800 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3248 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3253 #line 1804 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3255 yyval.ModuleVal = CurModule.CurrentModule;
3256 // Emit an error if there are any unresolved types left.
3257 if (!CurModule.LateResolveTypes.empty()) {
3258 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
3259 if (DID.Type == ValID::NameVal) {
3260 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3262 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3269 #line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3271 // Eagerly resolve types. This is not an optimization, this is a
3272 // requirement that is due to the fact that we could have this:
3274 // %list = type { %list * }
3275 // %list = type { %list * } ; repeated type decl
3277 // If types are not resolved eagerly, then the two types will not be
3278 // determined to be the same type!
3280 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3282 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3284 // If this is a named type that is not a redefinition, add it to the slot
3286 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3289 delete yyvsp[0].TypeVal;
3294 #line 1841 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3295 { // Function prototypes can be in const pool
3300 #line 1844 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3301 { // Asm blocks can be in the const pool
3306 #line 1847 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3308 if (yyvsp[0].ConstVal == 0)
3309 GEN_ERROR("Global value initializer is not a constant!");
3310 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3315 #line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3321 #line 1855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3323 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3325 delete yyvsp[0].TypeVal;
3329 #line 1859 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3336 #line 1863 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3338 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3340 delete yyvsp[0].TypeVal;
3344 #line 1867 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3351 #line 1871 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3354 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3356 delete yyvsp[0].TypeVal;
3360 #line 1876 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3367 #line 1880 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3373 #line 1883 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3379 #line 1886 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3384 #line 1890 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3386 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3387 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3388 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3389 free(yyvsp[0].StrVal);
3391 if (AsmSoFar.empty())
3392 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3394 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
3399 #line 1903 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3400 { yyval.Endianness = Module::BigEndian; ;
3403 #line 1904 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3404 { yyval.Endianness = Module::LittleEndian; ;
3407 #line 1906 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3409 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3414 #line 1910 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3416 if (yyvsp[0].UInt64Val == 32)
3417 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3418 else if (yyvsp[0].UInt64Val == 64)
3419 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3421 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3426 #line 1919 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3428 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3429 free(yyvsp[0].StrVal);
3433 #line 1923 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3435 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
3436 free(yyvsp[0].StrVal);
3440 #line 1930 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3442 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3443 free(yyvsp[0].StrVal);
3448 #line 1935 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3450 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3451 free(yyvsp[0].StrVal);
3456 #line 1940 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3462 #line 1950 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3463 { yyval.StrVal = 0; ;
3466 #line 1952 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3468 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3469 GEN_ERROR("void typed arguments are invalid!");
3470 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3475 #line 1959 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3477 yyval.ArgList = yyvsp[-2].ArgList;
3478 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3479 delete yyvsp[0].ArgVal;
3484 #line 1965 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3486 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3487 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3488 delete yyvsp[0].ArgVal;
3493 #line 1972 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3495 yyval.ArgList = yyvsp[0].ArgList;
3500 #line 1976 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3502 yyval.ArgList = yyvsp[-2].ArgList;
3503 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3504 char*>(new PATypeHolder(Type::VoidTy), 0));
3509 #line 1982 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3511 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3512 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3517 #line 1987 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3524 #line 1993 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3526 UnEscapeLexed(yyvsp[-5].StrVal);
3527 std::string FunctionName(yyvsp[-5].StrVal);
3528 free(yyvsp[-5].StrVal); // Free strdup'd memory!
3530 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
3531 GEN_ERROR("LLVM functions cannot return aggregate types!");
3533 std::vector<const Type*> ParamTypeList;
3534 if (yyvsp[-3].ArgList) { // If there are arguments...
3535 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3536 I != yyvsp[-3].ArgList->end(); ++I)
3537 ParamTypeList.push_back(I->first->get());
3540 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3541 if (isVarArg) ParamTypeList.pop_back();
3543 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
3544 const PointerType *PFT = PointerType::get(FT);
3545 delete yyvsp[-6].TypeVal;
3548 if (!FunctionName.empty()) {
3549 ID = ValID::create((char*)FunctionName.c_str());
3551 ID = ValID::create((int)CurModule.Values[PFT].size());
3555 // See if this function was forward referenced. If so, recycle the object.
3556 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3557 // Move the function to the end of the list, from whereever it was
3558 // previously inserted.
3559 Fn = cast<Function>(FWRef);
3560 CurModule.CurrentModule->getFunctionList().remove(Fn);
3561 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3562 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3563 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3564 // If this is the case, either we need to be a forward decl, or it needs
3566 if (!CurFun.isDeclare && !Fn->isExternal())
3567 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
3569 // Make sure to strip off any argument names so we can't get conflicts.
3570 if (Fn->isExternal())
3571 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3574 } else { // Not already defined?
3575 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3576 CurModule.CurrentModule);
3578 InsertValue(Fn, CurModule.Values);
3581 CurFun.FunctionStart(Fn);
3583 if (CurFun.isDeclare) {
3584 // If we have declaration, always overwrite linkage. This will allow us to
3585 // correctly handle cases, when pointer to function is passed as argument to
3586 // another function.
3587 Fn->setLinkage(CurFun.Linkage);
3589 Fn->setCallingConv(yyvsp[-7].UIntVal);
3590 Fn->setAlignment(yyvsp[0].UIntVal);
3591 if (yyvsp[-1].StrVal) {
3592 Fn->setSection(yyvsp[-1].StrVal);
3593 free(yyvsp[-1].StrVal);
3596 // Add all of the arguments we parsed to the function...
3597 if (yyvsp[-3].ArgList) { // Is null if empty...
3598 if (isVarArg) { // Nuke the last entry
3599 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
3600 "Not a varargs marker!");
3601 delete yyvsp[-3].ArgList->back().first;
3602 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
3604 Function::arg_iterator ArgIt = Fn->arg_begin();
3605 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3606 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
3607 delete I->first; // Delete the typeholder...
3609 setValueName(ArgIt, I->second); // Insert arg into symtab...
3614 delete yyvsp[-3].ArgList; // We're now done with the argument list
3620 #line 2089 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3622 yyval.FunctionVal = CurFun.CurrentFunction;
3624 // Make sure that we keep track of the linkage type even if there was a
3625 // previous "declare".
3626 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3630 #line 2099 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3632 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3637 #line 2105 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3638 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;
3641 #line 2106 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3642 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;
3645 #line 2108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3646 { CurFun.isDeclare = true; ;
3649 #line 2108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3651 yyval.FunctionVal = CurFun.CurrentFunction;
3652 CurFun.FunctionDone();
3657 #line 2118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3659 yyval.BoolVal = false;
3664 #line 2122 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3666 yyval.BoolVal = true;
3671 #line 2127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3672 { // A reference to a direct constant
3673 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3678 #line 2131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3680 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3685 #line 2135 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3686 { // Perhaps it's an FP constant?
3687 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3692 #line 2139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3694 yyval.ValIDVal = ValID::create(ConstantBool::getTrue());
3699 #line 2143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3701 yyval.ValIDVal = ValID::create(ConstantBool::getFalse());
3706 #line 2147 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3708 yyval.ValIDVal = ValID::createNull();
3713 #line 2151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3715 yyval.ValIDVal = ValID::createUndef();
3720 #line 2155 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3721 { // A vector zero constant.
3722 yyval.ValIDVal = ValID::createZeroInit();
3727 #line 2159 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3728 { // Nonempty unsized packed vector
3729 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3730 int NumElements = yyvsp[-1].ConstVector->size();
3732 PackedType* pt = PackedType::get(ETy, NumElements);
3733 PATypeHolder* PTy = new PATypeHolder(
3741 // Verify all elements are correct type!
3742 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3743 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3744 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3745 ETy->getDescription() +"' as required!\nIt is of type '" +
3746 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3749 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3750 delete PTy; delete yyvsp[-1].ConstVector;
3755 #line 2184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3757 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3762 #line 2188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3764 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3765 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3766 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3767 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3768 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3769 free(yyvsp[-2].StrVal);
3770 free(yyvsp[0].StrVal);
3775 #line 2202 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3776 { // Is it an integer reference...?
3777 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3782 #line 2206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3783 { // Is it a named reference...?
3784 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3789 #line 2218 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3791 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3796 #line 2223 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3798 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3803 #line 2227 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3804 { // Do not allow functions with 0 basic blocks
3805 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3810 #line 2236 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3812 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3814 InsertValue(yyvsp[0].TermInstVal);
3816 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3817 InsertValue(yyvsp[-2].BasicBlockVal);
3818 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3823 #line 2247 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3825 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3826 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3831 #line 2252 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3833 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3836 // Make sure to move the basic block to the correct location in the
3837 // function, instead of leaving it inserted wherever it was first
3839 Function::BasicBlockListType &BBL =
3840 CurFun.CurrentFunction->getBasicBlockList();
3841 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3846 #line 2264 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3848 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3851 // Make sure to move the basic block to the correct location in the
3852 // function, instead of leaving it inserted wherever it was first
3854 Function::BasicBlockListType &BBL =
3855 CurFun.CurrentFunction->getBasicBlockList();
3856 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3861 #line 2277 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3862 { // Return with a result...
3863 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3868 #line 2281 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3869 { // Return with no result...
3870 yyval.TermInstVal = new ReturnInst();
3875 #line 2285 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3876 { // Unconditional Branch...
3877 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
3879 yyval.TermInstVal = new BranchInst(tmpBB);
3883 #line 2290 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3885 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
3887 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
3889 Value* tmpVal = getVal(Type::BoolTy, yyvsp[-6].ValIDVal);
3891 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
3895 #line 2299 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3897 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
3899 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
3901 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
3902 yyval.TermInstVal = S;
3904 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3905 E = yyvsp[-1].JumpTable->end();
3906 for (; I != E; ++I) {
3907 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3908 S->addCase(CI, I->second);
3910 GEN_ERROR("Switch case is constant, but not a simple integer!");
3912 delete yyvsp[-1].JumpTable;
3917 #line 2318 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3919 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
3921 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
3923 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
3924 yyval.TermInstVal = S;
3929 #line 2328 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3931 const PointerType *PFTy;
3932 const FunctionType *Ty;
3934 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3935 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3936 // Pull out the types of all of the arguments...
3937 std::vector<const Type*> ParamTypes;
3938 if (yyvsp[-7].ValueList) {
3939 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3941 ParamTypes.push_back((*I)->getType());
3944 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3945 if (isVarArg) ParamTypes.pop_back();
3947 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3948 PFTy = PointerType::get(Ty);
3951 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3953 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3955 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3958 // Create the call node...
3959 if (!yyvsp[-7].ValueList) { // Has no arguments?
3960 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3961 } else { // Has arguments?
3962 // Loop through FunctionType's arguments and ensure they are specified
3965 FunctionType::param_iterator I = Ty->param_begin();
3966 FunctionType::param_iterator E = Ty->param_end();
3967 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3969 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3970 if ((*ArgI)->getType() != *I)
3971 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3972 (*I)->getDescription() + "'!");
3974 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3975 GEN_ERROR("Invalid number of parameters detected!");
3977 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3979 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3981 delete yyvsp[-10].TypeVal;
3982 delete yyvsp[-7].ValueList;
3987 #line 2383 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3989 yyval.TermInstVal = new UnwindInst();
3994 #line 2387 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3996 yyval.TermInstVal = new UnreachableInst();
4001 #line 2394 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4003 yyval.JumpTable = yyvsp[-5].JumpTable;
4004 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4007 GEN_ERROR("May only switch on a constant pool value!");
4009 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4011 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4015 #line 2405 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4017 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4018 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4022 GEN_ERROR("May only switch on a constant pool value!");
4024 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4026 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4030 #line 2418 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4032 // Is this definition named?? if so, assign the name...
4033 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
4035 InsertValue(yyvsp[0].InstVal);
4036 yyval.InstVal = yyvsp[0].InstVal;
4041 #line 2427 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4042 { // Used for PHI nodes
4043 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4044 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
4046 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4048 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4049 delete yyvsp[-5].TypeVal;
4053 #line 2436 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4055 yyval.PHIList = yyvsp[-6].PHIList;
4056 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
4058 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4060 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4064 #line 2446 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4065 { // Used for call statements, and memory insts...
4066 yyval.ValueList = new std::vector<Value*>();
4067 yyval.ValueList->push_back(yyvsp[0].ValueVal);
4071 #line 2450 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4073 yyval.ValueList = yyvsp[-2].ValueList;
4074 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
4079 #line 2457 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4080 { yyval.ValueList = 0; ;
4083 #line 2459 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4085 yyval.BoolVal = true;
4090 #line 2463 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4092 yyval.BoolVal = false;
4097 #line 2468 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4099 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4100 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4102 "Arithmetic operator requires integer, FP, or packed operands!");
4103 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) &&
4104 (yyvsp[-4].BinaryOpVal.opcode == Instruction::URem ||
4105 yyvsp[-4].BinaryOpVal.opcode == Instruction::SRem ||
4106 yyvsp[-4].BinaryOpVal.opcode == Instruction::FRem))
4107 GEN_ERROR("U/S/FRem not supported on packed types!");
4108 // Upgrade the opcode from obsolete versions before we do anything with it.
4109 sanitizeOpCode(yyvsp[-4].BinaryOpVal,*yyvsp[-3].TypeVal);
4111 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4113 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4115 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal.opcode, val1, val2);
4116 if (yyval.InstVal == 0)
4117 GEN_ERROR("binary operator returned null!");
4118 delete yyvsp[-3].TypeVal;
4122 #line 2490 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4124 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
4125 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
4126 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
4127 GEN_ERROR("Logical operator requires integral operands!");
4129 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4131 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4133 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal.opcode, tmpVal1, tmpVal2);
4134 if (yyval.InstVal == 0)
4135 GEN_ERROR("binary operator returned null!");
4136 delete yyvsp[-3].TypeVal;
4140 #line 2505 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4142 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
4144 "PackedTypes currently not supported in setcc instructions!");
4146 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4148 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4150 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal.opcode, tmpVal1, tmpVal2);
4151 if (yyval.InstVal == 0)
4152 GEN_ERROR("binary operator returned null!");
4153 delete yyvsp[-3].TypeVal;
4157 #line 2519 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4159 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4160 << " Replacing with 'xor'.\n";
4162 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
4164 GEN_ERROR("Expected integral type for not instruction!");
4166 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
4167 if (yyval.InstVal == 0)
4168 GEN_ERROR("Could not create a xor instruction!");
4173 #line 2532 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4175 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
4176 GEN_ERROR("Shift amount must be ubyte!");
4177 if (!yyvsp[-2].ValueVal->getType()->isInteger())
4178 GEN_ERROR("Shift constant expression requires integer operand!");
4179 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal.opcode, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4184 #line 2540 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4186 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
4187 GEN_ERROR("cast instruction to a non-primitive type: '" +
4188 yyvsp[0].TypeVal->get()->getDescription() + "'!");
4189 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4190 delete yyvsp[0].TypeVal;
4195 #line 2548 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4197 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
4198 GEN_ERROR("select condition must be boolean!");
4199 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
4200 GEN_ERROR("select value types should match!");
4201 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4206 #line 2556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4209 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4210 delete yyvsp[0].TypeVal;
4215 #line 2562 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4217 ObsoleteVarArgs = true;
4218 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4219 Function* NF = CurModule.CurrentModule->
4220 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
4223 //foo = alloca 1 of t
4227 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4228 CurBB->getInstList().push_back(foo);
4229 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4230 CurBB->getInstList().push_back(bar);
4231 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4232 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
4233 delete yyvsp[0].TypeVal;
4238 #line 2582 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4240 ObsoleteVarArgs = true;
4241 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4242 Function* NF = CurModule.CurrentModule->
4243 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
4245 //b = vanext a, t ->
4246 //foo = alloca 1 of t
4249 //tmp = vaarg foo, t
4251 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4252 CurBB->getInstList().push_back(foo);
4253 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4254 CurBB->getInstList().push_back(bar);
4255 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4256 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
4257 CurBB->getInstList().push_back(tmp);
4258 yyval.InstVal = new LoadInst(foo);
4259 delete yyvsp[0].TypeVal;
4264 #line 2605 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4266 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4267 GEN_ERROR("Invalid extractelement operands!");
4268 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4273 #line 2611 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4275 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4276 GEN_ERROR("Invalid insertelement operands!");
4277 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4282 #line 2617 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4284 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4285 GEN_ERROR("Invalid shufflevector operands!");
4286 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4291 #line 2623 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4293 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
4294 if (!Ty->isFirstClassType())
4295 GEN_ERROR("PHI node operands must be of first class type!");
4296 yyval.InstVal = new PHINode(Ty);
4297 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4298 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4299 if (yyvsp[0].PHIList->front().first->getType() != Ty)
4300 GEN_ERROR("All elements of a PHI node must be of the same type!");
4301 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4302 yyvsp[0].PHIList->pop_front();
4304 delete yyvsp[0].PHIList; // Free the list...
4309 #line 2638 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4311 const PointerType *PFTy;
4312 const FunctionType *Ty;
4314 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
4315 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4316 // Pull out the types of all of the arguments...
4317 std::vector<const Type*> ParamTypes;
4318 if (yyvsp[-1].ValueList) {
4319 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
4321 ParamTypes.push_back((*I)->getType());
4324 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4325 if (isVarArg) ParamTypes.pop_back();
4327 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
4328 GEN_ERROR("LLVM functions cannot return aggregate types!");
4330 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
4331 PFTy = PointerType::get(Ty);
4334 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
4337 // Create the call node...
4338 if (!yyvsp[-1].ValueList) { // Has no arguments?
4339 // Make sure no arguments is a good thing!
4340 if (Ty->getNumParams() != 0)
4341 GEN_ERROR("No arguments passed to a function that "
4342 "expects arguments!");
4344 yyval.InstVal = new CallInst(V, std::vector<Value*>());
4345 } else { // Has arguments?
4346 // Loop through FunctionType's arguments and ensure they are specified
4349 FunctionType::param_iterator I = Ty->param_begin();
4350 FunctionType::param_iterator E = Ty->param_end();
4351 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
4353 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4354 if ((*ArgI)->getType() != *I)
4355 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4356 (*I)->getDescription() + "'!");
4358 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
4359 GEN_ERROR("Invalid number of parameters detected!");
4361 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
4363 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
4364 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
4365 delete yyvsp[-4].TypeVal;
4366 delete yyvsp[-1].ValueList;
4371 #line 2697 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4373 yyval.InstVal = yyvsp[0].InstVal;
4378 #line 2704 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4380 yyval.ValueList = yyvsp[0].ValueList;
4385 #line 2707 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4387 yyval.ValueList = new std::vector<Value*>();
4392 #line 2712 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4394 yyval.BoolVal = true;
4399 #line 2716 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4401 yyval.BoolVal = false;
4406 #line 2723 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4408 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4409 delete yyvsp[-1].TypeVal;
4414 #line 2728 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4416 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4418 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4419 delete yyvsp[-4].TypeVal;
4423 #line 2734 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4425 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4426 delete yyvsp[-1].TypeVal;
4431 #line 2739 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4433 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4435 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4436 delete yyvsp[-4].TypeVal;
4440 #line 2745 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4442 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
4443 GEN_ERROR("Trying to free nonpointer type " +
4444 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4445 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
4450 #line 2753 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4452 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4453 GEN_ERROR("Can't load from nonpointer type: " +
4454 (*yyvsp[-1].TypeVal)->getDescription());
4455 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4456 GEN_ERROR("Can't load from pointer of non-first-class type: " +
4457 (*yyvsp[-1].TypeVal)->getDescription());
4458 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4460 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
4461 delete yyvsp[-1].TypeVal;
4465 #line 2765 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4467 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4469 GEN_ERROR("Can't store to a nonpointer type: " +
4470 (*yyvsp[-1].TypeVal)->getDescription());
4471 const Type *ElTy = PT->getElementType();
4472 if (ElTy != yyvsp[-3].ValueVal->getType())
4473 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4474 "' into space of type '" + ElTy->getDescription() + "'!");
4476 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4478 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
4479 delete yyvsp[-1].TypeVal;
4483 #line 2780 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4485 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4486 GEN_ERROR("getelementptr insn requires pointer operand!");
4488 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4489 // indices to uint struct indices for compatibility.
4490 generic_gep_type_iterator<std::vector<Value*>::iterator>
4491 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4492 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4493 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4494 if (isa<StructType>(*GTI)) // Only change struct indices
4495 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*yyvsp[0].ValueList)[i]))
4496 if (CUI->getType() == Type::UByteTy)
4497 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4499 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4500 GEN_ERROR("Invalid getelementptr indices for type '" +
4501 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4502 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
4504 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
4505 delete yyvsp[-2].TypeVal;
4506 delete yyvsp[0].ValueList;
4510 /* the action file gets copied in in place of this dollarsign */
4511 #line 543 "/usr/share/bison.simple"
4522 short *ssp1 = yyss - 1;
4523 fprintf (stderr, "state stack now");
4524 while (ssp1 != yyssp)
4525 fprintf (stderr, " %d", *++ssp1);
4526 fprintf (stderr, "\n");
4536 yylsp->first_line = yylloc.first_line;
4537 yylsp->first_column = yylloc.first_column;
4538 yylsp->last_line = (yylsp-1)->last_line;
4539 yylsp->last_column = (yylsp-1)->last_column;
4544 yylsp->last_line = (yylsp+yylen-1)->last_line;
4545 yylsp->last_column = (yylsp+yylen-1)->last_column;
4549 /* Now "shift" the result of the reduction.
4550 Determine what state that goes to,
4551 based on the state we popped back to
4552 and the rule number reduced by. */
4556 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4557 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4558 yystate = yytable[yystate];
4560 yystate = yydefgoto[yyn - YYNTBASE];
4564 yyerrlab: /* here on detecting error */
4567 /* If not already recovering from an error, report this error. */
4571 #ifdef YYERROR_VERBOSE
4572 yyn = yypact[yystate];
4574 if (yyn > YYFLAG && yyn < YYLAST)
4581 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4582 for (x = (yyn < 0 ? -yyn : 0);
4583 x < (sizeof(yytname) / sizeof(char *)); x++)
4584 if (yycheck[x + yyn] == x)
4585 size += strlen(yytname[x]) + 15, count++;
4586 msg = (char *) malloc(size + 15);
4589 strcpy(msg, "parse error");
4594 for (x = (yyn < 0 ? -yyn : 0);
4595 x < (sizeof(yytname) / sizeof(char *)); x++)
4596 if (yycheck[x + yyn] == x)
4598 strcat(msg, count == 0 ? ", expecting `" : " or `");
4599 strcat(msg, yytname[x]);
4608 yyerror ("parse error; also virtual memory exceeded");
4611 #endif /* YYERROR_VERBOSE */
4612 yyerror("parse error");
4616 yyerrlab1: /* here on error raised explicitly by an action */
4618 if (yyerrstatus == 3)
4620 /* if just tried and failed to reuse lookahead token after an error, discard it. */
4622 /* return failure if at end of input */
4623 if (yychar == YYEOF)
4628 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4634 /* Else will try to reuse lookahead token
4635 after shifting the error token. */
4637 yyerrstatus = 3; /* Each real token shifted decrements this */
4641 yyerrdefault: /* current state does not do anything special for the error token. */
4644 /* This is wrong; only states that explicitly want error tokens
4645 should shift them. */
4646 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4647 if (yyn) goto yydefault;
4650 yyerrpop: /* pop the current state because it cannot handle the error token */
4652 if (yyssp == yyss) YYABORT;
4662 short *ssp1 = yyss - 1;
4663 fprintf (stderr, "Error: state stack now");
4664 while (ssp1 != yyssp)
4665 fprintf (stderr, " %d", *++ssp1);
4666 fprintf (stderr, "\n");
4672 yyn = yypact[yystate];
4677 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4696 fprintf(stderr, "Shifting error token, ");
4708 /* YYACCEPT comes here. */
4720 /* YYABORT comes here. */
4731 #line 2806 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4734 void llvm::GenerateError(const std::string &message, int LineNo) {
4735 if (LineNo == -1) LineNo = llvmAsmlineno;
4736 // TODO: column number in exception
4738 TheParseError->setError(CurFilename, message, LineNo);
4742 int yyerror(const char *ErrorMsg) {
4744 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4745 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4746 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4747 if (yychar == YYEMPTY || yychar == 0)
4748 errMsg += "end-of-file.";
4750 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4751 GenerateError(errMsg);