Regenerate
[oota-llvm.git] / tools / llvm-upgrade / UpgradeParser.cpp.cvs
1 /* A Bison parser, made by GNU Bison 2.3.  */
2
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
4
5    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6    Free Software Foundation, Inc.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2, or (at your option)
11    any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    Boston, MA 02110-1301, USA.  */
22
23 /* As a special exception, you may create a larger work that contains
24    part or all of the Bison parser skeleton and distribute that work
25    under terms of your choice, so long as that work isn't itself a
26    parser generator using the skeleton or a modified version thereof
27    as a parser skeleton.  Alternatively, if you modify or redistribute
28    the parser skeleton itself, you may (at your option) remove this
29    special exception, which will cause the skeleton and the resulting
30    Bison output files to be licensed under the GNU General Public
31    License without this special exception.
32
33    This special exception was added by the Free Software Foundation in
34    version 2.2 of Bison.  */
35
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37    simplifying the original so-called "semantic" parser.  */
38
39 /* All symbols defined below should begin with yy or YY, to avoid
40    infringing on user name space.  This should be done even for local
41    variables, as they might otherwise be expanded by user macros.
42    There are some unavoidable exceptions within include files to
43    define necessary library symbols; they are noted "INFRINGES ON
44    USER NAME SPACE" below.  */
45
46 /* Identify Bison output.  */
47 #define YYBISON 1
48
49 /* Bison version.  */
50 #define YYBISON_VERSION "2.3"
51
52 /* Skeleton name.  */
53 #define YYSKELETON_NAME "yacc.c"
54
55 /* Pure parsers.  */
56 #define YYPURE 0
57
58 /* Using locations.  */
59 #define YYLSP_NEEDED 0
60
61 /* Substitute the variable and function names.  */
62 #define yyparse Upgradeparse
63 #define yylex   Upgradelex
64 #define yyerror Upgradeerror
65 #define yylval  Upgradelval
66 #define yychar  Upgradechar
67 #define yydebug Upgradedebug
68 #define yynerrs Upgradenerrs
69
70
71 /* Tokens.  */
72 #ifndef YYTOKENTYPE
73 # define YYTOKENTYPE
74    /* Put the tokens into the symbol table, so that GDB and other debuggers
75       know about them.  */
76    enum yytokentype {
77      ESINT64VAL = 258,
78      EUINT64VAL = 259,
79      SINTVAL = 260,
80      UINTVAL = 261,
81      FPVAL = 262,
82      VOID = 263,
83      BOOL = 264,
84      SBYTE = 265,
85      UBYTE = 266,
86      SHORT = 267,
87      USHORT = 268,
88      INT = 269,
89      UINT = 270,
90      LONG = 271,
91      ULONG = 272,
92      FLOAT = 273,
93      DOUBLE = 274,
94      TYPE = 275,
95      LABEL = 276,
96      VAR_ID = 277,
97      LABELSTR = 278,
98      STRINGCONSTANT = 279,
99      IMPLEMENTATION = 280,
100      ZEROINITIALIZER = 281,
101      TRUETOK = 282,
102      FALSETOK = 283,
103      BEGINTOK = 284,
104      ENDTOK = 285,
105      DECLARE = 286,
106      GLOBAL = 287,
107      CONSTANT = 288,
108      SECTION = 289,
109      VOLATILE = 290,
110      TO = 291,
111      DOTDOTDOT = 292,
112      NULL_TOK = 293,
113      UNDEF = 294,
114      CONST = 295,
115      INTERNAL = 296,
116      LINKONCE = 297,
117      WEAK = 298,
118      APPENDING = 299,
119      DLLIMPORT = 300,
120      DLLEXPORT = 301,
121      EXTERN_WEAK = 302,
122      OPAQUE = 303,
123      NOT = 304,
124      EXTERNAL = 305,
125      TARGET = 306,
126      TRIPLE = 307,
127      ENDIAN = 308,
128      POINTERSIZE = 309,
129      LITTLE = 310,
130      BIG = 311,
131      ALIGN = 312,
132      DEPLIBS = 313,
133      CALL = 314,
134      TAIL = 315,
135      ASM_TOK = 316,
136      MODULE = 317,
137      SIDEEFFECT = 318,
138      CC_TOK = 319,
139      CCC_TOK = 320,
140      CSRETCC_TOK = 321,
141      FASTCC_TOK = 322,
142      COLDCC_TOK = 323,
143      X86_STDCALLCC_TOK = 324,
144      X86_FASTCALLCC_TOK = 325,
145      DATALAYOUT = 326,
146      RET = 327,
147      BR = 328,
148      SWITCH = 329,
149      INVOKE = 330,
150      UNREACHABLE = 331,
151      UNWIND = 332,
152      EXCEPT = 333,
153      ADD = 334,
154      SUB = 335,
155      MUL = 336,
156      DIV = 337,
157      UDIV = 338,
158      SDIV = 339,
159      FDIV = 340,
160      REM = 341,
161      UREM = 342,
162      SREM = 343,
163      FREM = 344,
164      AND = 345,
165      OR = 346,
166      XOR = 347,
167      SETLE = 348,
168      SETGE = 349,
169      SETLT = 350,
170      SETGT = 351,
171      SETEQ = 352,
172      SETNE = 353,
173      ICMP = 354,
174      FCMP = 355,
175      MALLOC = 356,
176      ALLOCA = 357,
177      FREE = 358,
178      LOAD = 359,
179      STORE = 360,
180      GETELEMENTPTR = 361,
181      PHI_TOK = 362,
182      SELECT = 363,
183      SHL = 364,
184      SHR = 365,
185      ASHR = 366,
186      LSHR = 367,
187      VAARG = 368,
188      EXTRACTELEMENT = 369,
189      INSERTELEMENT = 370,
190      SHUFFLEVECTOR = 371,
191      VAARG_old = 372,
192      VANEXT_old = 373,
193      EQ = 374,
194      NE = 375,
195      SLT = 376,
196      SGT = 377,
197      SLE = 378,
198      SGE = 379,
199      ULT = 380,
200      UGT = 381,
201      ULE = 382,
202      UGE = 383,
203      OEQ = 384,
204      ONE = 385,
205      OLT = 386,
206      OGT = 387,
207      OLE = 388,
208      OGE = 389,
209      ORD = 390,
210      UNO = 391,
211      UEQ = 392,
212      UNE = 393,
213      CAST = 394,
214      TRUNC = 395,
215      ZEXT = 396,
216      SEXT = 397,
217      FPTRUNC = 398,
218      FPEXT = 399,
219      FPTOUI = 400,
220      FPTOSI = 401,
221      UITOFP = 402,
222      SITOFP = 403,
223      PTRTOINT = 404,
224      INTTOPTR = 405,
225      BITCAST = 406
226    };
227 #endif
228 /* Tokens.  */
229 #define ESINT64VAL 258
230 #define EUINT64VAL 259
231 #define SINTVAL 260
232 #define UINTVAL 261
233 #define FPVAL 262
234 #define VOID 263
235 #define BOOL 264
236 #define SBYTE 265
237 #define UBYTE 266
238 #define SHORT 267
239 #define USHORT 268
240 #define INT 269
241 #define UINT 270
242 #define LONG 271
243 #define ULONG 272
244 #define FLOAT 273
245 #define DOUBLE 274
246 #define TYPE 275
247 #define LABEL 276
248 #define VAR_ID 277
249 #define LABELSTR 278
250 #define STRINGCONSTANT 279
251 #define IMPLEMENTATION 280
252 #define ZEROINITIALIZER 281
253 #define TRUETOK 282
254 #define FALSETOK 283
255 #define BEGINTOK 284
256 #define ENDTOK 285
257 #define DECLARE 286
258 #define GLOBAL 287
259 #define CONSTANT 288
260 #define SECTION 289
261 #define VOLATILE 290
262 #define TO 291
263 #define DOTDOTDOT 292
264 #define NULL_TOK 293
265 #define UNDEF 294
266 #define CONST 295
267 #define INTERNAL 296
268 #define LINKONCE 297
269 #define WEAK 298
270 #define APPENDING 299
271 #define DLLIMPORT 300
272 #define DLLEXPORT 301
273 #define EXTERN_WEAK 302
274 #define OPAQUE 303
275 #define NOT 304
276 #define EXTERNAL 305
277 #define TARGET 306
278 #define TRIPLE 307
279 #define ENDIAN 308
280 #define POINTERSIZE 309
281 #define LITTLE 310
282 #define BIG 311
283 #define ALIGN 312
284 #define DEPLIBS 313
285 #define CALL 314
286 #define TAIL 315
287 #define ASM_TOK 316
288 #define MODULE 317
289 #define SIDEEFFECT 318
290 #define CC_TOK 319
291 #define CCC_TOK 320
292 #define CSRETCC_TOK 321
293 #define FASTCC_TOK 322
294 #define COLDCC_TOK 323
295 #define X86_STDCALLCC_TOK 324
296 #define X86_FASTCALLCC_TOK 325
297 #define DATALAYOUT 326
298 #define RET 327
299 #define BR 328
300 #define SWITCH 329
301 #define INVOKE 330
302 #define UNREACHABLE 331
303 #define UNWIND 332
304 #define EXCEPT 333
305 #define ADD 334
306 #define SUB 335
307 #define MUL 336
308 #define DIV 337
309 #define UDIV 338
310 #define SDIV 339
311 #define FDIV 340
312 #define REM 341
313 #define UREM 342
314 #define SREM 343
315 #define FREM 344
316 #define AND 345
317 #define OR 346
318 #define XOR 347
319 #define SETLE 348
320 #define SETGE 349
321 #define SETLT 350
322 #define SETGT 351
323 #define SETEQ 352
324 #define SETNE 353
325 #define ICMP 354
326 #define FCMP 355
327 #define MALLOC 356
328 #define ALLOCA 357
329 #define FREE 358
330 #define LOAD 359
331 #define STORE 360
332 #define GETELEMENTPTR 361
333 #define PHI_TOK 362
334 #define SELECT 363
335 #define SHL 364
336 #define SHR 365
337 #define ASHR 366
338 #define LSHR 367
339 #define VAARG 368
340 #define EXTRACTELEMENT 369
341 #define INSERTELEMENT 370
342 #define SHUFFLEVECTOR 371
343 #define VAARG_old 372
344 #define VANEXT_old 373
345 #define EQ 374
346 #define NE 375
347 #define SLT 376
348 #define SGT 377
349 #define SLE 378
350 #define SGE 379
351 #define ULT 380
352 #define UGT 381
353 #define ULE 382
354 #define UGE 383
355 #define OEQ 384
356 #define ONE 385
357 #define OLT 386
358 #define OGT 387
359 #define OLE 388
360 #define OGE 389
361 #define ORD 390
362 #define UNO 391
363 #define UEQ 392
364 #define UNE 393
365 #define CAST 394
366 #define TRUNC 395
367 #define ZEXT 396
368 #define SEXT 397
369 #define FPTRUNC 398
370 #define FPEXT 399
371 #define FPTOUI 400
372 #define FPTOSI 401
373 #define UITOFP 402
374 #define SITOFP 403
375 #define PTRTOINT 404
376 #define INTTOPTR 405
377 #define BITCAST 406
378
379
380
381
382 /* Copy the first part of user declarations.  */
383 #line 14 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
384
385 #include "UpgradeInternals.h"
386 #include "llvm/CallingConv.h"
387 #include "llvm/InlineAsm.h"
388 #include "llvm/Instructions.h"
389 #include "llvm/Module.h"
390 #include "llvm/SymbolTable.h"
391 #include "llvm/Support/GetElementPtrTypeIterator.h"
392 #include "llvm/ADT/STLExtras.h"
393 #include "llvm/Support/MathExtras.h"
394 #include <algorithm>
395 #include <iostream>
396 #include <list>
397 #include <utility>
398
399 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
400 // relating to upreferences in the input stream.
401 //
402 //#define DEBUG_UPREFS 1
403 #ifdef DEBUG_UPREFS
404 #define UR_OUT(X) std::cerr << X
405 #else
406 #define UR_OUT(X)
407 #endif
408
409 #define YYERROR_VERBOSE 1
410 #define YYINCLUDED_STDLIB_H
411 #define YYDEBUG 1
412
413 int yylex();
414 int yyparse();
415
416 int yyerror(const char*);
417 static void warning(const std::string& WarningMsg);
418
419 namespace llvm {
420
421 std::istream* LexInput;
422 static std::string CurFilename;
423
424 // This bool controls whether attributes are ever added to function declarations
425 // definitions and calls.
426 static bool AddAttributes = false;
427
428 static Module *ParserResult;
429 static bool ObsoleteVarArgs;
430 static bool NewVarArgs;
431 static BasicBlock *CurBB;
432 static GlobalVariable *CurGV;
433
434 // This contains info used when building the body of a function.  It is
435 // destroyed when the function is completed.
436 //
437 typedef std::vector<Value *> ValueList;           // Numbered defs
438
439 typedef std::pair<std::string,const Type*> RenameMapKey;
440 typedef std::map<RenameMapKey,std::string> RenameMapType;
441
442 static void 
443 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
444                    std::map<const Type *,ValueList> *FutureLateResolvers = 0);
445
446 static struct PerModuleInfo {
447   Module *CurrentModule;
448   std::map<const Type *, ValueList> Values; // Module level numbered definitions
449   std::map<const Type *,ValueList> LateResolveValues;
450   std::vector<PATypeHolder>    Types;
451   std::map<ValID, PATypeHolder> LateResolveTypes;
452   static Module::Endianness Endian;
453   static Module::PointerSize PointerSize;
454   RenameMapType RenameMap;
455
456   /// PlaceHolderInfo - When temporary placeholder objects are created, remember
457   /// how they were referenced and on which line of the input they came from so
458   /// that we can resolve them later and print error messages as appropriate.
459   std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
460
461   // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
462   // references to global values.  Global values may be referenced before they
463   // are defined, and if so, the temporary object that they represent is held
464   // here.  This is used for forward references of GlobalValues.
465   //
466   typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*> 
467     GlobalRefsType;
468   GlobalRefsType GlobalRefs;
469
470   void ModuleDone() {
471     // If we could not resolve some functions at function compilation time
472     // (calls to functions before they are defined), resolve them now...  Types
473     // are resolved when the constant pool has been completely parsed.
474     //
475     ResolveDefinitions(LateResolveValues);
476
477     // Check to make sure that all global value forward references have been
478     // resolved!
479     //
480     if (!GlobalRefs.empty()) {
481       std::string UndefinedReferences = "Unresolved global references exist:\n";
482
483       for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
484            I != E; ++I) {
485         UndefinedReferences += "  " + I->first.first->getDescription() + " " +
486                                I->first.second.getName() + "\n";
487       }
488       error(UndefinedReferences);
489       return;
490     }
491
492     if (CurrentModule->getDataLayout().empty()) {
493       std::string dataLayout;
494       if (Endian != Module::AnyEndianness)
495         dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
496       if (PointerSize != Module::AnyPointerSize) {
497         if (!dataLayout.empty())
498           dataLayout += "-";
499         dataLayout.append(PointerSize == Module::Pointer64 ? 
500                           "p:64:64" : "p:32:32");
501       }
502       CurrentModule->setDataLayout(dataLayout);
503     }
504
505     Values.clear();         // Clear out function local definitions
506     Types.clear();
507     CurrentModule = 0;
508   }
509
510   // GetForwardRefForGlobal - Check to see if there is a forward reference
511   // for this global.  If so, remove it from the GlobalRefs map and return it.
512   // If not, just return null.
513   GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
514     // Check to see if there is a forward reference to this global variable...
515     // if there is, eliminate it and patch the reference to use the new def'n.
516     GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
517     GlobalValue *Ret = 0;
518     if (I != GlobalRefs.end()) {
519       Ret = I->second;
520       GlobalRefs.erase(I);
521     }
522     return Ret;
523   }
524   void setEndianness(Module::Endianness E) { Endian = E; }
525   void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
526 } CurModule;
527
528 Module::Endianness  PerModuleInfo::Endian = Module::AnyEndianness;
529 Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
530
531 static struct PerFunctionInfo {
532   Function *CurrentFunction;     // Pointer to current function being created
533
534   std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
535   std::map<const Type*, ValueList> LateResolveValues;
536   bool isDeclare;                   // Is this function a forward declararation?
537   GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
538
539   /// BBForwardRefs - When we see forward references to basic blocks, keep
540   /// track of them here.
541   std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
542   std::vector<BasicBlock*> NumberedBlocks;
543   RenameMapType RenameMap;
544   unsigned NextBBNum;
545
546   inline PerFunctionInfo() {
547     CurrentFunction = 0;
548     isDeclare = false;
549     Linkage = GlobalValue::ExternalLinkage;    
550   }
551
552   inline void FunctionStart(Function *M) {
553     CurrentFunction = M;
554     NextBBNum = 0;
555   }
556
557   void FunctionDone() {
558     NumberedBlocks.clear();
559
560     // Any forward referenced blocks left?
561     if (!BBForwardRefs.empty()) {
562       error("Undefined reference to label " + 
563             BBForwardRefs.begin()->first->getName());
564       return;
565     }
566
567     // Resolve all forward references now.
568     ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
569
570     Values.clear();         // Clear out function local definitions
571     RenameMap.clear();
572     CurrentFunction = 0;
573     isDeclare = false;
574     Linkage = GlobalValue::ExternalLinkage;
575   }
576 } CurFun;  // Info for the current function...
577
578 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
579
580
581 //===----------------------------------------------------------------------===//
582 //               Code to handle definitions of all the types
583 //===----------------------------------------------------------------------===//
584
585 static int InsertValue(Value *V,
586                   std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
587   if (V->hasName()) return -1;           // Is this a numbered definition?
588
589   // Yes, insert the value into the value table...
590   ValueList &List = ValueTab[V->getType()];
591   List.push_back(V);
592   return List.size()-1;
593 }
594
595 static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
596   switch (D.Type) {
597   case ValID::NumberVal:               // Is it a numbered definition?
598     // Module constants occupy the lowest numbered slots...
599     if ((unsigned)D.Num < CurModule.Types.size()) {
600       return CurModule.Types[(unsigned)D.Num];
601     }
602     break;
603   case ValID::NameVal:                 // Is it a named definition?
604     if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
605       D.destroy();  // Free old strdup'd memory...
606       return N;
607     }
608     break;
609   default:
610     error("Internal parser error: Invalid symbol type reference");
611     return 0;
612   }
613
614   // If we reached here, we referenced either a symbol that we don't know about
615   // or an id number that hasn't been read yet.  We may be referencing something
616   // forward, so just create an entry to be resolved later and get to it...
617   //
618   if (DoNotImprovise) return 0;  // Do we just want a null to be returned?
619
620
621   if (inFunctionScope()) {
622     if (D.Type == ValID::NameVal) {
623       error("Reference to an undefined type: '" + D.getName() + "'");
624       return 0;
625     } else {
626       error("Reference to an undefined type: #" + itostr(D.Num));
627       return 0;
628     }
629   }
630
631   std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
632   if (I != CurModule.LateResolveTypes.end())
633     return I->second;
634
635   Type *Typ = OpaqueType::get();
636   CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
637   return Typ;
638  }
639
640 // getExistingValue - Look up the value specified by the provided type and
641 // the provided ValID.  If the value exists and has already been defined, return
642 // it.  Otherwise return null.
643 //
644 static Value *getExistingValue(const Type *Ty, const ValID &D) {
645   if (isa<FunctionType>(Ty)) {
646     error("Functions are not values and must be referenced as pointers");
647   }
648
649   switch (D.Type) {
650   case ValID::NumberVal: {                 // Is it a numbered definition?
651     unsigned Num = (unsigned)D.Num;
652
653     // Module constants occupy the lowest numbered slots...
654     std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
655     if (VI != CurModule.Values.end()) {
656       if (Num < VI->second.size())
657         return VI->second[Num];
658       Num -= VI->second.size();
659     }
660
661     // Make sure that our type is within bounds
662     VI = CurFun.Values.find(Ty);
663     if (VI == CurFun.Values.end()) return 0;
664
665     // Check that the number is within bounds...
666     if (VI->second.size() <= Num) return 0;
667
668     return VI->second[Num];
669   }
670
671   case ValID::NameVal: {                // Is it a named definition?
672     // Get the name out of the ID
673     std::string Name(D.Name);
674     Value* V = 0;
675     RenameMapKey Key = std::make_pair(Name, Ty);
676     if (inFunctionScope()) {
677       // See if the name was renamed
678       RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
679       std::string LookupName;
680       if (I != CurFun.RenameMap.end())
681         LookupName = I->second;
682       else
683         LookupName = Name;
684       SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
685       V = SymTab.lookup(Ty, LookupName);
686     }
687     if (!V) {
688       RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
689       std::string LookupName;
690       if (I != CurModule.RenameMap.end())
691         LookupName = I->second;
692       else
693         LookupName = Name;
694       V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
695     }
696     if (V == 0) 
697       return 0;
698
699     D.destroy();  // Free old strdup'd memory...
700     return V;
701   }
702
703   // Check to make sure that "Ty" is an integral type, and that our
704   // value will fit into the specified type...
705   case ValID::ConstSIntVal:    // Is it a constant pool reference??
706     if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
707       error("Signed integral constant '" + itostr(D.ConstPool64) + 
708             "' is invalid for type '" + Ty->getDescription() + "'");
709     }
710     return ConstantInt::get(Ty, D.ConstPool64);
711
712   case ValID::ConstUIntVal:     // Is it an unsigned const pool reference?
713     if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
714       if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
715         error("Integral constant '" + utostr(D.UConstPool64) + 
716               "' is invalid or out of range");
717       else     // This is really a signed reference.  Transmogrify.
718         return ConstantInt::get(Ty, D.ConstPool64);
719     } else
720       return ConstantInt::get(Ty, D.UConstPool64);
721
722   case ValID::ConstFPVal:        // Is it a floating point const pool reference?
723     if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
724       error("FP constant invalid for type");
725     return ConstantFP::get(Ty, D.ConstPoolFP);
726
727   case ValID::ConstNullVal:      // Is it a null value?
728     if (!isa<PointerType>(Ty))
729       error("Cannot create a a non pointer null");
730     return ConstantPointerNull::get(cast<PointerType>(Ty));
731
732   case ValID::ConstUndefVal:      // Is it an undef value?
733     return UndefValue::get(Ty);
734
735   case ValID::ConstZeroVal:      // Is it a zero value?
736     return Constant::getNullValue(Ty);
737     
738   case ValID::ConstantVal:       // Fully resolved constant?
739     if (D.ConstantValue->getType() != Ty) 
740       error("Constant expression type different from required type");
741     return D.ConstantValue;
742
743   case ValID::InlineAsmVal: {    // Inline asm expression
744     const PointerType *PTy = dyn_cast<PointerType>(Ty);
745     const FunctionType *FTy =
746       PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
747     if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
748       error("Invalid type for asm constraint string");
749     InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
750                                    D.IAD->HasSideEffects);
751     D.destroy();   // Free InlineAsmDescriptor.
752     return IA;
753   }
754   default:
755     assert(0 && "Unhandled case");
756     return 0;
757   }   // End of switch
758
759   assert(0 && "Unhandled case");
760   return 0;
761 }
762
763 // getVal - This function is identical to getExistingValue, except that if a
764 // value is not already defined, it "improvises" by creating a placeholder var
765 // that looks and acts just like the requested variable.  When the value is
766 // defined later, all uses of the placeholder variable are replaced with the
767 // real thing.
768 //
769 static Value *getVal(const Type *Ty, const ValID &ID) {
770   if (Ty == Type::LabelTy)
771     error("Cannot use a basic block here");
772
773   // See if the value has already been defined.
774   Value *V = getExistingValue(Ty, ID);
775   if (V) return V;
776
777   if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
778     error("Invalid use of a composite type");
779
780   // If we reached here, we referenced either a symbol that we don't know about
781   // or an id number that hasn't been read yet.  We may be referencing something
782   // forward, so just create an entry to be resolved later and get to it...
783   V = new Argument(Ty);
784
785   // Remember where this forward reference came from.  FIXME, shouldn't we try
786   // to recycle these things??
787   CurModule.PlaceHolderInfo.insert(
788     std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
789
790   if (inFunctionScope())
791     InsertValue(V, CurFun.LateResolveValues);
792   else
793     InsertValue(V, CurModule.LateResolveValues);
794   return V;
795 }
796
797 /// getBBVal - This is used for two purposes:
798 ///  * If isDefinition is true, a new basic block with the specified ID is being
799 ///    defined.
800 ///  * If isDefinition is true, this is a reference to a basic block, which may
801 ///    or may not be a forward reference.
802 ///
803 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
804   assert(inFunctionScope() && "Can't get basic block at global scope");
805
806   std::string Name;
807   BasicBlock *BB = 0;
808   switch (ID.Type) {
809   default: 
810     error("Illegal label reference " + ID.getName());
811     break;
812   case ValID::NumberVal:                // Is it a numbered definition?
813     if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
814       CurFun.NumberedBlocks.resize(ID.Num+1);
815     BB = CurFun.NumberedBlocks[ID.Num];
816     break;
817   case ValID::NameVal:                  // Is it a named definition?
818     Name = ID.Name;
819     if (Value *N = CurFun.CurrentFunction->
820                    getValueSymbolTable().lookup(Type::LabelTy, Name)) {
821       if (N->getType() != Type::LabelTy)
822         error("Name '" + Name + "' does not refer to a BasicBlock");
823       BB = cast<BasicBlock>(N);
824     }
825     break;
826   }
827
828   // See if the block has already been defined.
829   if (BB) {
830     // If this is the definition of the block, make sure the existing value was
831     // just a forward reference.  If it was a forward reference, there will be
832     // an entry for it in the PlaceHolderInfo map.
833     if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
834       // The existing value was a definition, not a forward reference.
835       error("Redefinition of label " + ID.getName());
836
837     ID.destroy();                       // Free strdup'd memory.
838     return BB;
839   }
840
841   // Otherwise this block has not been seen before.
842   BB = new BasicBlock("", CurFun.CurrentFunction);
843   if (ID.Type == ValID::NameVal) {
844     BB->setName(ID.Name);
845   } else {
846     CurFun.NumberedBlocks[ID.Num] = BB;
847   }
848
849   // If this is not a definition, keep track of it so we can use it as a forward
850   // reference.
851   if (!isDefinition) {
852     // Remember where this forward reference came from.
853     CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
854   } else {
855     // The forward declaration could have been inserted anywhere in the
856     // function: insert it into the correct place now.
857     CurFun.CurrentFunction->getBasicBlockList().remove(BB);
858     CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
859   }
860   ID.destroy();
861   return BB;
862 }
863
864
865 //===----------------------------------------------------------------------===//
866 //              Code to handle forward references in instructions
867 //===----------------------------------------------------------------------===//
868 //
869 // This code handles the late binding needed with statements that reference
870 // values not defined yet... for example, a forward branch, or the PHI node for
871 // a loop body.
872 //
873 // This keeps a table (CurFun.LateResolveValues) of all such forward references
874 // and back patchs after we are done.
875 //
876
877 // ResolveDefinitions - If we could not resolve some defs at parsing
878 // time (forward branches, phi functions for loops, etc...) resolve the
879 // defs now...
880 //
881 static void 
882 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
883                    std::map<const Type*,ValueList> *FutureLateResolvers) {
884   // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
885   for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
886          E = LateResolvers.end(); LRI != E; ++LRI) {
887     ValueList &List = LRI->second;
888     while (!List.empty()) {
889       Value *V = List.back();
890       List.pop_back();
891
892       std::map<Value*, std::pair<ValID, int> >::iterator PHI =
893         CurModule.PlaceHolderInfo.find(V);
894       assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
895
896       ValID &DID = PHI->second.first;
897
898       Value *TheRealValue = getExistingValue(LRI->first, DID);
899       if (TheRealValue) {
900         V->replaceAllUsesWith(TheRealValue);
901         delete V;
902         CurModule.PlaceHolderInfo.erase(PHI);
903       } else if (FutureLateResolvers) {
904         // Functions have their unresolved items forwarded to the module late
905         // resolver table
906         InsertValue(V, *FutureLateResolvers);
907       } else {
908         if (DID.Type == ValID::NameVal) {
909           error("Reference to an invalid definition: '" +DID.getName()+
910                 "' of type '" + V->getType()->getDescription() + "'",
911                 PHI->second.second);
912           return;
913         } else {
914           error("Reference to an invalid definition: #" +
915                 itostr(DID.Num) + " of type '" + 
916                 V->getType()->getDescription() + "'", PHI->second.second);
917           return;
918         }
919       }
920     }
921   }
922
923   LateResolvers.clear();
924 }
925
926 // ResolveTypeTo - A brand new type was just declared.  This means that (if
927 // name is not null) things referencing Name can be resolved.  Otherwise, things
928 // refering to the number can be resolved.  Do this now.
929 //
930 static void ResolveTypeTo(char *Name, const Type *ToTy) {
931   ValID D;
932   if (Name) D = ValID::create(Name);
933   else      D = ValID::create((int)CurModule.Types.size());
934
935   std::map<ValID, PATypeHolder>::iterator I =
936     CurModule.LateResolveTypes.find(D);
937   if (I != CurModule.LateResolveTypes.end()) {
938     ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
939     CurModule.LateResolveTypes.erase(I);
940   }
941 }
942
943 static std::string makeNameUnique(const std::string& Name) {
944   static unsigned UniqueNameCounter = 1;
945   std::string Result(Name);
946   Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
947   return Result;
948 }
949
950 // setValueName - Set the specified value to the name given.  The name may be
951 // null potentially, in which case this is a noop.  The string passed in is
952 // assumed to be a malloc'd string buffer, and is free'd by this function.
953 //
954 static void setValueName(Value *V, char *NameStr) {
955   if (NameStr) {
956     std::string Name(NameStr);      // Copy string
957     free(NameStr);                  // Free old string
958
959     if (V->getType() == Type::VoidTy) {
960       error("Can't assign name '" + Name + "' to value with void type");
961       return;
962     }
963
964     assert(inFunctionScope() && "Must be in function scope");
965
966     // Search the function's symbol table for an existing value of this name
967     Value* Existing = 0;
968     SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
969     SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
970     for ( ; PI != PE; ++PI) {
971       SymbolTable::value_const_iterator VI = PI->second.find(Name);
972       if (VI != PI->second.end()) {
973         Existing = VI->second;
974         break;
975       }
976     }
977     if (Existing) {
978       if (Existing->getType() == V->getType()) {
979         // The type of the Existing value and the new one are the same. This
980         // is probably a type plane collapsing error. If the types involved
981         // are both integer, just rename it. Otherwise it 
982         // is a redefinition error.
983         if (!Existing->getType()->isInteger()) {
984           error("Redefinition of value named '" + Name + "' in the '" +
985                 V->getType()->getDescription() + "' type plane");
986           return;
987         }
988       } 
989       // In LLVM 2.0 we don't allow names to be re-used for any values in a 
990       // function, regardless of Type. Previously re-use of names was okay as 
991       // long as they were distinct types. With type planes collapsing because
992       // of the signedness change and because of PR411, this can no longer be
993       // supported. We must search the entire symbol table for a conflicting
994       // name and make the name unique. No warning is needed as this can't 
995       // cause a problem.
996       std::string NewName = makeNameUnique(Name);
997       // We're changing the name but it will probably be used by other 
998       // instructions as operands later on. Consequently we have to retain
999       // a mapping of the renaming that we're doing.
1000       RenameMapKey Key = std::make_pair(Name,V->getType());
1001       CurFun.RenameMap[Key] = NewName;
1002       Name = NewName;
1003     }
1004
1005     // Set the name.
1006     V->setName(Name);
1007   }
1008 }
1009
1010 /// ParseGlobalVariable - Handle parsing of a global.  If Initializer is null,
1011 /// this is a declaration, otherwise it is a definition.
1012 static GlobalVariable *
1013 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1014                     bool isConstantGlobal, const Type *Ty,
1015                     Constant *Initializer) {
1016   if (isa<FunctionType>(Ty))
1017     error("Cannot declare global vars of function type");
1018
1019   const PointerType *PTy = PointerType::get(Ty);
1020
1021   std::string Name;
1022   if (NameStr) {
1023     Name = NameStr;      // Copy string
1024     free(NameStr);       // Free old string
1025   }
1026
1027   // See if this global value was forward referenced.  If so, recycle the
1028   // object.
1029   ValID ID;
1030   if (!Name.empty()) {
1031     ID = ValID::create((char*)Name.c_str());
1032   } else {
1033     ID = ValID::create((int)CurModule.Values[PTy].size());
1034   }
1035
1036   if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1037     // Move the global to the end of the list, from whereever it was
1038     // previously inserted.
1039     GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1040     CurModule.CurrentModule->getGlobalList().remove(GV);
1041     CurModule.CurrentModule->getGlobalList().push_back(GV);
1042     GV->setInitializer(Initializer);
1043     GV->setLinkage(Linkage);
1044     GV->setConstant(isConstantGlobal);
1045     InsertValue(GV, CurModule.Values);
1046     return GV;
1047   }
1048
1049   // If this global has a name, check to see if there is already a definition
1050   // of this global in the module and emit warnings if there are conflicts.
1051   if (!Name.empty()) {
1052     // The global has a name. See if there's an existing one of the same name.
1053     if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1054       // We found an existing global ov the same name. This isn't allowed 
1055       // in LLVM 2.0. Consequently, we must alter the name of the global so it
1056       // can at least compile. This can happen because of type planes 
1057       // There is alread a global of the same name which means there is a
1058       // conflict. Let's see what we can do about it.
1059       std::string NewName(makeNameUnique(Name));
1060       if (Linkage == GlobalValue::InternalLinkage) {
1061         // The linkage type is internal so just warn about the rename without
1062         // invoking "scarey language" about linkage failures. GVars with
1063         // InternalLinkage can be renamed at will.
1064         warning("Global variable '" + Name + "' was renamed to '"+ 
1065                 NewName + "'");
1066       } else {
1067         // The linkage of this gval is external so we can't reliably rename 
1068         // it because it could potentially create a linking problem.  
1069         // However, we can't leave the name conflict in the output either or 
1070         // it won't assemble with LLVM 2.0.  So, all we can do is rename 
1071         // this one to something unique and emit a warning about the problem.
1072         warning("Renaming global variable '" + Name + "' to '" + NewName + 
1073                   "' may cause linkage errors");
1074       }
1075
1076       // Put the renaming in the global rename map
1077       RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1078       CurModule.RenameMap[Key] = NewName;
1079
1080       // Rename it
1081       Name = NewName;
1082     }
1083   }
1084
1085   // Otherwise there is no existing GV to use, create one now.
1086   GlobalVariable *GV =
1087     new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1088                        CurModule.CurrentModule);
1089   InsertValue(GV, CurModule.Values);
1090   return GV;
1091 }
1092
1093 // setTypeName - Set the specified type to the name given.  The name may be
1094 // null potentially, in which case this is a noop.  The string passed in is
1095 // assumed to be a malloc'd string buffer, and is freed by this function.
1096 //
1097 // This function returns true if the type has already been defined, but is
1098 // allowed to be redefined in the specified context.  If the name is a new name
1099 // for the type plane, it is inserted and false is returned.
1100 static bool setTypeName(const Type *T, char *NameStr) {
1101   assert(!inFunctionScope() && "Can't give types function-local names");
1102   if (NameStr == 0) return false;
1103  
1104   std::string Name(NameStr);      // Copy string
1105   free(NameStr);                  // Free old string
1106
1107   // We don't allow assigning names to void type
1108   if (T == Type::VoidTy) {
1109     error("Can't assign name '" + Name + "' to the void type");
1110     return false;
1111   }
1112
1113   // Set the type name, checking for conflicts as we do so.
1114   bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1115
1116   if (AlreadyExists) {   // Inserting a name that is already defined???
1117     const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1118     assert(Existing && "Conflict but no matching type?");
1119
1120     // There is only one case where this is allowed: when we are refining an
1121     // opaque type.  In this case, Existing will be an opaque type.
1122     if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1123       // We ARE replacing an opaque type!
1124       const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1125       return true;
1126     }
1127
1128     // Otherwise, this is an attempt to redefine a type. That's okay if
1129     // the redefinition is identical to the original. This will be so if
1130     // Existing and T point to the same Type object. In this one case we
1131     // allow the equivalent redefinition.
1132     if (Existing == T) return true;  // Yes, it's equal.
1133
1134     // Any other kind of (non-equivalent) redefinition is an error.
1135     error("Redefinition of type named '" + Name + "' in the '" +
1136           T->getDescription() + "' type plane");
1137   }
1138
1139   return false;
1140 }
1141
1142 //===----------------------------------------------------------------------===//
1143 // Code for handling upreferences in type names...
1144 //
1145
1146 // TypeContains - Returns true if Ty directly contains E in it.
1147 //
1148 static bool TypeContains(const Type *Ty, const Type *E) {
1149   return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1150                    E) != Ty->subtype_end();
1151 }
1152
1153 namespace {
1154   struct UpRefRecord {
1155     // NestingLevel - The number of nesting levels that need to be popped before
1156     // this type is resolved.
1157     unsigned NestingLevel;
1158
1159     // LastContainedTy - This is the type at the current binding level for the
1160     // type.  Every time we reduce the nesting level, this gets updated.
1161     const Type *LastContainedTy;
1162
1163     // UpRefTy - This is the actual opaque type that the upreference is
1164     // represented with.
1165     OpaqueType *UpRefTy;
1166
1167     UpRefRecord(unsigned NL, OpaqueType *URTy)
1168       : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1169   };
1170 }
1171
1172 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1173 static std::vector<UpRefRecord> UpRefs;
1174
1175 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1176 /// called.  It loops through the UpRefs vector, which is a list of the
1177 /// currently active types.  For each type, if the up reference is contained in
1178 /// the newly completed type, we decrement the level count.  When the level
1179 /// count reaches zero, the upreferenced type is the type that is passed in:
1180 /// thus we can complete the cycle.
1181 ///
1182 static PATypeHolder HandleUpRefs(const Type *ty) {
1183   // If Ty isn't abstract, or if there are no up-references in it, then there is
1184   // nothing to resolve here.
1185   if (!ty->isAbstract() || UpRefs.empty()) return ty;
1186   
1187   PATypeHolder Ty(ty);
1188   UR_OUT("Type '" << Ty->getDescription() <<
1189          "' newly formed.  Resolving upreferences.\n" <<
1190          UpRefs.size() << " upreferences active!\n");
1191
1192   // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1193   // to zero), we resolve them all together before we resolve them to Ty.  At
1194   // the end of the loop, if there is anything to resolve to Ty, it will be in
1195   // this variable.
1196   OpaqueType *TypeToResolve = 0;
1197
1198   for (unsigned i = 0; i != UpRefs.size(); ++i) {
1199     UR_OUT("  UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1200            << UpRefs[i].second->getDescription() << ") = "
1201            << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1202     if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1203       // Decrement level of upreference
1204       unsigned Level = --UpRefs[i].NestingLevel;
1205       UpRefs[i].LastContainedTy = Ty;
1206       UR_OUT("  Uplevel Ref Level = " << Level << "\n");
1207       if (Level == 0) {                     // Upreference should be resolved!
1208         if (!TypeToResolve) {
1209           TypeToResolve = UpRefs[i].UpRefTy;
1210         } else {
1211           UR_OUT("  * Resolving upreference for "
1212                  << UpRefs[i].second->getDescription() << "\n";
1213                  std::string OldName = UpRefs[i].UpRefTy->getDescription());
1214           UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1215           UR_OUT("  * Type '" << OldName << "' refined upreference to: "
1216                  << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1217         }
1218         UpRefs.erase(UpRefs.begin()+i);     // Remove from upreference list...
1219         --i;                                // Do not skip the next element...
1220       }
1221     }
1222   }
1223
1224   if (TypeToResolve) {
1225     UR_OUT("  * Resolving upreference for "
1226            << UpRefs[i].second->getDescription() << "\n";
1227            std::string OldName = TypeToResolve->getDescription());
1228     TypeToResolve->refineAbstractTypeTo(Ty);
1229   }
1230
1231   return Ty;
1232 }
1233
1234 static inline Instruction::TermOps 
1235 getTermOp(TermOps op) {
1236   switch (op) {
1237     default           : assert(0 && "Invalid OldTermOp");
1238     case RetOp        : return Instruction::Ret;
1239     case BrOp         : return Instruction::Br;
1240     case SwitchOp     : return Instruction::Switch;
1241     case InvokeOp     : return Instruction::Invoke;
1242     case UnwindOp     : return Instruction::Unwind;
1243     case UnreachableOp: return Instruction::Unreachable;
1244   }
1245 }
1246
1247 static inline Instruction::BinaryOps 
1248 getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1249   switch (op) {
1250     default     : assert(0 && "Invalid OldBinaryOps");
1251     case SetEQ  : 
1252     case SetNE  : 
1253     case SetLE  :
1254     case SetGE  :
1255     case SetLT  :
1256     case SetGT  : assert(0 && "Should use getCompareOp");
1257     case AddOp  : return Instruction::Add;
1258     case SubOp  : return Instruction::Sub;
1259     case MulOp  : return Instruction::Mul;
1260     case DivOp  : {
1261       // This is an obsolete instruction so we must upgrade it based on the
1262       // types of its operands.
1263       bool isFP = Ty->isFloatingPoint();
1264       if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1265         // If its a packed type we want to use the element type
1266         isFP = PTy->getElementType()->isFloatingPoint();
1267       if (isFP)
1268         return Instruction::FDiv;
1269       else if (Sign == Signed)
1270         return Instruction::SDiv;
1271       return Instruction::UDiv;
1272     }
1273     case UDivOp : return Instruction::UDiv;
1274     case SDivOp : return Instruction::SDiv;
1275     case FDivOp : return Instruction::FDiv;
1276     case RemOp  : {
1277       // This is an obsolete instruction so we must upgrade it based on the
1278       // types of its operands.
1279       bool isFP = Ty->isFloatingPoint();
1280       if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1281         // If its a packed type we want to use the element type
1282         isFP = PTy->getElementType()->isFloatingPoint();
1283       // Select correct opcode
1284       if (isFP)
1285         return Instruction::FRem;
1286       else if (Sign == Signed)
1287         return Instruction::SRem;
1288       return Instruction::URem;
1289     }
1290     case URemOp : return Instruction::URem;
1291     case SRemOp : return Instruction::SRem;
1292     case FRemOp : return Instruction::FRem;
1293     case AndOp  : return Instruction::And;
1294     case OrOp   : return Instruction::Or;
1295     case XorOp  : return Instruction::Xor;
1296   }
1297 }
1298
1299 static inline Instruction::OtherOps 
1300 getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1301              Signedness Sign) {
1302   bool isSigned = Sign == Signed;
1303   bool isFP = Ty->isFloatingPoint();
1304   switch (op) {
1305     default     : assert(0 && "Invalid OldSetCC");
1306     case SetEQ  : 
1307       if (isFP) {
1308         predicate = FCmpInst::FCMP_OEQ;
1309         return Instruction::FCmp;
1310       } else {
1311         predicate = ICmpInst::ICMP_EQ;
1312         return Instruction::ICmp;
1313       }
1314     case SetNE  : 
1315       if (isFP) {
1316         predicate = FCmpInst::FCMP_UNE;
1317         return Instruction::FCmp;
1318       } else {
1319         predicate = ICmpInst::ICMP_NE;
1320         return Instruction::ICmp;
1321       }
1322     case SetLE  : 
1323       if (isFP) {
1324         predicate = FCmpInst::FCMP_OLE;
1325         return Instruction::FCmp;
1326       } else {
1327         if (isSigned)
1328           predicate = ICmpInst::ICMP_SLE;
1329         else
1330           predicate = ICmpInst::ICMP_ULE;
1331         return Instruction::ICmp;
1332       }
1333     case SetGE  : 
1334       if (isFP) {
1335         predicate = FCmpInst::FCMP_OGE;
1336         return Instruction::FCmp;
1337       } else {
1338         if (isSigned)
1339           predicate = ICmpInst::ICMP_SGE;
1340         else
1341           predicate = ICmpInst::ICMP_UGE;
1342         return Instruction::ICmp;
1343       }
1344     case SetLT  : 
1345       if (isFP) {
1346         predicate = FCmpInst::FCMP_OLT;
1347         return Instruction::FCmp;
1348       } else {
1349         if (isSigned)
1350           predicate = ICmpInst::ICMP_SLT;
1351         else
1352           predicate = ICmpInst::ICMP_ULT;
1353         return Instruction::ICmp;
1354       }
1355     case SetGT  : 
1356       if (isFP) {
1357         predicate = FCmpInst::FCMP_OGT;
1358         return Instruction::FCmp;
1359       } else {
1360         if (isSigned)
1361           predicate = ICmpInst::ICMP_SGT;
1362         else
1363           predicate = ICmpInst::ICMP_UGT;
1364         return Instruction::ICmp;
1365       }
1366   }
1367 }
1368
1369 static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1370   switch (op) {
1371     default              : assert(0 && "Invalid OldMemoryOps");
1372     case MallocOp        : return Instruction::Malloc;
1373     case FreeOp          : return Instruction::Free;
1374     case AllocaOp        : return Instruction::Alloca;
1375     case LoadOp          : return Instruction::Load;
1376     case StoreOp         : return Instruction::Store;
1377     case GetElementPtrOp : return Instruction::GetElementPtr;
1378   }
1379 }
1380
1381 static inline Instruction::OtherOps 
1382 getOtherOp(OtherOps op, Signedness Sign) {
1383   switch (op) {
1384     default               : assert(0 && "Invalid OldOtherOps");
1385     case PHIOp            : return Instruction::PHI;
1386     case CallOp           : return Instruction::Call;
1387     case ShlOp            : return Instruction::Shl;
1388     case ShrOp            : 
1389       if (Sign == Signed)
1390         return Instruction::AShr;
1391       return Instruction::LShr;
1392     case SelectOp         : return Instruction::Select;
1393     case UserOp1          : return Instruction::UserOp1;
1394     case UserOp2          : return Instruction::UserOp2;
1395     case VAArg            : return Instruction::VAArg;
1396     case ExtractElementOp : return Instruction::ExtractElement;
1397     case InsertElementOp  : return Instruction::InsertElement;
1398     case ShuffleVectorOp  : return Instruction::ShuffleVector;
1399     case ICmpOp           : return Instruction::ICmp;
1400     case FCmpOp           : return Instruction::FCmp;
1401     case LShrOp           : return Instruction::LShr;
1402     case AShrOp           : return Instruction::AShr;
1403   };
1404 }
1405
1406 static inline Value*
1407 getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy, 
1408         Signedness DstSign, bool ForceInstruction = false) {
1409   Instruction::CastOps Opcode;
1410   const Type* SrcTy = Src->getType();
1411   if (op == CastOp) {
1412     if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1413       // fp -> ptr cast is no longer supported but we must upgrade this
1414       // by doing a double cast: fp -> int -> ptr
1415       SrcTy = Type::Int64Ty;
1416       Opcode = Instruction::IntToPtr;
1417       if (isa<Constant>(Src)) {
1418         Src = ConstantExpr::getCast(Instruction::FPToUI, 
1419                                      cast<Constant>(Src), SrcTy);
1420       } else {
1421         std::string NewName(makeNameUnique(Src->getName()));
1422         Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1423       }
1424     } else if (isa<IntegerType>(DstTy) &&
1425                cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1426       // cast type %x to bool was previously defined as setne type %x, null
1427       // The cast semantic is now to truncate, not compare so we must retain
1428       // the original intent by replacing the cast with a setne
1429       Constant* Null = Constant::getNullValue(SrcTy);
1430       Instruction::OtherOps Opcode = Instruction::ICmp;
1431       unsigned short predicate = ICmpInst::ICMP_NE;
1432       if (SrcTy->isFloatingPoint()) {
1433         Opcode = Instruction::FCmp;
1434         predicate = FCmpInst::FCMP_ONE;
1435       } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1436         error("Invalid cast to bool");
1437       }
1438       if (isa<Constant>(Src) && !ForceInstruction)
1439         return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1440       else
1441         return CmpInst::create(Opcode, predicate, Src, Null);
1442     }
1443     // Determine the opcode to use by calling CastInst::getCastOpcode
1444     Opcode = 
1445       CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1446
1447   } else switch (op) {
1448     default: assert(0 && "Invalid cast token");
1449     case TruncOp:    Opcode = Instruction::Trunc; break;
1450     case ZExtOp:     Opcode = Instruction::ZExt; break;
1451     case SExtOp:     Opcode = Instruction::SExt; break;
1452     case FPTruncOp:  Opcode = Instruction::FPTrunc; break;
1453     case FPExtOp:    Opcode = Instruction::FPExt; break;
1454     case FPToUIOp:   Opcode = Instruction::FPToUI; break;
1455     case FPToSIOp:   Opcode = Instruction::FPToSI; break;
1456     case UIToFPOp:   Opcode = Instruction::UIToFP; break;
1457     case SIToFPOp:   Opcode = Instruction::SIToFP; break;
1458     case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1459     case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1460     case BitCastOp:  Opcode = Instruction::BitCast; break;
1461   }
1462
1463   if (isa<Constant>(Src) && !ForceInstruction)
1464     return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1465   return CastInst::create(Opcode, Src, DstTy);
1466 }
1467
1468 static Instruction *
1469 upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, 
1470                      std::vector<Value*>& Args) {
1471
1472   std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1473   if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1474     if (Args.size() != 2)
1475       error("Invalid prototype for " + Name + " prototype");
1476     return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1477   } else {
1478     static unsigned upgradeCount = 1;
1479     const Type* PtrTy = PointerType::get(Type::Int8Ty);
1480     std::vector<const Type*> Params;
1481     if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1482       if (Args.size() != 1)
1483         error("Invalid prototype for " + Name + " prototype");
1484       Params.push_back(PtrTy);
1485       const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1486       const PointerType *PFTy = PointerType::get(FTy);
1487       Value* Func = getVal(PFTy, ID);
1488       std::string InstName("va_upgrade");
1489       InstName += llvm::utostr(upgradeCount++);
1490       Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1491       return new CallInst(Func, Args);
1492     } else if (Name == "llvm.va_copy") {
1493       if (Args.size() != 2)
1494         error("Invalid prototype for " + Name + " prototype");
1495       Params.push_back(PtrTy);
1496       Params.push_back(PtrTy);
1497       const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1498       const PointerType *PFTy = PointerType::get(FTy);
1499       Value* Func = getVal(PFTy, ID);
1500       std::string InstName0("va_upgrade");
1501       InstName0 += llvm::utostr(upgradeCount++);
1502       std::string InstName1("va_upgrade");
1503       InstName1 += llvm::utostr(upgradeCount++);
1504       Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1505       Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1506       return new CallInst(Func, Args);
1507     }
1508   }
1509   return 0;
1510 }
1511
1512 const Type* upgradeGEPIndices(const Type* PTy, 
1513                        std::vector<ValueInfo> *Indices, 
1514                        std::vector<Value*>    &VIndices, 
1515                        std::vector<Constant*> *CIndices = 0) {
1516   // Traverse the indices with a gep_type_iterator so we can build the list
1517   // of constant and value indices for use later. Also perform upgrades
1518   VIndices.clear();
1519   if (CIndices) CIndices->clear();
1520   for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1521     VIndices.push_back((*Indices)[i].V);
1522   generic_gep_type_iterator<std::vector<Value*>::iterator>
1523     GTI = gep_type_begin(PTy, VIndices.begin(),  VIndices.end()),
1524     GTE = gep_type_end(PTy,  VIndices.begin(),  VIndices.end());
1525   for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1526     Value *Index = VIndices[i];
1527     if (CIndices && !isa<Constant>(Index))
1528       error("Indices to constant getelementptr must be constants");
1529     // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte 
1530     // struct indices to i32 struct indices with ZExt for compatibility.
1531     else if (isa<StructType>(*GTI)) {        // Only change struct indices
1532       if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1533         if (CUI->getType()->getBitWidth() == 8)
1534           Index = 
1535             ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1536     } else {
1537       // Make sure that unsigned SequentialType indices are zext'd to 
1538       // 64-bits if they were smaller than that because LLVM 2.0 will sext 
1539       // all indices for SequentialType elements. We must retain the same 
1540       // semantic (zext) for unsigned types.
1541       if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
1542         if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
1543           if (CIndices)
1544             Index = ConstantExpr::getCast(Instruction::ZExt, 
1545               cast<Constant>(Index), Type::Int64Ty);
1546           else
1547             Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1548               makeNameUnique("gep_upgrade"), CurBB);
1549           VIndices[i] = Index;
1550         }
1551     }
1552     // Add to the CIndices list, if requested.
1553     if (CIndices)
1554       CIndices->push_back(cast<Constant>(Index));
1555   }
1556
1557   const Type *IdxTy =
1558     GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1559     if (!IdxTy)
1560       error("Index list invalid for constant getelementptr");
1561   return IdxTy;
1562 }
1563
1564 Module* UpgradeAssembly(const std::string &infile, std::istream& in, 
1565                               bool debug, bool addAttrs)
1566 {
1567   Upgradelineno = 1; 
1568   CurFilename = infile;
1569   LexInput = &in;
1570   yydebug = debug;
1571   AddAttributes = addAttrs;
1572   ObsoleteVarArgs = false;
1573   NewVarArgs = false;
1574
1575   CurModule.CurrentModule = new Module(CurFilename);
1576
1577   // Check to make sure the parser succeeded
1578   if (yyparse()) {
1579     if (ParserResult)
1580       delete ParserResult;
1581     std::cerr << "llvm-upgrade: parse failed.\n";
1582     return 0;
1583   }
1584
1585   // Check to make sure that parsing produced a result
1586   if (!ParserResult) {
1587     std::cerr << "llvm-upgrade: no parse result.\n";
1588     return 0;
1589   }
1590
1591   // Reset ParserResult variable while saving its value for the result.
1592   Module *Result = ParserResult;
1593   ParserResult = 0;
1594
1595   //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1596   {
1597     Function* F;
1598     if ((F = Result->getNamedFunction("llvm.va_start"))
1599         && F->getFunctionType()->getNumParams() == 0)
1600       ObsoleteVarArgs = true;
1601     if((F = Result->getNamedFunction("llvm.va_copy"))
1602        && F->getFunctionType()->getNumParams() == 1)
1603       ObsoleteVarArgs = true;
1604   }
1605
1606   if (ObsoleteVarArgs && NewVarArgs) {
1607     error("This file is corrupt: it uses both new and old style varargs");
1608     return 0;
1609   }
1610
1611   if(ObsoleteVarArgs) {
1612     if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1613       if (F->arg_size() != 0) {
1614         error("Obsolete va_start takes 0 argument");
1615         return 0;
1616       }
1617       
1618       //foo = va_start()
1619       // ->
1620       //bar = alloca typeof(foo)
1621       //va_start(bar)
1622       //foo = load bar
1623
1624       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1625       const Type* ArgTy = F->getFunctionType()->getReturnType();
1626       const Type* ArgTyPtr = PointerType::get(ArgTy);
1627       Function* NF = cast<Function>(Result->getOrInsertFunction(
1628         "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1629
1630       while (!F->use_empty()) {
1631         CallInst* CI = cast<CallInst>(F->use_back());
1632         AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1633         new CallInst(NF, bar, "", CI);
1634         Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1635         CI->replaceAllUsesWith(foo);
1636         CI->getParent()->getInstList().erase(CI);
1637       }
1638       Result->getFunctionList().erase(F);
1639     }
1640     
1641     if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1642       if(F->arg_size() != 1) {
1643         error("Obsolete va_end takes 1 argument");
1644         return 0;
1645       }
1646
1647       //vaend foo
1648       // ->
1649       //bar = alloca 1 of typeof(foo)
1650       //vaend bar
1651       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1652       const Type* ArgTy = F->getFunctionType()->getParamType(0);
1653       const Type* ArgTyPtr = PointerType::get(ArgTy);
1654       Function* NF = cast<Function>(Result->getOrInsertFunction(
1655         "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
1656
1657       while (!F->use_empty()) {
1658         CallInst* CI = cast<CallInst>(F->use_back());
1659         AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1660         new StoreInst(CI->getOperand(1), bar, CI);
1661         new CallInst(NF, bar, "", CI);
1662         CI->getParent()->getInstList().erase(CI);
1663       }
1664       Result->getFunctionList().erase(F);
1665     }
1666
1667     if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1668       if(F->arg_size() != 1) {
1669         error("Obsolete va_copy takes 1 argument");
1670         return 0;
1671       }
1672       //foo = vacopy(bar)
1673       // ->
1674       //a = alloca 1 of typeof(foo)
1675       //b = alloca 1 of typeof(foo)
1676       //store bar -> b
1677       //vacopy(a, b)
1678       //foo = load a
1679       
1680       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1681       const Type* ArgTy = F->getFunctionType()->getReturnType();
1682       const Type* ArgTyPtr = PointerType::get(ArgTy);
1683       Function* NF = cast<Function>(Result->getOrInsertFunction(
1684         "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
1685
1686       while (!F->use_empty()) {
1687         CallInst* CI = cast<CallInst>(F->use_back());
1688         AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1689         AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1690         new StoreInst(CI->getOperand(1), b, CI);
1691         new CallInst(NF, a, b, "", CI);
1692         Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1693         CI->replaceAllUsesWith(foo);
1694         CI->getParent()->getInstList().erase(CI);
1695       }
1696       Result->getFunctionList().erase(F);
1697     }
1698   }
1699
1700   return Result;
1701 }
1702
1703 } // end llvm namespace
1704
1705 using namespace llvm;
1706
1707
1708
1709 /* Enabling traces.  */
1710 #ifndef YYDEBUG
1711 # define YYDEBUG 0
1712 #endif
1713
1714 /* Enabling verbose error messages.  */
1715 #ifdef YYERROR_VERBOSE
1716 # undef YYERROR_VERBOSE
1717 # define YYERROR_VERBOSE 1
1718 #else
1719 # define YYERROR_VERBOSE 0
1720 #endif
1721
1722 /* Enabling the token table.  */
1723 #ifndef YYTOKEN_TABLE
1724 # define YYTOKEN_TABLE 0
1725 #endif
1726
1727 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1728 typedef union YYSTYPE
1729 #line 1339 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
1730 {
1731   llvm::Module                           *ModuleVal;
1732   llvm::Function                         *FunctionVal;
1733   std::pair<llvm::PATypeInfo, char*>     *ArgVal;
1734   llvm::BasicBlock                       *BasicBlockVal;
1735   llvm::TerminatorInst                   *TermInstVal;
1736   llvm::InstrInfo                        InstVal;
1737   llvm::ConstInfo                        ConstVal;
1738   llvm::ValueInfo                        ValueVal;
1739   llvm::PATypeInfo                       TypeVal;
1740   llvm::TypeInfo                         PrimType;
1741   llvm::PHIListInfo                      PHIList;
1742   std::list<llvm::PATypeInfo>            *TypeList;
1743   std::vector<llvm::ValueInfo>           *ValueList;
1744   std::vector<llvm::ConstInfo>           *ConstVector;
1745
1746
1747   std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1748   // Represent the RHS of PHI node
1749   std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1750
1751   llvm::GlobalValue::LinkageTypes         Linkage;
1752   int64_t                           SInt64Val;
1753   uint64_t                          UInt64Val;
1754   int                               SIntVal;
1755   unsigned                          UIntVal;
1756   double                            FPVal;
1757   bool                              BoolVal;
1758
1759   char                             *StrVal;   // This memory is strdup'd!
1760   llvm::ValID                       ValIDVal; // strdup'd memory maybe!
1761
1762   llvm::BinaryOps                   BinaryOpVal;
1763   llvm::TermOps                     TermOpVal;
1764   llvm::MemoryOps                   MemOpVal;
1765   llvm::OtherOps                    OtherOpVal;
1766   llvm::CastOps                     CastOpVal;
1767   llvm::ICmpInst::Predicate         IPred;
1768   llvm::FCmpInst::Predicate         FPred;
1769   llvm::Module::Endianness          Endianness;
1770 }
1771 /* Line 187 of yacc.c.  */
1772 #line 1773 "UpgradeParser.tab.c"
1773         YYSTYPE;
1774 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1775 # define YYSTYPE_IS_DECLARED 1
1776 # define YYSTYPE_IS_TRIVIAL 1
1777 #endif
1778
1779
1780
1781 /* Copy the second part of user declarations.  */
1782
1783
1784 /* Line 216 of yacc.c.  */
1785 #line 1786 "UpgradeParser.tab.c"
1786
1787 #ifdef short
1788 # undef short
1789 #endif
1790
1791 #ifdef YYTYPE_UINT8
1792 typedef YYTYPE_UINT8 yytype_uint8;
1793 #else
1794 typedef unsigned char yytype_uint8;
1795 #endif
1796
1797 #ifdef YYTYPE_INT8
1798 typedef YYTYPE_INT8 yytype_int8;
1799 #elif (defined __STDC__ || defined __C99__FUNC__ \
1800      || defined __cplusplus || defined _MSC_VER)
1801 typedef signed char yytype_int8;
1802 #else
1803 typedef short int yytype_int8;
1804 #endif
1805
1806 #ifdef YYTYPE_UINT16
1807 typedef YYTYPE_UINT16 yytype_uint16;
1808 #else
1809 typedef unsigned short int yytype_uint16;
1810 #endif
1811
1812 #ifdef YYTYPE_INT16
1813 typedef YYTYPE_INT16 yytype_int16;
1814 #else
1815 typedef short int yytype_int16;
1816 #endif
1817
1818 #ifndef YYSIZE_T
1819 # ifdef __SIZE_TYPE__
1820 #  define YYSIZE_T __SIZE_TYPE__
1821 # elif defined size_t
1822 #  define YYSIZE_T size_t
1823 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1824      || defined __cplusplus || defined _MSC_VER)
1825 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1826 #  define YYSIZE_T size_t
1827 # else
1828 #  define YYSIZE_T unsigned int
1829 # endif
1830 #endif
1831
1832 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1833
1834 #ifndef YY_
1835 # if YYENABLE_NLS
1836 #  if ENABLE_NLS
1837 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1838 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
1839 #  endif
1840 # endif
1841 # ifndef YY_
1842 #  define YY_(msgid) msgid
1843 # endif
1844 #endif
1845
1846 /* Suppress unused-variable warnings by "using" E.  */
1847 #if ! defined lint || defined __GNUC__
1848 # define YYUSE(e) ((void) (e))
1849 #else
1850 # define YYUSE(e) /* empty */
1851 #endif
1852
1853 /* Identity function, used to suppress warnings about constant conditions.  */
1854 #ifndef lint
1855 # define YYID(n) (n)
1856 #else
1857 #if (defined __STDC__ || defined __C99__FUNC__ \
1858      || defined __cplusplus || defined _MSC_VER)
1859 static int
1860 YYID (int i)
1861 #else
1862 static int
1863 YYID (i)
1864     int i;
1865 #endif
1866 {
1867   return i;
1868 }
1869 #endif
1870
1871 #if ! defined yyoverflow || YYERROR_VERBOSE
1872
1873 /* The parser invokes alloca or malloc; define the necessary symbols.  */
1874
1875 # ifdef YYSTACK_USE_ALLOCA
1876 #  if YYSTACK_USE_ALLOCA
1877 #   ifdef __GNUC__
1878 #    define YYSTACK_ALLOC __builtin_alloca
1879 #   elif defined __BUILTIN_VA_ARG_INCR
1880 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1881 #   elif defined _AIX
1882 #    define YYSTACK_ALLOC __alloca
1883 #   elif defined _MSC_VER
1884 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1885 #    define alloca _alloca
1886 #   else
1887 #    define YYSTACK_ALLOC alloca
1888 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1889      || defined __cplusplus || defined _MSC_VER)
1890 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1891 #     ifndef _STDLIB_H
1892 #      define _STDLIB_H 1
1893 #     endif
1894 #    endif
1895 #   endif
1896 #  endif
1897 # endif
1898
1899 # ifdef YYSTACK_ALLOC
1900    /* Pacify GCC's `empty if-body' warning.  */
1901 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1902 #  ifndef YYSTACK_ALLOC_MAXIMUM
1903     /* The OS might guarantee only one guard page at the bottom of the stack,
1904        and a page size can be as small as 4096 bytes.  So we cannot safely
1905        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
1906        to allow for a few compiler-allocated temporary stack slots.  */
1907 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1908 #  endif
1909 # else
1910 #  define YYSTACK_ALLOC YYMALLOC
1911 #  define YYSTACK_FREE YYFREE
1912 #  ifndef YYSTACK_ALLOC_MAXIMUM
1913 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1914 #  endif
1915 #  if (defined __cplusplus && ! defined _STDLIB_H \
1916        && ! ((defined YYMALLOC || defined malloc) \
1917              && (defined YYFREE || defined free)))
1918 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1919 #   ifndef _STDLIB_H
1920 #    define _STDLIB_H 1
1921 #   endif
1922 #  endif
1923 #  ifndef YYMALLOC
1924 #   define YYMALLOC malloc
1925 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1926      || defined __cplusplus || defined _MSC_VER)
1927 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1928 #   endif
1929 #  endif
1930 #  ifndef YYFREE
1931 #   define YYFREE free
1932 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1933      || defined __cplusplus || defined _MSC_VER)
1934 void free (void *); /* INFRINGES ON USER NAME SPACE */
1935 #   endif
1936 #  endif
1937 # endif
1938 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1939
1940
1941 #if (! defined yyoverflow \
1942      && (! defined __cplusplus \
1943          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1944
1945 /* A type that is properly aligned for any stack member.  */
1946 union yyalloc
1947 {
1948   yytype_int16 yyss;
1949   YYSTYPE yyvs;
1950   };
1951
1952 /* The size of the maximum gap between one aligned stack and the next.  */
1953 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1954
1955 /* The size of an array large to enough to hold all stacks, each with
1956    N elements.  */
1957 # define YYSTACK_BYTES(N) \
1958      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1959       + YYSTACK_GAP_MAXIMUM)
1960
1961 /* Copy COUNT objects from FROM to TO.  The source and destination do
1962    not overlap.  */
1963 # ifndef YYCOPY
1964 #  if defined __GNUC__ && 1 < __GNUC__
1965 #   define YYCOPY(To, From, Count) \
1966       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1967 #  else
1968 #   define YYCOPY(To, From, Count)              \
1969       do                                        \
1970         {                                       \
1971           YYSIZE_T yyi;                         \
1972           for (yyi = 0; yyi < (Count); yyi++)   \
1973             (To)[yyi] = (From)[yyi];            \
1974         }                                       \
1975       while (YYID (0))
1976 #  endif
1977 # endif
1978
1979 /* Relocate STACK from its old location to the new one.  The
1980    local variables YYSIZE and YYSTACKSIZE give the old and new number of
1981    elements in the stack, and YYPTR gives the new location of the
1982    stack.  Advance YYPTR to a properly aligned location for the next
1983    stack.  */
1984 # define YYSTACK_RELOCATE(Stack)                                        \
1985     do                                                                  \
1986       {                                                                 \
1987         YYSIZE_T yynewbytes;                                            \
1988         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
1989         Stack = &yyptr->Stack;                                          \
1990         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1991         yyptr += yynewbytes / sizeof (*yyptr);                          \
1992       }                                                                 \
1993     while (YYID (0))
1994
1995 #endif
1996
1997 /* YYFINAL -- State number of the termination state.  */
1998 #define YYFINAL  4
1999 /* YYLAST -- Last index in YYTABLE.  */
2000 #define YYLAST   1712
2001
2002 /* YYNTOKENS -- Number of terminals.  */
2003 #define YYNTOKENS  166
2004 /* YYNNTS -- Number of nonterminals.  */
2005 #define YYNNTS  79
2006 /* YYNRULES -- Number of rules.  */
2007 #define YYNRULES  308
2008 /* YYNRULES -- Number of states.  */
2009 #define YYNSTATES  604
2010
2011 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
2012 #define YYUNDEFTOK  2
2013 #define YYMAXUTOK   406
2014
2015 #define YYTRANSLATE(YYX)                                                \
2016   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2017
2018 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
2019 static const yytype_uint8 yytranslate[] =
2020 {
2021        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2022        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2023        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2024        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2025      155,   156,   164,     2,   153,     2,     2,     2,     2,     2,
2026        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2027      160,   152,   161,     2,     2,     2,     2,     2,     2,     2,
2028        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2029        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2030        2,   157,   154,   159,     2,     2,     2,     2,     2,   165,
2031        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2032        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2033      158,     2,     2,   162,     2,   163,     2,     2,     2,     2,
2034        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2035        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2036        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2037        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2038        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2039        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2040        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2041        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2042        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2043        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2044        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2045        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2046        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
2047        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
2048       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
2049       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
2050       35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
2051       45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
2052       55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
2053       65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
2054       75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
2055       85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
2056       95,    96,    97,    98,    99,   100,   101,   102,   103,   104,
2057      105,   106,   107,   108,   109,   110,   111,   112,   113,   114,
2058      115,   116,   117,   118,   119,   120,   121,   122,   123,   124,
2059      125,   126,   127,   128,   129,   130,   131,   132,   133,   134,
2060      135,   136,   137,   138,   139,   140,   141,   142,   143,   144,
2061      145,   146,   147,   148,   149,   150,   151
2062 };
2063
2064 #if YYDEBUG
2065 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2066    YYRHS.  */
2067 static const yytype_uint16 yyprhs[] =
2068 {
2069        0,     0,     3,     5,     7,     9,    11,    13,    15,    17,
2070       19,    21,    23,    25,    27,    29,    31,    33,    35,    37,
2071       39,    41,    43,    45,    47,    49,    51,    53,    55,    57,
2072       59,    61,    63,    65,    67,    69,    71,    73,    75,    77,
2073       79,    81,    83,    85,    87,    89,    91,    93,    95,    97,
2074       99,   101,   103,   105,   107,   109,   111,   113,   115,   117,
2075      119,   121,   123,   125,   127,   129,   131,   133,   135,   137,
2076      139,   141,   143,   145,   147,   149,   151,   153,   155,   157,
2077      159,   161,   164,   165,   167,   169,   171,   173,   175,   177,
2078      179,   180,   181,   183,   185,   187,   189,   191,   193,   196,
2079      197,   200,   201,   205,   208,   209,   211,   212,   216,   218,
2080      221,   223,   225,   227,   229,   231,   233,   235,   237,   239,
2081      241,   243,   245,   247,   249,   251,   253,   255,   257,   259,
2082      261,   264,   269,   275,   281,   285,   288,   294,   299,   302,
2083      304,   308,   310,   314,   316,   317,   322,   326,   330,   335,
2084      340,   344,   351,   357,   360,   363,   366,   369,   372,   375,
2085      378,   381,   384,   387,   394,   400,   409,   416,   423,   430,
2086      438,   446,   453,   460,   469,   478,   482,   484,   486,   488,
2087      490,   493,   496,   501,   504,   506,   511,   514,   519,   520,
2088      528,   529,   537,   538,   546,   547,   555,   559,   564,   565,
2089      567,   569,   571,   575,   579,   583,   587,   591,   595,   597,
2090      598,   600,   602,   604,   605,   608,   612,   614,   616,   620,
2091      622,   623,   632,   634,   636,   640,   642,   644,   647,   648,
2092      650,   652,   653,   658,   659,   661,   663,   665,   667,   669,
2093      671,   673,   675,   677,   681,   683,   689,   691,   693,   695,
2094      697,   700,   703,   706,   710,   713,   714,   716,   718,   720,
2095      723,   726,   730,   740,   750,   759,   773,   775,   777,   784,
2096      790,   793,   800,   808,   810,   814,   816,   817,   820,   822,
2097      828,   834,   840,   847,   854,   857,   862,   867,   874,   879,
2098      884,   889,   894,   901,   908,   911,   919,   921,   924,   925,
2099      927,   928,   932,   939,   943,   950,   953,   958,   965
2100 };
2101
2102 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
2103 static const yytype_int16 yyrhs[] =
2104 {
2105      200,     0,    -1,     5,    -1,     6,    -1,     3,    -1,     4,
2106       -1,    79,    -1,    80,    -1,    81,    -1,    82,    -1,    83,
2107       -1,    84,    -1,    85,    -1,    86,    -1,    87,    -1,    88,
2108       -1,    89,    -1,    90,    -1,    91,    -1,    92,    -1,    93,
2109       -1,    94,    -1,    95,    -1,    96,    -1,    97,    -1,    98,
2110       -1,   119,    -1,   120,    -1,   121,    -1,   122,    -1,   123,
2111       -1,   124,    -1,   125,    -1,   126,    -1,   127,    -1,   128,
2112       -1,   129,    -1,   130,    -1,   131,    -1,   132,    -1,   133,
2113       -1,   134,    -1,   135,    -1,   136,    -1,   137,    -1,   138,
2114       -1,   125,    -1,   126,    -1,   127,    -1,   128,    -1,    27,
2115       -1,    28,    -1,   109,    -1,   110,    -1,   111,    -1,   112,
2116       -1,   140,    -1,   141,    -1,   142,    -1,   143,    -1,   144,
2117       -1,   145,    -1,   146,    -1,   147,    -1,   148,    -1,   149,
2118       -1,   150,    -1,   151,    -1,   139,    -1,    16,    -1,    14,
2119       -1,    12,    -1,    10,    -1,    17,    -1,    15,    -1,    13,
2120       -1,    11,    -1,   176,    -1,   177,    -1,    18,    -1,    19,
2121       -1,   212,   152,    -1,    -1,    41,    -1,    42,    -1,    43,
2122       -1,    44,    -1,    45,    -1,    46,    -1,    47,    -1,    -1,
2123       -1,    65,    -1,    66,    -1,    67,    -1,    68,    -1,    69,
2124       -1,    70,    -1,    64,     4,    -1,    -1,    57,     4,    -1,
2125       -1,   153,    57,     4,    -1,    34,    24,    -1,    -1,   185,
2126       -1,    -1,   153,   188,   187,    -1,   185,    -1,    57,     4,
2127       -1,   191,    -1,     8,    -1,   193,    -1,     8,    -1,   193,
2128       -1,     9,    -1,    10,    -1,    11,    -1,    12,    -1,    13,
2129       -1,    14,    -1,    15,    -1,    16,    -1,    17,    -1,    18,
2130       -1,    19,    -1,    21,    -1,   192,    -1,    48,    -1,   227,
2131       -1,   154,     4,    -1,   190,   155,   195,   156,    -1,   157,
2132        4,   158,   193,   159,    -1,   160,     4,   158,   193,   161,
2133       -1,   162,   194,   163,    -1,   162,   163,    -1,   160,   162,
2134      194,   163,   161,    -1,   160,   162,   163,   161,    -1,   193,
2135      164,    -1,   193,    -1,   194,   153,   193,    -1,   194,    -1,
2136      194,   153,    37,    -1,    37,    -1,    -1,   191,   157,   198,
2137      159,    -1,   191,   157,   159,    -1,   191,   165,    24,    -1,
2138      191,   160,   198,   161,    -1,   191,   162,   198,   163,    -1,
2139      191,   162,   163,    -1,   191,   160,   162,   198,   163,   161,
2140       -1,   191,   160,   162,   163,   161,    -1,   191,    38,    -1,
2141      191,    39,    -1,   191,   227,    -1,   191,   197,    -1,   191,
2142       26,    -1,   176,   168,    -1,   177,     4,    -1,     9,    27,
2143       -1,     9,    28,    -1,   179,     7,    -1,   175,   155,   196,
2144       36,   191,   156,    -1,   106,   155,   196,   242,   156,    -1,
2145      108,   155,   196,   153,   196,   153,   196,   156,    -1,   169,
2146      155,   196,   153,   196,   156,    -1,   170,   155,   196,   153,
2147      196,   156,    -1,   171,   155,   196,   153,   196,   156,    -1,
2148       99,   172,   155,   196,   153,   196,   156,    -1,   100,   173,
2149      155,   196,   153,   196,   156,    -1,   174,   155,   196,   153,
2150      196,   156,    -1,   114,   155,   196,   153,   196,   156,    -1,
2151      115,   155,   196,   153,   196,   153,   196,   156,    -1,   116,
2152      155,   196,   153,   196,   153,   196,   156,    -1,   198,   153,
2153      196,    -1,   196,    -1,    32,    -1,    33,    -1,   201,    -1,
2154      201,   221,    -1,   201,   223,    -1,   201,    62,    61,   207,
2155       -1,   201,    25,    -1,   202,    -1,   202,   180,    20,   189,
2156       -1,   202,   223,    -1,   202,    62,    61,   207,    -1,    -1,
2157      202,   180,   181,   199,   196,   203,   187,    -1,    -1,   202,
2158      180,    50,   199,   191,   204,   187,    -1,    -1,   202,   180,
2159       45,   199,   191,   205,   187,    -1,    -1,   202,   180,    47,
2160      199,   191,   206,   187,    -1,   202,    51,   209,    -1,   202,
2161       58,   152,   210,    -1,    -1,    24,    -1,    56,    -1,    55,
2162       -1,    53,   152,   208,    -1,    54,   152,     4,    -1,    52,
2163      152,    24,    -1,    71,   152,    24,    -1,   157,   211,   159,
2164       -1,   211,   153,    24,    -1,    24,    -1,    -1,    22,    -1,
2165       24,    -1,   212,    -1,    -1,   191,   213,    -1,   215,   153,
2166      214,    -1,   214,    -1,   215,    -1,   215,   153,    37,    -1,
2167       37,    -1,    -1,   182,   189,   212,   155,   216,   156,   186,
2168      183,    -1,    29,    -1,   162,    -1,   181,   217,   218,    -1,
2169       30,    -1,   163,    -1,   230,   220,    -1,    -1,    45,    -1,
2170       47,    -1,    -1,    31,   224,   222,   217,    -1,    -1,    63,
2171       -1,     3,    -1,     4,    -1,     7,    -1,    27,    -1,    28,
2172       -1,    38,    -1,    39,    -1,    26,    -1,   160,   198,   161,
2173       -1,   197,    -1,    61,   225,    24,   153,    24,    -1,   167,
2174       -1,   212,    -1,   227,    -1,   226,    -1,   191,   228,    -1,
2175      230,   231,    -1,   219,   231,    -1,   232,   180,   234,    -1,
2176      232,   236,    -1,    -1,    23,    -1,    77,    -1,    78,    -1,
2177       72,   229,    -1,    72,     8,    -1,    73,    21,   228,    -1,
2178       73,     9,   228,   153,    21,   228,   153,    21,   228,    -1,
2179       74,   178,   228,   153,    21,   228,   157,   235,   159,    -1,
2180       74,   178,   228,   153,    21,   228,   157,   159,    -1,    75,
2181      182,   189,   228,   155,   239,   156,    36,    21,   228,   233,
2182       21,   228,    -1,   233,    -1,    76,    -1,   235,   178,   226,
2183      153,    21,   228,    -1,   178,   226,   153,    21,   228,    -1,
2184      180,   241,    -1,   191,   157,   228,   153,   228,   159,    -1,
2185      237,   153,   157,   228,   153,   228,   159,    -1,   229,    -1,
2186      238,   153,   229,    -1,   238,    -1,    -1,    60,    59,    -1,
2187       59,    -1,   169,   191,   228,   153,   228,    -1,   170,   191,
2188      228,   153,   228,    -1,   171,   191,   228,   153,   228,    -1,
2189       99,   172,   191,   228,   153,   228,    -1,   100,   173,   191,
2190      228,   153,   228,    -1,    49,   229,    -1,   174,   229,   153,
2191      229,    -1,   175,   229,    36,   191,    -1,   108,   229,   153,
2192      229,   153,   229,    -1,   113,   229,   153,   191,    -1,   117,
2193      229,   153,   191,    -1,   118,   229,   153,   191,    -1,   114,
2194      229,   153,   229,    -1,   115,   229,   153,   229,   153,   229,
2195       -1,   116,   229,   153,   229,   153,   229,    -1,   107,   237,
2196       -1,   240,   182,   189,   228,   155,   239,   156,    -1,   244,
2197       -1,   153,   238,    -1,    -1,    35,    -1,    -1,   101,   191,
2198      184,    -1,   101,   191,   153,    15,   228,   184,    -1,   102,
2199      191,   184,    -1,   102,   191,   153,    15,   228,   184,    -1,
2200      103,   229,    -1,   243,   104,   191,   228,    -1,   243,   105,
2201      229,   153,   191,   228,    -1,   106,   191,   228,   242,    -1
2202 };
2203
2204 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
2205 static const yytype_uint16 yyrline[] =
2206 {
2207        0,  1479,  1479,  1480,  1488,  1489,  1499,  1499,  1499,  1499,
2208     1499,  1499,  1499,  1499,  1499,  1499,  1499,  1503,  1503,  1503,
2209     1507,  1507,  1507,  1507,  1507,  1507,  1511,  1511,  1512,  1512,
2210     1513,  1513,  1514,  1514,  1515,  1515,  1519,  1519,  1520,  1520,
2211     1521,  1521,  1522,  1522,  1523,  1523,  1524,  1524,  1525,  1525,
2212     1526,  1527,  1530,  1530,  1530,  1530,  1534,  1534,  1534,  1534,
2213     1534,  1534,  1534,  1535,  1535,  1535,  1535,  1535,  1535,  1541,
2214     1541,  1541,  1541,  1545,  1545,  1545,  1545,  1549,  1549,  1553,
2215     1553,  1558,  1561,  1566,  1567,  1568,  1569,  1570,  1571,  1572,
2216     1573,  1577,  1578,  1579,  1580,  1581,  1582,  1583,  1584,  1594,
2217     1595,  1603,  1604,  1612,  1621,  1622,  1629,  1630,  1634,  1638,
2218     1654,  1655,  1662,  1663,  1670,  1678,  1678,  1678,  1678,  1678,
2219     1678,  1678,  1679,  1679,  1679,  1679,  1679,  1684,  1688,  1692,
2220     1697,  1706,  1722,  1728,  1741,  1750,  1754,  1765,  1769,  1782,
2221     1786,  1793,  1794,  1800,  1807,  1819,  1849,  1862,  1885,  1913,
2222     1935,  1946,  1968,  1979,  1988,  1993,  2051,  2058,  2066,  2073,
2223     2080,  2084,  2088,  2097,  2112,  2125,  2134,  2162,  2175,  2184,
2224     2190,  2196,  2205,  2211,  2217,  2228,  2229,  2238,  2239,  2251,
2225     2260,  2261,  2262,  2263,  2264,  2280,  2300,  2302,  2304,  2304,
2226     2311,  2311,  2318,  2318,  2325,  2325,  2333,  2335,  2337,  2342,
2227     2356,  2357,  2361,  2364,  2372,  2376,  2383,  2387,  2391,  2395,
2228     2403,  2403,  2407,  2408,  2412,  2420,  2425,  2433,  2434,  2441,
2229     2448,  2452,  2558,  2558,  2562,  2572,  2572,  2576,  2580,  2582,
2230     2583,  2587,  2587,  2599,  2600,  2605,  2606,  2607,  2608,  2609,
2231     2610,  2611,  2612,  2613,  2634,  2637,  2652,  2653,  2658,  2658,
2232     2666,  2675,  2678,  2687,  2697,  2702,  2711,  2722,  2722,  2725,
2233     2728,  2731,  2735,  2741,  2756,  2762,  2813,  2816,  2822,  2832,
2234     2845,  2874,  2882,  2890,  2894,  2901,  2902,  2906,  2909,  2915,
2235     2932,  2948,  2962,  2974,  2986,  2997,  3006,  3015,  3024,  3031,
2236     3052,  3076,  3082,  3088,  3094,  3110,  3183,  3191,  3192,  3196,
2237     3197,  3201,  3207,  3213,  3219,  3225,  3232,  3244,  3258
2238 };
2239 #endif
2240
2241 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2242 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2243    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
2244 static const char *const yytname[] =
2245 {
2246   "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2247   "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2248   "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2249   "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2250   "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2251   "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2252   "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2253   "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2254   "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2255   "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2256   "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2257   "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2258   "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2259   "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2260   "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2261   "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2262   "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2263   "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2264   "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2265   "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2266   "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2267   "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2268   "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2269   "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2270   "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2271   "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2272   "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2273   "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2274   "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2275   "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2276   "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2277   "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2278   "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2279   "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2280   "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2281   "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2282   "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2283   "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2284   "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2285   "OptVolatile", "MemoryInst", 0
2286 };
2287 #endif
2288
2289 # ifdef YYPRINT
2290 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2291    token YYLEX-NUM.  */
2292 static const yytype_uint16 yytoknum[] =
2293 {
2294        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
2295      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
2296      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
2297      285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
2298      295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
2299      305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
2300      315,   316,   317,   318,   319,   320,   321,   322,   323,   324,
2301      325,   326,   327,   328,   329,   330,   331,   332,   333,   334,
2302      335,   336,   337,   338,   339,   340,   341,   342,   343,   344,
2303      345,   346,   347,   348,   349,   350,   351,   352,   353,   354,
2304      355,   356,   357,   358,   359,   360,   361,   362,   363,   364,
2305      365,   366,   367,   368,   369,   370,   371,   372,   373,   374,
2306      375,   376,   377,   378,   379,   380,   381,   382,   383,   384,
2307      385,   386,   387,   388,   389,   390,   391,   392,   393,   394,
2308      395,   396,   397,   398,   399,   400,   401,   402,   403,   404,
2309      405,   406,    61,    44,    92,    40,    41,    91,   120,    93,
2310       60,    62,   123,   125,    42,    99
2311 };
2312 # endif
2313
2314 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
2315 static const yytype_uint8 yyr1[] =
2316 {
2317        0,   166,   167,   167,   168,   168,   169,   169,   169,   169,
2318      169,   169,   169,   169,   169,   169,   169,   170,   170,   170,
2319      171,   171,   171,   171,   171,   171,   172,   172,   172,   172,
2320      172,   172,   172,   172,   172,   172,   173,   173,   173,   173,
2321      173,   173,   173,   173,   173,   173,   173,   173,   173,   173,
2322      173,   173,   174,   174,   174,   174,   175,   175,   175,   175,
2323      175,   175,   175,   175,   175,   175,   175,   175,   175,   176,
2324      176,   176,   176,   177,   177,   177,   177,   178,   178,   179,
2325      179,   180,   180,   181,   181,   181,   181,   181,   181,   181,
2326      181,   182,   182,   182,   182,   182,   182,   182,   182,   183,
2327      183,   184,   184,   185,   186,   186,   187,   187,   188,   188,
2328      189,   189,   190,   190,   191,   192,   192,   192,   192,   192,
2329      192,   192,   192,   192,   192,   192,   192,   193,   193,   193,
2330      193,   193,   193,   193,   193,   193,   193,   193,   193,   194,
2331      194,   195,   195,   195,   195,   196,   196,   196,   196,   196,
2332      196,   196,   196,   196,   196,   196,   196,   196,   196,   196,
2333      196,   196,   196,   197,   197,   197,   197,   197,   197,   197,
2334      197,   197,   197,   197,   197,   198,   198,   199,   199,   200,
2335      201,   201,   201,   201,   201,   202,   202,   202,   203,   202,
2336      204,   202,   205,   202,   206,   202,   202,   202,   202,   207,
2337      208,   208,   209,   209,   209,   209,   210,   211,   211,   211,
2338      212,   212,   213,   213,   214,   215,   215,   216,   216,   216,
2339      216,   217,   218,   218,   219,   220,   220,   221,   222,   222,
2340      222,   224,   223,   225,   225,   226,   226,   226,   226,   226,
2341      226,   226,   226,   226,   226,   226,   227,   227,   228,   228,
2342      229,   230,   230,   231,   232,   232,   232,   233,   233,   234,
2343      234,   234,   234,   234,   234,   234,   234,   234,   235,   235,
2344      236,   237,   237,   238,   238,   239,   239,   240,   240,   241,
2345      241,   241,   241,   241,   241,   241,   241,   241,   241,   241,
2346      241,   241,   241,   241,   241,   241,   241,   242,   242,   243,
2347      243,   244,   244,   244,   244,   244,   244,   244,   244
2348 };
2349
2350 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
2351 static const yytype_uint8 yyr2[] =
2352 {
2353        0,     2,     1,     1,     1,     1,     1,     1,     1,     1,
2354        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2355        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2356        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2357        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2358        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2359        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2360        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2361        1,     2,     0,     1,     1,     1,     1,     1,     1,     1,
2362        0,     0,     1,     1,     1,     1,     1,     1,     2,     0,
2363        2,     0,     3,     2,     0,     1,     0,     3,     1,     2,
2364        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2365        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2366        2,     4,     5,     5,     3,     2,     5,     4,     2,     1,
2367        3,     1,     3,     1,     0,     4,     3,     3,     4,     4,
2368        3,     6,     5,     2,     2,     2,     2,     2,     2,     2,
2369        2,     2,     2,     6,     5,     8,     6,     6,     6,     7,
2370        7,     6,     6,     8,     8,     3,     1,     1,     1,     1,
2371        2,     2,     4,     2,     1,     4,     2,     4,     0,     7,
2372        0,     7,     0,     7,     0,     7,     3,     4,     0,     1,
2373        1,     1,     3,     3,     3,     3,     3,     3,     1,     0,
2374        1,     1,     1,     0,     2,     3,     1,     1,     3,     1,
2375        0,     8,     1,     1,     3,     1,     1,     2,     0,     1,
2376        1,     0,     4,     0,     1,     1,     1,     1,     1,     1,
2377        1,     1,     1,     3,     1,     5,     1,     1,     1,     1,
2378        2,     2,     2,     3,     2,     0,     1,     1,     1,     2,
2379        2,     3,     9,     9,     8,    13,     1,     1,     6,     5,
2380        2,     6,     7,     1,     3,     1,     0,     2,     1,     5,
2381        5,     5,     6,     6,     2,     4,     4,     6,     4,     4,
2382        4,     4,     6,     6,     2,     7,     1,     2,     0,     1,
2383        0,     3,     6,     3,     6,     2,     4,     6,     4
2384 };
2385
2386 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2387    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
2388    means the default is an error.  */
2389 static const yytype_uint16 yydefact[] =
2390 {
2391      198,     0,    90,   184,     1,   183,   231,    83,    84,    85,
2392       86,    87,    88,    89,     0,    91,   255,   180,   181,   255,
2393      210,   211,     0,     0,     0,    90,     0,   186,   228,     0,
2394        0,    92,    93,    94,    95,    96,    97,     0,     0,   256,
2395      252,    82,   225,   226,   227,   251,     0,     0,     0,     0,
2396      196,     0,     0,     0,     0,     0,     0,     0,    81,   229,
2397      230,    91,   199,   182,    98,     2,     3,   111,   115,   116,
2398      117,   118,   119,   120,   121,   122,   123,   124,   125,   126,
2399      128,     0,     0,     0,     0,   246,     0,     0,   110,   127,
2400      114,   247,   129,   222,   223,   224,   300,   254,     0,     0,
2401        0,     0,   209,   197,   187,   185,   177,   178,     0,     0,
2402        0,     0,   232,   130,     0,     0,     0,   113,   135,   139,
2403        0,     0,   144,   138,   299,     0,   278,     0,     0,     0,
2404        0,    91,   267,   257,   258,     6,     7,     8,     9,    10,
2405       11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
2406       21,    22,    23,    24,    25,     0,     0,     0,     0,     0,
2407        0,     0,     0,    52,    53,    54,    55,     0,     0,     0,
2408        0,     0,     0,    68,    56,    57,    58,    59,    60,    61,
2409       62,    63,    64,    65,    66,    67,     0,     0,     0,     0,
2410        0,   266,   253,    91,   270,     0,   296,   204,   201,   200,
2411      202,   203,   205,   208,     0,   192,   194,   190,   115,   116,
2412      117,   118,   119,   120,   121,   122,   123,   124,   125,     0,
2413        0,     0,     0,   188,     0,     0,     0,     0,     0,   134,
2414      220,   143,   141,     0,     0,   284,   277,   260,   259,     0,
2415        0,    72,    76,    71,    75,    70,    74,    69,    73,    77,
2416       78,     0,     0,    26,    27,    28,    29,    30,    31,    32,
2417       33,    34,    35,     0,    50,    51,    46,    47,    48,    49,
2418       36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
2419        0,   101,   101,   305,     0,     0,   294,     0,     0,     0,
2420        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2421        0,     0,     0,   206,   106,   106,   106,   160,   161,     4,
2422        5,   158,   159,   162,   157,   153,   154,     0,     0,     0,
2423        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2424        0,     0,     0,   156,   155,   106,   112,   112,   137,     0,
2425      140,   219,   213,   216,   217,     0,     0,   131,   235,   236,
2426      237,   242,   238,   239,   240,   241,   233,     0,   244,   249,
2427      248,   250,     0,   261,     0,     0,     0,     0,     0,   301,
2428        0,   303,   298,     0,     0,     0,     0,     0,     0,     0,
2429        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2430      207,     0,   193,   195,   191,     0,     0,     0,     0,     0,
2431        0,     0,   146,   176,     0,     0,     0,   150,     0,   147,
2432        0,     0,     0,     0,     0,   189,   132,   133,   136,   212,
2433      214,     0,   104,   142,   234,     0,     0,     0,     0,     0,
2434        0,     0,     0,     0,     0,     0,   308,     0,     0,     0,
2435      288,   291,     0,     0,   289,   290,     0,     0,     0,   285,
2436      286,     0,   306,     0,     0,     0,   108,   106,     0,     0,
2437      298,     0,     0,     0,     0,     0,   145,   135,   114,     0,
2438      148,   149,     0,     0,     0,     0,     0,   218,   215,   105,
2439       99,     0,   243,     0,     0,   276,     0,     0,   101,   102,
2440      101,   273,   297,     0,     0,     0,     0,     0,   279,   280,
2441      281,   276,     0,   103,   109,   107,     0,     0,     0,     0,
2442        0,     0,     0,   175,   152,     0,     0,     0,     0,     0,
2443        0,     0,   221,     0,     0,     0,   275,     0,   282,   283,
2444        0,   302,   304,     0,     0,     0,   287,   292,   293,     0,
2445      307,     0,     0,   164,     0,     0,     0,     0,   151,     0,
2446        0,     0,     0,     0,   100,   245,     0,     0,     0,   274,
2447      271,     0,   295,     0,     0,     0,   172,     0,     0,   166,
2448      167,   168,   171,   163,     0,   264,     0,     0,     0,   272,
2449      169,   170,     0,     0,     0,   262,     0,   263,     0,     0,
2450      165,   173,   174,     0,     0,     0,     0,     0,     0,   269,
2451        0,     0,   268,   265
2452 };
2453
2454 /* YYDEFGOTO[NTERM-NUM].  */
2455 static const yytype_int16 yydefgoto[] =
2456 {
2457       -1,    85,   311,   328,   329,   330,   263,   280,   331,   332,
2458      219,   220,   251,   221,    25,    15,    37,   522,   369,   456,
2459      480,   392,   457,    86,    87,   222,    89,    90,   120,   233,
2460      403,   358,   404,   108,     1,     2,     3,   335,   306,   304,
2461      305,    63,   200,    50,   103,   204,    91,   420,   343,   344,
2462      345,    38,    95,    16,    44,    17,    61,    18,    28,   425,
2463      359,    92,   361,   491,    19,    40,    41,   191,   192,   577,
2464       97,   286,   526,   527,   193,   194,   436,   195,   196
2465 };
2466
2467 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2468    STATE-NUM.  */
2469 #define YYPACT_NINF -508
2470 static const yytype_int16 yypact[] =
2471 {
2472     -508,    18,   144,   546,  -508,  -508,  -508,  -508,  -508,  -508,
2473     -508,  -508,  -508,  -508,     2,   152,    47,  -508,  -508,   -15,
2474     -508,  -508,   -30,   -75,    29,    69,   -10,  -508,    98,   104,
2475      151,  -508,  -508,  -508,  -508,  -508,  -508,  1307,    -8,  -508,
2476     -508,   149,  -508,  -508,  -508,  -508,    11,    20,    22,    24,
2477     -508,    27,   104,  1307,     0,     0,     0,     0,  -508,  -508,
2478     -508,   152,  -508,  -508,  -508,  -508,  -508,    37,  -508,  -508,
2479     -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,
2480     -508,   194,   200,     3,   695,  -508,   149,    54,  -508,  -508,
2481      -81,  -508,  -508,  -508,  -508,  -508,  1561,  -508,   186,   -19,
2482      210,   188,   203,  -508,  -508,  -508,  -508,  -508,  1368,  1368,
2483     1368,  1409,  -508,  -508,    66,    70,   715,  -508,  -508,   -81,
2484      -85,    75,   781,  -508,  -508,  1368,  -508,   172,  1429,    58,
2485      255,   152,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,
2486     -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,
2487     -508,  -508,  -508,  -508,  -508,   208,   394,  1368,  1368,  1368,
2488     1368,  1368,  1368,  -508,  -508,  -508,  -508,  1368,  1368,  1368,
2489     1368,  1368,  1368,  -508,  -508,  -508,  -508,  -508,  -508,  -508,
2490     -508,  -508,  -508,  -508,  -508,  -508,  1368,  1368,  1368,  1368,
2491     1368,  -508,  -508,   152,  -508,    55,  -508,  -508,  -508,  -508,
2492     -508,  -508,  -508,  -508,   -50,  -508,  -508,  -508,   153,   179,
2493      228,   191,   229,   193,   230,   197,   231,   233,   234,   199,
2494      232,   235,   537,  -508,  1368,  1368,    84,   -45,  1368,  -508,
2495     1149,  -508,    93,    91,   898,  -508,  -508,    37,  -508,   898,
2496      898,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,
2497     -508,   898,  1307,  -508,  -508,  -508,  -508,  -508,  -508,  -508,
2498     -508,  -508,  -508,  1368,  -508,  -508,  -508,  -508,  -508,  -508,
2499     -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,  -508,
2500     1368,    95,    96,  -508,   898,    99,    97,   105,   106,   107,
2501      120,   123,   126,   127,   898,   898,   898,   128,   221,  1307,
2502     1368,  1368,   258,  -508,   132,   132,   132,  -508,  -508,  -508,
2503     -508,  -508,  -508,  -508,  -508,  -508,  -508,   208,   394,   131,
2504      134,   135,   136,   137,  1190,  1470,   736,   259,   139,   140,
2505      141,   142,   148,  -508,  -508,   132,  -130,   -23,  -508,   143,
2506      -81,  -508,   149,  -508,   155,   154,  1210,  -508,  -508,  -508,
2507     -508,  -508,  -508,  -508,  -508,  -508,   224,  1409,  -508,  -508,
2508     -508,  -508,   156,  -508,   163,   898,   898,   898,     4,  -508,
2509        5,  -508,   164,   898,   162,  1368,  1368,  1368,  1368,  1368,
2510     1368,  1368,   167,   168,   169,  1368,  1368,   898,   898,   170,
2511     -508,   -17,  -508,  -508,  -508,   150,   182,  1409,  1409,  1409,
2512     1409,  1409,  -508,  -508,   -13,   756,   -24,  -508,   -36,  -508,
2513     1409,  1409,  1409,  1409,  1409,  -508,  -508,  -508,  -508,  -508,
2514     -508,  1251,   290,  -508,  -508,   301,   -14,   324,   325,   198,
2515      201,   202,   898,   348,   898,  1368,  -508,   204,   898,   205,
2516     -508,  -508,   211,   214,  -508,  -508,   898,   898,   898,  -508,
2517     -508,   213,  -508,  1368,   332,   365,  -508,   132,  1409,  1409,
2518      164,   217,   222,   223,   225,  1409,  -508,   216,   -71,   -27,
2519     -508,  -508,   226,   236,   237,   240,   338,  -508,  -508,  -508,
2520      326,   241,  -508,   898,   898,  1368,   898,   898,   242,  -508,
2521      242,  -508,   243,   898,   244,  1368,  1368,  1368,  -508,  -508,
2522     -508,  1368,   898,  -508,  -508,  -508,   246,   247,   245,  1409,
2523     1409,  1409,  1409,  -508,  -508,   220,  1409,  1409,  1409,  1409,
2524     1368,   378,  -508,   361,   249,   248,   243,   250,  -508,  -508,
2525      329,  -508,  -508,  1368,   256,   898,  -508,  -508,  -508,   251,
2526     -508,  1409,  1409,  -508,   261,   252,   270,   271,  -508,   269,
2527      272,   275,   279,   280,  -508,  -508,   367,    40,   368,  -508,
2528     -508,   267,  -508,   281,   282,  1409,  -508,  1409,  1409,  -508,
2529     -508,  -508,  -508,  -508,   898,  -508,   996,    85,   382,  -508,
2530     -508,  -508,   283,   285,   288,  -508,   274,  -508,   996,   898,
2531     -508,  -508,  -508,   424,   293,   130,   898,   426,   430,  -508,
2532      898,   898,  -508,  -508
2533 };
2534
2535 /* YYPGOTO[NTERM-NUM].  */
2536 static const yytype_int16 yypgoto[] =
2537 {
2538     -508,  -508,  -508,   356,   357,   360,   145,   147,   371,   374,
2539     -128,  -127,  -497,  -508,   416,   436,  -117,  -508,  -277,    41,
2540     -508,  -296,  -508,   -47,  -508,   -37,  -508,   -58,    46,  -508,
2541      -99,   253,  -298,    49,  -508,  -508,  -508,  -508,  -508,  -508,
2542     -508,   419,  -508,  -508,  -508,  -508,     8,  -508,    51,  -508,
2543     -508,   412,  -508,  -508,  -508,  -508,  -508,   471,  -508,  -508,
2544     -507,  -209,    67,  -124,  -508,   457,  -508,  -118,  -508,  -508,
2545     -508,  -508,    43,   -22,  -508,  -508,    21,  -508,  -508
2546 };
2547
2548 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
2549    positive, shift that token.  If negative, reduce the rule which
2550    number is the opposite.  If zero, do what YYDEFACT says.
2551    If YYTABLE_NINF, syntax error.  */
2552 #define YYTABLE_NINF -180
2553 static const yytype_int16 yytable[] =
2554 {
2555       88,   235,   249,   250,   238,   371,   105,   115,    39,   393,
2556      394,    26,   223,   334,   252,    42,    88,   454,     4,   432,
2557      434,    93,    46,    47,    48,   360,   119,   406,   408,   416,
2558      360,   360,   106,   107,   123,   283,   198,   199,   287,   415,
2559      455,    49,   360,   288,   289,   290,   291,   292,   293,    26,
2560      241,   242,   243,   244,   245,   246,   247,   248,   119,   426,
2561      576,   433,   433,    29,   119,   297,   298,   239,   228,   586,
2562       39,   205,   206,   207,  -112,   360,   299,    51,   229,   240,
2563      588,   594,  -139,   123,  -112,   360,   360,   360,   234,    53,
2564       52,   234,  -139,   123,   121,   241,   242,   243,   244,   245,
2565      246,   247,   248,   302,   109,   110,   111,   469,   228,   303,
2566        7,     8,     9,    10,    54,    12,    55,   465,   339,    56,
2567      281,   282,   234,   284,   285,   234,   465,   471,    62,   465,
2568      234,   234,   234,   234,   234,   234,   515,   470,   417,   465,
2569      465,   123,    58,    59,  -179,    60,   466,   482,    43,   294,
2570      295,   296,   234,   234,    94,    64,   360,   360,   360,   300,
2571      301,   505,   227,    98,   360,   116,   336,   337,   232,     5,
2572      340,    20,    99,    21,   100,     6,   101,   389,   360,   360,
2573      307,   308,   -72,   -72,   102,     7,     8,     9,    10,    11,
2574       12,    13,  -113,   342,   -71,   -71,   -70,   -70,   113,   575,
2575      -69,   -69,   309,   310,   114,   365,    14,   133,   134,   122,
2576      197,   531,   202,   532,   201,    88,    30,    31,    32,    33,
2577       34,    35,    36,   360,   224,   360,   366,   203,   225,   360,
2578      230,   236,   -76,   -75,   -74,   -73,   312,   360,   360,   360,
2579      -79,   -80,   313,   367,   587,   338,   346,   347,   368,   370,
2580      374,   439,   387,   441,   442,   443,   373,   386,   375,   376,
2581      377,   449,    88,   388,   234,   241,   242,   243,   244,   245,
2582      246,   247,   248,   378,   360,   360,   379,   360,   360,   380,
2583      381,   385,   390,   409,   360,   391,   397,   424,   340,   398,
2584      399,   400,   401,   360,   410,   411,   412,   413,   460,   461,
2585      462,   463,   464,   414,   418,   458,   362,   363,   421,   427,
2586      422,   472,   473,   474,   475,   476,   428,   435,   364,   438,
2587      446,   447,   448,   453,   454,   481,   360,   253,   254,   255,
2588      256,   257,   258,   259,   260,   261,   262,   459,   234,   440,
2589      234,   234,   234,   444,   445,   483,   484,   468,   234,   450,
2590      419,   372,   489,   485,   486,   487,   503,   493,   495,   506,
2591      507,   382,   383,   384,   496,   360,   513,   497,   501,   504,
2592      509,   536,   537,   538,   520,   510,   511,   514,   512,   516,
2593      360,   548,   554,   521,   342,   555,   433,   360,   574,   517,
2594      518,   360,   360,   519,   523,   530,   533,   535,   234,   541,
2595      542,   543,   556,   589,   578,   557,   558,   562,   566,   559,
2596      544,   545,   546,   547,   565,   560,   502,   549,   550,   551,
2597      552,   264,   265,   567,   568,   569,   579,   593,   570,   249,
2598      250,   571,   429,   430,   431,   572,   573,   580,   581,   590,
2599      437,   591,   563,   564,   592,   596,   597,   600,   234,   249,
2600      250,   601,   186,   187,   451,   452,   188,    96,   234,   234,
2601      234,    57,   395,   479,   234,   396,   582,   189,   583,   584,
2602      190,   104,   478,   112,    27,   333,    45,   598,   492,   539,
2603        0,   508,     0,   553,     0,     0,     0,     0,     0,     0,
2604        0,     0,     0,     0,     0,     0,   234,     0,     0,   488,
2605        0,   490,     0,     0,     0,   494,     0,     0,     0,     0,
2606        0,     0,     0,   498,   499,   500,     0,     0,     0,   266,
2607      267,   268,   269,   270,   271,   272,   273,   274,   275,   276,
2608      277,   278,   279,     0,     0,     0,     0,     0,     0,     0,
2609        0,     0,    65,    66,     0,     0,     0,     0,     0,     0,
2610      524,   525,     0,   528,   529,     0,     0,     0,     0,    20,
2611      534,    21,     0,   314,     0,     0,   -82,     0,    20,   540,
2612       21,     0,     0,     0,     0,   315,   316,     6,   -82,   -82,
2613        0,     0,     0,     0,     0,     0,     0,   -82,   -82,   -82,
2614      -82,   -82,   -82,   -82,     0,     0,   -82,    22,     0,     0,
2615        0,     0,   561,     0,    23,     0,     0,     0,    24,     0,
2616        0,     0,     0,     0,     0,     0,   135,   136,   137,   138,
2617      139,   140,   141,   142,   143,   144,   145,   146,   147,   148,
2618      149,   150,   151,   152,   153,   154,   317,   318,     0,     0,
2619        0,   585,     0,   319,     0,   320,   163,   164,   165,   166,
2620        0,   321,   322,   323,     0,     0,   595,     0,     0,     0,
2621        0,     0,     0,   599,     0,     0,     0,   602,   603,     0,
2622        0,     0,     0,     0,     0,     0,   173,   174,   175,   176,
2623      177,   178,   179,   180,   181,   182,   183,   184,   185,     0,
2624        0,     0,     0,     0,   324,     0,     0,   325,     0,   326,
2625       65,    66,   327,   117,    68,    69,    70,    71,    72,    73,
2626       74,    75,    76,    77,    78,     0,    79,    20,     0,    21,
2627       65,    66,     0,   117,    68,    69,    70,    71,    72,    73,
2628       74,    75,    76,    77,    78,     0,    79,    20,     0,    21,
2629        0,    65,    66,    80,   117,   208,   209,   210,   211,   212,
2630      213,   214,   215,   216,   217,   218,     0,    79,    20,     0,
2631       21,    65,    66,    80,   117,   208,   209,   210,   211,   212,
2632      213,   214,   215,   216,   217,   218,     0,    79,    20,     0,
2633       21,     0,     0,     0,    80,     0,    65,    66,     0,   117,
2634       68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
2635       78,     0,    79,    20,    80,    21,     0,     0,     0,     0,
2636        0,     0,     0,     0,     0,     0,     0,     0,   231,     0,
2637        0,     0,     0,     0,     0,     0,     0,     0,     0,    80,
2638        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2639        0,     0,     0,     0,     0,     0,     0,     0,     0,    81,
2640        0,     0,    82,     0,     0,    83,     0,    84,   118,     0,
2641        0,     0,     0,     0,     0,     0,     0,     0,     0,    81,
2642        0,     0,    82,     0,     0,    83,     0,    84,   226,     0,
2643        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2644       81,     0,     0,    82,     0,     0,    83,     0,    84,   407,
2645        0,   348,   349,    65,    66,   350,     0,     0,     0,     0,
2646       81,     0,     0,    82,     0,     0,    83,     0,    84,   467,
2647       20,     0,    21,     0,   351,   352,   353,     0,     0,     0,
2648        0,     0,     0,     0,     0,    81,   354,   355,    82,     0,
2649        0,    83,     0,    84,     0,     0,     0,     0,     0,     0,
2650        0,     0,     0,     0,     0,     0,     0,     0,     0,   356,
2651        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2652        0,     0,     0,     0,     0,     0,     0,   135,   136,   137,
2653      138,   139,   140,   141,   142,   143,   144,   145,   146,   147,
2654      148,   149,   150,   151,   152,   153,   154,   317,   318,   348,
2655      349,     0,     0,   350,   319,     0,   320,   163,   164,   165,
2656      166,     0,   321,   322,   323,     0,     0,     0,     0,     0,
2657        0,     0,   351,   352,   353,     0,     0,     0,     0,     0,
2658        0,     0,     0,     0,   354,   355,     0,   173,   174,   175,
2659      176,   177,   178,   179,   180,   181,   182,   183,   184,   185,
2660        0,     0,     0,     0,     0,     0,     0,   356,   357,     0,
2661        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2662        0,     0,     0,     0,     0,   135,   136,   137,   138,   139,
2663      140,   141,   142,   143,   144,   145,   146,   147,   148,   149,
2664      150,   151,   152,   153,   154,   317,   318,     0,     0,     0,
2665        0,     0,   319,     0,   320,   163,   164,   165,   166,     0,
2666      321,   322,   323,     0,     0,     0,     0,     0,     0,     0,
2667        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2668        0,     0,     0,     0,     0,   173,   174,   175,   176,   177,
2669      178,   179,   180,   181,   182,   183,   184,   185,     0,     0,
2670        0,     0,     0,     0,    65,    66,   357,   117,    68,    69,
2671       70,    71,    72,    73,    74,    75,    76,    77,    78,     0,
2672       79,    20,     0,    21,     0,     0,     0,     0,     0,     0,
2673        0,     0,     0,     0,     0,     0,   341,     0,     0,     0,
2674        0,     0,     0,     0,     0,    65,    66,    80,   117,   208,
2675      209,   210,   211,   212,   213,   214,   215,   216,   217,   218,
2676        0,    79,    20,     0,    21,    65,    66,     0,   117,    68,
2677       69,    70,    71,    72,    73,    74,    75,    76,    77,    78,
2678        0,    79,    20,     0,    21,     0,     0,     0,    80,     0,
2679        0,     0,     0,     0,     0,     0,     0,   423,     0,     0,
2680        0,     0,     0,     0,     0,     0,    65,    66,    80,   117,
2681       68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
2682       78,     0,    79,    20,     0,    21,     0,     0,     0,     0,
2683        0,     0,     0,     0,     0,     0,     0,     0,   477,     0,
2684        0,     0,     0,     0,     0,     0,     0,     0,     0,    80,
2685        0,     0,     0,    81,     0,     0,    82,     0,     0,    83,
2686        0,    84,    65,    66,     0,    67,    68,    69,    70,    71,
2687       72,    73,    74,    75,    76,    77,    78,     0,    79,    20,
2688        0,    21,     0,     0,     0,     0,     0,     0,     0,     0,
2689        0,     0,     0,     0,    81,     0,     0,    82,     0,   402,
2690       83,     0,    84,     0,     0,    80,     0,     0,     0,     0,
2691        0,     0,     0,     0,    81,     0,     0,    82,     0,     0,
2692       83,     0,    84,    65,    66,     0,   117,    68,    69,    70,
2693       71,    72,    73,    74,    75,    76,    77,    78,     0,    79,
2694       20,     0,    21,     0,     0,     0,     0,     0,     0,     0,
2695        0,     0,     0,     0,     0,    81,     0,     0,    82,     0,
2696        0,    83,     0,    84,    65,    66,    80,   117,   208,   209,
2697      210,   211,   212,   213,   214,   215,   216,   217,   218,     0,
2698       79,    20,     0,    21,    65,    66,     0,   237,    68,    69,
2699       70,    71,    72,    73,    74,    75,    76,    77,    78,     0,
2700       79,    20,     0,    21,     0,     0,     0,    80,     0,     0,
2701        0,    81,     0,     0,    82,     0,     0,    83,     0,    84,
2702        0,     0,     0,     0,     0,    65,    66,    80,   117,   208,
2703      209,   210,   211,   212,   213,   214,   215,   216,   217,   218,
2704        0,    79,    20,     0,    21,     0,     0,     0,     0,     0,
2705        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2706        0,     0,     0,     0,     0,     0,     0,     0,    80,     0,
2707        0,     0,    81,     0,     0,    82,     0,     0,    83,     0,
2708       84,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2709        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2710        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2711        0,     0,     0,    81,     0,     0,    82,     0,     0,    83,
2712        0,    84,     0,     0,     0,     0,     0,     0,     0,     0,
2713        0,     0,     0,    81,     0,     0,    82,     0,     0,    83,
2714        0,    84,     0,     0,     0,     0,   124,     0,     0,     0,
2715        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2716      125,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2717      126,   127,     0,     0,    81,     0,     0,    82,     0,     0,
2718       83,     0,   405,   128,   129,   130,   131,   132,   133,   134,
2719      135,   136,   137,   138,   139,   140,   141,   142,   143,   144,
2720      145,   146,   147,   148,   149,   150,   151,   152,   153,   154,
2721      155,   156,   157,   158,   159,     0,     0,   160,   161,   162,
2722      163,   164,   165,   166,   167,   168,   169,   170,   171,   172,
2723        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2724        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2725      173,   174,   175,   176,   177,   178,   179,   180,   181,   182,
2726      183,   184,   185
2727 };
2728
2729 static const yytype_int16 yycheck[] =
2730 {
2731       37,   125,   130,   130,   128,   282,    53,     4,    23,   305,
2732      306,     3,   111,   222,   131,    30,    53,    34,     0,    15,
2733       15,    29,    52,    53,    54,   234,    84,   325,   326,   159,
2734      239,   240,    32,    33,   164,   159,    55,    56,   162,   335,
2735       57,    71,   251,   167,   168,   169,   170,   171,   172,    41,
2736       10,    11,    12,    13,    14,    15,    16,    17,   116,   357,
2737      557,    57,    57,    61,   122,   189,   190,     9,   153,   576,
2738       23,   108,   109,   110,   155,   284,   193,   152,   163,    21,
2739      577,   588,   153,   164,   155,   294,   295,   296,   125,    20,
2740       61,   128,   163,   164,    86,    10,    11,    12,    13,    14,
2741       15,    16,    17,   153,    55,    56,    57,   405,   153,   159,
2742       41,    42,    43,    44,    45,    46,    47,   153,   163,    50,
2743      157,   158,   159,   160,   161,   162,   153,   163,    24,   153,
2744      167,   168,   169,   170,   171,   172,   163,   161,   161,   153,
2745      153,   164,   152,    45,     0,    47,   159,   161,   163,   186,
2746      187,   188,   189,   190,   162,     4,   365,   366,   367,   104,
2747      105,   457,   116,   152,   373,   162,   224,   225,   122,    25,
2748      228,    22,   152,    24,   152,    31,   152,   301,   387,   388,
2749       27,    28,     3,     4,   157,    41,    42,    43,    44,    45,
2750       46,    47,   155,   230,     3,     4,     3,     4,     4,   159,
2751        3,     4,     3,     4,     4,   252,    62,    77,    78,   155,
2752       24,   488,    24,   490,     4,   252,    64,    65,    66,    67,
2753       68,    69,    70,   432,   158,   434,   263,    24,   158,   438,
2754      155,    59,     4,     4,     4,     4,     4,   446,   447,   448,
2755        7,     7,     7,   280,   159,   161,   153,   156,   153,   153,
2756      153,   375,   299,   377,   378,   379,   157,    36,   153,   153,
2757      153,   385,   299,   300,   301,    10,    11,    12,    13,    14,
2758       15,    16,    17,   153,   483,   484,   153,   486,   487,   153,
2759      153,   153,    24,    24,   493,   153,   155,    63,   346,   155,
2760      155,   155,   155,   502,   155,   155,   155,   155,   397,   398,
2761      399,   400,   401,   155,   161,   155,   239,   240,   153,   153,
2762      156,   410,   411,   412,   413,   414,   153,   153,   251,   157,
2763      153,   153,   153,   153,    34,    24,   535,   119,   120,   121,
2764      122,   123,   124,   125,   126,   127,   128,   155,   375,   376,
2765      377,   378,   379,   380,   381,    21,    21,   405,   385,   386,
2766      342,   284,     4,   155,   153,   153,    24,   153,   153,   458,
2767      459,   294,   295,   296,   153,   574,   465,   153,   155,     4,
2768      153,   495,   496,   497,    36,   153,   153,   161,   153,   153,
2769      589,   161,     4,    57,   421,    24,    57,   596,    21,   153,
2770      153,   600,   601,   153,   153,   153,   153,   153,   435,   153,
2771      153,   156,   153,    21,    36,   157,   156,   156,   156,   533,
2772      509,   510,   511,   512,   153,   159,   453,   516,   517,   518,
2773      519,    27,    28,   153,   153,   156,   159,   153,   156,   557,
2774      557,   156,   365,   366,   367,   156,   156,   156,   156,   156,
2775      373,   156,   541,   542,   156,    21,   153,    21,   485,   577,
2776      577,    21,    96,    96,   387,   388,    96,    41,   495,   496,
2777      497,    25,   317,   422,   501,   318,   565,    96,   567,   568,
2778       96,    52,   421,    61,     3,   222,    19,   595,   435,   501,
2779       -1,   460,    -1,   520,    -1,    -1,    -1,    -1,    -1,    -1,
2780       -1,    -1,    -1,    -1,    -1,    -1,   533,    -1,    -1,   432,
2781       -1,   434,    -1,    -1,    -1,   438,    -1,    -1,    -1,    -1,
2782       -1,    -1,    -1,   446,   447,   448,    -1,    -1,    -1,   125,
2783      126,   127,   128,   129,   130,   131,   132,   133,   134,   135,
2784      136,   137,   138,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2785       -1,    -1,     5,     6,    -1,    -1,    -1,    -1,    -1,    -1,
2786      483,   484,    -1,   486,   487,    -1,    -1,    -1,    -1,    22,
2787      493,    24,    -1,    26,    -1,    -1,    20,    -1,    22,   502,
2788       24,    -1,    -1,    -1,    -1,    38,    39,    31,    32,    33,
2789       -1,    -1,    -1,    -1,    -1,    -1,    -1,    41,    42,    43,
2790       44,    45,    46,    47,    -1,    -1,    50,    51,    -1,    -1,
2791       -1,    -1,   535,    -1,    58,    -1,    -1,    -1,    62,    -1,
2792       -1,    -1,    -1,    -1,    -1,    -1,    79,    80,    81,    82,
2793       83,    84,    85,    86,    87,    88,    89,    90,    91,    92,
2794       93,    94,    95,    96,    97,    98,    99,   100,    -1,    -1,
2795       -1,   574,    -1,   106,    -1,   108,   109,   110,   111,   112,
2796       -1,   114,   115,   116,    -1,    -1,   589,    -1,    -1,    -1,
2797       -1,    -1,    -1,   596,    -1,    -1,    -1,   600,   601,    -1,
2798       -1,    -1,    -1,    -1,    -1,    -1,   139,   140,   141,   142,
2799      143,   144,   145,   146,   147,   148,   149,   150,   151,    -1,
2800       -1,    -1,    -1,    -1,   157,    -1,    -1,   160,    -1,   162,
2801        5,     6,   165,     8,     9,    10,    11,    12,    13,    14,
2802       15,    16,    17,    18,    19,    -1,    21,    22,    -1,    24,
2803        5,     6,    -1,     8,     9,    10,    11,    12,    13,    14,
2804       15,    16,    17,    18,    19,    -1,    21,    22,    -1,    24,
2805       -1,     5,     6,    48,     8,     9,    10,    11,    12,    13,
2806       14,    15,    16,    17,    18,    19,    -1,    21,    22,    -1,
2807       24,     5,     6,    48,     8,     9,    10,    11,    12,    13,
2808       14,    15,    16,    17,    18,    19,    -1,    21,    22,    -1,
2809       24,    -1,    -1,    -1,    48,    -1,     5,     6,    -1,     8,
2810        9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
2811       19,    -1,    21,    22,    48,    24,    -1,    -1,    -1,    -1,
2812       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,    -1,
2813       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    48,
2814       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2815       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   154,
2816       -1,    -1,   157,    -1,    -1,   160,    -1,   162,   163,    -1,
2817       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   154,
2818       -1,    -1,   157,    -1,    -1,   160,    -1,   162,   163,    -1,
2819       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2820      154,    -1,    -1,   157,    -1,    -1,   160,    -1,   162,   163,
2821       -1,     3,     4,     5,     6,     7,    -1,    -1,    -1,    -1,
2822      154,    -1,    -1,   157,    -1,    -1,   160,    -1,   162,   163,
2823       22,    -1,    24,    -1,    26,    27,    28,    -1,    -1,    -1,
2824       -1,    -1,    -1,    -1,    -1,   154,    38,    39,   157,    -1,
2825       -1,   160,    -1,   162,    -1,    -1,    -1,    -1,    -1,    -1,
2826       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    61,
2827       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2828       -1,    -1,    -1,    -1,    -1,    -1,    -1,    79,    80,    81,
2829       82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
2830       92,    93,    94,    95,    96,    97,    98,    99,   100,     3,
2831        4,    -1,    -1,     7,   106,    -1,   108,   109,   110,   111,
2832      112,    -1,   114,   115,   116,    -1,    -1,    -1,    -1,    -1,
2833       -1,    -1,    26,    27,    28,    -1,    -1,    -1,    -1,    -1,
2834       -1,    -1,    -1,    -1,    38,    39,    -1,   139,   140,   141,
2835      142,   143,   144,   145,   146,   147,   148,   149,   150,   151,
2836       -1,    -1,    -1,    -1,    -1,    -1,    -1,    61,   160,    -1,
2837       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2838       -1,    -1,    -1,    -1,    -1,    79,    80,    81,    82,    83,
2839       84,    85,    86,    87,    88,    89,    90,    91,    92,    93,
2840       94,    95,    96,    97,    98,    99,   100,    -1,    -1,    -1,
2841       -1,    -1,   106,    -1,   108,   109,   110,   111,   112,    -1,
2842      114,   115,   116,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2843       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2844       -1,    -1,    -1,    -1,    -1,   139,   140,   141,   142,   143,
2845      144,   145,   146,   147,   148,   149,   150,   151,    -1,    -1,
2846       -1,    -1,    -1,    -1,     5,     6,   160,     8,     9,    10,
2847       11,    12,    13,    14,    15,    16,    17,    18,    19,    -1,
2848       21,    22,    -1,    24,    -1,    -1,    -1,    -1,    -1,    -1,
2849       -1,    -1,    -1,    -1,    -1,    -1,    37,    -1,    -1,    -1,
2850       -1,    -1,    -1,    -1,    -1,     5,     6,    48,     8,     9,
2851       10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
2852       -1,    21,    22,    -1,    24,     5,     6,    -1,     8,     9,
2853       10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
2854       -1,    21,    22,    -1,    24,    -1,    -1,    -1,    48,    -1,
2855       -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,    -1,    -1,
2856       -1,    -1,    -1,    -1,    -1,    -1,     5,     6,    48,     8,
2857        9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
2858       19,    -1,    21,    22,    -1,    24,    -1,    -1,    -1,    -1,
2859       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,    -1,
2860       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    48,
2861       -1,    -1,    -1,   154,    -1,    -1,   157,    -1,    -1,   160,
2862       -1,   162,     5,     6,    -1,     8,     9,    10,    11,    12,
2863       13,    14,    15,    16,    17,    18,    19,    -1,    21,    22,
2864       -1,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2865       -1,    -1,    -1,    -1,   154,    -1,    -1,   157,    -1,   159,
2866      160,    -1,   162,    -1,    -1,    48,    -1,    -1,    -1,    -1,
2867       -1,    -1,    -1,    -1,   154,    -1,    -1,   157,    -1,    -1,
2868      160,    -1,   162,     5,     6,    -1,     8,     9,    10,    11,
2869       12,    13,    14,    15,    16,    17,    18,    19,    -1,    21,
2870       22,    -1,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2871       -1,    -1,    -1,    -1,    -1,   154,    -1,    -1,   157,    -1,
2872       -1,   160,    -1,   162,     5,     6,    48,     8,     9,    10,
2873       11,    12,    13,    14,    15,    16,    17,    18,    19,    -1,
2874       21,    22,    -1,    24,     5,     6,    -1,     8,     9,    10,
2875       11,    12,    13,    14,    15,    16,    17,    18,    19,    -1,
2876       21,    22,    -1,    24,    -1,    -1,    -1,    48,    -1,    -1,
2877       -1,   154,    -1,    -1,   157,    -1,    -1,   160,    -1,   162,
2878       -1,    -1,    -1,    -1,    -1,     5,     6,    48,     8,     9,
2879       10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
2880       -1,    21,    22,    -1,    24,    -1,    -1,    -1,    -1,    -1,
2881       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2882       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    48,    -1,
2883       -1,    -1,   154,    -1,    -1,   157,    -1,    -1,   160,    -1,
2884      162,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2885       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2886       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2887       -1,    -1,    -1,   154,    -1,    -1,   157,    -1,    -1,   160,
2888       -1,   162,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2889       -1,    -1,    -1,   154,    -1,    -1,   157,    -1,    -1,   160,
2890       -1,   162,    -1,    -1,    -1,    -1,    35,    -1,    -1,    -1,
2891       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2892       49,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2893       59,    60,    -1,    -1,   154,    -1,    -1,   157,    -1,    -1,
2894      160,    -1,   162,    72,    73,    74,    75,    76,    77,    78,
2895       79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
2896       89,    90,    91,    92,    93,    94,    95,    96,    97,    98,
2897       99,   100,   101,   102,   103,    -1,    -1,   106,   107,   108,
2898      109,   110,   111,   112,   113,   114,   115,   116,   117,   118,
2899       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2900       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2901      139,   140,   141,   142,   143,   144,   145,   146,   147,   148,
2902      149,   150,   151
2903 };
2904
2905 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2906    symbol of state STATE-NUM.  */
2907 static const yytype_uint8 yystos[] =
2908 {
2909        0,   200,   201,   202,     0,    25,    31,    41,    42,    43,
2910       44,    45,    46,    47,    62,   181,   219,   221,   223,   230,
2911       22,    24,    51,    58,    62,   180,   212,   223,   224,    61,
2912       64,    65,    66,    67,    68,    69,    70,   182,   217,    23,
2913      231,   232,    30,   163,   220,   231,    52,    53,    54,    71,
2914      209,   152,    61,    20,    45,    47,    50,   181,   152,    45,
2915       47,   222,    24,   207,     4,     5,     6,     8,     9,    10,
2916       11,    12,    13,    14,    15,    16,    17,    18,    19,    21,
2917       48,   154,   157,   160,   162,   167,   189,   190,   191,   192,
2918      193,   212,   227,    29,   162,   218,   180,   236,   152,   152,
2919      152,   152,   157,   210,   207,   189,    32,    33,   199,   199,
2920      199,   199,   217,     4,     4,     4,   162,     8,   163,   193,
2921      194,   212,   155,   164,    35,    49,    59,    60,    72,    73,
2922       74,    75,    76,    77,    78,    79,    80,    81,    82,    83,
2923       84,    85,    86,    87,    88,    89,    90,    91,    92,    93,
2924       94,    95,    96,    97,    98,    99,   100,   101,   102,   103,
2925      106,   107,   108,   109,   110,   111,   112,   113,   114,   115,
2926      116,   117,   118,   139,   140,   141,   142,   143,   144,   145,
2927      146,   147,   148,   149,   150,   151,   169,   170,   171,   174,
2928      175,   233,   234,   240,   241,   243,   244,    24,    55,    56,
2929      208,     4,    24,    24,   211,   191,   191,   191,     9,    10,
2930       11,    12,    13,    14,    15,    16,    17,    18,    19,   176,
2931      177,   179,   191,   196,   158,   158,   163,   194,   153,   163,
2932      155,    37,   194,   195,   191,   229,    59,     8,   229,     9,
2933       21,    10,    11,    12,    13,    14,    15,    16,    17,   176,
2934      177,   178,   182,   119,   120,   121,   122,   123,   124,   125,
2935      126,   127,   128,   172,    27,    28,   125,   126,   127,   128,
2936      129,   130,   131,   132,   133,   134,   135,   136,   137,   138,
2937      173,   191,   191,   229,   191,   191,   237,   229,   229,   229,
2938      229,   229,   229,   229,   191,   191,   191,   229,   229,   182,
2939      104,   105,   153,   159,   205,   206,   204,    27,    28,     3,
2940        4,   168,     4,     7,    26,    38,    39,    99,   100,   106,
2941      108,   114,   115,   116,   157,   160,   162,   165,   169,   170,
2942      171,   174,   175,   197,   227,   203,   193,   193,   161,   163,
2943      193,    37,   191,   214,   215,   216,   153,   156,     3,     4,
2944        7,    26,    27,    28,    38,    39,    61,   160,   197,   226,
2945      227,   228,   228,   228,   228,   189,   191,   191,   153,   184,
2946      153,   184,   228,   157,   153,   153,   153,   153,   153,   153,
2947      153,   153,   228,   228,   228,   153,    36,   189,   191,   229,
2948       24,   153,   187,   187,   187,   172,   173,   155,   155,   155,
2949      155,   155,   159,   196,   198,   162,   198,   163,   198,    24,
2950      155,   155,   155,   155,   155,   187,   159,   161,   161,   212,
2951      213,   153,   156,    37,    63,   225,   198,   153,   153,   228,
2952      228,   228,    15,    57,    15,   153,   242,   228,   157,   229,
2953      191,   229,   229,   229,   191,   191,   153,   153,   153,   229,
2954      191,   228,   228,   153,    34,    57,   185,   188,   155,   155,
2955      196,   196,   196,   196,   196,   153,   159,   163,   193,   198,
2956      161,   163,   196,   196,   196,   196,   196,    37,   214,   185,
2957      186,    24,   161,    21,    21,   155,   153,   153,   228,     4,
2958      228,   229,   238,   153,   228,   153,   153,   153,   228,   228,
2959      228,   155,   191,    24,     4,   187,   196,   196,   242,   153,
2960      153,   153,   153,   196,   161,   163,   153,   153,   153,   153,
2961       36,    57,   183,   153,   228,   228,   238,   239,   228,   228,
2962      153,   184,   184,   153,   228,   153,   229,   229,   229,   239,
2963      228,   153,   153,   156,   196,   196,   196,   196,   161,   196,
2964      196,   196,   196,   191,     4,    24,   153,   157,   156,   229,
2965      159,   228,   156,   196,   196,   153,   156,   153,   153,   156,
2966      156,   156,   156,   156,    21,   159,   178,   235,    36,   159,
2967      156,   156,   196,   196,   196,   228,   226,   159,   178,    21,
2968      156,   156,   156,   153,   226,   228,    21,   153,   233,   228,
2969       21,    21,   228,   228
2970 };
2971
2972 #define yyerrok         (yyerrstatus = 0)
2973 #define yyclearin       (yychar = YYEMPTY)
2974 #define YYEMPTY         (-2)
2975 #define YYEOF           0
2976
2977 #define YYACCEPT        goto yyacceptlab
2978 #define YYABORT         goto yyabortlab
2979 #define YYERROR         goto yyerrorlab
2980
2981
2982 /* Like YYERROR except do call yyerror.  This remains here temporarily
2983    to ease the transition to the new meaning of YYERROR, for GCC.
2984    Once GCC version 2 has supplanted version 1, this can go.  */
2985
2986 #define YYFAIL          goto yyerrlab
2987
2988 #define YYRECOVERING()  (!!yyerrstatus)
2989
2990 #define YYBACKUP(Token, Value)                                  \
2991 do                                                              \
2992   if (yychar == YYEMPTY && yylen == 1)                          \
2993     {                                                           \
2994       yychar = (Token);                                         \
2995       yylval = (Value);                                         \
2996       yytoken = YYTRANSLATE (yychar);                           \
2997       YYPOPSTACK (1);                                           \
2998       goto yybackup;                                            \
2999     }                                                           \
3000   else                                                          \
3001     {                                                           \
3002       yyerror (YY_("syntax error: cannot back up")); \
3003       YYERROR;                                                  \
3004     }                                                           \
3005 while (YYID (0))
3006
3007
3008 #define YYTERROR        1
3009 #define YYERRCODE       256
3010
3011
3012 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3013    If N is 0, then set CURRENT to the empty location which ends
3014    the previous symbol: RHS[0] (always defined).  */
3015
3016 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
3017 #ifndef YYLLOC_DEFAULT
3018 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
3019     do                                                                  \
3020       if (YYID (N))                                                    \
3021         {                                                               \
3022           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
3023           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
3024           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
3025           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
3026         }                                                               \
3027       else                                                              \
3028         {                                                               \
3029           (Current).first_line   = (Current).last_line   =              \
3030             YYRHSLOC (Rhs, 0).last_line;                                \
3031           (Current).first_column = (Current).last_column =              \
3032             YYRHSLOC (Rhs, 0).last_column;                              \
3033         }                                                               \
3034     while (YYID (0))
3035 #endif
3036
3037
3038 /* YY_LOCATION_PRINT -- Print the location on the stream.
3039    This macro was not mandated originally: define only if we know
3040    we won't break user code: when these are the locations we know.  */
3041
3042 #ifndef YY_LOCATION_PRINT
3043 # if YYLTYPE_IS_TRIVIAL
3044 #  define YY_LOCATION_PRINT(File, Loc)                  \
3045      fprintf (File, "%d.%d-%d.%d",                      \
3046               (Loc).first_line, (Loc).first_column,     \
3047               (Loc).last_line,  (Loc).last_column)
3048 # else
3049 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3050 # endif
3051 #endif
3052
3053
3054 /* YYLEX -- calling `yylex' with the right arguments.  */
3055
3056 #ifdef YYLEX_PARAM
3057 # define YYLEX yylex (YYLEX_PARAM)
3058 #else
3059 # define YYLEX yylex ()
3060 #endif
3061
3062 /* Enable debugging if requested.  */
3063 #if YYDEBUG
3064
3065 # ifndef YYFPRINTF
3066 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3067 #  define YYFPRINTF fprintf
3068 # endif
3069
3070 # define YYDPRINTF(Args)                        \
3071 do {                                            \
3072   if (yydebug)                                  \
3073     YYFPRINTF Args;                             \
3074 } while (YYID (0))
3075
3076 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
3077 do {                                                                      \
3078   if (yydebug)                                                            \
3079     {                                                                     \
3080       YYFPRINTF (stderr, "%s ", Title);                                   \
3081       yy_symbol_print (stderr,                                            \
3082                   Type, Value); \
3083       YYFPRINTF (stderr, "\n");                                           \
3084     }                                                                     \
3085 } while (YYID (0))
3086
3087
3088 /*--------------------------------.
3089 | Print this symbol on YYOUTPUT.  |
3090 `--------------------------------*/
3091
3092 /*ARGSUSED*/
3093 #if (defined __STDC__ || defined __C99__FUNC__ \
3094      || defined __cplusplus || defined _MSC_VER)
3095 static void
3096 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3097 #else
3098 static void
3099 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
3100     FILE *yyoutput;
3101     int yytype;
3102     YYSTYPE const * const yyvaluep;
3103 #endif
3104 {
3105   if (!yyvaluep)
3106     return;
3107 # ifdef YYPRINT
3108   if (yytype < YYNTOKENS)
3109     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3110 # else
3111   YYUSE (yyoutput);
3112 # endif
3113   switch (yytype)
3114     {
3115       default:
3116         break;
3117     }
3118 }
3119
3120
3121 /*--------------------------------.
3122 | Print this symbol on YYOUTPUT.  |
3123 `--------------------------------*/
3124
3125 #if (defined __STDC__ || defined __C99__FUNC__ \
3126      || defined __cplusplus || defined _MSC_VER)
3127 static void
3128 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3129 #else
3130 static void
3131 yy_symbol_print (yyoutput, yytype, yyvaluep)
3132     FILE *yyoutput;
3133     int yytype;
3134     YYSTYPE const * const yyvaluep;
3135 #endif
3136 {
3137   if (yytype < YYNTOKENS)
3138     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3139   else
3140     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3141
3142   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3143   YYFPRINTF (yyoutput, ")");
3144 }
3145
3146 /*------------------------------------------------------------------.
3147 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
3148 | TOP (included).                                                   |
3149 `------------------------------------------------------------------*/
3150
3151 #if (defined __STDC__ || defined __C99__FUNC__ \
3152      || defined __cplusplus || defined _MSC_VER)
3153 static void
3154 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
3155 #else
3156 static void
3157 yy_stack_print (bottom, top)
3158     yytype_int16 *bottom;
3159     yytype_int16 *top;
3160 #endif
3161 {
3162   YYFPRINTF (stderr, "Stack now");
3163   for (; bottom <= top; ++bottom)
3164     YYFPRINTF (stderr, " %d", *bottom);
3165   YYFPRINTF (stderr, "\n");
3166 }
3167
3168 # define YY_STACK_PRINT(Bottom, Top)                            \
3169 do {                                                            \
3170   if (yydebug)                                                  \
3171     yy_stack_print ((Bottom), (Top));                           \
3172 } while (YYID (0))
3173
3174
3175 /*------------------------------------------------.
3176 | Report that the YYRULE is going to be reduced.  |
3177 `------------------------------------------------*/
3178
3179 #if (defined __STDC__ || defined __C99__FUNC__ \
3180      || defined __cplusplus || defined _MSC_VER)
3181 static void
3182 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
3183 #else
3184 static void
3185 yy_reduce_print (yyvsp, yyrule)
3186     YYSTYPE *yyvsp;
3187     int yyrule;
3188 #endif
3189 {
3190   int yynrhs = yyr2[yyrule];
3191   int yyi;
3192   unsigned long int yylno = yyrline[yyrule];
3193   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3194              yyrule - 1, yylno);
3195   /* The symbols being reduced.  */
3196   for (yyi = 0; yyi < yynrhs; yyi++)
3197     {
3198       fprintf (stderr, "   $%d = ", yyi + 1);
3199       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3200                        &(yyvsp[(yyi + 1) - (yynrhs)])
3201                                        );
3202       fprintf (stderr, "\n");
3203     }
3204 }
3205
3206 # define YY_REDUCE_PRINT(Rule)          \
3207 do {                                    \
3208   if (yydebug)                          \
3209     yy_reduce_print (yyvsp, Rule); \
3210 } while (YYID (0))
3211
3212 /* Nonzero means print parse trace.  It is left uninitialized so that
3213    multiple parsers can coexist.  */
3214 int yydebug;
3215 #else /* !YYDEBUG */
3216 # define YYDPRINTF(Args)
3217 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3218 # define YY_STACK_PRINT(Bottom, Top)
3219 # define YY_REDUCE_PRINT(Rule)
3220 #endif /* !YYDEBUG */
3221
3222
3223 /* YYINITDEPTH -- initial size of the parser's stacks.  */
3224 #ifndef YYINITDEPTH
3225 # define YYINITDEPTH 200
3226 #endif
3227
3228 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3229    if the built-in stack extension method is used).
3230
3231    Do not make this value too large; the results are undefined if
3232    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3233    evaluated with infinite-precision integer arithmetic.  */
3234
3235 #ifndef YYMAXDEPTH
3236 # define YYMAXDEPTH 10000
3237 #endif
3238
3239 \f
3240
3241 #if YYERROR_VERBOSE
3242
3243 # ifndef yystrlen
3244 #  if defined __GLIBC__ && defined _STRING_H
3245 #   define yystrlen strlen
3246 #  else
3247 /* Return the length of YYSTR.  */
3248 #if (defined __STDC__ || defined __C99__FUNC__ \
3249      || defined __cplusplus || defined _MSC_VER)
3250 static YYSIZE_T
3251 yystrlen (const char *yystr)
3252 #else
3253 static YYSIZE_T
3254 yystrlen (yystr)
3255     const char *yystr;
3256 #endif
3257 {
3258   YYSIZE_T yylen;
3259   for (yylen = 0; yystr[yylen]; yylen++)
3260     continue;
3261   return yylen;
3262 }
3263 #  endif
3264 # endif
3265
3266 # ifndef yystpcpy
3267 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3268 #   define yystpcpy stpcpy
3269 #  else
3270 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3271    YYDEST.  */
3272 #if (defined __STDC__ || defined __C99__FUNC__ \
3273      || defined __cplusplus || defined _MSC_VER)
3274 static char *
3275 yystpcpy (char *yydest, const char *yysrc)
3276 #else
3277 static char *
3278 yystpcpy (yydest, yysrc)
3279     char *yydest;
3280     const char *yysrc;
3281 #endif
3282 {
3283   char *yyd = yydest;
3284   const char *yys = yysrc;
3285
3286   while ((*yyd++ = *yys++) != '\0')
3287     continue;
3288
3289   return yyd - 1;
3290 }
3291 #  endif
3292 # endif
3293
3294 # ifndef yytnamerr
3295 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3296    quotes and backslashes, so that it's suitable for yyerror.  The
3297    heuristic is that double-quoting is unnecessary unless the string
3298    contains an apostrophe, a comma, or backslash (other than
3299    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
3300    null, do not copy; instead, return the length of what the result
3301    would have been.  */
3302 static YYSIZE_T
3303 yytnamerr (char *yyres, const char *yystr)
3304 {
3305   if (*yystr == '"')
3306     {
3307       YYSIZE_T yyn = 0;
3308       char const *yyp = yystr;
3309
3310       for (;;)
3311         switch (*++yyp)
3312           {
3313           case '\'':
3314           case ',':
3315             goto do_not_strip_quotes;
3316
3317           case '\\':
3318             if (*++yyp != '\\')
3319               goto do_not_strip_quotes;
3320             /* Fall through.  */
3321           default:
3322             if (yyres)
3323               yyres[yyn] = *yyp;
3324             yyn++;
3325             break;
3326
3327           case '"':
3328             if (yyres)
3329               yyres[yyn] = '\0';
3330             return yyn;
3331           }
3332     do_not_strip_quotes: ;
3333     }
3334
3335   if (! yyres)
3336     return yystrlen (yystr);
3337
3338   return yystpcpy (yyres, yystr) - yyres;
3339 }
3340 # endif
3341
3342 /* Copy into YYRESULT an error message about the unexpected token
3343    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
3344    including the terminating null byte.  If YYRESULT is null, do not
3345    copy anything; just return the number of bytes that would be
3346    copied.  As a special case, return 0 if an ordinary "syntax error"
3347    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
3348    size calculation.  */
3349 static YYSIZE_T
3350 yysyntax_error (char *yyresult, int yystate, int yychar)
3351 {
3352   int yyn = yypact[yystate];
3353
3354   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3355     return 0;
3356   else
3357     {
3358       int yytype = YYTRANSLATE (yychar);
3359       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3360       YYSIZE_T yysize = yysize0;
3361       YYSIZE_T yysize1;
3362       int yysize_overflow = 0;
3363       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3364       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3365       int yyx;
3366
3367 # if 0
3368       /* This is so xgettext sees the translatable formats that are
3369          constructed on the fly.  */
3370       YY_("syntax error, unexpected %s");
3371       YY_("syntax error, unexpected %s, expecting %s");
3372       YY_("syntax error, unexpected %s, expecting %s or %s");
3373       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3374       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3375 # endif
3376       char *yyfmt;
3377       char const *yyf;
3378       static char const yyunexpected[] = "syntax error, unexpected %s";
3379       static char const yyexpecting[] = ", expecting %s";
3380       static char const yyor[] = " or %s";
3381       char yyformat[sizeof yyunexpected
3382                     + sizeof yyexpecting - 1
3383                     + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3384                        * (sizeof yyor - 1))];
3385       char const *yyprefix = yyexpecting;
3386
3387       /* Start YYX at -YYN if negative to avoid negative indexes in
3388          YYCHECK.  */
3389       int yyxbegin = yyn < 0 ? -yyn : 0;
3390
3391       /* Stay within bounds of both yycheck and yytname.  */
3392       int yychecklim = YYLAST - yyn + 1;
3393       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3394       int yycount = 1;
3395
3396       yyarg[0] = yytname[yytype];
3397       yyfmt = yystpcpy (yyformat, yyunexpected);
3398
3399       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3400         if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3401           {
3402             if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3403               {
3404                 yycount = 1;
3405                 yysize = yysize0;
3406                 yyformat[sizeof yyunexpected - 1] = '\0';
3407                 break;
3408               }
3409             yyarg[yycount++] = yytname[yyx];
3410             yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3411             yysize_overflow |= (yysize1 < yysize);
3412             yysize = yysize1;
3413             yyfmt = yystpcpy (yyfmt, yyprefix);
3414             yyprefix = yyor;
3415           }
3416
3417       yyf = YY_(yyformat);
3418       yysize1 = yysize + yystrlen (yyf);
3419       yysize_overflow |= (yysize1 < yysize);
3420       yysize = yysize1;
3421
3422       if (yysize_overflow)
3423         return YYSIZE_MAXIMUM;
3424
3425       if (yyresult)
3426         {
3427           /* Avoid sprintf, as that infringes on the user's name space.
3428              Don't have undefined behavior even if the translation
3429              produced a string with the wrong number of "%s"s.  */
3430           char *yyp = yyresult;
3431           int yyi = 0;
3432           while ((*yyp = *yyf) != '\0')
3433             {
3434               if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3435                 {
3436                   yyp += yytnamerr (yyp, yyarg[yyi++]);
3437                   yyf += 2;
3438                 }
3439               else
3440                 {
3441                   yyp++;
3442                   yyf++;
3443                 }
3444             }
3445         }
3446       return yysize;
3447     }
3448 }
3449 #endif /* YYERROR_VERBOSE */
3450 \f
3451
3452 /*-----------------------------------------------.
3453 | Release the memory associated to this symbol.  |
3454 `-----------------------------------------------*/
3455
3456 /*ARGSUSED*/
3457 #if (defined __STDC__ || defined __C99__FUNC__ \
3458      || defined __cplusplus || defined _MSC_VER)
3459 static void
3460 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3461 #else
3462 static void
3463 yydestruct (yymsg, yytype, yyvaluep)
3464     const char *yymsg;
3465     int yytype;
3466     YYSTYPE *yyvaluep;
3467 #endif
3468 {
3469   YYUSE (yyvaluep);
3470
3471   if (!yymsg)
3472     yymsg = "Deleting";
3473   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3474
3475   switch (yytype)
3476     {
3477
3478       default:
3479         break;
3480     }
3481 }
3482 \f
3483
3484 /* Prevent warnings from -Wmissing-prototypes.  */
3485
3486 #ifdef YYPARSE_PARAM
3487 #if defined __STDC__ || defined __cplusplus
3488 int yyparse (void *YYPARSE_PARAM);
3489 #else
3490 int yyparse ();
3491 #endif
3492 #else /* ! YYPARSE_PARAM */
3493 #if defined __STDC__ || defined __cplusplus
3494 int yyparse (void);
3495 #else
3496 int yyparse ();
3497 #endif
3498 #endif /* ! YYPARSE_PARAM */
3499
3500
3501
3502 /* The look-ahead symbol.  */
3503 int yychar;
3504
3505 /* The semantic value of the look-ahead symbol.  */
3506 YYSTYPE yylval;
3507
3508 /* Number of syntax errors so far.  */
3509 int yynerrs;
3510
3511
3512
3513 /*----------.
3514 | yyparse.  |
3515 `----------*/
3516
3517 #ifdef YYPARSE_PARAM
3518 #if (defined __STDC__ || defined __C99__FUNC__ \
3519      || defined __cplusplus || defined _MSC_VER)
3520 int
3521 yyparse (void *YYPARSE_PARAM)
3522 #else
3523 int
3524 yyparse (YYPARSE_PARAM)
3525     void *YYPARSE_PARAM;
3526 #endif
3527 #else /* ! YYPARSE_PARAM */
3528 #if (defined __STDC__ || defined __C99__FUNC__ \
3529      || defined __cplusplus || defined _MSC_VER)
3530 int
3531 yyparse (void)
3532 #else
3533 int
3534 yyparse ()
3535
3536 #endif
3537 #endif
3538 {
3539   
3540   int yystate;
3541   int yyn;
3542   int yyresult;
3543   /* Number of tokens to shift before error messages enabled.  */
3544   int yyerrstatus;
3545   /* Look-ahead token as an internal (translated) token number.  */
3546   int yytoken = 0;
3547 #if YYERROR_VERBOSE
3548   /* Buffer for error messages, and its allocated size.  */
3549   char yymsgbuf[128];
3550   char *yymsg = yymsgbuf;
3551   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3552 #endif
3553
3554   /* Three stacks and their tools:
3555      `yyss': related to states,
3556      `yyvs': related to semantic values,
3557      `yyls': related to locations.
3558
3559      Refer to the stacks thru separate pointers, to allow yyoverflow
3560      to reallocate them elsewhere.  */
3561
3562   /* The state stack.  */
3563   yytype_int16 yyssa[YYINITDEPTH];
3564   yytype_int16 *yyss = yyssa;
3565   yytype_int16 *yyssp;
3566
3567   /* The semantic value stack.  */
3568   YYSTYPE yyvsa[YYINITDEPTH];
3569   YYSTYPE *yyvs = yyvsa;
3570   YYSTYPE *yyvsp;
3571
3572
3573
3574 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
3575
3576   YYSIZE_T yystacksize = YYINITDEPTH;
3577
3578   /* The variables used to return semantic value and location from the
3579      action routines.  */
3580   YYSTYPE yyval;
3581
3582
3583   /* The number of symbols on the RHS of the reduced rule.
3584      Keep to zero when no symbol should be popped.  */
3585   int yylen = 0;
3586
3587   YYDPRINTF ((stderr, "Starting parse\n"));
3588
3589   yystate = 0;
3590   yyerrstatus = 0;
3591   yynerrs = 0;
3592   yychar = YYEMPTY;             /* Cause a token to be read.  */
3593
3594   /* Initialize stack pointers.
3595      Waste one element of value and location stack
3596      so that they stay on the same level as the state stack.
3597      The wasted elements are never initialized.  */
3598
3599   yyssp = yyss;
3600   yyvsp = yyvs;
3601
3602   goto yysetstate;
3603
3604 /*------------------------------------------------------------.
3605 | yynewstate -- Push a new state, which is found in yystate.  |
3606 `------------------------------------------------------------*/
3607  yynewstate:
3608   /* In all cases, when you get here, the value and location stacks
3609      have just been pushed.  So pushing a state here evens the stacks.  */
3610   yyssp++;
3611
3612  yysetstate:
3613   *yyssp = yystate;
3614
3615   if (yyss + yystacksize - 1 <= yyssp)
3616     {
3617       /* Get the current used size of the three stacks, in elements.  */
3618       YYSIZE_T yysize = yyssp - yyss + 1;
3619
3620 #ifdef yyoverflow
3621       {
3622         /* Give user a chance to reallocate the stack.  Use copies of
3623            these so that the &'s don't force the real ones into
3624            memory.  */
3625         YYSTYPE *yyvs1 = yyvs;
3626         yytype_int16 *yyss1 = yyss;
3627
3628
3629         /* Each stack pointer address is followed by the size of the
3630            data in use in that stack, in bytes.  This used to be a
3631            conditional around just the two extra args, but that might
3632            be undefined if yyoverflow is a macro.  */
3633         yyoverflow (YY_("memory exhausted"),
3634                     &yyss1, yysize * sizeof (*yyssp),
3635                     &yyvs1, yysize * sizeof (*yyvsp),
3636
3637                     &yystacksize);
3638
3639         yyss = yyss1;
3640         yyvs = yyvs1;
3641       }
3642 #else /* no yyoverflow */
3643 # ifndef YYSTACK_RELOCATE
3644       goto yyexhaustedlab;
3645 # else
3646       /* Extend the stack our own way.  */
3647       if (YYMAXDEPTH <= yystacksize)
3648         goto yyexhaustedlab;
3649       yystacksize *= 2;
3650       if (YYMAXDEPTH < yystacksize)
3651         yystacksize = YYMAXDEPTH;
3652
3653       {
3654         yytype_int16 *yyss1 = yyss;
3655         union yyalloc *yyptr =
3656           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3657         if (! yyptr)
3658           goto yyexhaustedlab;
3659         YYSTACK_RELOCATE (yyss);
3660         YYSTACK_RELOCATE (yyvs);
3661
3662 #  undef YYSTACK_RELOCATE
3663         if (yyss1 != yyssa)
3664           YYSTACK_FREE (yyss1);
3665       }
3666 # endif
3667 #endif /* no yyoverflow */
3668
3669       yyssp = yyss + yysize - 1;
3670       yyvsp = yyvs + yysize - 1;
3671
3672
3673       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3674                   (unsigned long int) yystacksize));
3675
3676       if (yyss + yystacksize - 1 <= yyssp)
3677         YYABORT;
3678     }
3679
3680   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
3681
3682   goto yybackup;
3683
3684 /*-----------.
3685 | yybackup.  |
3686 `-----------*/
3687 yybackup:
3688
3689   /* Do appropriate processing given the current state.  Read a
3690      look-ahead token if we need one and don't already have one.  */
3691
3692   /* First try to decide what to do without reference to look-ahead token.  */
3693   yyn = yypact[yystate];
3694   if (yyn == YYPACT_NINF)
3695     goto yydefault;
3696
3697   /* Not known => get a look-ahead token if don't already have one.  */
3698
3699   /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
3700   if (yychar == YYEMPTY)
3701     {
3702       YYDPRINTF ((stderr, "Reading a token: "));
3703       yychar = YYLEX;
3704     }
3705
3706   if (yychar <= YYEOF)
3707     {
3708       yychar = yytoken = YYEOF;
3709       YYDPRINTF ((stderr, "Now at end of input.\n"));
3710     }
3711   else
3712     {
3713       yytoken = YYTRANSLATE (yychar);
3714       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
3715     }
3716
3717   /* If the proper action on seeing token YYTOKEN is to reduce or to
3718      detect an error, take that action.  */
3719   yyn += yytoken;
3720   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
3721     goto yydefault;
3722   yyn = yytable[yyn];
3723   if (yyn <= 0)
3724     {
3725       if (yyn == 0 || yyn == YYTABLE_NINF)
3726         goto yyerrlab;
3727       yyn = -yyn;
3728       goto yyreduce;
3729     }
3730
3731   if (yyn == YYFINAL)
3732     YYACCEPT;
3733
3734   /* Count tokens shifted since error; after three, turn off error
3735      status.  */
3736   if (yyerrstatus)
3737     yyerrstatus--;
3738
3739   /* Shift the look-ahead token.  */
3740   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3741
3742   /* Discard the shifted token unless it is eof.  */
3743   if (yychar != YYEOF)
3744     yychar = YYEMPTY;
3745
3746   yystate = yyn;
3747   *++yyvsp = yylval;
3748
3749   goto yynewstate;
3750
3751
3752 /*-----------------------------------------------------------.
3753 | yydefault -- do the default action for the current state.  |
3754 `-----------------------------------------------------------*/
3755 yydefault:
3756   yyn = yydefact[yystate];
3757   if (yyn == 0)
3758     goto yyerrlab;
3759   goto yyreduce;
3760
3761
3762 /*-----------------------------.
3763 | yyreduce -- Do a reduction.  |
3764 `-----------------------------*/
3765 yyreduce:
3766   /* yyn is the number of a rule to reduce with.  */
3767   yylen = yyr2[yyn];
3768
3769   /* If YYLEN is nonzero, implement the default value of the action:
3770      `$$ = $1'.
3771
3772      Otherwise, the following line sets YYVAL to garbage.
3773      This behavior is undocumented and Bison
3774      users should not rely upon it.  Assigning to YYVAL
3775      unconditionally makes the parser a bit smaller, and it avoids a
3776      GCC warning that YYVAL may be used uninitialized.  */
3777   yyval = yyvsp[1-yylen];
3778
3779
3780   YY_REDUCE_PRINT (yyn);
3781   switch (yyn)
3782     {
3783         case 3:
3784 #line 1480 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3785     {
3786     if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX)     // Outside of my range!
3787       error("Value too large for type");
3788     (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
3789   ;}
3790     break;
3791
3792   case 5:
3793 #line 1489 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3794     {
3795     if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX)     // Outside of my range!
3796       error("Value too large for type");
3797     (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
3798   ;}
3799     break;
3800
3801   case 26:
3802 #line 1511 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3803     { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3804     break;
3805
3806   case 27:
3807 #line 1511 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3808     { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3809     break;
3810
3811   case 28:
3812 #line 1512 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3813     { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3814     break;
3815
3816   case 29:
3817 #line 1512 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3818     { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3819     break;
3820
3821   case 30:
3822 #line 1513 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3823     { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3824     break;
3825
3826   case 31:
3827 #line 1513 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3828     { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3829     break;
3830
3831   case 32:
3832 #line 1514 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3833     { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3834     break;
3835
3836   case 33:
3837 #line 1514 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3838     { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3839     break;
3840
3841   case 34:
3842 #line 1515 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3843     { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3844     break;
3845
3846   case 35:
3847 #line 1515 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3848     { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3849     break;
3850
3851   case 36:
3852 #line 1519 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3853     { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3854     break;
3855
3856   case 37:
3857 #line 1519 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3858     { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3859     break;
3860
3861   case 38:
3862 #line 1520 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3863     { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3864     break;
3865
3866   case 39:
3867 #line 1520 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3868     { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3869     break;
3870
3871   case 40:
3872 #line 1521 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3873     { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3874     break;
3875
3876   case 41:
3877 #line 1521 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3878     { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3879     break;
3880
3881   case 42:
3882 #line 1522 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3883     { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3884     break;
3885
3886   case 43:
3887 #line 1522 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3888     { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3889     break;
3890
3891   case 44:
3892 #line 1523 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3893     { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3894     break;
3895
3896   case 45:
3897 #line 1523 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3898     { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3899     break;
3900
3901   case 46:
3902 #line 1524 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3903     { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3904     break;
3905
3906   case 47:
3907 #line 1524 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3908     { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3909     break;
3910
3911   case 48:
3912 #line 1525 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3913     { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3914     break;
3915
3916   case 49:
3917 #line 1525 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3918     { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3919     break;
3920
3921   case 50:
3922 #line 1526 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3923     { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3924     break;
3925
3926   case 51:
3927 #line 1527 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3928     { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3929     break;
3930
3931   case 81:
3932 #line 1558 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3933     {
3934     (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
3935   ;}
3936     break;
3937
3938   case 82:
3939 #line 1561 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3940     {
3941     (yyval.StrVal) = 0;
3942   ;}
3943     break;
3944
3945   case 83:
3946 #line 1566 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3947     { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3948     break;
3949
3950   case 84:
3951 #line 1567 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3952     { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3953     break;
3954
3955   case 85:
3956 #line 1568 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3957     { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3958     break;
3959
3960   case 86:
3961 #line 1569 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3962     { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3963     break;
3964
3965   case 87:
3966 #line 1570 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3967     { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3968     break;
3969
3970   case 88:
3971 #line 1571 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3972     { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3973     break;
3974
3975   case 89:
3976 #line 1572 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3977     { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3978     break;
3979
3980   case 90:
3981 #line 1573 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3982     { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3983     break;
3984
3985   case 91:
3986 #line 1577 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3987     { (yyval.UIntVal) = CallingConv::C; ;}
3988     break;
3989
3990   case 92:
3991 #line 1578 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3992     { (yyval.UIntVal) = CallingConv::C; ;}
3993     break;
3994
3995   case 93:
3996 #line 1579 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3997     { (yyval.UIntVal) = CallingConv::C; ;}
3998     break;
3999
4000   case 94:
4001 #line 1580 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4002     { (yyval.UIntVal) = CallingConv::Fast; ;}
4003     break;
4004
4005   case 95:
4006 #line 1581 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4007     { (yyval.UIntVal) = CallingConv::Cold; ;}
4008     break;
4009
4010   case 96:
4011 #line 1582 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4012     { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
4013     break;
4014
4015   case 97:
4016 #line 1583 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4017     { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
4018     break;
4019
4020   case 98:
4021 #line 1584 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4022     {
4023     if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
4024       error("Calling conv too large");
4025     (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4026   ;}
4027     break;
4028
4029   case 99:
4030 #line 1594 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4031     { (yyval.UIntVal) = 0; ;}
4032     break;
4033
4034   case 100:
4035 #line 1595 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4036     {
4037     (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4038     if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4039       error("Alignment must be a power of two");
4040   ;}
4041     break;
4042
4043   case 101:
4044 #line 1603 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4045     { (yyval.UIntVal) = 0; ;}
4046     break;
4047
4048   case 102:
4049 #line 1604 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4050     {
4051     (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4052     if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4053       error("Alignment must be a power of two");
4054   ;}
4055     break;
4056
4057   case 103:
4058 #line 1612 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4059     {
4060     for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
4061       if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
4062         error("Invalid character in section name");
4063     (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
4064   ;}
4065     break;
4066
4067   case 104:
4068 #line 1621 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4069     { (yyval.StrVal) = 0; ;}
4070     break;
4071
4072   case 105:
4073 #line 1622 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4074     { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
4075     break;
4076
4077   case 106:
4078 #line 1629 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4079     {;}
4080     break;
4081
4082   case 107:
4083 #line 1630 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4084     {;}
4085     break;
4086
4087   case 108:
4088 #line 1634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4089     {
4090     CurGV->setSection((yyvsp[(1) - (1)].StrVal));
4091     free((yyvsp[(1) - (1)].StrVal));
4092   ;}
4093     break;
4094
4095   case 109:
4096 #line 1638 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4097     {
4098     if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
4099       error("Alignment must be a power of two");
4100     CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
4101     
4102   ;}
4103     break;
4104
4105   case 111:
4106 #line 1655 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4107     { 
4108     (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T); 
4109     (yyval.TypeVal).S = Signless;
4110   ;}
4111     break;
4112
4113   case 113:
4114 #line 1663 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4115     { 
4116     (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T); 
4117     (yyval.TypeVal).S = Signless;
4118   ;}
4119     break;
4120
4121   case 114:
4122 #line 1670 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4123     {
4124     if (!UpRefs.empty())
4125       error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).T)->getDescription());
4126     (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4127   ;}
4128     break;
4129
4130   case 127:
4131 #line 1684 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4132     { 
4133     (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4134     (yyval.TypeVal).S = (yyvsp[(1) - (1)].PrimType).S;
4135   ;}
4136     break;
4137
4138   case 128:
4139 #line 1688 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4140     {
4141     (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4142     (yyval.TypeVal).S = Signless;
4143   ;}
4144     break;
4145
4146   case 129:
4147 #line 1692 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4148     {            // Named types are also simple types...
4149     const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
4150     (yyval.TypeVal).T = new PATypeHolder(tmp);
4151     (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4152   ;}
4153     break;
4154
4155   case 130:
4156 #line 1697 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4157     {                   // Type UpReference
4158     if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) 
4159       error("Value out of range");
4160     OpaqueType *OT = OpaqueType::get();        // Use temporary placeholder
4161     UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT));  // Add to vector...
4162     (yyval.TypeVal).T = new PATypeHolder(OT);
4163     (yyval.TypeVal).S = Signless;
4164     UR_OUT("New Upreference!\n");
4165   ;}
4166     break;
4167
4168   case 131:
4169 #line 1706 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4170     {           // Function derived type?
4171     std::vector<const Type*> Params;
4172     for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
4173            E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
4174       Params.push_back(I->T->get());
4175       delete I->T;
4176     }
4177     bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4178     if (isVarArg) Params.pop_back();
4179
4180     (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
4181                            FunctionType::get((yyvsp[(1) - (4)].TypeVal).T->get(),Params,isVarArg)));
4182     (yyval.TypeVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4183     delete (yyvsp[(1) - (4)].TypeVal).T;    // Delete the return type handle
4184     delete (yyvsp[(3) - (4)].TypeList);      // Delete the argument list
4185   ;}
4186     break;
4187
4188   case 132:
4189 #line 1722 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4190     {          // Sized array type?
4191     (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).T->get(), 
4192                                                         (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4193     (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4194     delete (yyvsp[(4) - (5)].TypeVal).T;
4195   ;}
4196     break;
4197
4198   case 133:
4199 #line 1728 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4200     {          // Packed array type?
4201      const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).T->get();
4202      if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
4203         error("Unsigned result not equal to signed result");
4204      if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4205         error("Elements of a PackedType must be integer or floating point");
4206      if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
4207        error("PackedType length should be a power of 2");
4208      (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy, 
4209                                           (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4210      (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4211      delete (yyvsp[(4) - (5)].TypeVal).T;
4212   ;}
4213     break;
4214
4215   case 134:
4216 #line 1741 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4217     {                        // Structure type?
4218     std::vector<const Type*> Elements;
4219     for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4220            E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
4221       Elements.push_back(I->T->get());
4222     (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4223     (yyval.TypeVal).S = Signless;
4224     delete (yyvsp[(2) - (3)].TypeList);
4225   ;}
4226     break;
4227
4228   case 135:
4229 #line 1750 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4230     {                                  // Empty structure type?
4231     (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4232     (yyval.TypeVal).S = Signless;
4233   ;}
4234     break;
4235
4236   case 136:
4237 #line 1754 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4238     {                // Packed Structure type?
4239     std::vector<const Type*> Elements;
4240     for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4241            E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
4242       Elements.push_back(I->T->get());
4243       delete I->T;
4244     }
4245     (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4246     (yyval.TypeVal).S = Signless;
4247     delete (yyvsp[(3) - (5)].TypeList);
4248   ;}
4249     break;
4250
4251   case 137:
4252 #line 1765 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4253     {                          // Empty packed structure type?
4254     (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4255     (yyval.TypeVal).S = Signless;
4256   ;}
4257     break;
4258
4259   case 138:
4260 #line 1769 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4261     {                             // Pointer type?
4262     if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::LabelTy)
4263       error("Cannot form a pointer to a basic block");
4264     (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).T->get())));
4265     (yyval.TypeVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4266     delete (yyvsp[(1) - (2)].TypeVal).T;
4267   ;}
4268     break;
4269
4270   case 139:
4271 #line 1782 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4272     {
4273     (yyval.TypeList) = new std::list<PATypeInfo>();
4274     (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal)); 
4275   ;}
4276     break;
4277
4278   case 140:
4279 #line 1786 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4280     {
4281     ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
4282   ;}
4283     break;
4284
4285   case 142:
4286 #line 1794 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4287     {
4288     PATypeInfo VoidTI;
4289     VoidTI.T = new PATypeHolder(Type::VoidTy);
4290     VoidTI.S = Signless;
4291     ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
4292   ;}
4293     break;
4294
4295   case 143:
4296 #line 1800 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4297     {
4298     (yyval.TypeList) = new std::list<PATypeInfo>();
4299     PATypeInfo VoidTI;
4300     VoidTI.T = new PATypeHolder(Type::VoidTy);
4301     VoidTI.S = Signless;
4302     (yyval.TypeList)->push_back(VoidTI);
4303   ;}
4304     break;
4305
4306   case 144:
4307 #line 1807 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4308     {
4309     (yyval.TypeList) = new std::list<PATypeInfo>();
4310   ;}
4311     break;
4312
4313   case 145:
4314 #line 1819 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4315     { // Nonempty unsized arr
4316     const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).T->get());
4317     if (ATy == 0)
4318       error("Cannot make array constant with type: '" + 
4319             (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4320     const Type *ETy = ATy->getElementType();
4321     int NumElements = ATy->getNumElements();
4322
4323     // Verify that we have the correct size...
4324     if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4325       error("Type mismatch: constant sized array initialized with " +
4326             utostr((yyvsp[(3) - (4)].ConstVector)->size()) +  " arguments, but has size of " + 
4327             itostr(NumElements) + "");
4328
4329     // Verify all elements are correct type!
4330     std::vector<Constant*> Elems;
4331     for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4332       Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4333       const Type* ValTy = C->getType();
4334       if (ETy != ValTy)
4335         error("Element #" + utostr(i) + " is not of type '" + 
4336               ETy->getDescription() +"' as required!\nIt is of type '"+
4337               ValTy->getDescription() + "'");
4338       Elems.push_back(C);
4339     }
4340     (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4341     (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4342     delete (yyvsp[(1) - (4)].TypeVal).T; 
4343     delete (yyvsp[(3) - (4)].ConstVector);
4344   ;}
4345     break;
4346
4347   case 146:
4348 #line 1849 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4349     {
4350     const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
4351     if (ATy == 0)
4352       error("Cannot make array constant with type: '" + 
4353             (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4354     int NumElements = ATy->getNumElements();
4355     if (NumElements != -1 && NumElements != 0) 
4356       error("Type mismatch: constant sized array initialized with 0"
4357             " arguments, but has size of " + itostr(NumElements) +"");
4358     (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4359     (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4360     delete (yyvsp[(1) - (3)].TypeVal).T;
4361   ;}
4362     break;
4363
4364   case 147:
4365 #line 1862 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4366     {
4367     const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
4368     if (ATy == 0)
4369       error("Cannot make array constant with type: '" + 
4370             (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4371     int NumElements = ATy->getNumElements();
4372     const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4373     if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4374       error("String arrays require type i8, not '" + ETy->getDescription() + 
4375             "'");
4376     char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4377     if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
4378       error("Can't build string constant of size " + 
4379             itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " + 
4380             itostr(NumElements) + "");
4381     std::vector<Constant*> Vals;
4382     for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
4383       Vals.push_back(ConstantInt::get(ETy, *C));
4384     free((yyvsp[(3) - (3)].StrVal));
4385     (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4386     (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4387     delete (yyvsp[(1) - (3)].TypeVal).T;
4388   ;}
4389     break;
4390
4391   case 148:
4392 #line 1885 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4393     { // Nonempty unsized arr
4394     const PackedType *PTy = dyn_cast<PackedType>((yyvsp[(1) - (4)].TypeVal).T->get());
4395     if (PTy == 0)
4396       error("Cannot make packed constant with type: '" + 
4397             (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4398     const Type *ETy = PTy->getElementType();
4399     int NumElements = PTy->getNumElements();
4400     // Verify that we have the correct size...
4401     if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
4402       error("Type mismatch: constant sized packed initialized with " +
4403             utostr((yyvsp[(3) - (4)].ConstVector)->size()) +  " arguments, but has size of " + 
4404             itostr(NumElements) + "");
4405     // Verify all elements are correct type!
4406     std::vector<Constant*> Elems;
4407     for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4408       Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4409       const Type* ValTy = C->getType();
4410       if (ETy != ValTy)
4411         error("Element #" + utostr(i) + " is not of type '" + 
4412               ETy->getDescription() +"' as required!\nIt is of type '"+
4413               ValTy->getDescription() + "'");
4414       Elems.push_back(C);
4415     }
4416     (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
4417     (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4418     delete (yyvsp[(1) - (4)].TypeVal).T;
4419     delete (yyvsp[(3) - (4)].ConstVector);
4420   ;}
4421     break;
4422
4423   case 149:
4424 #line 1913 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4425     {
4426     const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).T->get());
4427     if (STy == 0)
4428       error("Cannot make struct constant with type: '" + 
4429             (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4430     if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
4431       error("Illegal number of initializers for structure type");
4432
4433     // Check to ensure that constants are compatible with the type initializer!
4434     std::vector<Constant*> Fields;
4435     for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
4436       Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
4437       if (C->getType() != STy->getElementType(i))
4438         error("Expected type '" + STy->getElementType(i)->getDescription() +
4439               "' for element #" + utostr(i) + " of structure initializer");
4440       Fields.push_back(C);
4441     }
4442     (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4443     (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4444     delete (yyvsp[(1) - (4)].TypeVal).T;
4445     delete (yyvsp[(3) - (4)].ConstVector);
4446   ;}
4447     break;
4448
4449   case 150:
4450 #line 1935 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4451     {
4452     const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).T->get());
4453     if (STy == 0)
4454       error("Cannot make struct constant with type: '" + 
4455               (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
4456     if (STy->getNumContainedTypes() != 0)
4457       error("Illegal number of initializers for structure type");
4458     (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4459     (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4460     delete (yyvsp[(1) - (3)].TypeVal).T;
4461   ;}
4462     break;
4463
4464   case 151:
4465 #line 1946 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4466     {
4467     const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).T->get());
4468     if (STy == 0)
4469       error("Cannot make packed struct constant with type: '" + 
4470             (yyvsp[(1) - (6)].TypeVal).T->get()->getDescription() + "'");
4471     if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
4472       error("Illegal number of initializers for packed structure type");
4473
4474     // Check to ensure that constants are compatible with the type initializer!
4475     std::vector<Constant*> Fields;
4476     for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
4477       Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
4478       if (C->getType() != STy->getElementType(i))
4479         error("Expected type '" + STy->getElementType(i)->getDescription() +
4480               "' for element #" + utostr(i) + " of packed struct initializer");
4481       Fields.push_back(C);
4482     }
4483     (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4484     (yyval.ConstVal).S = (yyvsp[(1) - (6)].TypeVal).S;
4485     delete (yyvsp[(1) - (6)].TypeVal).T; 
4486     delete (yyvsp[(4) - (6)].ConstVector);
4487   ;}
4488     break;
4489
4490   case 152:
4491 #line 1968 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4492     {
4493     const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).T->get());
4494     if (STy == 0)
4495       error("Cannot make packed struct constant with type: '" + 
4496               (yyvsp[(1) - (5)].TypeVal).T->get()->getDescription() + "'");
4497     if (STy->getNumContainedTypes() != 0)
4498       error("Illegal number of initializers for packed structure type");
4499     (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4500     (yyval.ConstVal).S = (yyvsp[(1) - (5)].TypeVal).S;
4501     delete (yyvsp[(1) - (5)].TypeVal).T;
4502   ;}
4503     break;
4504
4505   case 153:
4506 #line 1979 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4507     {
4508     const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
4509     if (PTy == 0)
4510       error("Cannot make null pointer constant with type: '" + 
4511             (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription() + "'");
4512     (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4513     (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4514     delete (yyvsp[(1) - (2)].TypeVal).T;
4515   ;}
4516     break;
4517
4518   case 154:
4519 #line 1988 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4520     {
4521     (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).T->get());
4522     (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4523     delete (yyvsp[(1) - (2)].TypeVal).T;
4524   ;}
4525     break;
4526
4527   case 155:
4528 #line 1993 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4529     {
4530     const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
4531     if (Ty == 0)
4532       error("Global const reference must be a pointer type, not" +
4533             (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription());
4534
4535     // ConstExprs can exist in the body of a function, thus creating
4536     // GlobalValues whenever they refer to a variable.  Because we are in
4537     // the context of a function, getExistingValue will search the functions
4538     // symbol table instead of the module symbol table for the global symbol,
4539     // which throws things all off.  To get around this, we just tell
4540     // getExistingValue that we are at global scope here.
4541     //
4542     Function *SavedCurFn = CurFun.CurrentFunction;
4543     CurFun.CurrentFunction = 0;
4544     Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
4545     CurFun.CurrentFunction = SavedCurFn;
4546
4547     // If this is an initializer for a constant pointer, which is referencing a
4548     // (currently) undefined variable, create a stub now that shall be replaced
4549     // in the future with the right type of variable.
4550     //
4551     if (V == 0) {
4552       assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4553       const PointerType *PT = cast<PointerType>(Ty);
4554
4555       // First check to see if the forward references value is already created!
4556       PerModuleInfo::GlobalRefsType::iterator I =
4557         CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
4558     
4559       if (I != CurModule.GlobalRefs.end()) {
4560         V = I->second;             // Placeholder already exists, use it...
4561         (yyvsp[(2) - (2)].ValIDVal).destroy();
4562       } else {
4563         std::string Name;
4564         if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4565
4566         // Create the forward referenced global.
4567         GlobalValue *GV;
4568         if (const FunctionType *FTy = 
4569                  dyn_cast<FunctionType>(PT->getElementType())) {
4570           GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4571                             CurModule.CurrentModule);
4572         } else {
4573           GV = new GlobalVariable(PT->getElementType(), false,
4574                                   GlobalValue::ExternalLinkage, 0,
4575                                   Name, CurModule.CurrentModule);
4576         }
4577
4578         // Keep track of the fact that we have a forward ref to recycle it
4579         CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
4580         V = GV;
4581       }
4582     }
4583     (yyval.ConstVal).C = cast<GlobalValue>(V);
4584     (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4585     delete (yyvsp[(1) - (2)].TypeVal).T;            // Free the type handle
4586   ;}
4587     break;
4588
4589   case 156:
4590 #line 2051 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4591     {
4592     if ((yyvsp[(1) - (2)].TypeVal).T->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
4593       error("Mismatched types for constant expression");
4594     (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4595     (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4596     delete (yyvsp[(1) - (2)].TypeVal).T;
4597   ;}
4598     break;
4599
4600   case 157:
4601 #line 2058 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4602     {
4603     const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
4604     if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4605       error("Cannot create a null initialized value of this type");
4606     (yyval.ConstVal).C = Constant::getNullValue(Ty);
4607     (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4608     delete (yyvsp[(1) - (2)].TypeVal).T;
4609   ;}
4610     break;
4611
4612   case 158:
4613 #line 2066 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4614     {      // integral constants
4615     const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4616     if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
4617       error("Constant value doesn't fit in type");
4618     (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
4619     (yyval.ConstVal).S = Signed;
4620   ;}
4621     break;
4622
4623   case 159:
4624 #line 2073 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4625     {            // integral constants
4626     const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4627     if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
4628       error("Constant value doesn't fit in type");
4629     (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
4630     (yyval.ConstVal).S = Unsigned;
4631   ;}
4632     break;
4633
4634   case 160:
4635 #line 2080 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4636     {                      // Boolean constants
4637     (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4638     (yyval.ConstVal).S = Unsigned;
4639   ;}
4640     break;
4641
4642   case 161:
4643 #line 2084 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4644     {                     // Boolean constants
4645     (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4646     (yyval.ConstVal).S = Unsigned;
4647   ;}
4648     break;
4649
4650   case 162:
4651 #line 2088 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4652     {                   // Float & Double constants
4653     if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal)))
4654       error("Floating point constant invalid for type");
4655     (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal));
4656     (yyval.ConstVal).S = Signless;
4657   ;}
4658     break;
4659
4660   case 163:
4661 #line 2097 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4662     {
4663     const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
4664     const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).T->get();
4665     Signedness SrcSign = (yyvsp[(3) - (6)].ConstVal).S;
4666     Signedness DstSign = (yyvsp[(5) - (6)].TypeVal).S;
4667     if (!SrcTy->isFirstClassType())
4668       error("cast constant expression from a non-primitive type: '" +
4669             SrcTy->getDescription() + "'");
4670     if (!DstTy->isFirstClassType())
4671       error("cast constant expression to a non-primitive type: '" +
4672             DstTy->getDescription() + "'");
4673     (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign));
4674     (yyval.ConstVal).S = DstSign;
4675     delete (yyvsp[(5) - (6)].TypeVal).T;
4676   ;}
4677     break;
4678
4679   case 164:
4680 #line 2112 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4681     {
4682     const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
4683     if (!isa<PointerType>(Ty))
4684       error("GetElementPtr requires a pointer operand");
4685
4686     std::vector<Value*> VIndices;
4687     std::vector<Constant*> CIndices;
4688     upgradeGEPIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), VIndices, &CIndices);
4689
4690     delete (yyvsp[(4) - (5)].ValueList);
4691     (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, CIndices);
4692     (yyval.ConstVal).S = Signless;
4693   ;}
4694     break;
4695
4696   case 165:
4697 #line 2125 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4698     {
4699     if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
4700         cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
4701       error("Select condition must be bool type");
4702     if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
4703       error("Select operand types must match");
4704     (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4705     (yyval.ConstVal).S = Unsigned;
4706   ;}
4707     break;
4708
4709   case 166:
4710 #line 2134 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4711     {
4712     const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4713     if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4714       error("Binary operator types must match");
4715     // First, make sure we're dealing with the right opcode by upgrading from
4716     // obsolete versions.
4717     Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
4718
4719     // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4720     // To retain backward compatibility with these early compilers, we emit a
4721     // cast to the appropriate integer type automatically if we are in the
4722     // broken case.  See PR424 for more information.
4723     if (!isa<PointerType>(Ty)) {
4724       (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4725     } else {
4726       const Type *IntPtrTy = 0;
4727       switch (CurModule.CurrentModule->getPointerSize()) {
4728       case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4729       case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4730       default: error("invalid pointer binary constant expr");
4731       }
4732       (yyval.ConstVal).C = ConstantExpr::get(Opcode, 
4733              ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
4734              ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
4735       (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4736     }
4737     (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S; 
4738   ;}
4739     break;
4740
4741   case 167:
4742 #line 2162 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4743     {
4744     const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4745     if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4746       error("Logical operator types must match");
4747     if (!Ty->isInteger()) {
4748       if (!isa<PackedType>(Ty) || 
4749           !cast<PackedType>(Ty)->getElementType()->isInteger())
4750         error("Logical operator requires integer operands");
4751     }
4752     Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
4753     (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4754     (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4755   ;}
4756     break;
4757
4758   case 168:
4759 #line 2175 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4760     {
4761     const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4762     if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
4763       error("setcc operand types must match");
4764     unsigned short pred;
4765     Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
4766     (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4767     (yyval.ConstVal).S = Unsigned;
4768   ;}
4769     break;
4770
4771   case 169:
4772 #line 2184 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4773     {
4774     if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType()) 
4775       error("icmp operand types must match");
4776     (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
4777     (yyval.ConstVal).S = Unsigned;
4778   ;}
4779     break;
4780
4781   case 170:
4782 #line 2190 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4783     {
4784     if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType()) 
4785       error("fcmp operand types must match");
4786     (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
4787     (yyval.ConstVal).S = Unsigned;
4788   ;}
4789     break;
4790
4791   case 171:
4792 #line 2196 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4793     {
4794     if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
4795         cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
4796       error("Shift count for shift constant must be unsigned byte");
4797     if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
4798       error("Shift constant expression requires integer operand");
4799     (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(3) - (6)].ConstVal).S), (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4800     (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4801   ;}
4802     break;
4803
4804   case 172:
4805 #line 2205 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4806     {
4807     if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
4808       error("Invalid extractelement operands");
4809     (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4810     (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
4811   ;}
4812     break;
4813
4814   case 173:
4815 #line 2211 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4816     {
4817     if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
4818       error("Invalid insertelement operands");
4819     (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4820     (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
4821   ;}
4822     break;
4823
4824   case 174:
4825 #line 2217 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4826     {
4827     if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
4828       error("Invalid shufflevector operands");
4829     (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4830     (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
4831   ;}
4832     break;
4833
4834   case 175:
4835 #line 2228 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4836     { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
4837     break;
4838
4839   case 176:
4840 #line 2229 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4841     {
4842     (yyval.ConstVector) = new std::vector<ConstInfo>();
4843     (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
4844   ;}
4845     break;
4846
4847   case 177:
4848 #line 2238 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4849     { (yyval.BoolVal) = false; ;}
4850     break;
4851
4852   case 178:
4853 #line 2239 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4854     { (yyval.BoolVal) = true; ;}
4855     break;
4856
4857   case 179:
4858 #line 2251 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4859     {
4860     (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
4861     CurModule.ModuleDone();
4862   ;}
4863     break;
4864
4865   case 180:
4866 #line 2260 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4867     { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
4868     break;
4869
4870   case 181:
4871 #line 2261 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4872     { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
4873     break;
4874
4875   case 182:
4876 #line 2262 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4877     { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
4878     break;
4879
4880   case 183:
4881 #line 2263 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4882     { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
4883     break;
4884
4885   case 184:
4886 #line 2264 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4887     {
4888     (yyval.ModuleVal) = CurModule.CurrentModule;
4889     // Emit an error if there are any unresolved types left.
4890     if (!CurModule.LateResolveTypes.empty()) {
4891       const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4892       if (DID.Type == ValID::NameVal) {
4893         error("Reference to an undefined type: '"+DID.getName() + "'");
4894       } else {
4895         error("Reference to an undefined type: #" + itostr(DID.Num));
4896       }
4897     }
4898   ;}
4899     break;
4900
4901   case 185:
4902 #line 2280 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4903     {
4904     // Eagerly resolve types.  This is not an optimization, this is a
4905     // requirement that is due to the fact that we could have this:
4906     //
4907     // %list = type { %list * }
4908     // %list = type { %list * }    ; repeated type decl
4909     //
4910     // If types are not resolved eagerly, then the two types will not be
4911     // determined to be the same type!
4912     //
4913     const Type* Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
4914     ResolveTypeTo((yyvsp[(2) - (4)].StrVal), Ty);
4915
4916     if (!setTypeName(Ty, (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
4917       // If this is a named type that is not a redefinition, add it to the slot
4918       // table.
4919       CurModule.Types.push_back(Ty);
4920     }
4921     delete (yyvsp[(4) - (4)].TypeVal).T;
4922   ;}
4923     break;
4924
4925   case 186:
4926 #line 2300 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4927     {       // Function prototypes can be in const pool
4928   ;}
4929     break;
4930
4931   case 187:
4932 #line 2302 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4933     {  // Asm blocks can be in the const pool
4934   ;}
4935     break;
4936
4937   case 188:
4938 #line 2304 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4939     {
4940     if ((yyvsp[(5) - (5)].ConstVal).C == 0) 
4941       error("Global value initializer is not a constant");
4942     CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), (yyvsp[(3) - (5)].Linkage), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal).C->getType(), (yyvsp[(5) - (5)].ConstVal).C);
4943   ;}
4944     break;
4945
4946   case 189:
4947 #line 2308 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4948     {
4949     CurGV = 0;
4950   ;}
4951     break;
4952
4953   case 190:
4954 #line 2311 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4955     {
4956     const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
4957     CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4958     delete (yyvsp[(5) - (5)].TypeVal).T;
4959   ;}
4960     break;
4961
4962   case 191:
4963 #line 2315 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4964     {
4965     CurGV = 0;
4966   ;}
4967     break;
4968
4969   case 192:
4970 #line 2318 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4971     {
4972     const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
4973     CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4974     delete (yyvsp[(5) - (5)].TypeVal).T;
4975   ;}
4976     break;
4977
4978   case 193:
4979 #line 2322 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4980     {
4981     CurGV = 0;
4982   ;}
4983     break;
4984
4985   case 194:
4986 #line 2325 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4987     {
4988     const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
4989     CurGV = 
4990       ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4991     delete (yyvsp[(5) - (5)].TypeVal).T;
4992   ;}
4993     break;
4994
4995   case 195:
4996 #line 2330 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4997     {
4998     CurGV = 0;
4999   ;}
5000     break;
5001
5002   case 196:
5003 #line 2333 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5004     { 
5005   ;}
5006     break;
5007
5008   case 197:
5009 #line 2335 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5010     {
5011   ;}
5012     break;
5013
5014   case 198:
5015 #line 2337 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5016     { 
5017   ;}
5018     break;
5019
5020   case 199:
5021 #line 2342 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5022     {
5023     const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5024     char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
5025     std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
5026     free((yyvsp[(1) - (1)].StrVal));
5027
5028     if (AsmSoFar.empty())
5029       CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5030     else
5031       CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
5032   ;}
5033     break;
5034
5035   case 200:
5036 #line 2356 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5037     { (yyval.Endianness) = Module::BigEndian; ;}
5038     break;
5039
5040   case 201:
5041 #line 2357 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5042     { (yyval.Endianness) = Module::LittleEndian; ;}
5043     break;
5044
5045   case 202:
5046 #line 2361 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5047     {
5048     CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
5049   ;}
5050     break;
5051
5052   case 203:
5053 #line 2364 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5054     {
5055     if ((yyvsp[(3) - (3)].UInt64Val) == 32)
5056       CurModule.setPointerSize(Module::Pointer32);
5057     else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
5058       CurModule.setPointerSize(Module::Pointer64);
5059     else
5060       error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
5061   ;}
5062     break;
5063
5064   case 204:
5065 #line 2372 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5066     {
5067     CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
5068     free((yyvsp[(3) - (3)].StrVal));
5069   ;}
5070     break;
5071
5072   case 205:
5073 #line 2376 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5074     {
5075     CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
5076     free((yyvsp[(3) - (3)].StrVal));
5077   ;}
5078     break;
5079
5080   case 207:
5081 #line 2387 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5082     {
5083       CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
5084       free((yyvsp[(3) - (3)].StrVal));
5085   ;}
5086     break;
5087
5088   case 208:
5089 #line 2391 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5090     {
5091     CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
5092     free((yyvsp[(1) - (1)].StrVal));
5093   ;}
5094     break;
5095
5096   case 209:
5097 #line 2395 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5098     { ;}
5099     break;
5100
5101   case 213:
5102 #line 2408 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5103     { (yyval.StrVal) = 0; ;}
5104     break;
5105
5106   case 214:
5107 #line 2412 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5108     {
5109     if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::VoidTy)
5110       error("void typed arguments are invalid");
5111     (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
5112   ;}
5113     break;
5114
5115   case 215:
5116 #line 2420 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5117     {
5118     (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5119     (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
5120     delete (yyvsp[(3) - (3)].ArgVal);
5121   ;}
5122     break;
5123
5124   case 216:
5125 #line 2425 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5126     {
5127     (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5128     (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
5129     delete (yyvsp[(1) - (1)].ArgVal);
5130   ;}
5131     break;
5132
5133   case 217:
5134 #line 2433 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5135     { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
5136     break;
5137
5138   case 218:
5139 #line 2434 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5140     {
5141     (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5142     PATypeInfo VoidTI;
5143     VoidTI.T = new PATypeHolder(Type::VoidTy);
5144     VoidTI.S = Signless;
5145     (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5146   ;}
5147     break;
5148
5149   case 219:
5150 #line 2441 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5151     {
5152     (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5153     PATypeInfo VoidTI;
5154     VoidTI.T = new PATypeHolder(Type::VoidTy);
5155     VoidTI.S = Signless;
5156     (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5157   ;}
5158     break;
5159
5160   case 220:
5161 #line 2448 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5162     { (yyval.ArgList) = 0; ;}
5163     break;
5164
5165   case 221:
5166 #line 2452 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5167     {
5168     UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
5169     std::string FunctionName((yyvsp[(3) - (8)].StrVal));
5170     free((yyvsp[(3) - (8)].StrVal));  // Free strdup'd memory!
5171
5172     const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).T->get();
5173     
5174     if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5175       error("LLVM functions cannot return aggregate types");
5176
5177     std::vector<const Type*> ParamTypeList;
5178
5179     // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5180     // i8*. We check here for those names and override the parameter list
5181     // types to ensure the prototype is correct.
5182     if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5183       ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5184     } else if (FunctionName == "llvm.va_copy") {
5185       ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5186       ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5187     } else if ((yyvsp[(5) - (8)].ArgList)) {   // If there are arguments...
5188       for (std::vector<std::pair<PATypeInfo,char*> >::iterator 
5189            I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
5190         const Type *Ty = I->first.T->get();
5191         ParamTypeList.push_back(Ty);
5192       }
5193     }
5194
5195     bool isVarArg = 
5196       ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5197     if (isVarArg) ParamTypeList.pop_back();
5198
5199     const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
5200     const PointerType *PFT = PointerType::get(FT);
5201     delete (yyvsp[(2) - (8)].TypeVal).T;
5202
5203     ValID ID;
5204     if (!FunctionName.empty()) {
5205       ID = ValID::create((char*)FunctionName.c_str());
5206     } else {
5207       ID = ValID::create((int)CurModule.Values[PFT].size());
5208     }
5209
5210     Function *Fn = 0;
5211     // See if this function was forward referenced.  If so, recycle the object.
5212     if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5213       // Move the function to the end of the list, from whereever it was 
5214       // previously inserted.
5215       Fn = cast<Function>(FWRef);
5216       CurModule.CurrentModule->getFunctionList().remove(Fn);
5217       CurModule.CurrentModule->getFunctionList().push_back(Fn);
5218     } else if (!FunctionName.empty() &&     // Merge with an earlier prototype?
5219                (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5220       // If this is the case, either we need to be a forward decl, or it needs 
5221       // to be.
5222       if (!CurFun.isDeclare && !Fn->isExternal())
5223         error("Redefinition of function '" + FunctionName + "'");
5224       
5225       // Make sure to strip off any argument names so we can't get conflicts.
5226       if (Fn->isExternal())
5227         for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5228              AI != AE; ++AI)
5229           AI->setName("");
5230     } else  {  // Not already defined?
5231       Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5232                         CurModule.CurrentModule);
5233
5234       InsertValue(Fn, CurModule.Values);
5235     }
5236
5237     CurFun.FunctionStart(Fn);
5238
5239     if (CurFun.isDeclare) {
5240       // If we have declaration, always overwrite linkage.  This will allow us 
5241       // to correctly handle cases, when pointer to function is passed as 
5242       // argument to another function.
5243       Fn->setLinkage(CurFun.Linkage);
5244     }
5245     Fn->setCallingConv((yyvsp[(1) - (8)].UIntVal));
5246     Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
5247     if ((yyvsp[(7) - (8)].StrVal)) {
5248       Fn->setSection((yyvsp[(7) - (8)].StrVal));
5249       free((yyvsp[(7) - (8)].StrVal));
5250     }
5251
5252     // Add all of the arguments we parsed to the function...
5253     if ((yyvsp[(5) - (8)].ArgList)) {                     // Is null if empty...
5254       if (isVarArg) {  // Nuke the last entry
5255         assert((yyvsp[(5) - (8)].ArgList)->back().first.T->get() == Type::VoidTy && 
5256                (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
5257         delete (yyvsp[(5) - (8)].ArgList)->back().first.T;
5258         (yyvsp[(5) - (8)].ArgList)->pop_back();  // Delete the last entry
5259       }
5260       Function::arg_iterator ArgIt = Fn->arg_begin();
5261       for (std::vector<std::pair<PATypeInfo,char*> >::iterator 
5262            I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I, ++ArgIt) {
5263         delete I->first.T;                        // Delete the typeholder...
5264         setValueName(ArgIt, I->second);           // Insert arg into symtab...
5265         InsertValue(ArgIt);
5266       }
5267       delete (yyvsp[(5) - (8)].ArgList);                     // We're now done with the argument list
5268     }
5269   ;}
5270     break;
5271
5272   case 224:
5273 #line 2562 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5274     {
5275     (yyval.FunctionVal) = CurFun.CurrentFunction;
5276
5277     // Make sure that we keep track of the linkage type even if there was a
5278     // previous "declare".
5279     (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (3)].Linkage));
5280   ;}
5281     break;
5282
5283   case 227:
5284 #line 2576 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5285     {
5286     (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5287   ;}
5288     break;
5289
5290   case 229:
5291 #line 2582 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5292     { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5293     break;
5294
5295   case 230:
5296 #line 2583 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5297     { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5298     break;
5299
5300   case 231:
5301 #line 2587 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5302     { CurFun.isDeclare = true; ;}
5303     break;
5304
5305   case 232:
5306 #line 2587 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5307     {
5308     (yyval.FunctionVal) = CurFun.CurrentFunction;
5309     CurFun.FunctionDone();
5310     
5311   ;}
5312     break;
5313
5314   case 233:
5315 #line 2599 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5316     { (yyval.BoolVal) = false; ;}
5317     break;
5318
5319   case 234:
5320 #line 2600 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5321     { (yyval.BoolVal) = true; ;}
5322     break;
5323
5324   case 235:
5325 #line 2605 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5326     {    (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
5327     break;
5328
5329   case 236:
5330 #line 2606 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5331     { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
5332     break;
5333
5334   case 237:
5335 #line 2607 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5336     { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
5337     break;
5338
5339   case 238:
5340 #line 2608 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5341     { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
5342     break;
5343
5344   case 239:
5345 #line 2609 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5346     { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5347     break;
5348
5349   case 240:
5350 #line 2610 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5351     { (yyval.ValIDVal) = ValID::createNull(); ;}
5352     break;
5353
5354   case 241:
5355 #line 2611 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5356     { (yyval.ValIDVal) = ValID::createUndef(); ;}
5357     break;
5358
5359   case 242:
5360 #line 2612 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5361     { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5362     break;
5363
5364   case 243:
5365 #line 2613 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5366     { // Nonempty unsized packed vector
5367     const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
5368     int NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); 
5369     PackedType* pt = PackedType::get(ETy, NumElements);
5370     PATypeHolder* PTy = new PATypeHolder(
5371       HandleUpRefs(PackedType::get(ETy, NumElements)));
5372     
5373     // Verify all elements are correct type!
5374     std::vector<Constant*> Elems;
5375     for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5376       Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
5377       const Type *CTy = C->getType();
5378       if (ETy != CTy)
5379         error("Element #" + utostr(i) + " is not of type '" + 
5380               ETy->getDescription() +"' as required!\nIt is of type '" +
5381               CTy->getDescription() + "'");
5382       Elems.push_back(C);
5383     }
5384     (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
5385     delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
5386   ;}
5387     break;
5388
5389   case 244:
5390 #line 2634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5391     {
5392     (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
5393   ;}
5394     break;
5395
5396   case 245:
5397 #line 2637 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5398     {
5399     char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5400     std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5401     End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5402     std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5403     (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5404     free((yyvsp[(3) - (5)].StrVal));
5405     free((yyvsp[(5) - (5)].StrVal));
5406   ;}
5407     break;
5408
5409   case 246:
5410 #line 2652 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5411     {  (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); ;}
5412     break;
5413
5414   case 247:
5415 #line 2653 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5416     {  (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); ;}
5417     break;
5418
5419   case 250:
5420 #line 2666 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5421     { 
5422     const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
5423     (yyval.ValueVal).S = (yyvsp[(1) - (2)].TypeVal).S;
5424     (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal)); 
5425     delete (yyvsp[(1) - (2)].TypeVal).T;
5426   ;}
5427     break;
5428
5429   case 251:
5430 #line 2675 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5431     {
5432     (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5433   ;}
5434     break;
5435
5436   case 252:
5437 #line 2678 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5438     { // Do not allow functions with 0 basic blocks   
5439     (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5440   ;}
5441     break;
5442
5443   case 253:
5444 #line 2687 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5445     {
5446     setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
5447     InsertValue((yyvsp[(3) - (3)].TermInstVal));
5448     (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5449     InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5450     (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5451   ;}
5452     break;
5453
5454   case 254:
5455 #line 2697 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5456     {
5457     if ((yyvsp[(2) - (2)].InstVal).I)
5458       (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
5459     (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
5460   ;}
5461     break;
5462
5463   case 255:
5464 #line 2702 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5465     {
5466     (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5467     // Make sure to move the basic block to the correct location in the
5468     // function, instead of leaving it inserted wherever it was first
5469     // referenced.
5470     Function::BasicBlockListType &BBL = 
5471       CurFun.CurrentFunction->getBasicBlockList();
5472     BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5473   ;}
5474     break;
5475
5476   case 256:
5477 #line 2711 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5478     {
5479     (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
5480     // Make sure to move the basic block to the correct location in the
5481     // function, instead of leaving it inserted wherever it was first
5482     // referenced.
5483     Function::BasicBlockListType &BBL = 
5484       CurFun.CurrentFunction->getBasicBlockList();
5485     BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5486   ;}
5487     break;
5488
5489   case 259:
5490 #line 2725 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5491     {              // Return with a result...
5492     (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
5493   ;}
5494     break;
5495
5496   case 260:
5497 #line 2728 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5498     {                                       // Return with no result...
5499     (yyval.TermInstVal) = new ReturnInst();
5500   ;}
5501     break;
5502
5503   case 261:
5504 #line 2731 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5505     {                         // Unconditional Branch...
5506     BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5507     (yyval.TermInstVal) = new BranchInst(tmpBB);
5508   ;}
5509     break;
5510
5511   case 262:
5512 #line 2735 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5513     {  
5514     BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5515     BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5516     Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5517     (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5518   ;}
5519     break;
5520
5521   case 263:
5522 #line 2741 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5523     {
5524     Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
5525     BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5526     SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5527     (yyval.TermInstVal) = S;
5528     std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5529       E = (yyvsp[(8) - (9)].JumpTable)->end();
5530     for (; I != E; ++I) {
5531       if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5532           S->addCase(CI, I->second);
5533       else
5534         error("Switch case is constant, but not a simple integer");
5535     }
5536     delete (yyvsp[(8) - (9)].JumpTable);
5537   ;}
5538     break;
5539
5540   case 264:
5541 #line 2756 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5542     {
5543     Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
5544     BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
5545     SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5546     (yyval.TermInstVal) = S;
5547   ;}
5548     break;
5549
5550   case 265:
5551 #line 2763 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5552     {
5553     const PointerType *PFTy;
5554     const FunctionType *Ty;
5555
5556     if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).T->get())) ||
5557         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5558       // Pull out the types of all of the arguments...
5559       std::vector<const Type*> ParamTypes;
5560       if ((yyvsp[(6) - (13)].ValueList)) {
5561         for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
5562              I != E; ++I)
5563           ParamTypes.push_back((*I).V->getType());
5564       }
5565       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5566       if (isVarArg) ParamTypes.pop_back();
5567       Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).T->get(), ParamTypes, isVarArg);
5568       PFTy = PointerType::get(Ty);
5569     }
5570     Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal));   // Get the function we're calling...
5571     BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
5572     BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
5573
5574     // Create the call node...
5575     if (!(yyvsp[(6) - (13)].ValueList)) {                                   // Has no arguments?
5576       (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5577     } else {                                     // Has arguments?
5578       // Loop through FunctionType's arguments and ensure they are specified
5579       // correctly!
5580       //
5581       FunctionType::param_iterator I = Ty->param_begin();
5582       FunctionType::param_iterator E = Ty->param_end();
5583       std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
5584
5585       std::vector<Value*> Args;
5586       for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5587         if ((*ArgI).V->getType() != *I)
5588           error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5589                 (*I)->getDescription() + "'");
5590         Args.push_back((*ArgI).V);
5591       }
5592
5593       if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5594         error("Invalid number of parameters detected");
5595
5596       (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5597     }
5598     cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[(2) - (13)].UIntVal));
5599     delete (yyvsp[(3) - (13)].TypeVal).T;
5600     delete (yyvsp[(6) - (13)].ValueList);
5601   ;}
5602     break;
5603
5604   case 266:
5605 #line 2813 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5606     {
5607     (yyval.TermInstVal) = new UnwindInst();
5608   ;}
5609     break;
5610
5611   case 267:
5612 #line 2816 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5613     {
5614     (yyval.TermInstVal) = new UnreachableInst();
5615   ;}
5616     break;
5617
5618   case 268:
5619 #line 2822 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5620     {
5621     (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5622     Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
5623     
5624     if (V == 0)
5625       error("May only switch on a constant pool value");
5626
5627     BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
5628     (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5629   ;}
5630     break;
5631
5632   case 269:
5633 #line 2832 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5634     {
5635     (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5636     Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
5637
5638     if (V == 0)
5639       error("May only switch on a constant pool value");
5640
5641     BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
5642     (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); 
5643   ;}
5644     break;
5645
5646   case 270:
5647 #line 2845 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5648     {
5649     bool omit = false;
5650     if ((yyvsp[(1) - (2)].StrVal))
5651       if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
5652         if (BCI->getSrcTy() == BCI->getDestTy() && 
5653             BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
5654           // This is a useless bit cast causing a name redefinition. It is
5655           // a bit cast from a type to the same type of an operand with the
5656           // same name as the name we would give this instruction. Since this
5657           // instruction results in no code generation, it is safe to omit
5658           // the instruction. This situation can occur because of collapsed
5659           // type planes. For example:
5660           //   %X = add int %Y, %Z
5661           //   %X = cast int %Y to uint
5662           // After upgrade, this looks like:
5663           //   %X = add i32 %Y, %Z
5664           //   %X = bitcast i32 to i32
5665           // The bitcast is clearly useless so we omit it.
5666           omit = true;
5667     if (omit) {
5668       (yyval.InstVal).I = 0;
5669       (yyval.InstVal).S = Signless;
5670     } else {
5671       setValueName((yyvsp[(2) - (2)].InstVal).I, (yyvsp[(1) - (2)].StrVal));
5672       InsertValue((yyvsp[(2) - (2)].InstVal).I);
5673       (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
5674     }
5675   ;}
5676     break;
5677
5678   case 271:
5679 #line 2874 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5680     {    // Used for PHI nodes
5681     (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5682     (yyval.PHIList).S = (yyvsp[(1) - (6)].TypeVal).S;
5683     Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).T->get(), (yyvsp[(3) - (6)].ValIDVal));
5684     BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5685     (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5686     delete (yyvsp[(1) - (6)].TypeVal).T;
5687   ;}
5688     break;
5689
5690   case 272:
5691 #line 2882 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5692     {
5693     (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5694     Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
5695     BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
5696     (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5697   ;}
5698     break;
5699
5700   case 273:
5701 #line 2890 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5702     {    // Used for call statements, and memory insts...
5703     (yyval.ValueList) = new std::vector<ValueInfo>();
5704     (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
5705   ;}
5706     break;
5707
5708   case 274:
5709 #line 2894 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5710     {
5711     (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5712     (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
5713   ;}
5714     break;
5715
5716   case 276:
5717 #line 2902 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5718     { (yyval.ValueList) = 0; ;}
5719     break;
5720
5721   case 277:
5722 #line 2906 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5723     {
5724     (yyval.BoolVal) = true;
5725   ;}
5726     break;
5727
5728   case 278:
5729 #line 2909 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5730     {
5731     (yyval.BoolVal) = false;
5732   ;}
5733     break;
5734
5735   case 279:
5736 #line 2915 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5737     {
5738     const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5739     if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5740       error("Arithmetic operator requires integer, FP, or packed operands");
5741     if (isa<PackedType>(Ty) && 
5742         ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp))
5743       error("Remainder not supported on packed types");
5744     // Upgrade the opcode from obsolete versions before we do anything with it.
5745     Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5746     Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal)); 
5747     Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5748     (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5749     if ((yyval.InstVal).I == 0)
5750       error("binary operator returned null");
5751     (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5752     delete (yyvsp[(2) - (5)].TypeVal).T;
5753   ;}
5754     break;
5755
5756   case 280:
5757 #line 2932 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5758     {
5759     const Type *Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5760     if (!Ty->isInteger()) {
5761       if (!isa<PackedType>(Ty) ||
5762           !cast<PackedType>(Ty)->getElementType()->isInteger())
5763         error("Logical operator requires integral operands");
5764     }
5765     Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5766     Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5767     Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5768     (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5769     if ((yyval.InstVal).I == 0)
5770       error("binary operator returned null");
5771     (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5772     delete (yyvsp[(2) - (5)].TypeVal).T;
5773   ;}
5774     break;
5775
5776   case 281:
5777 #line 2948 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5778     {
5779     const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
5780     if(isa<PackedType>(Ty))
5781       error("PackedTypes currently not supported in setcc instructions");
5782     unsigned short pred;
5783     Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
5784     Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5785     Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
5786     (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5787     if ((yyval.InstVal).I == 0)
5788       error("binary operator returned null");
5789     (yyval.InstVal).S = Unsigned;
5790     delete (yyvsp[(2) - (5)].TypeVal).T;
5791   ;}
5792     break;
5793
5794   case 282:
5795 #line 2962 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5796     {
5797     const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
5798     if (isa<PackedType>(Ty)) 
5799       error("PackedTypes currently not supported in icmp instructions");
5800     else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5801       error("icmp requires integer or pointer typed operands");
5802     Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5803     Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5804     (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
5805     (yyval.InstVal).S = Unsigned;
5806     delete (yyvsp[(3) - (6)].TypeVal).T;
5807   ;}
5808     break;
5809
5810   case 283:
5811 #line 2974 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5812     {
5813     const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
5814     if (isa<PackedType>(Ty))
5815       error("PackedTypes currently not supported in fcmp instructions");
5816     else if (!Ty->isFloatingPoint())
5817       error("fcmp instruction requires floating point operands");
5818     Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5819     Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5820     (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
5821     (yyval.InstVal).S = Unsigned;
5822     delete (yyvsp[(3) - (6)].TypeVal).T;
5823   ;}
5824     break;
5825
5826   case 284:
5827 #line 2986 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5828     {
5829     warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5830     const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
5831     Value *Ones = ConstantInt::getAllOnesValue(Ty);
5832     if (Ones == 0)
5833       error("Expected integral type for not instruction");
5834     (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
5835     if ((yyval.InstVal).I == 0)
5836       error("Could not create a xor instruction");
5837     (yyval.InstVal).S = (yyvsp[(2) - (2)].ValueVal).S
5838   ;}
5839     break;
5840
5841   case 285:
5842 #line 2997 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5843     {
5844     if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
5845         cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
5846       error("Shift amount must be int8");
5847     if (!(yyvsp[(2) - (4)].ValueVal).V->getType()->isInteger())
5848       error("Shift constant expression requires integer operand");
5849     (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[(1) - (4)].OtherOpVal), (yyvsp[(2) - (4)].ValueVal).S), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
5850     (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
5851   ;}
5852     break;
5853
5854   case 286:
5855 #line 3006 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5856     {
5857     const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5858     if (!DstTy->isFirstClassType())
5859       error("cast instruction to a non-primitive type: '" +
5860             DstTy->getDescription() + "'");
5861     (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[(1) - (4)].CastOpVal), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(2) - (4)].ValueVal).S, DstTy, (yyvsp[(4) - (4)].TypeVal).S, true));
5862     (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5863     delete (yyvsp[(4) - (4)].TypeVal).T;
5864   ;}
5865     break;
5866
5867   case 287:
5868 #line 3015 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5869     {
5870     if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
5871         cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
5872       error("select condition must be bool");
5873     if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
5874       error("select value types should match");
5875     (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5876     (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
5877   ;}
5878     break;
5879
5880   case 288:
5881 #line 3024 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5882     {
5883     const Type *Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
5884     NewVarArgs = true;
5885     (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
5886     (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5887     delete (yyvsp[(4) - (4)].TypeVal).T;
5888   ;}
5889     break;
5890
5891   case 289:
5892 #line 3031 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5893     {
5894     const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5895     const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5896     ObsoleteVarArgs = true;
5897     Function* NF = cast<Function>(CurModule.CurrentModule->
5898       getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5899
5900     //b = vaarg a, t -> 
5901     //foo = alloca 1 of t
5902     //bar = vacopy a 
5903     //store bar -> foo
5904     //b = vaarg foo, t
5905     AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5906     CurBB->getInstList().push_back(foo);
5907     CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
5908     CurBB->getInstList().push_back(bar);
5909     CurBB->getInstList().push_back(new StoreInst(bar, foo));
5910     (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5911     (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5912     delete (yyvsp[(4) - (4)].TypeVal).T;
5913   ;}
5914     break;
5915
5916   case 290:
5917 #line 3052 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5918     {
5919     const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5920     const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
5921     ObsoleteVarArgs = true;
5922     Function* NF = cast<Function>(CurModule.CurrentModule->
5923       getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5924
5925     //b = vanext a, t ->
5926     //foo = alloca 1 of t
5927     //bar = vacopy a
5928     //store bar -> foo
5929     //tmp = vaarg foo, t
5930     //b = load foo
5931     AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5932     CurBB->getInstList().push_back(foo);
5933     CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
5934     CurBB->getInstList().push_back(bar);
5935     CurBB->getInstList().push_back(new StoreInst(bar, foo));
5936     Instruction* tmp = new VAArgInst(foo, DstTy);
5937     CurBB->getInstList().push_back(tmp);
5938     (yyval.InstVal).I = new LoadInst(foo);
5939     (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5940     delete (yyvsp[(4) - (4)].TypeVal).T;
5941   ;}
5942     break;
5943
5944   case 291:
5945 #line 3076 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5946     {
5947     if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
5948       error("Invalid extractelement operands");
5949     (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
5950     (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
5951   ;}
5952     break;
5953
5954   case 292:
5955 #line 3082 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5956     {
5957     if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
5958       error("Invalid insertelement operands");
5959     (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5960     (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
5961   ;}
5962     break;
5963
5964   case 293:
5965 #line 3088 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5966     {
5967     if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
5968       error("Invalid shufflevector operands");
5969     (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5970     (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
5971   ;}
5972     break;
5973
5974   case 294:
5975 #line 3094 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5976     {
5977     const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
5978     if (!Ty->isFirstClassType())
5979       error("PHI node operands must be of first class type");
5980     PHINode *PHI = new PHINode(Ty);
5981     PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
5982     while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
5983       if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty) 
5984         error("All elements of a PHI node must be of the same type");
5985       PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
5986       (yyvsp[(2) - (2)].PHIList).P->pop_front();
5987     }
5988     (yyval.InstVal).I = PHI;
5989     (yyval.InstVal).S = (yyvsp[(2) - (2)].PHIList).S;
5990     delete (yyvsp[(2) - (2)].PHIList).P;  // Free the list...
5991   ;}
5992     break;
5993
5994   case 295:
5995 #line 3110 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5996     {
5997
5998     // Handle the short call syntax
5999     const PointerType *PFTy;
6000     const FunctionType *FTy;
6001     if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).T->get())) ||
6002         !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6003       // Pull out the types of all of the arguments...
6004       std::vector<const Type*> ParamTypes;
6005       if ((yyvsp[(6) - (7)].ValueList)) {
6006         for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
6007              I != E; ++I)
6008           ParamTypes.push_back((*I).V->getType());
6009       }
6010
6011       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6012       if (isVarArg) ParamTypes.pop_back();
6013
6014       const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).T->get();
6015       if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6016         error("Functions cannot return aggregate types");
6017
6018       FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
6019       PFTy = PointerType::get(FTy);
6020     }
6021
6022     // First upgrade any intrinsic calls.
6023     std::vector<Value*> Args;
6024     if ((yyvsp[(6) - (7)].ValueList))
6025       for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i) 
6026         Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
6027     Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[(4) - (7)].ValIDVal), Args);
6028
6029     // If we got an upgraded intrinsic
6030     if (Inst) {
6031       (yyval.InstVal).I = Inst;
6032       (yyval.InstVal).S = Signless;
6033     } else {
6034       // Get the function we're calling
6035       Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
6036
6037       // Check the argument values match
6038       if (!(yyvsp[(6) - (7)].ValueList)) {                                   // Has no arguments?
6039         // Make sure no arguments is a good thing!
6040         if (FTy->getNumParams() != 0)
6041           error("No arguments passed to a function that expects arguments");
6042       } else {                                     // Has arguments?
6043         // Loop through FunctionType's arguments and ensure they are specified
6044         // correctly!
6045         //
6046         FunctionType::param_iterator I = FTy->param_begin();
6047         FunctionType::param_iterator E = FTy->param_end();
6048         std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
6049
6050         for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6051           if ((*ArgI).V->getType() != *I)
6052             error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6053                   (*I)->getDescription() + "'");
6054
6055         if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6056           error("Invalid number of parameters detected");
6057       }
6058
6059       // Create the call instruction
6060       CallInst *CI = new CallInst(V, Args);
6061       CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
6062       CI->setCallingConv((yyvsp[(2) - (7)].UIntVal));
6063       (yyval.InstVal).I = CI;
6064       (yyval.InstVal).S = (yyvsp[(3) - (7)].TypeVal).S;
6065     }
6066     delete (yyvsp[(3) - (7)].TypeVal).T;
6067     delete (yyvsp[(6) - (7)].ValueList);
6068   ;}
6069     break;
6070
6071   case 296:
6072 #line 3183 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6073     {
6074     (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
6075   ;}
6076     break;
6077
6078   case 297:
6079 #line 3191 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6080     { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
6081     break;
6082
6083   case 298:
6084 #line 3192 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6085     { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6086     break;
6087
6088   case 299:
6089 #line 3196 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6090     { (yyval.BoolVal) = true; ;}
6091     break;
6092
6093   case 300:
6094 #line 3197 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6095     { (yyval.BoolVal) = false; ;}
6096     break;
6097
6098   case 301:
6099 #line 3201 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6100     {
6101     const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6102     (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6103     (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6104     delete (yyvsp[(2) - (3)].TypeVal).T;
6105   ;}
6106     break;
6107
6108   case 302:
6109 #line 3207 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6110     {
6111     const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6112     (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6113     (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6114     delete (yyvsp[(2) - (6)].TypeVal).T;
6115   ;}
6116     break;
6117
6118   case 303:
6119 #line 3213 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6120     {
6121     const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6122     (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6123     (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6124     delete (yyvsp[(2) - (3)].TypeVal).T;
6125   ;}
6126     break;
6127
6128   case 304:
6129 #line 3219 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6130     {
6131     const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6132     (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6133     (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6134     delete (yyvsp[(2) - (6)].TypeVal).T;
6135   ;}
6136     break;
6137
6138   case 305:
6139 #line 3225 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6140     {
6141     const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
6142     if (!isa<PointerType>(PTy))
6143       error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
6144     (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
6145     (yyval.InstVal).S = Signless;
6146   ;}
6147     break;
6148
6149   case 306:
6150 #line 3232 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6151     {
6152     const Type* Ty = (yyvsp[(3) - (4)].TypeVal).T->get();
6153     (yyval.InstVal).S = (yyvsp[(3) - (4)].TypeVal).S;
6154     if (!isa<PointerType>(Ty))
6155       error("Can't load from nonpointer type: " + Ty->getDescription());
6156     if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6157       error("Can't load from pointer of non-first-class type: " +
6158                      Ty->getDescription());
6159     Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
6160     (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
6161     delete (yyvsp[(3) - (4)].TypeVal).T;
6162   ;}
6163     break;
6164
6165   case 307:
6166 #line 3244 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6167     {
6168     const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).T->get());
6169     if (!PTy)
6170       error("Can't store to a nonpointer type: " + 
6171              (yyvsp[(5) - (6)].TypeVal).T->get()->getDescription());
6172     const Type *ElTy = PTy->getElementType();
6173     if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType())
6174       error("Can't store '" + (yyvsp[(3) - (6)].ValueVal).V->getType()->getDescription() +
6175             "' into space of type '" + ElTy->getDescription() + "'");
6176     Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
6177     (yyval.InstVal).I = new StoreInst((yyvsp[(3) - (6)].ValueVal).V, tmpVal, (yyvsp[(1) - (6)].BoolVal));
6178     (yyval.InstVal).S = Signless;
6179     delete (yyvsp[(5) - (6)].TypeVal).T;
6180   ;}
6181     break;
6182
6183   case 308:
6184 #line 3258 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6185     {
6186     const Type* Ty = (yyvsp[(2) - (4)].TypeVal).T->get();
6187     if (!isa<PointerType>(Ty))
6188       error("getelementptr insn requires pointer operand");
6189
6190     std::vector<Value*> VIndices;
6191     upgradeGEPIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
6192
6193     Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
6194     (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6195     (yyval.InstVal).S = Signless;
6196     delete (yyvsp[(2) - (4)].TypeVal).T;
6197     delete (yyvsp[(4) - (4)].ValueList);
6198   ;}
6199     break;
6200
6201
6202 /* Line 1267 of yacc.c.  */
6203 #line 6204 "UpgradeParser.tab.c"
6204       default: break;
6205     }
6206   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6207
6208   YYPOPSTACK (yylen);
6209   yylen = 0;
6210   YY_STACK_PRINT (yyss, yyssp);
6211
6212   *++yyvsp = yyval;
6213
6214
6215   /* Now `shift' the result of the reduction.  Determine what state
6216      that goes to, based on the state we popped back to and the rule
6217      number reduced by.  */
6218
6219   yyn = yyr1[yyn];
6220
6221   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6222   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
6223     yystate = yytable[yystate];
6224   else
6225     yystate = yydefgoto[yyn - YYNTOKENS];
6226
6227   goto yynewstate;
6228
6229
6230 /*------------------------------------.
6231 | yyerrlab -- here on detecting error |
6232 `------------------------------------*/
6233 yyerrlab:
6234   /* If not already recovering from an error, report this error.  */
6235   if (!yyerrstatus)
6236     {
6237       ++yynerrs;
6238 #if ! YYERROR_VERBOSE
6239       yyerror (YY_("syntax error"));
6240 #else
6241       {
6242         YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6243         if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6244           {
6245             YYSIZE_T yyalloc = 2 * yysize;
6246             if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6247               yyalloc = YYSTACK_ALLOC_MAXIMUM;
6248             if (yymsg != yymsgbuf)
6249               YYSTACK_FREE (yymsg);
6250             yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6251             if (yymsg)
6252               yymsg_alloc = yyalloc;
6253             else
6254               {
6255                 yymsg = yymsgbuf;
6256                 yymsg_alloc = sizeof yymsgbuf;
6257               }
6258           }
6259
6260         if (0 < yysize && yysize <= yymsg_alloc)
6261           {
6262             (void) yysyntax_error (yymsg, yystate, yychar);
6263             yyerror (yymsg);
6264           }
6265         else
6266           {
6267             yyerror (YY_("syntax error"));
6268             if (yysize != 0)
6269               goto yyexhaustedlab;
6270           }
6271       }
6272 #endif
6273     }
6274
6275
6276
6277   if (yyerrstatus == 3)
6278     {
6279       /* If just tried and failed to reuse look-ahead token after an
6280          error, discard it.  */
6281
6282       if (yychar <= YYEOF)
6283         {
6284           /* Return failure if at end of input.  */
6285           if (yychar == YYEOF)
6286             YYABORT;
6287         }
6288       else
6289         {
6290           yydestruct ("Error: discarding",
6291                       yytoken, &yylval);
6292           yychar = YYEMPTY;
6293         }
6294     }
6295
6296   /* Else will try to reuse look-ahead token after shifting the error
6297      token.  */
6298   goto yyerrlab1;
6299
6300
6301 /*---------------------------------------------------.
6302 | yyerrorlab -- error raised explicitly by YYERROR.  |
6303 `---------------------------------------------------*/
6304 yyerrorlab:
6305
6306   /* Pacify compilers like GCC when the user code never invokes
6307      YYERROR and the label yyerrorlab therefore never appears in user
6308      code.  */
6309   if (/*CONSTCOND*/ 0)
6310      goto yyerrorlab;
6311
6312   /* Do not reclaim the symbols of the rule which action triggered
6313      this YYERROR.  */
6314   YYPOPSTACK (yylen);
6315   yylen = 0;
6316   YY_STACK_PRINT (yyss, yyssp);
6317   yystate = *yyssp;
6318   goto yyerrlab1;
6319
6320
6321 /*-------------------------------------------------------------.
6322 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
6323 `-------------------------------------------------------------*/
6324 yyerrlab1:
6325   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
6326
6327   for (;;)
6328     {
6329       yyn = yypact[yystate];
6330       if (yyn != YYPACT_NINF)
6331         {
6332           yyn += YYTERROR;
6333           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6334             {
6335               yyn = yytable[yyn];
6336               if (0 < yyn)
6337                 break;
6338             }
6339         }
6340
6341       /* Pop the current state because it cannot handle the error token.  */
6342       if (yyssp == yyss)
6343         YYABORT;
6344
6345
6346       yydestruct ("Error: popping",
6347                   yystos[yystate], yyvsp);
6348       YYPOPSTACK (1);
6349       yystate = *yyssp;
6350       YY_STACK_PRINT (yyss, yyssp);
6351     }
6352
6353   if (yyn == YYFINAL)
6354     YYACCEPT;
6355
6356   *++yyvsp = yylval;
6357
6358
6359   /* Shift the error token.  */
6360   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6361
6362   yystate = yyn;
6363   goto yynewstate;
6364
6365
6366 /*-------------------------------------.
6367 | yyacceptlab -- YYACCEPT comes here.  |
6368 `-------------------------------------*/
6369 yyacceptlab:
6370   yyresult = 0;
6371   goto yyreturn;
6372
6373 /*-----------------------------------.
6374 | yyabortlab -- YYABORT comes here.  |
6375 `-----------------------------------*/
6376 yyabortlab:
6377   yyresult = 1;
6378   goto yyreturn;
6379
6380 #ifndef yyoverflow
6381 /*-------------------------------------------------.
6382 | yyexhaustedlab -- memory exhaustion comes here.  |
6383 `-------------------------------------------------*/
6384 yyexhaustedlab:
6385   yyerror (YY_("memory exhausted"));
6386   yyresult = 2;
6387   /* Fall through.  */
6388 #endif
6389
6390 yyreturn:
6391   if (yychar != YYEOF && yychar != YYEMPTY)
6392      yydestruct ("Cleanup: discarding lookahead",
6393                  yytoken, &yylval);
6394   /* Do not reclaim the symbols of the rule which action triggered
6395      this YYABORT or YYACCEPT.  */
6396   YYPOPSTACK (yylen);
6397   YY_STACK_PRINT (yyss, yyssp);
6398   while (yyssp != yyss)
6399     {
6400       yydestruct ("Cleanup: popping",
6401                   yystos[*yyssp], yyvsp);
6402       YYPOPSTACK (1);
6403     }
6404 #ifndef yyoverflow
6405   if (yyss != yyssa)
6406     YYSTACK_FREE (yyss);
6407 #endif
6408 #if YYERROR_VERBOSE
6409   if (yymsg != yymsgbuf)
6410     YYSTACK_FREE (yymsg);
6411 #endif
6412   /* Make sure YYID is used.  */
6413   return YYID (yyresult);
6414 }
6415
6416
6417 #line 3274 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6418
6419
6420 int yyerror(const char *ErrorMsg) {
6421   std::string where 
6422     = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6423                   + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6424   std::string errMsg = where + "error: " + std::string(ErrorMsg);
6425   if (yychar != YYEMPTY && yychar != 0)
6426     errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6427               "'.";
6428   std::cerr << "llvm-upgrade: " << errMsg << '\n';
6429   std::cout << "llvm-upgrade: parse failed.\n";
6430   exit(1);
6431 }
6432
6433 void warning(const std::string& ErrorMsg) {
6434   std::string where 
6435     = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6436                   + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6437   std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6438   if (yychar != YYEMPTY && yychar != 0)
6439     errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6440               "'.";
6441   std::cerr << "llvm-upgrade: " << errMsg << '\n';
6442 }
6443
6444 void error(const std::string& ErrorMsg, int LineNo) {
6445   if (LineNo == -1) LineNo = Upgradelineno;
6446   Upgradelineno = LineNo;
6447   yyerror(ErrorMsg.c_str());
6448 }
6449
6450