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