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