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