2 /* A Bison parser, made from /Users/resistor/llvm/src/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
88 #define UNREACHABLE 331
108 #define GETELEMENTPTR 351
115 #define EXTRACTELEMENT 358
116 #define INSERTELEMENT 359
117 #define SHUFFLEVECTOR 360
118 #define VAARG_old 361
119 #define VANEXT_old 362
121 #line 14 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
123 #include "ParserInternals.h"
124 #include "llvm/CallingConv.h"
125 #include "llvm/InlineAsm.h"
126 #include "llvm/Instructions.h"
127 #include "llvm/Module.h"
128 #include "llvm/SymbolTable.h"
129 #include "llvm/Assembly/AutoUpgrade.h"
130 #include "llvm/Support/GetElementPtrTypeIterator.h"
131 #include "llvm/ADT/STLExtras.h"
132 #include "llvm/Support/MathExtras.h"
138 // The following is a gross hack. In order to rid the libAsmParser library of
139 // exceptions, we have to have a way of getting the yyparse function to go into
140 // an error situation. So, whenever we want an error to occur, the GenerateError
141 // function (see bottom of file) sets TriggerError. Then, at the end of each
142 // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
143 // (a goto) to put YACC in error state. Furthermore, several calls to
144 // GenerateError are made from inside productions and they must simulate the
145 // previous exception behavior by exiting the production immediately. We have
146 // replaced these with the GEN_ERROR macro which calls GeneratError and then
147 // immediately invokes YYERROR. This would be so much cleaner if it was a
148 // recursive descent parser.
149 static bool TriggerError = false;
150 #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
151 #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
153 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
154 int yylex(); // declaration" of xxx warnings.
158 std::string CurFilename;
160 using namespace llvm;
162 static Module *ParserResult;
164 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
165 // relating to upreferences in the input stream.
167 //#define DEBUG_UPREFS 1
169 #define UR_OUT(X) std::cerr << X
174 #define YYERROR_VERBOSE 1
176 static bool ObsoleteVarArgs;
177 static bool NewVarArgs;
178 static BasicBlock *CurBB;
179 static GlobalVariable *CurGV;
182 // This contains info used when building the body of a function. It is
183 // destroyed when the function is completed.
185 typedef std::vector<Value *> ValueList; // Numbered defs
187 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
188 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
190 static struct PerModuleInfo {
191 Module *CurrentModule;
192 std::map<const Type *, ValueList> Values; // Module level numbered definitions
193 std::map<const Type *,ValueList> LateResolveValues;
194 std::vector<PATypeHolder> Types;
195 std::map<ValID, PATypeHolder> LateResolveTypes;
197 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
198 /// how they were referenced and on which line of the input they came from so
199 /// that we can resolve them later and print error messages as appropriate.
200 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
202 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
203 // references to global values. Global values may be referenced before they
204 // are defined, and if so, the temporary object that they represent is held
205 // here. This is used for forward references of GlobalValues.
207 typedef std::map<std::pair<const PointerType *,
208 ValID>, GlobalValue*> GlobalRefsType;
209 GlobalRefsType GlobalRefs;
212 // If we could not resolve some functions at function compilation time
213 // (calls to functions before they are defined), resolve them now... Types
214 // are resolved when the constant pool has been completely parsed.
216 ResolveDefinitions(LateResolveValues);
220 // Check to make sure that all global value forward references have been
223 if (!GlobalRefs.empty()) {
224 std::string UndefinedReferences = "Unresolved global references exist:\n";
226 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
228 UndefinedReferences += " " + I->first.first->getDescription() + " " +
229 I->first.second.getName() + "\n";
231 GenerateError(UndefinedReferences);
235 // Look for intrinsic functions and CallInst that need to be upgraded
236 for (Module::iterator FI = CurrentModule->begin(),
237 FE = CurrentModule->end(); FI != FE; )
238 UpgradeCallsToIntrinsic(FI++);
240 Values.clear(); // Clear out function local definitions
245 // GetForwardRefForGlobal - Check to see if there is a forward reference
246 // for this global. If so, remove it from the GlobalRefs map and return it.
247 // If not, just return null.
248 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
249 // Check to see if there is a forward reference to this global variable...
250 // if there is, eliminate it and patch the reference to use the new def'n.
251 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
252 GlobalValue *Ret = 0;
253 if (I != GlobalRefs.end()) {
261 static struct PerFunctionInfo {
262 Function *CurrentFunction; // Pointer to current function being created
264 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
265 std::map<const Type*, ValueList> LateResolveValues;
266 bool isDeclare; // Is this function a forward declararation?
267 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
269 /// BBForwardRefs - When we see forward references to basic blocks, keep
270 /// track of them here.
271 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
272 std::vector<BasicBlock*> NumberedBlocks;
275 inline PerFunctionInfo() {
278 Linkage = GlobalValue::ExternalLinkage;
281 inline void FunctionStart(Function *M) {
286 void FunctionDone() {
287 NumberedBlocks.clear();
289 // Any forward referenced blocks left?
290 if (!BBForwardRefs.empty()) {
291 GenerateError("Undefined reference to label " +
292 BBForwardRefs.begin()->first->getName());
296 // Resolve all forward references now.
297 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
299 Values.clear(); // Clear out function local definitions
302 Linkage = GlobalValue::ExternalLinkage;
304 } CurFun; // Info for the current function...
306 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
309 //===----------------------------------------------------------------------===//
310 // Code to handle definitions of all the types
311 //===----------------------------------------------------------------------===//
313 static int InsertValue(Value *V,
314 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
315 if (V->hasName()) return -1; // Is this a numbered definition?
317 // Yes, insert the value into the value table...
318 ValueList &List = ValueTab[V->getType()];
320 return List.size()-1;
323 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
325 case ValID::NumberVal: // Is it a numbered definition?
326 // Module constants occupy the lowest numbered slots...
327 if ((unsigned)D.Num < CurModule.Types.size())
328 return CurModule.Types[(unsigned)D.Num];
330 case ValID::NameVal: // Is it a named definition?
331 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
332 D.destroy(); // Free old strdup'd memory...
337 GenerateError("Internal parser error: Invalid symbol type reference!");
341 // If we reached here, we referenced either a symbol that we don't know about
342 // or an id number that hasn't been read yet. We may be referencing something
343 // forward, so just create an entry to be resolved later and get to it...
345 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
348 if (inFunctionScope()) {
349 if (D.Type == ValID::NameVal) {
350 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
353 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
358 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
359 if (I != CurModule.LateResolveTypes.end())
362 Type *Typ = OpaqueType::get();
363 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
367 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
368 SymbolTable &SymTab =
369 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
370 CurModule.CurrentModule->getSymbolTable();
371 return SymTab.lookup(Ty, Name);
374 // getValNonImprovising - Look up the value specified by the provided type and
375 // the provided ValID. If the value exists and has already been defined, return
376 // it. Otherwise return null.
378 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
379 if (isa<FunctionType>(Ty)) {
380 GenerateError("Functions are not values and "
381 "must be referenced as pointers");
386 case ValID::NumberVal: { // Is it a numbered definition?
387 unsigned Num = (unsigned)D.Num;
389 // Module constants occupy the lowest numbered slots...
390 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
391 if (VI != CurModule.Values.end()) {
392 if (Num < VI->second.size())
393 return VI->second[Num];
394 Num -= VI->second.size();
397 // Make sure that our type is within bounds
398 VI = CurFun.Values.find(Ty);
399 if (VI == CurFun.Values.end()) return 0;
401 // Check that the number is within bounds...
402 if (VI->second.size() <= Num) return 0;
404 return VI->second[Num];
407 case ValID::NameVal: { // Is it a named definition?
408 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
409 if (N == 0) return 0;
411 D.destroy(); // Free old strdup'd memory...
415 // Check to make sure that "Ty" is an integral type, and that our
416 // value will fit into the specified type...
417 case ValID::ConstSIntVal: // Is it a constant pool reference??
418 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
419 GenerateError("Signed integral constant '" +
420 itostr(D.ConstPool64) + "' is invalid for type '" +
421 Ty->getDescription() + "'!");
424 return ConstantSInt::get(Ty, D.ConstPool64);
426 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
427 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
428 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
429 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
430 "' is invalid or out of range!");
432 } else { // This is really a signed reference. Transmogrify.
433 return ConstantSInt::get(Ty, D.ConstPool64);
436 return ConstantUInt::get(Ty, D.UConstPool64);
439 case ValID::ConstFPVal: // Is it a floating point const pool reference?
440 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
441 GenerateError("FP constant invalid for type!!");
444 return ConstantFP::get(Ty, D.ConstPoolFP);
446 case ValID::ConstNullVal: // Is it a null value?
447 if (!isa<PointerType>(Ty)) {
448 GenerateError("Cannot create a a non pointer null!");
451 return ConstantPointerNull::get(cast<PointerType>(Ty));
453 case ValID::ConstUndefVal: // Is it an undef value?
454 return UndefValue::get(Ty);
456 case ValID::ConstZeroVal: // Is it a zero value?
457 return Constant::getNullValue(Ty);
459 case ValID::ConstantVal: // Fully resolved constant?
460 if (D.ConstantValue->getType() != Ty) {
461 GenerateError("Constant expression type different from required type!");
464 return D.ConstantValue;
466 case ValID::InlineAsmVal: { // Inline asm expression
467 const PointerType *PTy = dyn_cast<PointerType>(Ty);
468 const FunctionType *FTy =
469 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
470 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
471 GenerateError("Invalid type for asm constraint string!");
474 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
475 D.IAD->HasSideEffects);
476 D.destroy(); // Free InlineAsmDescriptor.
480 assert(0 && "Unhandled case!");
484 assert(0 && "Unhandled case!");
488 // getVal - This function is identical to getValNonImprovising, except that if a
489 // value is not already defined, it "improvises" by creating a placeholder var
490 // that looks and acts just like the requested variable. When the value is
491 // defined later, all uses of the placeholder variable are replaced with the
494 static Value *getVal(const Type *Ty, const ValID &ID) {
495 if (Ty == Type::LabelTy) {
496 GenerateError("Cannot use a basic block here");
500 // See if the value has already been defined.
501 Value *V = getValNonImprovising(Ty, ID);
503 if (TriggerError) return 0;
505 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
506 GenerateError("Invalid use of a composite type!");
510 // If we reached here, we referenced either a symbol that we don't know about
511 // or an id number that hasn't been read yet. We may be referencing something
512 // forward, so just create an entry to be resolved later and get to it...
514 V = new Argument(Ty);
516 // Remember where this forward reference came from. FIXME, shouldn't we try
517 // to recycle these things??
518 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
521 if (inFunctionScope())
522 InsertValue(V, CurFun.LateResolveValues);
524 InsertValue(V, CurModule.LateResolveValues);
528 /// getBBVal - This is used for two purposes:
529 /// * If isDefinition is true, a new basic block with the specified ID is being
531 /// * If isDefinition is true, this is a reference to a basic block, which may
532 /// or may not be a forward reference.
534 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
535 assert(inFunctionScope() && "Can't get basic block at global scope!");
541 GenerateError("Illegal label reference " + ID.getName());
543 case ValID::NumberVal: // Is it a numbered definition?
544 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
545 CurFun.NumberedBlocks.resize(ID.Num+1);
546 BB = CurFun.NumberedBlocks[ID.Num];
548 case ValID::NameVal: // Is it a named definition?
550 if (Value *N = CurFun.CurrentFunction->
551 getSymbolTable().lookup(Type::LabelTy, Name))
552 BB = cast<BasicBlock>(N);
556 // See if the block has already been defined.
558 // If this is the definition of the block, make sure the existing value was
559 // just a forward reference. If it was a forward reference, there will be
560 // an entry for it in the PlaceHolderInfo map.
561 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
562 // The existing value was a definition, not a forward reference.
563 GenerateError("Redefinition of label " + ID.getName());
567 ID.destroy(); // Free strdup'd memory.
571 // Otherwise this block has not been seen before.
572 BB = new BasicBlock("", CurFun.CurrentFunction);
573 if (ID.Type == ValID::NameVal) {
574 BB->setName(ID.Name);
576 CurFun.NumberedBlocks[ID.Num] = BB;
579 // If this is not a definition, keep track of it so we can use it as a forward
582 // Remember where this forward reference came from.
583 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
585 // The forward declaration could have been inserted anywhere in the
586 // function: insert it into the correct place now.
587 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
588 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
595 //===----------------------------------------------------------------------===//
596 // Code to handle forward references in instructions
597 //===----------------------------------------------------------------------===//
599 // This code handles the late binding needed with statements that reference
600 // values not defined yet... for example, a forward branch, or the PHI node for
603 // This keeps a table (CurFun.LateResolveValues) of all such forward references
604 // and back patchs after we are done.
607 // ResolveDefinitions - If we could not resolve some defs at parsing
608 // time (forward branches, phi functions for loops, etc...) resolve the
612 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
613 std::map<const Type*,ValueList> *FutureLateResolvers) {
614 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
615 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
616 E = LateResolvers.end(); LRI != E; ++LRI) {
617 ValueList &List = LRI->second;
618 while (!List.empty()) {
619 Value *V = List.back();
622 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
623 CurModule.PlaceHolderInfo.find(V);
624 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
626 ValID &DID = PHI->second.first;
628 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
632 V->replaceAllUsesWith(TheRealValue);
634 CurModule.PlaceHolderInfo.erase(PHI);
635 } else if (FutureLateResolvers) {
636 // Functions have their unresolved items forwarded to the module late
638 InsertValue(V, *FutureLateResolvers);
640 if (DID.Type == ValID::NameVal) {
641 GenerateError("Reference to an invalid definition: '" +DID.getName()+
642 "' of type '" + V->getType()->getDescription() + "'",
646 GenerateError("Reference to an invalid definition: #" +
647 itostr(DID.Num) + " of type '" +
648 V->getType()->getDescription() + "'",
656 LateResolvers.clear();
659 // ResolveTypeTo - A brand new type was just declared. This means that (if
660 // name is not null) things referencing Name can be resolved. Otherwise, things
661 // refering to the number can be resolved. Do this now.
663 static void ResolveTypeTo(char *Name, const Type *ToTy) {
665 if (Name) D = ValID::create(Name);
666 else D = ValID::create((int)CurModule.Types.size());
668 std::map<ValID, PATypeHolder>::iterator I =
669 CurModule.LateResolveTypes.find(D);
670 if (I != CurModule.LateResolveTypes.end()) {
671 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
672 CurModule.LateResolveTypes.erase(I);
676 // setValueName - Set the specified value to the name given. The name may be
677 // null potentially, in which case this is a noop. The string passed in is
678 // assumed to be a malloc'd string buffer, and is free'd by this function.
680 static void setValueName(Value *V, char *NameStr) {
682 std::string Name(NameStr); // Copy string
683 free(NameStr); // Free old string
685 if (V->getType() == Type::VoidTy) {
686 GenerateError("Can't assign name '" + Name+"' to value with void type!");
690 assert(inFunctionScope() && "Must be in function scope!");
691 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
692 if (ST.lookup(V->getType(), Name)) {
693 GenerateError("Redefinition of value named '" + Name + "' in the '" +
694 V->getType()->getDescription() + "' type plane!");
703 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
704 /// this is a declaration, otherwise it is a definition.
705 static GlobalVariable *
706 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
707 bool isConstantGlobal, const Type *Ty,
708 Constant *Initializer) {
709 if (isa<FunctionType>(Ty)) {
710 GenerateError("Cannot declare global vars of function type!");
714 const PointerType *PTy = PointerType::get(Ty);
718 Name = NameStr; // Copy string
719 free(NameStr); // Free old string
722 // See if this global value was forward referenced. If so, recycle the
726 ID = ValID::create((char*)Name.c_str());
728 ID = ValID::create((int)CurModule.Values[PTy].size());
731 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
732 // Move the global to the end of the list, from whereever it was
733 // previously inserted.
734 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
735 CurModule.CurrentModule->getGlobalList().remove(GV);
736 CurModule.CurrentModule->getGlobalList().push_back(GV);
737 GV->setInitializer(Initializer);
738 GV->setLinkage(Linkage);
739 GV->setConstant(isConstantGlobal);
740 InsertValue(GV, CurModule.Values);
744 // If this global has a name, check to see if there is already a definition
745 // of this global in the module. If so, merge as appropriate. Note that
746 // this is really just a hack around problems in the CFE. :(
748 // We are a simple redefinition of a value, check to see if it is defined
749 // the same as the old one.
750 if (GlobalVariable *EGV =
751 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
752 // We are allowed to redefine a global variable in two circumstances:
753 // 1. If at least one of the globals is uninitialized or
754 // 2. If both initializers have the same value.
756 if (!EGV->hasInitializer() || !Initializer ||
757 EGV->getInitializer() == Initializer) {
759 // Make sure the existing global version gets the initializer! Make
760 // sure that it also gets marked const if the new version is.
761 if (Initializer && !EGV->hasInitializer())
762 EGV->setInitializer(Initializer);
763 if (isConstantGlobal)
764 EGV->setConstant(true);
765 EGV->setLinkage(Linkage);
769 GenerateError("Redefinition of global variable named '" + Name +
770 "' in the '" + Ty->getDescription() + "' type plane!");
775 // Otherwise there is no existing GV to use, create one now.
777 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
778 CurModule.CurrentModule);
779 InsertValue(GV, CurModule.Values);
783 // setTypeName - Set the specified type to the name given. The name may be
784 // null potentially, in which case this is a noop. The string passed in is
785 // assumed to be a malloc'd string buffer, and is freed by this function.
787 // This function returns true if the type has already been defined, but is
788 // allowed to be redefined in the specified context. If the name is a new name
789 // for the type plane, it is inserted and false is returned.
790 static bool setTypeName(const Type *T, char *NameStr) {
791 assert(!inFunctionScope() && "Can't give types function-local names!");
792 if (NameStr == 0) return false;
794 std::string Name(NameStr); // Copy string
795 free(NameStr); // Free old string
797 // We don't allow assigning names to void type
798 if (T == Type::VoidTy) {
799 GenerateError("Can't assign name '" + Name + "' to the void type!");
803 // Set the type name, checking for conflicts as we do so.
804 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
806 if (AlreadyExists) { // Inserting a name that is already defined???
807 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
808 assert(Existing && "Conflict but no matching type?");
810 // There is only one case where this is allowed: when we are refining an
811 // opaque type. In this case, Existing will be an opaque type.
812 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
813 // We ARE replacing an opaque type!
814 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
818 // Otherwise, this is an attempt to redefine a type. That's okay if
819 // the redefinition is identical to the original. This will be so if
820 // Existing and T point to the same Type object. In this one case we
821 // allow the equivalent redefinition.
822 if (Existing == T) return true; // Yes, it's equal.
824 // Any other kind of (non-equivalent) redefinition is an error.
825 GenerateError("Redefinition of type named '" + Name + "' in the '" +
826 T->getDescription() + "' type plane!");
832 //===----------------------------------------------------------------------===//
833 // Code for handling upreferences in type names...
836 // TypeContains - Returns true if Ty directly contains E in it.
838 static bool TypeContains(const Type *Ty, const Type *E) {
839 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
840 E) != Ty->subtype_end();
845 // NestingLevel - The number of nesting levels that need to be popped before
846 // this type is resolved.
847 unsigned NestingLevel;
849 // LastContainedTy - This is the type at the current binding level for the
850 // type. Every time we reduce the nesting level, this gets updated.
851 const Type *LastContainedTy;
853 // UpRefTy - This is the actual opaque type that the upreference is
857 UpRefRecord(unsigned NL, OpaqueType *URTy)
858 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
862 // UpRefs - A list of the outstanding upreferences that need to be resolved.
863 static std::vector<UpRefRecord> UpRefs;
865 /// HandleUpRefs - Every time we finish a new layer of types, this function is
866 /// called. It loops through the UpRefs vector, which is a list of the
867 /// currently active types. For each type, if the up reference is contained in
868 /// the newly completed type, we decrement the level count. When the level
869 /// count reaches zero, the upreferenced type is the type that is passed in:
870 /// thus we can complete the cycle.
872 static PATypeHolder HandleUpRefs(const Type *ty) {
873 // If Ty isn't abstract, or if there are no up-references in it, then there is
874 // nothing to resolve here.
875 if (!ty->isAbstract() || UpRefs.empty()) return ty;
878 UR_OUT("Type '" << Ty->getDescription() <<
879 "' newly formed. Resolving upreferences.\n" <<
880 UpRefs.size() << " upreferences active!\n");
882 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
883 // to zero), we resolve them all together before we resolve them to Ty. At
884 // the end of the loop, if there is anything to resolve to Ty, it will be in
886 OpaqueType *TypeToResolve = 0;
888 for (unsigned i = 0; i != UpRefs.size(); ++i) {
889 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
890 << UpRefs[i].second->getDescription() << ") = "
891 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
892 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
893 // Decrement level of upreference
894 unsigned Level = --UpRefs[i].NestingLevel;
895 UpRefs[i].LastContainedTy = Ty;
896 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
897 if (Level == 0) { // Upreference should be resolved!
898 if (!TypeToResolve) {
899 TypeToResolve = UpRefs[i].UpRefTy;
901 UR_OUT(" * Resolving upreference for "
902 << UpRefs[i].second->getDescription() << "\n";
903 std::string OldName = UpRefs[i].UpRefTy->getDescription());
904 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
905 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
906 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
908 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
909 --i; // Do not skip the next element...
915 UR_OUT(" * Resolving upreference for "
916 << UpRefs[i].second->getDescription() << "\n";
917 std::string OldName = TypeToResolve->getDescription());
918 TypeToResolve->refineAbstractTypeTo(Ty);
925 // common code from the two 'RunVMAsmParser' functions
926 static Module* RunParser(Module * M) {
928 llvmAsmlineno = 1; // Reset the current line number...
929 ObsoleteVarArgs = false;
931 CurModule.CurrentModule = M;
933 // Check to make sure the parser succeeded
940 // Check to make sure that parsing produced a result
944 // Reset ParserResult variable while saving its value for the result.
945 Module *Result = ParserResult;
948 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
951 if ((F = Result->getNamedFunction("llvm.va_start"))
952 && F->getFunctionType()->getNumParams() == 0)
953 ObsoleteVarArgs = true;
954 if((F = Result->getNamedFunction("llvm.va_copy"))
955 && F->getFunctionType()->getNumParams() == 1)
956 ObsoleteVarArgs = true;
959 if (ObsoleteVarArgs && NewVarArgs) {
961 "This file is corrupt: it uses both new and old style varargs");
965 if(ObsoleteVarArgs) {
966 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
967 if (F->arg_size() != 0) {
968 GenerateError("Obsolete va_start takes 0 argument!");
974 //bar = alloca typeof(foo)
978 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
979 const Type* ArgTy = F->getFunctionType()->getReturnType();
980 const Type* ArgTyPtr = PointerType::get(ArgTy);
981 Function* NF = Result->getOrInsertFunction("llvm.va_start",
982 RetTy, ArgTyPtr, (Type *)0);
984 while (!F->use_empty()) {
985 CallInst* CI = cast<CallInst>(F->use_back());
986 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
987 new CallInst(NF, bar, "", CI);
988 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
989 CI->replaceAllUsesWith(foo);
990 CI->getParent()->getInstList().erase(CI);
992 Result->getFunctionList().erase(F);
995 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
996 if(F->arg_size() != 1) {
997 GenerateError("Obsolete va_end takes 1 argument!");
1003 //bar = alloca 1 of typeof(foo)
1005 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1006 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1007 const Type* ArgTyPtr = PointerType::get(ArgTy);
1008 Function* NF = Result->getOrInsertFunction("llvm.va_end",
1009 RetTy, ArgTyPtr, (Type *)0);
1011 while (!F->use_empty()) {
1012 CallInst* CI = cast<CallInst>(F->use_back());
1013 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1014 new StoreInst(CI->getOperand(1), bar, CI);
1015 new CallInst(NF, bar, "", CI);
1016 CI->getParent()->getInstList().erase(CI);
1018 Result->getFunctionList().erase(F);
1021 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1022 if(F->arg_size() != 1) {
1023 GenerateError("Obsolete va_copy takes 1 argument!");
1028 //a = alloca 1 of typeof(foo)
1029 //b = alloca 1 of typeof(foo)
1034 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1035 const Type* ArgTy = F->getFunctionType()->getReturnType();
1036 const Type* ArgTyPtr = PointerType::get(ArgTy);
1037 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
1038 RetTy, ArgTyPtr, ArgTyPtr,
1041 while (!F->use_empty()) {
1042 CallInst* CI = cast<CallInst>(F->use_back());
1043 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1044 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1045 new StoreInst(CI->getOperand(1), b, CI);
1046 new CallInst(NF, a, b, "", CI);
1047 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1048 CI->replaceAllUsesWith(foo);
1049 CI->getParent()->getInstList().erase(CI);
1051 Result->getFunctionList().erase(F);
1058 //===----------------------------------------------------------------------===//
1059 // RunVMAsmParser - Define an interface to this parser
1060 //===----------------------------------------------------------------------===//
1062 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1065 CurFilename = Filename;
1066 return RunParser(new Module(CurFilename));
1069 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1070 set_scan_string(AsmString);
1072 CurFilename = "from_memory";
1074 return RunParser(new Module (CurFilename));
1076 return RunParser(M);
1081 #line 974 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
1083 llvm::Module *ModuleVal;
1084 llvm::Function *FunctionVal;
1085 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1086 llvm::BasicBlock *BasicBlockVal;
1087 llvm::TerminatorInst *TermInstVal;
1088 llvm::Instruction *InstVal;
1089 llvm::Constant *ConstVal;
1091 const llvm::Type *PrimType;
1092 llvm::PATypeHolder *TypeVal;
1093 llvm::Value *ValueVal;
1095 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1096 std::vector<llvm::Value*> *ValueList;
1097 std::list<llvm::PATypeHolder> *TypeList;
1098 // Represent the RHS of PHI node
1099 std::list<std::pair<llvm::Value*,
1100 llvm::BasicBlock*> > *PHIList;
1101 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1102 std::vector<llvm::Constant*> *ConstVector;
1104 llvm::GlobalValue::LinkageTypes Linkage;
1112 char *StrVal; // This memory is strdup'd!
1113 llvm::ValID ValIDVal; // strdup'd memory maybe!
1115 llvm::Instruction::BinaryOps BinaryOpVal;
1116 llvm::Instruction::TermOps TermOpVal;
1117 llvm::Instruction::MemoryOps MemOpVal;
1118 llvm::Instruction::OtherOps OtherOpVal;
1119 llvm::Module::Endianness Endianness;
1132 #define YYFLAG -32768
1133 #define YYNTBASE 123
1135 #define YYTRANSLATE(x) ((unsigned)(x) <= 362 ? yytranslate[x] : 197)
1137 static const char yytranslate[] = { 0,
1138 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1139 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1141 2, 2, 2, 2, 2, 2, 2, 2, 2, 112,
1142 113, 121, 2, 110, 2, 2, 2, 2, 2, 2,
1143 2, 2, 2, 2, 2, 2, 2, 2, 2, 117,
1144 109, 118, 2, 2, 2, 2, 2, 2, 2, 2,
1145 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1146 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1147 114, 111, 116, 2, 2, 2, 2, 2, 122, 2,
1148 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1149 2, 2, 2, 2, 2, 2, 2, 2, 2, 115,
1150 2, 2, 119, 2, 120, 2, 2, 2, 2, 2,
1151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1153 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1154 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1155 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1156 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1157 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1158 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1159 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1161 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1162 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1163 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1164 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1165 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1166 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1167 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1168 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1169 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1170 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1171 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1172 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1173 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1178 static const short yyprhs[] = { 0,
1179 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1180 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1181 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1182 60, 62, 64, 67, 68, 70, 72, 74, 76, 78,
1183 80, 82, 83, 84, 86, 88, 90, 92, 94, 96,
1184 99, 100, 103, 104, 108, 111, 112, 114, 115, 119,
1185 121, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1186 142, 144, 146, 148, 150, 152, 154, 156, 158, 160,
1187 162, 164, 166, 169, 174, 180, 186, 190, 193, 196,
1188 198, 202, 204, 208, 210, 211, 216, 220, 224, 229,
1189 234, 238, 241, 244, 247, 250, 253, 256, 259, 262,
1190 265, 268, 275, 281, 290, 297, 304, 311, 318, 325,
1191 334, 343, 347, 349, 351, 353, 355, 358, 361, 366,
1192 369, 371, 376, 379, 384, 385, 393, 394, 402, 403,
1193 411, 412, 420, 424, 429, 430, 432, 434, 436, 440,
1194 444, 448, 452, 456, 460, 462, 463, 465, 467, 469,
1195 470, 473, 477, 479, 481, 485, 487, 488, 497, 499,
1196 501, 505, 507, 509, 512, 513, 515, 517, 518, 523,
1197 524, 526, 528, 530, 532, 534, 536, 538, 540, 542,
1198 546, 548, 554, 556, 558, 560, 562, 565, 568, 571,
1199 575, 578, 579, 581, 584, 587, 591, 601, 611, 620,
1200 634, 636, 638, 645, 651, 654, 661, 669, 671, 675,
1201 677, 678, 681, 683, 689, 695, 701, 704, 709, 714,
1202 721, 726, 731, 736, 741, 748, 755, 758, 766, 768,
1203 771, 772, 774, 775, 779, 786, 790, 797, 800, 805,
1207 static const short yyrhs[] = { 5,
1208 0, 6, 0, 3, 0, 4, 0, 78, 0, 79,
1209 0, 80, 0, 81, 0, 82, 0, 83, 0, 84,
1210 0, 85, 0, 86, 0, 87, 0, 88, 0, 89,
1211 0, 90, 0, 91, 0, 101, 0, 102, 0, 16,
1212 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1213 0, 13, 0, 11, 0, 129, 0, 130, 0, 18,
1214 0, 19, 0, 165, 109, 0, 0, 41, 0, 42,
1215 0, 43, 0, 44, 0, 45, 0, 46, 0, 47,
1216 0, 0, 0, 65, 0, 66, 0, 67, 0, 68,
1217 0, 69, 0, 70, 0, 64, 4, 0, 0, 57,
1218 4, 0, 0, 110, 57, 4, 0, 34, 24, 0,
1219 0, 138, 0, 0, 110, 141, 140, 0, 138, 0,
1220 57, 4, 0, 144, 0, 8, 0, 146, 0, 8,
1221 0, 146, 0, 9, 0, 10, 0, 11, 0, 12,
1222 0, 13, 0, 14, 0, 15, 0, 16, 0, 17,
1223 0, 18, 0, 19, 0, 20, 0, 21, 0, 48,
1224 0, 145, 0, 180, 0, 111, 4, 0, 143, 112,
1225 148, 113, 0, 114, 4, 115, 146, 116, 0, 117,
1226 4, 115, 146, 118, 0, 119, 147, 120, 0, 119,
1227 120, 0, 146, 121, 0, 146, 0, 147, 110, 146,
1228 0, 147, 0, 147, 110, 37, 0, 37, 0, 0,
1229 144, 114, 151, 116, 0, 144, 114, 116, 0, 144,
1230 122, 24, 0, 144, 117, 151, 118, 0, 144, 119,
1231 151, 120, 0, 144, 119, 120, 0, 144, 38, 0,
1232 144, 39, 0, 144, 180, 0, 144, 150, 0, 144,
1233 26, 0, 129, 124, 0, 130, 4, 0, 9, 27,
1234 0, 9, 28, 0, 132, 7, 0, 99, 112, 149,
1235 36, 144, 113, 0, 97, 112, 149, 194, 113, 0,
1236 100, 112, 149, 110, 149, 110, 149, 113, 0, 125,
1237 112, 149, 110, 149, 113, 0, 126, 112, 149, 110,
1238 149, 113, 0, 127, 112, 149, 110, 149, 113, 0,
1239 128, 112, 149, 110, 149, 113, 0, 104, 112, 149,
1240 110, 149, 113, 0, 105, 112, 149, 110, 149, 110,
1241 149, 113, 0, 106, 112, 149, 110, 149, 110, 149,
1242 113, 0, 151, 110, 149, 0, 149, 0, 32, 0,
1243 33, 0, 154, 0, 154, 174, 0, 154, 176, 0,
1244 154, 62, 61, 160, 0, 154, 25, 0, 155, 0,
1245 155, 133, 20, 142, 0, 155, 176, 0, 155, 62,
1246 61, 160, 0, 0, 155, 133, 134, 152, 149, 156,
1247 140, 0, 0, 155, 133, 50, 152, 144, 157, 140,
1248 0, 0, 155, 133, 45, 152, 144, 158, 140, 0,
1249 0, 155, 133, 47, 152, 144, 159, 140, 0, 155,
1250 51, 162, 0, 155, 58, 109, 163, 0, 0, 24,
1251 0, 56, 0, 55, 0, 53, 109, 161, 0, 54,
1252 109, 4, 0, 52, 109, 24, 0, 71, 109, 24,
1253 0, 114, 164, 116, 0, 164, 110, 24, 0, 24,
1254 0, 0, 22, 0, 24, 0, 165, 0, 0, 144,
1255 166, 0, 168, 110, 167, 0, 167, 0, 168, 0,
1256 168, 110, 37, 0, 37, 0, 0, 135, 142, 165,
1257 112, 169, 113, 139, 136, 0, 29, 0, 119, 0,
1258 134, 170, 171, 0, 30, 0, 120, 0, 183, 173,
1259 0, 0, 45, 0, 47, 0, 0, 31, 177, 175,
1260 170, 0, 0, 63, 0, 3, 0, 4, 0, 7,
1261 0, 27, 0, 28, 0, 38, 0, 39, 0, 26,
1262 0, 117, 151, 118, 0, 150, 0, 61, 178, 24,
1263 110, 24, 0, 123, 0, 165, 0, 180, 0, 179,
1264 0, 144, 181, 0, 183, 184, 0, 172, 184, 0,
1265 185, 133, 186, 0, 185, 188, 0, 0, 23, 0,
1266 72, 182, 0, 72, 8, 0, 73, 21, 181, 0,
1267 73, 9, 181, 110, 21, 181, 110, 21, 181, 0,
1268 74, 131, 181, 110, 21, 181, 114, 187, 116, 0,
1269 74, 131, 181, 110, 21, 181, 114, 116, 0, 75,
1270 135, 142, 181, 112, 191, 113, 36, 21, 181, 76,
1271 21, 181, 0, 76, 0, 77, 0, 187, 131, 179,
1272 110, 21, 181, 0, 131, 179, 110, 21, 181, 0,
1273 133, 193, 0, 144, 114, 181, 110, 181, 116, 0,
1274 189, 110, 114, 181, 110, 181, 116, 0, 182, 0,
1275 190, 110, 182, 0, 190, 0, 0, 60, 59, 0,
1276 59, 0, 125, 144, 181, 110, 181, 0, 126, 144,
1277 181, 110, 181, 0, 127, 144, 181, 110, 181, 0,
1278 49, 182, 0, 128, 182, 110, 182, 0, 99, 182,
1279 36, 144, 0, 100, 182, 110, 182, 110, 182, 0,
1280 103, 182, 110, 144, 0, 107, 182, 110, 144, 0,
1281 108, 182, 110, 144, 0, 104, 182, 110, 182, 0,
1282 105, 182, 110, 182, 110, 182, 0, 106, 182, 110,
1283 182, 110, 182, 0, 98, 189, 0, 192, 135, 142,
1284 181, 112, 191, 113, 0, 196, 0, 110, 190, 0,
1285 0, 35, 0, 0, 92, 144, 137, 0, 92, 144,
1286 110, 15, 181, 137, 0, 93, 144, 137, 0, 93,
1287 144, 110, 15, 181, 137, 0, 94, 182, 0, 195,
1288 95, 144, 181, 0, 195, 96, 182, 110, 144, 181,
1289 0, 97, 144, 181, 194, 0
1295 static const short yyrline[] = { 0,
1296 1097, 1098, 1106, 1107, 1117, 1117, 1117, 1117, 1117, 1118,
1297 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1119, 1121, 1121,
1298 1125, 1125, 1125, 1125, 1126, 1126, 1126, 1126, 1127, 1127,
1299 1128, 1128, 1131, 1135, 1140, 1140, 1141, 1142, 1143, 1144,
1300 1145, 1146, 1149, 1149, 1150, 1151, 1152, 1153, 1154, 1155,
1301 1165, 1165, 1172, 1172, 1181, 1189, 1189, 1195, 1195, 1197,
1302 1202, 1216, 1216, 1217, 1217, 1219, 1229, 1229, 1229, 1229,
1303 1229, 1229, 1229, 1230, 1230, 1230, 1230, 1230, 1230, 1231,
1304 1235, 1239, 1247, 1255, 1268, 1273, 1285, 1295, 1299, 1310,
1305 1315, 1321, 1322, 1326, 1330, 1341, 1367, 1381, 1411, 1437,
1306 1458, 1471, 1481, 1486, 1547, 1554, 1563, 1569, 1575, 1579,
1307 1583, 1591, 1602, 1634, 1642, 1664, 1675, 1681, 1689, 1695,
1308 1701, 1710, 1714, 1722, 1722, 1732, 1740, 1745, 1749, 1753,
1309 1757, 1772, 1794, 1797, 1800, 1805, 1808, 1812, 1816, 1820,
1310 1824, 1829, 1833, 1836, 1839, 1843, 1856, 1857, 1859, 1863,
1311 1872, 1877, 1883, 1885, 1890, 1895, 1904, 1904, 1905, 1905,
1312 1907, 1914, 1920, 1927, 1931, 1937, 1942, 1947, 2042, 2042,
1313 2044, 2052, 2052, 2054, 2059, 2059, 2060, 2063, 2063, 2073,
1314 2077, 2082, 2086, 2090, 2094, 2098, 2102, 2106, 2110, 2114,
1315 2139, 2143, 2157, 2161, 2167, 2167, 2173, 2178, 2182, 2191,
1316 2202, 2207, 2219, 2232, 2236, 2240, 2245, 2254, 2273, 2282,
1317 2338, 2342, 2349, 2360, 2373, 2382, 2391, 2401, 2405, 2412,
1318 2412, 2414, 2418, 2423, 2439, 2454, 2468, 2481, 2489, 2497,
1319 2505, 2511, 2531, 2554, 2560, 2566, 2572, 2587, 2646, 2653,
1320 2656, 2661, 2665, 2672, 2677, 2683, 2688, 2694, 2702, 2714,
1326 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1328 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1329 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1330 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1331 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1332 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1333 "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1334 "DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE",
1335 "ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK",
1336 "MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK",
1337 "X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATA","RET","BR","SWITCH","INVOKE",
1338 "UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE",
1339 "SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
1340 "GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT",
1341 "INSERTELEMENT","SHUFFLEVECTOR","VAARG_old","VANEXT_old","'='","','","'\\\\'",
1342 "'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL",
1343 "ArithmeticOps","LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType",
1344 "FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString",
1345 "OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV",
1346 "Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1347 "ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","@3",
1348 "@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition","LibList",
1349 "Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader",
1350 "END","Function","FnDeclareLinkage","FunctionProto","@5","OptSideEffect","ConstValueRef",
1351 "SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1352 "BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","ValueRefListE",
1353 "OptTailCall","InstVal","IndexList","OptVolatile","MemoryInst", NULL
1357 static const short yyr1[] = { 0,
1358 123, 123, 124, 124, 125, 125, 125, 125, 125, 126,
1359 126, 126, 127, 127, 127, 127, 127, 127, 128, 128,
1360 129, 129, 129, 129, 130, 130, 130, 130, 131, 131,
1361 132, 132, 133, 133, 134, 134, 134, 134, 134, 134,
1362 134, 134, 135, 135, 135, 135, 135, 135, 135, 135,
1363 136, 136, 137, 137, 138, 139, 139, 140, 140, 141,
1364 141, 142, 142, 143, 143, 144, 145, 145, 145, 145,
1365 145, 145, 145, 145, 145, 145, 145, 145, 145, 146,
1366 146, 146, 146, 146, 146, 146, 146, 146, 146, 147,
1367 147, 148, 148, 148, 148, 149, 149, 149, 149, 149,
1368 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
1369 149, 150, 150, 150, 150, 150, 150, 150, 150, 150,
1370 150, 151, 151, 152, 152, 153, 154, 154, 154, 154,
1371 154, 155, 155, 155, 156, 155, 157, 155, 158, 155,
1372 159, 155, 155, 155, 155, 160, 161, 161, 162, 162,
1373 162, 162, 163, 164, 164, 164, 165, 165, 166, 166,
1374 167, 168, 168, 169, 169, 169, 169, 170, 171, 171,
1375 172, 173, 173, 174, 175, 175, 175, 177, 176, 178,
1376 178, 179, 179, 179, 179, 179, 179, 179, 179, 179,
1377 179, 179, 180, 180, 181, 181, 182, 183, 183, 184,
1378 185, 185, 185, 186, 186, 186, 186, 186, 186, 186,
1379 186, 186, 187, 187, 188, 189, 189, 190, 190, 191,
1380 191, 192, 192, 193, 193, 193, 193, 193, 193, 193,
1381 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
1382 194, 195, 195, 196, 196, 196, 196, 196, 196, 196,
1386 static const short yyr2[] = { 0,
1387 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1388 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1389 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1390 1, 1, 2, 0, 1, 1, 1, 1, 1, 1,
1391 1, 0, 0, 1, 1, 1, 1, 1, 1, 2,
1392 0, 2, 0, 3, 2, 0, 1, 0, 3, 1,
1393 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1395 1, 1, 2, 4, 5, 5, 3, 2, 2, 1,
1396 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
1397 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1398 2, 6, 5, 8, 6, 6, 6, 6, 6, 8,
1399 8, 3, 1, 1, 1, 1, 2, 2, 4, 2,
1400 1, 4, 2, 4, 0, 7, 0, 7, 0, 7,
1401 0, 7, 3, 4, 0, 1, 1, 1, 3, 3,
1402 3, 3, 3, 3, 1, 0, 1, 1, 1, 0,
1403 2, 3, 1, 1, 3, 1, 0, 8, 1, 1,
1404 3, 1, 1, 2, 0, 1, 1, 0, 4, 0,
1405 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1406 1, 5, 1, 1, 1, 1, 2, 2, 2, 3,
1407 2, 0, 1, 2, 2, 3, 9, 9, 8, 13,
1408 1, 1, 6, 5, 2, 6, 7, 1, 3, 1,
1409 0, 2, 1, 5, 5, 5, 2, 4, 4, 6,
1410 4, 4, 4, 4, 6, 6, 2, 7, 1, 2,
1411 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
1415 static const short yydefact[] = { 145,
1416 42, 131, 130, 178, 35, 36, 37, 38, 39, 40,
1417 41, 0, 43, 202, 127, 128, 202, 157, 158, 0,
1418 0, 0, 42, 0, 133, 175, 0, 0, 44, 45,
1419 46, 47, 48, 49, 0, 0, 203, 199, 34, 172,
1420 173, 174, 198, 0, 0, 0, 0, 143, 0, 0,
1421 0, 0, 0, 0, 0, 33, 176, 177, 43, 146,
1422 129, 50, 1, 2, 63, 67, 68, 69, 70, 71,
1423 72, 73, 74, 75, 76, 77, 78, 79, 80, 0,
1424 0, 0, 0, 193, 0, 0, 62, 81, 66, 194,
1425 82, 169, 170, 171, 243, 201, 0, 0, 0, 0,
1426 156, 144, 134, 132, 124, 125, 0, 0, 0, 0,
1427 179, 83, 0, 0, 65, 88, 90, 0, 0, 95,
1428 89, 242, 0, 223, 0, 0, 0, 0, 43, 211,
1429 212, 5, 6, 7, 8, 9, 10, 11, 12, 13,
1430 14, 15, 16, 17, 18, 0, 0, 0, 0, 0,
1431 0, 0, 19, 20, 0, 0, 0, 0, 0, 0,
1432 0, 0, 0, 0, 200, 43, 215, 0, 239, 151,
1433 148, 147, 149, 150, 152, 155, 0, 139, 141, 137,
1434 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1435 77, 0, 0, 0, 0, 135, 0, 0, 0, 87,
1436 167, 94, 92, 0, 0, 227, 222, 205, 204, 0,
1437 0, 24, 28, 23, 27, 22, 26, 21, 25, 29,
1438 30, 0, 0, 53, 53, 248, 0, 0, 237, 0,
1439 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1440 0, 0, 0, 0, 0, 153, 58, 58, 58, 109,
1441 110, 3, 4, 107, 108, 111, 106, 102, 103, 0,
1442 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1443 0, 0, 0, 105, 104, 58, 64, 64, 91, 166,
1444 160, 163, 164, 0, 0, 84, 182, 183, 184, 189,
1445 185, 186, 187, 188, 180, 0, 191, 196, 195, 197,
1446 0, 206, 0, 0, 0, 244, 0, 246, 241, 0,
1447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1448 0, 0, 0, 0, 0, 0, 154, 0, 140, 142,
1449 138, 0, 0, 0, 0, 0, 0, 97, 123, 0,
1450 0, 101, 0, 98, 0, 0, 0, 0, 136, 85,
1451 86, 159, 161, 0, 56, 93, 181, 0, 0, 0,
1452 0, 0, 0, 0, 0, 0, 251, 0, 0, 229,
1453 0, 231, 234, 0, 0, 232, 233, 0, 0, 0,
1454 228, 0, 249, 0, 0, 0, 60, 58, 241, 0,
1455 0, 0, 0, 0, 0, 96, 99, 100, 0, 0,
1456 0, 0, 165, 162, 57, 51, 0, 190, 0, 0,
1457 221, 53, 54, 53, 218, 240, 0, 0, 0, 0,
1458 0, 224, 225, 226, 221, 0, 55, 61, 59, 0,
1459 0, 0, 0, 0, 0, 122, 0, 0, 0, 0,
1460 0, 168, 0, 0, 0, 220, 0, 0, 245, 247,
1461 0, 0, 0, 230, 235, 236, 0, 250, 113, 0,
1462 0, 0, 0, 0, 0, 0, 0, 0, 52, 192,
1463 0, 0, 0, 219, 216, 0, 238, 112, 0, 119,
1464 0, 0, 115, 116, 117, 118, 0, 209, 0, 0,
1465 0, 217, 0, 0, 0, 207, 0, 208, 0, 0,
1466 114, 120, 121, 0, 0, 0, 0, 0, 0, 214,
1467 0, 0, 213, 210, 0, 0, 0
1470 static const short yydefgoto[] = { 84,
1471 254, 270, 271, 272, 273, 192, 193, 222, 194, 23,
1472 13, 35, 442, 306, 387, 406, 329, 388, 85, 86,
1473 195, 88, 89, 118, 204, 339, 297, 340, 107, 515,
1474 1, 2, 276, 249, 247, 248, 61, 173, 48, 102,
1475 177, 90, 353, 282, 283, 284, 36, 94, 14, 42,
1476 15, 59, 16, 26, 358, 298, 91, 300, 415, 17,
1477 38, 39, 165, 490, 96, 229, 446, 447, 166, 167,
1481 static const short yypact[] = {-32768,
1482 118, 605,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1483 -32768, -46, 131, 10,-32768,-32768, -18,-32768,-32768, 29,
1484 -69, 58, 51, -19,-32768, 106, 114, 144,-32768,-32768,
1485 -32768,-32768,-32768,-32768, 1060, -20,-32768,-32768, 130,-32768,
1486 -32768,-32768,-32768, 80, 81, 83, 94,-32768, 57, 114,
1487 1060, 44, 44, 44, 44,-32768,-32768,-32768, 131,-32768,
1488 -32768,-32768,-32768,-32768, 90,-32768,-32768,-32768,-32768,-32768,
1489 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 200,
1490 201, 202, 572,-32768, 130, 99,-32768,-32768, -34,-32768,
1491 -32768,-32768,-32768,-32768, 1231,-32768, 191, 77, 212, 193,
1492 194,-32768,-32768,-32768,-32768,-32768, 1101, 1101, 1101, 1142,
1493 -32768,-32768, 104, 107,-32768,-32768, -34, -74, 109, 852,
1494 -32768,-32768, 1101,-32768, 165, 1183, 30, 93, 131,-32768,
1495 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1496 -32768,-32768,-32768,-32768,-32768, 1101, 1101, 1101, 1101, 1101,
1497 1101, 1101,-32768,-32768, 1101, 1101, 1101, 1101, 1101, 1101,
1498 1101, 1101, 1101, 1101,-32768, 131,-32768, 62,-32768,-32768,
1499 -32768,-32768,-32768,-32768,-32768,-32768, -72,-32768,-32768,-32768,
1500 142, 170, 221, 173, 222, 175, 223, 178, 224, 231,
1501 232, 183, 225, 233, 425,-32768, 1101, 1101, 1101,-32768,
1502 893,-32768, 120, 128, 638,-32768,-32768, 90,-32768, 638,
1503 638,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1504 -32768, 638, 1060, 121, 132,-32768, 638, 129, 134, 214,
1505 141, 143, 146, 147, 148, 149, 150, 638, 638, 638,
1506 151, 1060, 1101, 1101, 228,-32768, 152, 152, 152,-32768,
1507 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 153,
1508 154, 155, 156, 159, 160, 934, 1142, 592, 230, 161,
1509 164, 177, 180,-32768,-32768, 152, -37, -99, -34,-32768,
1510 130,-32768, 184, 174, 978,-32768,-32768,-32768,-32768,-32768,
1511 -32768,-32768,-32768,-32768, 227, 1142,-32768,-32768,-32768,-32768,
1512 186,-32768, 187, 638, 2,-32768, 3,-32768, 188, 638,
1513 179, 1101, 1101, 1101, 1101, 1101, 1101, 1101, 1101, 189,
1514 190, 195, 1101, 638, 638, 196,-32768, -23,-32768,-32768,
1515 -32768, 1142, 1142, 1142, 1142, 1142, 1142,-32768,-32768, -30,
1516 21,-32768, -73,-32768, 1142, 1142, 1142, 1142,-32768,-32768,
1517 -32768,-32768,-32768, 1019, 229,-32768,-32768, 240, 24, 280,
1518 286, 197, 638, 307, 638, 1101,-32768, 203, 638,-32768,
1519 205,-32768,-32768, 210, 211,-32768,-32768, 638, 638, 638,
1520 -32768, 215,-32768, 1101, 288, 318,-32768, 152, 188, 290,
1521 218, 219, 220, 226, 1142,-32768,-32768,-32768, 234, 237,
1522 241, 242,-32768,-32768,-32768, 284, 243,-32768, 638, 638,
1523 1101, 246,-32768, 246,-32768, 247, 638, 248, 1101, 1101,
1524 1101,-32768,-32768,-32768, 1101, 638,-32768,-32768,-32768, 252,
1525 1101, 1142, 1142, 1142, 1142,-32768, 1142, 1142, 1142, 1142,
1526 338,-32768, 319, 249, 236, 247, 253, 303,-32768,-32768,
1527 1101, 245, 638,-32768,-32768,-32768, 254,-32768,-32768, 256,
1528 260, 259, 263, 265, 264, 267, 270, 274,-32768,-32768,
1529 357, 14, 355,-32768,-32768, 276,-32768,-32768, 1142,-32768,
1530 1142, 1142,-32768,-32768,-32768,-32768, 638,-32768, 742, 52,
1531 372,-32768, 281, 282, 287,-32768, 289,-32768, 742, 638,
1532 -32768,-32768,-32768, 376, 291, 326, 638, 382, 383,-32768,
1533 638, 638,-32768,-32768, 405, 406,-32768
1536 static const short yypgoto[] = {-32768,
1537 -32768, 312, 313, 314, 315, -127, -126, -458,-32768, 373,
1538 388, -116,-32768, -221, 59,-32768, -241,-32768, -48,-32768,
1539 -35,-32768, -62, 293,-32768, -100, 239, -226, 91,-32768,
1540 -32768,-32768,-32768,-32768,-32768,-32768, 365,-32768,-32768,-32768,
1541 -32768, 4,-32768, 63,-32768,-32768, 359,-32768,-32768,-32768,
1542 -32768,-32768, 417,-32768,-32768, -414, -55, 64, -103,-32768,
1543 403,-32768,-32768,-32768,-32768,-32768, 55, -3,-32768,-32768,
1551 static const short yytable[] = { 87,
1552 220, 221, 104, 308, 37, 24, 330, 331, 92, 196,
1553 385, 40, 223, 489, 27, 87, 363, 365, 351, 206,
1554 117, 121, 209, 212, 213, 214, 215, 216, 217, 218,
1555 219, 499, 37, 386, 349, 199, 395, 245, 210, 49,
1556 341, 343, 24, 246, 226, 200, 398, 230, 231, 242,
1557 211, 232, 233, 234, 235, 236, 237, 117, 364, 364,
1558 241, 212, 213, 214, 215, 216, 217, 218, 219, 359,
1559 51, 178, 179, 180, 497, 105, 106, -64, 350, 395,
1560 44, 45, 46, 121, 505, 396, 121, 205, 119, 56,
1561 205, 5, 6, 7, 8, 52, 10, 53, 93, 47,
1562 54, 41, 212, 213, 214, 215, 216, 217, 218, 219,
1563 224, 225, 205, 227, 228, 205, 205, -126, 50, 205,
1564 205, 205, 205, 205, 205, 238, 239, 240, 205, 488,
1565 395, 171, 172, 395, 277, 278, 279, 60, 397, 275,
1566 326, 408, 3, 108, 109, 110, 429, 62, 4, 299,
1567 57, 18, 58, 19, 299, 299, 243, 244, 5, 6,
1568 7, 8, 9, 10, 11, 281, 299, 498, 250, 251,
1569 101, 299, -24, -24, 304, -23, -23, -22, -22, 12,
1570 -21, -21, 299, 299, 299, 252, 253, 87, 97, 98,
1571 449, 99, 450, 324, 28, 29, 30, 31, 32, 33,
1572 34, -65, 100, 112, 113, 114, 87, 325, 205, 371,
1573 120, 373, 374, 375, 170, 174, 175, 176, 197, 381,
1574 201, 198, 279, 207, -28, -27, -26, -25, 255, 285,
1575 305, 389, 390, 391, 392, 393, 394, -31, -32, 256,
1576 286, 307, 310, 311, 399, 400, 401, 402, 299, 312,
1577 313, 327, 314, 344, 299, 315, 316, 317, 318, 319,
1578 323, 328, 385, 407, 332, 333, 334, 335, 299, 299,
1579 336, 337, 345, 301, 302, 346, 370, 205, 372, 205,
1580 205, 205, 376, 377, 352, 303, 355, 205, 347, 357,
1581 309, 348, 369, 354, 436, 360, 361, 366, 378, 379,
1582 409, 320, 321, 322, 380, 384, 410, 299, 411, 299,
1583 413, 427, 417, 299, 419, 454, 455, 456, 281, 420,
1584 421, 428, 299, 299, 299, 431, 425, 432, 433, 434,
1585 205, 461, 462, 463, 464, 435, 465, 466, 467, 468,
1586 441, 469, 470, 437, 220, 221, 438, 474, 426, 472,
1587 439, 440, 443, 299, 299, 448, 451, 453, 471, 364,
1588 475, 299, 220, 221, 459, 473, 477, 362, 478, 479,
1589 299, 480, 481, 368, 482, 205, 483, 487, 493, 484,
1590 494, 495, 485, 205, 205, 205, 486, 382, 383, 205,
1591 491, 492, 500, 501, 502, 460, 507, 299, 504, 503,
1592 508, 509, 511, 512, 516, 517, 161, 162, 163, 164,
1593 55, 95, 203, 405, 103, 205, 404, 111, 25, 43,
1594 416, 457, 430, 0, 0, 0, 412, 0, 414, 63,
1595 64, 299, 418, 274, 0, 0, 0, 0, 0, 0,
1596 0, 422, 423, 424, 299, 0, 18, 0, 19, 0,
1597 257, 299, 0, 0, 0, 299, 299, 0, 0, 0,
1598 0, 0, 258, 259, 0, 0, 0, 0, 0, 0,
1599 0, 0, 444, 445, 0, 0, 0, 0, 0, 0,
1600 452, 0, 0, 0, 0, 0, 0, 0, 0, 458,
1601 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1602 0, 0, 132, 133, 134, 135, 136, 137, 138, 139,
1603 140, 141, 142, 143, 144, 145, 476, 0, 0, 0,
1604 0, 260, 0, 261, 262, 153, 154, 0, 263, 264,
1605 265, 0, 0, 0, 0, 0, 0, 0, 266, 0,
1606 0, 267, 0, 268, 0, 0, 269, 0, 0, 0,
1607 496, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1608 0, 0, 0, 506, 0, 0, 0, 0, 0, 0,
1609 510, 0, 0, 0, 513, 514, 63, 64, 0, 115,
1610 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1611 76, 77, 78, 18, 0, 19, 63, 64, 0, 115,
1612 181, 182, 183, 184, 185, 186, 187, 188, 189, 190,
1613 191, 77, 78, 18, 0, 19, 0, 0, 0, 79,
1614 0, 0, 0, 0, -34, 0, 18, 0, 19, 0,
1615 0, 0, 0, 0, 0, 4, -34, -34, 0, 79,
1616 287, 288, 63, 64, 289, -34, -34, -34, -34, -34,
1617 -34, -34, 0, 0, -34, 20, 0, 0, 0, 18,
1618 0, 19, 21, 290, 291, 292, 22, 0, 0, 0,
1619 0, 0, 0, 0, 0, 293, 294, 0, 0, 0,
1620 0, 0, 80, 0, 0, 81, 0, 0, 82, 0,
1621 83, 116, 0, 0, 0, 0, 0, 0, 295, 0,
1622 0, 0, 80, 0, 0, 81, 0, 0, 82, 0,
1623 83, 342, 0, 0, 0, 132, 133, 134, 135, 136,
1624 137, 138, 139, 140, 141, 142, 143, 144, 145, 0,
1625 0, 0, 0, 0, 260, 0, 261, 262, 153, 154,
1626 0, 263, 264, 265, 287, 288, 0, 0, 289, 0,
1627 0, 0, 0, 0, 296, 0, 0, 0, 0, 0,
1628 0, 0, 0, 0, 0, 0, 0, 290, 291, 292,
1629 0, 0, 0, 0, 0, 0, 0, 0, 0, 293,
1630 294, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1631 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1632 0, 0, 295, 0, 0, 0, 0, 0, 0, 0,
1633 0, 0, 0, 0, 0, 0, 0, 0, 0, 132,
1634 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
1635 143, 144, 145, 0, 0, 0, 0, 0, 260, 0,
1636 261, 262, 153, 154, 0, 263, 264, 265, 0, 0,
1637 0, 0, 0, 0, 0, 0, 63, 64, 296, 115,
1638 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1639 76, 77, 78, 18, 0, 19, 0, 0, 0, 0,
1640 0, 0, 0, 0, 0, 0, 0, 0, 202, 0,
1641 0, 0, 0, 0, 0, 0, 0, 63, 64, 79,
1642 115, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1643 75, 76, 77, 78, 18, 0, 19, 0, 0, 0,
1644 0, 0, 0, 0, 0, 0, 0, 0, 0, 280,
1645 0, 0, 0, 0, 0, 0, 0, 0, 63, 64,
1646 79, 115, 181, 182, 183, 184, 185, 186, 187, 188,
1647 189, 190, 191, 77, 78, 18, 0, 19, 0, 0,
1648 0, 0, 80, 0, 0, 81, 0, 0, 82, 0,
1649 83, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1650 0, 79, 63, 64, 0, 115, 66, 67, 68, 69,
1651 70, 71, 72, 73, 74, 75, 76, 77, 78, 18,
1652 0, 19, 0, 80, 0, 0, 81, 0, 0, 82,
1653 0, 83, 0, 0, 356, 0, 0, 0, 0, 0,
1654 0, 0, 0, 63, 64, 79, 115, 66, 67, 68,
1655 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1656 18, 0, 19, 0, 80, 0, 0, 81, 0, 338,
1657 82, 0, 83, 0, 0, 403, 0, 0, 0, 0,
1658 0, 0, 0, 0, 63, 64, 79, 65, 66, 67,
1659 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1660 78, 18, 0, 19, 0, 0, 0, 0, 80, 0,
1661 0, 81, 0, 0, 82, 0, 83, 0, 0, 0,
1662 0, 0, 0, 0, 0, 63, 64, 79, 115, 66,
1663 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1664 77, 78, 18, 0, 19, 0, 0, 0, 0, 80,
1665 0, 0, 81, 0, 0, 82, 0, 83, 0, 0,
1666 0, 0, 0, 0, 0, 0, 63, 64, 79, 115,
1667 181, 182, 183, 184, 185, 186, 187, 188, 189, 190,
1668 191, 77, 78, 18, 0, 19, 0, 0, 0, 0,
1669 80, 0, 0, 81, 0, 0, 82, 0, 83, 0,
1670 0, 0, 0, 0, 0, 0, 0, 63, 64, 79,
1671 208, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1672 75, 76, 77, 78, 18, 0, 19, 0, 0, 0,
1673 0, 80, 0, 0, 81, 0, 0, 82, 0, 83,
1674 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1675 79, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1676 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1677 0, 0, 80, 0, 0, 81, 0, 0, 82, 0,
1678 83, 0, 0, 0, 0, 122, 0, 0, 0, 0,
1679 0, 0, 0, 0, 0, 0, 0, 0, 0, 123,
1680 0, 0, 0, 0, 0, 0, 0, 0, 0, 124,
1681 125, 0, 0, 80, 0, 0, 81, 0, 0, 82,
1682 0, 83, 126, 127, 128, 129, 130, 131, 132, 133,
1683 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
1684 144, 145, 146, 147, 148, 0, 0, 149, 150, 151,
1685 152, 153, 154, 155, 156, 157, 158, 159, 160
1688 static const short yycheck[] = { 35,
1689 128, 128, 51, 225, 23, 2, 248, 249, 29, 110,
1690 34, 30, 129, 472, 61, 51, 15, 15, 118, 123,
1691 83, 121, 126, 10, 11, 12, 13, 14, 15, 16,
1692 17, 490, 23, 57, 276, 110, 110, 110, 9, 109,
1693 267, 268, 39, 116, 148, 120, 120, 151, 152, 166,
1694 21, 155, 156, 157, 158, 159, 160, 120, 57, 57,
1695 164, 10, 11, 12, 13, 14, 15, 16, 17, 296,
1696 20, 107, 108, 109, 489, 32, 33, 112, 116, 110,
1697 52, 53, 54, 121, 499, 116, 121, 123, 85, 109,
1698 126, 41, 42, 43, 44, 45, 46, 47, 119, 71,
1699 50, 120, 10, 11, 12, 13, 14, 15, 16, 17,
1700 146, 147, 148, 149, 150, 151, 152, 0, 61, 155,
1701 156, 157, 158, 159, 160, 161, 162, 163, 164, 116,
1702 110, 55, 56, 110, 197, 198, 199, 24, 118, 195,
1703 244, 118, 25, 53, 54, 55, 388, 4, 31, 205,
1704 45, 22, 47, 24, 210, 211, 95, 96, 41, 42,
1705 43, 44, 45, 46, 47, 201, 222, 116, 27, 28,
1706 114, 227, 3, 4, 223, 3, 4, 3, 4, 62,
1707 3, 4, 238, 239, 240, 3, 4, 223, 109, 109,
1708 412, 109, 414, 242, 64, 65, 66, 67, 68, 69,
1709 70, 112, 109, 4, 4, 4, 242, 243, 244, 313,
1710 112, 315, 316, 317, 24, 4, 24, 24, 115, 323,
1711 112, 115, 285, 59, 4, 4, 4, 4, 4, 110,
1712 110, 332, 333, 334, 335, 336, 337, 7, 7, 7,
1713 113, 110, 114, 110, 345, 346, 347, 348, 304, 36,
1714 110, 24, 110, 24, 310, 110, 110, 110, 110, 110,
1715 110, 110, 34, 24, 112, 112, 112, 112, 324, 325,
1716 112, 112, 112, 210, 211, 112, 312, 313, 314, 315,
1717 316, 317, 318, 319, 281, 222, 113, 323, 112, 63,
1718 227, 112, 114, 110, 395, 110, 110, 110, 110, 110,
1719 21, 238, 239, 240, 110, 110, 21, 363, 112, 365,
1720 4, 24, 110, 369, 110, 419, 420, 421, 354, 110,
1721 110, 4, 378, 379, 380, 36, 112, 110, 110, 110,
1722 366, 432, 433, 434, 435, 110, 437, 438, 439, 440,
1723 57, 4, 24, 110, 472, 472, 110, 451, 384, 114,
1724 110, 110, 110, 409, 410, 110, 110, 110, 110, 57,
1725 116, 417, 490, 490, 113, 113, 113, 304, 113, 110,
1726 426, 113, 110, 310, 110, 411, 113, 21, 479, 113,
1727 481, 482, 113, 419, 420, 421, 113, 324, 325, 425,
1728 36, 116, 21, 113, 113, 431, 21, 453, 110, 113,
1729 110, 76, 21, 21, 0, 0, 95, 95, 95, 95,
1730 23, 39, 120, 355, 50, 451, 354, 59, 2, 17,
1731 366, 425, 389, -1, -1, -1, 363, -1, 365, 5,
1732 6, 487, 369, 195, -1, -1, -1, -1, -1, -1,
1733 -1, 378, 379, 380, 500, -1, 22, -1, 24, -1,
1734 26, 507, -1, -1, -1, 511, 512, -1, -1, -1,
1735 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
1736 -1, -1, 409, 410, -1, -1, -1, -1, -1, -1,
1737 417, -1, -1, -1, -1, -1, -1, -1, -1, 426,
1738 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1739 -1, -1, 78, 79, 80, 81, 82, 83, 84, 85,
1740 86, 87, 88, 89, 90, 91, 453, -1, -1, -1,
1741 -1, 97, -1, 99, 100, 101, 102, -1, 104, 105,
1742 106, -1, -1, -1, -1, -1, -1, -1, 114, -1,
1743 -1, 117, -1, 119, -1, -1, 122, -1, -1, -1,
1744 487, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1745 -1, -1, -1, 500, -1, -1, -1, -1, -1, -1,
1746 507, -1, -1, -1, 511, 512, 5, 6, -1, 8,
1747 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1748 19, 20, 21, 22, -1, 24, 5, 6, -1, 8,
1749 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1750 19, 20, 21, 22, -1, 24, -1, -1, -1, 48,
1751 -1, -1, -1, -1, 20, -1, 22, -1, 24, -1,
1752 -1, -1, -1, -1, -1, 31, 32, 33, -1, 48,
1753 3, 4, 5, 6, 7, 41, 42, 43, 44, 45,
1754 46, 47, -1, -1, 50, 51, -1, -1, -1, 22,
1755 -1, 24, 58, 26, 27, 28, 62, -1, -1, -1,
1756 -1, -1, -1, -1, -1, 38, 39, -1, -1, -1,
1757 -1, -1, 111, -1, -1, 114, -1, -1, 117, -1,
1758 119, 120, -1, -1, -1, -1, -1, -1, 61, -1,
1759 -1, -1, 111, -1, -1, 114, -1, -1, 117, -1,
1760 119, 120, -1, -1, -1, 78, 79, 80, 81, 82,
1761 83, 84, 85, 86, 87, 88, 89, 90, 91, -1,
1762 -1, -1, -1, -1, 97, -1, 99, 100, 101, 102,
1763 -1, 104, 105, 106, 3, 4, -1, -1, 7, -1,
1764 -1, -1, -1, -1, 117, -1, -1, -1, -1, -1,
1765 -1, -1, -1, -1, -1, -1, -1, 26, 27, 28,
1766 -1, -1, -1, -1, -1, -1, -1, -1, -1, 38,
1767 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1768 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1769 -1, -1, 61, -1, -1, -1, -1, -1, -1, -1,
1770 -1, -1, -1, -1, -1, -1, -1, -1, -1, 78,
1771 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1772 89, 90, 91, -1, -1, -1, -1, -1, 97, -1,
1773 99, 100, 101, 102, -1, 104, 105, 106, -1, -1,
1774 -1, -1, -1, -1, -1, -1, 5, 6, 117, 8,
1775 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1776 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1777 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
1778 -1, -1, -1, -1, -1, -1, -1, 5, 6, 48,
1779 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1780 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1781 -1, -1, -1, -1, -1, -1, -1, -1, -1, 37,
1782 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1783 48, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1784 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1785 -1, -1, 111, -1, -1, 114, -1, -1, 117, -1,
1786 119, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1787 -1, 48, 5, 6, -1, 8, 9, 10, 11, 12,
1788 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1789 -1, 24, -1, 111, -1, -1, 114, -1, -1, 117,
1790 -1, 119, -1, -1, 37, -1, -1, -1, -1, -1,
1791 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
1792 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1793 22, -1, 24, -1, 111, -1, -1, 114, -1, 116,
1794 117, -1, 119, -1, -1, 37, -1, -1, -1, -1,
1795 -1, -1, -1, -1, 5, 6, 48, 8, 9, 10,
1796 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1797 21, 22, -1, 24, -1, -1, -1, -1, 111, -1,
1798 -1, 114, -1, -1, 117, -1, 119, -1, -1, -1,
1799 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
1800 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1801 20, 21, 22, -1, 24, -1, -1, -1, -1, 111,
1802 -1, -1, 114, -1, -1, 117, -1, 119, -1, -1,
1803 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
1804 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1805 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1806 111, -1, -1, 114, -1, -1, 117, -1, 119, -1,
1807 -1, -1, -1, -1, -1, -1, -1, 5, 6, 48,
1808 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1809 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1810 -1, 111, -1, -1, 114, -1, -1, 117, -1, 119,
1811 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1812 48, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1813 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1814 -1, -1, 111, -1, -1, 114, -1, -1, 117, -1,
1815 119, -1, -1, -1, -1, 35, -1, -1, -1, -1,
1816 -1, -1, -1, -1, -1, -1, -1, -1, -1, 49,
1817 -1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
1818 60, -1, -1, 111, -1, -1, 114, -1, -1, 117,
1819 -1, 119, 72, 73, 74, 75, 76, 77, 78, 79,
1820 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
1821 90, 91, 92, 93, 94, -1, -1, 97, 98, 99,
1822 100, 101, 102, 103, 104, 105, 106, 107, 108
1824 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1825 #line 3 "/usr/share/bison.simple"
1826 /* This file comes from bison-1.28. */
1828 /* Skeleton output parser for bison,
1829 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1831 This program is free software; you can redistribute it and/or modify
1832 it under the terms of the GNU General Public License as published by
1833 the Free Software Foundation; either version 2, or (at your option)
1836 This program is distributed in the hope that it will be useful,
1837 but WITHOUT ANY WARRANTY; without even the implied warranty of
1838 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1839 GNU General Public License for more details.
1841 You should have received a copy of the GNU General Public License
1842 along with this program; if not, write to the Free Software
1843 Foundation, Inc., 59 Temple Place - Suite 330,
1844 Boston, MA 02111-1307, USA. */
1846 /* As a special exception, when this file is copied by Bison into a
1847 Bison output file, you may use that output file without restriction.
1848 This special exception was added by the Free Software Foundation
1849 in version 1.24 of Bison. */
1851 /* This is the parser code that is written into each bison parser
1852 when the %semantic_parser declaration is not specified in the grammar.
1853 It was written by Richard Stallman by simplifying the hairy parser
1854 used when %semantic_parser is specified. */
1856 #ifndef YYSTACK_USE_ALLOCA
1858 #define YYSTACK_USE_ALLOCA
1859 #else /* alloca not defined */
1861 #define YYSTACK_USE_ALLOCA
1862 #define alloca __builtin_alloca
1863 #else /* not GNU C. */
1864 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1865 #define YYSTACK_USE_ALLOCA
1867 #else /* not sparc */
1868 /* We think this test detects Watcom and Microsoft C. */
1869 /* This used to test MSDOS, but that is a bad idea
1870 since that symbol is in the user namespace. */
1871 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1872 #if 0 /* No need for malloc.h, which pollutes the namespace;
1873 instead, just don't use alloca. */
1876 #else /* not MSDOS, or __TURBOC__ */
1878 /* I don't know what this was needed for, but it pollutes the namespace.
1879 So I turned it off. rms, 2 May 1997. */
1880 /* #include <malloc.h> */
1882 #define YYSTACK_USE_ALLOCA
1883 #else /* not MSDOS, or __TURBOC__, or _AIX */
1885 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1886 and on HPUX 10. Eventually we can turn this on. */
1887 #define YYSTACK_USE_ALLOCA
1888 #define alloca __builtin_alloca
1891 #endif /* not _AIX */
1892 #endif /* not MSDOS, or __TURBOC__ */
1893 #endif /* not sparc */
1894 #endif /* not GNU C */
1895 #endif /* alloca not defined */
1896 #endif /* YYSTACK_USE_ALLOCA not defined */
1898 #ifdef YYSTACK_USE_ALLOCA
1899 #define YYSTACK_ALLOC alloca
1901 #define YYSTACK_ALLOC malloc
1904 /* Note: there must be only one dollar sign in this file.
1905 It is replaced by the list of actions, each action
1906 as one case of the switch. */
1908 #define yyerrok (yyerrstatus = 0)
1909 #define yyclearin (yychar = YYEMPTY)
1912 #define YYACCEPT goto yyacceptlab
1913 #define YYABORT goto yyabortlab
1914 #define YYERROR goto yyerrlab1
1915 /* Like YYERROR except do call yyerror.
1916 This remains here temporarily to ease the
1917 transition to the new meaning of YYERROR, for GCC.
1918 Once GCC version 2 has supplanted version 1, this can go. */
1919 #define YYFAIL goto yyerrlab
1920 #define YYRECOVERING() (!!yyerrstatus)
1921 #define YYBACKUP(token, value) \
1923 if (yychar == YYEMPTY && yylen == 1) \
1924 { yychar = (token), yylval = (value); \
1925 yychar1 = YYTRANSLATE (yychar); \
1930 { yyerror ("syntax error: cannot back up"); YYERROR; } \
1934 #define YYERRCODE 256
1937 #define YYLEX yylex()
1943 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
1945 #define YYLEX yylex(&yylval, &yylloc)
1947 #else /* not YYLSP_NEEDED */
1949 #define YYLEX yylex(&yylval, YYLEX_PARAM)
1951 #define YYLEX yylex(&yylval)
1953 #endif /* not YYLSP_NEEDED */
1956 /* If nonreentrant, generate the variables here */
1960 int yychar; /* the lookahead symbol */
1961 YYSTYPE yylval; /* the semantic value of the */
1962 /* lookahead symbol */
1965 YYLTYPE yylloc; /* location data for the lookahead */
1969 int yynerrs; /* number of parse errors so far */
1970 #endif /* not YYPURE */
1973 int yydebug; /* nonzero means print parse trace */
1974 /* Since this is uninitialized, it does not stop multiple parsers
1978 /* YYINITDEPTH indicates the initial size of the parser's stacks */
1981 #define YYINITDEPTH 200
1984 /* YYMAXDEPTH is the maximum size the stacks can grow to
1985 (effective only if the built-in stack extension method is used). */
1992 #define YYMAXDEPTH 10000
1995 /* Define __yy_memcpy. Note that the size argument
1996 should be passed with type unsigned int, because that is what the non-GCC
1997 definitions require. With GCC, __builtin_memcpy takes an arg
1998 of type size_t, but it can handle unsigned int. */
2000 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2001 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2002 #else /* not GNU C or C++ */
2005 /* This is the most reliable way to avoid incompatibilities
2006 in available built-in functions on various systems. */
2008 __yy_memcpy (to, from, count)
2013 register char *f = from;
2014 register char *t = to;
2015 register int i = count;
2021 #else /* __cplusplus */
2023 /* This is the most reliable way to avoid incompatibilities
2024 in available built-in functions on various systems. */
2026 __yy_memcpy (char *to, char *from, unsigned int count)
2028 register char *t = to;
2029 register char *f = from;
2030 register int i = count;
2039 #line 217 "/usr/share/bison.simple"
2041 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2042 into yyparse. The argument should have type void *.
2043 It should actually point to an object.
2044 Grammar actions can access the variable by casting it
2045 to the proper pointer type. */
2047 #ifdef YYPARSE_PARAM
2049 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2050 #define YYPARSE_PARAM_DECL
2051 #else /* not __cplusplus */
2052 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2053 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2054 #endif /* not __cplusplus */
2055 #else /* not YYPARSE_PARAM */
2056 #define YYPARSE_PARAM_ARG
2057 #define YYPARSE_PARAM_DECL
2058 #endif /* not YYPARSE_PARAM */
2060 /* Prevent warning if -Wstrict-prototypes. */
2062 #ifdef YYPARSE_PARAM
2063 int yyparse (void *);
2070 yyparse(YYPARSE_PARAM_ARG)
2073 register int yystate;
2075 register short *yyssp;
2076 register YYSTYPE *yyvsp;
2077 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2078 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2080 short yyssa[YYINITDEPTH]; /* the state stack */
2081 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2083 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2084 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2087 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2088 YYLTYPE *yyls = yylsa;
2091 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2093 #define YYPOPSTACK (yyvsp--, yyssp--)
2096 int yystacksize = YYINITDEPTH;
2097 int yyfree_stacks = 0;
2108 YYSTYPE yyval; /* the variable used to return */
2109 /* semantic values from the action */
2116 fprintf(stderr, "Starting parse\n");
2122 yychar = YYEMPTY; /* Cause a token to be read. */
2124 /* Initialize stack pointers.
2125 Waste one element of value and location stack
2126 so that they stay on the same level as the state stack.
2127 The wasted elements are never initialized. */
2135 /* Push a new state, which is found in yystate . */
2136 /* In all cases, when you get here, the value and location stacks
2137 have just been pushed. so pushing a state here evens the stacks. */
2142 if (yyssp >= yyss + yystacksize - 1)
2144 /* Give user a chance to reallocate the stack */
2145 /* Use copies of these so that the &'s don't force the real ones into memory. */
2146 YYSTYPE *yyvs1 = yyvs;
2147 short *yyss1 = yyss;
2149 YYLTYPE *yyls1 = yyls;
2152 /* Get the current used size of the three stacks, in elements. */
2153 int size = yyssp - yyss + 1;
2156 /* Each stack pointer address is followed by the size of
2157 the data in use in that stack, in bytes. */
2159 /* This used to be a conditional around just the two extra args,
2160 but that might be undefined if yyoverflow is a macro. */
2161 yyoverflow("parser stack overflow",
2162 &yyss1, size * sizeof (*yyssp),
2163 &yyvs1, size * sizeof (*yyvsp),
2164 &yyls1, size * sizeof (*yylsp),
2167 yyoverflow("parser stack overflow",
2168 &yyss1, size * sizeof (*yyssp),
2169 &yyvs1, size * sizeof (*yyvsp),
2173 yyss = yyss1; yyvs = yyvs1;
2177 #else /* no yyoverflow */
2178 /* Extend the stack our own way. */
2179 if (yystacksize >= YYMAXDEPTH)
2181 yyerror("parser stack overflow");
2193 if (yystacksize > YYMAXDEPTH)
2194 yystacksize = YYMAXDEPTH;
2195 #ifndef YYSTACK_USE_ALLOCA
2198 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2199 __yy_memcpy ((char *)yyss, (char *)yyss1,
2200 size * (unsigned int) sizeof (*yyssp));
2201 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2202 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2203 size * (unsigned int) sizeof (*yyvsp));
2205 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2206 __yy_memcpy ((char *)yyls, (char *)yyls1,
2207 size * (unsigned int) sizeof (*yylsp));
2209 #endif /* no yyoverflow */
2211 yyssp = yyss + size - 1;
2212 yyvsp = yyvs + size - 1;
2214 yylsp = yyls + size - 1;
2219 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2222 if (yyssp >= yyss + yystacksize - 1)
2228 fprintf(stderr, "Entering state %d\n", yystate);
2234 /* Do appropriate processing given the current state. */
2235 /* Read a lookahead token if we need one and don't already have one. */
2238 /* First try to decide what to do without reference to lookahead token. */
2240 yyn = yypact[yystate];
2244 /* Not known => get a lookahead token if don't already have one. */
2246 /* yychar is either YYEMPTY or YYEOF
2247 or a valid token in external form. */
2249 if (yychar == YYEMPTY)
2253 fprintf(stderr, "Reading a token: ");
2258 /* Convert token to internal form (in yychar1) for indexing tables with */
2260 if (yychar <= 0) /* This means end of input. */
2263 yychar = YYEOF; /* Don't call YYLEX any more */
2267 fprintf(stderr, "Now at end of input.\n");
2272 yychar1 = YYTRANSLATE(yychar);
2277 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2278 /* Give the individual parser a way to print the precise meaning
2279 of a token, for further debugging info. */
2281 YYPRINT (stderr, yychar, yylval);
2283 fprintf (stderr, ")\n");
2289 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2294 /* yyn is what to do for this token type in this state.
2295 Negative => reduce, -yyn is rule number.
2296 Positive => shift, yyn is new state.
2297 New state is final state => don't bother to shift,
2298 just return success.
2299 0, or most negative number => error. */
2314 /* Shift the lookahead token. */
2318 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2321 /* Discard the token being shifted unless it is eof. */
2322 if (yychar != YYEOF)
2330 /* count tokens shifted since error; after three, turn off error status. */
2331 if (yyerrstatus) yyerrstatus--;
2336 /* Do the default action for the current state. */
2339 yyn = yydefact[yystate];
2343 /* Do a reduction. yyn is the number of a rule to reduce with. */
2347 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2354 fprintf (stderr, "Reducing via rule %d (line %d), ",
2357 /* Print the symbols being reduced, and their result. */
2358 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2359 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2360 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2368 #line 1098 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2370 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2371 GEN_ERROR("Value too large for type!");
2372 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2377 #line 1107 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2379 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2380 GEN_ERROR("Value too large for type!");
2381 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2386 #line 1131 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2388 yyval.StrVal = yyvsp[-1].StrVal;
2393 #line 1135 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2400 #line 1140 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2401 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2404 #line 1141 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2405 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2408 #line 1142 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2409 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2412 #line 1143 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2413 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2416 #line 1144 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2417 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2420 #line 1145 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2421 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2424 #line 1146 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2425 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2428 #line 1147 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2429 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2432 #line 1149 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2433 { yyval.UIntVal = CallingConv::C; ;
2436 #line 1150 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2437 { yyval.UIntVal = CallingConv::C; ;
2440 #line 1151 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2441 { yyval.UIntVal = CallingConv::CSRet; ;
2444 #line 1152 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2445 { yyval.UIntVal = CallingConv::Fast; ;
2448 #line 1153 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2449 { yyval.UIntVal = CallingConv::Cold; ;
2452 #line 1154 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2453 { yyval.UIntVal = CallingConv::X86_StdCall; ;
2456 #line 1155 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2457 { yyval.UIntVal = CallingConv::X86_FastCall; ;
2460 #line 1156 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2462 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2463 GEN_ERROR("Calling conv too large!");
2464 yyval.UIntVal = yyvsp[0].UInt64Val;
2469 #line 1165 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2470 { yyval.UIntVal = 0; ;
2473 #line 1166 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2475 yyval.UIntVal = yyvsp[0].UInt64Val;
2476 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2477 GEN_ERROR("Alignment must be a power of two!");
2482 #line 1172 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2483 { yyval.UIntVal = 0; ;
2486 #line 1173 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2488 yyval.UIntVal = yyvsp[0].UInt64Val;
2489 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2490 GEN_ERROR("Alignment must be a power of two!");
2495 #line 1181 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2497 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2498 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2499 GEN_ERROR("Invalid character in section name!");
2500 yyval.StrVal = yyvsp[0].StrVal;
2505 #line 1189 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2506 { yyval.StrVal = 0; ;
2509 #line 1190 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2510 { yyval.StrVal = yyvsp[0].StrVal; ;
2513 #line 1195 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2517 #line 1196 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2521 #line 1197 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2523 CurGV->setSection(yyvsp[0].StrVal);
2524 free(yyvsp[0].StrVal);
2529 #line 1202 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2531 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2532 GEN_ERROR("Alignment must be a power of two!");
2533 CurGV->setAlignment(yyvsp[0].UInt64Val);
2538 #line 1216 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2539 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2542 #line 1217 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2543 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2546 #line 1219 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2548 if (!UpRefs.empty())
2549 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2550 yyval.TypeVal = yyvsp[0].TypeVal;
2555 #line 1231 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2557 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2562 #line 1235 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2564 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2569 #line 1239 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2570 { // Named types are also simple types...
2571 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
2573 yyval.TypeVal = new PATypeHolder(tmp);
2577 #line 1247 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2578 { // Type UpReference
2579 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
2580 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2581 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2582 yyval.TypeVal = new PATypeHolder(OT);
2583 UR_OUT("New Upreference!\n");
2588 #line 1255 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2589 { // Function derived type?
2590 std::vector<const Type*> Params;
2591 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2592 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2593 Params.push_back(*I);
2594 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2595 if (isVarArg) Params.pop_back();
2597 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2598 delete yyvsp[-1].TypeList; // Delete the argument list
2599 delete yyvsp[-3].TypeVal; // Delete the return type handle
2604 #line 1268 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2605 { // Sized array type?
2606 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2607 delete yyvsp[-1].TypeVal;
2612 #line 1273 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2613 { // Packed array type?
2614 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2615 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2616 GEN_ERROR("Unsigned result not equal to signed result");
2617 if (!ElemTy->isPrimitiveType())
2618 GEN_ERROR("Elemental type of a PackedType must be primitive");
2619 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2620 GEN_ERROR("Vector length should be a power of 2!");
2621 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2622 delete yyvsp[-1].TypeVal;
2627 #line 1285 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2628 { // Structure type?
2629 std::vector<const Type*> Elements;
2630 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2631 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2632 Elements.push_back(*I);
2634 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2635 delete yyvsp[-1].TypeList;
2640 #line 1295 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2641 { // Empty structure type?
2642 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2647 #line 1299 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2649 if (*yyvsp[-1].TypeVal == Type::LabelTy)
2650 GEN_ERROR("Cannot form a pointer to a basic block");
2651 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2652 delete yyvsp[-1].TypeVal;
2657 #line 1310 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2659 yyval.TypeList = new std::list<PATypeHolder>();
2660 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2665 #line 1315 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2667 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2672 #line 1322 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2674 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2679 #line 1326 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2681 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2686 #line 1330 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2688 yyval.TypeList = new std::list<PATypeHolder>();
2693 #line 1341 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2694 { // Nonempty unsized arr
2695 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2697 GEN_ERROR("Cannot make array constant with type: '" +
2698 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2699 const Type *ETy = ATy->getElementType();
2700 int NumElements = ATy->getNumElements();
2702 // Verify that we have the correct size...
2703 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2704 GEN_ERROR("Type mismatch: constant sized array initialized with " +
2705 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2706 itostr(NumElements) + "!");
2708 // Verify all elements are correct type!
2709 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2710 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2711 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
2712 ETy->getDescription() +"' as required!\nIt is of type '"+
2713 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2716 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2717 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2722 #line 1367 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2724 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2726 GEN_ERROR("Cannot make array constant with type: '" +
2727 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2729 int NumElements = ATy->getNumElements();
2730 if (NumElements != -1 && NumElements != 0)
2731 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
2732 " arguments, but has size of " + itostr(NumElements) +"!");
2733 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2734 delete yyvsp[-2].TypeVal;
2739 #line 1381 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2741 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2743 GEN_ERROR("Cannot make array constant with type: '" +
2744 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2746 int NumElements = ATy->getNumElements();
2747 const Type *ETy = ATy->getElementType();
2748 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2749 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2750 GEN_ERROR("Can't build string constant of size " +
2751 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2752 " when array has size " + itostr(NumElements) + "!");
2753 std::vector<Constant*> Vals;
2754 if (ETy == Type::SByteTy) {
2755 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
2756 Vals.push_back(ConstantSInt::get(ETy, *C));
2757 } else if (ETy == Type::UByteTy) {
2758 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2759 C != (unsigned char*)EndStr; ++C)
2760 Vals.push_back(ConstantUInt::get(ETy, *C));
2762 free(yyvsp[0].StrVal);
2763 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
2765 free(yyvsp[0].StrVal);
2766 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2767 delete yyvsp[-2].TypeVal;
2772 #line 1411 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2773 { // Nonempty unsized arr
2774 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2776 GEN_ERROR("Cannot make packed constant with type: '" +
2777 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2778 const Type *ETy = PTy->getElementType();
2779 int NumElements = PTy->getNumElements();
2781 // Verify that we have the correct size...
2782 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2783 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
2784 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2785 itostr(NumElements) + "!");
2787 // Verify all elements are correct type!
2788 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2789 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2790 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
2791 ETy->getDescription() +"' as required!\nIt is of type '"+
2792 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2795 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2796 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2801 #line 1437 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2803 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2805 GEN_ERROR("Cannot make struct constant with type: '" +
2806 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2808 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2809 GEN_ERROR("Illegal number of initializers for structure type!");
2811 // Check to ensure that constants are compatible with the type initializer!
2812 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2813 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2814 GEN_ERROR("Expected type '" +
2815 STy->getElementType(i)->getDescription() +
2816 "' for element #" + utostr(i) +
2817 " of structure initializer!");
2819 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2820 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2825 #line 1458 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2827 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2829 GEN_ERROR("Cannot make struct constant with type: '" +
2830 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2832 if (STy->getNumContainedTypes() != 0)
2833 GEN_ERROR("Illegal number of initializers for structure type!");
2835 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2836 delete yyvsp[-2].TypeVal;
2841 #line 1471 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2843 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2845 GEN_ERROR("Cannot make null pointer constant with type: '" +
2846 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2848 yyval.ConstVal = ConstantPointerNull::get(PTy);
2849 delete yyvsp[-1].TypeVal;
2854 #line 1481 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2856 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2857 delete yyvsp[-1].TypeVal;
2862 #line 1486 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2864 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2866 GEN_ERROR("Global const reference must be a pointer type!");
2868 // ConstExprs can exist in the body of a function, thus creating
2869 // GlobalValues whenever they refer to a variable. Because we are in
2870 // the context of a function, getValNonImprovising will search the functions
2871 // symbol table instead of the module symbol table for the global symbol,
2872 // which throws things all off. To get around this, we just tell
2873 // getValNonImprovising that we are at global scope here.
2875 Function *SavedCurFn = CurFun.CurrentFunction;
2876 CurFun.CurrentFunction = 0;
2878 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2881 CurFun.CurrentFunction = SavedCurFn;
2883 // If this is an initializer for a constant pointer, which is referencing a
2884 // (currently) undefined variable, create a stub now that shall be replaced
2885 // in the future with the right type of variable.
2888 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2889 const PointerType *PT = cast<PointerType>(Ty);
2891 // First check to see if the forward references value is already created!
2892 PerModuleInfo::GlobalRefsType::iterator I =
2893 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2895 if (I != CurModule.GlobalRefs.end()) {
2896 V = I->second; // Placeholder already exists, use it...
2897 yyvsp[0].ValIDVal.destroy();
2900 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2902 // Create the forward referenced global.
2904 if (const FunctionType *FTy =
2905 dyn_cast<FunctionType>(PT->getElementType())) {
2906 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2907 CurModule.CurrentModule);
2909 GV = new GlobalVariable(PT->getElementType(), false,
2910 GlobalValue::ExternalLinkage, 0,
2911 Name, CurModule.CurrentModule);
2914 // Keep track of the fact that we have a forward ref to recycle it
2915 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2920 yyval.ConstVal = cast<GlobalValue>(V);
2921 delete yyvsp[-1].TypeVal; // Free the type handle
2926 #line 1547 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2928 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2929 GEN_ERROR("Mismatched types for constant expression!");
2930 yyval.ConstVal = yyvsp[0].ConstVal;
2931 delete yyvsp[-1].TypeVal;
2936 #line 1554 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2938 const Type *Ty = yyvsp[-1].TypeVal->get();
2939 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2940 GEN_ERROR("Cannot create a null initialized value of this type!");
2941 yyval.ConstVal = Constant::getNullValue(Ty);
2942 delete yyvsp[-1].TypeVal;
2947 #line 1563 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2948 { // integral constants
2949 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2950 GEN_ERROR("Constant value doesn't fit in type!");
2951 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
2956 #line 1569 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2957 { // integral constants
2958 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2959 GEN_ERROR("Constant value doesn't fit in type!");
2960 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
2965 #line 1575 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2966 { // Boolean constants
2967 yyval.ConstVal = ConstantBool::getTrue();
2972 #line 1579 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2973 { // Boolean constants
2974 yyval.ConstVal = ConstantBool::getFalse();
2979 #line 1583 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2980 { // Float & Double constants
2981 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2982 GEN_ERROR("Floating point constant invalid for type!!");
2983 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
2988 #line 1591 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
2990 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2991 GEN_ERROR("cast constant expression from a non-primitive type: '" +
2992 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2993 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2994 GEN_ERROR("cast constant expression to a non-primitive type: '" +
2995 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2996 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2997 delete yyvsp[-1].TypeVal;
3002 #line 1602 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3004 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
3005 GEN_ERROR("GetElementPtr requires a pointer operand!");
3007 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3008 // indices to uint struct indices for compatibility.
3009 generic_gep_type_iterator<std::vector<Value*>::iterator>
3010 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
3011 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
3012 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3013 if (isa<StructType>(*GTI)) // Only change struct indices
3014 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
3015 if (CUI->getType() == Type::UByteTy)
3016 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3019 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
3021 GEN_ERROR("Index list invalid for constant getelementptr!");
3023 std::vector<Constant*> IdxVec;
3024 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3025 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
3026 IdxVec.push_back(C);
3028 GEN_ERROR("Indices to constant getelementptr must be constants!");
3030 delete yyvsp[-1].ValueList;
3032 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
3037 #line 1634 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3039 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
3040 GEN_ERROR("Select condition must be of boolean type!");
3041 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3042 GEN_ERROR("Select operand types must match!");
3043 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3048 #line 1642 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3050 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3051 GEN_ERROR("Binary operator types must match!");
3052 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3053 // To retain backward compatibility with these early compilers, we emit a
3054 // cast to the appropriate integer type automatically if we are in the
3055 // broken case. See PR424 for more information.
3056 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
3057 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3059 const Type *IntPtrTy = 0;
3060 switch (CurModule.CurrentModule->getPointerSize()) {
3061 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3062 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
3063 default: GEN_ERROR("invalid pointer binary constant expr!");
3065 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
3066 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
3067 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
3073 #line 1664 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3075 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3076 GEN_ERROR("Logical operator types must match!");
3077 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
3078 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3079 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
3080 GEN_ERROR("Logical operator requires integral operands!");
3082 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3087 #line 1675 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3089 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3090 GEN_ERROR("setcc operand types must match!");
3091 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3096 #line 1681 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3098 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
3099 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
3100 if (!yyvsp[-3].ConstVal->getType()->isInteger())
3101 GEN_ERROR("Shift constant expression requires integer operand!");
3102 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3107 #line 1689 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3109 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3110 GEN_ERROR("Invalid extractelement operands!");
3111 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3116 #line 1695 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3118 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3119 GEN_ERROR("Invalid insertelement operands!");
3120 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3125 #line 1701 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3127 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3128 GEN_ERROR("Invalid shufflevector operands!");
3129 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3134 #line 1710 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3136 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
3141 #line 1714 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3143 yyval.ConstVector = new std::vector<Constant*>();
3144 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
3149 #line 1722 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3150 { yyval.BoolVal = false; ;
3153 #line 1722 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3154 { yyval.BoolVal = true; ;
3157 #line 1732 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3159 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
3160 CurModule.ModuleDone();
3165 #line 1740 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3167 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3168 CurFun.FunctionDone();
3173 #line 1745 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3175 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3180 #line 1749 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3182 yyval.ModuleVal = yyvsp[-3].ModuleVal;
3187 #line 1753 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3189 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3194 #line 1757 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3196 yyval.ModuleVal = CurModule.CurrentModule;
3197 // Emit an error if there are any unresolved types left.
3198 if (!CurModule.LateResolveTypes.empty()) {
3199 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
3200 if (DID.Type == ValID::NameVal) {
3201 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3203 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3210 #line 1772 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3212 // Eagerly resolve types. This is not an optimization, this is a
3213 // requirement that is due to the fact that we could have this:
3215 // %list = type { %list * }
3216 // %list = type { %list * } ; repeated type decl
3218 // If types are not resolved eagerly, then the two types will not be
3219 // determined to be the same type!
3221 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3223 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3225 // If this is a named type that is not a redefinition, add it to the slot
3227 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3230 delete yyvsp[0].TypeVal;
3235 #line 1794 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3236 { // Function prototypes can be in const pool
3241 #line 1797 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3242 { // Asm blocks can be in the const pool
3247 #line 1800 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3249 if (yyvsp[0].ConstVal == 0)
3250 GEN_ERROR("Global value initializer is not a constant!");
3251 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3256 #line 1805 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3262 #line 1808 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3264 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3266 delete yyvsp[0].TypeVal;
3270 #line 1812 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3277 #line 1816 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3279 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3281 delete yyvsp[0].TypeVal;
3285 #line 1820 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3292 #line 1824 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3295 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3297 delete yyvsp[0].TypeVal;
3301 #line 1829 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3308 #line 1833 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3314 #line 1836 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3320 #line 1839 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3325 #line 1843 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3327 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3328 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3329 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3330 free(yyvsp[0].StrVal);
3332 if (AsmSoFar.empty())
3333 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3335 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
3340 #line 1856 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3341 { yyval.Endianness = Module::BigEndian; ;
3344 #line 1857 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3345 { yyval.Endianness = Module::LittleEndian; ;
3348 #line 1859 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3350 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3355 #line 1863 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3357 if (yyvsp[0].UInt64Val == 32)
3358 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3359 else if (yyvsp[0].UInt64Val == 64)
3360 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3362 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3367 #line 1872 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3369 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3370 free(yyvsp[0].StrVal);
3375 #line 1877 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3377 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
3378 free(yyvsp[0].StrVal);
3383 #line 1885 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3385 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3386 free(yyvsp[0].StrVal);
3391 #line 1890 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3393 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3394 free(yyvsp[0].StrVal);
3399 #line 1895 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3405 #line 1905 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3406 { yyval.StrVal = 0; ;
3409 #line 1907 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3411 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3412 GEN_ERROR("void typed arguments are invalid!");
3413 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3418 #line 1914 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3420 yyval.ArgList = yyvsp[-2].ArgList;
3421 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3422 delete yyvsp[0].ArgVal;
3427 #line 1920 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3429 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3430 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3431 delete yyvsp[0].ArgVal;
3436 #line 1927 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3438 yyval.ArgList = yyvsp[0].ArgList;
3443 #line 1931 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3445 yyval.ArgList = yyvsp[-2].ArgList;
3446 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3447 char*>(new PATypeHolder(Type::VoidTy), 0));
3452 #line 1937 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3454 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3455 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3460 #line 1942 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3467 #line 1948 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3469 UnEscapeLexed(yyvsp[-5].StrVal);
3470 std::string FunctionName(yyvsp[-5].StrVal);
3471 free(yyvsp[-5].StrVal); // Free strdup'd memory!
3473 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
3474 GEN_ERROR("LLVM functions cannot return aggregate types!");
3476 std::vector<const Type*> ParamTypeList;
3477 if (yyvsp[-3].ArgList) { // If there are arguments...
3478 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3479 I != yyvsp[-3].ArgList->end(); ++I)
3480 ParamTypeList.push_back(I->first->get());
3483 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3484 if (isVarArg) ParamTypeList.pop_back();
3486 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
3487 const PointerType *PFT = PointerType::get(FT);
3488 delete yyvsp[-6].TypeVal;
3491 if (!FunctionName.empty()) {
3492 ID = ValID::create((char*)FunctionName.c_str());
3494 ID = ValID::create((int)CurModule.Values[PFT].size());
3498 // See if this function was forward referenced. If so, recycle the object.
3499 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3500 // Move the function to the end of the list, from whereever it was
3501 // previously inserted.
3502 Fn = cast<Function>(FWRef);
3503 CurModule.CurrentModule->getFunctionList().remove(Fn);
3504 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3505 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3506 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3507 // If this is the case, either we need to be a forward decl, or it needs
3509 if (!CurFun.isDeclare && !Fn->isExternal())
3510 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
3512 // Make sure to strip off any argument names so we can't get conflicts.
3513 if (Fn->isExternal())
3514 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3517 } else { // Not already defined?
3518 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3519 CurModule.CurrentModule);
3521 InsertValue(Fn, CurModule.Values);
3524 CurFun.FunctionStart(Fn);
3526 if (CurFun.isDeclare) {
3527 // If we have declaration, always overwrite linkage. This will allow us to
3528 // correctly handle cases, when pointer to function is passed as argument to
3529 // another function.
3530 Fn->setLinkage(CurFun.Linkage);
3532 Fn->setCallingConv(yyvsp[-7].UIntVal);
3533 Fn->setAlignment(yyvsp[0].UIntVal);
3534 if (yyvsp[-1].StrVal) {
3535 Fn->setSection(yyvsp[-1].StrVal);
3536 free(yyvsp[-1].StrVal);
3539 // Add all of the arguments we parsed to the function...
3540 if (yyvsp[-3].ArgList) { // Is null if empty...
3541 if (isVarArg) { // Nuke the last entry
3542 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
3543 "Not a varargs marker!");
3544 delete yyvsp[-3].ArgList->back().first;
3545 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
3547 Function::arg_iterator ArgIt = Fn->arg_begin();
3548 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3549 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
3550 delete I->first; // Delete the typeholder...
3552 setValueName(ArgIt, I->second); // Insert arg into symtab...
3557 delete yyvsp[-3].ArgList; // We're now done with the argument list
3563 #line 2044 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3565 yyval.FunctionVal = CurFun.CurrentFunction;
3567 // Make sure that we keep track of the linkage type even if there was a
3568 // previous "declare".
3569 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3573 #line 2054 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3575 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3580 #line 2060 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3581 { CurFun.Linkage = GlobalValue::DLLImportLinkage ;
3584 #line 2061 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3585 { CurFun.Linkage = GlobalValue::DLLImportLinkage ;
3588 #line 2063 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3589 { CurFun.isDeclare = true; ;
3592 #line 2063 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3594 yyval.FunctionVal = CurFun.CurrentFunction;
3595 CurFun.FunctionDone();
3600 #line 2073 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3602 yyval.BoolVal = false;
3607 #line 2077 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3609 yyval.BoolVal = true;
3614 #line 2082 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3615 { // A reference to a direct constant
3616 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3621 #line 2086 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3623 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3628 #line 2090 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3629 { // Perhaps it's an FP constant?
3630 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3635 #line 2094 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3637 yyval.ValIDVal = ValID::create(ConstantBool::getTrue());
3642 #line 2098 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3644 yyval.ValIDVal = ValID::create(ConstantBool::getFalse());
3649 #line 2102 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3651 yyval.ValIDVal = ValID::createNull();
3656 #line 2106 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3658 yyval.ValIDVal = ValID::createUndef();
3663 #line 2110 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3664 { // A vector zero constant.
3665 yyval.ValIDVal = ValID::createZeroInit();
3670 #line 2114 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3671 { // Nonempty unsized packed vector
3672 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3673 int NumElements = yyvsp[-1].ConstVector->size();
3675 PackedType* pt = PackedType::get(ETy, NumElements);
3676 PATypeHolder* PTy = new PATypeHolder(
3684 // Verify all elements are correct type!
3685 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3686 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3687 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3688 ETy->getDescription() +"' as required!\nIt is of type '" +
3689 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3692 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3693 delete PTy; delete yyvsp[-1].ConstVector;
3698 #line 2139 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3700 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3705 #line 2143 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3707 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3708 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3709 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3710 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3711 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3712 free(yyvsp[-2].StrVal);
3713 free(yyvsp[0].StrVal);
3718 #line 2157 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3719 { // Is it an integer reference...?
3720 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3725 #line 2161 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3726 { // Is it a named reference...?
3727 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3732 #line 2173 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3734 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3739 #line 2178 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3741 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3746 #line 2182 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3747 { // Do not allow functions with 0 basic blocks
3748 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3753 #line 2191 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3755 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3757 InsertValue(yyvsp[0].TermInstVal);
3759 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3760 InsertValue(yyvsp[-2].BasicBlockVal);
3761 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3766 #line 2202 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3768 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3769 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3774 #line 2207 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3776 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3779 // Make sure to move the basic block to the correct location in the
3780 // function, instead of leaving it inserted wherever it was first
3782 Function::BasicBlockListType &BBL =
3783 CurFun.CurrentFunction->getBasicBlockList();
3784 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3789 #line 2219 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3791 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3794 // Make sure to move the basic block to the correct location in the
3795 // function, instead of leaving it inserted wherever it was first
3797 Function::BasicBlockListType &BBL =
3798 CurFun.CurrentFunction->getBasicBlockList();
3799 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3804 #line 2232 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3805 { // Return with a result...
3806 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3811 #line 2236 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3812 { // Return with no result...
3813 yyval.TermInstVal = new ReturnInst();
3818 #line 2240 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3819 { // Unconditional Branch...
3820 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
3822 yyval.TermInstVal = new BranchInst(tmpBB);
3826 #line 2245 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3828 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
3830 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
3832 Value* tmpVal = getVal(Type::BoolTy, yyvsp[-6].ValIDVal);
3834 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
3838 #line 2254 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3840 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
3842 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
3844 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
3845 yyval.TermInstVal = S;
3847 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3848 E = yyvsp[-1].JumpTable->end();
3849 for (; I != E; ++I) {
3850 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3851 S->addCase(CI, I->second);
3853 GEN_ERROR("Switch case is constant, but not a simple integer!");
3855 delete yyvsp[-1].JumpTable;
3860 #line 2273 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3862 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
3864 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
3866 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
3867 yyval.TermInstVal = S;
3872 #line 2283 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3874 const PointerType *PFTy;
3875 const FunctionType *Ty;
3877 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3878 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3879 // Pull out the types of all of the arguments...
3880 std::vector<const Type*> ParamTypes;
3881 if (yyvsp[-7].ValueList) {
3882 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3884 ParamTypes.push_back((*I)->getType());
3887 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3888 if (isVarArg) ParamTypes.pop_back();
3890 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3891 PFTy = PointerType::get(Ty);
3894 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3896 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3898 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3901 // Create the call node...
3902 if (!yyvsp[-7].ValueList) { // Has no arguments?
3903 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3904 } else { // Has arguments?
3905 // Loop through FunctionType's arguments and ensure they are specified
3908 FunctionType::param_iterator I = Ty->param_begin();
3909 FunctionType::param_iterator E = Ty->param_end();
3910 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3912 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3913 if ((*ArgI)->getType() != *I)
3914 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3915 (*I)->getDescription() + "'!");
3917 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3918 GEN_ERROR("Invalid number of parameters detected!");
3920 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3922 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3924 delete yyvsp[-10].TypeVal;
3925 delete yyvsp[-7].ValueList;
3930 #line 2338 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3932 yyval.TermInstVal = new UnwindInst();
3937 #line 2342 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3939 yyval.TermInstVal = new UnreachableInst();
3944 #line 2349 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3946 yyval.JumpTable = yyvsp[-5].JumpTable;
3947 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3950 GEN_ERROR("May only switch on a constant pool value!");
3952 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
3954 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
3958 #line 2360 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3960 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3961 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3965 GEN_ERROR("May only switch on a constant pool value!");
3967 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
3969 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
3973 #line 2373 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3975 // Is this definition named?? if so, assign the name...
3976 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3978 InsertValue(yyvsp[0].InstVal);
3979 yyval.InstVal = yyvsp[0].InstVal;
3984 #line 2382 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3985 { // Used for PHI nodes
3986 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3987 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
3989 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
3991 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
3992 delete yyvsp[-5].TypeVal;
3996 #line 2391 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
3998 yyval.PHIList = yyvsp[-6].PHIList;
3999 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
4001 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4003 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4007 #line 2401 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4008 { // Used for call statements, and memory insts...
4009 yyval.ValueList = new std::vector<Value*>();
4010 yyval.ValueList->push_back(yyvsp[0].ValueVal);
4014 #line 2405 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4016 yyval.ValueList = yyvsp[-2].ValueList;
4017 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
4022 #line 2412 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4023 { yyval.ValueList = 0; ;
4026 #line 2414 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4028 yyval.BoolVal = true;
4033 #line 2418 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4035 yyval.BoolVal = false;
4040 #line 2423 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4042 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4043 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
4045 "Arithmetic operator requires integer, FP, or packed operands!");
4046 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
4047 GEN_ERROR("Rem not supported on packed types!");
4048 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4050 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4052 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4053 if (yyval.InstVal == 0)
4054 GEN_ERROR("binary operator returned null!");
4055 delete yyvsp[-3].TypeVal;
4059 #line 2439 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4061 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
4062 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
4063 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
4064 GEN_ERROR("Logical operator requires integral operands!");
4066 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4068 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4070 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4071 if (yyval.InstVal == 0)
4072 GEN_ERROR("binary operator returned null!");
4073 delete yyvsp[-3].TypeVal;
4077 #line 2454 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4079 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
4081 "PackedTypes currently not supported in setcc instructions!");
4083 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4085 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4087 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4088 if (yyval.InstVal == 0)
4089 GEN_ERROR("binary operator returned null!");
4090 delete yyvsp[-3].TypeVal;
4094 #line 2468 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4096 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4097 << " Replacing with 'xor'.\n";
4099 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
4101 GEN_ERROR("Expected integral type for not instruction!");
4103 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
4104 if (yyval.InstVal == 0)
4105 GEN_ERROR("Could not create a xor instruction!");
4110 #line 2481 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4112 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
4113 GEN_ERROR("Shift amount must be ubyte!");
4114 if (!yyvsp[-2].ValueVal->getType()->isInteger())
4115 GEN_ERROR("Shift constant expression requires integer operand!");
4116 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4121 #line 2489 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4123 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
4124 GEN_ERROR("cast instruction to a non-primitive type: '" +
4125 yyvsp[0].TypeVal->get()->getDescription() + "'!");
4126 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4127 delete yyvsp[0].TypeVal;
4132 #line 2497 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4134 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
4135 GEN_ERROR("select condition must be boolean!");
4136 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
4137 GEN_ERROR("select value types should match!");
4138 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4143 #line 2505 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4146 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4147 delete yyvsp[0].TypeVal;
4152 #line 2511 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4154 ObsoleteVarArgs = true;
4155 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4156 Function* NF = CurModule.CurrentModule->
4157 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
4160 //foo = alloca 1 of t
4164 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4165 CurBB->getInstList().push_back(foo);
4166 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4167 CurBB->getInstList().push_back(bar);
4168 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4169 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
4170 delete yyvsp[0].TypeVal;
4175 #line 2531 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4177 ObsoleteVarArgs = true;
4178 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4179 Function* NF = CurModule.CurrentModule->
4180 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
4182 //b = vanext a, t ->
4183 //foo = alloca 1 of t
4186 //tmp = vaarg foo, t
4188 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4189 CurBB->getInstList().push_back(foo);
4190 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4191 CurBB->getInstList().push_back(bar);
4192 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4193 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
4194 CurBB->getInstList().push_back(tmp);
4195 yyval.InstVal = new LoadInst(foo);
4196 delete yyvsp[0].TypeVal;
4201 #line 2554 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4203 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4204 GEN_ERROR("Invalid extractelement operands!");
4205 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4210 #line 2560 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4212 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4213 GEN_ERROR("Invalid insertelement operands!");
4214 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4219 #line 2566 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4221 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4222 GEN_ERROR("Invalid shufflevector operands!");
4223 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4228 #line 2572 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4230 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
4231 if (!Ty->isFirstClassType())
4232 GEN_ERROR("PHI node operands must be of first class type!");
4233 yyval.InstVal = new PHINode(Ty);
4234 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4235 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4236 if (yyvsp[0].PHIList->front().first->getType() != Ty)
4237 GEN_ERROR("All elements of a PHI node must be of the same type!");
4238 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4239 yyvsp[0].PHIList->pop_front();
4241 delete yyvsp[0].PHIList; // Free the list...
4246 #line 2587 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4248 const PointerType *PFTy;
4249 const FunctionType *Ty;
4251 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
4252 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4253 // Pull out the types of all of the arguments...
4254 std::vector<const Type*> ParamTypes;
4255 if (yyvsp[-1].ValueList) {
4256 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
4258 ParamTypes.push_back((*I)->getType());
4261 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4262 if (isVarArg) ParamTypes.pop_back();
4264 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
4265 GEN_ERROR("LLVM functions cannot return aggregate types!");
4267 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
4268 PFTy = PointerType::get(Ty);
4271 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
4274 // Create the call node...
4275 if (!yyvsp[-1].ValueList) { // Has no arguments?
4276 // Make sure no arguments is a good thing!
4277 if (Ty->getNumParams() != 0)
4278 GEN_ERROR("No arguments passed to a function that "
4279 "expects arguments!");
4281 yyval.InstVal = new CallInst(V, std::vector<Value*>());
4282 } else { // Has arguments?
4283 // Loop through FunctionType's arguments and ensure they are specified
4286 FunctionType::param_iterator I = Ty->param_begin();
4287 FunctionType::param_iterator E = Ty->param_end();
4288 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
4290 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4291 if ((*ArgI)->getType() != *I)
4292 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4293 (*I)->getDescription() + "'!");
4295 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
4296 GEN_ERROR("Invalid number of parameters detected!");
4298 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
4300 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
4301 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
4302 delete yyvsp[-4].TypeVal;
4303 delete yyvsp[-1].ValueList;
4308 #line 2646 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4310 yyval.InstVal = yyvsp[0].InstVal;
4315 #line 2653 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4317 yyval.ValueList = yyvsp[0].ValueList;
4322 #line 2656 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4324 yyval.ValueList = new std::vector<Value*>();
4329 #line 2661 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4331 yyval.BoolVal = true;
4336 #line 2665 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4338 yyval.BoolVal = false;
4343 #line 2672 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4345 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4346 delete yyvsp[-1].TypeVal;
4351 #line 2677 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4353 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4355 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4356 delete yyvsp[-4].TypeVal;
4360 #line 2683 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4362 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4363 delete yyvsp[-1].TypeVal;
4368 #line 2688 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4370 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4372 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4373 delete yyvsp[-4].TypeVal;
4377 #line 2694 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4379 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
4380 GEN_ERROR("Trying to free nonpointer type " +
4381 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4382 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
4387 #line 2702 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4389 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4390 GEN_ERROR("Can't load from nonpointer type: " +
4391 (*yyvsp[-1].TypeVal)->getDescription());
4392 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4393 GEN_ERROR("Can't load from pointer of non-first-class type: " +
4394 (*yyvsp[-1].TypeVal)->getDescription());
4395 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4397 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
4398 delete yyvsp[-1].TypeVal;
4402 #line 2714 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4404 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4406 GEN_ERROR("Can't store to a nonpointer type: " +
4407 (*yyvsp[-1].TypeVal)->getDescription());
4408 const Type *ElTy = PT->getElementType();
4409 if (ElTy != yyvsp[-3].ValueVal->getType())
4410 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4411 "' into space of type '" + ElTy->getDescription() + "'!");
4413 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4415 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
4416 delete yyvsp[-1].TypeVal;
4420 #line 2729 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4422 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4423 GEN_ERROR("getelementptr insn requires pointer operand!");
4425 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4426 // indices to uint struct indices for compatibility.
4427 generic_gep_type_iterator<std::vector<Value*>::iterator>
4428 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4429 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4430 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4431 if (isa<StructType>(*GTI)) // Only change struct indices
4432 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4433 if (CUI->getType() == Type::UByteTy)
4434 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4436 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4437 GEN_ERROR("Invalid getelementptr indices for type '" +
4438 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4439 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
4441 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
4442 delete yyvsp[-2].TypeVal;
4443 delete yyvsp[0].ValueList;
4447 /* the action file gets copied in in place of this dollarsign */
4448 #line 543 "/usr/share/bison.simple"
4459 short *ssp1 = yyss - 1;
4460 fprintf (stderr, "state stack now");
4461 while (ssp1 != yyssp)
4462 fprintf (stderr, " %d", *++ssp1);
4463 fprintf (stderr, "\n");
4473 yylsp->first_line = yylloc.first_line;
4474 yylsp->first_column = yylloc.first_column;
4475 yylsp->last_line = (yylsp-1)->last_line;
4476 yylsp->last_column = (yylsp-1)->last_column;
4481 yylsp->last_line = (yylsp+yylen-1)->last_line;
4482 yylsp->last_column = (yylsp+yylen-1)->last_column;
4486 /* Now "shift" the result of the reduction.
4487 Determine what state that goes to,
4488 based on the state we popped back to
4489 and the rule number reduced by. */
4493 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4494 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4495 yystate = yytable[yystate];
4497 yystate = yydefgoto[yyn - YYNTBASE];
4501 yyerrlab: /* here on detecting error */
4504 /* If not already recovering from an error, report this error. */
4508 #ifdef YYERROR_VERBOSE
4509 yyn = yypact[yystate];
4511 if (yyn > YYFLAG && yyn < YYLAST)
4518 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4519 for (x = (yyn < 0 ? -yyn : 0);
4520 x < (sizeof(yytname) / sizeof(char *)); x++)
4521 if (yycheck[x + yyn] == x)
4522 size += strlen(yytname[x]) + 15, count++;
4523 msg = (char *) malloc(size + 15);
4526 strcpy(msg, "parse error");
4531 for (x = (yyn < 0 ? -yyn : 0);
4532 x < (sizeof(yytname) / sizeof(char *)); x++)
4533 if (yycheck[x + yyn] == x)
4535 strcat(msg, count == 0 ? ", expecting `" : " or `");
4536 strcat(msg, yytname[x]);
4545 yyerror ("parse error; also virtual memory exceeded");
4548 #endif /* YYERROR_VERBOSE */
4549 yyerror("parse error");
4553 yyerrlab1: /* here on error raised explicitly by an action */
4555 if (yyerrstatus == 3)
4557 /* if just tried and failed to reuse lookahead token after an error, discard it. */
4559 /* return failure if at end of input */
4560 if (yychar == YYEOF)
4565 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4571 /* Else will try to reuse lookahead token
4572 after shifting the error token. */
4574 yyerrstatus = 3; /* Each real token shifted decrements this */
4578 yyerrdefault: /* current state does not do anything special for the error token. */
4581 /* This is wrong; only states that explicitly want error tokens
4582 should shift them. */
4583 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4584 if (yyn) goto yydefault;
4587 yyerrpop: /* pop the current state because it cannot handle the error token */
4589 if (yyssp == yyss) YYABORT;
4599 short *ssp1 = yyss - 1;
4600 fprintf (stderr, "Error: state stack now");
4601 while (ssp1 != yyssp)
4602 fprintf (stderr, " %d", *++ssp1);
4603 fprintf (stderr, "\n");
4609 yyn = yypact[yystate];
4614 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4633 fprintf(stderr, "Shifting error token, ");
4645 /* YYACCEPT comes here. */
4657 /* YYABORT comes here. */
4668 #line 2755 "/Users/resistor/llvm/src/llvm/lib/AsmParser/llvmAsmParser.y"
4671 void llvm::GenerateError(const std::string &message, int LineNo) {
4672 if (LineNo == -1) LineNo = llvmAsmlineno;
4673 // TODO: column number in exception
4675 TheParseError->setError(CurFilename, message, LineNo);
4679 int yyerror(const char *ErrorMsg) {
4681 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4682 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4683 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4684 if (yychar == YYEMPTY || yychar == 0)
4685 errMsg += "end-of-file.";
4687 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4688 GenerateError(errMsg);