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