blob: 515d2d6bab58ecd933608312dc65b65b9a4bbd8d [file] [log] [blame]
Reid Spencerb7046c72007-01-29 05:41:34 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Reid Spencerb7046c72007-01-29 05:41:34 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 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
Reid Spencerb7046c72007-01-29 05:41:34 +000021/* 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. */
Reid Spencer319a7302007-01-05 17:20:02 +000025
Reid Spencerb7046c72007-01-29 05:41:34 +000026/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
Reid Spencer319a7302007-01-05 17:20:02 +000028
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. */
Reid Spencerb7046c72007-01-29 05:41:34 +000040#define YYBISON_VERSION "2.1"
Reid Spencer950bf602007-01-26 08:19:09 +000041
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 Spencerb7046c72007-01-29 05:41:34 +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 Spencerb7046c72007-01-29 05:41:34 +0000534 unsigned LastCC;
Reid Spencer950bf602007-01-26 08:19:09 +0000535 unsigned NextBBNum;
536
537 inline PerFunctionInfo() {
538 CurrentFunction = 0;
539 isDeclare = false;
540 Linkage = GlobalValue::ExternalLinkage;
541 }
542
543 inline void FunctionStart(Function *M) {
544 CurrentFunction = M;
545 NextBBNum = 0;
546 }
547
548 void FunctionDone() {
549 NumberedBlocks.clear();
550
551 // Any forward referenced blocks left?
552 if (!BBForwardRefs.empty()) {
553 error("Undefined reference to label " +
554 BBForwardRefs.begin()->first->getName());
555 return;
556 }
557
558 // Resolve all forward references now.
559 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
560
561 Values.clear(); // Clear out function local definitions
562 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000563 CurrentFunction = 0;
564 isDeclare = false;
565 Linkage = GlobalValue::ExternalLinkage;
566 }
567} CurFun; // Info for the current function...
568
569static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
570
571
572//===----------------------------------------------------------------------===//
573// Code to handle definitions of all the types
574//===----------------------------------------------------------------------===//
575
576static int InsertValue(Value *V,
577 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
578 if (V->hasName()) return -1; // Is this a numbered definition?
579
580 // Yes, insert the value into the value table...
581 ValueList &List = ValueTab[V->getType()];
582 List.push_back(V);
583 return List.size()-1;
584}
585
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000586static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000587 switch (D.Type) {
588 case ValID::NumberVal: // Is it a numbered definition?
589 // Module constants occupy the lowest numbered slots...
590 if ((unsigned)D.Num < CurModule.Types.size()) {
591 return CurModule.Types[(unsigned)D.Num];
592 }
593 break;
594 case ValID::NameVal: // Is it a named definition?
595 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
596 D.destroy(); // Free old strdup'd memory...
597 return N;
598 }
599 break;
600 default:
601 error("Internal parser error: Invalid symbol type reference");
602 return 0;
603 }
604
605 // If we reached here, we referenced either a symbol that we don't know about
606 // or an id number that hasn't been read yet. We may be referencing something
607 // forward, so just create an entry to be resolved later and get to it...
608 //
609 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
610
611
612 if (inFunctionScope()) {
613 if (D.Type == ValID::NameVal) {
614 error("Reference to an undefined type: '" + D.getName() + "'");
615 return 0;
616 } else {
617 error("Reference to an undefined type: #" + itostr(D.Num));
618 return 0;
619 }
620 }
621
622 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
623 if (I != CurModule.LateResolveTypes.end())
624 return I->second;
625
626 Type *Typ = OpaqueType::get();
627 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
628 return Typ;
629 }
630
631// getExistingValue - Look up the value specified by the provided type and
632// the provided ValID. If the value exists and has already been defined, return
633// it. Otherwise return null.
634//
635static Value *getExistingValue(const Type *Ty, const ValID &D) {
636 if (isa<FunctionType>(Ty)) {
637 error("Functions are not values and must be referenced as pointers");
638 }
639
640 switch (D.Type) {
641 case ValID::NumberVal: { // Is it a numbered definition?
642 unsigned Num = (unsigned)D.Num;
643
644 // Module constants occupy the lowest numbered slots...
645 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
646 if (VI != CurModule.Values.end()) {
647 if (Num < VI->second.size())
648 return VI->second[Num];
649 Num -= VI->second.size();
650 }
651
652 // Make sure that our type is within bounds
653 VI = CurFun.Values.find(Ty);
654 if (VI == CurFun.Values.end()) return 0;
655
656 // Check that the number is within bounds...
657 if (VI->second.size() <= Num) return 0;
658
659 return VI->second[Num];
660 }
661
662 case ValID::NameVal: { // Is it a named definition?
663 // Get the name out of the ID
664 std::string Name(D.Name);
665 Value* V = 0;
666 RenameMapKey Key = std::make_pair(Name, Ty);
667 if (inFunctionScope()) {
668 // See if the name was renamed
669 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
670 std::string LookupName;
671 if (I != CurFun.RenameMap.end())
672 LookupName = I->second;
673 else
674 LookupName = Name;
675 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
676 V = SymTab.lookup(Ty, LookupName);
677 }
678 if (!V) {
679 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
680 std::string LookupName;
681 if (I != CurModule.RenameMap.end())
682 LookupName = I->second;
683 else
684 LookupName = Name;
685 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
686 }
687 if (V == 0)
688 return 0;
689
690 D.destroy(); // Free old strdup'd memory...
691 return V;
692 }
693
694 // Check to make sure that "Ty" is an integral type, and that our
695 // value will fit into the specified type...
696 case ValID::ConstSIntVal: // Is it a constant pool reference??
697 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
698 error("Signed integral constant '" + itostr(D.ConstPool64) +
699 "' is invalid for type '" + Ty->getDescription() + "'");
700 }
701 return ConstantInt::get(Ty, D.ConstPool64);
702
703 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
704 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
705 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
706 error("Integral constant '" + utostr(D.UConstPool64) +
707 "' is invalid or out of range");
708 else // This is really a signed reference. Transmogrify.
709 return ConstantInt::get(Ty, D.ConstPool64);
710 } else
711 return ConstantInt::get(Ty, D.UConstPool64);
712
713 case ValID::ConstFPVal: // Is it a floating point const pool reference?
714 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
715 error("FP constant invalid for type");
716 return ConstantFP::get(Ty, D.ConstPoolFP);
717
718 case ValID::ConstNullVal: // Is it a null value?
719 if (!isa<PointerType>(Ty))
720 error("Cannot create a a non pointer null");
721 return ConstantPointerNull::get(cast<PointerType>(Ty));
722
723 case ValID::ConstUndefVal: // Is it an undef value?
724 return UndefValue::get(Ty);
725
726 case ValID::ConstZeroVal: // Is it a zero value?
727 return Constant::getNullValue(Ty);
728
729 case ValID::ConstantVal: // Fully resolved constant?
730 if (D.ConstantValue->getType() != Ty)
731 error("Constant expression type different from required type");
732 return D.ConstantValue;
733
734 case ValID::InlineAsmVal: { // Inline asm expression
735 const PointerType *PTy = dyn_cast<PointerType>(Ty);
736 const FunctionType *FTy =
737 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
738 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
739 error("Invalid type for asm constraint string");
740 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
741 D.IAD->HasSideEffects);
742 D.destroy(); // Free InlineAsmDescriptor.
743 return IA;
744 }
745 default:
746 assert(0 && "Unhandled case");
747 return 0;
748 } // End of switch
749
750 assert(0 && "Unhandled case");
751 return 0;
752}
753
754// getVal - This function is identical to getExistingValue, except that if a
755// value is not already defined, it "improvises" by creating a placeholder var
756// that looks and acts just like the requested variable. When the value is
757// defined later, all uses of the placeholder variable are replaced with the
758// real thing.
759//
760static Value *getVal(const Type *Ty, const ValID &ID) {
761 if (Ty == Type::LabelTy)
762 error("Cannot use a basic block here");
763
764 // See if the value has already been defined.
765 Value *V = getExistingValue(Ty, ID);
766 if (V) return V;
767
768 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
769 error("Invalid use of a composite type");
770
771 // If we reached here, we referenced either a symbol that we don't know about
772 // or an id number that hasn't been read yet. We may be referencing something
773 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000774 V = new Argument(Ty);
775
776 // Remember where this forward reference came from. FIXME, shouldn't we try
777 // to recycle these things??
778 CurModule.PlaceHolderInfo.insert(
779 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
780
781 if (inFunctionScope())
782 InsertValue(V, CurFun.LateResolveValues);
783 else
784 InsertValue(V, CurModule.LateResolveValues);
785 return V;
786}
787
788/// getBBVal - This is used for two purposes:
789/// * If isDefinition is true, a new basic block with the specified ID is being
790/// defined.
791/// * If isDefinition is true, this is a reference to a basic block, which may
792/// or may not be a forward reference.
793///
794static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
795 assert(inFunctionScope() && "Can't get basic block at global scope");
796
797 std::string Name;
798 BasicBlock *BB = 0;
799 switch (ID.Type) {
800 default:
801 error("Illegal label reference " + ID.getName());
802 break;
803 case ValID::NumberVal: // Is it a numbered definition?
804 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
805 CurFun.NumberedBlocks.resize(ID.Num+1);
806 BB = CurFun.NumberedBlocks[ID.Num];
807 break;
808 case ValID::NameVal: // Is it a named definition?
809 Name = ID.Name;
810 if (Value *N = CurFun.CurrentFunction->
811 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
812 if (N->getType() != Type::LabelTy)
813 error("Name '" + Name + "' does not refer to a BasicBlock");
814 BB = cast<BasicBlock>(N);
815 }
816 break;
817 }
818
819 // See if the block has already been defined.
820 if (BB) {
821 // If this is the definition of the block, make sure the existing value was
822 // just a forward reference. If it was a forward reference, there will be
823 // an entry for it in the PlaceHolderInfo map.
824 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
825 // The existing value was a definition, not a forward reference.
826 error("Redefinition of label " + ID.getName());
827
828 ID.destroy(); // Free strdup'd memory.
829 return BB;
830 }
831
832 // Otherwise this block has not been seen before.
833 BB = new BasicBlock("", CurFun.CurrentFunction);
834 if (ID.Type == ValID::NameVal) {
835 BB->setName(ID.Name);
836 } else {
837 CurFun.NumberedBlocks[ID.Num] = BB;
838 }
839
840 // If this is not a definition, keep track of it so we can use it as a forward
841 // reference.
842 if (!isDefinition) {
843 // Remember where this forward reference came from.
844 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
845 } else {
846 // The forward declaration could have been inserted anywhere in the
847 // function: insert it into the correct place now.
848 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
849 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
850 }
851 ID.destroy();
852 return BB;
853}
854
855
856//===----------------------------------------------------------------------===//
857// Code to handle forward references in instructions
858//===----------------------------------------------------------------------===//
859//
860// This code handles the late binding needed with statements that reference
861// values not defined yet... for example, a forward branch, or the PHI node for
862// a loop body.
863//
864// This keeps a table (CurFun.LateResolveValues) of all such forward references
865// and back patchs after we are done.
866//
867
Reid Spencer7de2e012007-01-29 19:08:46 +0000868/// This function determines if two function types differ only in their use of
869/// the sret parameter attribute in the first argument. If they are identical
870/// in all other respects, it returns true. Otherwise, it returns false.
871bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
872 const FunctionType *F2) {
873 if (F1->getReturnType() != F2->getReturnType() ||
874 F1->getNumParams() != F2->getNumParams() ||
875 F1->getParamAttrs(0) != F2->getParamAttrs(0))
876 return false;
877 unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute);
878 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
879 if (F1->getParamType(i) != F2->getParamType(i) ||
880 unsigned(F1->getParamAttrs(i+1)) & SRetMask !=
881 unsigned(F2->getParamAttrs(i+1)) & SRetMask)
882 return false;
883 }
884 return true;
885}
886
Reid Spencer950bf602007-01-26 08:19:09 +0000887// ResolveDefinitions - If we could not resolve some defs at parsing
888// time (forward branches, phi functions for loops, etc...) resolve the
889// defs now...
890//
891static void
892ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
893 std::map<const Type*,ValueList> *FutureLateResolvers) {
894 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
895 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
896 E = LateResolvers.end(); LRI != E; ++LRI) {
897 ValueList &List = LRI->second;
898 while (!List.empty()) {
899 Value *V = List.back();
900 List.pop_back();
901
902 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
903 CurModule.PlaceHolderInfo.find(V);
904 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
905
906 ValID &DID = PHI->second.first;
907
908 Value *TheRealValue = getExistingValue(LRI->first, DID);
909 if (TheRealValue) {
910 V->replaceAllUsesWith(TheRealValue);
911 delete V;
912 CurModule.PlaceHolderInfo.erase(PHI);
913 } else if (FutureLateResolvers) {
914 // Functions have their unresolved items forwarded to the module late
915 // resolver table
916 InsertValue(V, *FutureLateResolvers);
917 } else {
918 if (DID.Type == ValID::NameVal) {
Reid Spencer7de2e012007-01-29 19:08:46 +0000919 // The upgrade of csretcc to sret param attribute may have caused a
920 // function to not be found because the param attribute changed the
921 // type of the called function. Detect this situation and insert a
922 // cast as necessary.
923 bool fixed = false;
924 if (const PointerType *PTy = dyn_cast<PointerType>(V->getType()))
925 if (const FunctionType *FTy =
926 dyn_cast<FunctionType>(PTy->getElementType()))
927 if (Function *OtherF =
928 CurModule.CurrentModule->getNamedFunction(DID.getName()))
929 if (FuncTysDifferOnlyBySRet(FTy,OtherF->getFunctionType())) {
930 V->replaceAllUsesWith(ConstantExpr::getBitCast(OtherF, PTy));
931 fixed = true;
932 }
933 if (!fixed) {
934 error("Reference to an invalid definition: '" +DID.getName()+
935 "' of type '" + V->getType()->getDescription() + "'",
936 PHI->second.second);
937 return;
938 }
Reid Spencer950bf602007-01-26 08:19:09 +0000939 } else {
940 error("Reference to an invalid definition: #" +
941 itostr(DID.Num) + " of type '" +
942 V->getType()->getDescription() + "'", PHI->second.second);
943 return;
944 }
945 }
946 }
947 }
948
949 LateResolvers.clear();
950}
951
952// ResolveTypeTo - A brand new type was just declared. This means that (if
953// name is not null) things referencing Name can be resolved. Otherwise, things
954// refering to the number can be resolved. Do this now.
955//
956static void ResolveTypeTo(char *Name, const Type *ToTy) {
957 ValID D;
958 if (Name) D = ValID::create(Name);
959 else D = ValID::create((int)CurModule.Types.size());
960
961 std::map<ValID, PATypeHolder>::iterator I =
962 CurModule.LateResolveTypes.find(D);
963 if (I != CurModule.LateResolveTypes.end()) {
964 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
965 CurModule.LateResolveTypes.erase(I);
966 }
967}
968
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000969/// @brief This just makes any name given to it unique, up to MAX_UINT times.
Reid Spencer950bf602007-01-26 08:19:09 +0000970static std::string makeNameUnique(const std::string& Name) {
971 static unsigned UniqueNameCounter = 1;
972 std::string Result(Name);
973 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
974 return Result;
975}
976
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000977/// This is the implementation portion of TypeHasInteger. It traverses the
978/// type given, avoiding recursive types, and returns true as soon as it finds
979/// an integer type. If no integer type is found, it returns false.
980static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
981 // Handle some easy cases
982 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
983 return false;
984 if (Ty->isInteger())
985 return true;
986 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
987 return STy->getElementType()->isInteger();
988
989 // Avoid type structure recursion
990 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
991 I != E; ++I)
992 if (Ty == *I)
993 return false;
994
995 // Push us on the type stack
996 Stack.push_back(Ty);
997
998 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
999 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1000 return true;
1001 FunctionType::param_iterator I = FTy->param_begin();
1002 FunctionType::param_iterator E = FTy->param_end();
1003 for (; I != E; ++I)
1004 if (TypeHasIntegerI(*I, Stack))
1005 return true;
1006 return false;
1007 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1008 StructType::element_iterator I = STy->element_begin();
1009 StructType::element_iterator E = STy->element_end();
1010 for (; I != E; ++I) {
1011 if (TypeHasIntegerI(*I, Stack))
1012 return true;
1013 }
1014 return false;
1015 }
1016 // There shouldn't be anything else, but its definitely not integer
1017 assert(0 && "What type is this?");
1018 return false;
1019}
1020
1021/// This is the interface to TypeHasIntegerI. It just provides the type stack,
1022/// to avoid recursion, and then calls TypeHasIntegerI.
1023static inline bool TypeHasInteger(const Type *Ty) {
1024 std::vector<const Type*> TyStack;
1025 return TypeHasIntegerI(Ty, TyStack);
1026}
1027
Reid Spencer950bf602007-01-26 08:19:09 +00001028// setValueName - Set the specified value to the name given. The name may be
1029// null potentially, in which case this is a noop. The string passed in is
1030// assumed to be a malloc'd string buffer, and is free'd by this function.
1031//
1032static void setValueName(Value *V, char *NameStr) {
1033 if (NameStr) {
1034 std::string Name(NameStr); // Copy string
1035 free(NameStr); // Free old string
1036
1037 if (V->getType() == Type::VoidTy) {
1038 error("Can't assign name '" + Name + "' to value with void type");
1039 return;
1040 }
1041
Reid Spencer950bf602007-01-26 08:19:09 +00001042 assert(inFunctionScope() && "Must be in function scope");
1043
1044 // Search the function's symbol table for an existing value of this name
1045 Value* Existing = 0;
1046 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1047 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
1048 for ( ; PI != PE; ++PI) {
1049 SymbolTable::value_const_iterator VI = PI->second.find(Name);
1050 if (VI != PI->second.end()) {
1051 Existing = VI->second;
1052 break;
1053 }
1054 }
1055 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001056 // An existing value of the same name was found. This might have happened
1057 // because of the integer type planes collapsing in LLVM 2.0.
1058 if (Existing->getType() == V->getType() &&
1059 !TypeHasInteger(Existing->getType())) {
1060 // If the type does not contain any integers in them then this can't be
1061 // a type plane collapsing issue. It truly is a redefinition and we
1062 // should error out as the assembly is invalid.
1063 error("Redefinition of value named '" + Name + "' of type '" +
1064 V->getType()->getDescription() + "'");
1065 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001066 }
1067 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1068 // function, regardless of Type. Previously re-use of names was okay as
1069 // long as they were distinct types. With type planes collapsing because
1070 // of the signedness change and because of PR411, this can no longer be
1071 // supported. We must search the entire symbol table for a conflicting
1072 // name and make the name unique. No warning is needed as this can't
1073 // cause a problem.
1074 std::string NewName = makeNameUnique(Name);
1075 // We're changing the name but it will probably be used by other
1076 // instructions as operands later on. Consequently we have to retain
1077 // a mapping of the renaming that we're doing.
1078 RenameMapKey Key = std::make_pair(Name,V->getType());
1079 CurFun.RenameMap[Key] = NewName;
1080 Name = NewName;
1081 }
1082
1083 // Set the name.
1084 V->setName(Name);
1085 }
1086}
1087
1088/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1089/// this is a declaration, otherwise it is a definition.
1090static GlobalVariable *
1091ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1092 bool isConstantGlobal, const Type *Ty,
1093 Constant *Initializer) {
1094 if (isa<FunctionType>(Ty))
1095 error("Cannot declare global vars of function type");
1096
1097 const PointerType *PTy = PointerType::get(Ty);
1098
1099 std::string Name;
1100 if (NameStr) {
1101 Name = NameStr; // Copy string
1102 free(NameStr); // Free old string
1103 }
1104
1105 // See if this global value was forward referenced. If so, recycle the
1106 // object.
1107 ValID ID;
1108 if (!Name.empty()) {
1109 ID = ValID::create((char*)Name.c_str());
1110 } else {
1111 ID = ValID::create((int)CurModule.Values[PTy].size());
1112 }
1113
1114 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1115 // Move the global to the end of the list, from whereever it was
1116 // previously inserted.
1117 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1118 CurModule.CurrentModule->getGlobalList().remove(GV);
1119 CurModule.CurrentModule->getGlobalList().push_back(GV);
1120 GV->setInitializer(Initializer);
1121 GV->setLinkage(Linkage);
1122 GV->setConstant(isConstantGlobal);
1123 InsertValue(GV, CurModule.Values);
1124 return GV;
1125 }
1126
1127 // If this global has a name, check to see if there is already a definition
1128 // of this global in the module and emit warnings if there are conflicts.
1129 if (!Name.empty()) {
1130 // The global has a name. See if there's an existing one of the same name.
1131 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1132 // We found an existing global ov the same name. This isn't allowed
1133 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1134 // can at least compile. This can happen because of type planes
1135 // There is alread a global of the same name which means there is a
1136 // conflict. Let's see what we can do about it.
1137 std::string NewName(makeNameUnique(Name));
1138 if (Linkage == GlobalValue::InternalLinkage) {
1139 // The linkage type is internal so just warn about the rename without
1140 // invoking "scarey language" about linkage failures. GVars with
1141 // InternalLinkage can be renamed at will.
1142 warning("Global variable '" + Name + "' was renamed to '"+
1143 NewName + "'");
1144 } else {
1145 // The linkage of this gval is external so we can't reliably rename
1146 // it because it could potentially create a linking problem.
1147 // However, we can't leave the name conflict in the output either or
1148 // it won't assemble with LLVM 2.0. So, all we can do is rename
1149 // this one to something unique and emit a warning about the problem.
1150 warning("Renaming global variable '" + Name + "' to '" + NewName +
1151 "' may cause linkage errors");
1152 }
1153
1154 // Put the renaming in the global rename map
1155 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1156 CurModule.RenameMap[Key] = NewName;
1157
1158 // Rename it
1159 Name = NewName;
1160 }
1161 }
1162
1163 // Otherwise there is no existing GV to use, create one now.
1164 GlobalVariable *GV =
1165 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1166 CurModule.CurrentModule);
1167 InsertValue(GV, CurModule.Values);
1168 return GV;
1169}
1170
1171// setTypeName - Set the specified type to the name given. The name may be
1172// null potentially, in which case this is a noop. The string passed in is
1173// assumed to be a malloc'd string buffer, and is freed by this function.
1174//
1175// This function returns true if the type has already been defined, but is
1176// allowed to be redefined in the specified context. If the name is a new name
1177// for the type plane, it is inserted and false is returned.
1178static bool setTypeName(const Type *T, char *NameStr) {
1179 assert(!inFunctionScope() && "Can't give types function-local names");
1180 if (NameStr == 0) return false;
1181
1182 std::string Name(NameStr); // Copy string
1183 free(NameStr); // Free old string
1184
1185 // We don't allow assigning names to void type
1186 if (T == Type::VoidTy) {
1187 error("Can't assign name '" + Name + "' to the void type");
1188 return false;
1189 }
1190
1191 // Set the type name, checking for conflicts as we do so.
1192 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1193
1194 if (AlreadyExists) { // Inserting a name that is already defined???
1195 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1196 assert(Existing && "Conflict but no matching type?");
1197
1198 // There is only one case where this is allowed: when we are refining an
1199 // opaque type. In this case, Existing will be an opaque type.
1200 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1201 // We ARE replacing an opaque type!
1202 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1203 return true;
1204 }
1205
1206 // Otherwise, this is an attempt to redefine a type. That's okay if
1207 // the redefinition is identical to the original. This will be so if
1208 // Existing and T point to the same Type object. In this one case we
1209 // allow the equivalent redefinition.
1210 if (Existing == T) return true; // Yes, it's equal.
1211
1212 // Any other kind of (non-equivalent) redefinition is an error.
1213 error("Redefinition of type named '" + Name + "' in the '" +
1214 T->getDescription() + "' type plane");
1215 }
1216
1217 return false;
1218}
1219
1220//===----------------------------------------------------------------------===//
1221// Code for handling upreferences in type names...
1222//
1223
1224// TypeContains - Returns true if Ty directly contains E in it.
1225//
1226static bool TypeContains(const Type *Ty, const Type *E) {
1227 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1228 E) != Ty->subtype_end();
1229}
1230
1231namespace {
1232 struct UpRefRecord {
1233 // NestingLevel - The number of nesting levels that need to be popped before
1234 // this type is resolved.
1235 unsigned NestingLevel;
1236
1237 // LastContainedTy - This is the type at the current binding level for the
1238 // type. Every time we reduce the nesting level, this gets updated.
1239 const Type *LastContainedTy;
1240
1241 // UpRefTy - This is the actual opaque type that the upreference is
1242 // represented with.
1243 OpaqueType *UpRefTy;
1244
1245 UpRefRecord(unsigned NL, OpaqueType *URTy)
1246 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1247 };
1248}
1249
1250// UpRefs - A list of the outstanding upreferences that need to be resolved.
1251static std::vector<UpRefRecord> UpRefs;
1252
1253/// HandleUpRefs - Every time we finish a new layer of types, this function is
1254/// called. It loops through the UpRefs vector, which is a list of the
1255/// currently active types. For each type, if the up reference is contained in
1256/// the newly completed type, we decrement the level count. When the level
1257/// count reaches zero, the upreferenced type is the type that is passed in:
1258/// thus we can complete the cycle.
1259///
1260static PATypeHolder HandleUpRefs(const Type *ty) {
1261 // If Ty isn't abstract, or if there are no up-references in it, then there is
1262 // nothing to resolve here.
1263 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1264
1265 PATypeHolder Ty(ty);
1266 UR_OUT("Type '" << Ty->getDescription() <<
1267 "' newly formed. Resolving upreferences.\n" <<
1268 UpRefs.size() << " upreferences active!\n");
1269
1270 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1271 // to zero), we resolve them all together before we resolve them to Ty. At
1272 // the end of the loop, if there is anything to resolve to Ty, it will be in
1273 // this variable.
1274 OpaqueType *TypeToResolve = 0;
1275
1276 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1277 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1278 << UpRefs[i].second->getDescription() << ") = "
1279 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1280 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1281 // Decrement level of upreference
1282 unsigned Level = --UpRefs[i].NestingLevel;
1283 UpRefs[i].LastContainedTy = Ty;
1284 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1285 if (Level == 0) { // Upreference should be resolved!
1286 if (!TypeToResolve) {
1287 TypeToResolve = UpRefs[i].UpRefTy;
1288 } else {
1289 UR_OUT(" * Resolving upreference for "
1290 << UpRefs[i].second->getDescription() << "\n";
1291 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1292 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1293 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1294 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1295 }
1296 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1297 --i; // Do not skip the next element...
1298 }
1299 }
1300 }
1301
1302 if (TypeToResolve) {
1303 UR_OUT(" * Resolving upreference for "
1304 << UpRefs[i].second->getDescription() << "\n";
1305 std::string OldName = TypeToResolve->getDescription());
1306 TypeToResolve->refineAbstractTypeTo(Ty);
1307 }
1308
1309 return Ty;
1310}
1311
1312static inline Instruction::TermOps
1313getTermOp(TermOps op) {
1314 switch (op) {
1315 default : assert(0 && "Invalid OldTermOp");
1316 case RetOp : return Instruction::Ret;
1317 case BrOp : return Instruction::Br;
1318 case SwitchOp : return Instruction::Switch;
1319 case InvokeOp : return Instruction::Invoke;
1320 case UnwindOp : return Instruction::Unwind;
1321 case UnreachableOp: return Instruction::Unreachable;
1322 }
1323}
1324
1325static inline Instruction::BinaryOps
1326getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1327 switch (op) {
1328 default : assert(0 && "Invalid OldBinaryOps");
1329 case SetEQ :
1330 case SetNE :
1331 case SetLE :
1332 case SetGE :
1333 case SetLT :
1334 case SetGT : assert(0 && "Should use getCompareOp");
1335 case AddOp : return Instruction::Add;
1336 case SubOp : return Instruction::Sub;
1337 case MulOp : return Instruction::Mul;
1338 case DivOp : {
1339 // This is an obsolete instruction so we must upgrade it based on the
1340 // types of its operands.
1341 bool isFP = Ty->isFloatingPoint();
1342 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1343 // If its a packed type we want to use the element type
1344 isFP = PTy->getElementType()->isFloatingPoint();
1345 if (isFP)
1346 return Instruction::FDiv;
1347 else if (Sign == Signed)
1348 return Instruction::SDiv;
1349 return Instruction::UDiv;
1350 }
1351 case UDivOp : return Instruction::UDiv;
1352 case SDivOp : return Instruction::SDiv;
1353 case FDivOp : return Instruction::FDiv;
1354 case RemOp : {
1355 // This is an obsolete instruction so we must upgrade it based on the
1356 // types of its operands.
1357 bool isFP = Ty->isFloatingPoint();
1358 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1359 // If its a packed type we want to use the element type
1360 isFP = PTy->getElementType()->isFloatingPoint();
1361 // Select correct opcode
1362 if (isFP)
1363 return Instruction::FRem;
1364 else if (Sign == Signed)
1365 return Instruction::SRem;
1366 return Instruction::URem;
1367 }
1368 case URemOp : return Instruction::URem;
1369 case SRemOp : return Instruction::SRem;
1370 case FRemOp : return Instruction::FRem;
1371 case AndOp : return Instruction::And;
1372 case OrOp : return Instruction::Or;
1373 case XorOp : return Instruction::Xor;
1374 }
1375}
1376
1377static inline Instruction::OtherOps
1378getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1379 Signedness Sign) {
1380 bool isSigned = Sign == Signed;
1381 bool isFP = Ty->isFloatingPoint();
1382 switch (op) {
1383 default : assert(0 && "Invalid OldSetCC");
1384 case SetEQ :
1385 if (isFP) {
1386 predicate = FCmpInst::FCMP_OEQ;
1387 return Instruction::FCmp;
1388 } else {
1389 predicate = ICmpInst::ICMP_EQ;
1390 return Instruction::ICmp;
1391 }
1392 case SetNE :
1393 if (isFP) {
1394 predicate = FCmpInst::FCMP_UNE;
1395 return Instruction::FCmp;
1396 } else {
1397 predicate = ICmpInst::ICMP_NE;
1398 return Instruction::ICmp;
1399 }
1400 case SetLE :
1401 if (isFP) {
1402 predicate = FCmpInst::FCMP_OLE;
1403 return Instruction::FCmp;
1404 } else {
1405 if (isSigned)
1406 predicate = ICmpInst::ICMP_SLE;
1407 else
1408 predicate = ICmpInst::ICMP_ULE;
1409 return Instruction::ICmp;
1410 }
1411 case SetGE :
1412 if (isFP) {
1413 predicate = FCmpInst::FCMP_OGE;
1414 return Instruction::FCmp;
1415 } else {
1416 if (isSigned)
1417 predicate = ICmpInst::ICMP_SGE;
1418 else
1419 predicate = ICmpInst::ICMP_UGE;
1420 return Instruction::ICmp;
1421 }
1422 case SetLT :
1423 if (isFP) {
1424 predicate = FCmpInst::FCMP_OLT;
1425 return Instruction::FCmp;
1426 } else {
1427 if (isSigned)
1428 predicate = ICmpInst::ICMP_SLT;
1429 else
1430 predicate = ICmpInst::ICMP_ULT;
1431 return Instruction::ICmp;
1432 }
1433 case SetGT :
1434 if (isFP) {
1435 predicate = FCmpInst::FCMP_OGT;
1436 return Instruction::FCmp;
1437 } else {
1438 if (isSigned)
1439 predicate = ICmpInst::ICMP_SGT;
1440 else
1441 predicate = ICmpInst::ICMP_UGT;
1442 return Instruction::ICmp;
1443 }
1444 }
1445}
1446
1447static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1448 switch (op) {
1449 default : assert(0 && "Invalid OldMemoryOps");
1450 case MallocOp : return Instruction::Malloc;
1451 case FreeOp : return Instruction::Free;
1452 case AllocaOp : return Instruction::Alloca;
1453 case LoadOp : return Instruction::Load;
1454 case StoreOp : return Instruction::Store;
1455 case GetElementPtrOp : return Instruction::GetElementPtr;
1456 }
1457}
1458
1459static inline Instruction::OtherOps
1460getOtherOp(OtherOps op, Signedness Sign) {
1461 switch (op) {
1462 default : assert(0 && "Invalid OldOtherOps");
1463 case PHIOp : return Instruction::PHI;
1464 case CallOp : return Instruction::Call;
1465 case ShlOp : return Instruction::Shl;
1466 case ShrOp :
1467 if (Sign == Signed)
1468 return Instruction::AShr;
1469 return Instruction::LShr;
1470 case SelectOp : return Instruction::Select;
1471 case UserOp1 : return Instruction::UserOp1;
1472 case UserOp2 : return Instruction::UserOp2;
1473 case VAArg : return Instruction::VAArg;
1474 case ExtractElementOp : return Instruction::ExtractElement;
1475 case InsertElementOp : return Instruction::InsertElement;
1476 case ShuffleVectorOp : return Instruction::ShuffleVector;
1477 case ICmpOp : return Instruction::ICmp;
1478 case FCmpOp : return Instruction::FCmp;
1479 case LShrOp : return Instruction::LShr;
1480 case AShrOp : return Instruction::AShr;
1481 };
1482}
1483
1484static inline Value*
1485getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1486 Signedness DstSign, bool ForceInstruction = false) {
1487 Instruction::CastOps Opcode;
1488 const Type* SrcTy = Src->getType();
1489 if (op == CastOp) {
1490 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1491 // fp -> ptr cast is no longer supported but we must upgrade this
1492 // by doing a double cast: fp -> int -> ptr
1493 SrcTy = Type::Int64Ty;
1494 Opcode = Instruction::IntToPtr;
1495 if (isa<Constant>(Src)) {
1496 Src = ConstantExpr::getCast(Instruction::FPToUI,
1497 cast<Constant>(Src), SrcTy);
1498 } else {
1499 std::string NewName(makeNameUnique(Src->getName()));
1500 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1501 }
1502 } else if (isa<IntegerType>(DstTy) &&
1503 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1504 // cast type %x to bool was previously defined as setne type %x, null
1505 // The cast semantic is now to truncate, not compare so we must retain
1506 // the original intent by replacing the cast with a setne
1507 Constant* Null = Constant::getNullValue(SrcTy);
1508 Instruction::OtherOps Opcode = Instruction::ICmp;
1509 unsigned short predicate = ICmpInst::ICMP_NE;
1510 if (SrcTy->isFloatingPoint()) {
1511 Opcode = Instruction::FCmp;
1512 predicate = FCmpInst::FCMP_ONE;
1513 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1514 error("Invalid cast to bool");
1515 }
1516 if (isa<Constant>(Src) && !ForceInstruction)
1517 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1518 else
1519 return CmpInst::create(Opcode, predicate, Src, Null);
1520 }
1521 // Determine the opcode to use by calling CastInst::getCastOpcode
1522 Opcode =
1523 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1524
1525 } else switch (op) {
1526 default: assert(0 && "Invalid cast token");
1527 case TruncOp: Opcode = Instruction::Trunc; break;
1528 case ZExtOp: Opcode = Instruction::ZExt; break;
1529 case SExtOp: Opcode = Instruction::SExt; break;
1530 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1531 case FPExtOp: Opcode = Instruction::FPExt; break;
1532 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1533 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1534 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1535 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1536 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1537 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1538 case BitCastOp: Opcode = Instruction::BitCast; break;
1539 }
1540
1541 if (isa<Constant>(Src) && !ForceInstruction)
1542 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1543 return CastInst::create(Opcode, Src, DstTy);
1544}
1545
1546static Instruction *
1547upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1548 std::vector<Value*>& Args) {
1549
1550 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1551 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1552 if (Args.size() != 2)
1553 error("Invalid prototype for " + Name + " prototype");
1554 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1555 } else {
1556 static unsigned upgradeCount = 1;
1557 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1558 std::vector<const Type*> Params;
1559 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1560 if (Args.size() != 1)
1561 error("Invalid prototype for " + Name + " prototype");
1562 Params.push_back(PtrTy);
1563 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1564 const PointerType *PFTy = PointerType::get(FTy);
1565 Value* Func = getVal(PFTy, ID);
1566 std::string InstName("va_upgrade");
1567 InstName += llvm::utostr(upgradeCount++);
1568 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1569 return new CallInst(Func, Args);
1570 } else if (Name == "llvm.va_copy") {
1571 if (Args.size() != 2)
1572 error("Invalid prototype for " + Name + " prototype");
1573 Params.push_back(PtrTy);
1574 Params.push_back(PtrTy);
1575 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1576 const PointerType *PFTy = PointerType::get(FTy);
1577 Value* Func = getVal(PFTy, ID);
1578 std::string InstName0("va_upgrade");
1579 InstName0 += llvm::utostr(upgradeCount++);
1580 std::string InstName1("va_upgrade");
1581 InstName1 += llvm::utostr(upgradeCount++);
1582 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1583 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1584 return new CallInst(Func, Args);
1585 }
1586 }
1587 return 0;
1588}
1589
1590const Type* upgradeGEPIndices(const Type* PTy,
1591 std::vector<ValueInfo> *Indices,
1592 std::vector<Value*> &VIndices,
1593 std::vector<Constant*> *CIndices = 0) {
1594 // Traverse the indices with a gep_type_iterator so we can build the list
1595 // of constant and value indices for use later. Also perform upgrades
1596 VIndices.clear();
1597 if (CIndices) CIndices->clear();
1598 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1599 VIndices.push_back((*Indices)[i].V);
1600 generic_gep_type_iterator<std::vector<Value*>::iterator>
1601 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1602 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1603 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1604 Value *Index = VIndices[i];
1605 if (CIndices && !isa<Constant>(Index))
1606 error("Indices to constant getelementptr must be constants");
1607 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1608 // struct indices to i32 struct indices with ZExt for compatibility.
1609 else if (isa<StructType>(*GTI)) { // Only change struct indices
1610 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1611 if (CUI->getType()->getBitWidth() == 8)
1612 Index =
1613 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1614 } else {
1615 // Make sure that unsigned SequentialType indices are zext'd to
1616 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1617 // all indices for SequentialType elements. We must retain the same
1618 // semantic (zext) for unsigned types.
1619 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001620 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001621 if (CIndices)
1622 Index = ConstantExpr::getCast(Instruction::ZExt,
1623 cast<Constant>(Index), Type::Int64Ty);
1624 else
1625 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencerd7c4f8c2007-01-26 19:59:25 +00001626 makeNameUnique("gep_upgrade"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001627 VIndices[i] = Index;
1628 }
Reid Spencer950bf602007-01-26 08:19:09 +00001629 }
1630 // Add to the CIndices list, if requested.
1631 if (CIndices)
1632 CIndices->push_back(cast<Constant>(Index));
1633 }
1634
1635 const Type *IdxTy =
1636 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1637 if (!IdxTy)
1638 error("Index list invalid for constant getelementptr");
1639 return IdxTy;
1640}
1641
Reid Spencerb7046c72007-01-29 05:41:34 +00001642unsigned upgradeCallingConv(unsigned CC) {
1643 switch (CC) {
1644 case OldCallingConv::C : return CallingConv::C;
1645 case OldCallingConv::CSRet : return CallingConv::C;
1646 case OldCallingConv::Fast : return CallingConv::Fast;
1647 case OldCallingConv::Cold : return CallingConv::Cold;
1648 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1649 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1650 default:
1651 return CC;
1652 }
1653}
1654
Reid Spencer950bf602007-01-26 08:19:09 +00001655Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1656 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001657{
1658 Upgradelineno = 1;
1659 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001660 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001661 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001662 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001663 ObsoleteVarArgs = false;
1664 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001665
Reid Spencer950bf602007-01-26 08:19:09 +00001666 CurModule.CurrentModule = new Module(CurFilename);
1667
1668 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001669 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001670 if (ParserResult)
1671 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001672 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001673 return 0;
1674 }
1675
Reid Spencer950bf602007-01-26 08:19:09 +00001676 // Check to make sure that parsing produced a result
1677 if (!ParserResult) {
1678 std::cerr << "llvm-upgrade: no parse result.\n";
1679 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001680 }
1681
Reid Spencer950bf602007-01-26 08:19:09 +00001682 // Reset ParserResult variable while saving its value for the result.
1683 Module *Result = ParserResult;
1684 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001685
Reid Spencer950bf602007-01-26 08:19:09 +00001686 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001687 {
Reid Spencer950bf602007-01-26 08:19:09 +00001688 Function* F;
1689 if ((F = Result->getNamedFunction("llvm.va_start"))
1690 && F->getFunctionType()->getNumParams() == 0)
1691 ObsoleteVarArgs = true;
1692 if((F = Result->getNamedFunction("llvm.va_copy"))
1693 && F->getFunctionType()->getNumParams() == 1)
1694 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001695 }
Reid Spencer319a7302007-01-05 17:20:02 +00001696
Reid Spencer950bf602007-01-26 08:19:09 +00001697 if (ObsoleteVarArgs && NewVarArgs) {
1698 error("This file is corrupt: it uses both new and old style varargs");
1699 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001700 }
Reid Spencer319a7302007-01-05 17:20:02 +00001701
Reid Spencer950bf602007-01-26 08:19:09 +00001702 if(ObsoleteVarArgs) {
1703 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1704 if (F->arg_size() != 0) {
1705 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001706 return 0;
1707 }
Reid Spencer950bf602007-01-26 08:19:09 +00001708
1709 //foo = va_start()
1710 // ->
1711 //bar = alloca typeof(foo)
1712 //va_start(bar)
1713 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001714
Reid Spencer950bf602007-01-26 08:19:09 +00001715 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1716 const Type* ArgTy = F->getFunctionType()->getReturnType();
1717 const Type* ArgTyPtr = PointerType::get(ArgTy);
1718 Function* NF = cast<Function>(Result->getOrInsertFunction(
1719 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1720
1721 while (!F->use_empty()) {
1722 CallInst* CI = cast<CallInst>(F->use_back());
1723 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1724 new CallInst(NF, bar, "", CI);
1725 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1726 CI->replaceAllUsesWith(foo);
1727 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001728 }
Reid Spencer950bf602007-01-26 08:19:09 +00001729 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001730 }
Reid Spencer950bf602007-01-26 08:19:09 +00001731
1732 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1733 if(F->arg_size() != 1) {
1734 error("Obsolete va_end takes 1 argument");
1735 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001736 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001737
Reid Spencer950bf602007-01-26 08:19:09 +00001738 //vaend foo
1739 // ->
1740 //bar = alloca 1 of typeof(foo)
1741 //vaend bar
1742 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1743 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1744 const Type* ArgTyPtr = PointerType::get(ArgTy);
1745 Function* NF = cast<Function>(Result->getOrInsertFunction(
1746 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001747
Reid Spencer950bf602007-01-26 08:19:09 +00001748 while (!F->use_empty()) {
1749 CallInst* CI = cast<CallInst>(F->use_back());
1750 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1751 new StoreInst(CI->getOperand(1), bar, CI);
1752 new CallInst(NF, bar, "", CI);
1753 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001754 }
Reid Spencer950bf602007-01-26 08:19:09 +00001755 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001756 }
Reid Spencer950bf602007-01-26 08:19:09 +00001757
1758 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1759 if(F->arg_size() != 1) {
1760 error("Obsolete va_copy takes 1 argument");
1761 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001762 }
Reid Spencer950bf602007-01-26 08:19:09 +00001763 //foo = vacopy(bar)
1764 // ->
1765 //a = alloca 1 of typeof(foo)
1766 //b = alloca 1 of typeof(foo)
1767 //store bar -> b
1768 //vacopy(a, b)
1769 //foo = load a
1770
1771 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1772 const Type* ArgTy = F->getFunctionType()->getReturnType();
1773 const Type* ArgTyPtr = PointerType::get(ArgTy);
1774 Function* NF = cast<Function>(Result->getOrInsertFunction(
1775 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001776
Reid Spencer950bf602007-01-26 08:19:09 +00001777 while (!F->use_empty()) {
1778 CallInst* CI = cast<CallInst>(F->use_back());
1779 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1780 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1781 new StoreInst(CI->getOperand(1), b, CI);
1782 new CallInst(NF, a, b, "", CI);
1783 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1784 CI->replaceAllUsesWith(foo);
1785 CI->getParent()->getInstList().erase(CI);
1786 }
1787 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001788 }
1789 }
1790
Reid Spencer52402b02007-01-02 05:45:11 +00001791 return Result;
1792}
1793
Reid Spencer950bf602007-01-26 08:19:09 +00001794} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001795
Reid Spencer950bf602007-01-26 08:19:09 +00001796using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001797
1798
Reid Spencer319a7302007-01-05 17:20:02 +00001799
1800/* Enabling traces. */
1801#ifndef YYDEBUG
1802# define YYDEBUG 0
1803#endif
1804
1805/* Enabling verbose error messages. */
1806#ifdef YYERROR_VERBOSE
1807# undef YYERROR_VERBOSE
1808# define YYERROR_VERBOSE 1
1809#else
1810# define YYERROR_VERBOSE 0
1811#endif
1812
Reid Spencer950bf602007-01-26 08:19:09 +00001813/* Enabling the token table. */
1814#ifndef YYTOKEN_TABLE
1815# define YYTOKEN_TABLE 0
1816#endif
1817
Reid Spencerb7046c72007-01-29 05:41:34 +00001818#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer7de2e012007-01-29 19:08:46 +00001819#line 1440 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00001820typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00001821 llvm::Module *ModuleVal;
1822 llvm::Function *FunctionVal;
1823 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1824 llvm::BasicBlock *BasicBlockVal;
1825 llvm::TerminatorInst *TermInstVal;
1826 llvm::InstrInfo InstVal;
1827 llvm::ConstInfo ConstVal;
1828 llvm::ValueInfo ValueVal;
1829 llvm::PATypeInfo TypeVal;
1830 llvm::TypeInfo PrimType;
1831 llvm::PHIListInfo PHIList;
1832 std::list<llvm::PATypeInfo> *TypeList;
1833 std::vector<llvm::ValueInfo> *ValueList;
1834 std::vector<llvm::ConstInfo> *ConstVector;
1835
1836
1837 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1838 // Represent the RHS of PHI node
1839 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1840
1841 llvm::GlobalValue::LinkageTypes Linkage;
1842 int64_t SInt64Val;
1843 uint64_t UInt64Val;
1844 int SIntVal;
1845 unsigned UIntVal;
1846 double FPVal;
1847 bool BoolVal;
1848
1849 char *StrVal; // This memory is strdup'd!
1850 llvm::ValID ValIDVal; // strdup'd memory maybe!
1851
1852 llvm::BinaryOps BinaryOpVal;
1853 llvm::TermOps TermOpVal;
1854 llvm::MemoryOps MemOpVal;
1855 llvm::OtherOps OtherOpVal;
1856 llvm::CastOps CastOpVal;
1857 llvm::ICmpInst::Predicate IPred;
1858 llvm::FCmpInst::Predicate FPred;
1859 llvm::Module::Endianness Endianness;
Reid Spencerb7046c72007-01-29 05:41:34 +00001860} YYSTYPE;
1861/* Line 196 of yacc.c. */
Reid Spencer7de2e012007-01-29 19:08:46 +00001862#line 1863 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001863# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1864# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001865# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001866#endif
1867
Reid Spencer950bf602007-01-26 08:19:09 +00001868
Reid Spencere7c3c602006-11-30 06:36:44 +00001869
Reid Spencer319a7302007-01-05 17:20:02 +00001870/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001871
1872
Reid Spencerb7046c72007-01-29 05:41:34 +00001873/* Line 219 of yacc.c. */
Reid Spencer7de2e012007-01-29 19:08:46 +00001874#line 1875 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001875
Reid Spencerb7046c72007-01-29 05:41:34 +00001876#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1877# define YYSIZE_T __SIZE_TYPE__
Reid Spencer950bf602007-01-26 08:19:09 +00001878#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001879#if ! defined (YYSIZE_T) && defined (size_t)
1880# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001881#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001882#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1883# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1884# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001885#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001886#if ! defined (YYSIZE_T)
1887# define YYSIZE_T unsigned int
Reid Spencer950bf602007-01-26 08:19:09 +00001888#endif
1889
1890#ifndef YY_
1891# if YYENABLE_NLS
1892# if ENABLE_NLS
1893# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1894# define YY_(msgid) dgettext ("bison-runtime", msgid)
1895# endif
1896# endif
1897# ifndef YY_
1898# define YY_(msgid) msgid
1899# endif
1900#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001901
Reid Spencerb7046c72007-01-29 05:41:34 +00001902#if ! defined (yyoverflow) || YYERROR_VERBOSE
Reid Spencer319a7302007-01-05 17:20:02 +00001903
1904/* The parser invokes alloca or malloc; define the necessary symbols. */
1905
Reid Spencer950bf602007-01-26 08:19:09 +00001906# ifdef YYSTACK_USE_ALLOCA
1907# if YYSTACK_USE_ALLOCA
1908# ifdef __GNUC__
1909# define YYSTACK_ALLOC __builtin_alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001910# else
Reid Spencer950bf602007-01-26 08:19:09 +00001911# define YYSTACK_ALLOC alloca
Reid Spencerb7046c72007-01-29 05:41:34 +00001912# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00001913# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Reid Spencerb7046c72007-01-29 05:41:34 +00001914# define YYINCLUDED_STDLIB_H
Reid Spencer319a7302007-01-05 17:20:02 +00001915# endif
1916# endif
1917# endif
1918# endif
1919
1920# ifdef YYSTACK_ALLOC
Reid Spencerb7046c72007-01-29 05:41:34 +00001921 /* Pacify GCC's `empty if-body' warning. */
1922# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00001923# ifndef YYSTACK_ALLOC_MAXIMUM
1924 /* The OS might guarantee only one guard page at the bottom of the stack,
1925 and a page size can be as small as 4096 bytes. So we cannot safely
1926 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1927 to allow for a few compiler-allocated temporary stack slots. */
Reid Spencerb7046c72007-01-29 05:41:34 +00001928# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer319a7302007-01-05 17:20:02 +00001929# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001930# else
1931# define YYSTACK_ALLOC YYMALLOC
1932# define YYSTACK_FREE YYFREE
1933# ifndef YYSTACK_ALLOC_MAXIMUM
Reid Spencerb7046c72007-01-29 05:41:34 +00001934# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
Reid Spencer950bf602007-01-26 08:19:09 +00001935# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001936# ifdef __cplusplus
1937extern "C" {
Reid Spencer950bf602007-01-26 08:19:09 +00001938# endif
1939# ifndef YYMALLOC
1940# define YYMALLOC malloc
Reid Spencerb7046c72007-01-29 05:41:34 +00001941# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1942 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001943void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1944# endif
1945# endif
1946# ifndef YYFREE
1947# define YYFREE free
Reid Spencerb7046c72007-01-29 05:41:34 +00001948# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1949 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001950void free (void *); /* INFRINGES ON USER NAME SPACE */
1951# endif
1952# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001953# ifdef __cplusplus
1954}
1955# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001956# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001957#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00001958
1959
Reid Spencerb7046c72007-01-29 05:41:34 +00001960#if (! defined (yyoverflow) \
1961 && (! defined (__cplusplus) \
1962 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001963
1964/* A type that is properly aligned for any stack member. */
1965union yyalloc
1966{
Reid Spencerb7046c72007-01-29 05:41:34 +00001967 short int yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001968 YYSTYPE yyvs;
1969 };
1970
1971/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00001972# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00001973
1974/* The size of an array large to enough to hold all stacks, each with
1975 N elements. */
1976# define YYSTACK_BYTES(N) \
Reid Spencerb7046c72007-01-29 05:41:34 +00001977 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer950bf602007-01-26 08:19:09 +00001978 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00001979
1980/* Copy COUNT objects from FROM to TO. The source and destination do
1981 not overlap. */
1982# ifndef YYCOPY
Reid Spencerb7046c72007-01-29 05:41:34 +00001983# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00001984# define YYCOPY(To, From, Count) \
1985 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1986# else
1987# define YYCOPY(To, From, Count) \
1988 do \
1989 { \
Reid Spencer950bf602007-01-26 08:19:09 +00001990 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00001991 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00001992 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00001993 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00001994 while (0)
Reid Spencer319a7302007-01-05 17:20:02 +00001995# endif
1996# endif
1997
1998/* Relocate STACK from its old location to the new one. The
1999 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2000 elements in the stack, and YYPTR gives the new location of the
2001 stack. Advance YYPTR to a properly aligned location for the next
2002 stack. */
2003# define YYSTACK_RELOCATE(Stack) \
2004 do \
2005 { \
2006 YYSIZE_T yynewbytes; \
2007 YYCOPY (&yyptr->Stack, Stack, yysize); \
2008 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00002009 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00002010 yyptr += yynewbytes / sizeof (*yyptr); \
2011 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00002012 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00002013
2014#endif
2015
Reid Spencerb7046c72007-01-29 05:41:34 +00002016#if defined (__STDC__) || defined (__cplusplus)
2017 typedef signed char yysigned_char;
2018#else
2019 typedef short int yysigned_char;
2020#endif
2021
2022/* YYFINAL -- State number of the termination state. */
Reid Spencer319a7302007-01-05 17:20:02 +00002023#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00002024/* YYLAST -- Last index in YYTABLE. */
2025#define YYLAST 1712
Reid Spencer319a7302007-01-05 17:20:02 +00002026
Reid Spencerb7046c72007-01-29 05:41:34 +00002027/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002028#define YYNTOKENS 166
Reid Spencerb7046c72007-01-29 05:41:34 +00002029/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002030#define YYNNTS 79
Reid Spencerb7046c72007-01-29 05:41:34 +00002031/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00002032#define YYNRULES 308
Reid Spencerb7046c72007-01-29 05:41:34 +00002033/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00002034#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00002035
2036/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2037#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00002038#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00002039
Reid Spencer950bf602007-01-26 08:19:09 +00002040#define YYTRANSLATE(YYX) \
2041 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00002042
2043/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002044static const unsigned char yytranslate[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002045{
2046 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002050 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002051 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002052 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002053 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002055 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2057 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002058 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002059 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2060 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2061 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2062 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2063 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2064 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2065 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2066 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2067 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2071 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2072 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2073 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2074 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2075 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2076 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2077 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2078 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2079 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2080 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2081 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2082 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2083 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2084 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2085 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002086 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002087};
2088
2089#if YYDEBUG
2090/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2091 YYRHS. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002092static const unsigned short int yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002093{
2094 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2095 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2096 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2097 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2098 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2099 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2100 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2101 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2102 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002103 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002104 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2105 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2106 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2107 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2108 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002109 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2110 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2111 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2112 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2113 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2114 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2115 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2116 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2117 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2118 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2119 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2120 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2121 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2122 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2123 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2124 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002125};
2126
Reid Spencerb7046c72007-01-29 05:41:34 +00002127/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2128static const short int yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002129{
Reid Spencer950bf602007-01-26 08:19:09 +00002130 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002131 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2132 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2133 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2134 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
Reid Spencer950bf602007-01-26 08:19:09 +00002135 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2136 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2137 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2138 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2139 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2140 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2141 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2142 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2143 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2144 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2145 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2146 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2147 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2148 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2149 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2150 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2151 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2152 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002153 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002154 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2155 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2156 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2157 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2158 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2159 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2160 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2161 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2162 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2163 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2164 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2165 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2166 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2167 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2168 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2169 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2170 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2171 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2172 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2173 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2174 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2175 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2176 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2177 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2178 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2179 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2180 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2181 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2182 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2183 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2184 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2185 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2186 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2187 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2188 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2189 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2190 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2191 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2192 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2193 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2194 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2195 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2196 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2197 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2198 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2199 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2200 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2201 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2202 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2203 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2204 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2205 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2206 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2207 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2208 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2209 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2210 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2211 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2212 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2213 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2214 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2215 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2216 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2217 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2218 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2219 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2220 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2221 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2222 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2223 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2224 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2225 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2226 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002227};
2228
2229/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002230static const unsigned short int yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002231{
Reid Spencer7de2e012007-01-29 19:08:46 +00002232 0, 1580, 1580, 1581, 1589, 1590, 1600, 1600, 1600, 1600,
2233 1600, 1600, 1600, 1600, 1600, 1600, 1600, 1604, 1604, 1604,
2234 1608, 1608, 1608, 1608, 1608, 1608, 1612, 1612, 1613, 1613,
2235 1614, 1614, 1615, 1615, 1616, 1616, 1620, 1620, 1621, 1621,
2236 1622, 1622, 1623, 1623, 1624, 1624, 1625, 1625, 1626, 1626,
2237 1627, 1628, 1631, 1631, 1631, 1631, 1635, 1635, 1635, 1635,
2238 1635, 1635, 1635, 1636, 1636, 1636, 1636, 1636, 1636, 1642,
2239 1642, 1642, 1642, 1646, 1646, 1646, 1646, 1650, 1650, 1654,
2240 1654, 1659, 1662, 1667, 1668, 1669, 1670, 1671, 1672, 1673,
2241 1674, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1695,
2242 1696, 1704, 1705, 1713, 1722, 1723, 1730, 1731, 1735, 1739,
2243 1755, 1756, 1763, 1764, 1771, 1779, 1779, 1779, 1779, 1779,
2244 1779, 1779, 1780, 1780, 1780, 1780, 1780, 1785, 1789, 1793,
2245 1798, 1807, 1828, 1834, 1847, 1856, 1860, 1871, 1875, 1888,
2246 1892, 1899, 1900, 1906, 1913, 1925, 1955, 1968, 1991, 2019,
2247 2041, 2052, 2074, 2085, 2094, 2099, 2157, 2164, 2172, 2179,
2248 2186, 2190, 2194, 2203, 2218, 2231, 2240, 2268, 2281, 2290,
2249 2296, 2302, 2311, 2317, 2323, 2334, 2335, 2344, 2345, 2357,
2250 2366, 2367, 2368, 2369, 2370, 2386, 2406, 2408, 2410, 2410,
2251 2417, 2417, 2424, 2424, 2431, 2431, 2439, 2441, 2443, 2448,
2252 2462, 2463, 2467, 2470, 2478, 2482, 2489, 2493, 2497, 2501,
2253 2509, 2509, 2513, 2514, 2518, 2526, 2531, 2539, 2540, 2547,
2254 2554, 2558, 2673, 2673, 2677, 2687, 2687, 2691, 2695, 2697,
2255 2698, 2702, 2702, 2714, 2715, 2720, 2721, 2722, 2723, 2724,
2256 2725, 2726, 2727, 2728, 2749, 2752, 2767, 2768, 2773, 2773,
2257 2781, 2790, 2793, 2802, 2812, 2817, 2826, 2837, 2837, 2840,
2258 2843, 2846, 2850, 2856, 2871, 2877, 2933, 2936, 2942, 2952,
2259 2965, 2994, 3002, 3010, 3014, 3021, 3022, 3026, 3029, 3035,
2260 3052, 3068, 3082, 3094, 3106, 3117, 3126, 3135, 3144, 3151,
2261 3172, 3196, 3202, 3208, 3214, 3230, 3308, 3316, 3317, 3321,
2262 3322, 3326, 3332, 3338, 3344, 3350, 3357, 3369, 3383
Reid Spencer319a7302007-01-05 17:20:02 +00002263};
2264#endif
2265
Reid Spencer950bf602007-01-26 08:19:09 +00002266#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2267/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencerb7046c72007-01-29 05:41:34 +00002268 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer319a7302007-01-05 17:20:02 +00002269static const char *const yytname[] =
2270{
Reid Spencer950bf602007-01-26 08:19:09 +00002271 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2272 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2273 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2274 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2275 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2276 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2277 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2278 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2279 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2280 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2281 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2282 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2283 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2284 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2285 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2286 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2287 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2288 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2289 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2290 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2291 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2292 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2293 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2294 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2295 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2296 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2297 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2298 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2299 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2300 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2301 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2302 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2303 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2304 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2305 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2306 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2307 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2308 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2309 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002310 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002311};
2312#endif
2313
2314# ifdef YYPRINT
2315/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2316 token YYLEX-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002317static const unsigned short int yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002318{
2319 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2320 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2321 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2322 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2323 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2324 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2325 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2326 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2327 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2328 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2329 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2330 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2331 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2332 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2333 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002334 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2335 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002336};
2337# endif
2338
2339/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002340static const unsigned char yyr1[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002341{
Reid Spencer950bf602007-01-26 08:19:09 +00002342 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2343 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2344 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2345 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2346 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2347 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2348 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2349 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2350 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2351 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2352 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2353 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2354 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2355 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2356 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2357 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2358 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2359 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2360 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2361 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2362 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2363 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2364 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2365 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2366 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2367 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2368 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2369 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2370 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2371 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2372 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002373};
2374
2375/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002376static const unsigned char yyr2[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002377{
2378 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2379 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2381 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2382 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2383 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2384 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2385 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2386 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002387 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002388 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2389 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2390 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2391 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2392 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002393 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2394 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2395 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2396 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2397 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2398 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2399 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2400 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2401 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2402 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2403 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2404 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2405 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2406 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2407 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2408 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002409};
2410
2411/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2412 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2413 means the default is an error. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002414static const unsigned short int yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002415{
Reid Spencer950bf602007-01-26 08:19:09 +00002416 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2417 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2418 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2419 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2420 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2421 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2422 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2423 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2424 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2425 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2426 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2427 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2428 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2429 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2430 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2431 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2432 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2433 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2434 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2435 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2436 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2437 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2438 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2439 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2440 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2441 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2442 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2443 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2444 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002445 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002446 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2447 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002448 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002449 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2450 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2451 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2452 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2453 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2454 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2455 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2456 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2457 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2458 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2459 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2460 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2461 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2462 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2463 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2464 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2465 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2466 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2467 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2468 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2469 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2470 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2471 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2472 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2473 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2474 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2475 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2476 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002477};
2478
Reid Spencerb7046c72007-01-29 05:41:34 +00002479/* YYDEFGOTO[NTERM-NUM]. */
2480static const short int yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002481{
Reid Spencer950bf602007-01-26 08:19:09 +00002482 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2483 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2484 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2485 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2486 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2487 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2488 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2489 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002490};
2491
2492/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2493 STATE-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002494#define YYPACT_NINF -508
Reid Spencerb7046c72007-01-29 05:41:34 +00002495static const short int yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002496{
Reid Spencer950bf602007-01-26 08:19:09 +00002497 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2498 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2499 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2500 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2501 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2502 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2503 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2504 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2505 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2506 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2507 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2508 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2509 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2510 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2511 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2512 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2513 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2514 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2515 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2516 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2517 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2518 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2519 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2520 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2521 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2522 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2523 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2524 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2525 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2526 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2527 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2528 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2529 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2530 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2531 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2532 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2533 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2534 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2535 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2536 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2537 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2538 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2539 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2540 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2541 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2542 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2543 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2544 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2545 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2546 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2547 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2548 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2549 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2550 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2551 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2552 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2553 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2554 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2555 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2556 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2557 898, 898, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002558};
2559
2560/* YYPGOTO[NTERM-NUM]. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002561static const short int yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002562{
Reid Spencer950bf602007-01-26 08:19:09 +00002563 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2564 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2565 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2566 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2567 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2568 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2569 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2570 -508, -508, 43, -22, -508, -508, 21, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002571};
2572
2573/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2574 positive, shift that token. If negative, reduce the rule which
2575 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002576 If YYTABLE_NINF, syntax error. */
2577#define YYTABLE_NINF -180
Reid Spencerb7046c72007-01-29 05:41:34 +00002578static const short int yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002579{
Reid Spencer950bf602007-01-26 08:19:09 +00002580 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2581 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2582 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2583 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2584 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2585 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2586 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2587 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2588 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2589 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2590 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2591 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2592 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2593 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2594 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2595 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2596 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2597 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2598 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2599 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2600 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2601 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2602 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2603 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2604 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2605 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2606 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2607 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2608 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2609 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2610 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2611 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2612 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2613 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2614 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2615 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2616 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2617 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2618 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2619 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2620 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2621 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2622 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2623 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2624 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2625 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2626 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2627 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2628 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2629 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2630 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2631 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2632 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2633 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2634 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2635 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2636 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2637 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2638 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2639 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2640 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2641 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2642 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2643 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2644 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2645 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2646 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2647 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2648 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2649 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2650 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2651 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2652 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2653 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2654 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2655 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2656 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2657 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2658 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2659 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2660 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2661 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2662 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
Reid Spencerc4d96252007-01-13 00:03:30 +00002663 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002664 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2665 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2666 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2667 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002668 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002669 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2670 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2671 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2672 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2673 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2674 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2675 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2676 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2677 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2678 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2679 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2680 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2681 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2682 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2683 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2684 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2685 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2686 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2687 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2688 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2689 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2690 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2691 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2692 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2693 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2694 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2695 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2696 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2697 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2698 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2699 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2700 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2701 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2702 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2703 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2704 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2705 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2706 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2707 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2708 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2709 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2710 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2711 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2712 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2713 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2714 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2715 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2716 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2717 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2718 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2719 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2720 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2721 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2722 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2723 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2724 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2725 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2726 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2727 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2728 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2729 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2730 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2731 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2732 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2733 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002734 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2735 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002736 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2737 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2738 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2739 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002740 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002741 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2742 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2743 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2744 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2745 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2746 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2747 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2748 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2749 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2750 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2751 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002752};
2753
Reid Spencerb7046c72007-01-29 05:41:34 +00002754static const short int yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002755{
Reid Spencer950bf602007-01-26 08:19:09 +00002756 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2757 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2758 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2759 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2760 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2761 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2762 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2763 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2764 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2765 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2766 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2767 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2768 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2769 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2770 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2771 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2772 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2773 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2774 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2775 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2776 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2777 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2778 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2779 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2780 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2781 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2782 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2783 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2784 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2785 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2786 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2787 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2788 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2789 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2790 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2791 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2792 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2793 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2794 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2795 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2796 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2797 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2798 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2799 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2800 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2801 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2802 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2803 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2804 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2805 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2806 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2807 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
Reid Spencerc4d96252007-01-13 00:03:30 +00002808 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
Reid Spencer950bf602007-01-26 08:19:09 +00002809 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2810 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2811 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2812 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2813 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2814 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2815 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2816 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2817 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2818 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2819 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2820 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2821 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2822 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2823 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2824 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2825 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2826 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2827 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2828 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2829 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2830 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2831 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2832 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2833 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2834 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2835 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2836 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2837 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2838 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2839 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2840 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2841 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2842 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2843 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2844 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2845 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2846 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2847 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2848 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2849 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2850 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2851 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2852 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2853 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2854 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2855 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2856 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2857 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2858 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2859 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2860 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2861 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2862 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2863 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2864 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2865 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2866 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2867 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2868 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2869 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2870 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2871 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2872 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2873 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2874 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2875 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2876 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2877 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2878 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2879 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2880 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2881 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2882 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2883 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2884 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2885 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2886 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2887 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2888 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2889 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2890 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2891 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2892 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2893 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2894 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2895 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2896 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2897 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2898 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2899 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2900 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2901 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2902 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2903 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2904 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2905 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2906 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2907 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2908 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2909 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2910 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2911 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2912 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2913 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2914 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2915 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2916 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2917 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2918 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2919 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2920 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2921 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2922 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2923 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2924 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2925 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2926 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2927 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002928};
2929
2930/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2931 symbol of state STATE-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002932static const unsigned char yystos[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002933{
Reid Spencer950bf602007-01-26 08:19:09 +00002934 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2935 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2936 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2937 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2938 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2939 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2940 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2941 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2942 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2943 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2944 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2945 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2946 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2947 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2948 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2949 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2950 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2951 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2952 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2953 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2954 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2955 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2956 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2957 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2958 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2959 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2960 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2961 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2962 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2963 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2964 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2965 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2966 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2967 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2968 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2969 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2970 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2971 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2972 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2973 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2974 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2975 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2976 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2977 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2978 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2979 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2980 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2981 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2982 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2983 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2984 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2985 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2986 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2987 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2988 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2989 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2990 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2991 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2992 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2993 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2994 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00002995};
Reid Spencere7c3c602006-11-30 06:36:44 +00002996
2997#define yyerrok (yyerrstatus = 0)
2998#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00002999#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003000#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00003001
Reid Spencere7c3c602006-11-30 06:36:44 +00003002#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00003003#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00003004#define YYERROR goto yyerrorlab
3005
Reid Spencer319a7302007-01-05 17:20:02 +00003006
3007/* Like YYERROR except do call yyerror. This remains here temporarily
3008 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003009 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00003010
Reid Spencere7c3c602006-11-30 06:36:44 +00003011#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00003012
Reid Spencere7c3c602006-11-30 06:36:44 +00003013#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00003014
3015#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003016do \
3017 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00003018 { \
3019 yychar = (Token); \
3020 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00003021 yytoken = YYTRANSLATE (yychar); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003022 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003023 goto yybackup; \
3024 } \
3025 else \
Reid Spencer950bf602007-01-26 08:19:09 +00003026 { \
3027 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00003028 YYERROR; \
3029 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003030while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003031
Reid Spencer950bf602007-01-26 08:19:09 +00003032
Reid Spencere7c3c602006-11-30 06:36:44 +00003033#define YYTERROR 1
3034#define YYERRCODE 256
3035
Reid Spencer319a7302007-01-05 17:20:02 +00003036
Reid Spencer950bf602007-01-26 08:19:09 +00003037/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3038 If N is 0, then set CURRENT to the empty location which ends
3039 the previous symbol: RHS[0] (always defined). */
3040
3041#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00003042#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00003043# define YYLLOC_DEFAULT(Current, Rhs, N) \
3044 do \
Reid Spencerb7046c72007-01-29 05:41:34 +00003045 if (N) \
Reid Spencer950bf602007-01-26 08:19:09 +00003046 { \
3047 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3048 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3049 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3050 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3051 } \
3052 else \
3053 { \
3054 (Current).first_line = (Current).last_line = \
3055 YYRHSLOC (Rhs, 0).last_line; \
3056 (Current).first_column = (Current).last_column = \
3057 YYRHSLOC (Rhs, 0).last_column; \
3058 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003059 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003060#endif
3061
Reid Spencer950bf602007-01-26 08:19:09 +00003062
3063/* YY_LOCATION_PRINT -- Print the location on the stream.
3064 This macro was not mandated originally: define only if we know
3065 we won't break user code: when these are the locations we know. */
3066
3067#ifndef YY_LOCATION_PRINT
3068# if YYLTYPE_IS_TRIVIAL
3069# define YY_LOCATION_PRINT(File, Loc) \
3070 fprintf (File, "%d.%d-%d.%d", \
Reid Spencerb7046c72007-01-29 05:41:34 +00003071 (Loc).first_line, (Loc).first_column, \
3072 (Loc).last_line, (Loc).last_column)
Reid Spencer950bf602007-01-26 08:19:09 +00003073# else
3074# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3075# endif
3076#endif
3077
3078
Reid Spencer319a7302007-01-05 17:20:02 +00003079/* YYLEX -- calling `yylex' with the right arguments. */
3080
Reid Spencer950bf602007-01-26 08:19:09 +00003081#ifdef YYLEX_PARAM
3082# define YYLEX yylex (YYLEX_PARAM)
3083#else
3084# define YYLEX yylex ()
3085#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003086
3087/* Enable debugging if requested. */
3088#if YYDEBUG
3089
3090# ifndef YYFPRINTF
3091# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3092# define YYFPRINTF fprintf
3093# endif
3094
3095# define YYDPRINTF(Args) \
3096do { \
3097 if (yydebug) \
3098 YYFPRINTF Args; \
Reid Spencerb7046c72007-01-29 05:41:34 +00003099} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003100
Reid Spencerb7046c72007-01-29 05:41:34 +00003101# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3102do { \
3103 if (yydebug) \
3104 { \
3105 YYFPRINTF (stderr, "%s ", Title); \
3106 yysymprint (stderr, \
3107 Type, Value); \
3108 YYFPRINTF (stderr, "\n"); \
3109 } \
3110} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003111
3112/*------------------------------------------------------------------.
3113| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3114| TOP (included). |
3115`------------------------------------------------------------------*/
3116
Reid Spencerb7046c72007-01-29 05:41:34 +00003117#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003118static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003119yy_stack_print (short int *bottom, short int *top)
Reid Spencer950bf602007-01-26 08:19:09 +00003120#else
3121static void
3122yy_stack_print (bottom, top)
Reid Spencerb7046c72007-01-29 05:41:34 +00003123 short int *bottom;
3124 short int *top;
Reid Spencer950bf602007-01-26 08:19:09 +00003125#endif
3126{
3127 YYFPRINTF (stderr, "Stack now");
Reid Spencerb7046c72007-01-29 05:41:34 +00003128 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer950bf602007-01-26 08:19:09 +00003129 YYFPRINTF (stderr, " %d", *bottom);
3130 YYFPRINTF (stderr, "\n");
3131}
3132
3133# define YY_STACK_PRINT(Bottom, Top) \
3134do { \
3135 if (yydebug) \
3136 yy_stack_print ((Bottom), (Top)); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003137} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003138
3139
3140/*------------------------------------------------.
3141| Report that the YYRULE is going to be reduced. |
3142`------------------------------------------------*/
3143
Reid Spencerb7046c72007-01-29 05:41:34 +00003144#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003145static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003146yy_reduce_print (int yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003147#else
3148static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003149yy_reduce_print (yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003150 int yyrule;
3151#endif
3152{
3153 int yyi;
3154 unsigned long int yylno = yyrline[yyrule];
Reid Spencerb7046c72007-01-29 05:41:34 +00003155 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3156 yyrule - 1, yylno);
3157 /* Print the symbols being reduced, and their result. */
3158 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3159 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3160 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer950bf602007-01-26 08:19:09 +00003161}
3162
3163# define YY_REDUCE_PRINT(Rule) \
3164do { \
3165 if (yydebug) \
Reid Spencerb7046c72007-01-29 05:41:34 +00003166 yy_reduce_print (Rule); \
3167} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003168
Reid Spencer319a7302007-01-05 17:20:02 +00003169/* Nonzero means print parse trace. It is left uninitialized so that
3170 multiple parsers can coexist. */
3171int yydebug;
3172#else /* !YYDEBUG */
3173# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003174# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3175# define YY_STACK_PRINT(Bottom, Top)
3176# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003177#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003178
Reid Spencer950bf602007-01-26 08:19:09 +00003179
Reid Spencer319a7302007-01-05 17:20:02 +00003180/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003181#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003182# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003183#endif
3184
Reid Spencer319a7302007-01-05 17:20:02 +00003185/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3186 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003187
Reid Spencer319a7302007-01-05 17:20:02 +00003188 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003189 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003190 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003191
3192#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003193# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003194#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003195
Reid Spencere7c3c602006-11-30 06:36:44 +00003196
3197
Reid Spencer319a7302007-01-05 17:20:02 +00003198#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003199
Reid Spencer319a7302007-01-05 17:20:02 +00003200# ifndef yystrlen
Reid Spencerb7046c72007-01-29 05:41:34 +00003201# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer319a7302007-01-05 17:20:02 +00003202# define yystrlen strlen
3203# else
3204/* Return the length of YYSTR. */
3205static YYSIZE_T
Reid Spencerb7046c72007-01-29 05:41:34 +00003206# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003207yystrlen (const char *yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003208# else
Reid Spencer319a7302007-01-05 17:20:02 +00003209yystrlen (yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003210 const char *yystr;
3211# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003212{
Reid Spencerb7046c72007-01-29 05:41:34 +00003213 const char *yys = yystr;
3214
3215 while (*yys++ != '\0')
Reid Spencer319a7302007-01-05 17:20:02 +00003216 continue;
Reid Spencerb7046c72007-01-29 05:41:34 +00003217
3218 return yys - yystr - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003219}
Reid Spencer319a7302007-01-05 17:20:02 +00003220# endif
3221# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003222
Reid Spencer319a7302007-01-05 17:20:02 +00003223# ifndef yystpcpy
Reid Spencerb7046c72007-01-29 05:41:34 +00003224# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer319a7302007-01-05 17:20:02 +00003225# define yystpcpy stpcpy
3226# else
3227/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3228 YYDEST. */
3229static char *
Reid Spencerb7046c72007-01-29 05:41:34 +00003230# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003231yystpcpy (char *yydest, const char *yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003232# else
Reid Spencer319a7302007-01-05 17:20:02 +00003233yystpcpy (yydest, yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003234 char *yydest;
3235 const char *yysrc;
3236# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003237{
Reid Spencer950bf602007-01-26 08:19:09 +00003238 char *yyd = yydest;
3239 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003240
Reid Spencer319a7302007-01-05 17:20:02 +00003241 while ((*yyd++ = *yys++) != '\0')
3242 continue;
3243
3244 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003245}
Reid Spencer319a7302007-01-05 17:20:02 +00003246# endif
3247# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003248
Reid Spencer950bf602007-01-26 08:19:09 +00003249# ifndef yytnamerr
3250/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3251 quotes and backslashes, so that it's suitable for yyerror. The
3252 heuristic is that double-quoting is unnecessary unless the string
3253 contains an apostrophe, a comma, or backslash (other than
3254 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3255 null, do not copy; instead, return the length of what the result
3256 would have been. */
3257static YYSIZE_T
3258yytnamerr (char *yyres, const char *yystr)
3259{
3260 if (*yystr == '"')
3261 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003262 size_t yyn = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00003263 char const *yyp = yystr;
3264
3265 for (;;)
3266 switch (*++yyp)
3267 {
3268 case '\'':
3269 case ',':
3270 goto do_not_strip_quotes;
3271
3272 case '\\':
3273 if (*++yyp != '\\')
3274 goto do_not_strip_quotes;
3275 /* Fall through. */
3276 default:
3277 if (yyres)
3278 yyres[yyn] = *yyp;
3279 yyn++;
3280 break;
3281
3282 case '"':
3283 if (yyres)
3284 yyres[yyn] = '\0';
3285 return yyn;
3286 }
3287 do_not_strip_quotes: ;
3288 }
3289
3290 if (! yyres)
3291 return yystrlen (yystr);
3292
3293 return yystpcpy (yyres, yystr) - yyres;
3294}
3295# endif
3296
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003297#endif /* YYERROR_VERBOSE */
Reid Spencerb7046c72007-01-29 05:41:34 +00003298
Reid Spencere7c3c602006-11-30 06:36:44 +00003299
3300
Reid Spencerb7046c72007-01-29 05:41:34 +00003301#if YYDEBUG
3302/*--------------------------------.
3303| Print this symbol on YYOUTPUT. |
3304`--------------------------------*/
3305
3306#if defined (__STDC__) || defined (__cplusplus)
3307static void
3308yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
3309#else
3310static void
3311yysymprint (yyoutput, yytype, yyvaluep)
3312 FILE *yyoutput;
3313 int yytype;
3314 YYSTYPE *yyvaluep;
3315#endif
3316{
3317 /* Pacify ``unused variable'' warnings. */
3318 (void) yyvaluep;
3319
3320 if (yytype < YYNTOKENS)
3321 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3322 else
3323 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3324
3325
3326# ifdef YYPRINT
3327 if (yytype < YYNTOKENS)
3328 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3329# endif
3330 switch (yytype)
3331 {
3332 default:
3333 break;
3334 }
3335 YYFPRINTF (yyoutput, ")");
3336}
3337
3338#endif /* ! YYDEBUG */
Reid Spencer319a7302007-01-05 17:20:02 +00003339/*-----------------------------------------------.
3340| Release the memory associated to this symbol. |
3341`-----------------------------------------------*/
3342
Reid Spencerb7046c72007-01-29 05:41:34 +00003343#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003344static void
3345yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003346#else
Reid Spencer950bf602007-01-26 08:19:09 +00003347static void
3348yydestruct (yymsg, yytype, yyvaluep)
3349 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003350 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003351 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003352#endif
3353{
Reid Spencerb7046c72007-01-29 05:41:34 +00003354 /* Pacify ``unused variable'' warnings. */
3355 (void) yyvaluep;
Reid Spencer950bf602007-01-26 08:19:09 +00003356
3357 if (!yymsg)
3358 yymsg = "Deleting";
3359 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003360
3361 switch (yytype)
3362 {
Reid Spencer950bf602007-01-26 08:19:09 +00003363
Reid Spencer319a7302007-01-05 17:20:02 +00003364 default:
Reid Spencerb7046c72007-01-29 05:41:34 +00003365 break;
Reid Spencer319a7302007-01-05 17:20:02 +00003366 }
3367}
3368
3369
Reid Spencer950bf602007-01-26 08:19:09 +00003370/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003371
3372#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003373# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003374int yyparse (void *YYPARSE_PARAM);
Reid Spencerb7046c72007-01-29 05:41:34 +00003375# else
Reid Spencer950bf602007-01-26 08:19:09 +00003376int yyparse ();
Reid Spencerb7046c72007-01-29 05:41:34 +00003377# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003378#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003379#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003380int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003381#else
3382int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003383#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003384#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003385
3386
Reid Spencer950bf602007-01-26 08:19:09 +00003387
3388/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003389int yychar;
3390
Reid Spencer950bf602007-01-26 08:19:09 +00003391/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003392YYSTYPE yylval;
3393
Reid Spencer950bf602007-01-26 08:19:09 +00003394/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003395int yynerrs;
3396
3397
Reid Spencer950bf602007-01-26 08:19:09 +00003398
3399/*----------.
3400| yyparse. |
3401`----------*/
3402
3403#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003404# if defined (__STDC__) || defined (__cplusplus)
3405int yyparse (void *YYPARSE_PARAM)
3406# else
3407int yyparse (YYPARSE_PARAM)
3408 void *YYPARSE_PARAM;
3409# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003410#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003411#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003412int
Reid Spencer950bf602007-01-26 08:19:09 +00003413yyparse (void)
3414#else
3415int
3416yyparse ()
3417
3418#endif
3419#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003420{
3421
Reid Spencer950bf602007-01-26 08:19:09 +00003422 int yystate;
3423 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003424 int yyresult;
3425 /* Number of tokens to shift before error messages enabled. */
3426 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003427 /* Look-ahead token as an internal (translated) token number. */
3428 int yytoken = 0;
Reid Spencer319a7302007-01-05 17:20:02 +00003429
3430 /* Three stacks and their tools:
3431 `yyss': related to states,
3432 `yyvs': related to semantic values,
3433 `yyls': related to locations.
3434
3435 Refer to the stacks thru separate pointers, to allow yyoverflow
3436 to reallocate them elsewhere. */
3437
3438 /* The state stack. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003439 short int yyssa[YYINITDEPTH];
3440 short int *yyss = yyssa;
3441 short int *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003442
3443 /* The semantic value stack. */
3444 YYSTYPE yyvsa[YYINITDEPTH];
3445 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003446 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003447
3448
3449
Reid Spencerb7046c72007-01-29 05:41:34 +00003450#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003451
Reid Spencer319a7302007-01-05 17:20:02 +00003452 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003453
Reid Spencer319a7302007-01-05 17:20:02 +00003454 /* The variables used to return semantic value and location from the
3455 action routines. */
3456 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003457
3458
Reid Spencerb7046c72007-01-29 05:41:34 +00003459 /* When reducing, the number of symbols on the RHS of the reduced
3460 rule. */
3461 int yylen;
Reid Spencere7c3c602006-11-30 06:36:44 +00003462
Reid Spencer319a7302007-01-05 17:20:02 +00003463 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003464
3465 yystate = 0;
3466 yyerrstatus = 0;
3467 yynerrs = 0;
3468 yychar = YYEMPTY; /* Cause a token to be read. */
3469
3470 /* Initialize stack pointers.
3471 Waste one element of value and location stack
3472 so that they stay on the same level as the state stack.
3473 The wasted elements are never initialized. */
3474
Reid Spencer319a7302007-01-05 17:20:02 +00003475 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003476 yyvsp = yyvs;
3477
Reid Spencer319a7302007-01-05 17:20:02 +00003478 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003479
Reid Spencer319a7302007-01-05 17:20:02 +00003480/*------------------------------------------------------------.
3481| yynewstate -- Push a new state, which is found in yystate. |
3482`------------------------------------------------------------*/
3483 yynewstate:
3484 /* In all cases, when you get here, the value and location stacks
Reid Spencerb7046c72007-01-29 05:41:34 +00003485 have just been pushed. so pushing a state here evens the stacks.
3486 */
Reid Spencer319a7302007-01-05 17:20:02 +00003487 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003488
Reid Spencer319a7302007-01-05 17:20:02 +00003489 yysetstate:
3490 *yyssp = yystate;
3491
Reid Spencer950bf602007-01-26 08:19:09 +00003492 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003493 {
3494 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003495 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003496
3497#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003498 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003499 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer319a7302007-01-05 17:20:02 +00003500 these so that the &'s don't force the real ones into
3501 memory. */
3502 YYSTYPE *yyvs1 = yyvs;
Reid Spencerb7046c72007-01-29 05:41:34 +00003503 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003504
Reid Spencer319a7302007-01-05 17:20:02 +00003505
3506 /* Each stack pointer address is followed by the size of the
3507 data in use in that stack, in bytes. This used to be a
3508 conditional around just the two extra args, but that might
3509 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003510 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003511 &yyss1, yysize * sizeof (*yyssp),
3512 &yyvs1, yysize * sizeof (*yyvsp),
3513
3514 &yystacksize);
3515
3516 yyss = yyss1;
3517 yyvs = yyvs1;
3518 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003519#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003520# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003521 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003522# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003523 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003524 if (YYMAXDEPTH <= yystacksize)
3525 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003526 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003527 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003528 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003529
3530 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003531 short int *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003532 union yyalloc *yyptr =
3533 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3534 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003535 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003536 YYSTACK_RELOCATE (yyss);
3537 YYSTACK_RELOCATE (yyvs);
3538
3539# undef YYSTACK_RELOCATE
3540 if (yyss1 != yyssa)
3541 YYSTACK_FREE (yyss1);
3542 }
3543# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003544#endif /* no yyoverflow */
3545
Reid Spencer319a7302007-01-05 17:20:02 +00003546 yyssp = yyss + yysize - 1;
3547 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003548
3549
Reid Spencer319a7302007-01-05 17:20:02 +00003550 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3551 (unsigned long int) yystacksize));
3552
Reid Spencer950bf602007-01-26 08:19:09 +00003553 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003554 YYABORT;
3555 }
3556
Reid Spencer319a7302007-01-05 17:20:02 +00003557 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003558
3559 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003560
3561/*-----------.
3562| yybackup. |
3563`-----------*/
3564yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003565
Reid Spencerb7046c72007-01-29 05:41:34 +00003566/* Do appropriate processing given the current state. */
3567/* Read a look-ahead token if we need one and don't already have one. */
3568/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003569
Reid Spencer950bf602007-01-26 08:19:09 +00003570 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003571
Reid Spencere7c3c602006-11-30 06:36:44 +00003572 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003573 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003574 goto yydefault;
3575
Reid Spencer950bf602007-01-26 08:19:09 +00003576 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003577
Reid Spencer950bf602007-01-26 08:19:09 +00003578 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003579 if (yychar == YYEMPTY)
3580 {
Reid Spencer319a7302007-01-05 17:20:02 +00003581 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003582 yychar = YYLEX;
3583 }
3584
Reid Spencer950bf602007-01-26 08:19:09 +00003585 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003586 {
Reid Spencer950bf602007-01-26 08:19:09 +00003587 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003588 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003589 }
3590 else
3591 {
Reid Spencer950bf602007-01-26 08:19:09 +00003592 yytoken = YYTRANSLATE (yychar);
3593 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003594 }
3595
Reid Spencer950bf602007-01-26 08:19:09 +00003596 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003597 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003598 yyn += yytoken;
3599 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003600 goto yydefault;
3601 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003602 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003603 {
Reid Spencer319a7302007-01-05 17:20:02 +00003604 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003605 goto yyerrlab;
3606 yyn = -yyn;
3607 goto yyreduce;
3608 }
3609
3610 if (yyn == YYFINAL)
3611 YYACCEPT;
3612
Reid Spencerb7046c72007-01-29 05:41:34 +00003613 /* Shift the look-ahead token. */
3614 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3615
3616 /* Discard the token being shifted unless it is eof. */
3617 if (yychar != YYEOF)
3618 yychar = YYEMPTY;
3619
3620 *++yyvsp = yylval;
3621
3622
Reid Spencer319a7302007-01-05 17:20:02 +00003623 /* Count tokens shifted since error; after three, turn off error
3624 status. */
3625 if (yyerrstatus)
3626 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003627
3628 yystate = yyn;
3629 goto yynewstate;
3630
Chris Lattner37e01c52007-01-04 18:46:42 +00003631
Reid Spencer319a7302007-01-05 17:20:02 +00003632/*-----------------------------------------------------------.
3633| yydefault -- do the default action for the current state. |
3634`-----------------------------------------------------------*/
3635yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003636 yyn = yydefact[yystate];
3637 if (yyn == 0)
3638 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003639 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003640
Reid Spencer319a7302007-01-05 17:20:02 +00003641
3642/*-----------------------------.
3643| yyreduce -- Do a reduction. |
3644`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003645yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003646 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003647 yylen = yyr2[yyn];
3648
Reid Spencer319a7302007-01-05 17:20:02 +00003649 /* If YYLEN is nonzero, implement the default value of the action:
3650 `$$ = $1'.
3651
3652 Otherwise, the following line sets YYVAL to garbage.
3653 This behavior is undocumented and Bison
3654 users should not rely upon it. Assigning to YYVAL
3655 unconditionally makes the parser a bit smaller, and it avoids a
3656 GCC warning that YYVAL may be used uninitialized. */
3657 yyval = yyvsp[1-yylen];
3658
3659
Reid Spencer950bf602007-01-26 08:19:09 +00003660 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003661 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003662 {
Reid Spencer950bf602007-01-26 08:19:09 +00003663 case 3:
Reid Spencer7de2e012007-01-29 19:08:46 +00003664#line 1581 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003665 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003666 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003667 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003668 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003669 ;}
3670 break;
3671
3672 case 5:
Reid Spencer7de2e012007-01-29 19:08:46 +00003673#line 1590 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003674 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003675 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003676 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003677 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003678 ;}
3679 break;
3680
3681 case 26:
Reid Spencer7de2e012007-01-29 19:08:46 +00003682#line 1612 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003683 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3684 break;
3685
3686 case 27:
Reid Spencer7de2e012007-01-29 19:08:46 +00003687#line 1612 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003688 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3689 break;
3690
3691 case 28:
Reid Spencer7de2e012007-01-29 19:08:46 +00003692#line 1613 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003693 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3694 break;
3695
3696 case 29:
Reid Spencer7de2e012007-01-29 19:08:46 +00003697#line 1613 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003698 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3699 break;
3700
3701 case 30:
Reid Spencer7de2e012007-01-29 19:08:46 +00003702#line 1614 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003703 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3704 break;
3705
3706 case 31:
Reid Spencer7de2e012007-01-29 19:08:46 +00003707#line 1614 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003708 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3709 break;
3710
3711 case 32:
Reid Spencer7de2e012007-01-29 19:08:46 +00003712#line 1615 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003713 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3714 break;
3715
3716 case 33:
Reid Spencer7de2e012007-01-29 19:08:46 +00003717#line 1615 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003718 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3719 break;
3720
3721 case 34:
Reid Spencer7de2e012007-01-29 19:08:46 +00003722#line 1616 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003723 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3724 break;
3725
3726 case 35:
Reid Spencer7de2e012007-01-29 19:08:46 +00003727#line 1616 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003728 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3729 break;
3730
3731 case 36:
Reid Spencer7de2e012007-01-29 19:08:46 +00003732#line 1620 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003733 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3734 break;
3735
3736 case 37:
Reid Spencer7de2e012007-01-29 19:08:46 +00003737#line 1620 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003738 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3739 break;
3740
3741 case 38:
Reid Spencer7de2e012007-01-29 19:08:46 +00003742#line 1621 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003743 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3744 break;
3745
3746 case 39:
Reid Spencer7de2e012007-01-29 19:08:46 +00003747#line 1621 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003748 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3749 break;
3750
3751 case 40:
Reid Spencer7de2e012007-01-29 19:08:46 +00003752#line 1622 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003753 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3754 break;
3755
3756 case 41:
Reid Spencer7de2e012007-01-29 19:08:46 +00003757#line 1622 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003758 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3759 break;
3760
3761 case 42:
Reid Spencer7de2e012007-01-29 19:08:46 +00003762#line 1623 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003763 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3764 break;
3765
3766 case 43:
Reid Spencer7de2e012007-01-29 19:08:46 +00003767#line 1623 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003768 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3769 break;
3770
3771 case 44:
Reid Spencer7de2e012007-01-29 19:08:46 +00003772#line 1624 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003773 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3774 break;
3775
3776 case 45:
Reid Spencer7de2e012007-01-29 19:08:46 +00003777#line 1624 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003778 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3779 break;
3780
3781 case 46:
Reid Spencer7de2e012007-01-29 19:08:46 +00003782#line 1625 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003783 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3784 break;
3785
3786 case 47:
Reid Spencer7de2e012007-01-29 19:08:46 +00003787#line 1625 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003788 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3789 break;
3790
3791 case 48:
Reid Spencer7de2e012007-01-29 19:08:46 +00003792#line 1626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003793 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3794 break;
3795
3796 case 49:
Reid Spencer7de2e012007-01-29 19:08:46 +00003797#line 1626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003798 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3799 break;
3800
3801 case 50:
Reid Spencer7de2e012007-01-29 19:08:46 +00003802#line 1627 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003803 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3804 break;
3805
3806 case 51:
Reid Spencer7de2e012007-01-29 19:08:46 +00003807#line 1628 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003808 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3809 break;
3810
3811 case 81:
Reid Spencer7de2e012007-01-29 19:08:46 +00003812#line 1659 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003813 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003814 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003815 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003816 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003817
Reid Spencer319a7302007-01-05 17:20:02 +00003818 case 82:
Reid Spencer7de2e012007-01-29 19:08:46 +00003819#line 1662 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003820 {
Reid Spencer950bf602007-01-26 08:19:09 +00003821 (yyval.StrVal) = 0;
3822 ;}
3823 break;
3824
3825 case 83:
Reid Spencer7de2e012007-01-29 19:08:46 +00003826#line 1667 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003827 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3828 break;
3829
3830 case 84:
Reid Spencer7de2e012007-01-29 19:08:46 +00003831#line 1668 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003832 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3833 break;
3834
3835 case 85:
Reid Spencer7de2e012007-01-29 19:08:46 +00003836#line 1669 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003837 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3838 break;
3839
3840 case 86:
Reid Spencer7de2e012007-01-29 19:08:46 +00003841#line 1670 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003842 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3843 break;
3844
3845 case 87:
Reid Spencer7de2e012007-01-29 19:08:46 +00003846#line 1671 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003847 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3848 break;
3849
3850 case 88:
Reid Spencer7de2e012007-01-29 19:08:46 +00003851#line 1672 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003852 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3853 break;
3854
3855 case 89:
Reid Spencer7de2e012007-01-29 19:08:46 +00003856#line 1673 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003857 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003858 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003859
Reid Spencer319a7302007-01-05 17:20:02 +00003860 case 90:
Reid Spencer7de2e012007-01-29 19:08:46 +00003861#line 1674 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003862 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3863 break;
3864
3865 case 91:
Reid Spencer7de2e012007-01-29 19:08:46 +00003866#line 1678 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003867 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003868 break;
3869
3870 case 92:
Reid Spencer7de2e012007-01-29 19:08:46 +00003871#line 1679 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003872 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003873 break;
3874
3875 case 93:
Reid Spencer7de2e012007-01-29 19:08:46 +00003876#line 1680 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003877 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::CSRet; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003878 break;
3879
3880 case 94:
Reid Spencer7de2e012007-01-29 19:08:46 +00003881#line 1681 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003882 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::Fast; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003883 break;
3884
3885 case 95:
Reid Spencer7de2e012007-01-29 19:08:46 +00003886#line 1682 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003887 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::Cold; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003888 break;
3889
3890 case 96:
Reid Spencer7de2e012007-01-29 19:08:46 +00003891#line 1683 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003892 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003893 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00003894
Reid Spencer319a7302007-01-05 17:20:02 +00003895 case 97:
Reid Spencer7de2e012007-01-29 19:08:46 +00003896#line 1684 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003897 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003898 break;
Reid Spencer16244f42006-12-01 21:10:07 +00003899
Reid Spencer319a7302007-01-05 17:20:02 +00003900 case 98:
Reid Spencer7de2e012007-01-29 19:08:46 +00003901#line 1685 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003902 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003903 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00003904 error("Calling conv too large");
Reid Spencerb7046c72007-01-29 05:41:34 +00003905 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003906 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003907 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003908
Reid Spencer319a7302007-01-05 17:20:02 +00003909 case 99:
Reid Spencer7de2e012007-01-29 19:08:46 +00003910#line 1695 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003911 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003912 break;
3913
Reid Spencerc4d96252007-01-13 00:03:30 +00003914 case 100:
Reid Spencer7de2e012007-01-29 19:08:46 +00003915#line 1696 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003916 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003917 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003918 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3919 error("Alignment must be a power of two");
3920 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003921 break;
3922
3923 case 101:
Reid Spencer7de2e012007-01-29 19:08:46 +00003924#line 1704 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003925 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003926 break;
3927
3928 case 102:
Reid Spencer7de2e012007-01-29 19:08:46 +00003929#line 1705 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003930 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003931 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003932 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3933 error("Alignment must be a power of two");
3934 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003935 break;
3936
3937 case 103:
Reid Spencer7de2e012007-01-29 19:08:46 +00003938#line 1713 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003939 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003940 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3941 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00003942 error("Invalid character in section name");
Reid Spencerb7046c72007-01-29 05:41:34 +00003943 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003944 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003945 break;
3946
3947 case 104:
Reid Spencer7de2e012007-01-29 19:08:46 +00003948#line 1722 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003949 { (yyval.StrVal) = 0; ;}
3950 break;
3951
3952 case 105:
Reid Spencer7de2e012007-01-29 19:08:46 +00003953#line 1723 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003954 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003955 break;
3956
Reid Spencerc4d96252007-01-13 00:03:30 +00003957 case 106:
Reid Spencer7de2e012007-01-29 19:08:46 +00003958#line 1730 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003959 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003960 break;
3961
Reid Spencer319a7302007-01-05 17:20:02 +00003962 case 107:
Reid Spencer7de2e012007-01-29 19:08:46 +00003963#line 1731 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003964 {;}
3965 break;
3966
3967 case 108:
Reid Spencer7de2e012007-01-29 19:08:46 +00003968#line 1735 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003969 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003970 CurGV->setSection((yyvsp[0].StrVal));
3971 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00003972 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003973 break;
3974
3975 case 109:
Reid Spencer7de2e012007-01-29 19:08:46 +00003976#line 1739 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003977 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003978 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00003979 error("Alignment must be a power of two");
Reid Spencerb7046c72007-01-29 05:41:34 +00003980 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00003981
3982 ;}
3983 break;
3984
3985 case 111:
Reid Spencer7de2e012007-01-29 19:08:46 +00003986#line 1756 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003987 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003988 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00003989 (yyval.TypeVal).S = Signless;
3990 ;}
3991 break;
3992
3993 case 113:
Reid Spencer7de2e012007-01-29 19:08:46 +00003994#line 1764 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003995 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003996 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00003997 (yyval.TypeVal).S = Signless;
3998 ;}
3999 break;
4000
4001 case 114:
Reid Spencer7de2e012007-01-29 19:08:46 +00004002#line 1771 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004003 {
4004 if (!UpRefs.empty())
Reid Spencerb7046c72007-01-29 05:41:34 +00004005 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).T)->getDescription());
4006 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004007 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004008 break;
4009
4010 case 127:
Reid Spencer7de2e012007-01-29 19:08:46 +00004011#line 1785 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004012 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004013 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
4014 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004015 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004016 break;
4017
4018 case 128:
Reid Spencer7de2e012007-01-29 19:08:46 +00004019#line 1789 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004020 {
4021 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4022 (yyval.TypeVal).S = Signless;
4023 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004024 break;
4025
4026 case 129:
Reid Spencer7de2e012007-01-29 19:08:46 +00004027#line 1793 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004028 { // Named types are also simple types...
Reid Spencerb7046c72007-01-29 05:41:34 +00004029 const Type* tmp = getType((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004030 (yyval.TypeVal).T = new PATypeHolder(tmp);
4031 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4032 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004033 break;
4034
4035 case 130:
Reid Spencer7de2e012007-01-29 19:08:46 +00004036#line 1798 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004037 { // Type UpReference
Reid Spencerb7046c72007-01-29 05:41:34 +00004038 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004039 error("Value out of range");
4040 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencerb7046c72007-01-29 05:41:34 +00004041 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Reid Spencer950bf602007-01-26 08:19:09 +00004042 (yyval.TypeVal).T = new PATypeHolder(OT);
4043 (yyval.TypeVal).S = Signless;
4044 UR_OUT("New Upreference!\n");
4045 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004046 break;
4047
4048 case 131:
Reid Spencer7de2e012007-01-29 19:08:46 +00004049#line 1807 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004050 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004051 std::vector<const Type*> Params;
Reid Spencerb7046c72007-01-29 05:41:34 +00004052 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4053 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004054 Params.push_back(I->T->get());
4055 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004056 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004057 FunctionType::ParamAttrsList ParamAttrs;
4058 if (CurFun.LastCC == OldCallingConv::CSRet) {
4059 ParamAttrs.push_back(FunctionType::NoAttributeSet);
4060 ParamAttrs.push_back(FunctionType::StructRetAttribute);
4061 }
Reid Spencer950bf602007-01-26 08:19:09 +00004062 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4063 if (isVarArg) Params.pop_back();
4064
Reid Spencerb7046c72007-01-29 05:41:34 +00004065 (yyval.TypeVal).T = new PATypeHolder(
4066 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).T->get(),Params,isVarArg, ParamAttrs)));
4067 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
4068 delete (yyvsp[-3].TypeVal).T; // Delete the return type handle
4069 delete (yyvsp[-1].TypeList); // Delete the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00004070 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004071 break;
4072
4073 case 132:
Reid Spencer7de2e012007-01-29 19:08:46 +00004074#line 1828 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004075 { // Sized array type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004076 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).T->get(),
4077 (unsigned)(yyvsp[-3].UInt64Val))));
4078 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4079 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004080 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004081 break;
4082
4083 case 133:
Reid Spencer7de2e012007-01-29 19:08:46 +00004084#line 1834 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004085 { // Packed array type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004086 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).T->get();
4087 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004088 error("Unsigned result not equal to signed result");
4089 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4090 error("Elements of a PackedType must be integer or floating point");
Reid Spencerb7046c72007-01-29 05:41:34 +00004091 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004092 error("PackedType length should be a power of 2");
4093 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
Reid Spencerb7046c72007-01-29 05:41:34 +00004094 (unsigned)(yyvsp[-3].UInt64Val))));
4095 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4096 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004097 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004098 break;
4099
4100 case 134:
Reid Spencer7de2e012007-01-29 19:08:46 +00004101#line 1847 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004102 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004103 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004104 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4105 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer950bf602007-01-26 08:19:09 +00004106 Elements.push_back(I->T->get());
4107 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4108 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004109 delete (yyvsp[-1].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004110 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004111 break;
4112
4113 case 135:
Reid Spencer7de2e012007-01-29 19:08:46 +00004114#line 1856 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004115 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004116 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4117 (yyval.TypeVal).S = Signless;
4118 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004119 break;
4120
4121 case 136:
Reid Spencer7de2e012007-01-29 19:08:46 +00004122#line 1860 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004123 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004124 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004125 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4126 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004127 Elements.push_back(I->T->get());
4128 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004129 }
Reid Spencer950bf602007-01-26 08:19:09 +00004130 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4131 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004132 delete (yyvsp[-2].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004133 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004134 break;
4135
4136 case 137:
Reid Spencer7de2e012007-01-29 19:08:46 +00004137#line 1871 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004138 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004139 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4140 (yyval.TypeVal).S = Signless;
4141 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004142 break;
4143
4144 case 138:
Reid Spencer7de2e012007-01-29 19:08:46 +00004145#line 1875 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004146 { // Pointer type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004147 if ((yyvsp[-1].TypeVal).T->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004148 error("Cannot form a pointer to a basic block");
Reid Spencerb7046c72007-01-29 05:41:34 +00004149 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).T->get())));
4150 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4151 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004152 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004153 break;
4154
4155 case 139:
Reid Spencer7de2e012007-01-29 19:08:46 +00004156#line 1888 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004157 {
Reid Spencer950bf602007-01-26 08:19:09 +00004158 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004159 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004160 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004161 break;
4162
4163 case 140:
Reid Spencer7de2e012007-01-29 19:08:46 +00004164#line 1892 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004165 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004166 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004167 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004168 break;
4169
4170 case 142:
Reid Spencer7de2e012007-01-29 19:08:46 +00004171#line 1900 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004172 {
Reid Spencer950bf602007-01-26 08:19:09 +00004173 PATypeInfo VoidTI;
4174 VoidTI.T = new PATypeHolder(Type::VoidTy);
4175 VoidTI.S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004176 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
Reid Spencer950bf602007-01-26 08:19:09 +00004177 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004178 break;
4179
4180 case 143:
Reid Spencer7de2e012007-01-29 19:08:46 +00004181#line 1906 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004182 {
Reid Spencer950bf602007-01-26 08:19:09 +00004183 (yyval.TypeList) = new std::list<PATypeInfo>();
4184 PATypeInfo VoidTI;
4185 VoidTI.T = new PATypeHolder(Type::VoidTy);
4186 VoidTI.S = Signless;
4187 (yyval.TypeList)->push_back(VoidTI);
4188 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004189 break;
4190
4191 case 144:
Reid Spencer7de2e012007-01-29 19:08:46 +00004192#line 1913 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004193 {
Reid Spencer950bf602007-01-26 08:19:09 +00004194 (yyval.TypeList) = new std::list<PATypeInfo>();
4195 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004196 break;
4197
4198 case 145:
Reid Spencer7de2e012007-01-29 19:08:46 +00004199#line 1925 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004200 { // Nonempty unsized arr
Reid Spencerb7046c72007-01-29 05:41:34 +00004201 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004202 if (ATy == 0)
4203 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004204 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004205 const Type *ETy = ATy->getElementType();
4206 int NumElements = ATy->getNumElements();
4207
4208 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004209 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004210 error("Type mismatch: constant sized array initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004211 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004212 itostr(NumElements) + "");
4213
4214 // Verify all elements are correct type!
4215 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004216 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4217 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004218 const Type* ValTy = C->getType();
4219 if (ETy != ValTy)
4220 error("Element #" + utostr(i) + " is not of type '" +
4221 ETy->getDescription() +"' as required!\nIt is of type '"+
4222 ValTy->getDescription() + "'");
4223 Elems.push_back(C);
4224 }
4225 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004226 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4227 delete (yyvsp[-3].TypeVal).T;
4228 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004229 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004230 break;
4231
4232 case 146:
Reid Spencer7de2e012007-01-29 19:08:46 +00004233#line 1955 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004234 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004235 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004236 if (ATy == 0)
4237 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004238 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004239 int NumElements = ATy->getNumElements();
4240 if (NumElements != -1 && NumElements != 0)
4241 error("Type mismatch: constant sized array initialized with 0"
4242 " arguments, but has size of " + itostr(NumElements) +"");
4243 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004244 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4245 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004246 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004247 break;
4248
4249 case 147:
Reid Spencer7de2e012007-01-29 19:08:46 +00004250#line 1968 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004251 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004252 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004253 if (ATy == 0)
4254 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004255 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004256 int NumElements = ATy->getNumElements();
4257 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4258 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4259 error("String arrays require type i8, not '" + ETy->getDescription() +
4260 "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004261 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4262 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004263 error("Can't build string constant of size " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004264 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004265 itostr(NumElements) + "");
4266 std::vector<Constant*> Vals;
Reid Spencerb7046c72007-01-29 05:41:34 +00004267 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004268 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencerb7046c72007-01-29 05:41:34 +00004269 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004270 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerb7046c72007-01-29 05:41:34 +00004271 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4272 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004273 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004274 break;
4275
4276 case 148:
Reid Spencer7de2e012007-01-29 19:08:46 +00004277#line 1991 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004278 { // Nonempty unsized arr
Reid Spencerb7046c72007-01-29 05:41:34 +00004279 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004280 if (PTy == 0)
4281 error("Cannot make packed constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004282 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004283 const Type *ETy = PTy->getElementType();
4284 int NumElements = PTy->getNumElements();
4285 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004286 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004287 error("Type mismatch: constant sized packed initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004288 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004289 itostr(NumElements) + "");
4290 // Verify all elements are correct type!
4291 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004292 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4293 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004294 const Type* ValTy = C->getType();
4295 if (ETy != ValTy)
4296 error("Element #" + utostr(i) + " is not of type '" +
4297 ETy->getDescription() +"' as required!\nIt is of type '"+
4298 ValTy->getDescription() + "'");
4299 Elems.push_back(C);
4300 }
4301 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004302 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4303 delete (yyvsp[-3].TypeVal).T;
4304 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004305 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004306 break;
4307
4308 case 149:
Reid Spencer7de2e012007-01-29 19:08:46 +00004309#line 2019 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004310 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004311 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004312 if (STy == 0)
4313 error("Cannot make struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004314 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4315 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004316 error("Illegal number of initializers for structure type");
4317
4318 // Check to ensure that constants are compatible with the type initializer!
4319 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004320 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4321 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004322 if (C->getType() != STy->getElementType(i))
4323 error("Expected type '" + STy->getElementType(i)->getDescription() +
4324 "' for element #" + utostr(i) + " of structure initializer");
4325 Fields.push_back(C);
4326 }
4327 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004328 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4329 delete (yyvsp[-3].TypeVal).T;
4330 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004331 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004332 break;
4333
4334 case 150:
Reid Spencer7de2e012007-01-29 19:08:46 +00004335#line 2041 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004336 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004337 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004338 if (STy == 0)
4339 error("Cannot make struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004340 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004341 if (STy->getNumContainedTypes() != 0)
4342 error("Illegal number of initializers for structure type");
4343 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004344 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4345 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004346 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004347 break;
4348
4349 case 151:
Reid Spencer7de2e012007-01-29 19:08:46 +00004350#line 2052 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004351 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004352 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004353 if (STy == 0)
4354 error("Cannot make packed struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004355 (yyvsp[-5].TypeVal).T->get()->getDescription() + "'");
4356 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004357 error("Illegal number of initializers for packed structure type");
4358
4359 // Check to ensure that constants are compatible with the type initializer!
4360 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004361 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4362 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004363 if (C->getType() != STy->getElementType(i))
4364 error("Expected type '" + STy->getElementType(i)->getDescription() +
4365 "' for element #" + utostr(i) + " of packed struct initializer");
4366 Fields.push_back(C);
4367 }
4368 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004369 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4370 delete (yyvsp[-5].TypeVal).T;
4371 delete (yyvsp[-2].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004372 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004373 break;
4374
4375 case 152:
Reid Spencer7de2e012007-01-29 19:08:46 +00004376#line 2074 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004377 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004378 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004379 if (STy == 0)
4380 error("Cannot make packed struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004381 (yyvsp[-4].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004382 if (STy->getNumContainedTypes() != 0)
4383 error("Illegal number of initializers for packed structure type");
4384 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004385 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4386 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004387 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004388 break;
4389
4390 case 153:
Reid Spencer7de2e012007-01-29 19:08:46 +00004391#line 2085 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004392 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004393 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004394 if (PTy == 0)
4395 error("Cannot make null pointer constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004396 (yyvsp[-1].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004397 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00004398 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4399 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004400 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004401 break;
4402
4403 case 154:
Reid Spencer7de2e012007-01-29 19:08:46 +00004404#line 2094 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004405 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004406 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).T->get());
4407 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4408 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004409 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004410 break;
4411
4412 case 155:
Reid Spencer7de2e012007-01-29 19:08:46 +00004413#line 2099 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004414 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004415 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004416 if (Ty == 0)
4417 error("Global const reference must be a pointer type, not" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004418 (yyvsp[-1].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004419
4420 // ConstExprs can exist in the body of a function, thus creating
4421 // GlobalValues whenever they refer to a variable. Because we are in
4422 // the context of a function, getExistingValue will search the functions
4423 // symbol table instead of the module symbol table for the global symbol,
4424 // which throws things all off. To get around this, we just tell
4425 // getExistingValue that we are at global scope here.
4426 //
4427 Function *SavedCurFn = CurFun.CurrentFunction;
4428 CurFun.CurrentFunction = 0;
Reid Spencerb7046c72007-01-29 05:41:34 +00004429 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004430 CurFun.CurrentFunction = SavedCurFn;
4431
4432 // If this is an initializer for a constant pointer, which is referencing a
4433 // (currently) undefined variable, create a stub now that shall be replaced
4434 // in the future with the right type of variable.
4435 //
4436 if (V == 0) {
4437 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4438 const PointerType *PT = cast<PointerType>(Ty);
4439
4440 // First check to see if the forward references value is already created!
4441 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencerb7046c72007-01-29 05:41:34 +00004442 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004443
4444 if (I != CurModule.GlobalRefs.end()) {
4445 V = I->second; // Placeholder already exists, use it...
Reid Spencerb7046c72007-01-29 05:41:34 +00004446 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004447 } else {
4448 std::string Name;
Reid Spencerb7046c72007-01-29 05:41:34 +00004449 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004450
4451 // Create the forward referenced global.
4452 GlobalValue *GV;
4453 if (const FunctionType *FTy =
4454 dyn_cast<FunctionType>(PT->getElementType())) {
4455 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4456 CurModule.CurrentModule);
4457 } else {
4458 GV = new GlobalVariable(PT->getElementType(), false,
4459 GlobalValue::ExternalLinkage, 0,
4460 Name, CurModule.CurrentModule);
4461 }
4462
4463 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencerb7046c72007-01-29 05:41:34 +00004464 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004465 V = GV;
4466 }
4467 }
4468 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerb7046c72007-01-29 05:41:34 +00004469 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4470 delete (yyvsp[-1].TypeVal).T; // Free the type handle
Reid Spencer950bf602007-01-26 08:19:09 +00004471 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004472 break;
4473
4474 case 156:
Reid Spencer7de2e012007-01-29 19:08:46 +00004475#line 2157 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004476 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004477 if ((yyvsp[-1].TypeVal).T->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004478 error("Mismatched types for constant expression");
Reid Spencerb7046c72007-01-29 05:41:34 +00004479 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4480 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4481 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004482 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004483 break;
4484
4485 case 157:
Reid Spencer7de2e012007-01-29 19:08:46 +00004486#line 2164 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004487 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004488 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004489 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4490 error("Cannot create a null initialized value of this type");
4491 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00004492 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4493 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004494 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004495 break;
4496
4497 case 158:
Reid Spencer7de2e012007-01-29 19:08:46 +00004498#line 2172 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004499 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004500 const Type *Ty = (yyvsp[-1].PrimType).T;
4501 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004502 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004503 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004504 (yyval.ConstVal).S = Signed;
4505 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004506 break;
4507
4508 case 159:
Reid Spencer7de2e012007-01-29 19:08:46 +00004509#line 2179 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004510 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004511 const Type *Ty = (yyvsp[-1].PrimType).T;
4512 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004513 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004514 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004515 (yyval.ConstVal).S = Unsigned;
4516 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004517 break;
4518
4519 case 160:
Reid Spencer7de2e012007-01-29 19:08:46 +00004520#line 2186 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004521 { // Boolean constants
4522 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4523 (yyval.ConstVal).S = Unsigned;
4524 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004525 break;
4526
4527 case 161:
Reid Spencer7de2e012007-01-29 19:08:46 +00004528#line 2190 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004529 { // Boolean constants
4530 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4531 (yyval.ConstVal).S = Unsigned;
4532 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004533 break;
4534
4535 case 162:
Reid Spencer7de2e012007-01-29 19:08:46 +00004536#line 2194 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004537 { // Float & Double constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004538 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004539 error("Floating point constant invalid for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004540 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004541 (yyval.ConstVal).S = Signless;
4542 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004543 break;
4544
4545 case 163:
Reid Spencer7de2e012007-01-29 19:08:46 +00004546#line 2203 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004547 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004548 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4549 const Type* DstTy = (yyvsp[-1].TypeVal).T->get();
4550 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4551 Signedness DstSign = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004552 if (!SrcTy->isFirstClassType())
4553 error("cast constant expression from a non-primitive type: '" +
4554 SrcTy->getDescription() + "'");
4555 if (!DstTy->isFirstClassType())
4556 error("cast constant expression to a non-primitive type: '" +
4557 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004558 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencer950bf602007-01-26 08:19:09 +00004559 (yyval.ConstVal).S = DstSign;
Reid Spencerb7046c72007-01-29 05:41:34 +00004560 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004561 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004562 break;
4563
4564 case 164:
Reid Spencer7de2e012007-01-29 19:08:46 +00004565#line 2218 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004566 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004567 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004568 if (!isa<PointerType>(Ty))
4569 error("GetElementPtr requires a pointer operand");
4570
4571 std::vector<Value*> VIndices;
4572 std::vector<Constant*> CIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00004573 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004574
Reid Spencerb7046c72007-01-29 05:41:34 +00004575 delete (yyvsp[-1].ValueList);
4576 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004577 (yyval.ConstVal).S = Signless;
4578 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004579 break;
4580
4581 case 165:
Reid Spencer7de2e012007-01-29 19:08:46 +00004582#line 2231 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004583 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004584 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4585 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004586 error("Select condition must be bool type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004587 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004588 error("Select operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004589 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004590 (yyval.ConstVal).S = Unsigned;
4591 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004592 break;
4593
4594 case 166:
Reid Spencer7de2e012007-01-29 19:08:46 +00004595#line 2240 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004596 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004597 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4598 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004599 error("Binary operator types must match");
4600 // First, make sure we're dealing with the right opcode by upgrading from
4601 // obsolete versions.
Reid Spencerb7046c72007-01-29 05:41:34 +00004602 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004603
4604 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4605 // To retain backward compatibility with these early compilers, we emit a
4606 // cast to the appropriate integer type automatically if we are in the
4607 // broken case. See PR424 for more information.
4608 if (!isa<PointerType>(Ty)) {
Reid Spencerb7046c72007-01-29 05:41:34 +00004609 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004610 } else {
4611 const Type *IntPtrTy = 0;
4612 switch (CurModule.CurrentModule->getPointerSize()) {
4613 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4614 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4615 default: error("invalid pointer binary constant expr");
4616 }
4617 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
Reid Spencerb7046c72007-01-29 05:41:34 +00004618 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4619 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
Reid Spencer950bf602007-01-26 08:19:09 +00004620 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4621 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004622 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004623 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004624 break;
4625
4626 case 167:
Reid Spencer7de2e012007-01-29 19:08:46 +00004627#line 2268 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004628 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004629 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4630 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004631 error("Logical operator types must match");
4632 if (!Ty->isInteger()) {
4633 if (!isa<PackedType>(Ty) ||
4634 !cast<PackedType>(Ty)->getElementType()->isInteger())
4635 error("Logical operator requires integer operands");
4636 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004637 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4638 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4639 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004640 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004641 break;
4642
4643 case 168:
Reid Spencer7de2e012007-01-29 19:08:46 +00004644#line 2281 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004645 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004646 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4647 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004648 error("setcc operand types must match");
4649 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00004650 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4651 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004652 (yyval.ConstVal).S = Unsigned;
4653 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004654 break;
4655
4656 case 169:
Reid Spencer7de2e012007-01-29 19:08:46 +00004657#line 2290 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004658 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004659 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004660 error("icmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004661 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004662 (yyval.ConstVal).S = Unsigned;
4663 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004664 break;
4665
4666 case 170:
Reid Spencer7de2e012007-01-29 19:08:46 +00004667#line 2296 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004668 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004669 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004670 error("fcmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004671 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004672 (yyval.ConstVal).S = Unsigned;
4673 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004674 break;
4675
4676 case 171:
Reid Spencer7de2e012007-01-29 19:08:46 +00004677#line 2302 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004678 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004679 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4680 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004681 error("Shift count for shift constant must be unsigned byte");
Reid Spencerb7046c72007-01-29 05:41:34 +00004682 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004683 error("Shift constant expression requires integer operand");
Reid Spencerb7046c72007-01-29 05:41:34 +00004684 (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4685 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004686 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004687 break;
4688
4689 case 172:
Reid Spencer7de2e012007-01-29 19:08:46 +00004690#line 2311 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004691 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004692 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004693 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004694 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4695 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004696 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004697 break;
4698
4699 case 173:
Reid Spencer7de2e012007-01-29 19:08:46 +00004700#line 2317 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004701 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004702 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004703 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004704 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4705 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004706 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004707 break;
4708
4709 case 174:
Reid Spencer7de2e012007-01-29 19:08:46 +00004710#line 2323 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004711 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004712 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004713 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004714 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4715 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004716 ;}
4717 break;
4718
4719 case 175:
Reid Spencer7de2e012007-01-29 19:08:46 +00004720#line 2334 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004721 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004722 break;
4723
4724 case 176:
Reid Spencer7de2e012007-01-29 19:08:46 +00004725#line 2335 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004726 {
4727 (yyval.ConstVector) = new std::vector<ConstInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004728 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004729 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004730 break;
4731
4732 case 177:
Reid Spencer7de2e012007-01-29 19:08:46 +00004733#line 2344 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004734 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004735 break;
4736
4737 case 178:
Reid Spencer7de2e012007-01-29 19:08:46 +00004738#line 2345 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004739 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004740 break;
4741
4742 case 179:
Reid Spencer7de2e012007-01-29 19:08:46 +00004743#line 2357 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004744 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004745 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004746 CurModule.ModuleDone();
4747 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004748 break;
4749
4750 case 180:
Reid Spencer7de2e012007-01-29 19:08:46 +00004751#line 2366 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004752 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004753 break;
4754
4755 case 181:
Reid Spencer7de2e012007-01-29 19:08:46 +00004756#line 2367 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004757 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004758 break;
4759
4760 case 182:
Reid Spencer7de2e012007-01-29 19:08:46 +00004761#line 2368 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004762 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004763 break;
4764
4765 case 183:
Reid Spencer7de2e012007-01-29 19:08:46 +00004766#line 2369 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004767 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004768 break;
4769
4770 case 184:
Reid Spencer7de2e012007-01-29 19:08:46 +00004771#line 2370 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004772 {
4773 (yyval.ModuleVal) = CurModule.CurrentModule;
4774 // Emit an error if there are any unresolved types left.
4775 if (!CurModule.LateResolveTypes.empty()) {
4776 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4777 if (DID.Type == ValID::NameVal) {
4778 error("Reference to an undefined type: '"+DID.getName() + "'");
4779 } else {
4780 error("Reference to an undefined type: #" + itostr(DID.Num));
4781 }
4782 }
4783 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004784 break;
4785
4786 case 185:
Reid Spencer7de2e012007-01-29 19:08:46 +00004787#line 2386 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004788 {
Reid Spencer950bf602007-01-26 08:19:09 +00004789 // Eagerly resolve types. This is not an optimization, this is a
4790 // requirement that is due to the fact that we could have this:
4791 //
4792 // %list = type { %list * }
4793 // %list = type { %list * } ; repeated type decl
4794 //
4795 // If types are not resolved eagerly, then the two types will not be
4796 // determined to be the same type!
4797 //
Reid Spencerb7046c72007-01-29 05:41:34 +00004798 const Type* Ty = (yyvsp[0].TypeVal).T->get();
4799 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004800
Reid Spencerb7046c72007-01-29 05:41:34 +00004801 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer950bf602007-01-26 08:19:09 +00004802 // If this is a named type that is not a redefinition, add it to the slot
4803 // table.
4804 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004805 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004806 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004807 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004808 break;
4809
4810 case 186:
Reid Spencer7de2e012007-01-29 19:08:46 +00004811#line 2406 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004812 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004813 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004814 break;
4815
4816 case 187:
Reid Spencer7de2e012007-01-29 19:08:46 +00004817#line 2408 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004818 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004819 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004820 break;
4821
4822 case 188:
Reid Spencer7de2e012007-01-29 19:08:46 +00004823#line 2410 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004824 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004825 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00004826 error("Global value initializer is not a constant");
Reid Spencerb7046c72007-01-29 05:41:34 +00004827 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004828 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004829 break;
4830
4831 case 189:
Reid Spencer7de2e012007-01-29 19:08:46 +00004832#line 2414 "/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 CurGV = 0;
4835 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004836 break;
4837
4838 case 190:
Reid Spencer7de2e012007-01-29 19:08:46 +00004839#line 2417 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004840 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004841 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4842 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4843 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004844 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004845 break;
4846
4847 case 191:
Reid Spencer7de2e012007-01-29 19:08:46 +00004848#line 2421 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004849 {
Reid Spencer950bf602007-01-26 08:19:09 +00004850 CurGV = 0;
4851 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004852 break;
4853
4854 case 192:
Reid Spencer7de2e012007-01-29 19:08:46 +00004855#line 2424 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004856 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004857 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4858 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4859 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004860 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004861 break;
4862
4863 case 193:
Reid Spencer7de2e012007-01-29 19:08:46 +00004864#line 2428 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004865 {
Reid Spencer950bf602007-01-26 08:19:09 +00004866 CurGV = 0;
4867 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004868 break;
4869
4870 case 194:
Reid Spencer7de2e012007-01-29 19:08:46 +00004871#line 2431 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004872 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004873 const Type *Ty = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004874 CurGV =
Reid Spencerb7046c72007-01-29 05:41:34 +00004875 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4876 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004877 ;}
4878 break;
4879
4880 case 195:
Reid Spencer7de2e012007-01-29 19:08:46 +00004881#line 2436 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004882 {
4883 CurGV = 0;
4884 ;}
4885 break;
4886
4887 case 196:
Reid Spencer7de2e012007-01-29 19:08:46 +00004888#line 2439 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004889 {
Reid Spencer950bf602007-01-26 08:19:09 +00004890 ;}
4891 break;
4892
4893 case 197:
Reid Spencer7de2e012007-01-29 19:08:46 +00004894#line 2441 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004895 {
4896 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004897 break;
4898
4899 case 198:
Reid Spencer7de2e012007-01-29 19:08:46 +00004900#line 2443 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004901 {
4902 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004903 break;
4904
4905 case 199:
Reid Spencer7de2e012007-01-29 19:08:46 +00004906#line 2448 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004907 {
Reid Spencer950bf602007-01-26 08:19:09 +00004908 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencerb7046c72007-01-29 05:41:34 +00004909 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4910 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4911 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004912
4913 if (AsmSoFar.empty())
4914 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4915 else
4916 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4917 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004918 break;
4919
4920 case 200:
Reid Spencer7de2e012007-01-29 19:08:46 +00004921#line 2462 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004922 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004923 break;
4924
4925 case 201:
Reid Spencer7de2e012007-01-29 19:08:46 +00004926#line 2463 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004927 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004928 break;
4929
4930 case 202:
Reid Spencer7de2e012007-01-29 19:08:46 +00004931#line 2467 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004932 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004933 CurModule.setEndianness((yyvsp[0].Endianness));
Reid Spencer950bf602007-01-26 08:19:09 +00004934 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004935 break;
4936
4937 case 203:
Reid Spencer7de2e012007-01-29 19:08:46 +00004938#line 2470 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004939 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004940 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00004941 CurModule.setPointerSize(Module::Pointer32);
Reid Spencerb7046c72007-01-29 05:41:34 +00004942 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00004943 CurModule.setPointerSize(Module::Pointer64);
4944 else
Reid Spencerb7046c72007-01-29 05:41:34 +00004945 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004946 ;}
4947 break;
4948
4949 case 204:
Reid Spencer7de2e012007-01-29 19:08:46 +00004950#line 2478 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004951 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004952 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4953 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004954 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004955 break;
4956
4957 case 205:
Reid Spencer7de2e012007-01-29 19:08:46 +00004958#line 2482 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004959 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004960 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4961 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004962 ;}
4963 break;
4964
4965 case 207:
Reid Spencer7de2e012007-01-29 19:08:46 +00004966#line 2493 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004967 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004968 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4969 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004970 ;}
4971 break;
4972
4973 case 208:
Reid Spencer7de2e012007-01-29 19:08:46 +00004974#line 2497 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004975 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004976 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4977 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004978 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004979 break;
4980
4981 case 209:
Reid Spencer7de2e012007-01-29 19:08:46 +00004982#line 2501 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004983 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004984 break;
4985
Reid Spencerc4d96252007-01-13 00:03:30 +00004986 case 213:
Reid Spencer7de2e012007-01-29 19:08:46 +00004987#line 2514 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004988 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004989 break;
4990
Reid Spencer319a7302007-01-05 17:20:02 +00004991 case 214:
Reid Spencer7de2e012007-01-29 19:08:46 +00004992#line 2518 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004993 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004994 if ((yyvsp[-1].TypeVal).T->get() == Type::VoidTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004995 error("void typed arguments are invalid");
Reid Spencerb7046c72007-01-29 05:41:34 +00004996 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004997 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004998 break;
4999
5000 case 215:
Reid Spencer7de2e012007-01-29 19:08:46 +00005001#line 2526 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005002 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005003 (yyval.ArgList) = (yyvsp[-2].ArgList);
5004 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5005 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005006 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005007 break;
5008
5009 case 216:
Reid Spencer7de2e012007-01-29 19:08:46 +00005010#line 2531 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005011 {
5012 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005013 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5014 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005015 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005016 break;
5017
5018 case 217:
Reid Spencer7de2e012007-01-29 19:08:46 +00005019#line 2539 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005020 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005021 break;
5022
5023 case 218:
Reid Spencer7de2e012007-01-29 19:08:46 +00005024#line 2540 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005025 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005026 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer950bf602007-01-26 08:19:09 +00005027 PATypeInfo VoidTI;
5028 VoidTI.T = new PATypeHolder(Type::VoidTy);
5029 VoidTI.S = Signless;
5030 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5031 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005032 break;
5033
5034 case 219:
Reid Spencer7de2e012007-01-29 19:08:46 +00005035#line 2547 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005036 {
5037 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5038 PATypeInfo VoidTI;
5039 VoidTI.T = new PATypeHolder(Type::VoidTy);
5040 VoidTI.S = Signless;
5041 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5042 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005043 break;
5044
5045 case 220:
Reid Spencer7de2e012007-01-29 19:08:46 +00005046#line 2554 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005047 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005048 break;
5049
5050 case 221:
Reid Spencer7de2e012007-01-29 19:08:46 +00005051#line 2558 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005052 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005053 UnEscapeLexed((yyvsp[-5].StrVal));
5054 std::string FunctionName((yyvsp[-5].StrVal));
5055 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer950bf602007-01-26 08:19:09 +00005056
Reid Spencerb7046c72007-01-29 05:41:34 +00005057 const Type* RetTy = (yyvsp[-6].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005058
5059 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5060 error("LLVM functions cannot return aggregate types");
5061
5062 std::vector<const Type*> ParamTypeList;
5063
5064 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5065 // i8*. We check here for those names and override the parameter list
5066 // types to ensure the prototype is correct.
5067 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5068 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5069 } else if (FunctionName == "llvm.va_copy") {
5070 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5071 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencerb7046c72007-01-29 05:41:34 +00005072 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005073 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencerb7046c72007-01-29 05:41:34 +00005074 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005075 const Type *Ty = I->first.T->get();
5076 ParamTypeList.push_back(Ty);
5077 }
5078 }
5079
5080 bool isVarArg =
5081 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5082 if (isVarArg) ParamTypeList.pop_back();
5083
Reid Spencerb7046c72007-01-29 05:41:34 +00005084 // Convert the CSRet calling convention into the corresponding parameter
5085 // attribute.
5086 FunctionType::ParamAttrsList ParamAttrs;
5087 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
5088 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5089 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5090 }
5091
5092 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg,
5093 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005094 const PointerType *PFT = PointerType::get(FT);
Reid Spencerb7046c72007-01-29 05:41:34 +00005095 delete (yyvsp[-6].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005096
5097 ValID ID;
5098 if (!FunctionName.empty()) {
5099 ID = ValID::create((char*)FunctionName.c_str());
5100 } else {
5101 ID = ValID::create((int)CurModule.Values[PFT].size());
5102 }
5103
5104 Function *Fn = 0;
5105 // See if this function was forward referenced. If so, recycle the object.
5106 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5107 // Move the function to the end of the list, from whereever it was
5108 // previously inserted.
5109 Fn = cast<Function>(FWRef);
5110 CurModule.CurrentModule->getFunctionList().remove(Fn);
5111 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5112 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5113 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5114 // If this is the case, either we need to be a forward decl, or it needs
5115 // to be.
Reid Spencer5cbf9852007-01-30 20:08:39 +00005116 if (!CurFun.isDeclare && !Fn->isDeclaration())
Reid Spencer950bf602007-01-26 08:19:09 +00005117 error("Redefinition of function '" + FunctionName + "'");
5118
5119 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer5cbf9852007-01-30 20:08:39 +00005120 if (Fn->isDeclaration())
Reid Spencer950bf602007-01-26 08:19:09 +00005121 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5122 AI != AE; ++AI)
5123 AI->setName("");
5124 } else { // Not already defined?
5125 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5126 CurModule.CurrentModule);
5127
5128 InsertValue(Fn, CurModule.Values);
5129 }
5130
5131 CurFun.FunctionStart(Fn);
5132
5133 if (CurFun.isDeclare) {
5134 // If we have declaration, always overwrite linkage. This will allow us
5135 // to correctly handle cases, when pointer to function is passed as
5136 // argument to another function.
5137 Fn->setLinkage(CurFun.Linkage);
5138 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005139 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5140 Fn->setAlignment((yyvsp[0].UIntVal));
5141 if ((yyvsp[-1].StrVal)) {
5142 Fn->setSection((yyvsp[-1].StrVal));
5143 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005144 }
5145
5146 // Add all of the arguments we parsed to the function...
Reid Spencerb7046c72007-01-29 05:41:34 +00005147 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005148 if (isVarArg) { // Nuke the last entry
Reid Spencerb7046c72007-01-29 05:41:34 +00005149 assert((yyvsp[-3].ArgList)->back().first.T->get() == Type::VoidTy &&
5150 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5151 delete (yyvsp[-3].ArgList)->back().first.T;
5152 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005153 }
5154 Function::arg_iterator ArgIt = Fn->arg_begin();
5155 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencerb7046c72007-01-29 05:41:34 +00005156 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I, ++ArgIt) {
Reid Spencer950bf602007-01-26 08:19:09 +00005157 delete I->first.T; // Delete the typeholder...
5158 setValueName(ArgIt, I->second); // Insert arg into symtab...
5159 InsertValue(ArgIt);
5160 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005161 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005162 }
5163 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005164 break;
5165
5166 case 224:
Reid Spencer7de2e012007-01-29 19:08:46 +00005167#line 2677 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005168 {
5169 (yyval.FunctionVal) = CurFun.CurrentFunction;
5170
5171 // Make sure that we keep track of the linkage type even if there was a
5172 // previous "declare".
Reid Spencerb7046c72007-01-29 05:41:34 +00005173 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Reid Spencer950bf602007-01-26 08:19:09 +00005174 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005175 break;
5176
5177 case 227:
Reid Spencer7de2e012007-01-29 19:08:46 +00005178#line 2691 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005179 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005180 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005181 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005182 break;
5183
5184 case 229:
Reid Spencer7de2e012007-01-29 19:08:46 +00005185#line 2697 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005186 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5187 break;
5188
5189 case 230:
Reid Spencer7de2e012007-01-29 19:08:46 +00005190#line 2698 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005191 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5192 break;
5193
5194 case 231:
Reid Spencer7de2e012007-01-29 19:08:46 +00005195#line 2702 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005196 { CurFun.isDeclare = true; ;}
5197 break;
5198
5199 case 232:
Reid Spencer7de2e012007-01-29 19:08:46 +00005200#line 2702 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005201 {
5202 (yyval.FunctionVal) = CurFun.CurrentFunction;
5203 CurFun.FunctionDone();
5204
5205 ;}
5206 break;
5207
5208 case 233:
Reid Spencer7de2e012007-01-29 19:08:46 +00005209#line 2714 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005210 { (yyval.BoolVal) = false; ;}
5211 break;
5212
5213 case 234:
Reid Spencer7de2e012007-01-29 19:08:46 +00005214#line 2715 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005215 { (yyval.BoolVal) = true; ;}
5216 break;
5217
5218 case 235:
Reid Spencer7de2e012007-01-29 19:08:46 +00005219#line 2720 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005220 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005221 break;
5222
5223 case 236:
Reid Spencer7de2e012007-01-29 19:08:46 +00005224#line 2721 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005225 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005226 break;
5227
5228 case 237:
Reid Spencer7de2e012007-01-29 19:08:46 +00005229#line 2722 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005230 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005231 break;
5232
5233 case 238:
Reid Spencer7de2e012007-01-29 19:08:46 +00005234#line 2723 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005235 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005236 break;
5237
Reid Spencerc4d96252007-01-13 00:03:30 +00005238 case 239:
Reid Spencer7de2e012007-01-29 19:08:46 +00005239#line 2724 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005240 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5241 break;
5242
5243 case 240:
Reid Spencer7de2e012007-01-29 19:08:46 +00005244#line 2725 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005245 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005246 break;
5247
Reid Spencerc4d96252007-01-13 00:03:30 +00005248 case 241:
Reid Spencer7de2e012007-01-29 19:08:46 +00005249#line 2726 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005250 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5251 break;
5252
5253 case 242:
Reid Spencer7de2e012007-01-29 19:08:46 +00005254#line 2727 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005255 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5256 break;
5257
5258 case 243:
Reid Spencer7de2e012007-01-29 19:08:46 +00005259#line 2728 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005260 { // Nonempty unsized packed vector
Reid Spencerb7046c72007-01-29 05:41:34 +00005261 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5262 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer950bf602007-01-26 08:19:09 +00005263 PackedType* pt = PackedType::get(ETy, NumElements);
5264 PATypeHolder* PTy = new PATypeHolder(
5265 HandleUpRefs(PackedType::get(ETy, NumElements)));
5266
5267 // Verify all elements are correct type!
5268 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00005269 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5270 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005271 const Type *CTy = C->getType();
5272 if (ETy != CTy)
5273 error("Element #" + utostr(i) + " is not of type '" +
5274 ETy->getDescription() +"' as required!\nIt is of type '" +
5275 CTy->getDescription() + "'");
5276 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005277 }
Reid Spencer950bf602007-01-26 08:19:09 +00005278 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
Reid Spencerb7046c72007-01-29 05:41:34 +00005279 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00005280 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005281 break;
5282
Reid Spencerc4d96252007-01-13 00:03:30 +00005283 case 244:
Reid Spencer7de2e012007-01-29 19:08:46 +00005284#line 2749 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005285 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005286 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00005287 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005288 break;
5289
Reid Spencerc4d96252007-01-13 00:03:30 +00005290 case 245:
Reid Spencer7de2e012007-01-29 19:08:46 +00005291#line 2752 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005292 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005293 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5294 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5295 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5296 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5297 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5298 free((yyvsp[-2].StrVal));
5299 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005300 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005301 break;
5302
Reid Spencerc4d96252007-01-13 00:03:30 +00005303 case 246:
Reid Spencer7de2e012007-01-29 19:08:46 +00005304#line 2767 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005305 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005306 break;
5307
Reid Spencer319a7302007-01-05 17:20:02 +00005308 case 247:
Reid Spencer7de2e012007-01-29 19:08:46 +00005309#line 2768 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005310 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005311 break;
5312
5313 case 250:
Reid Spencer7de2e012007-01-29 19:08:46 +00005314#line 2781 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005315 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005316 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5317 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5318 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5319 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005320 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005321 break;
5322
Reid Spencerc4d96252007-01-13 00:03:30 +00005323 case 251:
Reid Spencer7de2e012007-01-29 19:08:46 +00005324#line 2790 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005325 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005326 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005327 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005328 break;
5329
Reid Spencerc4d96252007-01-13 00:03:30 +00005330 case 252:
Reid Spencer7de2e012007-01-29 19:08:46 +00005331#line 2793 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005332 { // Do not allow functions with 0 basic blocks
Reid Spencerb7046c72007-01-29 05:41:34 +00005333 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005334 ;}
5335 break;
5336
5337 case 253:
Reid Spencer7de2e012007-01-29 19:08:46 +00005338#line 2802 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005339 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005340 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5341 InsertValue((yyvsp[0].TermInstVal));
5342 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5343 InsertValue((yyvsp[-2].BasicBlockVal));
5344 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005345 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005346 break;
5347
Reid Spencerc4d96252007-01-13 00:03:30 +00005348 case 254:
Reid Spencer7de2e012007-01-29 19:08:46 +00005349#line 2812 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005350 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005351 if ((yyvsp[0].InstVal).I)
5352 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5353 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005354 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005355 break;
5356
Reid Spencerc4d96252007-01-13 00:03:30 +00005357 case 255:
Reid Spencer7de2e012007-01-29 19:08:46 +00005358#line 2817 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005359 {
5360 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5361 // Make sure to move the basic block to the correct location in the
5362 // function, instead of leaving it inserted wherever it was first
5363 // referenced.
5364 Function::BasicBlockListType &BBL =
5365 CurFun.CurrentFunction->getBasicBlockList();
5366 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5367 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005368 break;
5369
Reid Spencerc4d96252007-01-13 00:03:30 +00005370 case 256:
Reid Spencer7de2e012007-01-29 19:08:46 +00005371#line 2826 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005372 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005373 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005374 // Make sure to move the basic block to the correct location in the
5375 // function, instead of leaving it inserted wherever it was first
5376 // referenced.
5377 Function::BasicBlockListType &BBL =
5378 CurFun.CurrentFunction->getBasicBlockList();
5379 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5380 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005381 break;
5382
Reid Spencerc4d96252007-01-13 00:03:30 +00005383 case 259:
Reid Spencer7de2e012007-01-29 19:08:46 +00005384#line 2840 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005385 { // Return with a result...
Reid Spencerb7046c72007-01-29 05:41:34 +00005386 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005387 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005388 break;
5389
Reid Spencerc4d96252007-01-13 00:03:30 +00005390 case 260:
Reid Spencer7de2e012007-01-29 19:08:46 +00005391#line 2843 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005392 { // Return with no result...
5393 (yyval.TermInstVal) = new ReturnInst();
5394 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005395 break;
5396
Reid Spencerc4d96252007-01-13 00:03:30 +00005397 case 261:
Reid Spencer7de2e012007-01-29 19:08:46 +00005398#line 2846 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005399 { // Unconditional Branch...
Reid Spencerb7046c72007-01-29 05:41:34 +00005400 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005401 (yyval.TermInstVal) = new BranchInst(tmpBB);
5402 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005403 break;
5404
Reid Spencer319a7302007-01-05 17:20:02 +00005405 case 262:
Reid Spencer7de2e012007-01-29 19:08:46 +00005406#line 2850 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005407 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005408 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5409 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5410 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005411 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5412 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005413 break;
5414
5415 case 263:
Reid Spencer7de2e012007-01-29 19:08:46 +00005416#line 2856 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005417 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005418 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5419 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5420 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencer950bf602007-01-26 08:19:09 +00005421 (yyval.TermInstVal) = S;
Reid Spencerb7046c72007-01-29 05:41:34 +00005422 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5423 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005424 for (; I != E; ++I) {
5425 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5426 S->addCase(CI, I->second);
5427 else
5428 error("Switch case is constant, but not a simple integer");
5429 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005430 delete (yyvsp[-1].JumpTable);
Reid Spencer950bf602007-01-26 08:19:09 +00005431 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005432 break;
5433
5434 case 264:
Reid Spencer7de2e012007-01-29 19:08:46 +00005435#line 2871 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005436 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005437 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5438 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005439 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5440 (yyval.TermInstVal) = S;
5441 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005442 break;
5443
Reid Spencerc4d96252007-01-13 00:03:30 +00005444 case 265:
Reid Spencer7de2e012007-01-29 19:08:46 +00005445#line 2878 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005446 {
Reid Spencer950bf602007-01-26 08:19:09 +00005447 const PointerType *PFTy;
5448 const FunctionType *Ty;
5449
Reid Spencerb7046c72007-01-29 05:41:34 +00005450 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005451 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5452 // Pull out the types of all of the arguments...
5453 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005454 if ((yyvsp[-7].ValueList)) {
5455 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005456 I != E; ++I)
5457 ParamTypes.push_back((*I).V->getType());
5458 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005459 FunctionType::ParamAttrsList ParamAttrs;
5460 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
5461 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5462 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5463 }
Reid Spencer950bf602007-01-26 08:19:09 +00005464 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5465 if (isVarArg) ParamTypes.pop_back();
Reid Spencerb7046c72007-01-29 05:41:34 +00005466 Ty = FunctionType::get((yyvsp[-10].TypeVal).T->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005467 PFTy = PointerType::get(Ty);
5468 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005469 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5470 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5471 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005472
5473 // Create the call node...
Reid Spencerb7046c72007-01-29 05:41:34 +00005474 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005475 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5476 } else { // Has arguments?
5477 // Loop through FunctionType's arguments and ensure they are specified
5478 // correctly!
5479 //
5480 FunctionType::param_iterator I = Ty->param_begin();
5481 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00005482 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005483
5484 std::vector<Value*> Args;
5485 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5486 if ((*ArgI).V->getType() != *I)
5487 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5488 (*I)->getDescription() + "'");
5489 Args.push_back((*ArgI).V);
5490 }
5491
5492 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5493 error("Invalid number of parameters detected");
5494
5495 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5496 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005497 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
5498 delete (yyvsp[-10].TypeVal).T;
5499 delete (yyvsp[-7].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005500 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005501 break;
5502
Reid Spencerc4d96252007-01-13 00:03:30 +00005503 case 266:
Reid Spencer7de2e012007-01-29 19:08:46 +00005504#line 2933 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005505 {
Reid Spencer950bf602007-01-26 08:19:09 +00005506 (yyval.TermInstVal) = new UnwindInst();
5507 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005508 break;
5509
Reid Spencerc4d96252007-01-13 00:03:30 +00005510 case 267:
Reid Spencer7de2e012007-01-29 19:08:46 +00005511#line 2936 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005512 {
5513 (yyval.TermInstVal) = new UnreachableInst();
5514 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005515 break;
5516
Reid Spencerc4d96252007-01-13 00:03:30 +00005517 case 268:
Reid Spencer7de2e012007-01-29 19:08:46 +00005518#line 2942 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005519 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005520 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5521 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005522
5523 if (V == 0)
5524 error("May only switch on a constant pool value");
5525
Reid Spencerb7046c72007-01-29 05:41:34 +00005526 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005527 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5528 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005529 break;
5530
Reid Spencerc4d96252007-01-13 00:03:30 +00005531 case 269:
Reid Spencer7de2e012007-01-29 19:08:46 +00005532#line 2952 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005533 {
Reid Spencer950bf602007-01-26 08:19:09 +00005534 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005535 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005536
5537 if (V == 0)
5538 error("May only switch on a constant pool value");
5539
Reid Spencerb7046c72007-01-29 05:41:34 +00005540 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005541 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5542 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005543 break;
5544
Reid Spencerc4d96252007-01-13 00:03:30 +00005545 case 270:
Reid Spencer7de2e012007-01-29 19:08:46 +00005546#line 2965 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005547 {
Reid Spencer950bf602007-01-26 08:19:09 +00005548 bool omit = false;
Reid Spencerb7046c72007-01-29 05:41:34 +00005549 if ((yyvsp[-1].StrVal))
5550 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005551 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005552 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005553 // This is a useless bit cast causing a name redefinition. It is
5554 // a bit cast from a type to the same type of an operand with the
5555 // same name as the name we would give this instruction. Since this
5556 // instruction results in no code generation, it is safe to omit
5557 // the instruction. This situation can occur because of collapsed
5558 // type planes. For example:
5559 // %X = add int %Y, %Z
5560 // %X = cast int %Y to uint
5561 // After upgrade, this looks like:
5562 // %X = add i32 %Y, %Z
5563 // %X = bitcast i32 to i32
5564 // The bitcast is clearly useless so we omit it.
5565 omit = true;
5566 if (omit) {
5567 (yyval.InstVal).I = 0;
5568 (yyval.InstVal).S = Signless;
5569 } else {
Reid Spencerb7046c72007-01-29 05:41:34 +00005570 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5571 InsertValue((yyvsp[0].InstVal).I);
5572 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005573 }
5574 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005575 break;
5576
Reid Spencerc4d96252007-01-13 00:03:30 +00005577 case 271:
Reid Spencer7de2e012007-01-29 19:08:46 +00005578#line 2994 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005579 { // Used for PHI nodes
5580 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005581 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5582 Value* tmpVal = getVal((yyvsp[-5].TypeVal).T->get(), (yyvsp[-3].ValIDVal));
5583 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005584 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencerb7046c72007-01-29 05:41:34 +00005585 delete (yyvsp[-5].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005586 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005587 break;
5588
Reid Spencerc4d96252007-01-13 00:03:30 +00005589 case 272:
Reid Spencer7de2e012007-01-29 19:08:46 +00005590#line 3002 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005591 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005592 (yyval.PHIList) = (yyvsp[-6].PHIList);
5593 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5594 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5595 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer950bf602007-01-26 08:19:09 +00005596 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005597 break;
5598
Reid Spencerc4d96252007-01-13 00:03:30 +00005599 case 273:
Reid Spencer7de2e012007-01-29 19:08:46 +00005600#line 3010 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005601 { // Used for call statements, and memory insts...
5602 (yyval.ValueList) = new std::vector<ValueInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00005603 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005604 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005605 break;
5606
Reid Spencer950bf602007-01-26 08:19:09 +00005607 case 274:
Reid Spencer7de2e012007-01-29 19:08:46 +00005608#line 3014 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005609 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005610 (yyval.ValueList) = (yyvsp[-2].ValueList);
5611 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005612 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005613 break;
5614
Reid Spencerc4d96252007-01-13 00:03:30 +00005615 case 276:
Reid Spencer7de2e012007-01-29 19:08:46 +00005616#line 3022 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005617 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005618 break;
5619
Reid Spencerc4d96252007-01-13 00:03:30 +00005620 case 277:
Reid Spencer7de2e012007-01-29 19:08:46 +00005621#line 3026 "/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 (yyval.BoolVal) = true;
5624 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005625 break;
5626
Reid Spencer319a7302007-01-05 17:20:02 +00005627 case 278:
Reid Spencer7de2e012007-01-29 19:08:46 +00005628#line 3029 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005629 {
Reid Spencer950bf602007-01-26 08:19:09 +00005630 (yyval.BoolVal) = false;
5631 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005632 break;
5633
5634 case 279:
Reid Spencer7de2e012007-01-29 19:08:46 +00005635#line 3035 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005636 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005637 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005638 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5639 error("Arithmetic operator requires integer, FP, or packed operands");
5640 if (isa<PackedType>(Ty) &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005641 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Reid Spencer950bf602007-01-26 08:19:09 +00005642 error("Remainder not supported on packed types");
5643 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencerb7046c72007-01-29 05:41:34 +00005644 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5645 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5646 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005647 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5648 if ((yyval.InstVal).I == 0)
5649 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005650 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5651 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005652 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005653 break;
5654
5655 case 280:
Reid Spencer7de2e012007-01-29 19:08:46 +00005656#line 3052 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005657 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005658 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005659 if (!Ty->isInteger()) {
5660 if (!isa<PackedType>(Ty) ||
5661 !cast<PackedType>(Ty)->getElementType()->isInteger())
5662 error("Logical operator requires integral operands");
5663 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005664 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5665 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5666 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005667 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5668 if ((yyval.InstVal).I == 0)
5669 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005670 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5671 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005672 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005673 break;
5674
Reid Spencerc4d96252007-01-13 00:03:30 +00005675 case 281:
Reid Spencer7de2e012007-01-29 19:08:46 +00005676#line 3068 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005677 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005678 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005679 if(isa<PackedType>(Ty))
5680 error("PackedTypes currently not supported in setcc instructions");
5681 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00005682 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5683 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5684 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005685 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5686 if ((yyval.InstVal).I == 0)
5687 error("binary operator returned null");
5688 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005689 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005690 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005691 break;
5692
Reid Spencerc4d96252007-01-13 00:03:30 +00005693 case 282:
Reid Spencer7de2e012007-01-29 19:08:46 +00005694#line 3082 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005695 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005696 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005697 if (isa<PackedType>(Ty))
5698 error("PackedTypes currently not supported in icmp instructions");
5699 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5700 error("icmp requires integer or pointer typed operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005701 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5702 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5703 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005704 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005705 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005706 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005707 break;
5708
Reid Spencerc4d96252007-01-13 00:03:30 +00005709 case 283:
Reid Spencer7de2e012007-01-29 19:08:46 +00005710#line 3094 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005711 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005712 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005713 if (isa<PackedType>(Ty))
5714 error("PackedTypes currently not supported in fcmp instructions");
5715 else if (!Ty->isFloatingPoint())
5716 error("fcmp instruction requires floating point operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005717 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5718 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5719 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005720 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005721 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005722 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005723 break;
5724
Reid Spencerc4d96252007-01-13 00:03:30 +00005725 case 284:
Reid Spencer7de2e012007-01-29 19:08:46 +00005726#line 3106 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005727 {
Reid Spencer950bf602007-01-26 08:19:09 +00005728 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencerb7046c72007-01-29 05:41:34 +00005729 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005730 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5731 if (Ones == 0)
5732 error("Expected integral type for not instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005733 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
Reid Spencer950bf602007-01-26 08:19:09 +00005734 if ((yyval.InstVal).I == 0)
5735 error("Could not create a xor instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005736 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
Reid Spencer950bf602007-01-26 08:19:09 +00005737 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005738 break;
5739
5740 case 285:
Reid Spencer7de2e012007-01-29 19:08:46 +00005741#line 3117 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005742 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005743 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5744 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005745 error("Shift amount must be int8");
Reid Spencerb7046c72007-01-29 05:41:34 +00005746 if (!(yyvsp[-2].ValueVal).V->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005747 error("Shift constant expression requires integer operand");
Reid Spencerb7046c72007-01-29 05:41:34 +00005748 (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5749 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005750 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005751 break;
5752
5753 case 286:
Reid Spencer7de2e012007-01-29 19:08:46 +00005754#line 3126 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005755 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005756 const Type *DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005757 if (!DstTy->isFirstClassType())
5758 error("cast instruction to a non-primitive type: '" +
5759 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00005760 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5761 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5762 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005763 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005764 break;
5765
5766 case 287:
Reid Spencer7de2e012007-01-29 19:08:46 +00005767#line 3135 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005768 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005769 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5770 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005771 error("select condition must be bool");
Reid Spencerb7046c72007-01-29 05:41:34 +00005772 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005773 error("select value types should match");
Reid Spencerb7046c72007-01-29 05:41:34 +00005774 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5775 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005776 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005777 break;
5778
Reid Spencerc4d96252007-01-13 00:03:30 +00005779 case 288:
Reid Spencer7de2e012007-01-29 19:08:46 +00005780#line 3144 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005781 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005782 const Type *Ty = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005783 NewVarArgs = true;
Reid Spencerb7046c72007-01-29 05:41:34 +00005784 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5785 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5786 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005787 ;}
5788 break;
5789
5790 case 289:
Reid Spencer7de2e012007-01-29 19:08:46 +00005791#line 3151 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005792 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005793 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5794 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005795 ObsoleteVarArgs = true;
5796 Function* NF = cast<Function>(CurModule.CurrentModule->
5797 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5798
5799 //b = vaarg a, t ->
5800 //foo = alloca 1 of t
5801 //bar = vacopy a
5802 //store bar -> foo
5803 //b = vaarg foo, t
5804 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5805 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005806 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005807 CurBB->getInstList().push_back(bar);
5808 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5809 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00005810 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5811 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005812 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005813 break;
5814
Reid Spencerc4d96252007-01-13 00:03:30 +00005815 case 290:
Reid Spencer7de2e012007-01-29 19:08:46 +00005816#line 3172 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005817 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005818 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5819 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005820 ObsoleteVarArgs = true;
5821 Function* NF = cast<Function>(CurModule.CurrentModule->
5822 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5823
5824 //b = vanext a, t ->
5825 //foo = alloca 1 of t
5826 //bar = vacopy a
5827 //store bar -> foo
5828 //tmp = vaarg foo, t
5829 //b = load foo
5830 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5831 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005832 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005833 CurBB->getInstList().push_back(bar);
5834 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5835 Instruction* tmp = new VAArgInst(foo, DstTy);
5836 CurBB->getInstList().push_back(tmp);
5837 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005838 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5839 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005840 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005841 break;
5842
Reid Spencerc4d96252007-01-13 00:03:30 +00005843 case 291:
Reid Spencer7de2e012007-01-29 19:08:46 +00005844#line 3196 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005845 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005846 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005847 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005848 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5849 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005850 ;}
5851 break;
5852
5853 case 292:
Reid Spencer7de2e012007-01-29 19:08:46 +00005854#line 3202 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005855 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005856 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005857 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005858 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5859 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005860 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005861 break;
5862
Reid Spencerc4d96252007-01-13 00:03:30 +00005863 case 293:
Reid Spencer7de2e012007-01-29 19:08:46 +00005864#line 3208 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005865 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005866 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005867 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005868 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5869 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005870 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005871 break;
5872
Reid Spencerc4d96252007-01-13 00:03:30 +00005873 case 294:
Reid Spencer7de2e012007-01-29 19:08:46 +00005874#line 3214 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005875 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005876 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005877 if (!Ty->isFirstClassType())
5878 error("PHI node operands must be of first class type");
5879 PHINode *PHI = new PHINode(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00005880 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5881 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5882 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00005883 error("All elements of a PHI node must be of the same type");
Reid Spencerb7046c72007-01-29 05:41:34 +00005884 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5885 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00005886 }
5887 (yyval.InstVal).I = PHI;
Reid Spencerb7046c72007-01-29 05:41:34 +00005888 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5889 delete (yyvsp[0].PHIList).P; // Free the list...
Reid Spencer950bf602007-01-26 08:19:09 +00005890 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005891 break;
5892
5893 case 295:
Reid Spencer7de2e012007-01-29 19:08:46 +00005894#line 3230 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005895 {
Reid Spencer950bf602007-01-26 08:19:09 +00005896
5897 // Handle the short call syntax
5898 const PointerType *PFTy;
5899 const FunctionType *FTy;
Reid Spencerb7046c72007-01-29 05:41:34 +00005900 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005901 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5902 // Pull out the types of all of the arguments...
5903 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005904 if ((yyvsp[-1].ValueList)) {
5905 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005906 I != E; ++I)
5907 ParamTypes.push_back((*I).V->getType());
5908 }
5909
Reid Spencerb7046c72007-01-29 05:41:34 +00005910 FunctionType::ParamAttrsList ParamAttrs;
5911 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
5912 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5913 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5914 }
Reid Spencer950bf602007-01-26 08:19:09 +00005915 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5916 if (isVarArg) ParamTypes.pop_back();
5917
Reid Spencerb7046c72007-01-29 05:41:34 +00005918 const Type *RetTy = (yyvsp[-4].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005919 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5920 error("Functions cannot return aggregate types");
5921
Reid Spencerb7046c72007-01-29 05:41:34 +00005922 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005923 PFTy = PointerType::get(FTy);
5924 }
5925
5926 // First upgrade any intrinsic calls.
5927 std::vector<Value*> Args;
Reid Spencerb7046c72007-01-29 05:41:34 +00005928 if ((yyvsp[-1].ValueList))
5929 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
5930 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
5931 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00005932
5933 // If we got an upgraded intrinsic
5934 if (Inst) {
5935 (yyval.InstVal).I = Inst;
5936 (yyval.InstVal).S = Signless;
5937 } else {
5938 // Get the function we're calling
Reid Spencerb7046c72007-01-29 05:41:34 +00005939 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005940
5941 // Check the argument values match
Reid Spencerb7046c72007-01-29 05:41:34 +00005942 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005943 // Make sure no arguments is a good thing!
5944 if (FTy->getNumParams() != 0)
5945 error("No arguments passed to a function that expects arguments");
5946 } else { // Has arguments?
5947 // Loop through FunctionType's arguments and ensure they are specified
5948 // correctly!
5949 //
5950 FunctionType::param_iterator I = FTy->param_begin();
5951 FunctionType::param_iterator E = FTy->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00005952 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005953
5954 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5955 if ((*ArgI).V->getType() != *I)
5956 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5957 (*I)->getDescription() + "'");
5958
5959 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
5960 error("Invalid number of parameters detected");
5961 }
5962
5963 // Create the call instruction
5964 CallInst *CI = new CallInst(V, Args);
Reid Spencerb7046c72007-01-29 05:41:34 +00005965 CI->setTailCall((yyvsp[-6].BoolVal));
5966 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005967 (yyval.InstVal).I = CI;
Reid Spencerb7046c72007-01-29 05:41:34 +00005968 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005969 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005970 delete (yyvsp[-4].TypeVal).T;
5971 delete (yyvsp[-1].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005972 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005973 break;
5974
Reid Spencerc4d96252007-01-13 00:03:30 +00005975 case 296:
Reid Spencer7de2e012007-01-29 19:08:46 +00005976#line 3308 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005977 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005978 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005979 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005980 break;
5981
Reid Spencer609ca3e2007-01-12 20:10:51 +00005982 case 297:
Reid Spencer7de2e012007-01-29 19:08:46 +00005983#line 3316 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005984 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005985 break;
5986
5987 case 298:
Reid Spencer7de2e012007-01-29 19:08:46 +00005988#line 3317 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005989 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005990 break;
5991
Reid Spencerc4d96252007-01-13 00:03:30 +00005992 case 299:
Reid Spencer7de2e012007-01-29 19:08:46 +00005993#line 3321 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005994 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005995 break;
5996
Reid Spencerc4d96252007-01-13 00:03:30 +00005997 case 300:
Reid Spencer7de2e012007-01-29 19:08:46 +00005998#line 3322 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005999 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006000 break;
6001
Reid Spencerc4d96252007-01-13 00:03:30 +00006002 case 301:
Reid Spencer7de2e012007-01-29 19:08:46 +00006003#line 3326 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006004 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006005 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
6006 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6007 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6008 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006009 ;}
6010 break;
6011
6012 case 302:
Reid Spencer7de2e012007-01-29 19:08:46 +00006013#line 3332 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006014 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006015 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6016 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6017 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6018 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006019 ;}
6020 break;
6021
6022 case 303:
Reid Spencer7de2e012007-01-29 19:08:46 +00006023#line 3338 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006024 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006025 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
6026 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6027 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6028 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006029 ;}
6030 break;
6031
6032 case 304:
Reid Spencer7de2e012007-01-29 19:08:46 +00006033#line 3344 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006034 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006035 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6036 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6037 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6038 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006039 ;}
6040 break;
6041
6042 case 305:
Reid Spencer7de2e012007-01-29 19:08:46 +00006043#line 3350 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006044 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006045 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006046 if (!isa<PointerType>(PTy))
6047 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006048 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006049 (yyval.InstVal).S = Signless;
6050 ;}
6051 break;
6052
6053 case 306:
Reid Spencer7de2e012007-01-29 19:08:46 +00006054#line 3357 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006055 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006056 const Type* Ty = (yyvsp[-1].TypeVal).T->get();
6057 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006058 if (!isa<PointerType>(Ty))
6059 error("Can't load from nonpointer type: " + Ty->getDescription());
6060 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6061 error("Can't load from pointer of non-first-class type: " +
6062 Ty->getDescription());
Reid Spencerb7046c72007-01-29 05:41:34 +00006063 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6064 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
6065 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006066 ;}
6067 break;
6068
6069 case 307:
Reid Spencer7de2e012007-01-29 19:08:46 +00006070#line 3369 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006071 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006072 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00006073 if (!PTy)
6074 error("Can't store to a nonpointer type: " +
Reid Spencerb7046c72007-01-29 05:41:34 +00006075 (yyvsp[-1].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00006076 const Type *ElTy = PTy->getElementType();
Reid Spencerb7046c72007-01-29 05:41:34 +00006077 if (ElTy != (yyvsp[-3].ValueVal).V->getType())
6078 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencer950bf602007-01-26 08:19:09 +00006079 "' into space of type '" + ElTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006080 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6081 (yyval.InstVal).I = new StoreInst((yyvsp[-3].ValueVal).V, tmpVal, (yyvsp[-5].BoolVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006082 (yyval.InstVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00006083 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006084 ;}
6085 break;
6086
6087 case 308:
Reid Spencer7de2e012007-01-29 19:08:46 +00006088#line 3383 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006089 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006090 const Type* Ty = (yyvsp[-2].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006091 if (!isa<PointerType>(Ty))
6092 error("getelementptr insn requires pointer operand");
6093
6094 std::vector<Value*> VIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00006095 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006096
Reid Spencerb7046c72007-01-29 05:41:34 +00006097 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006098 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6099 (yyval.InstVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00006100 delete (yyvsp[-2].TypeVal).T;
6101 delete (yyvsp[0].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006102 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006103 break;
6104
6105
Reid Spencer950bf602007-01-26 08:19:09 +00006106 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006107 }
6108
Reid Spencerb7046c72007-01-29 05:41:34 +00006109/* Line 1126 of yacc.c. */
Reid Spencer7de2e012007-01-29 19:08:46 +00006110#line 6111 "UpgradeParser.tab.c"
Reid Spencerb7046c72007-01-29 05:41:34 +00006111
6112 yyvsp -= yylen;
6113 yyssp -= yylen;
6114
6115
Reid Spencer950bf602007-01-26 08:19:09 +00006116 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006117
6118 *++yyvsp = yyval;
6119
6120
Reid Spencer319a7302007-01-05 17:20:02 +00006121 /* Now `shift' the result of the reduction. Determine what state
6122 that goes to, based on the state we popped back to and the rule
6123 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006124
6125 yyn = yyr1[yyn];
6126
Reid Spencer319a7302007-01-05 17:20:02 +00006127 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6128 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006129 yystate = yytable[yystate];
6130 else
Reid Spencer319a7302007-01-05 17:20:02 +00006131 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006132
6133 goto yynewstate;
6134
6135
Reid Spencer319a7302007-01-05 17:20:02 +00006136/*------------------------------------.
6137| yyerrlab -- here on detecting error |
6138`------------------------------------*/
6139yyerrlab:
6140 /* If not already recovering from an error, report this error. */
6141 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006142 {
6143 ++yynerrs;
Reid Spencerb7046c72007-01-29 05:41:34 +00006144#if YYERROR_VERBOSE
6145 yyn = yypact[yystate];
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006146
Reid Spencerb7046c72007-01-29 05:41:34 +00006147 if (YYPACT_NINF < yyn && yyn < YYLAST)
6148 {
6149 int yytype = YYTRANSLATE (yychar);
6150 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6151 YYSIZE_T yysize = yysize0;
6152 YYSIZE_T yysize1;
6153 int yysize_overflow = 0;
6154 char *yymsg = 0;
6155# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6156 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6157 int yyx;
6158
6159#if 0
6160 /* This is so xgettext sees the translatable formats that are
6161 constructed on the fly. */
6162 YY_("syntax error, unexpected %s");
6163 YY_("syntax error, unexpected %s, expecting %s");
6164 YY_("syntax error, unexpected %s, expecting %s or %s");
6165 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6166 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006167#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006168 char *yyfmt;
6169 char const *yyf;
6170 static char const yyunexpected[] = "syntax error, unexpected %s";
6171 static char const yyexpecting[] = ", expecting %s";
6172 static char const yyor[] = " or %s";
6173 char yyformat[sizeof yyunexpected
6174 + sizeof yyexpecting - 1
6175 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6176 * (sizeof yyor - 1))];
6177 char const *yyprefix = yyexpecting;
6178
6179 /* Start YYX at -YYN if negative to avoid negative indexes in
6180 YYCHECK. */
6181 int yyxbegin = yyn < 0 ? -yyn : 0;
6182
6183 /* Stay within bounds of both yycheck and yytname. */
6184 int yychecklim = YYLAST - yyn;
6185 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6186 int yycount = 1;
6187
6188 yyarg[0] = yytname[yytype];
6189 yyfmt = yystpcpy (yyformat, yyunexpected);
6190
6191 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6192 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6193 {
6194 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6195 {
6196 yycount = 1;
6197 yysize = yysize0;
6198 yyformat[sizeof yyunexpected - 1] = '\0';
6199 break;
6200 }
6201 yyarg[yycount++] = yytname[yyx];
6202 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6203 yysize_overflow |= yysize1 < yysize;
6204 yysize = yysize1;
6205 yyfmt = yystpcpy (yyfmt, yyprefix);
6206 yyprefix = yyor;
6207 }
6208
6209 yyf = YY_(yyformat);
6210 yysize1 = yysize + yystrlen (yyf);
6211 yysize_overflow |= yysize1 < yysize;
6212 yysize = yysize1;
6213
6214 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6215 yymsg = (char *) YYSTACK_ALLOC (yysize);
6216 if (yymsg)
6217 {
6218 /* Avoid sprintf, as that infringes on the user's name space.
6219 Don't have undefined behavior even if the translation
6220 produced a string with the wrong number of "%s"s. */
6221 char *yyp = yymsg;
6222 int yyi = 0;
6223 while ((*yyp = *yyf))
6224 {
6225 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6226 {
6227 yyp += yytnamerr (yyp, yyarg[yyi++]);
6228 yyf += 2;
6229 }
6230 else
6231 {
6232 yyp++;
6233 yyf++;
6234 }
6235 }
6236 yyerror (yymsg);
6237 YYSTACK_FREE (yymsg);
6238 }
6239 else
6240 {
6241 yyerror (YY_("syntax error"));
6242 goto yyexhaustedlab;
6243 }
6244 }
6245 else
6246#endif /* YYERROR_VERBOSE */
6247 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006248 }
Reid Spencer950bf602007-01-26 08:19:09 +00006249
6250
6251
6252 if (yyerrstatus == 3)
6253 {
6254 /* If just tried and failed to reuse look-ahead token after an
6255 error, discard it. */
6256
6257 if (yychar <= YYEOF)
Reid Spencerb7046c72007-01-29 05:41:34 +00006258 {
Reid Spencer950bf602007-01-26 08:19:09 +00006259 /* Return failure if at end of input. */
6260 if (yychar == YYEOF)
6261 YYABORT;
Reid Spencerb7046c72007-01-29 05:41:34 +00006262 }
Reid Spencer950bf602007-01-26 08:19:09 +00006263 else
6264 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006265 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer950bf602007-01-26 08:19:09 +00006266 yychar = YYEMPTY;
6267 }
6268 }
6269
6270 /* Else will try to reuse look-ahead token after shifting the error
6271 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006272 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006273
Reid Spencer319a7302007-01-05 17:20:02 +00006274
Reid Spencer950bf602007-01-26 08:19:09 +00006275/*---------------------------------------------------.
6276| yyerrorlab -- error raised explicitly by YYERROR. |
6277`---------------------------------------------------*/
6278yyerrorlab:
6279
6280 /* Pacify compilers like GCC when the user code never invokes
6281 YYERROR and the label yyerrorlab therefore never appears in user
6282 code. */
Reid Spencerb7046c72007-01-29 05:41:34 +00006283 if (0)
Reid Spencer950bf602007-01-26 08:19:09 +00006284 goto yyerrorlab;
6285
Reid Spencerb7046c72007-01-29 05:41:34 +00006286yyvsp -= yylen;
6287 yyssp -= yylen;
Reid Spencer950bf602007-01-26 08:19:09 +00006288 yystate = *yyssp;
6289 goto yyerrlab1;
6290
6291
6292/*-------------------------------------------------------------.
6293| yyerrlab1 -- common code for both syntax error and YYERROR. |
6294`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006295yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006296 yyerrstatus = 3; /* Each real token shifted decrements this. */
6297
6298 for (;;)
6299 {
6300 yyn = yypact[yystate];
6301 if (yyn != YYPACT_NINF)
6302 {
6303 yyn += YYTERROR;
6304 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6305 {
6306 yyn = yytable[yyn];
6307 if (0 < yyn)
6308 break;
6309 }
6310 }
6311
6312 /* Pop the current state because it cannot handle the error token. */
6313 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006314 YYABORT;
6315
6316
Reid Spencerb7046c72007-01-29 05:41:34 +00006317 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6318 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006319 yystate = *yyssp;
6320 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006321 }
6322
6323 if (yyn == YYFINAL)
6324 YYACCEPT;
6325
6326 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006327
6328
Reid Spencerb7046c72007-01-29 05:41:34 +00006329 /* Shift the error token. */
Reid Spencer950bf602007-01-26 08:19:09 +00006330 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6331
Reid Spencere7c3c602006-11-30 06:36:44 +00006332 yystate = yyn;
6333 goto yynewstate;
6334
Chris Lattner37e01c52007-01-04 18:46:42 +00006335
Reid Spencer319a7302007-01-05 17:20:02 +00006336/*-------------------------------------.
6337| yyacceptlab -- YYACCEPT comes here. |
6338`-------------------------------------*/
6339yyacceptlab:
6340 yyresult = 0;
6341 goto yyreturn;
6342
6343/*-----------------------------------.
6344| yyabortlab -- YYABORT comes here. |
6345`-----------------------------------*/
6346yyabortlab:
6347 yyresult = 1;
6348 goto yyreturn;
6349
6350#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006351/*-------------------------------------------------.
6352| yyexhaustedlab -- memory exhaustion comes here. |
6353`-------------------------------------------------*/
6354yyexhaustedlab:
6355 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006356 yyresult = 2;
6357 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006358#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006359
6360yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006361 if (yychar != YYEOF && yychar != YYEMPTY)
6362 yydestruct ("Cleanup: discarding lookahead",
6363 yytoken, &yylval);
6364 while (yyssp != yyss)
6365 {
6366 yydestruct ("Cleanup: popping",
6367 yystos[*yyssp], yyvsp);
Reid Spencerb7046c72007-01-29 05:41:34 +00006368 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006369 }
Reid Spencer319a7302007-01-05 17:20:02 +00006370#ifndef yyoverflow
6371 if (yyss != yyssa)
6372 YYSTACK_FREE (yyss);
6373#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006374 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006375}
Reid Spencer319a7302007-01-05 17:20:02 +00006376
6377
Reid Spencer7de2e012007-01-29 19:08:46 +00006378#line 3399 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006379
6380
6381int yyerror(const char *ErrorMsg) {
6382 std::string where
6383 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006384 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6385 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6386 if (yychar != YYEMPTY && yychar != 0)
6387 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6388 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006389 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006390 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006391 exit(1);
6392}
Reid Spencer319a7302007-01-05 17:20:02 +00006393
Reid Spencer30d0c582007-01-15 00:26:18 +00006394void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006395 std::string where
6396 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006397 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6398 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6399 if (yychar != YYEMPTY && yychar != 0)
6400 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6401 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006402 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6403}
6404
Reid Spencer950bf602007-01-26 08:19:09 +00006405void error(const std::string& ErrorMsg, int LineNo) {
6406 if (LineNo == -1) LineNo = Upgradelineno;
6407 Upgradelineno = LineNo;
6408 yyerror(ErrorMsg.c_str());
6409}
6410
6411