Tighten up some checks
[oota-llvm.git] / lib / AsmParser / llvmAsmParser.cpp
1
2 /*  A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3     by GNU Bison version 1.28  */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
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
16 #define SINTVAL 259
17 #define UINTVAL 260
18 #define FPVAL   261
19 #define VOID    262
20 #define BOOL    263
21 #define SBYTE   264
22 #define UBYTE   265
23 #define SHORT   266
24 #define USHORT  267
25 #define INT     268
26 #define UINT    269
27 #define LONG    270
28 #define ULONG   271
29 #define FLOAT   272
30 #define DOUBLE  273
31 #define TYPE    274
32 #define LABEL   275
33 #define VAR_ID  276
34 #define LABELSTR        277
35 #define STRINGCONSTANT  278
36 #define IMPLEMENTATION  279
37 #define ZEROINITIALIZER 280
38 #define TRUETOK 281
39 #define FALSETOK        282
40 #define BEGINTOK        283
41 #define ENDTOK  284
42 #define DECLARE 285
43 #define GLOBAL  286
44 #define CONSTANT        287
45 #define SECTION 288
46 #define VOLATILE        289
47 #define TO      290
48 #define DOTDOTDOT       291
49 #define NULL_TOK        292
50 #define UNDEF   293
51 #define CONST   294
52 #define INTERNAL        295
53 #define LINKONCE        296
54 #define WEAK    297
55 #define APPENDING       298
56 #define OPAQUE  299
57 #define NOT     300
58 #define EXTERNAL        301
59 #define TARGET  302
60 #define TRIPLE  303
61 #define ENDIAN  304
62 #define POINTERSIZE     305
63 #define LITTLE  306
64 #define BIG     307
65 #define ALIGN   308
66 #define DEPLIBS 309
67 #define CALL    310
68 #define TAIL    311
69 #define CC_TOK  312
70 #define CCC_TOK 313
71 #define FASTCC_TOK      314
72 #define COLDCC_TOK      315
73 #define RET     316
74 #define BR      317
75 #define SWITCH  318
76 #define INVOKE  319
77 #define UNWIND  320
78 #define UNREACHABLE     321
79 #define ADD     322
80 #define SUB     323
81 #define MUL     324
82 #define DIV     325
83 #define REM     326
84 #define AND     327
85 #define OR      328
86 #define XOR     329
87 #define SETLE   330
88 #define SETGE   331
89 #define SETLT   332
90 #define SETGT   333
91 #define SETEQ   334
92 #define SETNE   335
93 #define MALLOC  336
94 #define ALLOCA  337
95 #define FREE    338
96 #define LOAD    339
97 #define STORE   340
98 #define GETELEMENTPTR   341
99 #define PHI_TOK 342
100 #define CAST    343
101 #define SELECT  344
102 #define SHL     345
103 #define SHR     346
104 #define VAARG   347
105 #define VAARG_old       348
106 #define VANEXT_old      349
107
108 #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
109
110 #include "ParserInternals.h"
111 #include "llvm/CallingConv.h"
112 #include "llvm/Instructions.h"
113 #include "llvm/Module.h"
114 #include "llvm/SymbolTable.h"
115 #include "llvm/Support/GetElementPtrTypeIterator.h"
116 #include "llvm/ADT/STLExtras.h"
117 #include "llvm/Support/MathExtras.h"
118 #include <algorithm>
119 #include <iostream>
120 #include <list>
121 #include <utility>
122
123 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
124 int yylex();                       // declaration" of xxx warnings.
125 int yyparse();
126
127 namespace llvm {
128   std::string CurFilename;
129 }
130 using namespace llvm;
131
132 static Module *ParserResult;
133
134 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
135 // relating to upreferences in the input stream.
136 //
137 //#define DEBUG_UPREFS 1
138 #ifdef DEBUG_UPREFS
139 #define UR_OUT(X) std::cerr << X
140 #else
141 #define UR_OUT(X)
142 #endif
143
144 #define YYERROR_VERBOSE 1
145
146 static bool ObsoleteVarArgs;
147 static bool NewVarArgs;
148 static BasicBlock *CurBB;
149 static GlobalVariable *CurGV;
150
151
152 // This contains info used when building the body of a function.  It is
153 // destroyed when the function is completed.
154 //
155 typedef std::vector<Value *> ValueList;           // Numbered defs
156 static void 
157 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
158                    std::map<const Type *,ValueList> *FutureLateResolvers = 0);
159
160 static struct PerModuleInfo {
161   Module *CurrentModule;
162   std::map<const Type *, ValueList> Values; // Module level numbered definitions
163   std::map<const Type *,ValueList> LateResolveValues;
164   std::vector<PATypeHolder>    Types;
165   std::map<ValID, PATypeHolder> LateResolveTypes;
166
167   /// PlaceHolderInfo - When temporary placeholder objects are created, remember
168   /// how they were referenced and one which line of the input they came from so
169   /// that we can resolve them later and print error messages as appropriate.
170   std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
171
172   // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
173   // references to global values.  Global values may be referenced before they
174   // are defined, and if so, the temporary object that they represent is held
175   // here.  This is used for forward references of GlobalValues.
176   //
177   typedef std::map<std::pair<const PointerType *,
178                              ValID>, GlobalValue*> GlobalRefsType;
179   GlobalRefsType GlobalRefs;
180
181   void ModuleDone() {
182     // If we could not resolve some functions at function compilation time
183     // (calls to functions before they are defined), resolve them now...  Types
184     // are resolved when the constant pool has been completely parsed.
185     //
186     ResolveDefinitions(LateResolveValues);
187
188     // Check to make sure that all global value forward references have been
189     // resolved!
190     //
191     if (!GlobalRefs.empty()) {
192       std::string UndefinedReferences = "Unresolved global references exist:\n";
193
194       for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
195            I != E; ++I) {
196         UndefinedReferences += "  " + I->first.first->getDescription() + " " +
197                                I->first.second.getName() + "\n";
198       }
199       ThrowException(UndefinedReferences);
200     }
201
202     Values.clear();         // Clear out function local definitions
203     Types.clear();
204     CurrentModule = 0;
205   }
206
207
208   // GetForwardRefForGlobal - Check to see if there is a forward reference
209   // for this global.  If so, remove it from the GlobalRefs map and return it.
210   // If not, just return null.
211   GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
212     // Check to see if there is a forward reference to this global variable...
213     // if there is, eliminate it and patch the reference to use the new def'n.
214     GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
215     GlobalValue *Ret = 0;
216     if (I != GlobalRefs.end()) {
217       Ret = I->second;
218       GlobalRefs.erase(I);
219     }
220     return Ret;
221   }
222 } CurModule;
223
224 static struct PerFunctionInfo {
225   Function *CurrentFunction;     // Pointer to current function being created
226
227   std::map<const Type*, ValueList> Values;   // Keep track of #'d definitions
228   std::map<const Type*, ValueList> LateResolveValues;
229   bool isDeclare;                // Is this function a forward declararation?
230
231   /// BBForwardRefs - When we see forward references to basic blocks, keep
232   /// track of them here.
233   std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
234   std::vector<BasicBlock*> NumberedBlocks;
235   unsigned NextBBNum;
236
237   inline PerFunctionInfo() {
238     CurrentFunction = 0;
239     isDeclare = false;
240   }
241
242   inline void FunctionStart(Function *M) {
243     CurrentFunction = M;
244     NextBBNum = 0;
245   }
246
247   void FunctionDone() {
248     NumberedBlocks.clear();
249
250     // Any forward referenced blocks left?
251     if (!BBForwardRefs.empty())
252       ThrowException("Undefined reference to label " +
253                      BBForwardRefs.begin()->first->getName());
254
255     // Resolve all forward references now.
256     ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
257
258     Values.clear();         // Clear out function local definitions
259     CurrentFunction = 0;
260     isDeclare = false;
261   }
262 } CurFun;  // Info for the current function...
263
264 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
265
266
267 //===----------------------------------------------------------------------===//
268 //               Code to handle definitions of all the types
269 //===----------------------------------------------------------------------===//
270
271 static int InsertValue(Value *V,
272                   std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
273   if (V->hasName()) return -1;           // Is this a numbered definition?
274
275   // Yes, insert the value into the value table...
276   ValueList &List = ValueTab[V->getType()];
277   List.push_back(V);
278   return List.size()-1;
279 }
280
281 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
282   switch (D.Type) {
283   case ValID::NumberVal:               // Is it a numbered definition?
284     // Module constants occupy the lowest numbered slots...
285     if ((unsigned)D.Num < CurModule.Types.size())
286       return CurModule.Types[(unsigned)D.Num];
287     break;
288   case ValID::NameVal:                 // Is it a named definition?
289     if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
290       D.destroy();  // Free old strdup'd memory...
291       return N;
292     }
293     break;
294   default:
295     ThrowException("Internal parser error: Invalid symbol type reference!");
296   }
297
298   // If we reached here, we referenced either a symbol that we don't know about
299   // or an id number that hasn't been read yet.  We may be referencing something
300   // forward, so just create an entry to be resolved later and get to it...
301   //
302   if (DoNotImprovise) return 0;  // Do we just want a null to be returned?
303
304
305   if (inFunctionScope()) {
306     if (D.Type == ValID::NameVal)
307       ThrowException("Reference to an undefined type: '" + D.getName() + "'");
308     else
309       ThrowException("Reference to an undefined type: #" + itostr(D.Num));
310   }
311
312   std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
313   if (I != CurModule.LateResolveTypes.end())
314     return I->second;
315
316   Type *Typ = OpaqueType::get();
317   CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
318   return Typ;
319  }
320
321 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
322   SymbolTable &SymTab =
323     inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
324                         CurModule.CurrentModule->getSymbolTable();
325   return SymTab.lookup(Ty, Name);
326 }
327
328 // getValNonImprovising - Look up the value specified by the provided type and
329 // the provided ValID.  If the value exists and has already been defined, return
330 // it.  Otherwise return null.
331 //
332 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
333   if (isa<FunctionType>(Ty))
334     ThrowException("Functions are not values and "
335                    "must be referenced as pointers");
336
337   switch (D.Type) {
338   case ValID::NumberVal: {                 // Is it a numbered definition?
339     unsigned Num = (unsigned)D.Num;
340
341     // Module constants occupy the lowest numbered slots...
342     std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
343     if (VI != CurModule.Values.end()) {
344       if (Num < VI->second.size())
345         return VI->second[Num];
346       Num -= VI->second.size();
347     }
348
349     // Make sure that our type is within bounds
350     VI = CurFun.Values.find(Ty);
351     if (VI == CurFun.Values.end()) return 0;
352
353     // Check that the number is within bounds...
354     if (VI->second.size() <= Num) return 0;
355
356     return VI->second[Num];
357   }
358
359   case ValID::NameVal: {                // Is it a named definition?
360     Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
361     if (N == 0) return 0;
362
363     D.destroy();  // Free old strdup'd memory...
364     return N;
365   }
366
367   // Check to make sure that "Ty" is an integral type, and that our
368   // value will fit into the specified type...
369   case ValID::ConstSIntVal:    // Is it a constant pool reference??
370     if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
371       ThrowException("Signed integral constant '" +
372                      itostr(D.ConstPool64) + "' is invalid for type '" +
373                      Ty->getDescription() + "'!");
374     return ConstantSInt::get(Ty, D.ConstPool64);
375
376   case ValID::ConstUIntVal:     // Is it an unsigned const pool reference?
377     if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
378       if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
379         ThrowException("Integral constant '" + utostr(D.UConstPool64) +
380                        "' is invalid or out of range!");
381       } else {     // This is really a signed reference.  Transmogrify.
382         return ConstantSInt::get(Ty, D.ConstPool64);
383       }
384     } else {
385       return ConstantUInt::get(Ty, D.UConstPool64);
386     }
387
388   case ValID::ConstFPVal:        // Is it a floating point const pool reference?
389     if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
390       ThrowException("FP constant invalid for type!!");
391     return ConstantFP::get(Ty, D.ConstPoolFP);
392
393   case ValID::ConstNullVal:      // Is it a null value?
394     if (!isa<PointerType>(Ty))
395       ThrowException("Cannot create a a non pointer null!");
396     return ConstantPointerNull::get(cast<PointerType>(Ty));
397
398   case ValID::ConstUndefVal:      // Is it an undef value?
399     return UndefValue::get(Ty);
400
401   case ValID::ConstantVal:       // Fully resolved constant?
402     if (D.ConstantValue->getType() != Ty)
403       ThrowException("Constant expression type different from required type!");
404     return D.ConstantValue;
405
406   default:
407     assert(0 && "Unhandled case!");
408     return 0;
409   }   // End of switch
410
411   assert(0 && "Unhandled case!");
412   return 0;
413 }
414
415 // getVal - This function is identical to getValNonImprovising, except that if a
416 // value is not already defined, it "improvises" by creating a placeholder var
417 // that looks and acts just like the requested variable.  When the value is
418 // defined later, all uses of the placeholder variable are replaced with the
419 // real thing.
420 //
421 static Value *getVal(const Type *Ty, const ValID &ID) {
422   if (Ty == Type::LabelTy)
423     ThrowException("Cannot use a basic block here");
424
425   // See if the value has already been defined.
426   Value *V = getValNonImprovising(Ty, ID);
427   if (V) return V;
428
429   if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
430     ThrowException("Invalid use of a composite type!");
431
432   // If we reached here, we referenced either a symbol that we don't know about
433   // or an id number that hasn't been read yet.  We may be referencing something
434   // forward, so just create an entry to be resolved later and get to it...
435   //
436   V = new Argument(Ty);
437
438   // Remember where this forward reference came from.  FIXME, shouldn't we try
439   // to recycle these things??
440   CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
441                                                                llvmAsmlineno)));
442
443   if (inFunctionScope())
444     InsertValue(V, CurFun.LateResolveValues);
445   else
446     InsertValue(V, CurModule.LateResolveValues);
447   return V;
448 }
449
450 /// getBBVal - This is used for two purposes:
451 ///  * If isDefinition is true, a new basic block with the specified ID is being
452 ///    defined.
453 ///  * If isDefinition is true, this is a reference to a basic block, which may
454 ///    or may not be a forward reference.
455 ///
456 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
457   assert(inFunctionScope() && "Can't get basic block at global scope!");
458
459   std::string Name;
460   BasicBlock *BB = 0;
461   switch (ID.Type) {
462   default: ThrowException("Illegal label reference " + ID.getName());
463   case ValID::NumberVal:                // Is it a numbered definition?
464     if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
465       CurFun.NumberedBlocks.resize(ID.Num+1);
466     BB = CurFun.NumberedBlocks[ID.Num];
467     break;
468   case ValID::NameVal:                  // Is it a named definition?
469     Name = ID.Name;
470     if (Value *N = CurFun.CurrentFunction->
471                    getSymbolTable().lookup(Type::LabelTy, Name))
472       BB = cast<BasicBlock>(N);
473     break;
474   }
475
476   // See if the block has already been defined.
477   if (BB) {
478     // If this is the definition of the block, make sure the existing value was
479     // just a forward reference.  If it was a forward reference, there will be
480     // an entry for it in the PlaceHolderInfo map.
481     if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
482       // The existing value was a definition, not a forward reference.
483       ThrowException("Redefinition of label " + ID.getName());
484
485     ID.destroy();                       // Free strdup'd memory.
486     return BB;
487   }
488
489   // Otherwise this block has not been seen before.
490   BB = new BasicBlock("", CurFun.CurrentFunction);
491   if (ID.Type == ValID::NameVal) {
492     BB->setName(ID.Name);
493   } else {
494     CurFun.NumberedBlocks[ID.Num] = BB;
495   }
496
497   // If this is not a definition, keep track of it so we can use it as a forward
498   // reference.
499   if (!isDefinition) {
500     // Remember where this forward reference came from.
501     CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
502   } else {
503     // The forward declaration could have been inserted anywhere in the
504     // function: insert it into the correct place now.
505     CurFun.CurrentFunction->getBasicBlockList().remove(BB);
506     CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
507   }
508   ID.destroy();
509   return BB;
510 }
511
512
513 //===----------------------------------------------------------------------===//
514 //              Code to handle forward references in instructions
515 //===----------------------------------------------------------------------===//
516 //
517 // This code handles the late binding needed with statements that reference
518 // values not defined yet... for example, a forward branch, or the PHI node for
519 // a loop body.
520 //
521 // This keeps a table (CurFun.LateResolveValues) of all such forward references
522 // and back patchs after we are done.
523 //
524
525 // ResolveDefinitions - If we could not resolve some defs at parsing
526 // time (forward branches, phi functions for loops, etc...) resolve the
527 // defs now...
528 //
529 static void 
530 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
531                    std::map<const Type*,ValueList> *FutureLateResolvers) {
532   // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
533   for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
534          E = LateResolvers.end(); LRI != E; ++LRI) {
535     ValueList &List = LRI->second;
536     while (!List.empty()) {
537       Value *V = List.back();
538       List.pop_back();
539
540       std::map<Value*, std::pair<ValID, int> >::iterator PHI =
541         CurModule.PlaceHolderInfo.find(V);
542       assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
543
544       ValID &DID = PHI->second.first;
545
546       Value *TheRealValue = getValNonImprovising(LRI->first, DID);
547       if (TheRealValue) {
548         V->replaceAllUsesWith(TheRealValue);
549         delete V;
550         CurModule.PlaceHolderInfo.erase(PHI);
551       } else if (FutureLateResolvers) {
552         // Functions have their unresolved items forwarded to the module late
553         // resolver table
554         InsertValue(V, *FutureLateResolvers);
555       } else {
556         if (DID.Type == ValID::NameVal)
557           ThrowException("Reference to an invalid definition: '" +DID.getName()+
558                          "' of type '" + V->getType()->getDescription() + "'",
559                          PHI->second.second);
560         else
561           ThrowException("Reference to an invalid definition: #" +
562                          itostr(DID.Num) + " of type '" +
563                          V->getType()->getDescription() + "'",
564                          PHI->second.second);
565       }
566     }
567   }
568
569   LateResolvers.clear();
570 }
571
572 // ResolveTypeTo - A brand new type was just declared.  This means that (if
573 // name is not null) things referencing Name can be resolved.  Otherwise, things
574 // refering to the number can be resolved.  Do this now.
575 //
576 static void ResolveTypeTo(char *Name, const Type *ToTy) {
577   ValID D;
578   if (Name) D = ValID::create(Name);
579   else      D = ValID::create((int)CurModule.Types.size());
580
581   std::map<ValID, PATypeHolder>::iterator I =
582     CurModule.LateResolveTypes.find(D);
583   if (I != CurModule.LateResolveTypes.end()) {
584     ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
585     CurModule.LateResolveTypes.erase(I);
586   }
587 }
588
589 // setValueName - Set the specified value to the name given.  The name may be
590 // null potentially, in which case this is a noop.  The string passed in is
591 // assumed to be a malloc'd string buffer, and is free'd by this function.
592 //
593 static void setValueName(Value *V, char *NameStr) {
594   if (NameStr) {
595     std::string Name(NameStr);      // Copy string
596     free(NameStr);                  // Free old string
597
598     if (V->getType() == Type::VoidTy)
599       ThrowException("Can't assign name '" + Name+"' to value with void type!");
600
601     assert(inFunctionScope() && "Must be in function scope!");
602     SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
603     if (ST.lookup(V->getType(), Name))
604       ThrowException("Redefinition of value named '" + Name + "' in the '" +
605                      V->getType()->getDescription() + "' type plane!");
606
607     // Set the name.
608     V->setName(Name);
609   }
610 }
611
612 /// ParseGlobalVariable - Handle parsing of a global.  If Initializer is null,
613 /// this is a declaration, otherwise it is a definition.
614 static GlobalVariable *
615 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
616                     bool isConstantGlobal, const Type *Ty,
617                     Constant *Initializer) {
618   if (isa<FunctionType>(Ty))
619     ThrowException("Cannot declare global vars of function type!");
620
621   const PointerType *PTy = PointerType::get(Ty);
622
623   std::string Name;
624   if (NameStr) {
625     Name = NameStr;      // Copy string
626     free(NameStr);       // Free old string
627   }
628
629   // See if this global value was forward referenced.  If so, recycle the
630   // object.
631   ValID ID;
632   if (!Name.empty()) {
633     ID = ValID::create((char*)Name.c_str());
634   } else {
635     ID = ValID::create((int)CurModule.Values[PTy].size());
636   }
637
638   if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
639     // Move the global to the end of the list, from whereever it was
640     // previously inserted.
641     GlobalVariable *GV = cast<GlobalVariable>(FWGV);
642     CurModule.CurrentModule->getGlobalList().remove(GV);
643     CurModule.CurrentModule->getGlobalList().push_back(GV);
644     GV->setInitializer(Initializer);
645     GV->setLinkage(Linkage);
646     GV->setConstant(isConstantGlobal);
647     InsertValue(GV, CurModule.Values);
648     return GV;
649   }
650
651   // If this global has a name, check to see if there is already a definition
652   // of this global in the module.  If so, merge as appropriate.  Note that
653   // this is really just a hack around problems in the CFE.  :(
654   if (!Name.empty()) {
655     // We are a simple redefinition of a value, check to see if it is defined
656     // the same as the old one.
657     if (GlobalVariable *EGV =
658                 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
659       // We are allowed to redefine a global variable in two circumstances:
660       // 1. If at least one of the globals is uninitialized or
661       // 2. If both initializers have the same value.
662       //
663       if (!EGV->hasInitializer() || !Initializer ||
664           EGV->getInitializer() == Initializer) {
665
666         // Make sure the existing global version gets the initializer!  Make
667         // sure that it also gets marked const if the new version is.
668         if (Initializer && !EGV->hasInitializer())
669           EGV->setInitializer(Initializer);
670         if (isConstantGlobal)
671           EGV->setConstant(true);
672         EGV->setLinkage(Linkage);
673         return EGV;
674       }
675
676       ThrowException("Redefinition of global variable named '" + Name +
677                      "' in the '" + Ty->getDescription() + "' type plane!");
678     }
679   }
680
681   // Otherwise there is no existing GV to use, create one now.
682   GlobalVariable *GV =
683     new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
684                        CurModule.CurrentModule);
685   InsertValue(GV, CurModule.Values);
686   return GV;
687 }
688
689 // setTypeName - Set the specified type to the name given.  The name may be
690 // null potentially, in which case this is a noop.  The string passed in is
691 // assumed to be a malloc'd string buffer, and is freed by this function.
692 //
693 // This function returns true if the type has already been defined, but is
694 // allowed to be redefined in the specified context.  If the name is a new name
695 // for the type plane, it is inserted and false is returned.
696 static bool setTypeName(const Type *T, char *NameStr) {
697   assert(!inFunctionScope() && "Can't give types function-local names!");
698   if (NameStr == 0) return false;
699  
700   std::string Name(NameStr);      // Copy string
701   free(NameStr);                  // Free old string
702
703   // We don't allow assigning names to void type
704   if (T == Type::VoidTy)
705     ThrowException("Can't assign name '" + Name + "' to the void type!");
706
707   // Set the type name, checking for conflicts as we do so.
708   bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
709
710   if (AlreadyExists) {   // Inserting a name that is already defined???
711     const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
712     assert(Existing && "Conflict but no matching type?");
713
714     // There is only one case where this is allowed: when we are refining an
715     // opaque type.  In this case, Existing will be an opaque type.
716     if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
717       // We ARE replacing an opaque type!
718       const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
719       return true;
720     }
721
722     // Otherwise, this is an attempt to redefine a type. That's okay if
723     // the redefinition is identical to the original. This will be so if
724     // Existing and T point to the same Type object. In this one case we
725     // allow the equivalent redefinition.
726     if (Existing == T) return true;  // Yes, it's equal.
727
728     // Any other kind of (non-equivalent) redefinition is an error.
729     ThrowException("Redefinition of type named '" + Name + "' in the '" +
730                    T->getDescription() + "' type plane!");
731   }
732
733   return false;
734 }
735
736 //===----------------------------------------------------------------------===//
737 // Code for handling upreferences in type names...
738 //
739
740 // TypeContains - Returns true if Ty directly contains E in it.
741 //
742 static bool TypeContains(const Type *Ty, const Type *E) {
743   return std::find(Ty->subtype_begin(), Ty->subtype_end(),
744                    E) != Ty->subtype_end();
745 }
746
747 namespace {
748   struct UpRefRecord {
749     // NestingLevel - The number of nesting levels that need to be popped before
750     // this type is resolved.
751     unsigned NestingLevel;
752
753     // LastContainedTy - This is the type at the current binding level for the
754     // type.  Every time we reduce the nesting level, this gets updated.
755     const Type *LastContainedTy;
756
757     // UpRefTy - This is the actual opaque type that the upreference is
758     // represented with.
759     OpaqueType *UpRefTy;
760
761     UpRefRecord(unsigned NL, OpaqueType *URTy)
762       : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
763   };
764 }
765
766 // UpRefs - A list of the outstanding upreferences that need to be resolved.
767 static std::vector<UpRefRecord> UpRefs;
768
769 /// HandleUpRefs - Every time we finish a new layer of types, this function is
770 /// called.  It loops through the UpRefs vector, which is a list of the
771 /// currently active types.  For each type, if the up reference is contained in
772 /// the newly completed type, we decrement the level count.  When the level
773 /// count reaches zero, the upreferenced type is the type that is passed in:
774 /// thus we can complete the cycle.
775 ///
776 static PATypeHolder HandleUpRefs(const Type *ty) {
777   if (!ty->isAbstract()) return ty;
778   PATypeHolder Ty(ty);
779   UR_OUT("Type '" << Ty->getDescription() <<
780          "' newly formed.  Resolving upreferences.\n" <<
781          UpRefs.size() << " upreferences active!\n");
782
783   // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
784   // to zero), we resolve them all together before we resolve them to Ty.  At
785   // the end of the loop, if there is anything to resolve to Ty, it will be in
786   // this variable.
787   OpaqueType *TypeToResolve = 0;
788
789   for (unsigned i = 0; i != UpRefs.size(); ++i) {
790     UR_OUT("  UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
791            << UpRefs[i].second->getDescription() << ") = "
792            << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
793     if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
794       // Decrement level of upreference
795       unsigned Level = --UpRefs[i].NestingLevel;
796       UpRefs[i].LastContainedTy = Ty;
797       UR_OUT("  Uplevel Ref Level = " << Level << "\n");
798       if (Level == 0) {                     // Upreference should be resolved!
799         if (!TypeToResolve) {
800           TypeToResolve = UpRefs[i].UpRefTy;
801         } else {
802           UR_OUT("  * Resolving upreference for "
803                  << UpRefs[i].second->getDescription() << "\n";
804                  std::string OldName = UpRefs[i].UpRefTy->getDescription());
805           UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
806           UR_OUT("  * Type '" << OldName << "' refined upreference to: "
807                  << (const void*)Ty << ", " << Ty->getDescription() << "\n");
808         }
809         UpRefs.erase(UpRefs.begin()+i);     // Remove from upreference list...
810         --i;                                // Do not skip the next element...
811       }
812     }
813   }
814
815   if (TypeToResolve) {
816     UR_OUT("  * Resolving upreference for "
817            << UpRefs[i].second->getDescription() << "\n";
818            std::string OldName = TypeToResolve->getDescription());
819     TypeToResolve->refineAbstractTypeTo(Ty);
820   }
821
822   return Ty;
823 }
824
825
826 // common code from the two 'RunVMAsmParser' functions
827  static Module * RunParser(Module * M) {
828
829   llvmAsmlineno = 1;      // Reset the current line number...
830   ObsoleteVarArgs = false;
831   NewVarArgs = false;
832
833   CurModule.CurrentModule = M;
834   yyparse();       // Parse the file, potentially throwing exception
835
836   Module *Result = ParserResult;
837   ParserResult = 0;
838
839   //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
840   {
841     Function* F;
842     if ((F = Result->getNamedFunction("llvm.va_start"))
843         && F->getFunctionType()->getNumParams() == 0)
844       ObsoleteVarArgs = true;
845     if((F = Result->getNamedFunction("llvm.va_copy"))
846        && F->getFunctionType()->getNumParams() == 1)
847       ObsoleteVarArgs = true;
848   }
849
850   if (ObsoleteVarArgs && NewVarArgs)
851     ThrowException("This file is corrupt: it uses both new and old style varargs");
852
853   if(ObsoleteVarArgs) {
854     if(Function* F = Result->getNamedFunction("llvm.va_start")) {
855       if (F->arg_size() != 0)
856         ThrowException("Obsolete va_start takes 0 argument!");
857       
858       //foo = va_start()
859       // ->
860       //bar = alloca typeof(foo)
861       //va_start(bar)
862       //foo = load bar
863
864       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
865       const Type* ArgTy = F->getFunctionType()->getReturnType();
866       const Type* ArgTyPtr = PointerType::get(ArgTy);
867       Function* NF = Result->getOrInsertFunction("llvm.va_start", 
868                                                  RetTy, ArgTyPtr, (Type *)0);
869
870       while (!F->use_empty()) {
871         CallInst* CI = cast<CallInst>(F->use_back());
872         AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
873         new CallInst(NF, bar, "", CI);
874         Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
875         CI->replaceAllUsesWith(foo);
876         CI->getParent()->getInstList().erase(CI);
877       }
878       Result->getFunctionList().erase(F);
879     }
880     
881     if(Function* F = Result->getNamedFunction("llvm.va_end")) {
882       if(F->arg_size() != 1)
883         ThrowException("Obsolete va_end takes 1 argument!");
884
885       //vaend foo
886       // ->
887       //bar = alloca 1 of typeof(foo)
888       //vaend bar
889       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
890       const Type* ArgTy = F->getFunctionType()->getParamType(0);
891       const Type* ArgTyPtr = PointerType::get(ArgTy);
892       Function* NF = Result->getOrInsertFunction("llvm.va_end", 
893                                                  RetTy, ArgTyPtr, (Type *)0);
894
895       while (!F->use_empty()) {
896         CallInst* CI = cast<CallInst>(F->use_back());
897         AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
898         new StoreInst(CI->getOperand(1), bar, CI);
899         new CallInst(NF, bar, "", CI);
900         CI->getParent()->getInstList().erase(CI);
901       }
902       Result->getFunctionList().erase(F);
903     }
904
905     if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
906       if(F->arg_size() != 1)
907         ThrowException("Obsolete va_copy takes 1 argument!");
908       //foo = vacopy(bar)
909       // ->
910       //a = alloca 1 of typeof(foo)
911       //b = alloca 1 of typeof(foo)
912       //store bar -> b
913       //vacopy(a, b)
914       //foo = load a
915       
916       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
917       const Type* ArgTy = F->getFunctionType()->getReturnType();
918       const Type* ArgTyPtr = PointerType::get(ArgTy);
919       Function* NF = Result->getOrInsertFunction("llvm.va_copy", 
920                                                  RetTy, ArgTyPtr, ArgTyPtr,
921                                                  (Type *)0);
922
923       while (!F->use_empty()) {
924         CallInst* CI = cast<CallInst>(F->use_back());
925         AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
926         AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
927         new StoreInst(CI->getOperand(1), b, CI);
928         new CallInst(NF, a, b, "", CI);
929         Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
930         CI->replaceAllUsesWith(foo);
931         CI->getParent()->getInstList().erase(CI);
932       }
933       Result->getFunctionList().erase(F);
934     }
935   }
936
937   return Result;
938
939  }
940
941 //===----------------------------------------------------------------------===//
942 //            RunVMAsmParser - Define an interface to this parser
943 //===----------------------------------------------------------------------===//
944 //
945 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
946   set_scan_file(F);
947
948   CurFilename = Filename;
949   return RunParser(new Module(CurFilename));
950 }
951
952 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
953   set_scan_string(AsmString);
954
955   CurFilename = "from_memory";
956   if (M == NULL) {
957     return RunParser(new Module (CurFilename));
958   } else {
959     return RunParser(M);
960   }
961 }
962
963
964 #line 870 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
965 typedef union {
966   llvm::Module                           *ModuleVal;
967   llvm::Function                         *FunctionVal;
968   std::pair<llvm::PATypeHolder*, char*>  *ArgVal;
969   llvm::BasicBlock                       *BasicBlockVal;
970   llvm::TerminatorInst                   *TermInstVal;
971   llvm::Instruction                      *InstVal;
972   llvm::Constant                         *ConstVal;
973
974   const llvm::Type                       *PrimType;
975   llvm::PATypeHolder                     *TypeVal;
976   llvm::Value                            *ValueVal;
977
978   std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
979   std::vector<llvm::Value*>              *ValueList;
980   std::list<llvm::PATypeHolder>          *TypeList;
981   // Represent the RHS of PHI node
982   std::list<std::pair<llvm::Value*,
983                       llvm::BasicBlock*> > *PHIList;
984   std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
985   std::vector<llvm::Constant*>           *ConstVector;
986
987   llvm::GlobalValue::LinkageTypes         Linkage;
988   int64_t                           SInt64Val;
989   uint64_t                          UInt64Val;
990   int                               SIntVal;
991   unsigned                          UIntVal;
992   double                            FPVal;
993   bool                              BoolVal;
994
995   char                             *StrVal;   // This memory is strdup'd!
996   llvm::ValID                             ValIDVal; // strdup'd memory maybe!
997
998   llvm::Instruction::BinaryOps            BinaryOpVal;
999   llvm::Instruction::TermOps              TermOpVal;
1000   llvm::Instruction::MemoryOps            MemOpVal;
1001   llvm::Instruction::OtherOps             OtherOpVal;
1002   llvm::Module::Endianness                Endianness;
1003 } YYSTYPE;
1004 #include <stdio.h>
1005
1006 #ifndef __cplusplus
1007 #ifndef __STDC__
1008 #define const
1009 #endif
1010 #endif
1011
1012
1013
1014 #define YYFINAL         443
1015 #define YYFLAG          -32768
1016 #define YYNTBASE        110
1017
1018 #define YYTRANSLATE(x) ((unsigned)(x) <= 349 ? yytranslate[x] : 179)
1019
1020 static const char yytranslate[] = {     0,
1021      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1022      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1023      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1024      2,     2,     2,     2,     2,     2,     2,     2,     2,    99,
1025    100,   108,     2,    97,     2,     2,     2,     2,     2,     2,
1026      2,     2,     2,     2,     2,     2,     2,     2,     2,   104,
1027     96,   105,     2,     2,     2,     2,     2,     2,     2,     2,
1028      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1029      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1030    101,    98,   103,     2,     2,     2,     2,     2,   109,     2,
1031      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1032      2,     2,     2,     2,     2,     2,     2,     2,     2,   102,
1033      2,     2,   106,     2,   107,     2,     2,     2,     2,     2,
1034      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1035      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1036      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1037      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1038      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1039      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1040      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1041      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1042      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1043      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1044      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1045      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1046      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
1047      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
1048     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
1049     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
1050     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
1051     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
1052     57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
1053     67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
1054     77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
1055     87,    88,    89,    90,    91,    92,    93,    94,    95
1056 };
1057
1058 #if YYDEBUG != 0
1059 static const short yyprhs[] = {     0,
1060      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
1061     20,    22,    24,    26,    28,    30,    32,    34,    36,    38,
1062     40,    42,    44,    46,    48,    50,    52,    54,    56,    58,
1063     60,    62,    64,    67,    68,    70,    72,    74,    76,    77,
1064     78,    80,    82,    84,    87,    88,    91,    92,    96,    99,
1065    100,   102,   103,   107,   109,   112,   114,   116,   118,   120,
1066    122,   124,   126,   128,   130,   132,   134,   136,   138,   140,
1067    142,   144,   146,   148,   150,   152,   154,   157,   162,   168,
1068    174,   178,   181,   184,   186,   190,   192,   196,   198,   199,
1069    204,   208,   212,   217,   222,   226,   229,   232,   235,   238,
1070    241,   244,   247,   250,   253,   256,   263,   269,   278,   285,
1071    292,   299,   306,   310,   312,   314,   316,   318,   321,   324,
1072    327,   329,   334,   337,   338,   346,   347,   355,   359,   364,
1073    365,   367,   369,   373,   377,   381,   385,   389,   391,   392,
1074    394,   396,   398,   399,   402,   406,   408,   410,   414,   416,
1075    417,   426,   428,   430,   434,   436,   438,   441,   442,   446,
1076    448,   450,   452,   454,   456,   458,   460,   464,   466,   468,
1077    470,   472,   474,   477,   480,   483,   487,   490,   491,   493,
1078    496,   499,   503,   513,   523,   532,   546,   548,   550,   557,
1079    563,   566,   573,   581,   583,   587,   589,   590,   593,   595,
1080    601,   607,   613,   616,   621,   626,   633,   638,   643,   648,
1081    651,   659,   661,   664,   665,   667,   668,   672,   679,   683,
1082    690,   693,   698,   705
1083 };
1084
1085 static const short yyrhs[] = {     5,
1086      0,     6,     0,     3,     0,     4,     0,    68,     0,    69,
1087      0,    70,     0,    71,     0,    72,     0,    73,     0,    74,
1088      0,    75,     0,    76,     0,    77,     0,    78,     0,    79,
1089      0,    80,     0,    81,     0,    91,     0,    92,     0,    16,
1090      0,    14,     0,    12,     0,    10,     0,    17,     0,    15,
1091      0,    13,     0,    11,     0,   116,     0,   117,     0,    18,
1092      0,    19,     0,   149,    96,     0,     0,    41,     0,    42,
1093      0,    43,     0,    44,     0,     0,     0,    59,     0,    60,
1094      0,    61,     0,    58,     4,     0,     0,    54,     4,     0,
1095      0,    97,    54,     4,     0,    34,    24,     0,     0,   125,
1096      0,     0,    97,   128,   127,     0,   125,     0,    54,     4,
1097      0,   131,     0,     8,     0,   133,     0,     8,     0,   133,
1098      0,     9,     0,    10,     0,    11,     0,    12,     0,    13,
1099      0,    14,     0,    15,     0,    16,     0,    17,     0,    18,
1100      0,    19,     0,    20,     0,    21,     0,    45,     0,   132,
1101      0,   162,     0,    98,     4,     0,   130,    99,   135,   100,
1102      0,   101,     4,   102,   133,   103,     0,   104,     4,   102,
1103    133,   105,     0,   106,   134,   107,     0,   106,   107,     0,
1104    133,   108,     0,   133,     0,   134,    97,   133,     0,   134,
1105      0,   134,    97,    37,     0,    37,     0,     0,   131,   101,
1106    138,   103,     0,   131,   101,   103,     0,   131,   109,    24,
1107      0,   131,   104,   138,   105,     0,   131,   106,   138,   107,
1108      0,   131,   106,   107,     0,   131,    38,     0,   131,    39,
1109      0,   131,   162,     0,   131,   137,     0,   131,    26,     0,
1110    116,   111,     0,   117,     4,     0,     9,    27,     0,     9,
1111     28,     0,   119,     7,     0,    89,    99,   136,    36,   131,
1112    100,     0,    87,    99,   136,   176,   100,     0,    90,    99,
1113    136,    97,   136,    97,   136,   100,     0,   112,    99,   136,
1114     97,   136,   100,     0,   113,    99,   136,    97,   136,   100,
1115      0,   114,    99,   136,    97,   136,   100,     0,   115,    99,
1116    136,    97,   136,   100,     0,   138,    97,   136,     0,   136,
1117      0,    32,     0,    33,     0,   141,     0,   141,   158,     0,
1118    141,   159,     0,   141,    25,     0,   142,     0,   142,   120,
1119     20,   129,     0,   142,   159,     0,     0,   142,   120,   121,
1120    139,   136,   143,   127,     0,     0,   142,   120,    47,   139,
1121    131,   144,   127,     0,   142,    48,   146,     0,   142,    55,
1122     96,   147,     0,     0,    53,     0,    52,     0,    50,    96,
1123    145,     0,    51,    96,     4,     0,    49,    96,    24,     0,
1124    101,   148,   103,     0,   148,    97,    24,     0,    24,     0,
1125      0,    22,     0,    24,     0,   149,     0,     0,   131,   150,
1126      0,   152,    97,   151,     0,   151,     0,   152,     0,   152,
1127     97,    37,     0,    37,     0,     0,   122,   129,   149,    99,
1128    153,   100,   126,   123,     0,    29,     0,   106,     0,   121,
1129    154,   155,     0,    30,     0,   107,     0,   165,   157,     0,
1130      0,    31,   160,   154,     0,     3,     0,     4,     0,     7,
1131      0,    27,     0,    28,     0,    38,     0,    39,     0,   104,
1132    138,   105,     0,   137,     0,   110,     0,   149,     0,   162,
1133      0,   161,     0,   131,   163,     0,   165,   166,     0,   156,
1134    166,     0,   167,   120,   168,     0,   167,   170,     0,     0,
1135     23,     0,    62,   164,     0,    62,     8,     0,    63,    21,
1136    163,     0,    63,     9,   163,    97,    21,   163,    97,    21,
1137    163,     0,    64,   118,   163,    97,    21,   163,   101,   169,
1138    103,     0,    64,   118,   163,    97,    21,   163,   101,   103,
1139      0,    65,   122,   129,   163,    99,   173,   100,    36,    21,
1140    163,    66,    21,   163,     0,    66,     0,    67,     0,   169,
1141    118,   161,    97,    21,   163,     0,   118,   161,    97,    21,
1142    163,     0,   120,   175,     0,   131,   101,   163,    97,   163,
1143    103,     0,   171,    97,   101,   163,    97,   163,   103,     0,
1144    164,     0,   172,    97,   164,     0,   172,     0,     0,    57,
1145     56,     0,    56,     0,   112,   131,   163,    97,   163,     0,
1146    113,   131,   163,    97,   163,     0,   114,   131,   163,    97,
1147    163,     0,    46,   164,     0,   115,   164,    97,   164,     0,
1148     89,   164,    36,   131,     0,    90,   164,    97,   164,    97,
1149    164,     0,    93,   164,    97,   131,     0,    94,   164,    97,
1150    131,     0,    95,   164,    97,   131,     0,    88,   171,     0,
1151    174,   122,   129,   163,    99,   173,   100,     0,   178,     0,
1152     97,   172,     0,     0,    35,     0,     0,    82,   131,   124,
1153      0,    82,   131,    97,    15,   163,   124,     0,    83,   131,
1154    124,     0,    83,   131,    97,    15,   163,   124,     0,    84,
1155    164,     0,   177,    85,   131,   163,     0,   177,    86,   164,
1156     97,   131,   163,     0,    87,   131,   163,   176,     0
1157 };
1158
1159 #endif
1160
1161 #if YYDEBUG != 0
1162 static const short yyrline[] = { 0,
1163    988,   989,   996,   997,  1006,  1006,  1006,  1006,  1006,  1007,
1164   1007,  1007,  1008,  1008,  1008,  1008,  1008,  1008,  1010,  1010,
1165   1014,  1014,  1014,  1014,  1015,  1015,  1015,  1015,  1016,  1016,
1166   1017,  1017,  1020,  1023,  1027,  1027,  1028,  1029,  1030,  1033,
1167   1033,  1034,  1035,  1036,  1045,  1045,  1051,  1051,  1059,  1066,
1168   1066,  1072,  1072,  1074,  1078,  1089,  1089,  1090,  1090,  1092,
1169   1101,  1101,  1101,  1101,  1101,  1101,  1101,  1102,  1102,  1102,
1170   1102,  1102,  1102,  1103,  1106,  1109,  1115,  1122,  1134,  1138,
1171   1149,  1158,  1161,  1169,  1173,  1178,  1179,  1182,  1185,  1195,
1172   1220,  1233,  1261,  1286,  1306,  1318,  1327,  1331,  1390,  1396,
1173   1404,  1409,  1414,  1417,  1420,  1427,  1437,  1468,  1475,  1496,
1174   1503,  1508,  1518,  1521,  1528,  1528,  1538,  1545,  1549,  1552,
1175   1555,  1568,  1588,  1590,  1593,  1596,  1600,  1603,  1605,  1607,
1176   1612,  1613,  1615,  1618,  1626,  1631,  1633,  1637,  1641,  1649,
1177   1649,  1650,  1650,  1652,  1658,  1663,  1669,  1672,  1677,  1681,
1178   1685,  1771,  1771,  1773,  1781,  1781,  1783,  1787,  1787,  1796,
1179   1799,  1802,  1805,  1808,  1811,  1814,  1817,  1841,  1848,  1851,
1180   1856,  1856,  1862,  1866,  1869,  1877,  1886,  1890,  1900,  1911,
1181   1914,  1917,  1920,  1923,  1937,  1941,  1994,  1997,  2003,  2011,
1182   2021,  2028,  2033,  2040,  2044,  2050,  2050,  2052,  2055,  2061,
1183   2073,  2081,  2091,  2103,  2110,  2117,  2124,  2129,  2148,  2170,
1184   2184,  2241,  2247,  2249,  2253,  2256,  2262,  2266,  2270,  2274,
1185   2278,  2285,  2295,  2308
1186 };
1187 #endif
1188
1189
1190 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1191
1192 static const char * const yytname[] = {   "$","error","$undefined.","ESINT64VAL",
1193 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1194 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1195 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1196 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1197 "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1198 "OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
1199 "BIG","ALIGN","DEPLIBS","CALL","TAIL","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK",
1200 "RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV",
1201 "REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC",
1202 "ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL",
1203 "SHR","VAARG","VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['",
1204 "'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps",
1205 "LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType",
1206 "OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString",
1207 "OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV",
1208 "Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1209 "ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","BigOrLittle",
1210 "TargetDefinition","LibrariesDefinition","LibList","Name","OptName","ArgVal",
1211 "ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END","Function",
1212 "FunctionProto","@3","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1213 "BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1214 "Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList",
1215 "OptVolatile","MemoryInst", NULL
1216 };
1217 #endif
1218
1219 static const short yyr1[] = {     0,
1220    110,   110,   111,   111,   112,   112,   112,   112,   112,   113,
1221    113,   113,   114,   114,   114,   114,   114,   114,   115,   115,
1222    116,   116,   116,   116,   117,   117,   117,   117,   118,   118,
1223    119,   119,   120,   120,   121,   121,   121,   121,   121,   122,
1224    122,   122,   122,   122,   123,   123,   124,   124,   125,   126,
1225    126,   127,   127,   128,   128,   129,   129,   130,   130,   131,
1226    132,   132,   132,   132,   132,   132,   132,   132,   132,   132,
1227    132,   132,   132,   133,   133,   133,   133,   133,   133,   133,
1228    133,   133,   133,   134,   134,   135,   135,   135,   135,   136,
1229    136,   136,   136,   136,   136,   136,   136,   136,   136,   136,
1230    136,   136,   136,   136,   136,   137,   137,   137,   137,   137,
1231    137,   137,   138,   138,   139,   139,   140,   141,   141,   141,
1232    141,   142,   142,   143,   142,   144,   142,   142,   142,   142,
1233    145,   145,   146,   146,   146,   147,   148,   148,   148,   149,
1234    149,   150,   150,   151,   152,   152,   153,   153,   153,   153,
1235    154,   155,   155,   156,   157,   157,   158,   160,   159,   161,
1236    161,   161,   161,   161,   161,   161,   161,   161,   162,   162,
1237    163,   163,   164,   165,   165,   166,   167,   167,   167,   168,
1238    168,   168,   168,   168,   168,   168,   168,   168,   169,   169,
1239    170,   171,   171,   172,   172,   173,   173,   174,   174,   175,
1240    175,   175,   175,   175,   175,   175,   175,   175,   175,   175,
1241    175,   175,   176,   176,   177,   177,   178,   178,   178,   178,
1242    178,   178,   178,   178
1243 };
1244
1245 static const short yyr2[] = {     0,
1246      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1247      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1248      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1249      1,     1,     2,     0,     1,     1,     1,     1,     0,     0,
1250      1,     1,     1,     2,     0,     2,     0,     3,     2,     0,
1251      1,     0,     3,     1,     2,     1,     1,     1,     1,     1,
1252      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1253      1,     1,     1,     1,     1,     1,     2,     4,     5,     5,
1254      3,     2,     2,     1,     3,     1,     3,     1,     0,     4,
1255      3,     3,     4,     4,     3,     2,     2,     2,     2,     2,
1256      2,     2,     2,     2,     2,     6,     5,     8,     6,     6,
1257      6,     6,     3,     1,     1,     1,     1,     2,     2,     2,
1258      1,     4,     2,     0,     7,     0,     7,     3,     4,     0,
1259      1,     1,     3,     3,     3,     3,     3,     1,     0,     1,
1260      1,     1,     0,     2,     3,     1,     1,     3,     1,     0,
1261      8,     1,     1,     3,     1,     1,     2,     0,     3,     1,
1262      1,     1,     1,     1,     1,     1,     3,     1,     1,     1,
1263      1,     1,     2,     2,     2,     3,     2,     0,     1,     2,
1264      2,     3,     9,     9,     8,    13,     1,     1,     6,     5,
1265      2,     6,     7,     1,     3,     1,     0,     2,     1,     5,
1266      5,     5,     2,     4,     4,     6,     4,     4,     4,     2,
1267      7,     1,     2,     0,     1,     0,     3,     6,     3,     6,
1268      2,     4,     6,     4
1269 };
1270
1271 static const short yydefact[] = {   130,
1272     39,   121,   120,   158,    35,    36,    37,    38,    40,   178,
1273    118,   119,   178,   140,   141,     0,     0,    39,     0,   123,
1274     40,     0,    41,    42,    43,     0,     0,   179,   175,    34,
1275    155,   156,   157,   174,     0,     0,     0,   128,     0,     0,
1276      0,     0,    33,   159,    44,     1,     2,    57,    61,    62,
1277     63,    64,    65,    66,    67,    68,    69,    70,    71,    72,
1278     73,    74,     0,     0,     0,     0,   169,     0,     0,    56,
1279     75,    60,   170,    76,   152,   153,   154,   216,   177,     0,
1280      0,     0,   139,   129,   122,   115,   116,     0,     0,    77,
1281      0,     0,    59,    82,    84,     0,     0,    89,    83,   215,
1282      0,   199,     0,     0,     0,     0,    40,   187,   188,     5,
1283      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
1284     16,    17,    18,     0,     0,     0,     0,     0,     0,     0,
1285     19,    20,     0,     0,     0,     0,     0,     0,     0,   176,
1286     40,   191,     0,   212,   135,   132,   131,   133,   134,   138,
1287      0,   126,    61,    62,    63,    64,    65,    66,    67,    68,
1288     69,    70,    71,     0,     0,     0,     0,   124,     0,     0,
1289      0,    81,   150,    88,    86,     0,     0,   203,   198,   181,
1290    180,     0,     0,    24,    28,    23,    27,    22,    26,    21,
1291     25,    29,    30,     0,     0,    47,    47,   221,     0,     0,
1292    210,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1293      0,     0,     0,     0,   136,    52,   103,   104,     3,     4,
1294    101,   102,   105,   100,    96,    97,     0,     0,     0,     0,
1295      0,     0,     0,     0,     0,     0,     0,    99,    98,    52,
1296     58,    58,    85,   149,   143,   146,   147,     0,     0,    78,
1297    160,   161,   162,   163,   164,   165,   166,     0,   168,   172,
1298    171,   173,     0,   182,     0,     0,     0,   217,     0,   219,
1299    214,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1300      0,     0,     0,     0,     0,   137,     0,   127,     0,     0,
1301      0,    91,   114,     0,     0,    95,     0,    92,     0,     0,
1302      0,     0,   125,    79,    80,   142,   144,     0,    50,    87,
1303      0,     0,     0,     0,     0,     0,     0,     0,   224,     0,
1304      0,   205,     0,   207,   208,   209,     0,     0,     0,   204,
1305      0,   222,     0,     0,     0,    54,    52,   214,     0,     0,
1306      0,    90,    93,    94,     0,     0,     0,     0,   148,   145,
1307     51,    45,   167,     0,     0,   197,    47,    48,    47,   194,
1308    213,     0,     0,     0,   200,   201,   202,   197,     0,    49,
1309     55,    53,     0,     0,     0,   113,     0,     0,     0,     0,
1310      0,   151,     0,     0,   196,     0,     0,   218,   220,     0,
1311      0,     0,   206,     0,   223,   107,     0,     0,     0,     0,
1312      0,     0,    46,     0,     0,     0,   195,   192,     0,   211,
1313    106,     0,   109,   110,   111,   112,     0,   185,     0,     0,
1314      0,   193,     0,   183,     0,   184,     0,     0,   108,     0,
1315      0,     0,     0,     0,     0,   190,     0,     0,   189,   186,
1316      0,     0,     0
1317 };
1318
1319 static const short yydefgoto[] = {    67,
1320    221,   234,   235,   236,   237,   164,   165,   194,   166,    18,
1321      9,    26,   382,   268,   336,   352,   288,   337,    68,    69,
1322    167,    71,    72,    96,   176,   293,   259,   294,    88,   441,
1323      1,     2,   240,   216,   148,    38,    84,   151,    73,   307,
1324    246,   247,   248,    27,    77,    10,    33,    11,    12,    21,
1325    260,    74,   262,   360,    13,    29,    30,   140,   420,    79,
1326    201,   385,   386,   141,   142,   319,   143,   144
1327 };
1328
1329 static const short yypact[] = {-32768,
1330     43,   303,-32768,-32768,-32768,-32768,-32768,-32768,    71,    -3,
1331 -32768,-32768,    34,-32768,-32768,    86,   -30,    47,   -19,-32768,
1332     71,    76,-32768,-32768,-32768,   994,   -25,-32768,-32768,    -6,
1333 -32768,-32768,-32768,-32768,   -14,    26,    37,-32768,    49,   994,
1334     -1,    -1,-32768,-32768,-32768,-32768,-32768,    -4,-32768,-32768,
1335 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1336 -32768,-32768,   134,   153,   157,   511,-32768,    -6,    63,-32768,
1337 -32768,   -16,-32768,-32768,-32768,-32768,-32768,  1109,-32768,   139,
1338     -5,   163,   144,-32768,-32768,-32768,-32768,  1014,  1058,-32768,
1339     68,    69,-32768,-32768,   -16,   -90,    73,   751,-32768,-32768,
1340   1014,-32768,   120,  1116,    51,   186,    71,-32768,-32768,-32768,
1341 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1342 -32768,-32768,-32768,  1014,  1014,  1014,  1014,  1014,  1014,  1014,
1343 -32768,-32768,  1014,  1014,  1014,  1014,  1014,  1014,  1014,-32768,
1344     71,-32768,   -15,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1345     22,-32768,   116,   142,   173,   145,   174,   149,   175,   151,
1346    176,   177,   181,   156,   179,   183,   409,-32768,  1014,  1014,
1347   1014,-32768,   789,-32768,    84,    91,   575,-32768,-32768,    -4,
1348 -32768,   575,   575,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1349 -32768,-32768,-32768,   575,   994,    95,    96,-32768,   575,    93,
1350    107,   172,   112,   113,   114,   115,   575,   575,   575,   117,
1351    994,  1014,  1014,   189,-32768,   122,-32768,-32768,-32768,-32768,
1352 -32768,-32768,-32768,-32768,-32768,-32768,   123,   125,   126,   853,
1353   1058,   531,   202,   128,   129,   131,   132,-32768,-32768,   122,
1354     20,   -12,   -16,-32768,    -6,-32768,   136,   135,   891,-32768,
1355 -32768,-32768,-32768,-32768,-32768,-32768,-32768,  1058,-32768,-32768,
1356 -32768,-32768,   137,-32768,   141,   575,    -9,-32768,     4,-32768,
1357    146,   575,   138,  1014,  1014,  1014,  1014,  1014,   147,   158,
1358    161,  1014,   575,   575,   162,-32768,     5,-32768,  1058,  1058,
1359   1058,-32768,-32768,    24,   -32,-32768,   -28,-32768,  1058,  1058,
1360   1058,  1058,-32768,-32768,-32768,-32768,-32768,   956,   208,-32768,
1361      0,   215,   233,   164,   575,   256,   575,  1014,-32768,   165,
1362    575,-32768,   167,-32768,-32768,-32768,   575,   575,   575,-32768,
1363    166,-32768,  1014,   237,   262,-32768,   122,   146,   231,   171,
1364   1058,-32768,-32768,-32768,   178,   180,   182,   184,-32768,-32768,
1365 -32768,   216,-32768,   575,   575,  1014,   190,-32768,   190,-32768,
1366    191,   575,   192,  1014,-32768,-32768,-32768,  1014,   575,-32768,
1367 -32768,-32768,   169,  1014,  1058,-32768,  1058,  1058,  1058,  1058,
1368    269,-32768,   193,   197,   191,   199,   222,-32768,-32768,  1014,
1369    200,   575,-32768,   205,-32768,-32768,   206,   211,   209,   213,
1370    214,   217,-32768,   259,    11,   247,-32768,-32768,   221,-32768,
1371 -32768,  1058,-32768,-32768,-32768,-32768,   575,-32768,   654,    39,
1372    281,-32768,   218,-32768,   223,-32768,   654,   575,-32768,   308,
1373    234,   266,   575,   312,   316,-32768,   575,   575,-32768,-32768,
1374    339,   340,-32768
1375 };
1376
1377 static const short yypgoto[] = {-32768,
1378 -32768,   263,   265,   274,   276,  -105,  -104,  -390,-32768,   326,
1379    342,   -78,-32768,  -184,    48,-32768,  -231,-32768,   -37,-32768,
1380    -26,-32768,   -54,   264,-32768,   -84,   194,  -197,   321,-32768,
1381 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,     8,-32768,
1382     60,-32768,-32768,   348,-32768,-32768,-32768,-32768,   368,-32768,
1383   -301,   -43,    38,   -93,-32768,   358,-32768,-32768,-32768,-32768,
1384 -32768,    54,     7,-32768,-32768,    35,-32768,-32768
1385 };
1386
1387
1388 #define YYLAST          1222
1389
1390
1391 static const short yytable[] = {    70,
1392    192,   193,    85,    75,   168,   315,   171,   178,   303,    19,
1393    181,    95,   270,    70,   419,    14,   172,    15,   317,    28,
1394    184,   185,   186,   187,   188,   189,   190,   191,   195,   427,
1395     86,    87,   198,   295,   297,   202,   203,    19,   334,   204,
1396    205,   206,  -117,    95,   316,   210,   146,   147,   184,   185,
1397    186,   187,   188,   189,   190,   191,    28,   316,   335,   182,
1398    311,   152,   211,    31,   341,    39,    40,     3,   341,   212,
1399    213,   183,   343,     4,   177,    97,    43,   177,   344,    45,
1400     76,    80,   -58,     5,     6,     7,     8,     5,     6,     7,
1401      8,    99,   305,    41,   -59,    99,   341,   196,   197,   177,
1402    199,   200,   177,   177,   353,   372,   177,   177,   177,   207,
1403    208,   209,   177,   418,   241,   242,   243,   425,   214,   285,
1404    341,    81,   304,   239,   215,   431,   342,    99,    22,    23,
1405     24,    25,    82,   261,    35,    36,    37,    90,   261,   261,
1406     32,   426,   217,   218,   -24,   -24,   245,   -23,   -23,    83,
1407    261,   -22,   -22,   -21,   -21,   261,    91,   266,   219,   220,
1408     92,    98,   145,   261,   261,   261,   149,   150,    70,   169,
1409    170,   173,   388,   283,   389,   179,   -28,   -27,   -26,   -25,
1410    249,   323,   222,   -31,    70,   284,   177,   -32,   330,   223,
1411    250,   267,   269,   272,   243,   184,   185,   186,   187,   188,
1412    189,   190,   191,   273,   338,   339,   340,   274,   275,   276,
1413    277,   278,   286,   282,   345,   346,   347,   348,   287,   263,
1414    264,   289,   261,   290,   291,   298,   299,   300,   261,   301,
1415    302,   265,   308,   312,   309,   354,   271,   313,   321,   261,
1416    261,   334,   318,   327,   279,   280,   281,   322,   177,   324,
1417    325,   326,   306,   355,   328,   177,   376,   329,   333,   358,
1418    370,   362,   356,   364,   368,   371,   374,   375,   396,   381,
1419    393,   261,   403,   261,   377,   316,   378,   261,   379,   417,
1420    380,   245,   421,   261,   261,   261,   387,   390,   392,   404,
1421    398,   177,   399,   400,   401,   402,   407,   405,   406,   192,
1422    193,   428,   408,   314,   410,   411,   369,   412,   413,   320,
1423    261,   261,   414,   415,   192,   193,   416,   429,   261,   430,
1424    331,   332,   -34,   422,    14,   261,    15,   423,   433,   177,
1425    434,   435,   437,     4,   -34,   -34,   438,   177,   442,   443,
1426    136,   177,   137,   -34,   -34,   -34,   -34,   397,   261,   -34,
1427     16,   138,   357,   139,   359,    78,   351,    17,   363,    42,
1428    238,   175,    89,   177,   365,   366,   367,   350,    44,    20,
1429     34,   361,   373,   261,   394,     0,     0,     0,     0,     0,
1430      0,     0,     0,     0,   261,     0,     0,     0,     0,   261,
1431      0,   383,   384,   261,   261,     0,     0,     0,     0,   391,
1432      0,     0,     0,     0,     0,     0,   395,     0,     0,     0,
1433      0,     0,     0,    46,    47,     0,     0,     0,     0,     0,
1434      0,     0,     0,     0,     0,     0,     0,     0,     0,   409,
1435     14,     0,    15,     0,   224,     0,     0,     0,     0,     0,
1436      0,     0,     0,     0,     0,     0,   225,   226,     0,     0,
1437      0,     0,     0,     0,   424,     0,     0,     0,     0,     0,
1438      0,     0,     0,     0,     0,   432,     0,     0,     0,     0,
1439    436,     0,     0,     0,   439,   440,   110,   111,   112,   113,
1440    114,   115,   116,   117,   118,   119,   120,   121,   122,   123,
1441      0,     0,     0,     0,     0,   227,     0,   228,   229,   131,
1442    132,     0,     0,     0,     0,     0,     0,     0,     0,   230,
1443      0,     0,   231,     0,   232,    46,    47,   233,    93,    49,
1444     50,    51,    52,    53,    54,    55,    56,    57,    58,    59,
1445     60,    61,    14,     0,    15,    46,    47,     0,    93,   153,
1446    154,   155,   156,   157,   158,   159,   160,   161,   162,   163,
1447     60,    61,    14,     0,    15,    62,     0,     0,     0,     0,
1448      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1449      0,     0,     0,     0,     0,    62,     0,   251,   252,    46,
1450     47,   253,     0,     0,     0,     0,     0,     0,     0,     0,
1451      0,     0,     0,     0,     0,     0,    14,     0,    15,     0,
1452      0,   254,   255,     0,     0,     0,     0,     0,    63,     0,
1453      0,    64,   256,   257,    65,     0,    66,    94,     0,     0,
1454      0,     0,     0,     0,     0,     0,     0,     0,    63,     0,
1455      0,    64,     0,     0,    65,     0,    66,   296,     0,     0,
1456      0,     0,   110,   111,   112,   113,   114,   115,   116,   117,
1457    118,   119,   120,   121,   122,   123,   251,   252,     0,     0,
1458    253,   227,     0,   228,   229,   131,   132,     0,     0,     0,
1459      0,     0,     0,     0,     0,     0,     0,     0,   258,     0,
1460    254,   255,     0,     0,     0,     0,     0,     0,     0,     0,
1461      0,   256,   257,     0,     0,     0,     0,     0,     0,     0,
1462      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1463      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1464      0,   110,   111,   112,   113,   114,   115,   116,   117,   118,
1465    119,   120,   121,   122,   123,     0,     0,     0,     0,     0,
1466    227,     0,   228,   229,   131,   132,     0,     0,     0,     0,
1467      0,     0,     0,     0,     0,    46,    47,   258,    93,    49,
1468     50,    51,    52,    53,    54,    55,    56,    57,    58,    59,
1469     60,    61,    14,     0,    15,     0,     0,     0,     0,     0,
1470      0,     0,     0,     0,     0,     0,     0,   174,     0,     0,
1471      0,     0,     0,    46,    47,    62,    93,    49,    50,    51,
1472     52,    53,    54,    55,    56,    57,    58,    59,    60,    61,
1473     14,     0,    15,     0,     0,     0,     0,     0,     0,     0,
1474      0,     0,     0,     0,     0,   244,     0,     0,     0,     0,
1475      0,     0,     0,    62,     0,     0,     0,     0,     0,     0,
1476      0,     0,     0,     0,     0,     0,     0,     0,    63,     0,
1477      0,    64,     0,     0,    65,     0,    66,    46,    47,     0,
1478     93,   153,   154,   155,   156,   157,   158,   159,   160,   161,
1479    162,   163,    60,    61,    14,     0,    15,     0,     0,     0,
1480      0,     0,     0,     0,     0,     0,    63,     0,     0,    64,
1481      0,     0,    65,     0,    66,    46,    47,    62,    93,    49,
1482     50,    51,    52,    53,    54,    55,    56,    57,    58,    59,
1483     60,    61,    14,     0,    15,     0,     0,     0,     0,     0,
1484      0,     0,     0,     0,     0,     0,     0,   310,     0,     0,
1485      0,     0,     0,     0,     0,    62,     0,     0,     0,     0,
1486      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1487     63,     0,     0,    64,     0,   292,    65,     0,    66,     0,
1488     46,    47,     0,    93,    49,    50,    51,    52,    53,    54,
1489     55,    56,    57,    58,    59,    60,    61,    14,     0,    15,
1490      0,     0,     0,     0,     0,     0,     0,     0,    63,     0,
1491      0,    64,   349,     0,    65,     0,    66,     0,    46,    47,
1492     62,    48,    49,    50,    51,    52,    53,    54,    55,    56,
1493     57,    58,    59,    60,    61,    14,     0,    15,    46,    47,
1494      0,    93,    49,    50,    51,    52,    53,    54,    55,    56,
1495     57,    58,    59,    60,    61,    14,     0,    15,    62,     0,
1496      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1497      0,     0,     0,    63,     0,     0,    64,     0,    62,    65,
1498      0,    66,    46,    47,     0,    93,   153,   154,   155,   156,
1499    157,   158,   159,   160,   161,   162,   163,    60,    61,    14,
1500      0,    15,     0,     0,     0,     0,     0,     0,     0,     0,
1501      0,    63,     0,     0,    64,     0,     0,    65,     0,    66,
1502      0,     0,    62,     0,     0,     0,     0,     0,     0,     0,
1503      0,    63,     0,     0,    64,     0,     0,    65,     0,    66,
1504     46,    47,     0,   180,    49,    50,    51,    52,    53,    54,
1505     55,    56,    57,    58,    59,    60,    61,    14,     0,    15,
1506      0,     0,     0,   100,     0,     0,     0,     0,     0,     0,
1507      0,     0,     0,     0,   101,    63,     0,     0,    64,     0,
1508     62,    65,     0,    66,   102,   103,     0,     0,     0,     0,
1509    104,   105,   106,   107,   108,   109,   110,   111,   112,   113,
1510    114,   115,   116,   117,   118,   119,   120,   121,   122,   123,
1511    124,   125,   126,     0,     0,   127,   128,   129,   130,   131,
1512    132,   133,   134,   135,     0,     0,     0,     0,     0,     0,
1513      0,     0,     0,    63,     0,     0,    64,     0,     0,    65,
1514      0,    66
1515 };
1516
1517 static const short yycheck[] = {    26,
1518    106,   106,    40,    29,    89,    15,    97,   101,   240,     2,
1519    104,    66,   197,    40,   405,    22,   107,    24,    15,    23,
1520     10,    11,    12,    13,    14,    15,    16,    17,   107,   420,
1521     32,    33,   126,   231,   232,   129,   130,    30,    34,   133,
1522    134,   135,     0,    98,    54,   139,    52,    53,    10,    11,
1523     12,    13,    14,    15,    16,    17,    23,    54,    54,     9,
1524    258,    88,   141,    30,    97,    96,    20,    25,    97,    85,
1525     86,    21,   105,    31,   101,    68,    96,   104,   107,     4,
1526    106,    96,    99,    41,    42,    43,    44,    41,    42,    43,
1527     44,   108,   105,    47,    99,   108,    97,   124,   125,   126,
1528    127,   128,   129,   130,   105,   337,   133,   134,   135,   136,
1529    137,   138,   139,   103,   169,   170,   171,   419,    97,   213,
1530     97,    96,   103,   167,   103,   427,   103,   108,    58,    59,
1531     60,    61,    96,   177,    49,    50,    51,     4,   182,   183,
1532    107,   103,    27,    28,     3,     4,   173,     3,     4,   101,
1533    194,     3,     4,     3,     4,   199,     4,   195,     3,     4,
1534      4,    99,    24,   207,   208,   209,     4,    24,   195,   102,
1535    102,    99,   357,   211,   359,    56,     4,     4,     4,     4,
1536     97,   275,     4,     7,   211,   212,   213,     7,   282,     7,
1537    100,    97,    97,   101,   249,    10,    11,    12,    13,    14,
1538     15,    16,    17,    97,   289,   290,   291,    36,    97,    97,
1539     97,    97,    24,    97,   299,   300,   301,   302,    97,   182,
1540    183,    99,   266,    99,    99,    24,    99,    99,   272,    99,
1541     99,   194,    97,    97,   100,    21,   199,    97,   101,   283,
1542    284,    34,    97,    97,   207,   208,   209,   274,   275,   276,
1543    277,   278,   245,    21,    97,   282,   341,    97,    97,     4,
1544     24,    97,    99,    97,    99,     4,    36,    97,   100,    54,
1545    364,   315,     4,   317,    97,    54,    97,   321,    97,    21,
1546     97,   308,    36,   327,   328,   329,    97,    97,    97,    97,
1547    375,   318,   377,   378,   379,   380,   390,   101,   100,   405,
1548    405,    21,   103,   266,   100,   100,   333,    97,   100,   272,
1549    354,   355,   100,   100,   420,   420,   100,   100,   362,    97,
1550    283,   284,    20,   103,    22,   369,    24,   412,    21,   356,
1551     97,    66,    21,    31,    32,    33,    21,   364,     0,     0,
1552     78,   368,    78,    41,    42,    43,    44,   374,   392,    47,
1553     48,    78,   315,    78,   317,    30,   309,    55,   321,    18,
1554    167,    98,    42,   390,   327,   328,   329,   308,    21,     2,
1555     13,   318,   338,   417,   368,    -1,    -1,    -1,    -1,    -1,
1556     -1,    -1,    -1,    -1,   428,    -1,    -1,    -1,    -1,   433,
1557     -1,   354,   355,   437,   438,    -1,    -1,    -1,    -1,   362,
1558     -1,    -1,    -1,    -1,    -1,    -1,   369,    -1,    -1,    -1,
1559     -1,    -1,    -1,     5,     6,    -1,    -1,    -1,    -1,    -1,
1560     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   392,
1561     22,    -1,    24,    -1,    26,    -1,    -1,    -1,    -1,    -1,
1562     -1,    -1,    -1,    -1,    -1,    -1,    38,    39,    -1,    -1,
1563     -1,    -1,    -1,    -1,   417,    -1,    -1,    -1,    -1,    -1,
1564     -1,    -1,    -1,    -1,    -1,   428,    -1,    -1,    -1,    -1,
1565    433,    -1,    -1,    -1,   437,   438,    68,    69,    70,    71,
1566     72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
1567     -1,    -1,    -1,    -1,    -1,    87,    -1,    89,    90,    91,
1568     92,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   101,
1569     -1,    -1,   104,    -1,   106,     5,     6,   109,     8,     9,
1570     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
1571     20,    21,    22,    -1,    24,     5,     6,    -1,     8,     9,
1572     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
1573     20,    21,    22,    -1,    24,    45,    -1,    -1,    -1,    -1,
1574     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1575     -1,    -1,    -1,    -1,    -1,    45,    -1,     3,     4,     5,
1576      6,     7,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1577     -1,    -1,    -1,    -1,    -1,    -1,    22,    -1,    24,    -1,
1578     -1,    27,    28,    -1,    -1,    -1,    -1,    -1,    98,    -1,
1579     -1,   101,    38,    39,   104,    -1,   106,   107,    -1,    -1,
1580     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    98,    -1,
1581     -1,   101,    -1,    -1,   104,    -1,   106,   107,    -1,    -1,
1582     -1,    -1,    68,    69,    70,    71,    72,    73,    74,    75,
1583     76,    77,    78,    79,    80,    81,     3,     4,    -1,    -1,
1584      7,    87,    -1,    89,    90,    91,    92,    -1,    -1,    -1,
1585     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,
1586     27,    28,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1587     -1,    38,    39,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1588     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1589     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1590     -1,    68,    69,    70,    71,    72,    73,    74,    75,    76,
1591     77,    78,    79,    80,    81,    -1,    -1,    -1,    -1,    -1,
1592     87,    -1,    89,    90,    91,    92,    -1,    -1,    -1,    -1,
1593     -1,    -1,    -1,    -1,    -1,     5,     6,   104,     8,     9,
1594     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
1595     20,    21,    22,    -1,    24,    -1,    -1,    -1,    -1,    -1,
1596     -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,    -1,    -1,
1597     -1,    -1,    -1,     5,     6,    45,     8,     9,    10,    11,
1598     12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
1599     22,    -1,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1600     -1,    -1,    -1,    -1,    -1,    37,    -1,    -1,    -1,    -1,
1601     -1,    -1,    -1,    45,    -1,    -1,    -1,    -1,    -1,    -1,
1602     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    98,    -1,
1603     -1,   101,    -1,    -1,   104,    -1,   106,     5,     6,    -1,
1604      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
1605     18,    19,    20,    21,    22,    -1,    24,    -1,    -1,    -1,
1606     -1,    -1,    -1,    -1,    -1,    -1,    98,    -1,    -1,   101,
1607     -1,    -1,   104,    -1,   106,     5,     6,    45,     8,     9,
1608     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
1609     20,    21,    22,    -1,    24,    -1,    -1,    -1,    -1,    -1,
1610     -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,    -1,    -1,
1611     -1,    -1,    -1,    -1,    -1,    45,    -1,    -1,    -1,    -1,
1612     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1613     98,    -1,    -1,   101,    -1,   103,   104,    -1,   106,    -1,
1614      5,     6,    -1,     8,     9,    10,    11,    12,    13,    14,
1615     15,    16,    17,    18,    19,    20,    21,    22,    -1,    24,
1616     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    98,    -1,
1617     -1,   101,    37,    -1,   104,    -1,   106,    -1,     5,     6,
1618     45,     8,     9,    10,    11,    12,    13,    14,    15,    16,
1619     17,    18,    19,    20,    21,    22,    -1,    24,     5,     6,
1620     -1,     8,     9,    10,    11,    12,    13,    14,    15,    16,
1621     17,    18,    19,    20,    21,    22,    -1,    24,    45,    -1,
1622     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1623     -1,    -1,    -1,    98,    -1,    -1,   101,    -1,    45,   104,
1624     -1,   106,     5,     6,    -1,     8,     9,    10,    11,    12,
1625     13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
1626     -1,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1627     -1,    98,    -1,    -1,   101,    -1,    -1,   104,    -1,   106,
1628     -1,    -1,    45,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1629     -1,    98,    -1,    -1,   101,    -1,    -1,   104,    -1,   106,
1630      5,     6,    -1,     8,     9,    10,    11,    12,    13,    14,
1631     15,    16,    17,    18,    19,    20,    21,    22,    -1,    24,
1632     -1,    -1,    -1,    35,    -1,    -1,    -1,    -1,    -1,    -1,
1633     -1,    -1,    -1,    -1,    46,    98,    -1,    -1,   101,    -1,
1634     45,   104,    -1,   106,    56,    57,    -1,    -1,    -1,    -1,
1635     62,    63,    64,    65,    66,    67,    68,    69,    70,    71,
1636     72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
1637     82,    83,    84,    -1,    -1,    87,    88,    89,    90,    91,
1638     92,    93,    94,    95,    -1,    -1,    -1,    -1,    -1,    -1,
1639     -1,    -1,    -1,    98,    -1,    -1,   101,    -1,    -1,   104,
1640     -1,   106
1641 };
1642 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
1643 #line 3 "/usr/share/bison.simple"
1644 /* This file comes from bison-1.28.  */
1645
1646 /* Skeleton output parser for bison,
1647    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1648
1649    This program is free software; you can redistribute it and/or modify
1650    it under the terms of the GNU General Public License as published by
1651    the Free Software Foundation; either version 2, or (at your option)
1652    any later version.
1653
1654    This program is distributed in the hope that it will be useful,
1655    but WITHOUT ANY WARRANTY; without even the implied warranty of
1656    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1657    GNU General Public License for more details.
1658
1659    You should have received a copy of the GNU General Public License
1660    along with this program; if not, write to the Free Software
1661    Foundation, Inc., 59 Temple Place - Suite 330,
1662    Boston, MA 02111-1307, USA.  */
1663
1664 /* As a special exception, when this file is copied by Bison into a
1665    Bison output file, you may use that output file without restriction.
1666    This special exception was added by the Free Software Foundation
1667    in version 1.24 of Bison.  */
1668
1669 /* This is the parser code that is written into each bison parser
1670   when the %semantic_parser declaration is not specified in the grammar.
1671   It was written by Richard Stallman by simplifying the hairy parser
1672   used when %semantic_parser is specified.  */
1673
1674 #ifndef YYSTACK_USE_ALLOCA
1675 #ifdef alloca
1676 #define YYSTACK_USE_ALLOCA
1677 #else /* alloca not defined */
1678 #ifdef __GNUC__
1679 #define YYSTACK_USE_ALLOCA
1680 #define alloca __builtin_alloca
1681 #else /* not GNU C.  */
1682 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1683 #define YYSTACK_USE_ALLOCA
1684 #include <alloca.h>
1685 #else /* not sparc */
1686 /* We think this test detects Watcom and Microsoft C.  */
1687 /* This used to test MSDOS, but that is a bad idea
1688    since that symbol is in the user namespace.  */
1689 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1690 #if 0 /* No need for malloc.h, which pollutes the namespace;
1691          instead, just don't use alloca.  */
1692 #include <malloc.h>
1693 #endif
1694 #else /* not MSDOS, or __TURBOC__ */
1695 #if defined(_AIX)
1696 /* I don't know what this was needed for, but it pollutes the namespace.
1697    So I turned it off.   rms, 2 May 1997.  */
1698 /* #include <malloc.h>  */
1699  #pragma alloca
1700 #define YYSTACK_USE_ALLOCA
1701 #else /* not MSDOS, or __TURBOC__, or _AIX */
1702 #if 0
1703 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1704                  and on HPUX 10.  Eventually we can turn this on.  */
1705 #define YYSTACK_USE_ALLOCA
1706 #define alloca __builtin_alloca
1707 #endif /* __hpux */
1708 #endif
1709 #endif /* not _AIX */
1710 #endif /* not MSDOS, or __TURBOC__ */
1711 #endif /* not sparc */
1712 #endif /* not GNU C */
1713 #endif /* alloca not defined */
1714 #endif /* YYSTACK_USE_ALLOCA not defined */
1715
1716 #ifdef YYSTACK_USE_ALLOCA
1717 #define YYSTACK_ALLOC alloca
1718 #else
1719 #define YYSTACK_ALLOC malloc
1720 #endif
1721
1722 /* Note: there must be only one dollar sign in this file.
1723    It is replaced by the list of actions, each action
1724    as one case of the switch.  */
1725
1726 #define yyerrok         (yyerrstatus = 0)
1727 #define yyclearin       (yychar = YYEMPTY)
1728 #define YYEMPTY         -2
1729 #define YYEOF           0
1730 #define YYACCEPT        goto yyacceptlab
1731 #define YYABORT         goto yyabortlab
1732 #define YYERROR         goto yyerrlab1
1733 /* Like YYERROR except do call yyerror.
1734    This remains here temporarily to ease the
1735    transition to the new meaning of YYERROR, for GCC.
1736    Once GCC version 2 has supplanted version 1, this can go.  */
1737 #define YYFAIL          goto yyerrlab
1738 #define YYRECOVERING()  (!!yyerrstatus)
1739 #define YYBACKUP(token, value) \
1740 do                                                              \
1741   if (yychar == YYEMPTY && yylen == 1)                          \
1742     { yychar = (token), yylval = (value);                       \
1743       yychar1 = YYTRANSLATE (yychar);                           \
1744       YYPOPSTACK;                                               \
1745       goto yybackup;                                            \
1746     }                                                           \
1747   else                                                          \
1748     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
1749 while (0)
1750
1751 #define YYTERROR        1
1752 #define YYERRCODE       256
1753
1754 #ifndef YYPURE
1755 #define YYLEX           yylex()
1756 #endif
1757
1758 #ifdef YYPURE
1759 #ifdef YYLSP_NEEDED
1760 #ifdef YYLEX_PARAM
1761 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
1762 #else
1763 #define YYLEX           yylex(&yylval, &yylloc)
1764 #endif
1765 #else /* not YYLSP_NEEDED */
1766 #ifdef YYLEX_PARAM
1767 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
1768 #else
1769 #define YYLEX           yylex(&yylval)
1770 #endif
1771 #endif /* not YYLSP_NEEDED */
1772 #endif
1773
1774 /* If nonreentrant, generate the variables here */
1775
1776 #ifndef YYPURE
1777
1778 int     yychar;                 /*  the lookahead symbol                */
1779 YYSTYPE yylval;                 /*  the semantic value of the           */
1780                                 /*  lookahead symbol                    */
1781
1782 #ifdef YYLSP_NEEDED
1783 YYLTYPE yylloc;                 /*  location data for the lookahead     */
1784                                 /*  symbol                              */
1785 #endif
1786
1787 int yynerrs;                    /*  number of parse errors so far       */
1788 #endif  /* not YYPURE */
1789
1790 #if YYDEBUG != 0
1791 int yydebug;                    /*  nonzero means print parse trace     */
1792 /* Since this is uninitialized, it does not stop multiple parsers
1793    from coexisting.  */
1794 #endif
1795
1796 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
1797
1798 #ifndef YYINITDEPTH
1799 #define YYINITDEPTH 200
1800 #endif
1801
1802 /*  YYMAXDEPTH is the maximum size the stacks can grow to
1803     (effective only if the built-in stack extension method is used).  */
1804
1805 #if YYMAXDEPTH == 0
1806 #undef YYMAXDEPTH
1807 #endif
1808
1809 #ifndef YYMAXDEPTH
1810 #define YYMAXDEPTH 10000
1811 #endif
1812 \f
1813 /* Define __yy_memcpy.  Note that the size argument
1814    should be passed with type unsigned int, because that is what the non-GCC
1815    definitions require.  With GCC, __builtin_memcpy takes an arg
1816    of type size_t, but it can handle unsigned int.  */
1817
1818 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
1819 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
1820 #else                           /* not GNU C or C++ */
1821 #ifndef __cplusplus
1822
1823 /* This is the most reliable way to avoid incompatibilities
1824    in available built-in functions on various systems.  */
1825 static void
1826 __yy_memcpy (to, from, count)
1827      char *to;
1828      char *from;
1829      unsigned int count;
1830 {
1831   register char *f = from;
1832   register char *t = to;
1833   register int i = count;
1834
1835   while (i-- > 0)
1836     *t++ = *f++;
1837 }
1838
1839 #else /* __cplusplus */
1840
1841 /* This is the most reliable way to avoid incompatibilities
1842    in available built-in functions on various systems.  */
1843 static void
1844 __yy_memcpy (char *to, char *from, unsigned int count)
1845 {
1846   register char *t = to;
1847   register char *f = from;
1848   register int i = count;
1849
1850   while (i-- > 0)
1851     *t++ = *f++;
1852 }
1853
1854 #endif
1855 #endif
1856 \f
1857 #line 217 "/usr/share/bison.simple"
1858
1859 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1860    into yyparse.  The argument should have type void *.
1861    It should actually point to an object.
1862    Grammar actions can access the variable by casting it
1863    to the proper pointer type.  */
1864
1865 #ifdef YYPARSE_PARAM
1866 #ifdef __cplusplus
1867 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1868 #define YYPARSE_PARAM_DECL
1869 #else /* not __cplusplus */
1870 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1871 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1872 #endif /* not __cplusplus */
1873 #else /* not YYPARSE_PARAM */
1874 #define YYPARSE_PARAM_ARG
1875 #define YYPARSE_PARAM_DECL
1876 #endif /* not YYPARSE_PARAM */
1877
1878 /* Prevent warning if -Wstrict-prototypes.  */
1879 #ifdef __GNUC__
1880 #ifdef YYPARSE_PARAM
1881 int yyparse (void *);
1882 #else
1883 int yyparse (void);
1884 #endif
1885 #endif
1886
1887 int
1888 yyparse(YYPARSE_PARAM_ARG)
1889      YYPARSE_PARAM_DECL
1890 {
1891   register int yystate;
1892   register int yyn;
1893   register short *yyssp;
1894   register YYSTYPE *yyvsp;
1895   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
1896   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
1897
1898   short yyssa[YYINITDEPTH];     /*  the state stack                     */
1899   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
1900
1901   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
1902   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
1903
1904 #ifdef YYLSP_NEEDED
1905   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
1906   YYLTYPE *yyls = yylsa;
1907   YYLTYPE *yylsp;
1908
1909 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
1910 #else
1911 #define YYPOPSTACK   (yyvsp--, yyssp--)
1912 #endif
1913
1914   int yystacksize = YYINITDEPTH;
1915   int yyfree_stacks = 0;
1916
1917 #ifdef YYPURE
1918   int yychar;
1919   YYSTYPE yylval;
1920   int yynerrs;
1921 #ifdef YYLSP_NEEDED
1922   YYLTYPE yylloc;
1923 #endif
1924 #endif
1925
1926   YYSTYPE yyval;                /*  the variable used to return         */
1927                                 /*  semantic values from the action     */
1928                                 /*  routines                            */
1929
1930   int yylen;
1931
1932 #if YYDEBUG != 0
1933   if (yydebug)
1934     fprintf(stderr, "Starting parse\n");
1935 #endif
1936
1937   yystate = 0;
1938   yyerrstatus = 0;
1939   yynerrs = 0;
1940   yychar = YYEMPTY;             /* Cause a token to be read.  */
1941
1942   /* Initialize stack pointers.
1943      Waste one element of value and location stack
1944      so that they stay on the same level as the state stack.
1945      The wasted elements are never initialized.  */
1946
1947   yyssp = yyss - 1;
1948   yyvsp = yyvs;
1949 #ifdef YYLSP_NEEDED
1950   yylsp = yyls;
1951 #endif
1952
1953 /* Push a new state, which is found in  yystate  .  */
1954 /* In all cases, when you get here, the value and location stacks
1955    have just been pushed. so pushing a state here evens the stacks.  */
1956 yynewstate:
1957
1958   *++yyssp = yystate;
1959
1960   if (yyssp >= yyss + yystacksize - 1)
1961     {
1962       /* Give user a chance to reallocate the stack */
1963       /* Use copies of these so that the &'s don't force the real ones into memory. */
1964       YYSTYPE *yyvs1 = yyvs;
1965       short *yyss1 = yyss;
1966 #ifdef YYLSP_NEEDED
1967       YYLTYPE *yyls1 = yyls;
1968 #endif
1969
1970       /* Get the current used size of the three stacks, in elements.  */
1971       int size = yyssp - yyss + 1;
1972
1973 #ifdef yyoverflow
1974       /* Each stack pointer address is followed by the size of
1975          the data in use in that stack, in bytes.  */
1976 #ifdef YYLSP_NEEDED
1977       /* This used to be a conditional around just the two extra args,
1978          but that might be undefined if yyoverflow is a macro.  */
1979       yyoverflow("parser stack overflow",
1980                  &yyss1, size * sizeof (*yyssp),
1981                  &yyvs1, size * sizeof (*yyvsp),
1982                  &yyls1, size * sizeof (*yylsp),
1983                  &yystacksize);
1984 #else
1985       yyoverflow("parser stack overflow",
1986                  &yyss1, size * sizeof (*yyssp),
1987                  &yyvs1, size * sizeof (*yyvsp),
1988                  &yystacksize);
1989 #endif
1990
1991       yyss = yyss1; yyvs = yyvs1;
1992 #ifdef YYLSP_NEEDED
1993       yyls = yyls1;
1994 #endif
1995 #else /* no yyoverflow */
1996       /* Extend the stack our own way.  */
1997       if (yystacksize >= YYMAXDEPTH)
1998         {
1999           yyerror("parser stack overflow");
2000           if (yyfree_stacks)
2001             {
2002               free (yyss);
2003               free (yyvs);
2004 #ifdef YYLSP_NEEDED
2005               free (yyls);
2006 #endif
2007             }
2008           return 2;
2009         }
2010       yystacksize *= 2;
2011       if (yystacksize > YYMAXDEPTH)
2012         yystacksize = YYMAXDEPTH;
2013 #ifndef YYSTACK_USE_ALLOCA
2014       yyfree_stacks = 1;
2015 #endif
2016       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2017       __yy_memcpy ((char *)yyss, (char *)yyss1,
2018                    size * (unsigned int) sizeof (*yyssp));
2019       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2020       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2021                    size * (unsigned int) sizeof (*yyvsp));
2022 #ifdef YYLSP_NEEDED
2023       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2024       __yy_memcpy ((char *)yyls, (char *)yyls1,
2025                    size * (unsigned int) sizeof (*yylsp));
2026 #endif
2027 #endif /* no yyoverflow */
2028
2029       yyssp = yyss + size - 1;
2030       yyvsp = yyvs + size - 1;
2031 #ifdef YYLSP_NEEDED
2032       yylsp = yyls + size - 1;
2033 #endif
2034
2035 #if YYDEBUG != 0
2036       if (yydebug)
2037         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2038 #endif
2039
2040       if (yyssp >= yyss + yystacksize - 1)
2041         YYABORT;
2042     }
2043
2044 #if YYDEBUG != 0
2045   if (yydebug)
2046     fprintf(stderr, "Entering state %d\n", yystate);
2047 #endif
2048
2049   goto yybackup;
2050  yybackup:
2051
2052 /* Do appropriate processing given the current state.  */
2053 /* Read a lookahead token if we need one and don't already have one.  */
2054 /* yyresume: */
2055
2056   /* First try to decide what to do without reference to lookahead token.  */
2057
2058   yyn = yypact[yystate];
2059   if (yyn == YYFLAG)
2060     goto yydefault;
2061
2062   /* Not known => get a lookahead token if don't already have one.  */
2063
2064   /* yychar is either YYEMPTY or YYEOF
2065      or a valid token in external form.  */
2066
2067   if (yychar == YYEMPTY)
2068     {
2069 #if YYDEBUG != 0
2070       if (yydebug)
2071         fprintf(stderr, "Reading a token: ");
2072 #endif
2073       yychar = YYLEX;
2074     }
2075
2076   /* Convert token to internal form (in yychar1) for indexing tables with */
2077
2078   if (yychar <= 0)              /* This means end of input. */
2079     {
2080       yychar1 = 0;
2081       yychar = YYEOF;           /* Don't call YYLEX any more */
2082
2083 #if YYDEBUG != 0
2084       if (yydebug)
2085         fprintf(stderr, "Now at end of input.\n");
2086 #endif
2087     }
2088   else
2089     {
2090       yychar1 = YYTRANSLATE(yychar);
2091
2092 #if YYDEBUG != 0
2093       if (yydebug)
2094         {
2095           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2096           /* Give the individual parser a way to print the precise meaning
2097              of a token, for further debugging info.  */
2098 #ifdef YYPRINT
2099           YYPRINT (stderr, yychar, yylval);
2100 #endif
2101           fprintf (stderr, ")\n");
2102         }
2103 #endif
2104     }
2105
2106   yyn += yychar1;
2107   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2108     goto yydefault;
2109
2110   yyn = yytable[yyn];
2111
2112   /* yyn is what to do for this token type in this state.
2113      Negative => reduce, -yyn is rule number.
2114      Positive => shift, yyn is new state.
2115        New state is final state => don't bother to shift,
2116        just return success.
2117      0, or most negative number => error.  */
2118
2119   if (yyn < 0)
2120     {
2121       if (yyn == YYFLAG)
2122         goto yyerrlab;
2123       yyn = -yyn;
2124       goto yyreduce;
2125     }
2126   else if (yyn == 0)
2127     goto yyerrlab;
2128
2129   if (yyn == YYFINAL)
2130     YYACCEPT;
2131
2132   /* Shift the lookahead token.  */
2133
2134 #if YYDEBUG != 0
2135   if (yydebug)
2136     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2137 #endif
2138
2139   /* Discard the token being shifted unless it is eof.  */
2140   if (yychar != YYEOF)
2141     yychar = YYEMPTY;
2142
2143   *++yyvsp = yylval;
2144 #ifdef YYLSP_NEEDED
2145   *++yylsp = yylloc;
2146 #endif
2147
2148   /* count tokens shifted since error; after three, turn off error status.  */
2149   if (yyerrstatus) yyerrstatus--;
2150
2151   yystate = yyn;
2152   goto yynewstate;
2153
2154 /* Do the default action for the current state.  */
2155 yydefault:
2156
2157   yyn = yydefact[yystate];
2158   if (yyn == 0)
2159     goto yyerrlab;
2160
2161 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
2162 yyreduce:
2163   yylen = yyr2[yyn];
2164   if (yylen > 0)
2165     yyval = yyvsp[1-yylen]; /* implement default value of the action */
2166
2167 #if YYDEBUG != 0
2168   if (yydebug)
2169     {
2170       int i;
2171
2172       fprintf (stderr, "Reducing via rule %d (line %d), ",
2173                yyn, yyrline[yyn]);
2174
2175       /* Print the symbols being reduced, and their result.  */
2176       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2177         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2178       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2179     }
2180 #endif
2181
2182
2183   switch (yyn) {
2184
2185 case 2:
2186 #line 989 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2187 {
2188   if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX)     // Outside of my range!
2189     ThrowException("Value too large for type!");
2190   yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2191 ;
2192     break;}
2193 case 4:
2194 #line 997 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2195 {
2196   if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX)     // Outside of my range!
2197     ThrowException("Value too large for type!");
2198   yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2199 ;
2200     break;}
2201 case 33:
2202 #line 1020 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2203 {
2204     yyval.StrVal = yyvsp[-1].StrVal;
2205   ;
2206     break;}
2207 case 34:
2208 #line 1023 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2209 {
2210     yyval.StrVal = 0;
2211   ;
2212     break;}
2213 case 35:
2214 #line 1027 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2215 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2216     break;}
2217 case 36:
2218 #line 1028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2219 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2220     break;}
2221 case 37:
2222 #line 1029 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2223 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2224     break;}
2225 case 38:
2226 #line 1030 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2227 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2228     break;}
2229 case 39:
2230 #line 1031 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2231 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2232     break;}
2233 case 40:
2234 #line 1033 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2235 { yyval.UIntVal = CallingConv::C; ;
2236     break;}
2237 case 41:
2238 #line 1034 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2239 { yyval.UIntVal = CallingConv::C; ;
2240     break;}
2241 case 42:
2242 #line 1035 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2243 { yyval.UIntVal = CallingConv::Fast; ;
2244     break;}
2245 case 43:
2246 #line 1036 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2247 { yyval.UIntVal = CallingConv::Cold; ;
2248     break;}
2249 case 44:
2250 #line 1037 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2251 {
2252                    if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2253                      ThrowException("Calling conv too large!");
2254                    yyval.UIntVal = yyvsp[0].UInt64Val;
2255                  ;
2256     break;}
2257 case 45:
2258 #line 1045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2259 { yyval.UIntVal = 0; ;
2260     break;}
2261 case 46:
2262 #line 1046 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2263 {
2264   yyval.UIntVal = yyvsp[0].UInt64Val;
2265   if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2266     ThrowException("Alignment must be a power of two!");
2267 ;
2268     break;}
2269 case 47:
2270 #line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2271 { yyval.UIntVal = 0; ;
2272     break;}
2273 case 48:
2274 #line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2275 {
2276   yyval.UIntVal = yyvsp[0].UInt64Val;
2277   if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2278     ThrowException("Alignment must be a power of two!");
2279 ;
2280     break;}
2281 case 49:
2282 #line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2283 {
2284   for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2285     if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2286       ThrowException("Invalid character in section name!");
2287   yyval.StrVal = yyvsp[0].StrVal;
2288 ;
2289     break;}
2290 case 50:
2291 #line 1066 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2292 { yyval.StrVal = 0; ;
2293     break;}
2294 case 51:
2295 #line 1067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2296 { yyval.StrVal = yyvsp[0].StrVal; ;
2297     break;}
2298 case 52:
2299 #line 1072 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2300 {;
2301     break;}
2302 case 53:
2303 #line 1073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2304 {;
2305     break;}
2306 case 54:
2307 #line 1074 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2308 {
2309     CurGV->setSection(yyvsp[0].StrVal);
2310     free(yyvsp[0].StrVal);
2311   ;
2312     break;}
2313 case 55:
2314 #line 1078 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2315 {
2316     CurGV->setAlignment(yyvsp[0].UInt64Val);
2317   ;
2318     break;}
2319 case 57:
2320 #line 1089 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2321 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2322     break;}
2323 case 59:
2324 #line 1090 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2325 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2326     break;}
2327 case 60:
2328 #line 1092 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2329 {
2330     if (!UpRefs.empty())
2331       ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2332     yyval.TypeVal = yyvsp[0].TypeVal;
2333   ;
2334     break;}
2335 case 74:
2336 #line 1103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2337 {
2338     yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2339   ;
2340     break;}
2341 case 75:
2342 #line 1106 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2343 {
2344     yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2345   ;
2346     break;}
2347 case 76:
2348 #line 1109 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2349 {            // Named types are also simple types...
2350   yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2351 ;
2352     break;}
2353 case 77:
2354 #line 1115 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2355 {                   // Type UpReference
2356     if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2357     OpaqueType *OT = OpaqueType::get();        // Use temporary placeholder
2358     UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT));  // Add to vector...
2359     yyval.TypeVal = new PATypeHolder(OT);
2360     UR_OUT("New Upreference!\n");
2361   ;
2362     break;}
2363 case 78:
2364 #line 1122 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2365 {           // Function derived type?
2366     std::vector<const Type*> Params;
2367     for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2368            E = yyvsp[-1].TypeList->end(); I != E; ++I)
2369       Params.push_back(*I);
2370     bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2371     if (isVarArg) Params.pop_back();
2372
2373     yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2374     delete yyvsp[-1].TypeList;      // Delete the argument list
2375     delete yyvsp[-3].TypeVal;      // Delete the return type handle
2376   ;
2377     break;}
2378 case 79:
2379 #line 1134 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2380 {          // Sized array type?
2381     yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2382     delete yyvsp[-1].TypeVal;
2383   ;
2384     break;}
2385 case 80:
2386 #line 1138 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2387 {          // Packed array type?
2388      const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2389      if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2390         ThrowException("Unsigned result not equal to signed result");
2391      if (!ElemTy->isPrimitiveType())
2392         ThrowException("Elemental type of a PackedType must be primitive");
2393      if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2394        ThrowException("Vector length should be a power of 2!");
2395      yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2396      delete yyvsp[-1].TypeVal;
2397   ;
2398     break;}
2399 case 81:
2400 #line 1149 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2401 {                        // Structure type?
2402     std::vector<const Type*> Elements;
2403     for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2404            E = yyvsp[-1].TypeList->end(); I != E; ++I)
2405       Elements.push_back(*I);
2406
2407     yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2408     delete yyvsp[-1].TypeList;
2409   ;
2410     break;}
2411 case 82:
2412 #line 1158 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2413 {                                  // Empty structure type?
2414     yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2415   ;
2416     break;}
2417 case 83:
2418 #line 1161 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2419 {                             // Pointer type?
2420     yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2421     delete yyvsp[-1].TypeVal;
2422   ;
2423     break;}
2424 case 84:
2425 #line 1169 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2426 {
2427     yyval.TypeList = new std::list<PATypeHolder>();
2428     yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2429   ;
2430     break;}
2431 case 85:
2432 #line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2433 {
2434     (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2435   ;
2436     break;}
2437 case 87:
2438 #line 1179 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2439 {
2440     (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2441   ;
2442     break;}
2443 case 88:
2444 #line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2445 {
2446     (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2447   ;
2448     break;}
2449 case 89:
2450 #line 1185 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2451 {
2452     yyval.TypeList = new std::list<PATypeHolder>();
2453   ;
2454     break;}
2455 case 90:
2456 #line 1195 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2457 { // Nonempty unsized arr
2458     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2459     if (ATy == 0)
2460       ThrowException("Cannot make array constant with type: '" + 
2461                      (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2462     const Type *ETy = ATy->getElementType();
2463     int NumElements = ATy->getNumElements();
2464
2465     // Verify that we have the correct size...
2466     if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2467       ThrowException("Type mismatch: constant sized array initialized with " +
2468                      utostr(yyvsp[-1].ConstVector->size()) +  " arguments, but has size of " + 
2469                      itostr(NumElements) + "!");
2470
2471     // Verify all elements are correct type!
2472     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2473       if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2474         ThrowException("Element #" + utostr(i) + " is not of type '" + 
2475                        ETy->getDescription() +"' as required!\nIt is of type '"+
2476                        (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2477     }
2478
2479     yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2480     delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2481   ;
2482     break;}
2483 case 91:
2484 #line 1220 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2485 {
2486     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2487     if (ATy == 0)
2488       ThrowException("Cannot make array constant with type: '" + 
2489                      (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2490
2491     int NumElements = ATy->getNumElements();
2492     if (NumElements != -1 && NumElements != 0) 
2493       ThrowException("Type mismatch: constant sized array initialized with 0"
2494                      " arguments, but has size of " + itostr(NumElements) +"!");
2495     yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2496     delete yyvsp[-2].TypeVal;
2497   ;
2498     break;}
2499 case 92:
2500 #line 1233 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2501 {
2502     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2503     if (ATy == 0)
2504       ThrowException("Cannot make array constant with type: '" + 
2505                      (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2506
2507     int NumElements = ATy->getNumElements();
2508     const Type *ETy = ATy->getElementType();
2509     char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2510     if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2511       ThrowException("Can't build string constant of size " + 
2512                      itostr((int)(EndStr-yyvsp[0].StrVal)) +
2513                      " when array has size " + itostr(NumElements) + "!");
2514     std::vector<Constant*> Vals;
2515     if (ETy == Type::SByteTy) {
2516       for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2517         Vals.push_back(ConstantSInt::get(ETy, *C));
2518     } else if (ETy == Type::UByteTy) {
2519       for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2520         Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2521     } else {
2522       free(yyvsp[0].StrVal);
2523       ThrowException("Cannot build string arrays of non byte sized elements!");
2524     }
2525     free(yyvsp[0].StrVal);
2526     yyval.ConstVal = ConstantArray::get(ATy, Vals);
2527     delete yyvsp[-2].TypeVal;
2528   ;
2529     break;}
2530 case 93:
2531 #line 1261 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2532 { // Nonempty unsized arr
2533     const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2534     if (PTy == 0)
2535       ThrowException("Cannot make packed constant with type: '" + 
2536                      (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2537     const Type *ETy = PTy->getElementType();
2538     int NumElements = PTy->getNumElements();
2539
2540     // Verify that we have the correct size...
2541     if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2542       ThrowException("Type mismatch: constant sized packed initialized with " +
2543                      utostr(yyvsp[-1].ConstVector->size()) +  " arguments, but has size of " + 
2544                      itostr(NumElements) + "!");
2545
2546     // Verify all elements are correct type!
2547     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2548       if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2549         ThrowException("Element #" + utostr(i) + " is not of type '" + 
2550            ETy->getDescription() +"' as required!\nIt is of type '"+
2551            (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2552     }
2553
2554     yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2555     delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2556   ;
2557     break;}
2558 case 94:
2559 #line 1286 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2560 {
2561     const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2562     if (STy == 0)
2563       ThrowException("Cannot make struct constant with type: '" + 
2564                      (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2565
2566     if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2567       ThrowException("Illegal number of initializers for structure type!");
2568
2569     // Check to ensure that constants are compatible with the type initializer!
2570     for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2571       if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2572         ThrowException("Expected type '" +
2573                        STy->getElementType(i)->getDescription() +
2574                        "' for element #" + utostr(i) +
2575                        " of structure initializer!");
2576
2577     yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2578     delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2579   ;
2580     break;}
2581 case 95:
2582 #line 1306 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2583 {
2584     const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2585     if (STy == 0)
2586       ThrowException("Cannot make struct constant with type: '" + 
2587                      (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2588
2589     if (STy->getNumContainedTypes() != 0)
2590       ThrowException("Illegal number of initializers for structure type!");
2591
2592     yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2593     delete yyvsp[-2].TypeVal;
2594   ;
2595     break;}
2596 case 96:
2597 #line 1318 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2598 {
2599     const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2600     if (PTy == 0)
2601       ThrowException("Cannot make null pointer constant with type: '" + 
2602                      (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2603
2604     yyval.ConstVal = ConstantPointerNull::get(PTy);
2605     delete yyvsp[-1].TypeVal;
2606   ;
2607     break;}
2608 case 97:
2609 #line 1327 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2610 {
2611     yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2612     delete yyvsp[-1].TypeVal;
2613   ;
2614     break;}
2615 case 98:
2616 #line 1331 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2617 {
2618     const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2619     if (Ty == 0)
2620       ThrowException("Global const reference must be a pointer type!");
2621
2622     // ConstExprs can exist in the body of a function, thus creating
2623     // GlobalValues whenever they refer to a variable.  Because we are in
2624     // the context of a function, getValNonImprovising will search the functions
2625     // symbol table instead of the module symbol table for the global symbol,
2626     // which throws things all off.  To get around this, we just tell
2627     // getValNonImprovising that we are at global scope here.
2628     //
2629     Function *SavedCurFn = CurFun.CurrentFunction;
2630     CurFun.CurrentFunction = 0;
2631
2632     Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2633
2634     CurFun.CurrentFunction = SavedCurFn;
2635
2636     // If this is an initializer for a constant pointer, which is referencing a
2637     // (currently) undefined variable, create a stub now that shall be replaced
2638     // in the future with the right type of variable.
2639     //
2640     if (V == 0) {
2641       assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2642       const PointerType *PT = cast<PointerType>(Ty);
2643
2644       // First check to see if the forward references value is already created!
2645       PerModuleInfo::GlobalRefsType::iterator I =
2646         CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2647     
2648       if (I != CurModule.GlobalRefs.end()) {
2649         V = I->second;             // Placeholder already exists, use it...
2650         yyvsp[0].ValIDVal.destroy();
2651       } else {
2652         std::string Name;
2653         if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2654
2655         // Create the forward referenced global.
2656         GlobalValue *GV;
2657         if (const FunctionType *FTy = 
2658                  dyn_cast<FunctionType>(PT->getElementType())) {
2659           GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2660                             CurModule.CurrentModule);
2661         } else {
2662           GV = new GlobalVariable(PT->getElementType(), false,
2663                                   GlobalValue::ExternalLinkage, 0,
2664                                   Name, CurModule.CurrentModule);
2665         }
2666
2667         // Keep track of the fact that we have a forward ref to recycle it
2668         CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2669         V = GV;
2670       }
2671     }
2672
2673     yyval.ConstVal = cast<GlobalValue>(V);
2674     delete yyvsp[-1].TypeVal;            // Free the type handle
2675   ;
2676     break;}
2677 case 99:
2678 #line 1390 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2679 {
2680     if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2681       ThrowException("Mismatched types for constant expression!");
2682     yyval.ConstVal = yyvsp[0].ConstVal;
2683     delete yyvsp[-1].TypeVal;
2684   ;
2685     break;}
2686 case 100:
2687 #line 1396 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2688 {
2689     const Type *Ty = yyvsp[-1].TypeVal->get();
2690     if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2691       ThrowException("Cannot create a null initialized value of this type!");
2692     yyval.ConstVal = Constant::getNullValue(Ty);
2693     delete yyvsp[-1].TypeVal;
2694   ;
2695     break;}
2696 case 101:
2697 #line 1404 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2698 {      // integral constants
2699     if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2700       ThrowException("Constant value doesn't fit in type!");
2701     yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
2702   ;
2703     break;}
2704 case 102:
2705 #line 1409 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2706 {            // integral constants
2707     if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2708       ThrowException("Constant value doesn't fit in type!");
2709     yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
2710   ;
2711     break;}
2712 case 103:
2713 #line 1414 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2714 {                      // Boolean constants
2715     yyval.ConstVal = ConstantBool::True;
2716   ;
2717     break;}
2718 case 104:
2719 #line 1417 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2720 {                     // Boolean constants
2721     yyval.ConstVal = ConstantBool::False;
2722   ;
2723     break;}
2724 case 105:
2725 #line 1420 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2726 {                   // Float & Double constants
2727     if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2728       ThrowException("Floating point constant invalid for type!!");
2729     yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
2730   ;
2731     break;}
2732 case 106:
2733 #line 1427 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2734 {
2735     if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2736       ThrowException("cast constant expression from a non-primitive type: '" +
2737                      yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2738     if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2739       ThrowException("cast constant expression to a non-primitive type: '" +
2740                      yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2741     yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2742     delete yyvsp[-1].TypeVal;
2743   ;
2744     break;}
2745 case 107:
2746 #line 1437 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2747 {
2748     if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2749       ThrowException("GetElementPtr requires a pointer operand!");
2750
2751     // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte struct
2752     // indices to uint struct indices for compatibility.
2753     generic_gep_type_iterator<std::vector<Value*>::iterator>
2754       GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2755       GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2756     for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2757       if (isa<StructType>(*GTI))        // Only change struct indices
2758         if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2759           if (CUI->getType() == Type::UByteTy)
2760             (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2761
2762     const Type *IdxTy =
2763       GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2764     if (!IdxTy)
2765       ThrowException("Index list invalid for constant getelementptr!");
2766
2767     std::vector<Constant*> IdxVec;
2768     for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2769       if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2770         IdxVec.push_back(C);
2771       else
2772         ThrowException("Indices to constant getelementptr must be constants!");
2773
2774     delete yyvsp[-1].ValueList;
2775
2776     yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
2777   ;
2778     break;}
2779 case 108:
2780 #line 1468 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2781 {
2782     if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2783       ThrowException("Select condition must be of boolean type!");
2784     if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2785       ThrowException("Select operand types must match!");
2786     yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2787   ;
2788     break;}
2789 case 109:
2790 #line 1475 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2791 {
2792     if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2793       ThrowException("Binary operator types must match!");
2794     // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2795     // To retain backward compatibility with these early compilers, we emit a
2796     // cast to the appropriate integer type automatically if we are in the
2797     // broken case.  See PR424 for more information.
2798     if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2799       yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2800     } else {
2801       const Type *IntPtrTy = 0;
2802       switch (CurModule.CurrentModule->getPointerSize()) {
2803       case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2804       case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2805       default: ThrowException("invalid pointer binary constant expr!");
2806       }
2807       yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2808                              ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2809       yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2810     }
2811   ;
2812     break;}
2813 case 110:
2814 #line 1496 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2815 {
2816     if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2817       ThrowException("Logical operator types must match!");
2818     if (!yyvsp[-3].ConstVal->getType()->isIntegral())
2819       ThrowException("Logical operands must have integral types!");
2820     yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2821   ;
2822     break;}
2823 case 111:
2824 #line 1503 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2825 {
2826     if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2827       ThrowException("setcc operand types must match!");
2828     yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2829   ;
2830     break;}
2831 case 112:
2832 #line 1508 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2833 {
2834     if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2835       ThrowException("Shift count for shift constant must be unsigned byte!");
2836     if (!yyvsp[-3].ConstVal->getType()->isInteger())
2837       ThrowException("Shift constant expression requires integer operand!");
2838     yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2839   ;
2840     break;}
2841 case 113:
2842 #line 1518 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2843 {
2844     (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
2845   ;
2846     break;}
2847 case 114:
2848 #line 1521 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2849 {
2850     yyval.ConstVector = new std::vector<Constant*>();
2851     yyval.ConstVector->push_back(yyvsp[0].ConstVal);
2852   ;
2853     break;}
2854 case 115:
2855 #line 1528 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2856 { yyval.BoolVal = false; ;
2857     break;}
2858 case 116:
2859 #line 1528 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2860 { yyval.BoolVal = true; ;
2861     break;}
2862 case 117:
2863 #line 1538 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2864 {
2865   yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2866   CurModule.ModuleDone();
2867 ;
2868     break;}
2869 case 118:
2870 #line 1545 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2871 {
2872     yyval.ModuleVal = yyvsp[-1].ModuleVal;
2873     CurFun.FunctionDone();
2874   ;
2875     break;}
2876 case 119:
2877 #line 1549 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2878 {
2879     yyval.ModuleVal = yyvsp[-1].ModuleVal;
2880   ;
2881     break;}
2882 case 120:
2883 #line 1552 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2884 {
2885     yyval.ModuleVal = yyvsp[-1].ModuleVal;
2886   ;
2887     break;}
2888 case 121:
2889 #line 1555 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2890 {
2891     yyval.ModuleVal = CurModule.CurrentModule;
2892     // Emit an error if there are any unresolved types left.
2893     if (!CurModule.LateResolveTypes.empty()) {
2894       const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2895       if (DID.Type == ValID::NameVal)
2896         ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2897       else
2898         ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2899     }
2900   ;
2901     break;}
2902 case 122:
2903 #line 1568 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2904 {
2905     // Eagerly resolve types.  This is not an optimization, this is a
2906     // requirement that is due to the fact that we could have this:
2907     //
2908     // %list = type { %list * }
2909     // %list = type { %list * }    ; repeated type decl
2910     //
2911     // If types are not resolved eagerly, then the two types will not be
2912     // determined to be the same type!
2913     //
2914     ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2915
2916     if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2917       // If this is a named type that is not a redefinition, add it to the slot
2918       // table.
2919       CurModule.Types.push_back(*yyvsp[0].TypeVal);
2920     }
2921
2922     delete yyvsp[0].TypeVal;
2923   ;
2924     break;}
2925 case 123:
2926 #line 1588 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2927 {       // Function prototypes can be in const pool
2928   ;
2929     break;}
2930 case 124:
2931 #line 1590 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2932 {
2933     if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
2934     CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
2935                                                        ;
2936     break;}
2937 case 125:
2938 #line 1593 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2939 {
2940     CurGV = 0;
2941   ;
2942     break;}
2943 case 126:
2944 #line 1596 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2945 {
2946     CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
2947                                              yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
2948     delete yyvsp[0].TypeVal;
2949                                                    ;
2950     break;}
2951 case 127:
2952 #line 1600 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2953 {
2954     CurGV = 0;
2955   ;
2956     break;}
2957 case 128:
2958 #line 1603 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2959
2960   ;
2961     break;}
2962 case 129:
2963 #line 1605 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2964 {
2965   ;
2966     break;}
2967 case 130:
2968 #line 1607 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2969
2970   ;
2971     break;}
2972 case 131:
2973 #line 1612 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2974 { yyval.Endianness = Module::BigEndian; ;
2975     break;}
2976 case 132:
2977 #line 1613 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2978 { yyval.Endianness = Module::LittleEndian; ;
2979     break;}
2980 case 133:
2981 #line 1615 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2982 {
2983     CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
2984   ;
2985     break;}
2986 case 134:
2987 #line 1618 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2988 {
2989     if (yyvsp[0].UInt64Val == 32)
2990       CurModule.CurrentModule->setPointerSize(Module::Pointer32);
2991     else if (yyvsp[0].UInt64Val == 64)
2992       CurModule.CurrentModule->setPointerSize(Module::Pointer64);
2993     else
2994       ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
2995   ;
2996     break;}
2997 case 135:
2998 #line 1626 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2999 {
3000     CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3001     free(yyvsp[0].StrVal);
3002   ;
3003     break;}
3004 case 137:
3005 #line 1633 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3006 {
3007           CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3008           free(yyvsp[0].StrVal);
3009         ;
3010     break;}
3011 case 138:
3012 #line 1637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3013 {
3014           CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3015           free(yyvsp[0].StrVal);
3016         ;
3017     break;}
3018 case 139:
3019 #line 1641 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3020 {
3021         ;
3022     break;}
3023 case 143:
3024 #line 1650 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3025 { yyval.StrVal = 0; ;
3026     break;}
3027 case 144:
3028 #line 1652 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3029 {
3030   if (*yyvsp[-1].TypeVal == Type::VoidTy)
3031     ThrowException("void typed arguments are invalid!");
3032   yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3033 ;
3034     break;}
3035 case 145:
3036 #line 1658 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3037 {
3038     yyval.ArgList = yyvsp[-2].ArgList;
3039     yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3040     delete yyvsp[0].ArgVal;
3041   ;
3042     break;}
3043 case 146:
3044 #line 1663 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3045 {
3046     yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3047     yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3048     delete yyvsp[0].ArgVal;
3049   ;
3050     break;}
3051 case 147:
3052 #line 1669 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3053 {
3054     yyval.ArgList = yyvsp[0].ArgList;
3055   ;
3056     break;}
3057 case 148:
3058 #line 1672 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3059 {
3060     yyval.ArgList = yyvsp[-2].ArgList;
3061     yyval.ArgList->push_back(std::pair<PATypeHolder*,
3062                             char*>(new PATypeHolder(Type::VoidTy), 0));
3063   ;
3064     break;}
3065 case 149:
3066 #line 1677 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3067 {
3068     yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3069     yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3070   ;
3071     break;}
3072 case 150:
3073 #line 1681 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3074 {
3075     yyval.ArgList = 0;
3076   ;
3077     break;}
3078 case 151:
3079 #line 1686 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3080 {
3081   UnEscapeLexed(yyvsp[-5].StrVal);
3082   std::string FunctionName(yyvsp[-5].StrVal);
3083   free(yyvsp[-5].StrVal);  // Free strdup'd memory!
3084   
3085   if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
3086     ThrowException("LLVM functions cannot return aggregate types!");
3087
3088   std::vector<const Type*> ParamTypeList;
3089   if (yyvsp[-3].ArgList) {   // If there are arguments...
3090     for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3091          I != yyvsp[-3].ArgList->end(); ++I)
3092       ParamTypeList.push_back(I->first->get());
3093   }
3094
3095   bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3096   if (isVarArg) ParamTypeList.pop_back();
3097
3098   const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
3099   const PointerType *PFT = PointerType::get(FT);
3100   delete yyvsp[-6].TypeVal;
3101
3102   ValID ID;
3103   if (!FunctionName.empty()) {
3104     ID = ValID::create((char*)FunctionName.c_str());
3105   } else {
3106     ID = ValID::create((int)CurModule.Values[PFT].size());
3107   }
3108
3109   Function *Fn = 0;
3110   // See if this function was forward referenced.  If so, recycle the object.
3111   if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3112     // Move the function to the end of the list, from whereever it was 
3113     // previously inserted.
3114     Fn = cast<Function>(FWRef);
3115     CurModule.CurrentModule->getFunctionList().remove(Fn);
3116     CurModule.CurrentModule->getFunctionList().push_back(Fn);
3117   } else if (!FunctionName.empty() &&     // Merge with an earlier prototype?
3118              (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3119     // If this is the case, either we need to be a forward decl, or it needs 
3120     // to be.
3121     if (!CurFun.isDeclare && !Fn->isExternal())
3122       ThrowException("Redefinition of function '" + FunctionName + "'!");
3123     
3124     // Make sure to strip off any argument names so we can't get conflicts.
3125     if (Fn->isExternal())
3126       for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3127            AI != AE; ++AI)
3128         AI->setName("");
3129
3130   } else  {  // Not already defined?
3131     Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3132                       CurModule.CurrentModule);
3133     InsertValue(Fn, CurModule.Values);
3134   }
3135
3136   CurFun.FunctionStart(Fn);
3137   Fn->setCallingConv(yyvsp[-7].UIntVal);
3138   Fn->setAlignment(yyvsp[0].UIntVal);
3139   if (yyvsp[-1].StrVal) {
3140     Fn->setSection(yyvsp[-1].StrVal);
3141     free(yyvsp[-1].StrVal);
3142   }
3143
3144   // Add all of the arguments we parsed to the function...
3145   if (yyvsp[-3].ArgList) {                     // Is null if empty...
3146     if (isVarArg) {  // Nuke the last entry
3147       assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
3148              "Not a varargs marker!");
3149       delete yyvsp[-3].ArgList->back().first;
3150       yyvsp[-3].ArgList->pop_back();  // Delete the last entry
3151     }
3152     Function::arg_iterator ArgIt = Fn->arg_begin();
3153     for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3154          I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
3155       delete I->first;                          // Delete the typeholder...
3156
3157       setValueName(ArgIt, I->second);           // Insert arg into symtab...
3158       InsertValue(ArgIt);
3159     }
3160
3161     delete yyvsp[-3].ArgList;                     // We're now done with the argument list
3162   }
3163 ;
3164     break;}
3165 case 154:
3166 #line 1773 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3167 {
3168   yyval.FunctionVal = CurFun.CurrentFunction;
3169
3170   // Make sure that we keep track of the linkage type even if there was a
3171   // previous "declare".
3172   yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3173 ;
3174     break;}
3175 case 157:
3176 #line 1783 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3177 {
3178   yyval.FunctionVal = yyvsp[-1].FunctionVal;
3179 ;
3180     break;}
3181 case 158:
3182 #line 1787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3183 { CurFun.isDeclare = true; ;
3184     break;}
3185 case 159:
3186 #line 1787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3187 {
3188   yyval.FunctionVal = CurFun.CurrentFunction;
3189   CurFun.FunctionDone();
3190 ;
3191     break;}
3192 case 160:
3193 #line 1796 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3194 {    // A reference to a direct constant
3195     yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3196   ;
3197     break;}
3198 case 161:
3199 #line 1799 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3200 {
3201     yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3202   ;
3203     break;}
3204 case 162:
3205 #line 1802 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3206 {                     // Perhaps it's an FP constant?
3207     yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3208   ;
3209     break;}
3210 case 163:
3211 #line 1805 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3212 {
3213     yyval.ValIDVal = ValID::create(ConstantBool::True);
3214   ;
3215     break;}
3216 case 164:
3217 #line 1808 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3218 {
3219     yyval.ValIDVal = ValID::create(ConstantBool::False);
3220   ;
3221     break;}
3222 case 165:
3223 #line 1811 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3224 {
3225     yyval.ValIDVal = ValID::createNull();
3226   ;
3227     break;}
3228 case 166:
3229 #line 1814 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3230 {
3231     yyval.ValIDVal = ValID::createUndef();
3232   ;
3233     break;}
3234 case 167:
3235 #line 1817 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3236 { // Nonempty unsized packed vector
3237     const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3238     int NumElements = yyvsp[-1].ConstVector->size(); 
3239     
3240     PackedType* pt = PackedType::get(ETy, NumElements);
3241     PATypeHolder* PTy = new PATypeHolder(
3242                                          HandleUpRefs(
3243                                             PackedType::get(
3244                                                 ETy, 
3245                                                 NumElements)
3246                                             )
3247                                          );
3248     
3249     // Verify all elements are correct type!
3250     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3251       if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3252         ThrowException("Element #" + utostr(i) + " is not of type '" + 
3253                      ETy->getDescription() +"' as required!\nIt is of type '" +
3254                      (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3255     }
3256
3257     yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3258     delete PTy; delete yyvsp[-1].ConstVector;
3259   ;
3260     break;}
3261 case 168:
3262 #line 1841 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3263 {
3264     yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3265   ;
3266     break;}
3267 case 169:
3268 #line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3269 {  // Is it an integer reference...?
3270     yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3271   ;
3272     break;}
3273 case 170:
3274 #line 1851 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3275 {                   // Is it a named reference...?
3276     yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3277   ;
3278     break;}
3279 case 173:
3280 #line 1862 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3281 {
3282     yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3283   ;
3284     break;}
3285 case 174:
3286 #line 1866 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3287 {
3288     yyval.FunctionVal = yyvsp[-1].FunctionVal;
3289   ;
3290     break;}
3291 case 175:
3292 #line 1869 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3293 { // Do not allow functions with 0 basic blocks   
3294     yyval.FunctionVal = yyvsp[-1].FunctionVal;
3295   ;
3296     break;}
3297 case 176:
3298 #line 1877 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3299 {
3300     setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3301     InsertValue(yyvsp[0].TermInstVal);
3302
3303     yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3304     InsertValue(yyvsp[-2].BasicBlockVal);
3305     yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3306   ;
3307     break;}
3308 case 177:
3309 #line 1886 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3310 {
3311     yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3312     yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3313   ;
3314     break;}
3315 case 178:
3316 #line 1890 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3317 {
3318     yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3319
3320     // Make sure to move the basic block to the correct location in the
3321     // function, instead of leaving it inserted wherever it was first
3322     // referenced.
3323     Function::BasicBlockListType &BBL = 
3324       CurFun.CurrentFunction->getBasicBlockList();
3325     BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3326   ;
3327     break;}
3328 case 179:
3329 #line 1900 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3330 {
3331     yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3332
3333     // Make sure to move the basic block to the correct location in the
3334     // function, instead of leaving it inserted wherever it was first
3335     // referenced.
3336     Function::BasicBlockListType &BBL = 
3337       CurFun.CurrentFunction->getBasicBlockList();
3338     BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3339   ;
3340     break;}
3341 case 180:
3342 #line 1911 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3343 {              // Return with a result...
3344     yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3345   ;
3346     break;}
3347 case 181:
3348 #line 1914 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3349 {                                       // Return with no result...
3350     yyval.TermInstVal = new ReturnInst();
3351   ;
3352     break;}
3353 case 182:
3354 #line 1917 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3355 {                         // Unconditional Branch...
3356     yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3357   ;
3358     break;}
3359 case 183:
3360 #line 1920 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3361 {  
3362     yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3363   ;
3364     break;}
3365 case 184:
3366 #line 1923 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3367 {
3368     SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3369     yyval.TermInstVal = S;
3370
3371     std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3372       E = yyvsp[-1].JumpTable->end();
3373     for (; I != E; ++I) {
3374       if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3375           S->addCase(CI, I->second);
3376       else
3377         ThrowException("Switch case is constant, but not a simple integer!");
3378     }
3379     delete yyvsp[-1].JumpTable;
3380   ;
3381     break;}
3382 case 185:
3383 #line 1937 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3384 {
3385     SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3386     yyval.TermInstVal = S;
3387   ;
3388     break;}
3389 case 186:
3390 #line 1942 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3391 {
3392     const PointerType *PFTy;
3393     const FunctionType *Ty;
3394
3395     if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3396         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3397       // Pull out the types of all of the arguments...
3398       std::vector<const Type*> ParamTypes;
3399       if (yyvsp[-7].ValueList) {
3400         for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3401              I != E; ++I)
3402           ParamTypes.push_back((*I)->getType());
3403       }
3404
3405       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3406       if (isVarArg) ParamTypes.pop_back();
3407
3408       Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3409       PFTy = PointerType::get(Ty);
3410     }
3411
3412     Value *V = getVal(PFTy, yyvsp[-9].ValIDVal);   // Get the function we're calling...
3413
3414     BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3415     BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3416
3417     // Create the call node...
3418     if (!yyvsp[-7].ValueList) {                                   // Has no arguments?
3419       yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3420     } else {                                     // Has arguments?
3421       // Loop through FunctionType's arguments and ensure they are specified
3422       // correctly!
3423       //
3424       FunctionType::param_iterator I = Ty->param_begin();
3425       FunctionType::param_iterator E = Ty->param_end();
3426       std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3427
3428       for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3429         if ((*ArgI)->getType() != *I)
3430           ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3431                          (*I)->getDescription() + "'!");
3432
3433       if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3434         ThrowException("Invalid number of parameters detected!");
3435
3436       yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3437     }
3438     cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3439   
3440     delete yyvsp[-10].TypeVal;
3441     delete yyvsp[-7].ValueList;
3442   ;
3443     break;}
3444 case 187:
3445 #line 1994 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3446 {
3447     yyval.TermInstVal = new UnwindInst();
3448   ;
3449     break;}
3450 case 188:
3451 #line 1997 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3452 {
3453     yyval.TermInstVal = new UnreachableInst();
3454   ;
3455     break;}
3456 case 189:
3457 #line 2003 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3458 {
3459     yyval.JumpTable = yyvsp[-5].JumpTable;
3460     Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3461     if (V == 0)
3462       ThrowException("May only switch on a constant pool value!");
3463
3464     yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3465   ;
3466     break;}
3467 case 190:
3468 #line 2011 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3469 {
3470     yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3471     Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3472
3473     if (V == 0)
3474       ThrowException("May only switch on a constant pool value!");
3475
3476     yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3477   ;
3478     break;}
3479 case 191:
3480 #line 2021 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3481 {
3482   // Is this definition named?? if so, assign the name...
3483   setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3484   InsertValue(yyvsp[0].InstVal);
3485   yyval.InstVal = yyvsp[0].InstVal;
3486 ;
3487     break;}
3488 case 192:
3489 #line 2028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3490 {    // Used for PHI nodes
3491     yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3492     yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3493     delete yyvsp[-5].TypeVal;
3494   ;
3495     break;}
3496 case 193:
3497 #line 2033 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3498 {
3499     yyval.PHIList = yyvsp[-6].PHIList;
3500     yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3501                                  getBBVal(yyvsp[-1].ValIDVal)));
3502   ;
3503     break;}
3504 case 194:
3505 #line 2040 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3506 {    // Used for call statements, and memory insts...
3507     yyval.ValueList = new std::vector<Value*>();
3508     yyval.ValueList->push_back(yyvsp[0].ValueVal);
3509   ;
3510     break;}
3511 case 195:
3512 #line 2044 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3513 {
3514     yyval.ValueList = yyvsp[-2].ValueList;
3515     yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
3516   ;
3517     break;}
3518 case 197:
3519 #line 2050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3520 { yyval.ValueList = 0; ;
3521     break;}
3522 case 198:
3523 #line 2052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3524 {
3525     yyval.BoolVal = true;
3526   ;
3527     break;}
3528 case 199:
3529 #line 2055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3530 {
3531     yyval.BoolVal = false;
3532   ;
3533     break;}
3534 case 200:
3535 #line 2061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3536 {
3537     if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && 
3538         !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3539       ThrowException(
3540         "Arithmetic operator requires integer, FP, or packed operands!");
3541     if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3542       ThrowException("Rem not supported on packed types!");
3543     yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3544     if (yyval.InstVal == 0)
3545       ThrowException("binary operator returned null!");
3546     delete yyvsp[-3].TypeVal;
3547   ;
3548     break;}
3549 case 201:
3550 #line 2073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3551 {
3552     if (!(*yyvsp[-3].TypeVal)->isIntegral())
3553       ThrowException("Logical operator requires integral operands!");
3554     yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3555     if (yyval.InstVal == 0)
3556       ThrowException("binary operator returned null!");
3557     delete yyvsp[-3].TypeVal;
3558   ;
3559     break;}
3560 case 202:
3561 #line 2081 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3562 {
3563     if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3564       ThrowException(
3565         "PackedTypes currently not supported in setcc instructions!");
3566     }
3567     yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3568     if (yyval.InstVal == 0)
3569       ThrowException("binary operator returned null!");
3570     delete yyvsp[-3].TypeVal;
3571   ;
3572     break;}
3573 case 203:
3574 #line 2091 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3575 {
3576     std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3577               << " Replacing with 'xor'.\n";
3578
3579     Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3580     if (Ones == 0)
3581       ThrowException("Expected integral type for not instruction!");
3582
3583     yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3584     if (yyval.InstVal == 0)
3585       ThrowException("Could not create a xor instruction!");
3586   ;
3587     break;}
3588 case 204:
3589 #line 2103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3590 {
3591     if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3592       ThrowException("Shift amount must be ubyte!");
3593     if (!yyvsp[-2].ValueVal->getType()->isInteger())
3594       ThrowException("Shift constant expression requires integer operand!");
3595     yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3596   ;
3597     break;}
3598 case 205:
3599 #line 2110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3600 {
3601     if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3602       ThrowException("cast instruction to a non-primitive type: '" +
3603                      yyvsp[0].TypeVal->get()->getDescription() + "'!");
3604     yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3605     delete yyvsp[0].TypeVal;
3606   ;
3607     break;}
3608 case 206:
3609 #line 2117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3610 {
3611     if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3612       ThrowException("select condition must be boolean!");
3613     if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3614       ThrowException("select value types should match!");
3615     yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3616   ;
3617     break;}
3618 case 207:
3619 #line 2124 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3620 {
3621     NewVarArgs = true;
3622     yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3623     delete yyvsp[0].TypeVal;
3624   ;
3625     break;}
3626 case 208:
3627 #line 2129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3628 {
3629     ObsoleteVarArgs = true;
3630     const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3631     Function* NF = CurModule.CurrentModule->
3632       getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3633
3634     //b = vaarg a, t -> 
3635     //foo = alloca 1 of t
3636     //bar = vacopy a 
3637     //store bar -> foo
3638     //b = vaarg foo, t
3639     AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3640     CurBB->getInstList().push_back(foo);
3641     CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3642     CurBB->getInstList().push_back(bar);
3643     CurBB->getInstList().push_back(new StoreInst(bar, foo));
3644     yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3645     delete yyvsp[0].TypeVal;
3646   ;
3647     break;}
3648 case 209:
3649 #line 2148 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3650 {
3651     ObsoleteVarArgs = true;
3652     const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3653     Function* NF = CurModule.CurrentModule->
3654       getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3655
3656     //b = vanext a, t ->
3657     //foo = alloca 1 of t
3658     //bar = vacopy a
3659     //store bar -> foo
3660     //tmp = vaarg foo, t
3661     //b = load foo
3662     AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3663     CurBB->getInstList().push_back(foo);
3664     CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3665     CurBB->getInstList().push_back(bar);
3666     CurBB->getInstList().push_back(new StoreInst(bar, foo));
3667     Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3668     CurBB->getInstList().push_back(tmp);
3669     yyval.InstVal = new LoadInst(foo);
3670     delete yyvsp[0].TypeVal;
3671   ;
3672     break;}
3673 case 210:
3674 #line 2170 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3675 {
3676     const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3677     if (!Ty->isFirstClassType())
3678       ThrowException("PHI node operands must be of first class type!");
3679     yyval.InstVal = new PHINode(Ty);
3680     ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3681     while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3682       if (yyvsp[0].PHIList->front().first->getType() != Ty) 
3683         ThrowException("All elements of a PHI node must be of the same type!");
3684       cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3685       yyvsp[0].PHIList->pop_front();
3686     }
3687     delete yyvsp[0].PHIList;  // Free the list...
3688   ;
3689     break;}
3690 case 211:
3691 #line 2184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3692 {
3693     const PointerType *PFTy;
3694     const FunctionType *Ty;
3695
3696     if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3697         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3698       // Pull out the types of all of the arguments...
3699       std::vector<const Type*> ParamTypes;
3700       if (yyvsp[-1].ValueList) {
3701         for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3702              I != E; ++I)
3703           ParamTypes.push_back((*I)->getType());
3704       }
3705
3706       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3707       if (isVarArg) ParamTypes.pop_back();
3708
3709       if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3710         ThrowException("LLVM functions cannot return aggregate types!");
3711
3712       Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3713       PFTy = PointerType::get(Ty);
3714     }
3715
3716     Value *V = getVal(PFTy, yyvsp[-3].ValIDVal);   // Get the function we're calling...
3717
3718     // Create the call node...
3719     if (!yyvsp[-1].ValueList) {                                   // Has no arguments?
3720       // Make sure no arguments is a good thing!
3721       if (Ty->getNumParams() != 0)
3722         ThrowException("No arguments passed to a function that "
3723                        "expects arguments!");
3724
3725       yyval.InstVal = new CallInst(V, std::vector<Value*>());
3726     } else {                                     // Has arguments?
3727       // Loop through FunctionType's arguments and ensure they are specified
3728       // correctly!
3729       //
3730       FunctionType::param_iterator I = Ty->param_begin();
3731       FunctionType::param_iterator E = Ty->param_end();
3732       std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3733
3734       for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3735         if ((*ArgI)->getType() != *I)
3736           ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3737                          (*I)->getDescription() + "'!");
3738
3739       if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3740         ThrowException("Invalid number of parameters detected!");
3741
3742       yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3743     }
3744     cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3745     cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3746     delete yyvsp[-4].TypeVal;
3747     delete yyvsp[-1].ValueList;
3748   ;
3749     break;}
3750 case 212:
3751 #line 2241 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3752 {
3753     yyval.InstVal = yyvsp[0].InstVal;
3754   ;
3755     break;}
3756 case 213:
3757 #line 2247 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3758
3759     yyval.ValueList = yyvsp[0].ValueList; 
3760   ;
3761     break;}
3762 case 214:
3763 #line 2249 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3764
3765     yyval.ValueList = new std::vector<Value*>(); 
3766   ;
3767     break;}
3768 case 215:
3769 #line 2253 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3770 {
3771     yyval.BoolVal = true;
3772   ;
3773     break;}
3774 case 216:
3775 #line 2256 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3776 {
3777     yyval.BoolVal = false;
3778   ;
3779     break;}
3780 case 217:
3781 #line 2262 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3782 {
3783     yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3784     delete yyvsp[-1].TypeVal;
3785   ;
3786     break;}
3787 case 218:
3788 #line 2266 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3789 {
3790     yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3791     delete yyvsp[-4].TypeVal;
3792   ;
3793     break;}
3794 case 219:
3795 #line 2270 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3796 {
3797     yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3798     delete yyvsp[-1].TypeVal;
3799   ;
3800     break;}
3801 case 220:
3802 #line 2274 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3803 {
3804     yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3805     delete yyvsp[-4].TypeVal;
3806   ;
3807     break;}
3808 case 221:
3809 #line 2278 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3810 {
3811     if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3812       ThrowException("Trying to free nonpointer type " + 
3813                      yyvsp[0].ValueVal->getType()->getDescription() + "!");
3814     yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
3815   ;
3816     break;}
3817 case 222:
3818 #line 2285 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3819 {
3820     if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3821       ThrowException("Can't load from nonpointer type: " +
3822                      (*yyvsp[-1].TypeVal)->getDescription());
3823     if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3824       ThrowException("Can't load from pointer of non-first-class type: " +
3825                      (*yyvsp[-1].TypeVal)->getDescription());
3826     yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3827     delete yyvsp[-1].TypeVal;
3828   ;
3829     break;}
3830 case 223:
3831 #line 2295 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3832 {
3833     const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3834     if (!PT)
3835       ThrowException("Can't store to a nonpointer type: " +
3836                      (*yyvsp[-1].TypeVal)->getDescription());
3837     const Type *ElTy = PT->getElementType();
3838     if (ElTy != yyvsp[-3].ValueVal->getType())
3839       ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3840                      "' into space of type '" + ElTy->getDescription() + "'!");
3841
3842     yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3843     delete yyvsp[-1].TypeVal;
3844   ;
3845     break;}
3846 case 224:
3847 #line 2308 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3848 {
3849     if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3850       ThrowException("getelementptr insn requires pointer operand!");
3851
3852     // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte struct
3853     // indices to uint struct indices for compatibility.
3854     generic_gep_type_iterator<std::vector<Value*>::iterator>
3855       GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3856       GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3857     for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3858       if (isa<StructType>(*GTI))        // Only change struct indices
3859         if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3860           if (CUI->getType() == Type::UByteTy)
3861             (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3862
3863     if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3864       ThrowException("Invalid getelementptr indices for type '" +
3865                      (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3866     yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3867     delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
3868   ;
3869     break;}
3870 }
3871    /* the action file gets copied in in place of this dollarsign */
3872 #line 543 "/usr/share/bison.simple"
3873 \f
3874   yyvsp -= yylen;
3875   yyssp -= yylen;
3876 #ifdef YYLSP_NEEDED
3877   yylsp -= yylen;
3878 #endif
3879
3880 #if YYDEBUG != 0
3881   if (yydebug)
3882     {
3883       short *ssp1 = yyss - 1;
3884       fprintf (stderr, "state stack now");
3885       while (ssp1 != yyssp)
3886         fprintf (stderr, " %d", *++ssp1);
3887       fprintf (stderr, "\n");
3888     }
3889 #endif
3890
3891   *++yyvsp = yyval;
3892
3893 #ifdef YYLSP_NEEDED
3894   yylsp++;
3895   if (yylen == 0)
3896     {
3897       yylsp->first_line = yylloc.first_line;
3898       yylsp->first_column = yylloc.first_column;
3899       yylsp->last_line = (yylsp-1)->last_line;
3900       yylsp->last_column = (yylsp-1)->last_column;
3901       yylsp->text = 0;
3902     }
3903   else
3904     {
3905       yylsp->last_line = (yylsp+yylen-1)->last_line;
3906       yylsp->last_column = (yylsp+yylen-1)->last_column;
3907     }
3908 #endif
3909
3910   /* Now "shift" the result of the reduction.
3911      Determine what state that goes to,
3912      based on the state we popped back to
3913      and the rule number reduced by.  */
3914
3915   yyn = yyr1[yyn];
3916
3917   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
3918   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
3919     yystate = yytable[yystate];
3920   else
3921     yystate = yydefgoto[yyn - YYNTBASE];
3922
3923   goto yynewstate;
3924
3925 yyerrlab:   /* here on detecting error */
3926
3927   if (! yyerrstatus)
3928     /* If not already recovering from an error, report this error.  */
3929     {
3930       ++yynerrs;
3931
3932 #ifdef YYERROR_VERBOSE
3933       yyn = yypact[yystate];
3934
3935       if (yyn > YYFLAG && yyn < YYLAST)
3936         {
3937           int size = 0;
3938           char *msg;
3939           int x, count;
3940
3941           count = 0;
3942           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
3943           for (x = (yyn < 0 ? -yyn : 0);
3944                x < (sizeof(yytname) / sizeof(char *)); x++)
3945             if (yycheck[x + yyn] == x)
3946               size += strlen(yytname[x]) + 15, count++;
3947           msg = (char *) malloc(size + 15);
3948           if (msg != 0)
3949             {
3950               strcpy(msg, "parse error");
3951
3952               if (count < 5)
3953                 {
3954                   count = 0;
3955                   for (x = (yyn < 0 ? -yyn : 0);
3956                        x < (sizeof(yytname) / sizeof(char *)); x++)
3957                     if (yycheck[x + yyn] == x)
3958                       {
3959                         strcat(msg, count == 0 ? ", expecting `" : " or `");
3960                         strcat(msg, yytname[x]);
3961                         strcat(msg, "'");
3962                         count++;
3963                       }
3964                 }
3965               yyerror(msg);
3966               free(msg);
3967             }
3968           else
3969             yyerror ("parse error; also virtual memory exceeded");
3970         }
3971       else
3972 #endif /* YYERROR_VERBOSE */
3973         yyerror("parse error");
3974     }
3975
3976   goto yyerrlab1;
3977 yyerrlab1:   /* here on error raised explicitly by an action */
3978
3979   if (yyerrstatus == 3)
3980     {
3981       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
3982
3983       /* return failure if at end of input */
3984       if (yychar == YYEOF)
3985         YYABORT;
3986
3987 #if YYDEBUG != 0
3988       if (yydebug)
3989         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
3990 #endif
3991
3992       yychar = YYEMPTY;
3993     }
3994
3995   /* Else will try to reuse lookahead token
3996      after shifting the error token.  */
3997
3998   yyerrstatus = 3;              /* Each real token shifted decrements this */
3999
4000   goto yyerrhandle;
4001
4002 yyerrdefault:  /* current state does not do anything special for the error token. */
4003
4004 #if 0
4005   /* This is wrong; only states that explicitly want error tokens
4006      should shift them.  */
4007   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
4008   if (yyn) goto yydefault;
4009 #endif
4010
4011 yyerrpop:   /* pop the current state because it cannot handle the error token */
4012
4013   if (yyssp == yyss) YYABORT;
4014   yyvsp--;
4015   yystate = *--yyssp;
4016 #ifdef YYLSP_NEEDED
4017   yylsp--;
4018 #endif
4019
4020 #if YYDEBUG != 0
4021   if (yydebug)
4022     {
4023       short *ssp1 = yyss - 1;
4024       fprintf (stderr, "Error: state stack now");
4025       while (ssp1 != yyssp)
4026         fprintf (stderr, " %d", *++ssp1);
4027       fprintf (stderr, "\n");
4028     }
4029 #endif
4030
4031 yyerrhandle:
4032
4033   yyn = yypact[yystate];
4034   if (yyn == YYFLAG)
4035     goto yyerrdefault;
4036
4037   yyn += YYTERROR;
4038   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4039     goto yyerrdefault;
4040
4041   yyn = yytable[yyn];
4042   if (yyn < 0)
4043     {
4044       if (yyn == YYFLAG)
4045         goto yyerrpop;
4046       yyn = -yyn;
4047       goto yyreduce;
4048     }
4049   else if (yyn == 0)
4050     goto yyerrpop;
4051
4052   if (yyn == YYFINAL)
4053     YYACCEPT;
4054
4055 #if YYDEBUG != 0
4056   if (yydebug)
4057     fprintf(stderr, "Shifting error token, ");
4058 #endif
4059
4060   *++yyvsp = yylval;
4061 #ifdef YYLSP_NEEDED
4062   *++yylsp = yylloc;
4063 #endif
4064
4065   yystate = yyn;
4066   goto yynewstate;
4067
4068  yyacceptlab:
4069   /* YYACCEPT comes here.  */
4070   if (yyfree_stacks)
4071     {
4072       free (yyss);
4073       free (yyvs);
4074 #ifdef YYLSP_NEEDED
4075       free (yyls);
4076 #endif
4077     }
4078   return 0;
4079
4080  yyabortlab:
4081   /* YYABORT comes here.  */
4082   if (yyfree_stacks)
4083     {
4084       free (yyss);
4085       free (yyvs);
4086 #ifdef YYLSP_NEEDED
4087       free (yyls);
4088 #endif
4089     }
4090   return 1;
4091 }
4092 #line 2331 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4093
4094 int yyerror(const char *ErrorMsg) {
4095   std::string where 
4096     = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4097                   + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4098   std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4099   if (yychar == YYEMPTY || yychar == 0)
4100     errMsg += "end-of-file.";
4101   else
4102     errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4103   ThrowException(errMsg);
4104   return 0;
4105 }