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