blob: c44d6dda0a7b589e343195b994d645959d7fcc58 [file] [log] [blame]
Reid Spencer950bf602007-01-26 08:19:09 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Reid Spencer319a7302007-01-05 17:20:02 +00003/* Skeleton parser for Yacc-like parsing with Bison,
Reid Spencer950bf602007-01-26 08:19:09 +00004 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00005
Reid Spencer319a7302007-01-05 17:20:02 +00006 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.
Reid Spencere7c3c602006-11-30 06:36:44 +000010
Reid Spencer319a7302007-01-05 17:20:02 +000011 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
Reid Spencer950bf602007-01-26 08:19:09 +000018 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
Reid Spencer319a7302007-01-05 17:20:02 +000020
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. */
Reid Spencer950bf602007-01-26 08:19:09 +000037#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
Reid Spencer319a7302007-01-05 17:20:02 +000044
45/* Pure parsers. */
Reid Spencer950bf602007-01-26 08:19:09 +000046#define YYPURE 0
Reid Spencer319a7302007-01-05 17:20:02 +000047
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
Reid Spencer950bf602007-01-26 08:19:09 +000051/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000052#define yyparse Upgradeparse
Reid Spencer319a7302007-01-05 17:20:02 +000053#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000054#define yyerror Upgradeerror
Reid Spencer319a7302007-01-05 17:20:02 +000055#define yylval Upgradelval
56#define yychar Upgradechar
Reid Spencere7c3c602006-11-30 06:36:44 +000057#define yydebug Upgradedebug
58#define yynerrs Upgradenerrs
59
Reid Spencere7c3c602006-11-30 06:36:44 +000060
Reid Spencer319a7302007-01-05 17:20:02 +000061/* 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 {
Reid Spencer950bf602007-01-26 08:19:09 +000067 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,
Reid Spencer319a7302007-01-05 17:20:02 +0000109 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
Reid Spencer950bf602007-01-26 08:19:09 +0000112 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,
Reid Spencerc4d96252007-01-13 00:03:30 +0000122 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,
Reid Spencer950bf602007-01-26 08:19:09 +0000140 UNREACHABLE = 331,
Reid Spencerc4d96252007-01-13 00:03:30 +0000141 UNWIND = 332,
Reid Spencer950bf602007-01-26 08:19:09 +0000142 EXCEPT = 333,
Reid Spencerc4d96252007-01-13 00:03:30 +0000143 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 SETLE = 348,
158 SETGE = 349,
159 SETLT = 350,
160 SETGT = 351,
161 SETEQ = 352,
162 SETNE = 353,
163 ICMP = 354,
164 FCMP = 355,
Reid Spencer950bf602007-01-26 08:19:09 +0000165 MALLOC = 356,
166 ALLOCA = 357,
167 FREE = 358,
168 LOAD = 359,
169 STORE = 360,
170 GETELEMENTPTR = 361,
171 PHI_TOK = 362,
172 SELECT = 363,
173 SHL = 364,
174 SHR = 365,
175 ASHR = 366,
176 LSHR = 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
Reid Spencer319a7302007-01-05 17:20:02 +0000216 };
217#endif
Reid Spencer950bf602007-01-26 08:19:09 +0000218/* 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
Reid Spencer319a7302007-01-05 17:20:02 +0000261#define DLLIMPORT 300
262#define DLLEXPORT 301
263#define EXTERN_WEAK 302
Reid Spencer950bf602007-01-26 08:19:09 +0000264#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
Reid Spencerc4d96252007-01-13 00:03:30 +0000274#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
Reid Spencer950bf602007-01-26 08:19:09 +0000292#define UNREACHABLE 331
Reid Spencerc4d96252007-01-13 00:03:30 +0000293#define UNWIND 332
Reid Spencer950bf602007-01-26 08:19:09 +0000294#define EXCEPT 333
Reid Spencerc4d96252007-01-13 00:03:30 +0000295#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 SETLE 348
310#define SETGE 349
311#define SETLT 350
312#define SETGT 351
313#define SETEQ 352
314#define SETNE 353
315#define ICMP 354
316#define FCMP 355
Reid Spencer950bf602007-01-26 08:19:09 +0000317#define MALLOC 356
318#define ALLOCA 357
319#define FREE 358
320#define LOAD 359
321#define STORE 360
322#define GETELEMENTPTR 361
323#define PHI_TOK 362
324#define SELECT 363
325#define SHL 364
326#define SHR 365
327#define ASHR 366
328#define LSHR 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
Reid Spencer319a7302007-01-05 17:20:02 +0000368
369
370
371
372/* Copy the first part of user declarations. */
Reid Spencer38f682b2007-01-26 20:31:18 +0000373#line 14 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +0000374
375#include "UpgradeInternals.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000376#include "llvm/CallingConv.h"
377#include "llvm/InlineAsm.h"
378#include "llvm/Instructions.h"
379#include "llvm/Module.h"
380#include "llvm/SymbolTable.h"
381#include "llvm/Support/GetElementPtrTypeIterator.h"
382#include "llvm/ADT/STLExtras.h"
383#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000384#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000385#include <iostream>
Reid Spencer950bf602007-01-26 08:19:09 +0000386#include <list>
387#include <utility>
388
389// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
390// relating to upreferences in the input stream.
391//
392//#define DEBUG_UPREFS 1
393#ifdef DEBUG_UPREFS
394#define UR_OUT(X) std::cerr << X
395#else
396#define UR_OUT(X)
397#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000398
Reid Spencere77e35e2006-12-01 20:26:20 +0000399#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000400#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000401#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000402
Reid Spencer950bf602007-01-26 08:19:09 +0000403int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000404int yyparse();
405
Reid Spencer950bf602007-01-26 08:19:09 +0000406int yyerror(const char*);
407static void warning(const std::string& WarningMsg);
408
409namespace llvm {
410
Reid Spencer950bf602007-01-26 08:19:09 +0000411std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000412static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000413
Reid Spencer71d2ec92006-12-31 06:02:26 +0000414// This bool controls whether attributes are ever added to function declarations
415// definitions and calls.
416static bool AddAttributes = false;
417
Reid Spencer950bf602007-01-26 08:19:09 +0000418static Module *ParserResult;
419static bool ObsoleteVarArgs;
420static bool NewVarArgs;
421static BasicBlock *CurBB;
422static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000423
Reid Spencer950bf602007-01-26 08:19:09 +0000424// This contains info used when building the body of a function. It is
425// destroyed when the function is completed.
426//
427typedef std::vector<Value *> ValueList; // Numbered defs
428
429typedef std::pair<std::string,const Type*> RenameMapKey;
430typedef std::map<RenameMapKey,std::string> RenameMapType;
431
432static void
433ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
434 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
435
436static struct PerModuleInfo {
437 Module *CurrentModule;
438 std::map<const Type *, ValueList> Values; // Module level numbered definitions
439 std::map<const Type *,ValueList> LateResolveValues;
440 std::vector<PATypeHolder> Types;
441 std::map<ValID, PATypeHolder> LateResolveTypes;
442 static Module::Endianness Endian;
443 static Module::PointerSize PointerSize;
444 RenameMapType RenameMap;
445
446 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
447 /// how they were referenced and on which line of the input they came from so
448 /// that we can resolve them later and print error messages as appropriate.
449 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
450
451 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
452 // references to global values. Global values may be referenced before they
453 // are defined, and if so, the temporary object that they represent is held
454 // here. This is used for forward references of GlobalValues.
455 //
456 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
457 GlobalRefsType;
458 GlobalRefsType GlobalRefs;
459
460 void ModuleDone() {
461 // If we could not resolve some functions at function compilation time
462 // (calls to functions before they are defined), resolve them now... Types
463 // are resolved when the constant pool has been completely parsed.
464 //
465 ResolveDefinitions(LateResolveValues);
466
467 // Check to make sure that all global value forward references have been
468 // resolved!
469 //
470 if (!GlobalRefs.empty()) {
471 std::string UndefinedReferences = "Unresolved global references exist:\n";
472
473 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
474 I != E; ++I) {
475 UndefinedReferences += " " + I->first.first->getDescription() + " " +
476 I->first.second.getName() + "\n";
477 }
478 error(UndefinedReferences);
479 return;
480 }
481
482 if (CurrentModule->getDataLayout().empty()) {
483 std::string dataLayout;
484 if (Endian != Module::AnyEndianness)
485 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
486 if (PointerSize != Module::AnyPointerSize) {
487 if (!dataLayout.empty())
488 dataLayout += "-";
489 dataLayout.append(PointerSize == Module::Pointer64 ?
490 "p:64:64" : "p:32:32");
491 }
492 CurrentModule->setDataLayout(dataLayout);
493 }
494
495 Values.clear(); // Clear out function local definitions
496 Types.clear();
497 CurrentModule = 0;
498 }
499
500 // GetForwardRefForGlobal - Check to see if there is a forward reference
501 // for this global. If so, remove it from the GlobalRefs map and return it.
502 // If not, just return null.
503 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
504 // Check to see if there is a forward reference to this global variable...
505 // if there is, eliminate it and patch the reference to use the new def'n.
506 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
507 GlobalValue *Ret = 0;
508 if (I != GlobalRefs.end()) {
509 Ret = I->second;
510 GlobalRefs.erase(I);
511 }
512 return Ret;
513 }
514 void setEndianness(Module::Endianness E) { Endian = E; }
515 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
516} CurModule;
517
518Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
519Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
520
521static struct PerFunctionInfo {
522 Function *CurrentFunction; // Pointer to current function being created
523
524 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
525 std::map<const Type*, ValueList> LateResolveValues;
526 bool isDeclare; // Is this function a forward declararation?
527 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
528
529 /// BBForwardRefs - When we see forward references to basic blocks, keep
530 /// track of them here.
531 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
532 std::vector<BasicBlock*> NumberedBlocks;
533 RenameMapType RenameMap;
Reid Spencer950bf602007-01-26 08:19:09 +0000534 unsigned NextBBNum;
535
536 inline PerFunctionInfo() {
537 CurrentFunction = 0;
538 isDeclare = false;
539 Linkage = GlobalValue::ExternalLinkage;
540 }
541
542 inline void FunctionStart(Function *M) {
543 CurrentFunction = M;
544 NextBBNum = 0;
545 }
546
547 void FunctionDone() {
548 NumberedBlocks.clear();
549
550 // Any forward referenced blocks left?
551 if (!BBForwardRefs.empty()) {
552 error("Undefined reference to label " +
553 BBForwardRefs.begin()->first->getName());
554 return;
555 }
556
557 // Resolve all forward references now.
558 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
559
560 Values.clear(); // Clear out function local definitions
561 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000562 CurrentFunction = 0;
563 isDeclare = false;
564 Linkage = GlobalValue::ExternalLinkage;
565 }
566} CurFun; // Info for the current function...
567
568static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
569
570
571//===----------------------------------------------------------------------===//
572// Code to handle definitions of all the types
573//===----------------------------------------------------------------------===//
574
575static int InsertValue(Value *V,
576 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
577 if (V->hasName()) return -1; // Is this a numbered definition?
578
579 // Yes, insert the value into the value table...
580 ValueList &List = ValueTab[V->getType()];
581 List.push_back(V);
582 return List.size()-1;
583}
584
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000585static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000586 switch (D.Type) {
587 case ValID::NumberVal: // Is it a numbered definition?
588 // Module constants occupy the lowest numbered slots...
589 if ((unsigned)D.Num < CurModule.Types.size()) {
590 return CurModule.Types[(unsigned)D.Num];
591 }
592 break;
593 case ValID::NameVal: // Is it a named definition?
594 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
595 D.destroy(); // Free old strdup'd memory...
596 return N;
597 }
598 break;
599 default:
600 error("Internal parser error: Invalid symbol type reference");
601 return 0;
602 }
603
604 // If we reached here, we referenced either a symbol that we don't know about
605 // or an id number that hasn't been read yet. We may be referencing something
606 // forward, so just create an entry to be resolved later and get to it...
607 //
608 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
609
610
611 if (inFunctionScope()) {
612 if (D.Type == ValID::NameVal) {
613 error("Reference to an undefined type: '" + D.getName() + "'");
614 return 0;
615 } else {
616 error("Reference to an undefined type: #" + itostr(D.Num));
617 return 0;
618 }
619 }
620
621 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
622 if (I != CurModule.LateResolveTypes.end())
623 return I->second;
624
625 Type *Typ = OpaqueType::get();
626 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
627 return Typ;
628 }
629
630// getExistingValue - Look up the value specified by the provided type and
631// the provided ValID. If the value exists and has already been defined, return
632// it. Otherwise return null.
633//
634static Value *getExistingValue(const Type *Ty, const ValID &D) {
635 if (isa<FunctionType>(Ty)) {
636 error("Functions are not values and must be referenced as pointers");
637 }
638
639 switch (D.Type) {
640 case ValID::NumberVal: { // Is it a numbered definition?
641 unsigned Num = (unsigned)D.Num;
642
643 // Module constants occupy the lowest numbered slots...
644 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
645 if (VI != CurModule.Values.end()) {
646 if (Num < VI->second.size())
647 return VI->second[Num];
648 Num -= VI->second.size();
649 }
650
651 // Make sure that our type is within bounds
652 VI = CurFun.Values.find(Ty);
653 if (VI == CurFun.Values.end()) return 0;
654
655 // Check that the number is within bounds...
656 if (VI->second.size() <= Num) return 0;
657
658 return VI->second[Num];
659 }
660
661 case ValID::NameVal: { // Is it a named definition?
662 // Get the name out of the ID
663 std::string Name(D.Name);
664 Value* V = 0;
665 RenameMapKey Key = std::make_pair(Name, Ty);
666 if (inFunctionScope()) {
667 // See if the name was renamed
668 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
669 std::string LookupName;
670 if (I != CurFun.RenameMap.end())
671 LookupName = I->second;
672 else
673 LookupName = Name;
674 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
675 V = SymTab.lookup(Ty, LookupName);
676 }
677 if (!V) {
678 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
679 std::string LookupName;
680 if (I != CurModule.RenameMap.end())
681 LookupName = I->second;
682 else
683 LookupName = Name;
684 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
685 }
686 if (V == 0)
687 return 0;
688
689 D.destroy(); // Free old strdup'd memory...
690 return V;
691 }
692
693 // Check to make sure that "Ty" is an integral type, and that our
694 // value will fit into the specified type...
695 case ValID::ConstSIntVal: // Is it a constant pool reference??
696 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
697 error("Signed integral constant '" + itostr(D.ConstPool64) +
698 "' is invalid for type '" + Ty->getDescription() + "'");
699 }
700 return ConstantInt::get(Ty, D.ConstPool64);
701
702 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
703 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
704 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
705 error("Integral constant '" + utostr(D.UConstPool64) +
706 "' is invalid or out of range");
707 else // This is really a signed reference. Transmogrify.
708 return ConstantInt::get(Ty, D.ConstPool64);
709 } else
710 return ConstantInt::get(Ty, D.UConstPool64);
711
712 case ValID::ConstFPVal: // Is it a floating point const pool reference?
713 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
714 error("FP constant invalid for type");
715 return ConstantFP::get(Ty, D.ConstPoolFP);
716
717 case ValID::ConstNullVal: // Is it a null value?
718 if (!isa<PointerType>(Ty))
719 error("Cannot create a a non pointer null");
720 return ConstantPointerNull::get(cast<PointerType>(Ty));
721
722 case ValID::ConstUndefVal: // Is it an undef value?
723 return UndefValue::get(Ty);
724
725 case ValID::ConstZeroVal: // Is it a zero value?
726 return Constant::getNullValue(Ty);
727
728 case ValID::ConstantVal: // Fully resolved constant?
729 if (D.ConstantValue->getType() != Ty)
730 error("Constant expression type different from required type");
731 return D.ConstantValue;
732
733 case ValID::InlineAsmVal: { // Inline asm expression
734 const PointerType *PTy = dyn_cast<PointerType>(Ty);
735 const FunctionType *FTy =
736 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
737 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
738 error("Invalid type for asm constraint string");
739 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
740 D.IAD->HasSideEffects);
741 D.destroy(); // Free InlineAsmDescriptor.
742 return IA;
743 }
744 default:
745 assert(0 && "Unhandled case");
746 return 0;
747 } // End of switch
748
749 assert(0 && "Unhandled case");
750 return 0;
751}
752
753// getVal - This function is identical to getExistingValue, except that if a
754// value is not already defined, it "improvises" by creating a placeholder var
755// that looks and acts just like the requested variable. When the value is
756// defined later, all uses of the placeholder variable are replaced with the
757// real thing.
758//
759static Value *getVal(const Type *Ty, const ValID &ID) {
760 if (Ty == Type::LabelTy)
761 error("Cannot use a basic block here");
762
763 // See if the value has already been defined.
764 Value *V = getExistingValue(Ty, ID);
765 if (V) return V;
766
767 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
768 error("Invalid use of a composite type");
769
770 // If we reached here, we referenced either a symbol that we don't know about
771 // or an id number that hasn't been read yet. We may be referencing something
772 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000773 V = new Argument(Ty);
774
775 // Remember where this forward reference came from. FIXME, shouldn't we try
776 // to recycle these things??
777 CurModule.PlaceHolderInfo.insert(
778 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
779
780 if (inFunctionScope())
781 InsertValue(V, CurFun.LateResolveValues);
782 else
783 InsertValue(V, CurModule.LateResolveValues);
784 return V;
785}
786
787/// getBBVal - This is used for two purposes:
788/// * If isDefinition is true, a new basic block with the specified ID is being
789/// defined.
790/// * If isDefinition is true, this is a reference to a basic block, which may
791/// or may not be a forward reference.
792///
793static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
794 assert(inFunctionScope() && "Can't get basic block at global scope");
795
796 std::string Name;
797 BasicBlock *BB = 0;
798 switch (ID.Type) {
799 default:
800 error("Illegal label reference " + ID.getName());
801 break;
802 case ValID::NumberVal: // Is it a numbered definition?
803 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
804 CurFun.NumberedBlocks.resize(ID.Num+1);
805 BB = CurFun.NumberedBlocks[ID.Num];
806 break;
807 case ValID::NameVal: // Is it a named definition?
808 Name = ID.Name;
809 if (Value *N = CurFun.CurrentFunction->
810 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
811 if (N->getType() != Type::LabelTy)
812 error("Name '" + Name + "' does not refer to a BasicBlock");
813 BB = cast<BasicBlock>(N);
814 }
815 break;
816 }
817
818 // See if the block has already been defined.
819 if (BB) {
820 // If this is the definition of the block, make sure the existing value was
821 // just a forward reference. If it was a forward reference, there will be
822 // an entry for it in the PlaceHolderInfo map.
823 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
824 // The existing value was a definition, not a forward reference.
825 error("Redefinition of label " + ID.getName());
826
827 ID.destroy(); // Free strdup'd memory.
828 return BB;
829 }
830
831 // Otherwise this block has not been seen before.
832 BB = new BasicBlock("", CurFun.CurrentFunction);
833 if (ID.Type == ValID::NameVal) {
834 BB->setName(ID.Name);
835 } else {
836 CurFun.NumberedBlocks[ID.Num] = BB;
837 }
838
839 // If this is not a definition, keep track of it so we can use it as a forward
840 // reference.
841 if (!isDefinition) {
842 // Remember where this forward reference came from.
843 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
844 } else {
845 // The forward declaration could have been inserted anywhere in the
846 // function: insert it into the correct place now.
847 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
848 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
849 }
850 ID.destroy();
851 return BB;
852}
853
854
855//===----------------------------------------------------------------------===//
856// Code to handle forward references in instructions
857//===----------------------------------------------------------------------===//
858//
859// This code handles the late binding needed with statements that reference
860// values not defined yet... for example, a forward branch, or the PHI node for
861// a loop body.
862//
863// This keeps a table (CurFun.LateResolveValues) of all such forward references
864// and back patchs after we are done.
865//
866
867// ResolveDefinitions - If we could not resolve some defs at parsing
868// time (forward branches, phi functions for loops, etc...) resolve the
869// defs now...
870//
871static void
872ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
873 std::map<const Type*,ValueList> *FutureLateResolvers) {
874 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
875 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
876 E = LateResolvers.end(); LRI != E; ++LRI) {
877 ValueList &List = LRI->second;
878 while (!List.empty()) {
879 Value *V = List.back();
880 List.pop_back();
881
882 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
883 CurModule.PlaceHolderInfo.find(V);
884 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
885
886 ValID &DID = PHI->second.first;
887
888 Value *TheRealValue = getExistingValue(LRI->first, DID);
889 if (TheRealValue) {
890 V->replaceAllUsesWith(TheRealValue);
891 delete V;
892 CurModule.PlaceHolderInfo.erase(PHI);
893 } else if (FutureLateResolvers) {
894 // Functions have their unresolved items forwarded to the module late
895 // resolver table
896 InsertValue(V, *FutureLateResolvers);
897 } else {
898 if (DID.Type == ValID::NameVal) {
899 error("Reference to an invalid definition: '" +DID.getName()+
900 "' of type '" + V->getType()->getDescription() + "'",
901 PHI->second.second);
902 return;
903 } else {
904 error("Reference to an invalid definition: #" +
905 itostr(DID.Num) + " of type '" +
906 V->getType()->getDescription() + "'", PHI->second.second);
907 return;
908 }
909 }
910 }
911 }
912
913 LateResolvers.clear();
914}
915
916// ResolveTypeTo - A brand new type was just declared. This means that (if
917// name is not null) things referencing Name can be resolved. Otherwise, things
918// refering to the number can be resolved. Do this now.
919//
920static void ResolveTypeTo(char *Name, const Type *ToTy) {
921 ValID D;
922 if (Name) D = ValID::create(Name);
923 else D = ValID::create((int)CurModule.Types.size());
924
925 std::map<ValID, PATypeHolder>::iterator I =
926 CurModule.LateResolveTypes.find(D);
927 if (I != CurModule.LateResolveTypes.end()) {
928 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
929 CurModule.LateResolveTypes.erase(I);
930 }
931}
932
933static std::string makeNameUnique(const std::string& Name) {
934 static unsigned UniqueNameCounter = 1;
935 std::string Result(Name);
936 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
937 return Result;
938}
939
940// setValueName - Set the specified value to the name given. The name may be
941// null potentially, in which case this is a noop. The string passed in is
942// assumed to be a malloc'd string buffer, and is free'd by this function.
943//
944static void setValueName(Value *V, char *NameStr) {
945 if (NameStr) {
946 std::string Name(NameStr); // Copy string
947 free(NameStr); // Free old string
948
949 if (V->getType() == Type::VoidTy) {
950 error("Can't assign name '" + Name + "' to value with void type");
951 return;
952 }
953
Reid Spencer950bf602007-01-26 08:19:09 +0000954 assert(inFunctionScope() && "Must be in function scope");
955
956 // Search the function's symbol table for an existing value of this name
957 Value* Existing = 0;
958 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
959 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
960 for ( ; PI != PE; ++PI) {
961 SymbolTable::value_const_iterator VI = PI->second.find(Name);
962 if (VI != PI->second.end()) {
963 Existing = VI->second;
964 break;
965 }
966 }
967 if (Existing) {
968 if (Existing->getType() == V->getType()) {
969 // The type of the Existing value and the new one are the same. This
970 // is probably a type plane collapsing error. If the types involved
971 // are both integer, just rename it. Otherwise it
972 // is a redefinition error.
973 if (!Existing->getType()->isInteger()) {
974 error("Redefinition of value named '" + Name + "' in the '" +
975 V->getType()->getDescription() + "' type plane");
976 return;
977 }
978 }
979 // In LLVM 2.0 we don't allow names to be re-used for any values in a
980 // function, regardless of Type. Previously re-use of names was okay as
981 // long as they were distinct types. With type planes collapsing because
982 // of the signedness change and because of PR411, this can no longer be
983 // supported. We must search the entire symbol table for a conflicting
984 // name and make the name unique. No warning is needed as this can't
985 // cause a problem.
986 std::string NewName = makeNameUnique(Name);
987 // We're changing the name but it will probably be used by other
988 // instructions as operands later on. Consequently we have to retain
989 // a mapping of the renaming that we're doing.
990 RenameMapKey Key = std::make_pair(Name,V->getType());
991 CurFun.RenameMap[Key] = NewName;
992 Name = NewName;
993 }
994
995 // Set the name.
996 V->setName(Name);
997 }
998}
999
1000/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1001/// this is a declaration, otherwise it is a definition.
1002static GlobalVariable *
1003ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1004 bool isConstantGlobal, const Type *Ty,
1005 Constant *Initializer) {
1006 if (isa<FunctionType>(Ty))
1007 error("Cannot declare global vars of function type");
1008
1009 const PointerType *PTy = PointerType::get(Ty);
1010
1011 std::string Name;
1012 if (NameStr) {
1013 Name = NameStr; // Copy string
1014 free(NameStr); // Free old string
1015 }
1016
1017 // See if this global value was forward referenced. If so, recycle the
1018 // object.
1019 ValID ID;
1020 if (!Name.empty()) {
1021 ID = ValID::create((char*)Name.c_str());
1022 } else {
1023 ID = ValID::create((int)CurModule.Values[PTy].size());
1024 }
1025
1026 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1027 // Move the global to the end of the list, from whereever it was
1028 // previously inserted.
1029 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1030 CurModule.CurrentModule->getGlobalList().remove(GV);
1031 CurModule.CurrentModule->getGlobalList().push_back(GV);
1032 GV->setInitializer(Initializer);
1033 GV->setLinkage(Linkage);
1034 GV->setConstant(isConstantGlobal);
1035 InsertValue(GV, CurModule.Values);
1036 return GV;
1037 }
1038
1039 // If this global has a name, check to see if there is already a definition
1040 // of this global in the module and emit warnings if there are conflicts.
1041 if (!Name.empty()) {
1042 // The global has a name. See if there's an existing one of the same name.
1043 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1044 // We found an existing global ov the same name. This isn't allowed
1045 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1046 // can at least compile. This can happen because of type planes
1047 // There is alread a global of the same name which means there is a
1048 // conflict. Let's see what we can do about it.
1049 std::string NewName(makeNameUnique(Name));
1050 if (Linkage == GlobalValue::InternalLinkage) {
1051 // The linkage type is internal so just warn about the rename without
1052 // invoking "scarey language" about linkage failures. GVars with
1053 // InternalLinkage can be renamed at will.
1054 warning("Global variable '" + Name + "' was renamed to '"+
1055 NewName + "'");
1056 } else {
1057 // The linkage of this gval is external so we can't reliably rename
1058 // it because it could potentially create a linking problem.
1059 // However, we can't leave the name conflict in the output either or
1060 // it won't assemble with LLVM 2.0. So, all we can do is rename
1061 // this one to something unique and emit a warning about the problem.
1062 warning("Renaming global variable '" + Name + "' to '" + NewName +
1063 "' may cause linkage errors");
1064 }
1065
1066 // Put the renaming in the global rename map
1067 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1068 CurModule.RenameMap[Key] = NewName;
1069
1070 // Rename it
1071 Name = NewName;
1072 }
1073 }
1074
1075 // Otherwise there is no existing GV to use, create one now.
1076 GlobalVariable *GV =
1077 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1078 CurModule.CurrentModule);
1079 InsertValue(GV, CurModule.Values);
1080 return GV;
1081}
1082
1083// setTypeName - Set the specified type to the name given. The name may be
1084// null potentially, in which case this is a noop. The string passed in is
1085// assumed to be a malloc'd string buffer, and is freed by this function.
1086//
1087// This function returns true if the type has already been defined, but is
1088// allowed to be redefined in the specified context. If the name is a new name
1089// for the type plane, it is inserted and false is returned.
1090static bool setTypeName(const Type *T, char *NameStr) {
1091 assert(!inFunctionScope() && "Can't give types function-local names");
1092 if (NameStr == 0) return false;
1093
1094 std::string Name(NameStr); // Copy string
1095 free(NameStr); // Free old string
1096
1097 // We don't allow assigning names to void type
1098 if (T == Type::VoidTy) {
1099 error("Can't assign name '" + Name + "' to the void type");
1100 return false;
1101 }
1102
1103 // Set the type name, checking for conflicts as we do so.
1104 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1105
1106 if (AlreadyExists) { // Inserting a name that is already defined???
1107 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1108 assert(Existing && "Conflict but no matching type?");
1109
1110 // There is only one case where this is allowed: when we are refining an
1111 // opaque type. In this case, Existing will be an opaque type.
1112 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1113 // We ARE replacing an opaque type!
1114 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1115 return true;
1116 }
1117
1118 // Otherwise, this is an attempt to redefine a type. That's okay if
1119 // the redefinition is identical to the original. This will be so if
1120 // Existing and T point to the same Type object. In this one case we
1121 // allow the equivalent redefinition.
1122 if (Existing == T) return true; // Yes, it's equal.
1123
1124 // Any other kind of (non-equivalent) redefinition is an error.
1125 error("Redefinition of type named '" + Name + "' in the '" +
1126 T->getDescription() + "' type plane");
1127 }
1128
1129 return false;
1130}
1131
1132//===----------------------------------------------------------------------===//
1133// Code for handling upreferences in type names...
1134//
1135
1136// TypeContains - Returns true if Ty directly contains E in it.
1137//
1138static bool TypeContains(const Type *Ty, const Type *E) {
1139 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1140 E) != Ty->subtype_end();
1141}
1142
1143namespace {
1144 struct UpRefRecord {
1145 // NestingLevel - The number of nesting levels that need to be popped before
1146 // this type is resolved.
1147 unsigned NestingLevel;
1148
1149 // LastContainedTy - This is the type at the current binding level for the
1150 // type. Every time we reduce the nesting level, this gets updated.
1151 const Type *LastContainedTy;
1152
1153 // UpRefTy - This is the actual opaque type that the upreference is
1154 // represented with.
1155 OpaqueType *UpRefTy;
1156
1157 UpRefRecord(unsigned NL, OpaqueType *URTy)
1158 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1159 };
1160}
1161
1162// UpRefs - A list of the outstanding upreferences that need to be resolved.
1163static std::vector<UpRefRecord> UpRefs;
1164
1165/// HandleUpRefs - Every time we finish a new layer of types, this function is
1166/// called. It loops through the UpRefs vector, which is a list of the
1167/// currently active types. For each type, if the up reference is contained in
1168/// the newly completed type, we decrement the level count. When the level
1169/// count reaches zero, the upreferenced type is the type that is passed in:
1170/// thus we can complete the cycle.
1171///
1172static PATypeHolder HandleUpRefs(const Type *ty) {
1173 // If Ty isn't abstract, or if there are no up-references in it, then there is
1174 // nothing to resolve here.
1175 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1176
1177 PATypeHolder Ty(ty);
1178 UR_OUT("Type '" << Ty->getDescription() <<
1179 "' newly formed. Resolving upreferences.\n" <<
1180 UpRefs.size() << " upreferences active!\n");
1181
1182 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1183 // to zero), we resolve them all together before we resolve them to Ty. At
1184 // the end of the loop, if there is anything to resolve to Ty, it will be in
1185 // this variable.
1186 OpaqueType *TypeToResolve = 0;
1187
1188 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1189 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1190 << UpRefs[i].second->getDescription() << ") = "
1191 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1192 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1193 // Decrement level of upreference
1194 unsigned Level = --UpRefs[i].NestingLevel;
1195 UpRefs[i].LastContainedTy = Ty;
1196 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1197 if (Level == 0) { // Upreference should be resolved!
1198 if (!TypeToResolve) {
1199 TypeToResolve = UpRefs[i].UpRefTy;
1200 } else {
1201 UR_OUT(" * Resolving upreference for "
1202 << UpRefs[i].second->getDescription() << "\n";
1203 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1204 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1205 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1206 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1207 }
1208 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1209 --i; // Do not skip the next element...
1210 }
1211 }
1212 }
1213
1214 if (TypeToResolve) {
1215 UR_OUT(" * Resolving upreference for "
1216 << UpRefs[i].second->getDescription() << "\n";
1217 std::string OldName = TypeToResolve->getDescription());
1218 TypeToResolve->refineAbstractTypeTo(Ty);
1219 }
1220
1221 return Ty;
1222}
1223
1224static inline Instruction::TermOps
1225getTermOp(TermOps op) {
1226 switch (op) {
1227 default : assert(0 && "Invalid OldTermOp");
1228 case RetOp : return Instruction::Ret;
1229 case BrOp : return Instruction::Br;
1230 case SwitchOp : return Instruction::Switch;
1231 case InvokeOp : return Instruction::Invoke;
1232 case UnwindOp : return Instruction::Unwind;
1233 case UnreachableOp: return Instruction::Unreachable;
1234 }
1235}
1236
1237static inline Instruction::BinaryOps
1238getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1239 switch (op) {
1240 default : assert(0 && "Invalid OldBinaryOps");
1241 case SetEQ :
1242 case SetNE :
1243 case SetLE :
1244 case SetGE :
1245 case SetLT :
1246 case SetGT : assert(0 && "Should use getCompareOp");
1247 case AddOp : return Instruction::Add;
1248 case SubOp : return Instruction::Sub;
1249 case MulOp : return Instruction::Mul;
1250 case DivOp : {
1251 // This is an obsolete instruction so we must upgrade it based on the
1252 // types of its operands.
1253 bool isFP = Ty->isFloatingPoint();
1254 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1255 // If its a packed type we want to use the element type
1256 isFP = PTy->getElementType()->isFloatingPoint();
1257 if (isFP)
1258 return Instruction::FDiv;
1259 else if (Sign == Signed)
1260 return Instruction::SDiv;
1261 return Instruction::UDiv;
1262 }
1263 case UDivOp : return Instruction::UDiv;
1264 case SDivOp : return Instruction::SDiv;
1265 case FDivOp : return Instruction::FDiv;
1266 case RemOp : {
1267 // This is an obsolete instruction so we must upgrade it based on the
1268 // types of its operands.
1269 bool isFP = Ty->isFloatingPoint();
1270 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1271 // If its a packed type we want to use the element type
1272 isFP = PTy->getElementType()->isFloatingPoint();
1273 // Select correct opcode
1274 if (isFP)
1275 return Instruction::FRem;
1276 else if (Sign == Signed)
1277 return Instruction::SRem;
1278 return Instruction::URem;
1279 }
1280 case URemOp : return Instruction::URem;
1281 case SRemOp : return Instruction::SRem;
1282 case FRemOp : return Instruction::FRem;
1283 case AndOp : return Instruction::And;
1284 case OrOp : return Instruction::Or;
1285 case XorOp : return Instruction::Xor;
1286 }
1287}
1288
1289static inline Instruction::OtherOps
1290getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1291 Signedness Sign) {
1292 bool isSigned = Sign == Signed;
1293 bool isFP = Ty->isFloatingPoint();
1294 switch (op) {
1295 default : assert(0 && "Invalid OldSetCC");
1296 case SetEQ :
1297 if (isFP) {
1298 predicate = FCmpInst::FCMP_OEQ;
1299 return Instruction::FCmp;
1300 } else {
1301 predicate = ICmpInst::ICMP_EQ;
1302 return Instruction::ICmp;
1303 }
1304 case SetNE :
1305 if (isFP) {
1306 predicate = FCmpInst::FCMP_UNE;
1307 return Instruction::FCmp;
1308 } else {
1309 predicate = ICmpInst::ICMP_NE;
1310 return Instruction::ICmp;
1311 }
1312 case SetLE :
1313 if (isFP) {
1314 predicate = FCmpInst::FCMP_OLE;
1315 return Instruction::FCmp;
1316 } else {
1317 if (isSigned)
1318 predicate = ICmpInst::ICMP_SLE;
1319 else
1320 predicate = ICmpInst::ICMP_ULE;
1321 return Instruction::ICmp;
1322 }
1323 case SetGE :
1324 if (isFP) {
1325 predicate = FCmpInst::FCMP_OGE;
1326 return Instruction::FCmp;
1327 } else {
1328 if (isSigned)
1329 predicate = ICmpInst::ICMP_SGE;
1330 else
1331 predicate = ICmpInst::ICMP_UGE;
1332 return Instruction::ICmp;
1333 }
1334 case SetLT :
1335 if (isFP) {
1336 predicate = FCmpInst::FCMP_OLT;
1337 return Instruction::FCmp;
1338 } else {
1339 if (isSigned)
1340 predicate = ICmpInst::ICMP_SLT;
1341 else
1342 predicate = ICmpInst::ICMP_ULT;
1343 return Instruction::ICmp;
1344 }
1345 case SetGT :
1346 if (isFP) {
1347 predicate = FCmpInst::FCMP_OGT;
1348 return Instruction::FCmp;
1349 } else {
1350 if (isSigned)
1351 predicate = ICmpInst::ICMP_SGT;
1352 else
1353 predicate = ICmpInst::ICMP_UGT;
1354 return Instruction::ICmp;
1355 }
1356 }
1357}
1358
1359static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1360 switch (op) {
1361 default : assert(0 && "Invalid OldMemoryOps");
1362 case MallocOp : return Instruction::Malloc;
1363 case FreeOp : return Instruction::Free;
1364 case AllocaOp : return Instruction::Alloca;
1365 case LoadOp : return Instruction::Load;
1366 case StoreOp : return Instruction::Store;
1367 case GetElementPtrOp : return Instruction::GetElementPtr;
1368 }
1369}
1370
1371static inline Instruction::OtherOps
1372getOtherOp(OtherOps op, Signedness Sign) {
1373 switch (op) {
1374 default : assert(0 && "Invalid OldOtherOps");
1375 case PHIOp : return Instruction::PHI;
1376 case CallOp : return Instruction::Call;
1377 case ShlOp : return Instruction::Shl;
1378 case ShrOp :
1379 if (Sign == Signed)
1380 return Instruction::AShr;
1381 return Instruction::LShr;
1382 case SelectOp : return Instruction::Select;
1383 case UserOp1 : return Instruction::UserOp1;
1384 case UserOp2 : return Instruction::UserOp2;
1385 case VAArg : return Instruction::VAArg;
1386 case ExtractElementOp : return Instruction::ExtractElement;
1387 case InsertElementOp : return Instruction::InsertElement;
1388 case ShuffleVectorOp : return Instruction::ShuffleVector;
1389 case ICmpOp : return Instruction::ICmp;
1390 case FCmpOp : return Instruction::FCmp;
1391 case LShrOp : return Instruction::LShr;
1392 case AShrOp : return Instruction::AShr;
1393 };
1394}
1395
1396static inline Value*
1397getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1398 Signedness DstSign, bool ForceInstruction = false) {
1399 Instruction::CastOps Opcode;
1400 const Type* SrcTy = Src->getType();
1401 if (op == CastOp) {
1402 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1403 // fp -> ptr cast is no longer supported but we must upgrade this
1404 // by doing a double cast: fp -> int -> ptr
1405 SrcTy = Type::Int64Ty;
1406 Opcode = Instruction::IntToPtr;
1407 if (isa<Constant>(Src)) {
1408 Src = ConstantExpr::getCast(Instruction::FPToUI,
1409 cast<Constant>(Src), SrcTy);
1410 } else {
1411 std::string NewName(makeNameUnique(Src->getName()));
1412 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1413 }
1414 } else if (isa<IntegerType>(DstTy) &&
1415 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1416 // cast type %x to bool was previously defined as setne type %x, null
1417 // The cast semantic is now to truncate, not compare so we must retain
1418 // the original intent by replacing the cast with a setne
1419 Constant* Null = Constant::getNullValue(SrcTy);
1420 Instruction::OtherOps Opcode = Instruction::ICmp;
1421 unsigned short predicate = ICmpInst::ICMP_NE;
1422 if (SrcTy->isFloatingPoint()) {
1423 Opcode = Instruction::FCmp;
1424 predicate = FCmpInst::FCMP_ONE;
1425 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1426 error("Invalid cast to bool");
1427 }
1428 if (isa<Constant>(Src) && !ForceInstruction)
1429 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1430 else
1431 return CmpInst::create(Opcode, predicate, Src, Null);
1432 }
1433 // Determine the opcode to use by calling CastInst::getCastOpcode
1434 Opcode =
1435 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1436
1437 } else switch (op) {
1438 default: assert(0 && "Invalid cast token");
1439 case TruncOp: Opcode = Instruction::Trunc; break;
1440 case ZExtOp: Opcode = Instruction::ZExt; break;
1441 case SExtOp: Opcode = Instruction::SExt; break;
1442 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1443 case FPExtOp: Opcode = Instruction::FPExt; break;
1444 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1445 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1446 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1447 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1448 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1449 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1450 case BitCastOp: Opcode = Instruction::BitCast; break;
1451 }
1452
1453 if (isa<Constant>(Src) && !ForceInstruction)
1454 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1455 return CastInst::create(Opcode, Src, DstTy);
1456}
1457
1458static Instruction *
1459upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1460 std::vector<Value*>& Args) {
1461
1462 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1463 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1464 if (Args.size() != 2)
1465 error("Invalid prototype for " + Name + " prototype");
1466 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1467 } else {
1468 static unsigned upgradeCount = 1;
1469 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1470 std::vector<const Type*> Params;
1471 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1472 if (Args.size() != 1)
1473 error("Invalid prototype for " + Name + " prototype");
1474 Params.push_back(PtrTy);
1475 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1476 const PointerType *PFTy = PointerType::get(FTy);
1477 Value* Func = getVal(PFTy, ID);
1478 std::string InstName("va_upgrade");
1479 InstName += llvm::utostr(upgradeCount++);
1480 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1481 return new CallInst(Func, Args);
1482 } else if (Name == "llvm.va_copy") {
1483 if (Args.size() != 2)
1484 error("Invalid prototype for " + Name + " prototype");
1485 Params.push_back(PtrTy);
1486 Params.push_back(PtrTy);
1487 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1488 const PointerType *PFTy = PointerType::get(FTy);
1489 Value* Func = getVal(PFTy, ID);
1490 std::string InstName0("va_upgrade");
1491 InstName0 += llvm::utostr(upgradeCount++);
1492 std::string InstName1("va_upgrade");
1493 InstName1 += llvm::utostr(upgradeCount++);
1494 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1495 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1496 return new CallInst(Func, Args);
1497 }
1498 }
1499 return 0;
1500}
1501
1502const Type* upgradeGEPIndices(const Type* PTy,
1503 std::vector<ValueInfo> *Indices,
1504 std::vector<Value*> &VIndices,
1505 std::vector<Constant*> *CIndices = 0) {
1506 // Traverse the indices with a gep_type_iterator so we can build the list
1507 // of constant and value indices for use later. Also perform upgrades
1508 VIndices.clear();
1509 if (CIndices) CIndices->clear();
1510 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1511 VIndices.push_back((*Indices)[i].V);
1512 generic_gep_type_iterator<std::vector<Value*>::iterator>
1513 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1514 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1515 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1516 Value *Index = VIndices[i];
1517 if (CIndices && !isa<Constant>(Index))
1518 error("Indices to constant getelementptr must be constants");
1519 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1520 // struct indices to i32 struct indices with ZExt for compatibility.
1521 else if (isa<StructType>(*GTI)) { // Only change struct indices
1522 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1523 if (CUI->getType()->getBitWidth() == 8)
1524 Index =
1525 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1526 } else {
1527 // Make sure that unsigned SequentialType indices are zext'd to
1528 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1529 // all indices for SequentialType elements. We must retain the same
1530 // semantic (zext) for unsigned types.
1531 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001532 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001533 if (CIndices)
1534 Index = ConstantExpr::getCast(Instruction::ZExt,
1535 cast<Constant>(Index), Type::Int64Ty);
1536 else
1537 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencerd7c4f8c2007-01-26 19:59:25 +00001538 makeNameUnique("gep_upgrade"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001539 VIndices[i] = Index;
1540 }
Reid Spencer950bf602007-01-26 08:19:09 +00001541 }
1542 // Add to the CIndices list, if requested.
1543 if (CIndices)
1544 CIndices->push_back(cast<Constant>(Index));
1545 }
1546
1547 const Type *IdxTy =
1548 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1549 if (!IdxTy)
1550 error("Index list invalid for constant getelementptr");
1551 return IdxTy;
1552}
1553
1554Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1555 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001556{
1557 Upgradelineno = 1;
1558 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001559 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001560 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001561 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001562 ObsoleteVarArgs = false;
1563 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001564
Reid Spencer950bf602007-01-26 08:19:09 +00001565 CurModule.CurrentModule = new Module(CurFilename);
1566
1567 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001568 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001569 if (ParserResult)
1570 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001571 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001572 return 0;
1573 }
1574
Reid Spencer950bf602007-01-26 08:19:09 +00001575 // Check to make sure that parsing produced a result
1576 if (!ParserResult) {
1577 std::cerr << "llvm-upgrade: no parse result.\n";
1578 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001579 }
1580
Reid Spencer950bf602007-01-26 08:19:09 +00001581 // Reset ParserResult variable while saving its value for the result.
1582 Module *Result = ParserResult;
1583 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001584
Reid Spencer950bf602007-01-26 08:19:09 +00001585 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001586 {
Reid Spencer950bf602007-01-26 08:19:09 +00001587 Function* F;
1588 if ((F = Result->getNamedFunction("llvm.va_start"))
1589 && F->getFunctionType()->getNumParams() == 0)
1590 ObsoleteVarArgs = true;
1591 if((F = Result->getNamedFunction("llvm.va_copy"))
1592 && F->getFunctionType()->getNumParams() == 1)
1593 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001594 }
Reid Spencer319a7302007-01-05 17:20:02 +00001595
Reid Spencer950bf602007-01-26 08:19:09 +00001596 if (ObsoleteVarArgs && NewVarArgs) {
1597 error("This file is corrupt: it uses both new and old style varargs");
1598 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001599 }
Reid Spencer319a7302007-01-05 17:20:02 +00001600
Reid Spencer950bf602007-01-26 08:19:09 +00001601 if(ObsoleteVarArgs) {
1602 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1603 if (F->arg_size() != 0) {
1604 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001605 return 0;
1606 }
Reid Spencer950bf602007-01-26 08:19:09 +00001607
1608 //foo = va_start()
1609 // ->
1610 //bar = alloca typeof(foo)
1611 //va_start(bar)
1612 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001613
Reid Spencer950bf602007-01-26 08:19:09 +00001614 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1615 const Type* ArgTy = F->getFunctionType()->getReturnType();
1616 const Type* ArgTyPtr = PointerType::get(ArgTy);
1617 Function* NF = cast<Function>(Result->getOrInsertFunction(
1618 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1619
1620 while (!F->use_empty()) {
1621 CallInst* CI = cast<CallInst>(F->use_back());
1622 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1623 new CallInst(NF, bar, "", CI);
1624 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1625 CI->replaceAllUsesWith(foo);
1626 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001627 }
Reid Spencer950bf602007-01-26 08:19:09 +00001628 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001629 }
Reid Spencer950bf602007-01-26 08:19:09 +00001630
1631 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1632 if(F->arg_size() != 1) {
1633 error("Obsolete va_end takes 1 argument");
1634 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001635 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001636
Reid Spencer950bf602007-01-26 08:19:09 +00001637 //vaend foo
1638 // ->
1639 //bar = alloca 1 of typeof(foo)
1640 //vaend bar
1641 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1642 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1643 const Type* ArgTyPtr = PointerType::get(ArgTy);
1644 Function* NF = cast<Function>(Result->getOrInsertFunction(
1645 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001646
Reid Spencer950bf602007-01-26 08:19:09 +00001647 while (!F->use_empty()) {
1648 CallInst* CI = cast<CallInst>(F->use_back());
1649 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1650 new StoreInst(CI->getOperand(1), bar, CI);
1651 new CallInst(NF, bar, "", CI);
1652 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001653 }
Reid Spencer950bf602007-01-26 08:19:09 +00001654 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001655 }
Reid Spencer950bf602007-01-26 08:19:09 +00001656
1657 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1658 if(F->arg_size() != 1) {
1659 error("Obsolete va_copy takes 1 argument");
1660 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001661 }
Reid Spencer950bf602007-01-26 08:19:09 +00001662 //foo = vacopy(bar)
1663 // ->
1664 //a = alloca 1 of typeof(foo)
1665 //b = alloca 1 of typeof(foo)
1666 //store bar -> b
1667 //vacopy(a, b)
1668 //foo = load a
1669
1670 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1671 const Type* ArgTy = F->getFunctionType()->getReturnType();
1672 const Type* ArgTyPtr = PointerType::get(ArgTy);
1673 Function* NF = cast<Function>(Result->getOrInsertFunction(
1674 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001675
Reid Spencer950bf602007-01-26 08:19:09 +00001676 while (!F->use_empty()) {
1677 CallInst* CI = cast<CallInst>(F->use_back());
1678 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1679 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1680 new StoreInst(CI->getOperand(1), b, CI);
1681 new CallInst(NF, a, b, "", CI);
1682 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1683 CI->replaceAllUsesWith(foo);
1684 CI->getParent()->getInstList().erase(CI);
1685 }
1686 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001687 }
1688 }
1689
Reid Spencer52402b02007-01-02 05:45:11 +00001690 return Result;
1691}
1692
Reid Spencer950bf602007-01-26 08:19:09 +00001693} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001694
Reid Spencer950bf602007-01-26 08:19:09 +00001695using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001696
1697
Reid Spencer319a7302007-01-05 17:20:02 +00001698
1699/* Enabling traces. */
1700#ifndef YYDEBUG
1701# define YYDEBUG 0
1702#endif
1703
1704/* Enabling verbose error messages. */
1705#ifdef YYERROR_VERBOSE
1706# undef YYERROR_VERBOSE
1707# define YYERROR_VERBOSE 1
1708#else
1709# define YYERROR_VERBOSE 0
1710#endif
1711
Reid Spencer950bf602007-01-26 08:19:09 +00001712/* Enabling the token table. */
1713#ifndef YYTOKEN_TABLE
1714# define YYTOKEN_TABLE 0
1715#endif
1716
1717#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer38f682b2007-01-26 20:31:18 +00001718#line 1339 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00001719typedef union YYSTYPE {
1720 llvm::Module *ModuleVal;
1721 llvm::Function *FunctionVal;
1722 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1723 llvm::BasicBlock *BasicBlockVal;
1724 llvm::TerminatorInst *TermInstVal;
1725 llvm::InstrInfo InstVal;
1726 llvm::ConstInfo ConstVal;
1727 llvm::ValueInfo ValueVal;
1728 llvm::PATypeInfo TypeVal;
1729 llvm::TypeInfo PrimType;
1730 llvm::PHIListInfo PHIList;
1731 std::list<llvm::PATypeInfo> *TypeList;
1732 std::vector<llvm::ValueInfo> *ValueList;
1733 std::vector<llvm::ConstInfo> *ConstVector;
1734
1735
1736 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1737 // Represent the RHS of PHI node
1738 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1739
1740 llvm::GlobalValue::LinkageTypes Linkage;
1741 int64_t SInt64Val;
1742 uint64_t UInt64Val;
1743 int SIntVal;
1744 unsigned UIntVal;
1745 double FPVal;
1746 bool BoolVal;
1747
1748 char *StrVal; // This memory is strdup'd!
1749 llvm::ValID ValIDVal; // strdup'd memory maybe!
1750
1751 llvm::BinaryOps BinaryOpVal;
1752 llvm::TermOps TermOpVal;
1753 llvm::MemoryOps MemOpVal;
1754 llvm::OtherOps OtherOpVal;
1755 llvm::CastOps CastOpVal;
1756 llvm::ICmpInst::Predicate IPred;
1757 llvm::FCmpInst::Predicate FPred;
1758 llvm::Module::Endianness Endianness;
1759} YYSTYPE;
1760/* Line 196 of yacc.c. */
Reid Spencer38f682b2007-01-26 20:31:18 +00001761#line 1762 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001762# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1763# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001764# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001765#endif
1766
Reid Spencer950bf602007-01-26 08:19:09 +00001767
Reid Spencere7c3c602006-11-30 06:36:44 +00001768
Reid Spencer319a7302007-01-05 17:20:02 +00001769/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001770
1771
Reid Spencer950bf602007-01-26 08:19:09 +00001772/* Line 219 of yacc.c. */
Reid Spencer38f682b2007-01-26 20:31:18 +00001773#line 1774 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001774
1775#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1776# define YYSIZE_T __SIZE_TYPE__
1777#endif
1778#if ! defined (YYSIZE_T) && defined (size_t)
1779# define YYSIZE_T size_t
1780#endif
1781#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1782# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1783# define YYSIZE_T size_t
1784#endif
1785#if ! defined (YYSIZE_T)
1786# define YYSIZE_T unsigned int
1787#endif
1788
1789#ifndef YY_
1790# if YYENABLE_NLS
1791# if ENABLE_NLS
1792# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1793# define YY_(msgid) dgettext ("bison-runtime", msgid)
1794# endif
1795# endif
1796# ifndef YY_
1797# define YY_(msgid) msgid
1798# endif
1799#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001800
1801#if ! defined (yyoverflow) || YYERROR_VERBOSE
1802
1803/* The parser invokes alloca or malloc; define the necessary symbols. */
1804
Reid Spencer950bf602007-01-26 08:19:09 +00001805# ifdef YYSTACK_USE_ALLOCA
1806# if YYSTACK_USE_ALLOCA
1807# ifdef __GNUC__
1808# define YYSTACK_ALLOC __builtin_alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001809# else
Reid Spencer950bf602007-01-26 08:19:09 +00001810# define YYSTACK_ALLOC alloca
1811# if defined (__STDC__) || defined (__cplusplus)
1812# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1813# define YYINCLUDED_STDLIB_H
Reid Spencer319a7302007-01-05 17:20:02 +00001814# endif
1815# endif
1816# endif
1817# endif
1818
1819# ifdef YYSTACK_ALLOC
1820 /* Pacify GCC's `empty if-body' warning. */
1821# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00001822# ifndef YYSTACK_ALLOC_MAXIMUM
1823 /* The OS might guarantee only one guard page at the bottom of the stack,
1824 and a page size can be as small as 4096 bytes. So we cannot safely
1825 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1826 to allow for a few compiler-allocated temporary stack slots. */
1827# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer319a7302007-01-05 17:20:02 +00001828# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001829# else
1830# define YYSTACK_ALLOC YYMALLOC
1831# define YYSTACK_FREE YYFREE
1832# ifndef YYSTACK_ALLOC_MAXIMUM
1833# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1834# endif
1835# ifdef __cplusplus
1836extern "C" {
1837# endif
1838# ifndef YYMALLOC
1839# define YYMALLOC malloc
1840# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1841 && (defined (__STDC__) || defined (__cplusplus)))
1842void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1843# endif
1844# endif
1845# ifndef YYFREE
1846# define YYFREE free
1847# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1848 && (defined (__STDC__) || defined (__cplusplus)))
1849void free (void *); /* INFRINGES ON USER NAME SPACE */
1850# endif
1851# endif
1852# ifdef __cplusplus
1853}
1854# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001855# endif
1856#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1857
1858
1859#if (! defined (yyoverflow) \
1860 && (! defined (__cplusplus) \
Reid Spencer950bf602007-01-26 08:19:09 +00001861 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001862
1863/* A type that is properly aligned for any stack member. */
1864union yyalloc
1865{
Reid Spencer950bf602007-01-26 08:19:09 +00001866 short int yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001867 YYSTYPE yyvs;
1868 };
1869
1870/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00001871# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00001872
1873/* The size of an array large to enough to hold all stacks, each with
1874 N elements. */
1875# define YYSTACK_BYTES(N) \
Reid Spencer950bf602007-01-26 08:19:09 +00001876 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1877 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00001878
1879/* Copy COUNT objects from FROM to TO. The source and destination do
1880 not overlap. */
1881# ifndef YYCOPY
Reid Spencer950bf602007-01-26 08:19:09 +00001882# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00001883# define YYCOPY(To, From, Count) \
1884 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1885# else
1886# define YYCOPY(To, From, Count) \
1887 do \
1888 { \
Reid Spencer950bf602007-01-26 08:19:09 +00001889 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00001890 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00001891 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00001892 } \
1893 while (0)
1894# endif
1895# endif
1896
1897/* Relocate STACK from its old location to the new one. The
1898 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1899 elements in the stack, and YYPTR gives the new location of the
1900 stack. Advance YYPTR to a properly aligned location for the next
1901 stack. */
1902# define YYSTACK_RELOCATE(Stack) \
1903 do \
1904 { \
1905 YYSIZE_T yynewbytes; \
1906 YYCOPY (&yyptr->Stack, Stack, yysize); \
1907 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00001908 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00001909 yyptr += yynewbytes / sizeof (*yyptr); \
1910 } \
1911 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00001912
1913#endif
1914
Reid Spencer319a7302007-01-05 17:20:02 +00001915#if defined (__STDC__) || defined (__cplusplus)
1916 typedef signed char yysigned_char;
Reid Spencere7c3c602006-11-30 06:36:44 +00001917#else
Reid Spencer950bf602007-01-26 08:19:09 +00001918 typedef short int yysigned_char;
Reid Spencere7c3c602006-11-30 06:36:44 +00001919#endif
1920
Reid Spencer319a7302007-01-05 17:20:02 +00001921/* YYFINAL -- State number of the termination state. */
1922#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00001923/* YYLAST -- Last index in YYTABLE. */
1924#define YYLAST 1712
Reid Spencer319a7302007-01-05 17:20:02 +00001925
1926/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00001927#define YYNTOKENS 166
Reid Spencer319a7302007-01-05 17:20:02 +00001928/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00001929#define YYNNTS 79
Reid Spencer319a7302007-01-05 17:20:02 +00001930/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00001931#define YYNRULES 308
Reid Spencer319a7302007-01-05 17:20:02 +00001932/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00001933#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00001934
1935/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1936#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00001937#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00001938
Reid Spencer950bf602007-01-26 08:19:09 +00001939#define YYTRANSLATE(YYX) \
1940 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00001941
1942/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1943static const unsigned char yytranslate[] =
1944{
1945 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1946 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1947 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1948 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00001949 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00001950 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00001951 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00001952 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1953 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00001954 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00001955 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1956 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00001957 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00001958 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1959 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1960 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1961 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1962 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1963 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1964 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1965 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1966 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1967 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1968 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1969 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1970 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1971 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1972 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1973 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1974 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1975 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1976 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1977 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1978 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1979 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1980 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1981 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1982 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1983 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1984 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00001985 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00001986};
1987
1988#if YYDEBUG
1989/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1990 YYRHS. */
Reid Spencer950bf602007-01-26 08:19:09 +00001991static const unsigned short int yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00001992{
1993 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1994 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1995 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1996 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1997 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1998 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1999 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2000 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2001 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002002 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002003 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2004 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2005 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2006 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2007 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002008 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2009 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2010 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2011 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2012 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2013 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2014 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2015 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2016 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2017 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2018 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2019 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2020 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2021 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2022 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2023 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002024};
2025
2026/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Reid Spencer950bf602007-01-26 08:19:09 +00002027static const short int yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002028{
Reid Spencer950bf602007-01-26 08:19:09 +00002029 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002030 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2031 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2032 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2033 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
Reid Spencer950bf602007-01-26 08:19:09 +00002034 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2035 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2036 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2037 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2038 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2039 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2040 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2041 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2042 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2043 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2044 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2045 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2046 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2047 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2048 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2049 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2050 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2051 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002052 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002053 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2054 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2055 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2056 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2057 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2058 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2059 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2060 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2061 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2062 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2063 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2064 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2065 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2066 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2067 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2068 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2069 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2070 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2071 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2072 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2073 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2074 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2075 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2076 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2077 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2078 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2079 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2080 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2081 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2082 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2083 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2084 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2085 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2086 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2087 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2088 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2089 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2090 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2091 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2092 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2093 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2094 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2095 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2096 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2097 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2098 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2099 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2100 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2101 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2102 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2103 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2104 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2105 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2106 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2107 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2108 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2109 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2110 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2111 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2112 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2113 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2114 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2115 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2116 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2117 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2118 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2119 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2120 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2121 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2122 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2123 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2124 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2125 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002126};
2127
2128/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencer950bf602007-01-26 08:19:09 +00002129static const unsigned short int yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002130{
Reid Spencer38f682b2007-01-26 20:31:18 +00002131 0, 1479, 1479, 1480, 1488, 1489, 1499, 1499, 1499, 1499,
2132 1499, 1499, 1499, 1499, 1499, 1499, 1499, 1503, 1503, 1503,
2133 1507, 1507, 1507, 1507, 1507, 1507, 1511, 1511, 1512, 1512,
2134 1513, 1513, 1514, 1514, 1515, 1515, 1519, 1519, 1520, 1520,
2135 1521, 1521, 1522, 1522, 1523, 1523, 1524, 1524, 1525, 1525,
2136 1526, 1527, 1530, 1530, 1530, 1530, 1534, 1534, 1534, 1534,
2137 1534, 1534, 1534, 1535, 1535, 1535, 1535, 1535, 1535, 1541,
2138 1541, 1541, 1541, 1545, 1545, 1545, 1545, 1549, 1549, 1553,
2139 1553, 1558, 1561, 1566, 1567, 1568, 1569, 1570, 1571, 1572,
2140 1573, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1594,
2141 1595, 1603, 1604, 1612, 1621, 1622, 1629, 1630, 1634, 1638,
2142 1654, 1655, 1662, 1663, 1670, 1678, 1678, 1678, 1678, 1678,
2143 1678, 1678, 1679, 1679, 1679, 1679, 1679, 1684, 1688, 1692,
2144 1697, 1706, 1722, 1728, 1741, 1750, 1754, 1765, 1769, 1782,
2145 1786, 1793, 1794, 1800, 1807, 1819, 1849, 1862, 1885, 1913,
2146 1935, 1946, 1968, 1979, 1988, 1993, 2051, 2058, 2066, 2073,
2147 2080, 2084, 2088, 2097, 2112, 2125, 2134, 2162, 2175, 2184,
2148 2190, 2196, 2205, 2211, 2217, 2228, 2229, 2238, 2239, 2251,
2149 2260, 2261, 2262, 2263, 2264, 2280, 2300, 2302, 2304, 2304,
2150 2311, 2311, 2318, 2318, 2325, 2325, 2333, 2335, 2337, 2342,
2151 2356, 2357, 2361, 2364, 2372, 2376, 2383, 2387, 2391, 2395,
2152 2403, 2403, 2407, 2408, 2412, 2420, 2425, 2433, 2434, 2441,
2153 2448, 2452, 2558, 2558, 2562, 2572, 2572, 2576, 2580, 2582,
2154 2583, 2587, 2587, 2599, 2600, 2605, 2606, 2607, 2608, 2609,
2155 2610, 2611, 2612, 2613, 2634, 2637, 2652, 2653, 2658, 2658,
2156 2666, 2675, 2678, 2687, 2697, 2702, 2711, 2722, 2722, 2725,
2157 2728, 2731, 2735, 2741, 2756, 2762, 2813, 2816, 2822, 2832,
2158 2845, 2874, 2882, 2890, 2894, 2901, 2902, 2906, 2909, 2915,
2159 2932, 2948, 2962, 2974, 2986, 2997, 3006, 3015, 3024, 3031,
2160 3052, 3076, 3082, 3088, 3094, 3110, 3183, 3191, 3192, 3196,
2161 3197, 3201, 3207, 3213, 3219, 3225, 3232, 3244, 3258
Reid Spencer319a7302007-01-05 17:20:02 +00002162};
2163#endif
2164
Reid Spencer950bf602007-01-26 08:19:09 +00002165#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2166/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencer319a7302007-01-05 17:20:02 +00002167 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2168static const char *const yytname[] =
2169{
Reid Spencer950bf602007-01-26 08:19:09 +00002170 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2171 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2172 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2173 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2174 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2175 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2176 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2177 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2178 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2179 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2180 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2181 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2182 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2183 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2184 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2185 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2186 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2187 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2188 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2189 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2190 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2191 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2192 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2193 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2194 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2195 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2196 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2197 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2198 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2199 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2200 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2201 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2202 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2203 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2204 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2205 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2206 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2207 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2208 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002209 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002210};
2211#endif
2212
2213# ifdef YYPRINT
2214/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2215 token YYLEX-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002216static const unsigned short int yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002217{
2218 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2219 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2220 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2221 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2222 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2223 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2224 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2225 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2226 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2227 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2228 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2229 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2230 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2231 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2232 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002233 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2234 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002235};
2236# endif
2237
2238/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2239static const unsigned char yyr1[] =
2240{
Reid Spencer950bf602007-01-26 08:19:09 +00002241 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2242 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2243 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2244 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2245 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2246 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2247 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2248 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2249 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2250 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2251 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2252 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2253 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2254 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2255 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2256 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2257 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2258 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2259 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2260 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2261 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2262 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2263 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2264 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2265 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2266 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2267 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2268 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2269 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2270 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2271 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002272};
2273
2274/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2275static const unsigned char yyr2[] =
2276{
2277 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2278 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2279 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2280 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2281 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2282 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2283 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2284 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2285 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002286 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002287 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2288 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2289 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2290 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2291 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002292 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2293 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2294 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2295 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2296 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2297 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2298 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2299 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2300 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2301 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2302 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2303 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2304 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2305 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2306 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2307 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002308};
2309
2310/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2311 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2312 means the default is an error. */
Reid Spencer950bf602007-01-26 08:19:09 +00002313static const unsigned short int yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002314{
Reid Spencer950bf602007-01-26 08:19:09 +00002315 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2316 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2317 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2318 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2319 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2320 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2321 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2322 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2323 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2324 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2325 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2326 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2327 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2328 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2329 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2330 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2331 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2332 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2333 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2334 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2335 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2336 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2337 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2338 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2339 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2340 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2341 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2342 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2343 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002344 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002345 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2346 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002347 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002348 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2349 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2350 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2351 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2352 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2353 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2354 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2355 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2356 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2357 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2358 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2359 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2360 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2361 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2362 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2363 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2364 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2365 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2366 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2367 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2368 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2369 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2370 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2371 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2372 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2373 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2374 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2375 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002376};
2377
2378/* YYDEFGOTO[NTERM-NUM]. */
Reid Spencer950bf602007-01-26 08:19:09 +00002379static const short int yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002380{
Reid Spencer950bf602007-01-26 08:19:09 +00002381 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2382 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2383 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2384 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2385 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2386 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2387 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2388 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002389};
2390
2391/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2392 STATE-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002393#define YYPACT_NINF -508
2394static const short int yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002395{
Reid Spencer950bf602007-01-26 08:19:09 +00002396 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2397 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2398 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2399 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2400 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2401 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2402 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2403 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2404 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2405 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2406 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2407 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2408 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2409 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2410 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2411 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2412 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2413 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2414 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2415 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2416 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2417 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2418 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2419 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2420 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2421 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2422 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2423 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2424 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2425 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2426 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2427 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2428 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2429 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2430 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2431 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2432 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2433 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2434 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2435 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2436 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2437 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2438 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2439 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2440 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2441 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2442 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2443 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2444 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2445 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2446 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2447 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2448 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2449 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2450 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2451 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2452 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2453 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2454 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2455 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2456 898, 898, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002457};
2458
2459/* YYPGOTO[NTERM-NUM]. */
Reid Spencer950bf602007-01-26 08:19:09 +00002460static const short int yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002461{
Reid Spencer950bf602007-01-26 08:19:09 +00002462 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2463 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2464 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2465 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2466 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2467 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2468 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2469 -508, -508, 43, -22, -508, -508, 21, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002470};
2471
2472/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2473 positive, shift that token. If negative, reduce the rule which
2474 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002475 If YYTABLE_NINF, syntax error. */
2476#define YYTABLE_NINF -180
2477static const short int yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002478{
Reid Spencer950bf602007-01-26 08:19:09 +00002479 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2480 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2481 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2482 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2483 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2484 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2485 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2486 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2487 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2488 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2489 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2490 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2491 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2492 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2493 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2494 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2495 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2496 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2497 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2498 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2499 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2500 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2501 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2502 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2503 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2504 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2505 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2506 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2507 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2508 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2509 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2510 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2511 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2512 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2513 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2514 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2515 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2516 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2517 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2518 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2519 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2520 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2521 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2522 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2523 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2524 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2525 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2526 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2527 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2528 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2529 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2530 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2531 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2532 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2533 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2534 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2535 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2536 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2537 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2538 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2539 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2540 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2541 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2542 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2543 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2544 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2545 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2546 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2547 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2548 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2549 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2550 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2551 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2552 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2553 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2554 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2555 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2556 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2557 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2558 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2559 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2560 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2561 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
Reid Spencerc4d96252007-01-13 00:03:30 +00002562 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002563 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2564 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2565 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2566 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002567 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002568 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2569 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2570 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2571 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2572 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2573 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2574 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2575 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2576 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2577 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2578 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2579 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2580 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2581 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2582 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2583 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2584 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2585 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2586 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2587 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2588 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2589 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2590 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2591 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2592 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2593 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2594 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2595 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2596 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2597 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2598 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2599 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2600 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2601 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2602 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2603 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2604 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2605 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2606 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2607 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2608 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2609 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2610 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2611 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2612 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2613 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2614 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2615 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2616 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2617 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2618 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2619 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2620 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2621 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2622 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2623 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2624 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2625 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2626 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2627 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2628 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2629 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2630 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2631 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2632 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002633 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2634 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002635 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2636 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2637 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2638 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002639 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002640 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2641 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2642 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2643 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2644 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2645 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2646 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2647 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2648 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2649 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2650 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002651};
2652
Reid Spencer950bf602007-01-26 08:19:09 +00002653static const short int yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002654{
Reid Spencer950bf602007-01-26 08:19:09 +00002655 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2656 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2657 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2658 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2659 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2660 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2661 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2662 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2663 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2664 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2665 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2666 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2667 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2668 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2669 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2670 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2671 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2672 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2673 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2674 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2675 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2676 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2677 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2678 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2679 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2680 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2681 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2682 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2683 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2684 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2685 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2686 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2687 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2688 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2689 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2690 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2691 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2692 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2693 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2694 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2695 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2696 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2697 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2698 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2699 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2700 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2701 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2702 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2703 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2704 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2705 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2706 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
Reid Spencerc4d96252007-01-13 00:03:30 +00002707 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
Reid Spencer950bf602007-01-26 08:19:09 +00002708 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2709 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2710 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2711 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2712 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2713 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2714 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2715 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2716 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2717 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2718 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2719 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2720 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2721 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2722 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2723 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2724 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2725 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2726 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2727 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2728 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2729 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2730 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2731 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2732 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2733 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2734 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2735 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2736 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2737 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2738 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2739 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2740 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2741 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2742 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2743 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2744 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2745 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2746 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2747 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2748 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2749 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2750 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2751 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2752 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2753 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2754 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2755 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2756 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2757 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2758 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2759 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2760 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2761 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2762 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2763 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2764 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2765 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2766 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2767 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2768 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2769 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2770 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2771 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2772 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2773 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2774 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2775 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2776 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2777 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2778 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2779 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2780 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2781 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2782 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2783 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2784 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2785 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2786 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2787 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2788 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2789 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2790 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2791 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2792 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2793 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2794 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2795 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2796 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2797 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2798 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2799 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2800 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2801 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2802 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2803 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2804 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2805 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2806 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2807 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2808 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2809 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2810 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2811 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2812 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2813 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2814 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2815 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2816 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2817 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2818 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2819 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2820 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2821 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2822 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2823 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2824 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2825 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2826 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002827};
2828
2829/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2830 symbol of state STATE-NUM. */
2831static const unsigned char yystos[] =
2832{
Reid Spencer950bf602007-01-26 08:19:09 +00002833 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2834 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2835 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2836 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2837 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2838 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2839 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2840 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2841 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2842 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2843 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2844 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2845 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2846 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2847 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2848 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2849 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2850 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2851 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2852 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2853 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2854 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2855 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2856 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2857 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2858 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2859 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2860 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2861 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2862 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2863 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2864 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2865 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2866 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2867 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2868 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2869 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2870 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2871 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2872 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2873 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2874 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2875 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2876 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2877 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2878 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2879 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2880 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2881 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2882 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2883 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2884 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2885 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2886 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2887 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2888 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2889 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2890 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2891 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2892 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2893 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00002894};
Reid Spencere7c3c602006-11-30 06:36:44 +00002895
2896#define yyerrok (yyerrstatus = 0)
2897#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00002898#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00002899#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00002900
Reid Spencere7c3c602006-11-30 06:36:44 +00002901#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00002902#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00002903#define YYERROR goto yyerrorlab
2904
Reid Spencer319a7302007-01-05 17:20:02 +00002905
2906/* Like YYERROR except do call yyerror. This remains here temporarily
2907 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00002908 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00002909
Reid Spencere7c3c602006-11-30 06:36:44 +00002910#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00002911
Reid Spencere7c3c602006-11-30 06:36:44 +00002912#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00002913
2914#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00002915do \
2916 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00002917 { \
2918 yychar = (Token); \
2919 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00002920 yytoken = YYTRANSLATE (yychar); \
Reid Spencere7c3c602006-11-30 06:36:44 +00002921 YYPOPSTACK; \
2922 goto yybackup; \
2923 } \
2924 else \
Reid Spencer950bf602007-01-26 08:19:09 +00002925 { \
2926 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00002927 YYERROR; \
2928 } \
Reid Spencere7c3c602006-11-30 06:36:44 +00002929while (0)
2930
Reid Spencer950bf602007-01-26 08:19:09 +00002931
Reid Spencere7c3c602006-11-30 06:36:44 +00002932#define YYTERROR 1
2933#define YYERRCODE 256
2934
Reid Spencer319a7302007-01-05 17:20:02 +00002935
Reid Spencer950bf602007-01-26 08:19:09 +00002936/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2937 If N is 0, then set CURRENT to the empty location which ends
2938 the previous symbol: RHS[0] (always defined). */
2939
2940#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00002941#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00002942# define YYLLOC_DEFAULT(Current, Rhs, N) \
2943 do \
2944 if (N) \
2945 { \
2946 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2947 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2948 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2949 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2950 } \
2951 else \
2952 { \
2953 (Current).first_line = (Current).last_line = \
2954 YYRHSLOC (Rhs, 0).last_line; \
2955 (Current).first_column = (Current).last_column = \
2956 YYRHSLOC (Rhs, 0).last_column; \
2957 } \
2958 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00002959#endif
2960
Reid Spencer950bf602007-01-26 08:19:09 +00002961
2962/* YY_LOCATION_PRINT -- Print the location on the stream.
2963 This macro was not mandated originally: define only if we know
2964 we won't break user code: when these are the locations we know. */
2965
2966#ifndef YY_LOCATION_PRINT
2967# if YYLTYPE_IS_TRIVIAL
2968# define YY_LOCATION_PRINT(File, Loc) \
2969 fprintf (File, "%d.%d-%d.%d", \
2970 (Loc).first_line, (Loc).first_column, \
2971 (Loc).last_line, (Loc).last_column)
2972# else
2973# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2974# endif
2975#endif
2976
2977
Reid Spencer319a7302007-01-05 17:20:02 +00002978/* YYLEX -- calling `yylex' with the right arguments. */
2979
Reid Spencer950bf602007-01-26 08:19:09 +00002980#ifdef YYLEX_PARAM
2981# define YYLEX yylex (YYLEX_PARAM)
2982#else
2983# define YYLEX yylex ()
2984#endif
Reid Spencer319a7302007-01-05 17:20:02 +00002985
2986/* Enable debugging if requested. */
2987#if YYDEBUG
2988
2989# ifndef YYFPRINTF
2990# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2991# define YYFPRINTF fprintf
2992# endif
2993
2994# define YYDPRINTF(Args) \
2995do { \
2996 if (yydebug) \
2997 YYFPRINTF Args; \
2998} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00002999
3000# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3001do { \
3002 if (yydebug) \
3003 { \
3004 YYFPRINTF (stderr, "%s ", Title); \
3005 yysymprint (stderr, \
3006 Type, Value); \
3007 YYFPRINTF (stderr, "\n"); \
3008 } \
Reid Spencer319a7302007-01-05 17:20:02 +00003009} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003010
3011/*------------------------------------------------------------------.
3012| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3013| TOP (included). |
3014`------------------------------------------------------------------*/
3015
3016#if defined (__STDC__) || defined (__cplusplus)
3017static void
3018yy_stack_print (short int *bottom, short int *top)
3019#else
3020static void
3021yy_stack_print (bottom, top)
3022 short int *bottom;
3023 short int *top;
3024#endif
3025{
3026 YYFPRINTF (stderr, "Stack now");
3027 for (/* Nothing. */; bottom <= top; ++bottom)
3028 YYFPRINTF (stderr, " %d", *bottom);
3029 YYFPRINTF (stderr, "\n");
3030}
3031
3032# define YY_STACK_PRINT(Bottom, Top) \
3033do { \
3034 if (yydebug) \
3035 yy_stack_print ((Bottom), (Top)); \
3036} while (0)
3037
3038
3039/*------------------------------------------------.
3040| Report that the YYRULE is going to be reduced. |
3041`------------------------------------------------*/
3042
3043#if defined (__STDC__) || defined (__cplusplus)
3044static void
3045yy_reduce_print (int yyrule)
3046#else
3047static void
3048yy_reduce_print (yyrule)
3049 int yyrule;
3050#endif
3051{
3052 int yyi;
3053 unsigned long int yylno = yyrline[yyrule];
3054 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3055 yyrule - 1, yylno);
3056 /* Print the symbols being reduced, and their result. */
3057 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3058 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3059 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3060}
3061
3062# define YY_REDUCE_PRINT(Rule) \
3063do { \
3064 if (yydebug) \
3065 yy_reduce_print (Rule); \
3066} while (0)
3067
Reid Spencer319a7302007-01-05 17:20:02 +00003068/* Nonzero means print parse trace. It is left uninitialized so that
3069 multiple parsers can coexist. */
3070int yydebug;
3071#else /* !YYDEBUG */
3072# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003073# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3074# define YY_STACK_PRINT(Bottom, Top)
3075# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003076#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003077
Reid Spencer950bf602007-01-26 08:19:09 +00003078
Reid Spencer319a7302007-01-05 17:20:02 +00003079/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003080#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003081# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003082#endif
3083
Reid Spencer319a7302007-01-05 17:20:02 +00003084/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3085 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003086
Reid Spencer319a7302007-01-05 17:20:02 +00003087 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003088 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003089 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003090
3091#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003092# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003093#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003094
Reid Spencere7c3c602006-11-30 06:36:44 +00003095
3096
Reid Spencer319a7302007-01-05 17:20:02 +00003097#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003098
Reid Spencer319a7302007-01-05 17:20:02 +00003099# ifndef yystrlen
3100# if defined (__GLIBC__) && defined (_STRING_H)
3101# define yystrlen strlen
3102# else
3103/* Return the length of YYSTR. */
3104static YYSIZE_T
3105# if defined (__STDC__) || defined (__cplusplus)
3106yystrlen (const char *yystr)
3107# else
3108yystrlen (yystr)
3109 const char *yystr;
3110# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003111{
Reid Spencer950bf602007-01-26 08:19:09 +00003112 const char *yys = yystr;
Chris Lattner37e01c52007-01-04 18:46:42 +00003113
Reid Spencer319a7302007-01-05 17:20:02 +00003114 while (*yys++ != '\0')
3115 continue;
3116
3117 return yys - yystr - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003118}
Reid Spencer319a7302007-01-05 17:20:02 +00003119# endif
3120# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003121
Reid Spencer319a7302007-01-05 17:20:02 +00003122# ifndef yystpcpy
3123# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3124# define yystpcpy stpcpy
3125# else
3126/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3127 YYDEST. */
3128static char *
3129# if defined (__STDC__) || defined (__cplusplus)
3130yystpcpy (char *yydest, const char *yysrc)
3131# else
3132yystpcpy (yydest, yysrc)
3133 char *yydest;
3134 const char *yysrc;
3135# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003136{
Reid Spencer950bf602007-01-26 08:19:09 +00003137 char *yyd = yydest;
3138 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003139
Reid Spencer319a7302007-01-05 17:20:02 +00003140 while ((*yyd++ = *yys++) != '\0')
3141 continue;
3142
3143 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003144}
Reid Spencer319a7302007-01-05 17:20:02 +00003145# endif
3146# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003147
Reid Spencer950bf602007-01-26 08:19:09 +00003148# ifndef yytnamerr
3149/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3150 quotes and backslashes, so that it's suitable for yyerror. The
3151 heuristic is that double-quoting is unnecessary unless the string
3152 contains an apostrophe, a comma, or backslash (other than
3153 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3154 null, do not copy; instead, return the length of what the result
3155 would have been. */
3156static YYSIZE_T
3157yytnamerr (char *yyres, const char *yystr)
3158{
3159 if (*yystr == '"')
3160 {
3161 size_t yyn = 0;
3162 char const *yyp = yystr;
3163
3164 for (;;)
3165 switch (*++yyp)
3166 {
3167 case '\'':
3168 case ',':
3169 goto do_not_strip_quotes;
3170
3171 case '\\':
3172 if (*++yyp != '\\')
3173 goto do_not_strip_quotes;
3174 /* Fall through. */
3175 default:
3176 if (yyres)
3177 yyres[yyn] = *yyp;
3178 yyn++;
3179 break;
3180
3181 case '"':
3182 if (yyres)
3183 yyres[yyn] = '\0';
3184 return yyn;
3185 }
3186 do_not_strip_quotes: ;
3187 }
3188
3189 if (! yyres)
3190 return yystrlen (yystr);
3191
3192 return yystpcpy (yyres, yystr) - yyres;
3193}
3194# endif
3195
3196#endif /* YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00003197
Reid Spencere7c3c602006-11-30 06:36:44 +00003198
3199
Reid Spencer319a7302007-01-05 17:20:02 +00003200#if YYDEBUG
Reid Spencer950bf602007-01-26 08:19:09 +00003201/*--------------------------------.
3202| Print this symbol on YYOUTPUT. |
3203`--------------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003204
Reid Spencer319a7302007-01-05 17:20:02 +00003205#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003206static void
3207yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner37e01c52007-01-04 18:46:42 +00003208#else
Reid Spencer950bf602007-01-26 08:19:09 +00003209static void
3210yysymprint (yyoutput, yytype, yyvaluep)
3211 FILE *yyoutput;
Reid Spencer319a7302007-01-05 17:20:02 +00003212 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003213 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003214#endif
3215{
3216 /* Pacify ``unused variable'' warnings. */
Reid Spencer950bf602007-01-26 08:19:09 +00003217 (void) yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003218
3219 if (yytype < YYNTOKENS)
Reid Spencer950bf602007-01-26 08:19:09 +00003220 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
Jeff Cohenac2dca92007-01-21 19:30:52 +00003221 else
Reid Spencer950bf602007-01-26 08:19:09 +00003222 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Jeff Cohenac2dca92007-01-21 19:30:52 +00003223
Reid Spencer950bf602007-01-26 08:19:09 +00003224
3225# ifdef YYPRINT
3226 if (yytype < YYNTOKENS)
3227 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3228# endif
Reid Spencer319a7302007-01-05 17:20:02 +00003229 switch (yytype)
3230 {
3231 default:
3232 break;
3233 }
Reid Spencer950bf602007-01-26 08:19:09 +00003234 YYFPRINTF (yyoutput, ")");
Reid Spencer319a7302007-01-05 17:20:02 +00003235}
3236
Reid Spencer950bf602007-01-26 08:19:09 +00003237#endif /* ! YYDEBUG */
Reid Spencer319a7302007-01-05 17:20:02 +00003238/*-----------------------------------------------.
3239| Release the memory associated to this symbol. |
3240`-----------------------------------------------*/
3241
3242#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003243static void
3244yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003245#else
Reid Spencer950bf602007-01-26 08:19:09 +00003246static void
3247yydestruct (yymsg, yytype, yyvaluep)
3248 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003249 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003250 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003251#endif
3252{
3253 /* Pacify ``unused variable'' warnings. */
Reid Spencer950bf602007-01-26 08:19:09 +00003254 (void) yyvaluep;
3255
3256 if (!yymsg)
3257 yymsg = "Deleting";
3258 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003259
3260 switch (yytype)
3261 {
Reid Spencer950bf602007-01-26 08:19:09 +00003262
Reid Spencer319a7302007-01-05 17:20:02 +00003263 default:
3264 break;
3265 }
3266}
3267
3268
Reid Spencer950bf602007-01-26 08:19:09 +00003269/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003270
3271#ifdef YYPARSE_PARAM
3272# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003273int yyparse (void *YYPARSE_PARAM);
Reid Spencer319a7302007-01-05 17:20:02 +00003274# else
Reid Spencer950bf602007-01-26 08:19:09 +00003275int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003276# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003277#else /* ! YYPARSE_PARAM */
3278#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003279int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003280#else
3281int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003282#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003283#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003284
3285
Reid Spencer950bf602007-01-26 08:19:09 +00003286
3287/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003288int yychar;
3289
Reid Spencer950bf602007-01-26 08:19:09 +00003290/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003291YYSTYPE yylval;
3292
Reid Spencer950bf602007-01-26 08:19:09 +00003293/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003294int yynerrs;
3295
3296
Reid Spencer950bf602007-01-26 08:19:09 +00003297
3298/*----------.
3299| yyparse. |
3300`----------*/
3301
3302#ifdef YYPARSE_PARAM
3303# if defined (__STDC__) || defined (__cplusplus)
3304int yyparse (void *YYPARSE_PARAM)
3305# else
3306int yyparse (YYPARSE_PARAM)
3307 void *YYPARSE_PARAM;
3308# endif
3309#else /* ! YYPARSE_PARAM */
3310#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003311int
Reid Spencer950bf602007-01-26 08:19:09 +00003312yyparse (void)
3313#else
3314int
3315yyparse ()
3316
3317#endif
3318#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003319{
3320
Reid Spencer950bf602007-01-26 08:19:09 +00003321 int yystate;
3322 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003323 int yyresult;
3324 /* Number of tokens to shift before error messages enabled. */
3325 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003326 /* Look-ahead token as an internal (translated) token number. */
3327 int yytoken = 0;
Reid Spencer319a7302007-01-05 17:20:02 +00003328
3329 /* Three stacks and their tools:
3330 `yyss': related to states,
3331 `yyvs': related to semantic values,
3332 `yyls': related to locations.
3333
3334 Refer to the stacks thru separate pointers, to allow yyoverflow
3335 to reallocate them elsewhere. */
3336
3337 /* The state stack. */
Reid Spencer950bf602007-01-26 08:19:09 +00003338 short int yyssa[YYINITDEPTH];
3339 short int *yyss = yyssa;
3340 short int *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003341
3342 /* The semantic value stack. */
3343 YYSTYPE yyvsa[YYINITDEPTH];
3344 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003345 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003346
3347
3348
Reid Spencere7c3c602006-11-30 06:36:44 +00003349#define YYPOPSTACK (yyvsp--, yyssp--)
3350
Reid Spencer319a7302007-01-05 17:20:02 +00003351 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003352
Reid Spencer319a7302007-01-05 17:20:02 +00003353 /* The variables used to return semantic value and location from the
3354 action routines. */
3355 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003356
3357
Reid Spencer319a7302007-01-05 17:20:02 +00003358 /* When reducing, the number of symbols on the RHS of the reduced
3359 rule. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003360 int yylen;
3361
Reid Spencer319a7302007-01-05 17:20:02 +00003362 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003363
3364 yystate = 0;
3365 yyerrstatus = 0;
3366 yynerrs = 0;
3367 yychar = YYEMPTY; /* Cause a token to be read. */
3368
3369 /* Initialize stack pointers.
3370 Waste one element of value and location stack
3371 so that they stay on the same level as the state stack.
3372 The wasted elements are never initialized. */
3373
Reid Spencer319a7302007-01-05 17:20:02 +00003374 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003375 yyvsp = yyvs;
3376
Reid Spencer319a7302007-01-05 17:20:02 +00003377 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003378
Reid Spencer319a7302007-01-05 17:20:02 +00003379/*------------------------------------------------------------.
3380| yynewstate -- Push a new state, which is found in yystate. |
3381`------------------------------------------------------------*/
3382 yynewstate:
3383 /* In all cases, when you get here, the value and location stacks
3384 have just been pushed. so pushing a state here evens the stacks.
3385 */
3386 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003387
Reid Spencer319a7302007-01-05 17:20:02 +00003388 yysetstate:
3389 *yyssp = yystate;
3390
Reid Spencer950bf602007-01-26 08:19:09 +00003391 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003392 {
3393 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003394 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003395
3396#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003397 {
3398 /* Give user a chance to reallocate the stack. Use copies of
3399 these so that the &'s don't force the real ones into
3400 memory. */
3401 YYSTYPE *yyvs1 = yyvs;
Reid Spencer950bf602007-01-26 08:19:09 +00003402 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003403
Reid Spencer319a7302007-01-05 17:20:02 +00003404
3405 /* Each stack pointer address is followed by the size of the
3406 data in use in that stack, in bytes. This used to be a
3407 conditional around just the two extra args, but that might
3408 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003409 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003410 &yyss1, yysize * sizeof (*yyssp),
3411 &yyvs1, yysize * sizeof (*yyvsp),
3412
3413 &yystacksize);
3414
3415 yyss = yyss1;
3416 yyvs = yyvs1;
3417 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003418#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003419# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003420 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003421# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003422 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003423 if (YYMAXDEPTH <= yystacksize)
3424 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003425 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003426 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003427 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003428
3429 {
Reid Spencer950bf602007-01-26 08:19:09 +00003430 short int *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003431 union yyalloc *yyptr =
3432 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3433 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003434 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003435 YYSTACK_RELOCATE (yyss);
3436 YYSTACK_RELOCATE (yyvs);
3437
3438# undef YYSTACK_RELOCATE
3439 if (yyss1 != yyssa)
3440 YYSTACK_FREE (yyss1);
3441 }
3442# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003443#endif /* no yyoverflow */
3444
Reid Spencer319a7302007-01-05 17:20:02 +00003445 yyssp = yyss + yysize - 1;
3446 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003447
3448
Reid Spencer319a7302007-01-05 17:20:02 +00003449 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3450 (unsigned long int) yystacksize));
3451
Reid Spencer950bf602007-01-26 08:19:09 +00003452 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003453 YYABORT;
3454 }
3455
Reid Spencer319a7302007-01-05 17:20:02 +00003456 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003457
3458 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003459
3460/*-----------.
3461| yybackup. |
3462`-----------*/
3463yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003464
3465/* Do appropriate processing given the current state. */
Reid Spencer950bf602007-01-26 08:19:09 +00003466/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003467/* yyresume: */
3468
Reid Spencer950bf602007-01-26 08:19:09 +00003469 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003470
3471 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003472 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003473 goto yydefault;
3474
Reid Spencer950bf602007-01-26 08:19:09 +00003475 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003476
Reid Spencer950bf602007-01-26 08:19:09 +00003477 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003478 if (yychar == YYEMPTY)
3479 {
Reid Spencer319a7302007-01-05 17:20:02 +00003480 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003481 yychar = YYLEX;
3482 }
3483
Reid Spencer950bf602007-01-26 08:19:09 +00003484 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003485 {
Reid Spencer950bf602007-01-26 08:19:09 +00003486 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003487 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003488 }
3489 else
3490 {
Reid Spencer950bf602007-01-26 08:19:09 +00003491 yytoken = YYTRANSLATE (yychar);
3492 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003493 }
3494
Reid Spencer950bf602007-01-26 08:19:09 +00003495 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003496 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003497 yyn += yytoken;
3498 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003499 goto yydefault;
3500 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003501 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003502 {
Reid Spencer319a7302007-01-05 17:20:02 +00003503 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003504 goto yyerrlab;
3505 yyn = -yyn;
3506 goto yyreduce;
3507 }
3508
3509 if (yyn == YYFINAL)
3510 YYACCEPT;
3511
Reid Spencer950bf602007-01-26 08:19:09 +00003512 /* Shift the look-ahead token. */
3513 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003514
3515 /* Discard the token being shifted unless it is eof. */
3516 if (yychar != YYEOF)
3517 yychar = YYEMPTY;
3518
3519 *++yyvsp = yylval;
3520
Reid Spencer319a7302007-01-05 17:20:02 +00003521
3522 /* Count tokens shifted since error; after three, turn off error
3523 status. */
3524 if (yyerrstatus)
3525 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003526
3527 yystate = yyn;
3528 goto yynewstate;
3529
Chris Lattner37e01c52007-01-04 18:46:42 +00003530
Reid Spencer319a7302007-01-05 17:20:02 +00003531/*-----------------------------------------------------------.
3532| yydefault -- do the default action for the current state. |
3533`-----------------------------------------------------------*/
3534yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003535 yyn = yydefact[yystate];
3536 if (yyn == 0)
3537 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003538 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003539
Reid Spencer319a7302007-01-05 17:20:02 +00003540
3541/*-----------------------------.
3542| yyreduce -- Do a reduction. |
3543`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003544yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003545 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003546 yylen = yyr2[yyn];
3547
Reid Spencer319a7302007-01-05 17:20:02 +00003548 /* If YYLEN is nonzero, implement the default value of the action:
3549 `$$ = $1'.
3550
3551 Otherwise, the following line sets YYVAL to garbage.
3552 This behavior is undocumented and Bison
3553 users should not rely upon it. Assigning to YYVAL
3554 unconditionally makes the parser a bit smaller, and it avoids a
3555 GCC warning that YYVAL may be used uninitialized. */
3556 yyval = yyvsp[1-yylen];
3557
3558
Reid Spencer950bf602007-01-26 08:19:09 +00003559 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003560 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003561 {
Reid Spencer950bf602007-01-26 08:19:09 +00003562 case 3:
Reid Spencer38f682b2007-01-26 20:31:18 +00003563#line 1480 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003564 {
Reid Spencer950bf602007-01-26 08:19:09 +00003565 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
3566 error("Value too large for type");
3567 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3568 ;}
3569 break;
3570
3571 case 5:
Reid Spencer38f682b2007-01-26 20:31:18 +00003572#line 1489 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003573 {
3574 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
3575 error("Value too large for type");
3576 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3577 ;}
3578 break;
3579
3580 case 26:
Reid Spencer38f682b2007-01-26 20:31:18 +00003581#line 1511 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003582 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3583 break;
3584
3585 case 27:
Reid Spencer38f682b2007-01-26 20:31:18 +00003586#line 1511 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003587 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3588 break;
3589
3590 case 28:
Reid Spencer38f682b2007-01-26 20:31:18 +00003591#line 1512 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003592 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3593 break;
3594
3595 case 29:
Reid Spencer38f682b2007-01-26 20:31:18 +00003596#line 1512 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003597 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3598 break;
3599
3600 case 30:
Reid Spencer38f682b2007-01-26 20:31:18 +00003601#line 1513 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003602 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3603 break;
3604
3605 case 31:
Reid Spencer38f682b2007-01-26 20:31:18 +00003606#line 1513 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003607 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3608 break;
3609
3610 case 32:
Reid Spencer38f682b2007-01-26 20:31:18 +00003611#line 1514 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003612 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3613 break;
3614
3615 case 33:
Reid Spencer38f682b2007-01-26 20:31:18 +00003616#line 1514 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003617 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3618 break;
3619
3620 case 34:
Reid Spencer38f682b2007-01-26 20:31:18 +00003621#line 1515 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003622 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3623 break;
3624
3625 case 35:
Reid Spencer38f682b2007-01-26 20:31:18 +00003626#line 1515 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003627 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3628 break;
3629
3630 case 36:
Reid Spencer38f682b2007-01-26 20:31:18 +00003631#line 1519 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003632 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3633 break;
3634
3635 case 37:
Reid Spencer38f682b2007-01-26 20:31:18 +00003636#line 1519 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003637 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3638 break;
3639
3640 case 38:
Reid Spencer38f682b2007-01-26 20:31:18 +00003641#line 1520 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003642 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3643 break;
3644
3645 case 39:
Reid Spencer38f682b2007-01-26 20:31:18 +00003646#line 1520 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003647 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3648 break;
3649
3650 case 40:
Reid Spencer38f682b2007-01-26 20:31:18 +00003651#line 1521 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003652 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3653 break;
3654
3655 case 41:
Reid Spencer38f682b2007-01-26 20:31:18 +00003656#line 1521 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003657 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3658 break;
3659
3660 case 42:
Reid Spencer38f682b2007-01-26 20:31:18 +00003661#line 1522 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003662 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3663 break;
3664
3665 case 43:
Reid Spencer38f682b2007-01-26 20:31:18 +00003666#line 1522 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003667 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3668 break;
3669
3670 case 44:
Reid Spencer38f682b2007-01-26 20:31:18 +00003671#line 1523 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003672 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3673 break;
3674
3675 case 45:
Reid Spencer38f682b2007-01-26 20:31:18 +00003676#line 1523 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003677 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3678 break;
3679
3680 case 46:
Reid Spencer38f682b2007-01-26 20:31:18 +00003681#line 1524 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003682 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3683 break;
3684
3685 case 47:
Reid Spencer38f682b2007-01-26 20:31:18 +00003686#line 1524 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003687 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3688 break;
3689
3690 case 48:
Reid Spencer38f682b2007-01-26 20:31:18 +00003691#line 1525 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003692 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3693 break;
3694
3695 case 49:
Reid Spencer38f682b2007-01-26 20:31:18 +00003696#line 1525 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003697 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3698 break;
3699
3700 case 50:
Reid Spencer38f682b2007-01-26 20:31:18 +00003701#line 1526 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003702 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3703 break;
3704
3705 case 51:
Reid Spencer38f682b2007-01-26 20:31:18 +00003706#line 1527 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003707 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3708 break;
3709
3710 case 81:
Reid Spencer38f682b2007-01-26 20:31:18 +00003711#line 1558 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003712 {
3713 (yyval.StrVal) = (yyvsp[-1].StrVal);
3714 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003715 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003716
Reid Spencer319a7302007-01-05 17:20:02 +00003717 case 82:
Reid Spencer38f682b2007-01-26 20:31:18 +00003718#line 1561 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003719 {
Reid Spencer950bf602007-01-26 08:19:09 +00003720 (yyval.StrVal) = 0;
3721 ;}
3722 break;
3723
3724 case 83:
Reid Spencer38f682b2007-01-26 20:31:18 +00003725#line 1566 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003726 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3727 break;
3728
3729 case 84:
Reid Spencer38f682b2007-01-26 20:31:18 +00003730#line 1567 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003731 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3732 break;
3733
3734 case 85:
Reid Spencer38f682b2007-01-26 20:31:18 +00003735#line 1568 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003736 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3737 break;
3738
3739 case 86:
Reid Spencer38f682b2007-01-26 20:31:18 +00003740#line 1569 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003741 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3742 break;
3743
3744 case 87:
Reid Spencer38f682b2007-01-26 20:31:18 +00003745#line 1570 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003746 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3747 break;
3748
3749 case 88:
Reid Spencer38f682b2007-01-26 20:31:18 +00003750#line 1571 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003751 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3752 break;
3753
3754 case 89:
Reid Spencer38f682b2007-01-26 20:31:18 +00003755#line 1572 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003756 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003757 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003758
Reid Spencer319a7302007-01-05 17:20:02 +00003759 case 90:
Reid Spencer38f682b2007-01-26 20:31:18 +00003760#line 1573 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003761 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3762 break;
3763
3764 case 91:
Reid Spencer38f682b2007-01-26 20:31:18 +00003765#line 1577 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003766 { (yyval.UIntVal) = CallingConv::C; ;}
3767 break;
3768
3769 case 92:
Reid Spencer38f682b2007-01-26 20:31:18 +00003770#line 1578 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003771 { (yyval.UIntVal) = CallingConv::C; ;}
3772 break;
3773
3774 case 93:
Reid Spencer38f682b2007-01-26 20:31:18 +00003775#line 1579 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003776 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3777 break;
3778
3779 case 94:
Reid Spencer38f682b2007-01-26 20:31:18 +00003780#line 1580 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003781 { (yyval.UIntVal) = CallingConv::Fast; ;}
3782 break;
3783
3784 case 95:
Reid Spencer38f682b2007-01-26 20:31:18 +00003785#line 1581 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003786 { (yyval.UIntVal) = CallingConv::Cold; ;}
3787 break;
3788
3789 case 96:
Reid Spencer38f682b2007-01-26 20:31:18 +00003790#line 1582 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003791 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003792 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00003793
Reid Spencer319a7302007-01-05 17:20:02 +00003794 case 97:
Reid Spencer38f682b2007-01-26 20:31:18 +00003795#line 1583 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003796 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003797 break;
Reid Spencer16244f42006-12-01 21:10:07 +00003798
Reid Spencer319a7302007-01-05 17:20:02 +00003799 case 98:
Reid Spencer38f682b2007-01-26 20:31:18 +00003800#line 1584 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003801 {
3802 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
3803 error("Calling conv too large");
3804 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3805 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003806 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003807
Reid Spencer319a7302007-01-05 17:20:02 +00003808 case 99:
Reid Spencer38f682b2007-01-26 20:31:18 +00003809#line 1594 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003810 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003811 break;
3812
Reid Spencerc4d96252007-01-13 00:03:30 +00003813 case 100:
Reid Spencer38f682b2007-01-26 20:31:18 +00003814#line 1595 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003815 {
3816 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3817 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3818 error("Alignment must be a power of two");
3819 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003820 break;
3821
3822 case 101:
Reid Spencer38f682b2007-01-26 20:31:18 +00003823#line 1603 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003824 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003825 break;
3826
3827 case 102:
Reid Spencer38f682b2007-01-26 20:31:18 +00003828#line 1604 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003829 {
3830 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3831 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3832 error("Alignment must be a power of two");
3833 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003834 break;
3835
3836 case 103:
Reid Spencer38f682b2007-01-26 20:31:18 +00003837#line 1612 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003838 {
3839 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3840 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
3841 error("Invalid character in section name");
3842 (yyval.StrVal) = (yyvsp[0].StrVal);
3843 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003844 break;
3845
3846 case 104:
Reid Spencer38f682b2007-01-26 20:31:18 +00003847#line 1621 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003848 { (yyval.StrVal) = 0; ;}
3849 break;
3850
3851 case 105:
Reid Spencer38f682b2007-01-26 20:31:18 +00003852#line 1622 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003853 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003854 break;
3855
Reid Spencerc4d96252007-01-13 00:03:30 +00003856 case 106:
Reid Spencer38f682b2007-01-26 20:31:18 +00003857#line 1629 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003858 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003859 break;
3860
Reid Spencer319a7302007-01-05 17:20:02 +00003861 case 107:
Reid Spencer38f682b2007-01-26 20:31:18 +00003862#line 1630 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003863 {;}
3864 break;
3865
3866 case 108:
Reid Spencer38f682b2007-01-26 20:31:18 +00003867#line 1634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003868 {
Reid Spencer950bf602007-01-26 08:19:09 +00003869 CurGV->setSection((yyvsp[0].StrVal));
3870 free((yyvsp[0].StrVal));
3871 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003872 break;
3873
3874 case 109:
Reid Spencer38f682b2007-01-26 20:31:18 +00003875#line 1638 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003876 {
Reid Spencer950bf602007-01-26 08:19:09 +00003877 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
3878 error("Alignment must be a power of two");
3879 CurGV->setAlignment((yyvsp[0].UInt64Val));
3880
3881 ;}
3882 break;
3883
3884 case 111:
Reid Spencer38f682b2007-01-26 20:31:18 +00003885#line 1655 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003886 {
3887 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3888 (yyval.TypeVal).S = Signless;
3889 ;}
3890 break;
3891
3892 case 113:
Reid Spencer38f682b2007-01-26 20:31:18 +00003893#line 1663 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003894 {
3895 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3896 (yyval.TypeVal).S = Signless;
3897 ;}
3898 break;
3899
3900 case 114:
Reid Spencer38f682b2007-01-26 20:31:18 +00003901#line 1670 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003902 {
3903 if (!UpRefs.empty())
3904 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).T)->getDescription());
3905 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3906 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003907 break;
3908
3909 case 127:
Reid Spencer38f682b2007-01-26 20:31:18 +00003910#line 1684 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003911 {
Reid Spencer950bf602007-01-26 08:19:09 +00003912 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3913 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
3914 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003915 break;
3916
3917 case 128:
Reid Spencer38f682b2007-01-26 20:31:18 +00003918#line 1688 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003919 {
3920 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
3921 (yyval.TypeVal).S = Signless;
3922 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003923 break;
3924
3925 case 129:
Reid Spencer38f682b2007-01-26 20:31:18 +00003926#line 1692 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003927 { // Named types are also simple types...
Reid Spencerd7c4f8c2007-01-26 19:59:25 +00003928 const Type* tmp = getType((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00003929 (yyval.TypeVal).T = new PATypeHolder(tmp);
3930 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
3931 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003932 break;
3933
3934 case 130:
Reid Spencer38f682b2007-01-26 20:31:18 +00003935#line 1697 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003936 { // Type UpReference
Reid Spencer950bf602007-01-26 08:19:09 +00003937 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
3938 error("Value out of range");
3939 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
3940 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3941 (yyval.TypeVal).T = new PATypeHolder(OT);
3942 (yyval.TypeVal).S = Signless;
3943 UR_OUT("New Upreference!\n");
3944 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003945 break;
3946
3947 case 131:
Reid Spencer38f682b2007-01-26 20:31:18 +00003948#line 1706 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003949 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00003950 std::vector<const Type*> Params;
3951 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
3952 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
3953 Params.push_back(I->T->get());
3954 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00003955 }
Reid Spencer950bf602007-01-26 08:19:09 +00003956 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3957 if (isVarArg) Params.pop_back();
3958
3959 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
3960 FunctionType::get((yyvsp[-3].TypeVal).T->get(),Params,isVarArg)));
3961 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
3962 delete (yyvsp[-3].TypeVal).T; // Delete the return type handle
3963 delete (yyvsp[-1].TypeList); // Delete the argument list
3964 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003965 break;
3966
3967 case 132:
Reid Spencer38f682b2007-01-26 20:31:18 +00003968#line 1722 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003969 { // Sized array type?
Reid Spencer950bf602007-01-26 08:19:09 +00003970 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).T->get(),
3971 (unsigned)(yyvsp[-3].UInt64Val))));
3972 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
3973 delete (yyvsp[-1].TypeVal).T;
3974 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003975 break;
3976
3977 case 133:
Reid Spencer38f682b2007-01-26 20:31:18 +00003978#line 1728 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003979 { // Packed array type?
Reid Spencer950bf602007-01-26 08:19:09 +00003980 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).T->get();
3981 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3982 error("Unsigned result not equal to signed result");
3983 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
3984 error("Elements of a PackedType must be integer or floating point");
3985 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3986 error("PackedType length should be a power of 2");
3987 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
3988 (unsigned)(yyvsp[-3].UInt64Val))));
3989 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
3990 delete (yyvsp[-1].TypeVal).T;
3991 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003992 break;
3993
3994 case 134:
Reid Spencer38f682b2007-01-26 20:31:18 +00003995#line 1741 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003996 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00003997 std::vector<const Type*> Elements;
3998 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
3999 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
4000 Elements.push_back(I->T->get());
4001 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4002 (yyval.TypeVal).S = Signless;
4003 delete (yyvsp[-1].TypeList);
4004 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004005 break;
4006
4007 case 135:
Reid Spencer38f682b2007-01-26 20:31:18 +00004008#line 1750 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004009 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004010 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4011 (yyval.TypeVal).S = Signless;
4012 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004013 break;
4014
4015 case 136:
Reid Spencer38f682b2007-01-26 20:31:18 +00004016#line 1754 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004017 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004018 std::vector<const Type*> Elements;
4019 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4020 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
4021 Elements.push_back(I->T->get());
4022 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004023 }
Reid Spencer950bf602007-01-26 08:19:09 +00004024 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4025 (yyval.TypeVal).S = Signless;
4026 delete (yyvsp[-2].TypeList);
4027 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004028 break;
4029
4030 case 137:
Reid Spencer38f682b2007-01-26 20:31:18 +00004031#line 1765 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004032 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004033 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4034 (yyval.TypeVal).S = Signless;
4035 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004036 break;
4037
4038 case 138:
Reid Spencer38f682b2007-01-26 20:31:18 +00004039#line 1769 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004040 { // Pointer type?
Reid Spencer950bf602007-01-26 08:19:09 +00004041 if ((yyvsp[-1].TypeVal).T->get() == Type::LabelTy)
4042 error("Cannot form a pointer to a basic block");
4043 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).T->get())));
4044 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4045 delete (yyvsp[-1].TypeVal).T;
4046 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004047 break;
4048
4049 case 139:
Reid Spencer38f682b2007-01-26 20:31:18 +00004050#line 1782 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004051 {
Reid Spencer950bf602007-01-26 08:19:09 +00004052 (yyval.TypeList) = new std::list<PATypeInfo>();
4053 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4054 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004055 break;
4056
4057 case 140:
Reid Spencer38f682b2007-01-26 20:31:18 +00004058#line 1786 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004059 {
Reid Spencer950bf602007-01-26 08:19:09 +00004060 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4061 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004062 break;
4063
4064 case 142:
Reid Spencer38f682b2007-01-26 20:31:18 +00004065#line 1794 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004066 {
Reid Spencer950bf602007-01-26 08:19:09 +00004067 PATypeInfo VoidTI;
4068 VoidTI.T = new PATypeHolder(Type::VoidTy);
4069 VoidTI.S = Signless;
4070 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4071 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004072 break;
4073
4074 case 143:
Reid Spencer38f682b2007-01-26 20:31:18 +00004075#line 1800 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004076 {
Reid Spencer950bf602007-01-26 08:19:09 +00004077 (yyval.TypeList) = new std::list<PATypeInfo>();
4078 PATypeInfo VoidTI;
4079 VoidTI.T = new PATypeHolder(Type::VoidTy);
4080 VoidTI.S = Signless;
4081 (yyval.TypeList)->push_back(VoidTI);
4082 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004083 break;
4084
4085 case 144:
Reid Spencer38f682b2007-01-26 20:31:18 +00004086#line 1807 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004087 {
Reid Spencer950bf602007-01-26 08:19:09 +00004088 (yyval.TypeList) = new std::list<PATypeInfo>();
4089 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004090 break;
4091
4092 case 145:
Reid Spencer38f682b2007-01-26 20:31:18 +00004093#line 1819 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004094 { // Nonempty unsized arr
Reid Spencer950bf602007-01-26 08:19:09 +00004095 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).T->get());
4096 if (ATy == 0)
4097 error("Cannot make array constant with type: '" +
4098 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4099 const Type *ETy = ATy->getElementType();
4100 int NumElements = ATy->getNumElements();
4101
4102 // Verify that we have the correct size...
4103 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4104 error("Type mismatch: constant sized array initialized with " +
4105 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4106 itostr(NumElements) + "");
4107
4108 // Verify all elements are correct type!
4109 std::vector<Constant*> Elems;
4110 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4111 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4112 const Type* ValTy = C->getType();
4113 if (ETy != ValTy)
4114 error("Element #" + utostr(i) + " is not of type '" +
4115 ETy->getDescription() +"' as required!\nIt is of type '"+
4116 ValTy->getDescription() + "'");
4117 Elems.push_back(C);
4118 }
4119 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4120 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4121 delete (yyvsp[-3].TypeVal).T;
4122 delete (yyvsp[-1].ConstVector);
4123 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004124 break;
4125
4126 case 146:
Reid Spencer38f682b2007-01-26 20:31:18 +00004127#line 1849 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004128 {
Reid Spencer950bf602007-01-26 08:19:09 +00004129 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
4130 if (ATy == 0)
4131 error("Cannot make array constant with type: '" +
4132 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4133 int NumElements = ATy->getNumElements();
4134 if (NumElements != -1 && NumElements != 0)
4135 error("Type mismatch: constant sized array initialized with 0"
4136 " arguments, but has size of " + itostr(NumElements) +"");
4137 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4138 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4139 delete (yyvsp[-2].TypeVal).T;
4140 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004141 break;
4142
4143 case 147:
Reid Spencer38f682b2007-01-26 20:31:18 +00004144#line 1862 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004145 {
Reid Spencer950bf602007-01-26 08:19:09 +00004146 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
4147 if (ATy == 0)
4148 error("Cannot make array constant with type: '" +
4149 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4150 int NumElements = ATy->getNumElements();
4151 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4152 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4153 error("String arrays require type i8, not '" + ETy->getDescription() +
4154 "'");
4155 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4156 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
4157 error("Can't build string constant of size " +
4158 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
4159 itostr(NumElements) + "");
4160 std::vector<Constant*> Vals;
4161 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
4162 Vals.push_back(ConstantInt::get(ETy, *C));
4163 free((yyvsp[0].StrVal));
4164 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4165 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4166 delete (yyvsp[-2].TypeVal).T;
4167 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004168 break;
4169
4170 case 148:
Reid Spencer38f682b2007-01-26 20:31:18 +00004171#line 1885 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004172 { // Nonempty unsized arr
Reid Spencer950bf602007-01-26 08:19:09 +00004173 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).T->get());
4174 if (PTy == 0)
4175 error("Cannot make packed constant with type: '" +
4176 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4177 const Type *ETy = PTy->getElementType();
4178 int NumElements = PTy->getNumElements();
4179 // Verify that we have the correct size...
4180 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4181 error("Type mismatch: constant sized packed initialized with " +
4182 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4183 itostr(NumElements) + "");
4184 // Verify all elements are correct type!
4185 std::vector<Constant*> Elems;
4186 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4187 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4188 const Type* ValTy = C->getType();
4189 if (ETy != ValTy)
4190 error("Element #" + utostr(i) + " is not of type '" +
4191 ETy->getDescription() +"' as required!\nIt is of type '"+
4192 ValTy->getDescription() + "'");
4193 Elems.push_back(C);
4194 }
4195 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
4196 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4197 delete (yyvsp[-3].TypeVal).T;
4198 delete (yyvsp[-1].ConstVector);
4199 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004200 break;
4201
4202 case 149:
Reid Spencer38f682b2007-01-26 20:31:18 +00004203#line 1913 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004204 {
Reid Spencer950bf602007-01-26 08:19:09 +00004205 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).T->get());
4206 if (STy == 0)
4207 error("Cannot make struct constant with type: '" +
4208 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4209 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
4210 error("Illegal number of initializers for structure type");
4211
4212 // Check to ensure that constants are compatible with the type initializer!
4213 std::vector<Constant*> Fields;
4214 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4215 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4216 if (C->getType() != STy->getElementType(i))
4217 error("Expected type '" + STy->getElementType(i)->getDescription() +
4218 "' for element #" + utostr(i) + " of structure initializer");
4219 Fields.push_back(C);
4220 }
4221 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4222 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4223 delete (yyvsp[-3].TypeVal).T;
4224 delete (yyvsp[-1].ConstVector);
4225 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004226 break;
4227
4228 case 150:
Reid Spencer38f682b2007-01-26 20:31:18 +00004229#line 1935 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004230 {
Reid Spencer950bf602007-01-26 08:19:09 +00004231 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).T->get());
4232 if (STy == 0)
4233 error("Cannot make struct constant with type: '" +
4234 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4235 if (STy->getNumContainedTypes() != 0)
4236 error("Illegal number of initializers for structure type");
4237 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4238 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4239 delete (yyvsp[-2].TypeVal).T;
4240 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004241 break;
4242
4243 case 151:
Reid Spencer38f682b2007-01-26 20:31:18 +00004244#line 1946 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004245 {
Reid Spencer950bf602007-01-26 08:19:09 +00004246 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).T->get());
4247 if (STy == 0)
4248 error("Cannot make packed struct constant with type: '" +
4249 (yyvsp[-5].TypeVal).T->get()->getDescription() + "'");
4250 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
4251 error("Illegal number of initializers for packed structure type");
4252
4253 // Check to ensure that constants are compatible with the type initializer!
4254 std::vector<Constant*> Fields;
4255 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4256 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
4257 if (C->getType() != STy->getElementType(i))
4258 error("Expected type '" + STy->getElementType(i)->getDescription() +
4259 "' for element #" + utostr(i) + " of packed struct initializer");
4260 Fields.push_back(C);
4261 }
4262 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4263 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4264 delete (yyvsp[-5].TypeVal).T;
4265 delete (yyvsp[-2].ConstVector);
4266 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004267 break;
4268
4269 case 152:
Reid Spencer38f682b2007-01-26 20:31:18 +00004270#line 1968 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004271 {
Reid Spencer950bf602007-01-26 08:19:09 +00004272 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).T->get());
4273 if (STy == 0)
4274 error("Cannot make packed struct constant with type: '" +
4275 (yyvsp[-4].TypeVal).T->get()->getDescription() + "'");
4276 if (STy->getNumContainedTypes() != 0)
4277 error("Illegal number of initializers for packed structure type");
4278 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4279 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4280 delete (yyvsp[-4].TypeVal).T;
4281 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004282 break;
4283
4284 case 153:
Reid Spencer38f682b2007-01-26 20:31:18 +00004285#line 1979 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004286 {
Reid Spencer950bf602007-01-26 08:19:09 +00004287 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
4288 if (PTy == 0)
4289 error("Cannot make null pointer constant with type: '" +
4290 (yyvsp[-1].TypeVal).T->get()->getDescription() + "'");
4291 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4292 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4293 delete (yyvsp[-1].TypeVal).T;
4294 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004295 break;
4296
4297 case 154:
Reid Spencer38f682b2007-01-26 20:31:18 +00004298#line 1988 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004299 {
Reid Spencer950bf602007-01-26 08:19:09 +00004300 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).T->get());
4301 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4302 delete (yyvsp[-1].TypeVal).T;
4303 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004304 break;
4305
4306 case 155:
Reid Spencer38f682b2007-01-26 20:31:18 +00004307#line 1993 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004308 {
Reid Spencer950bf602007-01-26 08:19:09 +00004309 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
4310 if (Ty == 0)
4311 error("Global const reference must be a pointer type, not" +
4312 (yyvsp[-1].TypeVal).T->get()->getDescription());
4313
4314 // ConstExprs can exist in the body of a function, thus creating
4315 // GlobalValues whenever they refer to a variable. Because we are in
4316 // the context of a function, getExistingValue will search the functions
4317 // symbol table instead of the module symbol table for the global symbol,
4318 // which throws things all off. To get around this, we just tell
4319 // getExistingValue that we are at global scope here.
4320 //
4321 Function *SavedCurFn = CurFun.CurrentFunction;
4322 CurFun.CurrentFunction = 0;
4323 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
4324 CurFun.CurrentFunction = SavedCurFn;
4325
4326 // If this is an initializer for a constant pointer, which is referencing a
4327 // (currently) undefined variable, create a stub now that shall be replaced
4328 // in the future with the right type of variable.
4329 //
4330 if (V == 0) {
4331 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4332 const PointerType *PT = cast<PointerType>(Ty);
4333
4334 // First check to see if the forward references value is already created!
4335 PerModuleInfo::GlobalRefsType::iterator I =
4336 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
4337
4338 if (I != CurModule.GlobalRefs.end()) {
4339 V = I->second; // Placeholder already exists, use it...
4340 (yyvsp[0].ValIDVal).destroy();
4341 } else {
4342 std::string Name;
4343 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
4344
4345 // Create the forward referenced global.
4346 GlobalValue *GV;
4347 if (const FunctionType *FTy =
4348 dyn_cast<FunctionType>(PT->getElementType())) {
4349 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4350 CurModule.CurrentModule);
4351 } else {
4352 GV = new GlobalVariable(PT->getElementType(), false,
4353 GlobalValue::ExternalLinkage, 0,
4354 Name, CurModule.CurrentModule);
4355 }
4356
4357 // Keep track of the fact that we have a forward ref to recycle it
4358 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
4359 V = GV;
4360 }
4361 }
4362 (yyval.ConstVal).C = cast<GlobalValue>(V);
4363 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4364 delete (yyvsp[-1].TypeVal).T; // Free the type handle
4365 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004366 break;
4367
4368 case 156:
Reid Spencer38f682b2007-01-26 20:31:18 +00004369#line 2051 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004370 {
4371 if ((yyvsp[-1].TypeVal).T->get() != (yyvsp[0].ConstVal).C->getType())
4372 error("Mismatched types for constant expression");
4373 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4374 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4375 delete (yyvsp[-1].TypeVal).T;
4376 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004377 break;
4378
4379 case 157:
Reid Spencer38f682b2007-01-26 20:31:18 +00004380#line 2058 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004381 {
4382 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
4383 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4384 error("Cannot create a null initialized value of this type");
4385 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4386 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4387 delete (yyvsp[-1].TypeVal).T;
4388 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004389 break;
4390
4391 case 158:
Reid Spencer38f682b2007-01-26 20:31:18 +00004392#line 2066 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004393 { // integral constants
4394 const Type *Ty = (yyvsp[-1].PrimType).T;
4395 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
4396 error("Constant value doesn't fit in type");
4397 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
4398 (yyval.ConstVal).S = Signed;
4399 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004400 break;
4401
4402 case 159:
Reid Spencer38f682b2007-01-26 20:31:18 +00004403#line 2073 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004404 { // integral constants
4405 const Type *Ty = (yyvsp[-1].PrimType).T;
4406 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
4407 error("Constant value doesn't fit in type");
4408 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
4409 (yyval.ConstVal).S = Unsigned;
4410 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004411 break;
4412
4413 case 160:
Reid Spencer38f682b2007-01-26 20:31:18 +00004414#line 2080 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004415 { // Boolean constants
4416 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4417 (yyval.ConstVal).S = Unsigned;
4418 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004419 break;
4420
4421 case 161:
Reid Spencer38f682b2007-01-26 20:31:18 +00004422#line 2084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004423 { // Boolean constants
4424 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4425 (yyval.ConstVal).S = Unsigned;
4426 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004427 break;
4428
4429 case 162:
Reid Spencer38f682b2007-01-26 20:31:18 +00004430#line 2088 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004431 { // Float & Double constants
4432 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
4433 error("Floating point constant invalid for type");
4434 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
4435 (yyval.ConstVal).S = Signless;
4436 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004437 break;
4438
4439 case 163:
Reid Spencer38f682b2007-01-26 20:31:18 +00004440#line 2097 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004441 {
Reid Spencer950bf602007-01-26 08:19:09 +00004442 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4443 const Type* DstTy = (yyvsp[-1].TypeVal).T->get();
4444 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4445 Signedness DstSign = (yyvsp[-1].TypeVal).S;
4446 if (!SrcTy->isFirstClassType())
4447 error("cast constant expression from a non-primitive type: '" +
4448 SrcTy->getDescription() + "'");
4449 if (!DstTy->isFirstClassType())
4450 error("cast constant expression to a non-primitive type: '" +
4451 DstTy->getDescription() + "'");
4452 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
4453 (yyval.ConstVal).S = DstSign;
4454 delete (yyvsp[-1].TypeVal).T;
4455 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004456 break;
4457
4458 case 164:
Reid Spencer38f682b2007-01-26 20:31:18 +00004459#line 2112 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004460 {
Reid Spencer950bf602007-01-26 08:19:09 +00004461 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
4462 if (!isa<PointerType>(Ty))
4463 error("GetElementPtr requires a pointer operand");
4464
4465 std::vector<Value*> VIndices;
4466 std::vector<Constant*> CIndices;
4467 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
4468
4469 delete (yyvsp[-1].ValueList);
4470 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
4471 (yyval.ConstVal).S = Signless;
4472 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004473 break;
4474
4475 case 165:
Reid Spencer38f682b2007-01-26 20:31:18 +00004476#line 2125 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004477 {
Reid Spencer950bf602007-01-26 08:19:09 +00004478 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4479 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
4480 error("Select condition must be bool type");
4481 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4482 error("Select operand types must match");
4483 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4484 (yyval.ConstVal).S = Unsigned;
4485 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004486 break;
4487
4488 case 166:
Reid Spencer38f682b2007-01-26 20:31:18 +00004489#line 2134 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004490 {
Reid Spencer950bf602007-01-26 08:19:09 +00004491 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4492 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4493 error("Binary operator types must match");
4494 // First, make sure we're dealing with the right opcode by upgrading from
4495 // obsolete versions.
4496 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4497
4498 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4499 // To retain backward compatibility with these early compilers, we emit a
4500 // cast to the appropriate integer type automatically if we are in the
4501 // broken case. See PR424 for more information.
4502 if (!isa<PointerType>(Ty)) {
4503 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4504 } else {
4505 const Type *IntPtrTy = 0;
4506 switch (CurModule.CurrentModule->getPointerSize()) {
4507 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4508 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4509 default: error("invalid pointer binary constant expr");
4510 }
4511 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4512 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4513 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4514 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4515 }
4516 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4517 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004518 break;
4519
4520 case 167:
Reid Spencer38f682b2007-01-26 20:31:18 +00004521#line 2162 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004522 {
Reid Spencer950bf602007-01-26 08:19:09 +00004523 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4524 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4525 error("Logical operator types must match");
4526 if (!Ty->isInteger()) {
4527 if (!isa<PackedType>(Ty) ||
4528 !cast<PackedType>(Ty)->getElementType()->isInteger())
4529 error("Logical operator requires integer operands");
4530 }
4531 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4532 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4533 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4534 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004535 break;
4536
4537 case 168:
Reid Spencer38f682b2007-01-26 20:31:18 +00004538#line 2175 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004539 {
Reid Spencer950bf602007-01-26 08:19:09 +00004540 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4541 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4542 error("setcc operand types must match");
4543 unsigned short pred;
4544 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4545 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4546 (yyval.ConstVal).S = Unsigned;
4547 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004548 break;
4549
4550 case 169:
Reid Spencer38f682b2007-01-26 20:31:18 +00004551#line 2184 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004552 {
Reid Spencer950bf602007-01-26 08:19:09 +00004553 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4554 error("icmp operand types must match");
4555 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4556 (yyval.ConstVal).S = Unsigned;
4557 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004558 break;
4559
4560 case 170:
Reid Spencer38f682b2007-01-26 20:31:18 +00004561#line 2190 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004562 {
Reid Spencer950bf602007-01-26 08:19:09 +00004563 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4564 error("fcmp operand types must match");
4565 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4566 (yyval.ConstVal).S = Unsigned;
4567 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004568 break;
4569
4570 case 171:
Reid Spencer38f682b2007-01-26 20:31:18 +00004571#line 2196 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004572 {
Reid Spencer950bf602007-01-26 08:19:09 +00004573 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4574 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
4575 error("Shift count for shift constant must be unsigned byte");
4576 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
4577 error("Shift constant expression requires integer operand");
4578 (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4579 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4580 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004581 break;
4582
4583 case 172:
Reid Spencer38f682b2007-01-26 20:31:18 +00004584#line 2205 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004585 {
Reid Spencer950bf602007-01-26 08:19:09 +00004586 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4587 error("Invalid extractelement operands");
4588 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4589 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4590 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004591 break;
4592
4593 case 173:
Reid Spencer38f682b2007-01-26 20:31:18 +00004594#line 2211 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004595 {
Reid Spencer950bf602007-01-26 08:19:09 +00004596 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4597 error("Invalid insertelement operands");
4598 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4599 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4600 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004601 break;
4602
4603 case 174:
Reid Spencer38f682b2007-01-26 20:31:18 +00004604#line 2217 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004605 {
4606 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4607 error("Invalid shufflevector operands");
4608 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4609 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4610 ;}
4611 break;
4612
4613 case 175:
Reid Spencer38f682b2007-01-26 20:31:18 +00004614#line 2228 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004615 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
4616 break;
4617
4618 case 176:
Reid Spencer38f682b2007-01-26 20:31:18 +00004619#line 2229 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004620 {
4621 (yyval.ConstVector) = new std::vector<ConstInfo>();
4622 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4623 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004624 break;
4625
4626 case 177:
Reid Spencer38f682b2007-01-26 20:31:18 +00004627#line 2238 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004628 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004629 break;
4630
4631 case 178:
Reid Spencer38f682b2007-01-26 20:31:18 +00004632#line 2239 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004633 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004634 break;
4635
4636 case 179:
Reid Spencer38f682b2007-01-26 20:31:18 +00004637#line 2251 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004638 {
Reid Spencer950bf602007-01-26 08:19:09 +00004639 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
4640 CurModule.ModuleDone();
4641 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004642 break;
4643
4644 case 180:
Reid Spencer38f682b2007-01-26 20:31:18 +00004645#line 2260 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004646 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004647 break;
4648
4649 case 181:
Reid Spencer38f682b2007-01-26 20:31:18 +00004650#line 2261 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004651 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004652 break;
4653
4654 case 182:
Reid Spencer38f682b2007-01-26 20:31:18 +00004655#line 2262 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004656 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
4657 break;
4658
4659 case 183:
Reid Spencer38f682b2007-01-26 20:31:18 +00004660#line 2263 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004661 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004662 break;
4663
4664 case 184:
Reid Spencer38f682b2007-01-26 20:31:18 +00004665#line 2264 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004666 {
4667 (yyval.ModuleVal) = CurModule.CurrentModule;
4668 // Emit an error if there are any unresolved types left.
4669 if (!CurModule.LateResolveTypes.empty()) {
4670 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4671 if (DID.Type == ValID::NameVal) {
4672 error("Reference to an undefined type: '"+DID.getName() + "'");
4673 } else {
4674 error("Reference to an undefined type: #" + itostr(DID.Num));
4675 }
4676 }
4677 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004678 break;
4679
4680 case 185:
Reid Spencer38f682b2007-01-26 20:31:18 +00004681#line 2280 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004682 {
Reid Spencer950bf602007-01-26 08:19:09 +00004683 // Eagerly resolve types. This is not an optimization, this is a
4684 // requirement that is due to the fact that we could have this:
4685 //
4686 // %list = type { %list * }
4687 // %list = type { %list * } ; repeated type decl
4688 //
4689 // If types are not resolved eagerly, then the two types will not be
4690 // determined to be the same type!
4691 //
4692 const Type* Ty = (yyvsp[0].TypeVal).T->get();
4693 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
4694
4695 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
4696 // If this is a named type that is not a redefinition, add it to the slot
4697 // table.
4698 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004699 }
Reid Spencer950bf602007-01-26 08:19:09 +00004700 delete (yyvsp[0].TypeVal).T;
4701 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004702 break;
4703
4704 case 186:
Reid Spencer38f682b2007-01-26 20:31:18 +00004705#line 2300 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004706 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004707 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004708 break;
4709
4710 case 187:
Reid Spencer38f682b2007-01-26 20:31:18 +00004711#line 2302 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004712 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004713 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004714 break;
4715
4716 case 188:
Reid Spencer38f682b2007-01-26 20:31:18 +00004717#line 2304 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004718 {
Reid Spencer950bf602007-01-26 08:19:09 +00004719 if ((yyvsp[0].ConstVal).C == 0)
4720 error("Global value initializer is not a constant");
4721 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C);
4722 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004723 break;
4724
4725 case 189:
Reid Spencer38f682b2007-01-26 20:31:18 +00004726#line 2308 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004727 {
Reid Spencer950bf602007-01-26 08:19:09 +00004728 CurGV = 0;
4729 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004730 break;
4731
4732 case 190:
Reid Spencer38f682b2007-01-26 20:31:18 +00004733#line 2311 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004734 {
Reid Spencer950bf602007-01-26 08:19:09 +00004735 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4736 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4737 delete (yyvsp[0].TypeVal).T;
4738 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004739 break;
4740
4741 case 191:
Reid Spencer38f682b2007-01-26 20:31:18 +00004742#line 2315 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004743 {
Reid Spencer950bf602007-01-26 08:19:09 +00004744 CurGV = 0;
4745 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004746 break;
4747
4748 case 192:
Reid Spencer38f682b2007-01-26 20:31:18 +00004749#line 2318 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004750 {
4751 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4752 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4753 delete (yyvsp[0].TypeVal).T;
4754 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004755 break;
4756
4757 case 193:
Reid Spencer38f682b2007-01-26 20:31:18 +00004758#line 2322 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004759 {
Reid Spencer950bf602007-01-26 08:19:09 +00004760 CurGV = 0;
4761 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004762 break;
4763
4764 case 194:
Reid Spencer38f682b2007-01-26 20:31:18 +00004765#line 2325 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004766 {
4767 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4768 CurGV =
4769 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4770 delete (yyvsp[0].TypeVal).T;
4771 ;}
4772 break;
4773
4774 case 195:
Reid Spencer38f682b2007-01-26 20:31:18 +00004775#line 2330 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004776 {
4777 CurGV = 0;
4778 ;}
4779 break;
4780
4781 case 196:
Reid Spencer38f682b2007-01-26 20:31:18 +00004782#line 2333 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004783 {
Reid Spencer950bf602007-01-26 08:19:09 +00004784 ;}
4785 break;
4786
4787 case 197:
Reid Spencer38f682b2007-01-26 20:31:18 +00004788#line 2335 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004789 {
4790 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004791 break;
4792
4793 case 198:
Reid Spencer38f682b2007-01-26 20:31:18 +00004794#line 2337 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004795 {
4796 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004797 break;
4798
4799 case 199:
Reid Spencer38f682b2007-01-26 20:31:18 +00004800#line 2342 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004801 {
Reid Spencer950bf602007-01-26 08:19:09 +00004802 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4803 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4804 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4805 free((yyvsp[0].StrVal));
4806
4807 if (AsmSoFar.empty())
4808 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4809 else
4810 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4811 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004812 break;
4813
4814 case 200:
Reid Spencer38f682b2007-01-26 20:31:18 +00004815#line 2356 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004816 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004817 break;
4818
4819 case 201:
Reid Spencer38f682b2007-01-26 20:31:18 +00004820#line 2357 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004821 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004822 break;
4823
4824 case 202:
Reid Spencer38f682b2007-01-26 20:31:18 +00004825#line 2361 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004826 {
Reid Spencer950bf602007-01-26 08:19:09 +00004827 CurModule.setEndianness((yyvsp[0].Endianness));
4828 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004829 break;
4830
4831 case 203:
Reid Spencer38f682b2007-01-26 20:31:18 +00004832#line 2364 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004833 {
Reid Spencer950bf602007-01-26 08:19:09 +00004834 if ((yyvsp[0].UInt64Val) == 32)
4835 CurModule.setPointerSize(Module::Pointer32);
4836 else if ((yyvsp[0].UInt64Val) == 64)
4837 CurModule.setPointerSize(Module::Pointer64);
4838 else
4839 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
4840 ;}
4841 break;
4842
4843 case 204:
Reid Spencer38f682b2007-01-26 20:31:18 +00004844#line 2372 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004845 {
4846 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4847 free((yyvsp[0].StrVal));
4848 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004849 break;
4850
4851 case 205:
Reid Spencer38f682b2007-01-26 20:31:18 +00004852#line 2376 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004853 {
Reid Spencer950bf602007-01-26 08:19:09 +00004854 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4855 free((yyvsp[0].StrVal));
4856 ;}
4857 break;
4858
4859 case 207:
Reid Spencer38f682b2007-01-26 20:31:18 +00004860#line 2387 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004861 {
4862 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4863 free((yyvsp[0].StrVal));
4864 ;}
4865 break;
4866
4867 case 208:
Reid Spencer38f682b2007-01-26 20:31:18 +00004868#line 2391 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004869 {
4870 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4871 free((yyvsp[0].StrVal));
4872 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004873 break;
4874
4875 case 209:
Reid Spencer38f682b2007-01-26 20:31:18 +00004876#line 2395 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004877 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004878 break;
4879
Reid Spencerc4d96252007-01-13 00:03:30 +00004880 case 213:
Reid Spencer38f682b2007-01-26 20:31:18 +00004881#line 2408 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004882 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004883 break;
4884
Reid Spencer319a7302007-01-05 17:20:02 +00004885 case 214:
Reid Spencer38f682b2007-01-26 20:31:18 +00004886#line 2412 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004887 {
Reid Spencer950bf602007-01-26 08:19:09 +00004888 if ((yyvsp[-1].TypeVal).T->get() == Type::VoidTy)
4889 error("void typed arguments are invalid");
4890 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
4891 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004892 break;
4893
4894 case 215:
Reid Spencer38f682b2007-01-26 20:31:18 +00004895#line 2420 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004896 {
Reid Spencer950bf602007-01-26 08:19:09 +00004897 (yyval.ArgList) = (yyvsp[-2].ArgList);
4898 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4899 delete (yyvsp[0].ArgVal);
4900 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004901 break;
4902
4903 case 216:
Reid Spencer38f682b2007-01-26 20:31:18 +00004904#line 2425 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004905 {
4906 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
4907 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4908 delete (yyvsp[0].ArgVal);
4909 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004910 break;
4911
4912 case 217:
Reid Spencer38f682b2007-01-26 20:31:18 +00004913#line 2433 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004914 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004915 break;
4916
4917 case 218:
Reid Spencer38f682b2007-01-26 20:31:18 +00004918#line 2434 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004919 {
4920 (yyval.ArgList) = (yyvsp[-2].ArgList);
4921 PATypeInfo VoidTI;
4922 VoidTI.T = new PATypeHolder(Type::VoidTy);
4923 VoidTI.S = Signless;
4924 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4925 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004926 break;
4927
4928 case 219:
Reid Spencer38f682b2007-01-26 20:31:18 +00004929#line 2441 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004930 {
4931 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
4932 PATypeInfo VoidTI;
4933 VoidTI.T = new PATypeHolder(Type::VoidTy);
4934 VoidTI.S = Signless;
4935 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4936 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004937 break;
4938
4939 case 220:
Reid Spencer38f682b2007-01-26 20:31:18 +00004940#line 2448 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004941 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004942 break;
4943
4944 case 221:
Reid Spencer38f682b2007-01-26 20:31:18 +00004945#line 2452 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004946 {
Reid Spencer950bf602007-01-26 08:19:09 +00004947 UnEscapeLexed((yyvsp[-5].StrVal));
4948 std::string FunctionName((yyvsp[-5].StrVal));
4949 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
4950
4951 const Type* RetTy = (yyvsp[-6].TypeVal).T->get();
4952
4953 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
4954 error("LLVM functions cannot return aggregate types");
4955
4956 std::vector<const Type*> ParamTypeList;
4957
4958 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
4959 // i8*. We check here for those names and override the parameter list
4960 // types to ensure the prototype is correct.
4961 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
4962 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
4963 } else if (FunctionName == "llvm.va_copy") {
4964 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
4965 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
4966 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
4967 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
4968 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
4969 const Type *Ty = I->first.T->get();
4970 ParamTypeList.push_back(Ty);
4971 }
4972 }
4973
4974 bool isVarArg =
4975 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4976 if (isVarArg) ParamTypeList.pop_back();
4977
4978 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
4979 const PointerType *PFT = PointerType::get(FT);
4980 delete (yyvsp[-6].TypeVal).T;
4981
4982 ValID ID;
4983 if (!FunctionName.empty()) {
4984 ID = ValID::create((char*)FunctionName.c_str());
4985 } else {
4986 ID = ValID::create((int)CurModule.Values[PFT].size());
4987 }
4988
4989 Function *Fn = 0;
4990 // See if this function was forward referenced. If so, recycle the object.
4991 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4992 // Move the function to the end of the list, from whereever it was
4993 // previously inserted.
4994 Fn = cast<Function>(FWRef);
4995 CurModule.CurrentModule->getFunctionList().remove(Fn);
4996 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4997 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4998 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4999 // If this is the case, either we need to be a forward decl, or it needs
5000 // to be.
5001 if (!CurFun.isDeclare && !Fn->isExternal())
5002 error("Redefinition of function '" + FunctionName + "'");
5003
5004 // Make sure to strip off any argument names so we can't get conflicts.
5005 if (Fn->isExternal())
5006 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5007 AI != AE; ++AI)
5008 AI->setName("");
5009 } else { // Not already defined?
5010 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5011 CurModule.CurrentModule);
5012
5013 InsertValue(Fn, CurModule.Values);
5014 }
5015
5016 CurFun.FunctionStart(Fn);
5017
5018 if (CurFun.isDeclare) {
5019 // If we have declaration, always overwrite linkage. This will allow us
5020 // to correctly handle cases, when pointer to function is passed as
5021 // argument to another function.
5022 Fn->setLinkage(CurFun.Linkage);
5023 }
5024 Fn->setCallingConv((yyvsp[-7].UIntVal));
5025 Fn->setAlignment((yyvsp[0].UIntVal));
5026 if ((yyvsp[-1].StrVal)) {
5027 Fn->setSection((yyvsp[-1].StrVal));
5028 free((yyvsp[-1].StrVal));
5029 }
5030
5031 // Add all of the arguments we parsed to the function...
5032 if ((yyvsp[-3].ArgList)) { // Is null if empty...
5033 if (isVarArg) { // Nuke the last entry
5034 assert((yyvsp[-3].ArgList)->back().first.T->get() == Type::VoidTy &&
5035 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5036 delete (yyvsp[-3].ArgList)->back().first.T;
5037 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
5038 }
5039 Function::arg_iterator ArgIt = Fn->arg_begin();
5040 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5041 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I, ++ArgIt) {
5042 delete I->first.T; // Delete the typeholder...
5043 setValueName(ArgIt, I->second); // Insert arg into symtab...
5044 InsertValue(ArgIt);
5045 }
5046 delete (yyvsp[-3].ArgList); // We're now done with the argument list
5047 }
5048 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005049 break;
5050
5051 case 224:
Reid Spencer38f682b2007-01-26 20:31:18 +00005052#line 2562 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005053 {
5054 (yyval.FunctionVal) = CurFun.CurrentFunction;
5055
5056 // Make sure that we keep track of the linkage type even if there was a
5057 // previous "declare".
5058 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
5059 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005060 break;
5061
5062 case 227:
Reid Spencer38f682b2007-01-26 20:31:18 +00005063#line 2576 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005064 {
5065 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5066 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005067 break;
5068
5069 case 229:
Reid Spencer38f682b2007-01-26 20:31:18 +00005070#line 2582 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005071 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5072 break;
5073
5074 case 230:
Reid Spencer38f682b2007-01-26 20:31:18 +00005075#line 2583 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005076 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5077 break;
5078
5079 case 231:
Reid Spencer38f682b2007-01-26 20:31:18 +00005080#line 2587 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005081 { CurFun.isDeclare = true; ;}
5082 break;
5083
5084 case 232:
Reid Spencer38f682b2007-01-26 20:31:18 +00005085#line 2587 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005086 {
5087 (yyval.FunctionVal) = CurFun.CurrentFunction;
5088 CurFun.FunctionDone();
5089
5090 ;}
5091 break;
5092
5093 case 233:
Reid Spencer38f682b2007-01-26 20:31:18 +00005094#line 2599 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005095 { (yyval.BoolVal) = false; ;}
5096 break;
5097
5098 case 234:
Reid Spencer38f682b2007-01-26 20:31:18 +00005099#line 2600 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005100 { (yyval.BoolVal) = true; ;}
5101 break;
5102
5103 case 235:
Reid Spencer38f682b2007-01-26 20:31:18 +00005104#line 2605 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005105 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
5106 break;
5107
5108 case 236:
Reid Spencer38f682b2007-01-26 20:31:18 +00005109#line 2606 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005110 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5111 break;
5112
5113 case 237:
Reid Spencer38f682b2007-01-26 20:31:18 +00005114#line 2607 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005115 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5116 break;
5117
5118 case 238:
Reid Spencer38f682b2007-01-26 20:31:18 +00005119#line 2608 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005120 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005121 break;
5122
Reid Spencerc4d96252007-01-13 00:03:30 +00005123 case 239:
Reid Spencer38f682b2007-01-26 20:31:18 +00005124#line 2609 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005125 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5126 break;
5127
5128 case 240:
Reid Spencer38f682b2007-01-26 20:31:18 +00005129#line 2610 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005130 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005131 break;
5132
Reid Spencerc4d96252007-01-13 00:03:30 +00005133 case 241:
Reid Spencer38f682b2007-01-26 20:31:18 +00005134#line 2611 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005135 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5136 break;
5137
5138 case 242:
Reid Spencer38f682b2007-01-26 20:31:18 +00005139#line 2612 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005140 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5141 break;
5142
5143 case 243:
Reid Spencer38f682b2007-01-26 20:31:18 +00005144#line 2613 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005145 { // Nonempty unsized packed vector
5146 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5147 int NumElements = (yyvsp[-1].ConstVector)->size();
5148 PackedType* pt = PackedType::get(ETy, NumElements);
5149 PATypeHolder* PTy = new PATypeHolder(
5150 HandleUpRefs(PackedType::get(ETy, NumElements)));
5151
5152 // Verify all elements are correct type!
5153 std::vector<Constant*> Elems;
5154 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5155 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
5156 const Type *CTy = C->getType();
5157 if (ETy != CTy)
5158 error("Element #" + utostr(i) + " is not of type '" +
5159 ETy->getDescription() +"' as required!\nIt is of type '" +
5160 CTy->getDescription() + "'");
5161 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005162 }
Reid Spencer950bf602007-01-26 08:19:09 +00005163 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
5164 delete PTy; delete (yyvsp[-1].ConstVector);
5165 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005166 break;
5167
Reid Spencerc4d96252007-01-13 00:03:30 +00005168 case 244:
Reid Spencer38f682b2007-01-26 20:31:18 +00005169#line 2634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005170 {
Reid Spencer950bf602007-01-26 08:19:09 +00005171 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
5172 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005173 break;
5174
Reid Spencerc4d96252007-01-13 00:03:30 +00005175 case 245:
Reid Spencer38f682b2007-01-26 20:31:18 +00005176#line 2637 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005177 {
Reid Spencer950bf602007-01-26 08:19:09 +00005178 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5179 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5180 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5181 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5182 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5183 free((yyvsp[-2].StrVal));
5184 free((yyvsp[0].StrVal));
5185 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005186 break;
5187
Reid Spencerc4d96252007-01-13 00:03:30 +00005188 case 246:
Reid Spencer38f682b2007-01-26 20:31:18 +00005189#line 2652 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005190 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005191 break;
5192
Reid Spencer319a7302007-01-05 17:20:02 +00005193 case 247:
Reid Spencer38f682b2007-01-26 20:31:18 +00005194#line 2653 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005195 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005196 break;
5197
5198 case 250:
Reid Spencer38f682b2007-01-26 20:31:18 +00005199#line 2666 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005200 {
5201 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5202 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5203 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5204 delete (yyvsp[-1].TypeVal).T;
5205 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005206 break;
5207
Reid Spencerc4d96252007-01-13 00:03:30 +00005208 case 251:
Reid Spencer38f682b2007-01-26 20:31:18 +00005209#line 2675 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005210 {
Reid Spencer950bf602007-01-26 08:19:09 +00005211 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5212 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005213 break;
5214
Reid Spencerc4d96252007-01-13 00:03:30 +00005215 case 252:
Reid Spencer38f682b2007-01-26 20:31:18 +00005216#line 2678 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005217 { // Do not allow functions with 0 basic blocks
5218 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5219 ;}
5220 break;
5221
5222 case 253:
Reid Spencer38f682b2007-01-26 20:31:18 +00005223#line 2687 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005224 {
Reid Spencer950bf602007-01-26 08:19:09 +00005225 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5226 InsertValue((yyvsp[0].TermInstVal));
5227 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5228 InsertValue((yyvsp[-2].BasicBlockVal));
5229 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5230 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005231 break;
5232
Reid Spencerc4d96252007-01-13 00:03:30 +00005233 case 254:
Reid Spencer38f682b2007-01-26 20:31:18 +00005234#line 2697 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005235 {
5236 if ((yyvsp[0].InstVal).I)
5237 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5238 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5239 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005240 break;
5241
Reid Spencerc4d96252007-01-13 00:03:30 +00005242 case 255:
Reid Spencer38f682b2007-01-26 20:31:18 +00005243#line 2702 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005244 {
5245 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5246 // Make sure to move the basic block to the correct location in the
5247 // function, instead of leaving it inserted wherever it was first
5248 // referenced.
5249 Function::BasicBlockListType &BBL =
5250 CurFun.CurrentFunction->getBasicBlockList();
5251 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5252 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005253 break;
5254
Reid Spencerc4d96252007-01-13 00:03:30 +00005255 case 256:
Reid Spencer38f682b2007-01-26 20:31:18 +00005256#line 2711 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005257 {
5258 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
5259 // Make sure to move the basic block to the correct location in the
5260 // function, instead of leaving it inserted wherever it was first
5261 // referenced.
5262 Function::BasicBlockListType &BBL =
5263 CurFun.CurrentFunction->getBasicBlockList();
5264 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5265 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005266 break;
5267
Reid Spencerc4d96252007-01-13 00:03:30 +00005268 case 259:
Reid Spencer38f682b2007-01-26 20:31:18 +00005269#line 2725 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005270 { // Return with a result...
5271 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
5272 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005273 break;
5274
Reid Spencerc4d96252007-01-13 00:03:30 +00005275 case 260:
Reid Spencer38f682b2007-01-26 20:31:18 +00005276#line 2728 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005277 { // Return with no result...
5278 (yyval.TermInstVal) = new ReturnInst();
5279 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005280 break;
5281
Reid Spencerc4d96252007-01-13 00:03:30 +00005282 case 261:
Reid Spencer38f682b2007-01-26 20:31:18 +00005283#line 2731 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005284 { // Unconditional Branch...
5285 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5286 (yyval.TermInstVal) = new BranchInst(tmpBB);
5287 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005288 break;
5289
Reid Spencer319a7302007-01-05 17:20:02 +00005290 case 262:
Reid Spencer38f682b2007-01-26 20:31:18 +00005291#line 2735 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005292 {
5293 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5294 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5295 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5296 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5297 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005298 break;
5299
5300 case 263:
Reid Spencer38f682b2007-01-26 20:31:18 +00005301#line 2741 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005302 {
Reid Spencer950bf602007-01-26 08:19:09 +00005303 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5304 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5305 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5306 (yyval.TermInstVal) = S;
5307 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5308 E = (yyvsp[-1].JumpTable)->end();
5309 for (; I != E; ++I) {
5310 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5311 S->addCase(CI, I->second);
5312 else
5313 error("Switch case is constant, but not a simple integer");
5314 }
5315 delete (yyvsp[-1].JumpTable);
5316 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005317 break;
5318
5319 case 264:
Reid Spencer38f682b2007-01-26 20:31:18 +00005320#line 2756 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005321 {
Reid Spencer950bf602007-01-26 08:19:09 +00005322 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5323 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
5324 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5325 (yyval.TermInstVal) = S;
5326 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005327 break;
5328
Reid Spencerc4d96252007-01-13 00:03:30 +00005329 case 265:
Reid Spencer38f682b2007-01-26 20:31:18 +00005330#line 2763 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005331 {
Reid Spencer950bf602007-01-26 08:19:09 +00005332 const PointerType *PFTy;
5333 const FunctionType *Ty;
5334
5335 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).T->get())) ||
5336 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5337 // Pull out the types of all of the arguments...
5338 std::vector<const Type*> ParamTypes;
5339 if ((yyvsp[-7].ValueList)) {
5340 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
5341 I != E; ++I)
5342 ParamTypes.push_back((*I).V->getType());
5343 }
5344 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5345 if (isVarArg) ParamTypes.pop_back();
5346 Ty = FunctionType::get((yyvsp[-10].TypeVal).T->get(), ParamTypes, isVarArg);
5347 PFTy = PointerType::get(Ty);
5348 }
5349 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5350 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5351 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
5352
5353 // Create the call node...
5354 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
5355 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5356 } else { // Has arguments?
5357 // Loop through FunctionType's arguments and ensure they are specified
5358 // correctly!
5359 //
5360 FunctionType::param_iterator I = Ty->param_begin();
5361 FunctionType::param_iterator E = Ty->param_end();
5362 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
5363
5364 std::vector<Value*> Args;
5365 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5366 if ((*ArgI).V->getType() != *I)
5367 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5368 (*I)->getDescription() + "'");
5369 Args.push_back((*ArgI).V);
5370 }
5371
5372 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5373 error("Invalid number of parameters detected");
5374
5375 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5376 }
5377 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
5378 delete (yyvsp[-10].TypeVal).T;
5379 delete (yyvsp[-7].ValueList);
5380 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005381 break;
5382
Reid Spencerc4d96252007-01-13 00:03:30 +00005383 case 266:
Reid Spencer38f682b2007-01-26 20:31:18 +00005384#line 2813 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005385 {
Reid Spencer950bf602007-01-26 08:19:09 +00005386 (yyval.TermInstVal) = new UnwindInst();
5387 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005388 break;
5389
Reid Spencerc4d96252007-01-13 00:03:30 +00005390 case 267:
Reid Spencer38f682b2007-01-26 20:31:18 +00005391#line 2816 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005392 {
5393 (yyval.TermInstVal) = new UnreachableInst();
5394 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005395 break;
5396
Reid Spencerc4d96252007-01-13 00:03:30 +00005397 case 268:
Reid Spencer38f682b2007-01-26 20:31:18 +00005398#line 2822 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005399 {
Reid Spencer950bf602007-01-26 08:19:09 +00005400 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5401 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5402
5403 if (V == 0)
5404 error("May only switch on a constant pool value");
5405
5406 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5407 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5408 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005409 break;
5410
Reid Spencerc4d96252007-01-13 00:03:30 +00005411 case 269:
Reid Spencer38f682b2007-01-26 20:31:18 +00005412#line 2832 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005413 {
Reid Spencer950bf602007-01-26 08:19:09 +00005414 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5415 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5416
5417 if (V == 0)
5418 error("May only switch on a constant pool value");
5419
5420 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5421 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5422 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005423 break;
5424
Reid Spencerc4d96252007-01-13 00:03:30 +00005425 case 270:
Reid Spencer38f682b2007-01-26 20:31:18 +00005426#line 2845 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005427 {
Reid Spencer950bf602007-01-26 08:19:09 +00005428 bool omit = false;
5429 if ((yyvsp[-1].StrVal))
5430 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
5431 if (BCI->getSrcTy() == BCI->getDestTy() &&
5432 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
5433 // This is a useless bit cast causing a name redefinition. It is
5434 // a bit cast from a type to the same type of an operand with the
5435 // same name as the name we would give this instruction. Since this
5436 // instruction results in no code generation, it is safe to omit
5437 // the instruction. This situation can occur because of collapsed
5438 // type planes. For example:
5439 // %X = add int %Y, %Z
5440 // %X = cast int %Y to uint
5441 // After upgrade, this looks like:
5442 // %X = add i32 %Y, %Z
5443 // %X = bitcast i32 to i32
5444 // The bitcast is clearly useless so we omit it.
5445 omit = true;
5446 if (omit) {
5447 (yyval.InstVal).I = 0;
5448 (yyval.InstVal).S = Signless;
5449 } else {
5450 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5451 InsertValue((yyvsp[0].InstVal).I);
5452 (yyval.InstVal) = (yyvsp[0].InstVal);
5453 }
5454 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005455 break;
5456
Reid Spencerc4d96252007-01-13 00:03:30 +00005457 case 271:
Reid Spencer38f682b2007-01-26 20:31:18 +00005458#line 2874 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005459 { // Used for PHI nodes
5460 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5461 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5462 Value* tmpVal = getVal((yyvsp[-5].TypeVal).T->get(), (yyvsp[-3].ValIDVal));
5463 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5464 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5465 delete (yyvsp[-5].TypeVal).T;
5466 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005467 break;
5468
Reid Spencerc4d96252007-01-13 00:03:30 +00005469 case 272:
Reid Spencer38f682b2007-01-26 20:31:18 +00005470#line 2882 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005471 {
5472 (yyval.PHIList) = (yyvsp[-6].PHIList);
5473 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5474 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5475 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5476 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005477 break;
5478
Reid Spencerc4d96252007-01-13 00:03:30 +00005479 case 273:
Reid Spencer38f682b2007-01-26 20:31:18 +00005480#line 2890 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005481 { // Used for call statements, and memory insts...
5482 (yyval.ValueList) = new std::vector<ValueInfo>();
5483 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5484 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005485 break;
5486
Reid Spencer950bf602007-01-26 08:19:09 +00005487 case 274:
Reid Spencer38f682b2007-01-26 20:31:18 +00005488#line 2894 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005489 {
Reid Spencer950bf602007-01-26 08:19:09 +00005490 (yyval.ValueList) = (yyvsp[-2].ValueList);
5491 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
5492 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005493 break;
5494
Reid Spencerc4d96252007-01-13 00:03:30 +00005495 case 276:
Reid Spencer38f682b2007-01-26 20:31:18 +00005496#line 2902 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005497 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005498 break;
5499
Reid Spencerc4d96252007-01-13 00:03:30 +00005500 case 277:
Reid Spencer38f682b2007-01-26 20:31:18 +00005501#line 2906 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005502 {
Reid Spencer950bf602007-01-26 08:19:09 +00005503 (yyval.BoolVal) = true;
5504 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005505 break;
5506
Reid Spencer319a7302007-01-05 17:20:02 +00005507 case 278:
Reid Spencer38f682b2007-01-26 20:31:18 +00005508#line 2909 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005509 {
Reid Spencer950bf602007-01-26 08:19:09 +00005510 (yyval.BoolVal) = false;
5511 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005512 break;
5513
5514 case 279:
Reid Spencer38f682b2007-01-26 20:31:18 +00005515#line 2915 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005516 {
Reid Spencer950bf602007-01-26 08:19:09 +00005517 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
5518 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5519 error("Arithmetic operator requires integer, FP, or packed operands");
5520 if (isa<PackedType>(Ty) &&
5521 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
5522 error("Remainder not supported on packed types");
5523 // Upgrade the opcode from obsolete versions before we do anything with it.
5524 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5525 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5526 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
5527 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5528 if ((yyval.InstVal).I == 0)
5529 error("binary operator returned null");
5530 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5531 delete (yyvsp[-3].TypeVal).T;
5532 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005533 break;
5534
5535 case 280:
Reid Spencer38f682b2007-01-26 20:31:18 +00005536#line 2932 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005537 {
Reid Spencer950bf602007-01-26 08:19:09 +00005538 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5539 if (!Ty->isInteger()) {
5540 if (!isa<PackedType>(Ty) ||
5541 !cast<PackedType>(Ty)->getElementType()->isInteger())
5542 error("Logical operator requires integral operands");
5543 }
5544 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5545 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5546 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5547 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5548 if ((yyval.InstVal).I == 0)
5549 error("binary operator returned null");
5550 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5551 delete (yyvsp[-3].TypeVal).T;
5552 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005553 break;
5554
Reid Spencerc4d96252007-01-13 00:03:30 +00005555 case 281:
Reid Spencer38f682b2007-01-26 20:31:18 +00005556#line 2948 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005557 {
Reid Spencer950bf602007-01-26 08:19:09 +00005558 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
5559 if(isa<PackedType>(Ty))
5560 error("PackedTypes currently not supported in setcc instructions");
5561 unsigned short pred;
5562 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5563 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5564 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5565 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5566 if ((yyval.InstVal).I == 0)
5567 error("binary operator returned null");
5568 (yyval.InstVal).S = Unsigned;
5569 delete (yyvsp[-3].TypeVal).T;
5570 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005571 break;
5572
Reid Spencerc4d96252007-01-13 00:03:30 +00005573 case 282:
Reid Spencer38f682b2007-01-26 20:31:18 +00005574#line 2962 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005575 {
Reid Spencer950bf602007-01-26 08:19:09 +00005576 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5577 if (isa<PackedType>(Ty))
5578 error("PackedTypes currently not supported in icmp instructions");
5579 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5580 error("icmp requires integer or pointer typed operands");
5581 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5582 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5583 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
5584 (yyval.InstVal).S = Unsigned;
5585 delete (yyvsp[-3].TypeVal).T;
5586 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005587 break;
5588
Reid Spencerc4d96252007-01-13 00:03:30 +00005589 case 283:
Reid Spencer38f682b2007-01-26 20:31:18 +00005590#line 2974 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005591 {
Reid Spencer950bf602007-01-26 08:19:09 +00005592 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5593 if (isa<PackedType>(Ty))
5594 error("PackedTypes currently not supported in fcmp instructions");
5595 else if (!Ty->isFloatingPoint())
5596 error("fcmp instruction requires floating point operands");
5597 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5598 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5599 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
5600 (yyval.InstVal).S = Unsigned;
5601 delete (yyvsp[-3].TypeVal).T;
5602 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005603 break;
5604
Reid Spencerc4d96252007-01-13 00:03:30 +00005605 case 284:
Reid Spencer38f682b2007-01-26 20:31:18 +00005606#line 2986 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005607 {
Reid Spencer950bf602007-01-26 08:19:09 +00005608 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5609 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
5610 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5611 if (Ones == 0)
5612 error("Expected integral type for not instruction");
5613 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
5614 if ((yyval.InstVal).I == 0)
5615 error("Could not create a xor instruction");
5616 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
5617 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005618 break;
5619
5620 case 285:
Reid Spencer38f682b2007-01-26 20:31:18 +00005621#line 2997 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005622 {
Reid Spencer950bf602007-01-26 08:19:09 +00005623 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5624 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
5625 error("Shift amount must be int8");
5626 if (!(yyvsp[-2].ValueVal).V->getType()->isInteger())
5627 error("Shift constant expression requires integer operand");
5628 (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5629 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5630 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005631 break;
5632
5633 case 286:
Reid Spencer38f682b2007-01-26 20:31:18 +00005634#line 3006 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005635 {
Reid Spencer950bf602007-01-26 08:19:09 +00005636 const Type *DstTy = (yyvsp[0].TypeVal).T->get();
5637 if (!DstTy->isFirstClassType())
5638 error("cast instruction to a non-primitive type: '" +
5639 DstTy->getDescription() + "'");
5640 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5641 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5642 delete (yyvsp[0].TypeVal).T;
5643 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005644 break;
5645
5646 case 287:
Reid Spencer38f682b2007-01-26 20:31:18 +00005647#line 3015 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005648 {
Reid Spencer950bf602007-01-26 08:19:09 +00005649 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5650 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
5651 error("select condition must be bool");
5652 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
5653 error("select value types should match");
5654 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5655 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5656 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005657 break;
5658
Reid Spencerc4d96252007-01-13 00:03:30 +00005659 case 288:
Reid Spencer38f682b2007-01-26 20:31:18 +00005660#line 3024 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005661 {
Reid Spencer950bf602007-01-26 08:19:09 +00005662 const Type *Ty = (yyvsp[0].TypeVal).T->get();
5663 NewVarArgs = true;
5664 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5665 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5666 delete (yyvsp[0].TypeVal).T;
5667 ;}
5668 break;
5669
5670 case 289:
Reid Spencer38f682b2007-01-26 20:31:18 +00005671#line 3031 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005672 {
5673 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5674 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
5675 ObsoleteVarArgs = true;
5676 Function* NF = cast<Function>(CurModule.CurrentModule->
5677 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5678
5679 //b = vaarg a, t ->
5680 //foo = alloca 1 of t
5681 //bar = vacopy a
5682 //store bar -> foo
5683 //b = vaarg foo, t
5684 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5685 CurBB->getInstList().push_back(foo);
5686 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5687 CurBB->getInstList().push_back(bar);
5688 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5689 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5690 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5691 delete (yyvsp[0].TypeVal).T;
5692 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005693 break;
5694
Reid Spencerc4d96252007-01-13 00:03:30 +00005695 case 290:
Reid Spencer38f682b2007-01-26 20:31:18 +00005696#line 3052 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005697 {
5698 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5699 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
5700 ObsoleteVarArgs = true;
5701 Function* NF = cast<Function>(CurModule.CurrentModule->
5702 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5703
5704 //b = vanext a, t ->
5705 //foo = alloca 1 of t
5706 //bar = vacopy a
5707 //store bar -> foo
5708 //tmp = vaarg foo, t
5709 //b = load foo
5710 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5711 CurBB->getInstList().push_back(foo);
5712 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5713 CurBB->getInstList().push_back(bar);
5714 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5715 Instruction* tmp = new VAArgInst(foo, DstTy);
5716 CurBB->getInstList().push_back(tmp);
5717 (yyval.InstVal).I = new LoadInst(foo);
5718 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5719 delete (yyvsp[0].TypeVal).T;
5720 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005721 break;
5722
Reid Spencerc4d96252007-01-13 00:03:30 +00005723 case 291:
Reid Spencer38f682b2007-01-26 20:31:18 +00005724#line 3076 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005725 {
5726 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5727 error("Invalid extractelement operands");
5728 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5729 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5730 ;}
5731 break;
5732
5733 case 292:
Reid Spencer38f682b2007-01-26 20:31:18 +00005734#line 3082 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005735 {
5736 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5737 error("Invalid insertelement operands");
5738 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5739 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5740 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005741 break;
5742
Reid Spencerc4d96252007-01-13 00:03:30 +00005743 case 293:
Reid Spencer38f682b2007-01-26 20:31:18 +00005744#line 3088 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005745 {
5746 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5747 error("Invalid shufflevector operands");
5748 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5749 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5750 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005751 break;
5752
Reid Spencerc4d96252007-01-13 00:03:30 +00005753 case 294:
Reid Spencer38f682b2007-01-26 20:31:18 +00005754#line 3094 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005755 {
Reid Spencer950bf602007-01-26 08:19:09 +00005756 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
5757 if (!Ty->isFirstClassType())
5758 error("PHI node operands must be of first class type");
5759 PHINode *PHI = new PHINode(Ty);
5760 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5761 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5762 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
5763 error("All elements of a PHI node must be of the same type");
5764 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5765 (yyvsp[0].PHIList).P->pop_front();
5766 }
5767 (yyval.InstVal).I = PHI;
5768 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5769 delete (yyvsp[0].PHIList).P; // Free the list...
5770 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005771 break;
5772
5773 case 295:
Reid Spencer38f682b2007-01-26 20:31:18 +00005774#line 3110 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005775 {
Reid Spencer950bf602007-01-26 08:19:09 +00005776
5777 // Handle the short call syntax
5778 const PointerType *PFTy;
5779 const FunctionType *FTy;
5780 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).T->get())) ||
5781 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5782 // Pull out the types of all of the arguments...
5783 std::vector<const Type*> ParamTypes;
5784 if ((yyvsp[-1].ValueList)) {
5785 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
5786 I != E; ++I)
5787 ParamTypes.push_back((*I).V->getType());
5788 }
5789
5790 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5791 if (isVarArg) ParamTypes.pop_back();
5792
5793 const Type *RetTy = (yyvsp[-4].TypeVal).T->get();
5794 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5795 error("Functions cannot return aggregate types");
5796
5797 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
5798 PFTy = PointerType::get(FTy);
5799 }
5800
5801 // First upgrade any intrinsic calls.
5802 std::vector<Value*> Args;
5803 if ((yyvsp[-1].ValueList))
5804 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
5805 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
5806 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
5807
5808 // If we got an upgraded intrinsic
5809 if (Inst) {
5810 (yyval.InstVal).I = Inst;
5811 (yyval.InstVal).S = Signless;
5812 } else {
5813 // Get the function we're calling
5814 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
5815
5816 // Check the argument values match
5817 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
5818 // Make sure no arguments is a good thing!
5819 if (FTy->getNumParams() != 0)
5820 error("No arguments passed to a function that expects arguments");
5821 } else { // Has arguments?
5822 // Loop through FunctionType's arguments and ensure they are specified
5823 // correctly!
5824 //
5825 FunctionType::param_iterator I = FTy->param_begin();
5826 FunctionType::param_iterator E = FTy->param_end();
5827 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
5828
5829 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5830 if ((*ArgI).V->getType() != *I)
5831 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5832 (*I)->getDescription() + "'");
5833
5834 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
5835 error("Invalid number of parameters detected");
5836 }
5837
5838 // Create the call instruction
5839 CallInst *CI = new CallInst(V, Args);
5840 CI->setTailCall((yyvsp[-6].BoolVal));
5841 CI->setCallingConv((yyvsp[-5].UIntVal));
5842 (yyval.InstVal).I = CI;
5843 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5844 }
5845 delete (yyvsp[-4].TypeVal).T;
5846 delete (yyvsp[-1].ValueList);
5847 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005848 break;
5849
Reid Spencerc4d96252007-01-13 00:03:30 +00005850 case 296:
Reid Spencer38f682b2007-01-26 20:31:18 +00005851#line 3183 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005852 {
Reid Spencer950bf602007-01-26 08:19:09 +00005853 (yyval.InstVal) = (yyvsp[0].InstVal);
5854 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005855 break;
5856
Reid Spencer609ca3e2007-01-12 20:10:51 +00005857 case 297:
Reid Spencer38f682b2007-01-26 20:31:18 +00005858#line 3191 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005859 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005860 break;
5861
5862 case 298:
Reid Spencer38f682b2007-01-26 20:31:18 +00005863#line 3192 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005864 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005865 break;
5866
Reid Spencerc4d96252007-01-13 00:03:30 +00005867 case 299:
Reid Spencer38f682b2007-01-26 20:31:18 +00005868#line 3196 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005869 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005870 break;
5871
Reid Spencerc4d96252007-01-13 00:03:30 +00005872 case 300:
Reid Spencer38f682b2007-01-26 20:31:18 +00005873#line 3197 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005874 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005875 break;
5876
Reid Spencerc4d96252007-01-13 00:03:30 +00005877 case 301:
Reid Spencer38f682b2007-01-26 20:31:18 +00005878#line 3201 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005879 {
Reid Spencer950bf602007-01-26 08:19:09 +00005880 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5881 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5882 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
5883 delete (yyvsp[-1].TypeVal).T;
5884 ;}
5885 break;
5886
5887 case 302:
Reid Spencer38f682b2007-01-26 20:31:18 +00005888#line 3207 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005889 {
5890 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
5891 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5892 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
5893 delete (yyvsp[-4].TypeVal).T;
5894 ;}
5895 break;
5896
5897 case 303:
Reid Spencer38f682b2007-01-26 20:31:18 +00005898#line 3213 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005899 {
5900 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5901 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5902 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
5903 delete (yyvsp[-1].TypeVal).T;
5904 ;}
5905 break;
5906
5907 case 304:
Reid Spencer38f682b2007-01-26 20:31:18 +00005908#line 3219 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005909 {
5910 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
5911 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5912 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
5913 delete (yyvsp[-4].TypeVal).T;
5914 ;}
5915 break;
5916
5917 case 305:
Reid Spencer38f682b2007-01-26 20:31:18 +00005918#line 3225 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005919 {
5920 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
5921 if (!isa<PointerType>(PTy))
5922 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
5923 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
5924 (yyval.InstVal).S = Signless;
5925 ;}
5926 break;
5927
5928 case 306:
Reid Spencer38f682b2007-01-26 20:31:18 +00005929#line 3232 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005930 {
5931 const Type* Ty = (yyvsp[-1].TypeVal).T->get();
5932 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5933 if (!isa<PointerType>(Ty))
5934 error("Can't load from nonpointer type: " + Ty->getDescription());
5935 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
5936 error("Can't load from pointer of non-first-class type: " +
5937 Ty->getDescription());
5938 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
5939 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5940 delete (yyvsp[-1].TypeVal).T;
5941 ;}
5942 break;
5943
5944 case 307:
Reid Spencer38f682b2007-01-26 20:31:18 +00005945#line 3244 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005946 {
5947 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
5948 if (!PTy)
5949 error("Can't store to a nonpointer type: " +
5950 (yyvsp[-1].TypeVal).T->get()->getDescription());
5951 const Type *ElTy = PTy->getElementType();
5952 if (ElTy != (yyvsp[-3].ValueVal).V->getType())
5953 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
5954 "' into space of type '" + ElTy->getDescription() + "'");
5955 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
5956 (yyval.InstVal).I = new StoreInst((yyvsp[-3].ValueVal).V, tmpVal, (yyvsp[-5].BoolVal));
5957 (yyval.InstVal).S = Signless;
5958 delete (yyvsp[-1].TypeVal).T;
5959 ;}
5960 break;
5961
5962 case 308:
Reid Spencer38f682b2007-01-26 20:31:18 +00005963#line 3258 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005964 {
5965 const Type* Ty = (yyvsp[-2].TypeVal).T->get();
5966 if (!isa<PointerType>(Ty))
5967 error("getelementptr insn requires pointer operand");
5968
5969 std::vector<Value*> VIndices;
5970 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
5971
5972 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
5973 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
5974 (yyval.InstVal).S = Signless;
5975 delete (yyvsp[-2].TypeVal).T;
5976 delete (yyvsp[0].ValueList);
5977 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005978 break;
5979
5980
Reid Spencer950bf602007-01-26 08:19:09 +00005981 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00005982 }
5983
Reid Spencer950bf602007-01-26 08:19:09 +00005984/* Line 1126 of yacc.c. */
Reid Spencer38f682b2007-01-26 20:31:18 +00005985#line 5986 "UpgradeParser.tab.c"
Reid Spencere7c3c602006-11-30 06:36:44 +00005986
5987 yyvsp -= yylen;
5988 yyssp -= yylen;
5989
Reid Spencer319a7302007-01-05 17:20:02 +00005990
Reid Spencer950bf602007-01-26 08:19:09 +00005991 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00005992
5993 *++yyvsp = yyval;
5994
5995
Reid Spencer319a7302007-01-05 17:20:02 +00005996 /* Now `shift' the result of the reduction. Determine what state
5997 that goes to, based on the state we popped back to and the rule
5998 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00005999
6000 yyn = yyr1[yyn];
6001
Reid Spencer319a7302007-01-05 17:20:02 +00006002 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6003 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006004 yystate = yytable[yystate];
6005 else
Reid Spencer319a7302007-01-05 17:20:02 +00006006 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006007
6008 goto yynewstate;
6009
6010
Reid Spencer319a7302007-01-05 17:20:02 +00006011/*------------------------------------.
6012| yyerrlab -- here on detecting error |
6013`------------------------------------*/
6014yyerrlab:
6015 /* If not already recovering from an error, report this error. */
6016 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006017 {
6018 ++yynerrs;
Reid Spencer319a7302007-01-05 17:20:02 +00006019#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00006020 yyn = yypact[yystate];
6021
Reid Spencer319a7302007-01-05 17:20:02 +00006022 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencere7c3c602006-11-30 06:36:44 +00006023 {
Reid Spencer319a7302007-01-05 17:20:02 +00006024 int yytype = YYTRANSLATE (yychar);
Reid Spencer950bf602007-01-26 08:19:09 +00006025 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6026 YYSIZE_T yysize = yysize0;
6027 YYSIZE_T yysize1;
6028 int yysize_overflow = 0;
6029 char *yymsg = 0;
6030# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6031 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6032 int yyx;
Reid Spencere7c3c602006-11-30 06:36:44 +00006033
Reid Spencer950bf602007-01-26 08:19:09 +00006034#if 0
6035 /* This is so xgettext sees the translatable formats that are
6036 constructed on the fly. */
6037 YY_("syntax error, unexpected %s");
6038 YY_("syntax error, unexpected %s, expecting %s");
6039 YY_("syntax error, unexpected %s, expecting %s or %s");
6040 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6041 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6042#endif
6043 char *yyfmt;
6044 char const *yyf;
6045 static char const yyunexpected[] = "syntax error, unexpected %s";
6046 static char const yyexpecting[] = ", expecting %s";
6047 static char const yyor[] = " or %s";
6048 char yyformat[sizeof yyunexpected
6049 + sizeof yyexpecting - 1
6050 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6051 * (sizeof yyor - 1))];
6052 char const *yyprefix = yyexpecting;
6053
Reid Spencer319a7302007-01-05 17:20:02 +00006054 /* Start YYX at -YYN if negative to avoid negative indexes in
6055 YYCHECK. */
Reid Spencer950bf602007-01-26 08:19:09 +00006056 int yyxbegin = yyn < 0 ? -yyn : 0;
Jeff Cohenac2dca92007-01-21 19:30:52 +00006057
Reid Spencer950bf602007-01-26 08:19:09 +00006058 /* Stay within bounds of both yycheck and yytname. */
6059 int yychecklim = YYLAST - yyn;
6060 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6061 int yycount = 1;
6062
6063 yyarg[0] = yytname[yytype];
6064 yyfmt = yystpcpy (yyformat, yyunexpected);
6065
6066 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6067 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6068 {
6069 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6070 {
6071 yycount = 1;
6072 yysize = yysize0;
6073 yyformat[sizeof yyunexpected - 1] = '\0';
6074 break;
6075 }
6076 yyarg[yycount++] = yytname[yyx];
6077 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6078 yysize_overflow |= yysize1 < yysize;
6079 yysize = yysize1;
6080 yyfmt = yystpcpy (yyfmt, yyprefix);
6081 yyprefix = yyor;
6082 }
6083
6084 yyf = YY_(yyformat);
6085 yysize1 = yysize + yystrlen (yyf);
6086 yysize_overflow |= yysize1 < yysize;
6087 yysize = yysize1;
6088
6089 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6090 yymsg = (char *) YYSTACK_ALLOC (yysize);
6091 if (yymsg)
6092 {
6093 /* Avoid sprintf, as that infringes on the user's name space.
6094 Don't have undefined behavior even if the translation
6095 produced a string with the wrong number of "%s"s. */
6096 char *yyp = yymsg;
6097 int yyi = 0;
6098 while ((*yyp = *yyf))
Reid Spencere7c3c602006-11-30 06:36:44 +00006099 {
Reid Spencer950bf602007-01-26 08:19:09 +00006100 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6101 {
6102 yyp += yytnamerr (yyp, yyarg[yyi++]);
6103 yyf += 2;
6104 }
6105 else
6106 {
6107 yyp++;
6108 yyf++;
6109 }
Reid Spencere7c3c602006-11-30 06:36:44 +00006110 }
Reid Spencer319a7302007-01-05 17:20:02 +00006111 yyerror (yymsg);
6112 YYSTACK_FREE (yymsg);
Reid Spencere7c3c602006-11-30 06:36:44 +00006113 }
6114 else
Reid Spencer950bf602007-01-26 08:19:09 +00006115 {
6116 yyerror (YY_("syntax error"));
6117 goto yyexhaustedlab;
6118 }
Reid Spencere7c3c602006-11-30 06:36:44 +00006119 }
6120 else
6121#endif /* YYERROR_VERBOSE */
Reid Spencer950bf602007-01-26 08:19:09 +00006122 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006123 }
Reid Spencer950bf602007-01-26 08:19:09 +00006124
6125
6126
6127 if (yyerrstatus == 3)
6128 {
6129 /* If just tried and failed to reuse look-ahead token after an
6130 error, discard it. */
6131
6132 if (yychar <= YYEOF)
6133 {
6134 /* Return failure if at end of input. */
6135 if (yychar == YYEOF)
6136 YYABORT;
6137 }
6138 else
6139 {
6140 yydestruct ("Error: discarding", yytoken, &yylval);
6141 yychar = YYEMPTY;
6142 }
6143 }
6144
6145 /* Else will try to reuse look-ahead token after shifting the error
6146 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006147 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006148
Reid Spencer319a7302007-01-05 17:20:02 +00006149
Reid Spencer950bf602007-01-26 08:19:09 +00006150/*---------------------------------------------------.
6151| yyerrorlab -- error raised explicitly by YYERROR. |
6152`---------------------------------------------------*/
6153yyerrorlab:
6154
6155 /* Pacify compilers like GCC when the user code never invokes
6156 YYERROR and the label yyerrorlab therefore never appears in user
6157 code. */
6158 if (0)
6159 goto yyerrorlab;
6160
6161yyvsp -= yylen;
6162 yyssp -= yylen;
6163 yystate = *yyssp;
6164 goto yyerrlab1;
6165
6166
6167/*-------------------------------------------------------------.
6168| yyerrlab1 -- common code for both syntax error and YYERROR. |
6169`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006170yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006171 yyerrstatus = 3; /* Each real token shifted decrements this. */
6172
6173 for (;;)
6174 {
6175 yyn = yypact[yystate];
6176 if (yyn != YYPACT_NINF)
6177 {
6178 yyn += YYTERROR;
6179 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6180 {
6181 yyn = yytable[yyn];
6182 if (0 < yyn)
6183 break;
6184 }
6185 }
6186
6187 /* Pop the current state because it cannot handle the error token. */
6188 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006189 YYABORT;
6190
6191
Reid Spencer950bf602007-01-26 08:19:09 +00006192 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6193 YYPOPSTACK;
6194 yystate = *yyssp;
6195 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006196 }
6197
6198 if (yyn == YYFINAL)
6199 YYACCEPT;
6200
6201 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006202
6203
Reid Spencer950bf602007-01-26 08:19:09 +00006204 /* Shift the error token. */
6205 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6206
Reid Spencere7c3c602006-11-30 06:36:44 +00006207 yystate = yyn;
6208 goto yynewstate;
6209
Chris Lattner37e01c52007-01-04 18:46:42 +00006210
Reid Spencer319a7302007-01-05 17:20:02 +00006211/*-------------------------------------.
6212| yyacceptlab -- YYACCEPT comes here. |
6213`-------------------------------------*/
6214yyacceptlab:
6215 yyresult = 0;
6216 goto yyreturn;
6217
6218/*-----------------------------------.
6219| yyabortlab -- YYABORT comes here. |
6220`-----------------------------------*/
6221yyabortlab:
6222 yyresult = 1;
6223 goto yyreturn;
6224
6225#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006226/*-------------------------------------------------.
6227| yyexhaustedlab -- memory exhaustion comes here. |
6228`-------------------------------------------------*/
6229yyexhaustedlab:
6230 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006231 yyresult = 2;
6232 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006233#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006234
6235yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006236 if (yychar != YYEOF && yychar != YYEMPTY)
6237 yydestruct ("Cleanup: discarding lookahead",
6238 yytoken, &yylval);
6239 while (yyssp != yyss)
6240 {
6241 yydestruct ("Cleanup: popping",
6242 yystos[*yyssp], yyvsp);
6243 YYPOPSTACK;
6244 }
Reid Spencer319a7302007-01-05 17:20:02 +00006245#ifndef yyoverflow
6246 if (yyss != yyssa)
6247 YYSTACK_FREE (yyss);
6248#endif
6249 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006250}
Reid Spencer319a7302007-01-05 17:20:02 +00006251
6252
Reid Spencer38f682b2007-01-26 20:31:18 +00006253#line 3274 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006254
6255
6256int yyerror(const char *ErrorMsg) {
6257 std::string where
6258 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006259 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6260 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6261 if (yychar != YYEMPTY && yychar != 0)
6262 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6263 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006264 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006265 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006266 exit(1);
6267}
Reid Spencer319a7302007-01-05 17:20:02 +00006268
Reid Spencer30d0c582007-01-15 00:26:18 +00006269void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006270 std::string where
6271 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006272 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6273 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6274 if (yychar != YYEMPTY && yychar != 0)
6275 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6276 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006277 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6278}
6279
Reid Spencer950bf602007-01-26 08:19:09 +00006280void error(const std::string& ErrorMsg, int LineNo) {
6281 if (LineNo == -1) LineNo = Upgradelineno;
6282 Upgradelineno = LineNo;
6283 yyerror(ErrorMsg.c_str());
6284}
6285
6286