blob: 239f6a4cb53ae9597d2e6b47d4afc2348fd34b68 [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,
Reid Spencer832254e2007-02-02 02:16:23 +0000157 SHL = 348,
158 SHR = 349,
159 ASHR = 350,
160 LSHR = 351,
161 SETLE = 352,
162 SETGE = 353,
163 SETLT = 354,
164 SETGT = 355,
165 SETEQ = 356,
166 SETNE = 357,
167 ICMP = 358,
168 FCMP = 359,
169 MALLOC = 360,
170 ALLOCA = 361,
171 FREE = 362,
172 LOAD = 363,
173 STORE = 364,
174 GETELEMENTPTR = 365,
175 PHI_TOK = 366,
176 SELECT = 367,
Reid Spencer950bf602007-01-26 08:19:09 +0000177 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
Reid Spencer832254e2007-02-02 02:16:23 +0000309#define SHL 348
310#define SHR 349
311#define ASHR 350
312#define LSHR 351
313#define SETLE 352
314#define SETGE 353
315#define SETLT 354
316#define SETGT 355
317#define SETEQ 356
318#define SETNE 357
319#define ICMP 358
320#define FCMP 359
321#define MALLOC 360
322#define ALLOCA 361
323#define FREE 362
324#define LOAD 363
325#define STORE 364
326#define GETELEMENTPTR 365
327#define PHI_TOK 366
328#define SELECT 367
Reid Spencer950bf602007-01-26 08:19:09 +0000329#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 Spenceref9b9a72007-02-05 20:47:22 +0000373#line 14 "/proj/llvm/llvm-3/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"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000380#include "llvm/ValueSymbolTable.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000381#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;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000675 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
676 V = SymTab.lookup(LookupName);
677 if (V && V->getType() != Ty)
678 V = 0;
Reid Spencer950bf602007-01-26 08:19:09 +0000679 }
680 if (!V) {
681 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
682 std::string LookupName;
683 if (I != CurModule.RenameMap.end())
684 LookupName = I->second;
685 else
686 LookupName = Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000687 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
688 if (V && V->getType() != Ty)
689 V = 0;
Reid Spencer950bf602007-01-26 08:19:09 +0000690 }
Reid Spenceref9b9a72007-02-05 20:47:22 +0000691 if (!V)
Reid Spencer950bf602007-01-26 08:19:09 +0000692 return 0;
693
694 D.destroy(); // Free old strdup'd memory...
695 return V;
696 }
697
698 // Check to make sure that "Ty" is an integral type, and that our
699 // value will fit into the specified type...
700 case ValID::ConstSIntVal: // Is it a constant pool reference??
701 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
702 error("Signed integral constant '" + itostr(D.ConstPool64) +
703 "' is invalid for type '" + Ty->getDescription() + "'");
704 }
705 return ConstantInt::get(Ty, D.ConstPool64);
706
707 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
708 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
709 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
710 error("Integral constant '" + utostr(D.UConstPool64) +
711 "' is invalid or out of range");
712 else // This is really a signed reference. Transmogrify.
713 return ConstantInt::get(Ty, D.ConstPool64);
714 } else
715 return ConstantInt::get(Ty, D.UConstPool64);
716
717 case ValID::ConstFPVal: // Is it a floating point const pool reference?
718 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
719 error("FP constant invalid for type");
720 return ConstantFP::get(Ty, D.ConstPoolFP);
721
722 case ValID::ConstNullVal: // Is it a null value?
723 if (!isa<PointerType>(Ty))
724 error("Cannot create a a non pointer null");
725 return ConstantPointerNull::get(cast<PointerType>(Ty));
726
727 case ValID::ConstUndefVal: // Is it an undef value?
728 return UndefValue::get(Ty);
729
730 case ValID::ConstZeroVal: // Is it a zero value?
731 return Constant::getNullValue(Ty);
732
733 case ValID::ConstantVal: // Fully resolved constant?
734 if (D.ConstantValue->getType() != Ty)
735 error("Constant expression type different from required type");
736 return D.ConstantValue;
737
738 case ValID::InlineAsmVal: { // Inline asm expression
739 const PointerType *PTy = dyn_cast<PointerType>(Ty);
740 const FunctionType *FTy =
741 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
742 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
743 error("Invalid type for asm constraint string");
744 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
745 D.IAD->HasSideEffects);
746 D.destroy(); // Free InlineAsmDescriptor.
747 return IA;
748 }
749 default:
750 assert(0 && "Unhandled case");
751 return 0;
752 } // End of switch
753
754 assert(0 && "Unhandled case");
755 return 0;
756}
757
758// getVal - This function is identical to getExistingValue, except that if a
759// value is not already defined, it "improvises" by creating a placeholder var
760// that looks and acts just like the requested variable. When the value is
761// defined later, all uses of the placeholder variable are replaced with the
762// real thing.
763//
764static Value *getVal(const Type *Ty, const ValID &ID) {
765 if (Ty == Type::LabelTy)
766 error("Cannot use a basic block here");
767
768 // See if the value has already been defined.
769 Value *V = getExistingValue(Ty, ID);
770 if (V) return V;
771
772 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
773 error("Invalid use of a composite type");
774
775 // If we reached here, we referenced either a symbol that we don't know about
776 // or an id number that hasn't been read yet. We may be referencing something
777 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000778 V = new Argument(Ty);
779
780 // Remember where this forward reference came from. FIXME, shouldn't we try
781 // to recycle these things??
782 CurModule.PlaceHolderInfo.insert(
Reid Spenceref9b9a72007-02-05 20:47:22 +0000783 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
Reid Spencer950bf602007-01-26 08:19:09 +0000784
785 if (inFunctionScope())
786 InsertValue(V, CurFun.LateResolveValues);
787 else
788 InsertValue(V, CurModule.LateResolveValues);
789 return V;
790}
791
792/// getBBVal - This is used for two purposes:
793/// * If isDefinition is true, a new basic block with the specified ID is being
794/// defined.
795/// * If isDefinition is true, this is a reference to a basic block, which may
796/// or may not be a forward reference.
797///
798static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
799 assert(inFunctionScope() && "Can't get basic block at global scope");
800
801 std::string Name;
802 BasicBlock *BB = 0;
803 switch (ID.Type) {
804 default:
805 error("Illegal label reference " + ID.getName());
806 break;
807 case ValID::NumberVal: // Is it a numbered definition?
808 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
809 CurFun.NumberedBlocks.resize(ID.Num+1);
810 BB = CurFun.NumberedBlocks[ID.Num];
811 break;
812 case ValID::NameVal: // Is it a named definition?
813 Name = ID.Name;
814 if (Value *N = CurFun.CurrentFunction->
Reid Spenceref9b9a72007-02-05 20:47:22 +0000815 getValueSymbolTable().lookup(Name)) {
Reid Spencer950bf602007-01-26 08:19:09 +0000816 if (N->getType() != Type::LabelTy)
817 error("Name '" + Name + "' does not refer to a BasicBlock");
818 BB = cast<BasicBlock>(N);
819 }
820 break;
821 }
822
823 // See if the block has already been defined.
824 if (BB) {
825 // If this is the definition of the block, make sure the existing value was
826 // just a forward reference. If it was a forward reference, there will be
827 // an entry for it in the PlaceHolderInfo map.
828 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
829 // The existing value was a definition, not a forward reference.
830 error("Redefinition of label " + ID.getName());
831
832 ID.destroy(); // Free strdup'd memory.
833 return BB;
834 }
835
836 // Otherwise this block has not been seen before.
837 BB = new BasicBlock("", CurFun.CurrentFunction);
838 if (ID.Type == ValID::NameVal) {
839 BB->setName(ID.Name);
840 } else {
841 CurFun.NumberedBlocks[ID.Num] = BB;
842 }
843
844 // If this is not a definition, keep track of it so we can use it as a forward
845 // reference.
846 if (!isDefinition) {
847 // Remember where this forward reference came from.
848 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
849 } else {
850 // The forward declaration could have been inserted anywhere in the
851 // function: insert it into the correct place now.
852 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
853 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
854 }
855 ID.destroy();
856 return BB;
857}
858
859
860//===----------------------------------------------------------------------===//
861// Code to handle forward references in instructions
862//===----------------------------------------------------------------------===//
863//
864// This code handles the late binding needed with statements that reference
865// values not defined yet... for example, a forward branch, or the PHI node for
866// a loop body.
867//
868// This keeps a table (CurFun.LateResolveValues) of all such forward references
869// and back patchs after we are done.
870//
871
Reid Spencer7de2e012007-01-29 19:08:46 +0000872/// This function determines if two function types differ only in their use of
873/// the sret parameter attribute in the first argument. If they are identical
874/// in all other respects, it returns true. Otherwise, it returns false.
875bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
876 const FunctionType *F2) {
877 if (F1->getReturnType() != F2->getReturnType() ||
878 F1->getNumParams() != F2->getNumParams() ||
879 F1->getParamAttrs(0) != F2->getParamAttrs(0))
880 return false;
881 unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute);
882 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
883 if (F1->getParamType(i) != F2->getParamType(i) ||
884 unsigned(F1->getParamAttrs(i+1)) & SRetMask !=
885 unsigned(F2->getParamAttrs(i+1)) & SRetMask)
886 return false;
887 }
888 return true;
889}
890
Reid Spencer950bf602007-01-26 08:19:09 +0000891// ResolveDefinitions - If we could not resolve some defs at parsing
892// time (forward branches, phi functions for loops, etc...) resolve the
893// defs now...
894//
895static void
896ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
897 std::map<const Type*,ValueList> *FutureLateResolvers) {
898 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
899 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
900 E = LateResolvers.end(); LRI != E; ++LRI) {
901 ValueList &List = LRI->second;
902 while (!List.empty()) {
903 Value *V = List.back();
904 List.pop_back();
905
906 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
907 CurModule.PlaceHolderInfo.find(V);
908 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
909
910 ValID &DID = PHI->second.first;
911
912 Value *TheRealValue = getExistingValue(LRI->first, DID);
913 if (TheRealValue) {
914 V->replaceAllUsesWith(TheRealValue);
915 delete V;
916 CurModule.PlaceHolderInfo.erase(PHI);
917 } else if (FutureLateResolvers) {
918 // Functions have their unresolved items forwarded to the module late
919 // resolver table
920 InsertValue(V, *FutureLateResolvers);
921 } else {
922 if (DID.Type == ValID::NameVal) {
Reid Spencer7de2e012007-01-29 19:08:46 +0000923 // The upgrade of csretcc to sret param attribute may have caused a
924 // function to not be found because the param attribute changed the
925 // type of the called function. Detect this situation and insert a
926 // cast as necessary.
927 bool fixed = false;
928 if (const PointerType *PTy = dyn_cast<PointerType>(V->getType()))
929 if (const FunctionType *FTy =
930 dyn_cast<FunctionType>(PTy->getElementType()))
931 if (Function *OtherF =
Reid Spencer688b0492007-02-05 21:19:13 +0000932 CurModule.CurrentModule->getFunction(DID.getName()))
Reid Spencer7de2e012007-01-29 19:08:46 +0000933 if (FuncTysDifferOnlyBySRet(FTy,OtherF->getFunctionType())) {
934 V->replaceAllUsesWith(ConstantExpr::getBitCast(OtherF, PTy));
935 fixed = true;
936 }
937 if (!fixed) {
938 error("Reference to an invalid definition: '" +DID.getName()+
939 "' of type '" + V->getType()->getDescription() + "'",
940 PHI->second.second);
941 return;
942 }
Reid Spencer950bf602007-01-26 08:19:09 +0000943 } else {
944 error("Reference to an invalid definition: #" +
945 itostr(DID.Num) + " of type '" +
946 V->getType()->getDescription() + "'", PHI->second.second);
947 return;
948 }
949 }
950 }
951 }
952
953 LateResolvers.clear();
954}
955
956// ResolveTypeTo - A brand new type was just declared. This means that (if
957// name is not null) things referencing Name can be resolved. Otherwise, things
958// refering to the number can be resolved. Do this now.
959//
960static void ResolveTypeTo(char *Name, const Type *ToTy) {
961 ValID D;
962 if (Name) D = ValID::create(Name);
963 else D = ValID::create((int)CurModule.Types.size());
964
965 std::map<ValID, PATypeHolder>::iterator I =
966 CurModule.LateResolveTypes.find(D);
967 if (I != CurModule.LateResolveTypes.end()) {
968 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
969 CurModule.LateResolveTypes.erase(I);
970 }
971}
972
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000973/// @brief This just makes any name given to it unique, up to MAX_UINT times.
Reid Spencer950bf602007-01-26 08:19:09 +0000974static std::string makeNameUnique(const std::string& Name) {
975 static unsigned UniqueNameCounter = 1;
976 std::string Result(Name);
977 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
978 return Result;
979}
980
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000981/// This is the implementation portion of TypeHasInteger. It traverses the
982/// type given, avoiding recursive types, and returns true as soon as it finds
983/// an integer type. If no integer type is found, it returns false.
984static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
985 // Handle some easy cases
986 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
987 return false;
988 if (Ty->isInteger())
989 return true;
990 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
991 return STy->getElementType()->isInteger();
992
993 // Avoid type structure recursion
994 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
995 I != E; ++I)
996 if (Ty == *I)
997 return false;
998
999 // Push us on the type stack
1000 Stack.push_back(Ty);
1001
1002 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1003 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1004 return true;
1005 FunctionType::param_iterator I = FTy->param_begin();
1006 FunctionType::param_iterator E = FTy->param_end();
1007 for (; I != E; ++I)
1008 if (TypeHasIntegerI(*I, Stack))
1009 return true;
1010 return false;
1011 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1012 StructType::element_iterator I = STy->element_begin();
1013 StructType::element_iterator E = STy->element_end();
1014 for (; I != E; ++I) {
1015 if (TypeHasIntegerI(*I, Stack))
1016 return true;
1017 }
1018 return false;
1019 }
1020 // There shouldn't be anything else, but its definitely not integer
1021 assert(0 && "What type is this?");
1022 return false;
1023}
1024
1025/// This is the interface to TypeHasIntegerI. It just provides the type stack,
1026/// to avoid recursion, and then calls TypeHasIntegerI.
1027static inline bool TypeHasInteger(const Type *Ty) {
1028 std::vector<const Type*> TyStack;
1029 return TypeHasIntegerI(Ty, TyStack);
1030}
1031
Reid Spencer950bf602007-01-26 08:19:09 +00001032// setValueName - Set the specified value to the name given. The name may be
1033// null potentially, in which case this is a noop. The string passed in is
1034// assumed to be a malloc'd string buffer, and is free'd by this function.
1035//
1036static void setValueName(Value *V, char *NameStr) {
1037 if (NameStr) {
1038 std::string Name(NameStr); // Copy string
1039 free(NameStr); // Free old string
1040
1041 if (V->getType() == Type::VoidTy) {
1042 error("Can't assign name '" + Name + "' to value with void type");
1043 return;
1044 }
1045
Reid Spencer950bf602007-01-26 08:19:09 +00001046 assert(inFunctionScope() && "Must be in function scope");
1047
1048 // Search the function's symbol table for an existing value of this name
Reid Spenceref9b9a72007-02-05 20:47:22 +00001049 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1050 Value* Existing = ST.lookup(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001051 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001052 // An existing value of the same name was found. This might have happened
1053 // because of the integer type planes collapsing in LLVM 2.0.
1054 if (Existing->getType() == V->getType() &&
1055 !TypeHasInteger(Existing->getType())) {
1056 // If the type does not contain any integers in them then this can't be
1057 // a type plane collapsing issue. It truly is a redefinition and we
1058 // should error out as the assembly is invalid.
1059 error("Redefinition of value named '" + Name + "' of type '" +
1060 V->getType()->getDescription() + "'");
1061 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001062 }
1063 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1064 // function, regardless of Type. Previously re-use of names was okay as
1065 // long as they were distinct types. With type planes collapsing because
1066 // of the signedness change and because of PR411, this can no longer be
1067 // supported. We must search the entire symbol table for a conflicting
1068 // name and make the name unique. No warning is needed as this can't
1069 // cause a problem.
1070 std::string NewName = makeNameUnique(Name);
1071 // We're changing the name but it will probably be used by other
1072 // instructions as operands later on. Consequently we have to retain
1073 // a mapping of the renaming that we're doing.
1074 RenameMapKey Key = std::make_pair(Name,V->getType());
1075 CurFun.RenameMap[Key] = NewName;
1076 Name = NewName;
1077 }
1078
1079 // Set the name.
1080 V->setName(Name);
1081 }
1082}
1083
1084/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1085/// this is a declaration, otherwise it is a definition.
1086static GlobalVariable *
1087ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1088 bool isConstantGlobal, const Type *Ty,
1089 Constant *Initializer) {
1090 if (isa<FunctionType>(Ty))
1091 error("Cannot declare global vars of function type");
1092
1093 const PointerType *PTy = PointerType::get(Ty);
1094
1095 std::string Name;
1096 if (NameStr) {
1097 Name = NameStr; // Copy string
1098 free(NameStr); // Free old string
1099 }
1100
1101 // See if this global value was forward referenced. If so, recycle the
1102 // object.
1103 ValID ID;
1104 if (!Name.empty()) {
1105 ID = ValID::create((char*)Name.c_str());
1106 } else {
1107 ID = ValID::create((int)CurModule.Values[PTy].size());
1108 }
1109
1110 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1111 // Move the global to the end of the list, from whereever it was
1112 // previously inserted.
1113 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1114 CurModule.CurrentModule->getGlobalList().remove(GV);
1115 CurModule.CurrentModule->getGlobalList().push_back(GV);
1116 GV->setInitializer(Initializer);
1117 GV->setLinkage(Linkage);
1118 GV->setConstant(isConstantGlobal);
1119 InsertValue(GV, CurModule.Values);
1120 return GV;
1121 }
1122
1123 // If this global has a name, check to see if there is already a definition
1124 // of this global in the module and emit warnings if there are conflicts.
1125 if (!Name.empty()) {
1126 // The global has a name. See if there's an existing one of the same name.
1127 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1128 // We found an existing global ov the same name. This isn't allowed
1129 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1130 // can at least compile. This can happen because of type planes
1131 // There is alread a global of the same name which means there is a
1132 // conflict. Let's see what we can do about it.
1133 std::string NewName(makeNameUnique(Name));
1134 if (Linkage == GlobalValue::InternalLinkage) {
1135 // The linkage type is internal so just warn about the rename without
1136 // invoking "scarey language" about linkage failures. GVars with
1137 // InternalLinkage can be renamed at will.
1138 warning("Global variable '" + Name + "' was renamed to '"+
1139 NewName + "'");
1140 } else {
1141 // The linkage of this gval is external so we can't reliably rename
1142 // it because it could potentially create a linking problem.
1143 // However, we can't leave the name conflict in the output either or
1144 // it won't assemble with LLVM 2.0. So, all we can do is rename
1145 // this one to something unique and emit a warning about the problem.
1146 warning("Renaming global variable '" + Name + "' to '" + NewName +
1147 "' may cause linkage errors");
1148 }
1149
1150 // Put the renaming in the global rename map
1151 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1152 CurModule.RenameMap[Key] = NewName;
1153
1154 // Rename it
1155 Name = NewName;
1156 }
1157 }
1158
1159 // Otherwise there is no existing GV to use, create one now.
1160 GlobalVariable *GV =
1161 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1162 CurModule.CurrentModule);
1163 InsertValue(GV, CurModule.Values);
1164 return GV;
1165}
1166
1167// setTypeName - Set the specified type to the name given. The name may be
1168// null potentially, in which case this is a noop. The string passed in is
1169// assumed to be a malloc'd string buffer, and is freed by this function.
1170//
1171// This function returns true if the type has already been defined, but is
1172// allowed to be redefined in the specified context. If the name is a new name
1173// for the type plane, it is inserted and false is returned.
1174static bool setTypeName(const Type *T, char *NameStr) {
1175 assert(!inFunctionScope() && "Can't give types function-local names");
1176 if (NameStr == 0) return false;
1177
1178 std::string Name(NameStr); // Copy string
1179 free(NameStr); // Free old string
1180
1181 // We don't allow assigning names to void type
1182 if (T == Type::VoidTy) {
1183 error("Can't assign name '" + Name + "' to the void type");
1184 return false;
1185 }
1186
1187 // Set the type name, checking for conflicts as we do so.
1188 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1189
1190 if (AlreadyExists) { // Inserting a name that is already defined???
1191 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1192 assert(Existing && "Conflict but no matching type?");
1193
1194 // There is only one case where this is allowed: when we are refining an
1195 // opaque type. In this case, Existing will be an opaque type.
1196 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1197 // We ARE replacing an opaque type!
1198 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1199 return true;
1200 }
1201
1202 // Otherwise, this is an attempt to redefine a type. That's okay if
1203 // the redefinition is identical to the original. This will be so if
1204 // Existing and T point to the same Type object. In this one case we
1205 // allow the equivalent redefinition.
1206 if (Existing == T) return true; // Yes, it's equal.
1207
1208 // Any other kind of (non-equivalent) redefinition is an error.
1209 error("Redefinition of type named '" + Name + "' in the '" +
1210 T->getDescription() + "' type plane");
1211 }
1212
1213 return false;
1214}
1215
1216//===----------------------------------------------------------------------===//
1217// Code for handling upreferences in type names...
1218//
1219
1220// TypeContains - Returns true if Ty directly contains E in it.
1221//
1222static bool TypeContains(const Type *Ty, const Type *E) {
1223 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1224 E) != Ty->subtype_end();
1225}
1226
1227namespace {
1228 struct UpRefRecord {
1229 // NestingLevel - The number of nesting levels that need to be popped before
1230 // this type is resolved.
1231 unsigned NestingLevel;
1232
1233 // LastContainedTy - This is the type at the current binding level for the
1234 // type. Every time we reduce the nesting level, this gets updated.
1235 const Type *LastContainedTy;
1236
1237 // UpRefTy - This is the actual opaque type that the upreference is
1238 // represented with.
1239 OpaqueType *UpRefTy;
1240
1241 UpRefRecord(unsigned NL, OpaqueType *URTy)
1242 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1243 };
1244}
1245
1246// UpRefs - A list of the outstanding upreferences that need to be resolved.
1247static std::vector<UpRefRecord> UpRefs;
1248
1249/// HandleUpRefs - Every time we finish a new layer of types, this function is
1250/// called. It loops through the UpRefs vector, which is a list of the
1251/// currently active types. For each type, if the up reference is contained in
1252/// the newly completed type, we decrement the level count. When the level
1253/// count reaches zero, the upreferenced type is the type that is passed in:
1254/// thus we can complete the cycle.
1255///
1256static PATypeHolder HandleUpRefs(const Type *ty) {
1257 // If Ty isn't abstract, or if there are no up-references in it, then there is
1258 // nothing to resolve here.
1259 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1260
1261 PATypeHolder Ty(ty);
1262 UR_OUT("Type '" << Ty->getDescription() <<
1263 "' newly formed. Resolving upreferences.\n" <<
1264 UpRefs.size() << " upreferences active!\n");
1265
1266 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1267 // to zero), we resolve them all together before we resolve them to Ty. At
1268 // the end of the loop, if there is anything to resolve to Ty, it will be in
1269 // this variable.
1270 OpaqueType *TypeToResolve = 0;
1271
1272 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1273 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1274 << UpRefs[i].second->getDescription() << ") = "
1275 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1276 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1277 // Decrement level of upreference
1278 unsigned Level = --UpRefs[i].NestingLevel;
1279 UpRefs[i].LastContainedTy = Ty;
1280 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1281 if (Level == 0) { // Upreference should be resolved!
1282 if (!TypeToResolve) {
1283 TypeToResolve = UpRefs[i].UpRefTy;
1284 } else {
1285 UR_OUT(" * Resolving upreference for "
1286 << UpRefs[i].second->getDescription() << "\n";
1287 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1288 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1289 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1290 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1291 }
1292 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1293 --i; // Do not skip the next element...
1294 }
1295 }
1296 }
1297
1298 if (TypeToResolve) {
1299 UR_OUT(" * Resolving upreference for "
1300 << UpRefs[i].second->getDescription() << "\n";
1301 std::string OldName = TypeToResolve->getDescription());
1302 TypeToResolve->refineAbstractTypeTo(Ty);
1303 }
1304
1305 return Ty;
1306}
1307
1308static inline Instruction::TermOps
1309getTermOp(TermOps op) {
1310 switch (op) {
1311 default : assert(0 && "Invalid OldTermOp");
1312 case RetOp : return Instruction::Ret;
1313 case BrOp : return Instruction::Br;
1314 case SwitchOp : return Instruction::Switch;
1315 case InvokeOp : return Instruction::Invoke;
1316 case UnwindOp : return Instruction::Unwind;
1317 case UnreachableOp: return Instruction::Unreachable;
1318 }
1319}
1320
1321static inline Instruction::BinaryOps
1322getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1323 switch (op) {
1324 default : assert(0 && "Invalid OldBinaryOps");
1325 case SetEQ :
1326 case SetNE :
1327 case SetLE :
1328 case SetGE :
1329 case SetLT :
1330 case SetGT : assert(0 && "Should use getCompareOp");
1331 case AddOp : return Instruction::Add;
1332 case SubOp : return Instruction::Sub;
1333 case MulOp : return Instruction::Mul;
1334 case DivOp : {
1335 // This is an obsolete instruction so we must upgrade it based on the
1336 // types of its operands.
1337 bool isFP = Ty->isFloatingPoint();
1338 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1339 // If its a packed type we want to use the element type
1340 isFP = PTy->getElementType()->isFloatingPoint();
1341 if (isFP)
1342 return Instruction::FDiv;
1343 else if (Sign == Signed)
1344 return Instruction::SDiv;
1345 return Instruction::UDiv;
1346 }
1347 case UDivOp : return Instruction::UDiv;
1348 case SDivOp : return Instruction::SDiv;
1349 case FDivOp : return Instruction::FDiv;
1350 case RemOp : {
1351 // This is an obsolete instruction so we must upgrade it based on the
1352 // types of its operands.
1353 bool isFP = Ty->isFloatingPoint();
1354 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1355 // If its a packed type we want to use the element type
1356 isFP = PTy->getElementType()->isFloatingPoint();
1357 // Select correct opcode
1358 if (isFP)
1359 return Instruction::FRem;
1360 else if (Sign == Signed)
1361 return Instruction::SRem;
1362 return Instruction::URem;
1363 }
1364 case URemOp : return Instruction::URem;
1365 case SRemOp : return Instruction::SRem;
1366 case FRemOp : return Instruction::FRem;
Reid Spencer832254e2007-02-02 02:16:23 +00001367 case LShrOp : return Instruction::LShr;
1368 case AShrOp : return Instruction::AShr;
1369 case ShlOp : return Instruction::Shl;
1370 case ShrOp :
1371 if (Sign == Signed)
1372 return Instruction::AShr;
1373 return Instruction::LShr;
Reid Spencer950bf602007-01-26 08:19:09 +00001374 case AndOp : return Instruction::And;
1375 case OrOp : return Instruction::Or;
1376 case XorOp : return Instruction::Xor;
1377 }
1378}
1379
1380static inline Instruction::OtherOps
1381getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1382 Signedness Sign) {
1383 bool isSigned = Sign == Signed;
1384 bool isFP = Ty->isFloatingPoint();
1385 switch (op) {
1386 default : assert(0 && "Invalid OldSetCC");
1387 case SetEQ :
1388 if (isFP) {
1389 predicate = FCmpInst::FCMP_OEQ;
1390 return Instruction::FCmp;
1391 } else {
1392 predicate = ICmpInst::ICMP_EQ;
1393 return Instruction::ICmp;
1394 }
1395 case SetNE :
1396 if (isFP) {
1397 predicate = FCmpInst::FCMP_UNE;
1398 return Instruction::FCmp;
1399 } else {
1400 predicate = ICmpInst::ICMP_NE;
1401 return Instruction::ICmp;
1402 }
1403 case SetLE :
1404 if (isFP) {
1405 predicate = FCmpInst::FCMP_OLE;
1406 return Instruction::FCmp;
1407 } else {
1408 if (isSigned)
1409 predicate = ICmpInst::ICMP_SLE;
1410 else
1411 predicate = ICmpInst::ICMP_ULE;
1412 return Instruction::ICmp;
1413 }
1414 case SetGE :
1415 if (isFP) {
1416 predicate = FCmpInst::FCMP_OGE;
1417 return Instruction::FCmp;
1418 } else {
1419 if (isSigned)
1420 predicate = ICmpInst::ICMP_SGE;
1421 else
1422 predicate = ICmpInst::ICMP_UGE;
1423 return Instruction::ICmp;
1424 }
1425 case SetLT :
1426 if (isFP) {
1427 predicate = FCmpInst::FCMP_OLT;
1428 return Instruction::FCmp;
1429 } else {
1430 if (isSigned)
1431 predicate = ICmpInst::ICMP_SLT;
1432 else
1433 predicate = ICmpInst::ICMP_ULT;
1434 return Instruction::ICmp;
1435 }
1436 case SetGT :
1437 if (isFP) {
1438 predicate = FCmpInst::FCMP_OGT;
1439 return Instruction::FCmp;
1440 } else {
1441 if (isSigned)
1442 predicate = ICmpInst::ICMP_SGT;
1443 else
1444 predicate = ICmpInst::ICMP_UGT;
1445 return Instruction::ICmp;
1446 }
1447 }
1448}
1449
1450static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1451 switch (op) {
1452 default : assert(0 && "Invalid OldMemoryOps");
1453 case MallocOp : return Instruction::Malloc;
1454 case FreeOp : return Instruction::Free;
1455 case AllocaOp : return Instruction::Alloca;
1456 case LoadOp : return Instruction::Load;
1457 case StoreOp : return Instruction::Store;
1458 case GetElementPtrOp : return Instruction::GetElementPtr;
1459 }
1460}
1461
1462static inline Instruction::OtherOps
1463getOtherOp(OtherOps op, Signedness Sign) {
1464 switch (op) {
1465 default : assert(0 && "Invalid OldOtherOps");
1466 case PHIOp : return Instruction::PHI;
1467 case CallOp : return Instruction::Call;
Reid Spencer950bf602007-01-26 08:19:09 +00001468 case SelectOp : return Instruction::Select;
1469 case UserOp1 : return Instruction::UserOp1;
1470 case UserOp2 : return Instruction::UserOp2;
1471 case VAArg : return Instruction::VAArg;
1472 case ExtractElementOp : return Instruction::ExtractElement;
1473 case InsertElementOp : return Instruction::InsertElement;
1474 case ShuffleVectorOp : return Instruction::ShuffleVector;
1475 case ICmpOp : return Instruction::ICmp;
1476 case FCmpOp : return Instruction::FCmp;
Reid Spencer950bf602007-01-26 08:19:09 +00001477 };
1478}
1479
1480static inline Value*
1481getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1482 Signedness DstSign, bool ForceInstruction = false) {
1483 Instruction::CastOps Opcode;
1484 const Type* SrcTy = Src->getType();
1485 if (op == CastOp) {
1486 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1487 // fp -> ptr cast is no longer supported but we must upgrade this
1488 // by doing a double cast: fp -> int -> ptr
1489 SrcTy = Type::Int64Ty;
1490 Opcode = Instruction::IntToPtr;
1491 if (isa<Constant>(Src)) {
1492 Src = ConstantExpr::getCast(Instruction::FPToUI,
1493 cast<Constant>(Src), SrcTy);
1494 } else {
1495 std::string NewName(makeNameUnique(Src->getName()));
1496 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1497 }
1498 } else if (isa<IntegerType>(DstTy) &&
1499 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1500 // cast type %x to bool was previously defined as setne type %x, null
1501 // The cast semantic is now to truncate, not compare so we must retain
1502 // the original intent by replacing the cast with a setne
1503 Constant* Null = Constant::getNullValue(SrcTy);
1504 Instruction::OtherOps Opcode = Instruction::ICmp;
1505 unsigned short predicate = ICmpInst::ICMP_NE;
1506 if (SrcTy->isFloatingPoint()) {
1507 Opcode = Instruction::FCmp;
1508 predicate = FCmpInst::FCMP_ONE;
1509 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1510 error("Invalid cast to bool");
1511 }
1512 if (isa<Constant>(Src) && !ForceInstruction)
1513 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1514 else
1515 return CmpInst::create(Opcode, predicate, Src, Null);
1516 }
1517 // Determine the opcode to use by calling CastInst::getCastOpcode
1518 Opcode =
1519 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1520
1521 } else switch (op) {
1522 default: assert(0 && "Invalid cast token");
1523 case TruncOp: Opcode = Instruction::Trunc; break;
1524 case ZExtOp: Opcode = Instruction::ZExt; break;
1525 case SExtOp: Opcode = Instruction::SExt; break;
1526 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1527 case FPExtOp: Opcode = Instruction::FPExt; break;
1528 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1529 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1530 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1531 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1532 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1533 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1534 case BitCastOp: Opcode = Instruction::BitCast; break;
1535 }
1536
1537 if (isa<Constant>(Src) && !ForceInstruction)
1538 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1539 return CastInst::create(Opcode, Src, DstTy);
1540}
1541
1542static Instruction *
1543upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1544 std::vector<Value*>& Args) {
1545
1546 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1547 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1548 if (Args.size() != 2)
1549 error("Invalid prototype for " + Name + " prototype");
1550 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1551 } else {
Reid Spencer950bf602007-01-26 08:19:09 +00001552 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1553 std::vector<const Type*> Params;
1554 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1555 if (Args.size() != 1)
1556 error("Invalid prototype for " + Name + " prototype");
1557 Params.push_back(PtrTy);
1558 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1559 const PointerType *PFTy = PointerType::get(FTy);
1560 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001561 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
Reid Spencer950bf602007-01-26 08:19:09 +00001562 return new CallInst(Func, Args);
1563 } else if (Name == "llvm.va_copy") {
1564 if (Args.size() != 2)
1565 error("Invalid prototype for " + Name + " prototype");
1566 Params.push_back(PtrTy);
1567 Params.push_back(PtrTy);
1568 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1569 const PointerType *PFTy = PointerType::get(FTy);
1570 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001571 std::string InstName0(makeNameUnique("va0"));
1572 std::string InstName1(makeNameUnique("va1"));
Reid Spencer950bf602007-01-26 08:19:09 +00001573 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1574 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1575 return new CallInst(Func, Args);
1576 }
1577 }
1578 return 0;
1579}
1580
1581const Type* upgradeGEPIndices(const Type* PTy,
1582 std::vector<ValueInfo> *Indices,
1583 std::vector<Value*> &VIndices,
1584 std::vector<Constant*> *CIndices = 0) {
1585 // Traverse the indices with a gep_type_iterator so we can build the list
1586 // of constant and value indices for use later. Also perform upgrades
1587 VIndices.clear();
1588 if (CIndices) CIndices->clear();
1589 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1590 VIndices.push_back((*Indices)[i].V);
1591 generic_gep_type_iterator<std::vector<Value*>::iterator>
1592 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1593 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1594 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1595 Value *Index = VIndices[i];
1596 if (CIndices && !isa<Constant>(Index))
1597 error("Indices to constant getelementptr must be constants");
1598 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1599 // struct indices to i32 struct indices with ZExt for compatibility.
1600 else if (isa<StructType>(*GTI)) { // Only change struct indices
1601 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1602 if (CUI->getType()->getBitWidth() == 8)
1603 Index =
1604 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1605 } else {
1606 // Make sure that unsigned SequentialType indices are zext'd to
1607 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1608 // all indices for SequentialType elements. We must retain the same
1609 // semantic (zext) for unsigned types.
1610 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001611 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001612 if (CIndices)
1613 Index = ConstantExpr::getCast(Instruction::ZExt,
1614 cast<Constant>(Index), Type::Int64Ty);
1615 else
1616 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001617 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001618 VIndices[i] = Index;
1619 }
Reid Spencer950bf602007-01-26 08:19:09 +00001620 }
1621 // Add to the CIndices list, if requested.
1622 if (CIndices)
1623 CIndices->push_back(cast<Constant>(Index));
1624 }
1625
1626 const Type *IdxTy =
1627 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1628 if (!IdxTy)
1629 error("Index list invalid for constant getelementptr");
1630 return IdxTy;
1631}
1632
Reid Spencerb7046c72007-01-29 05:41:34 +00001633unsigned upgradeCallingConv(unsigned CC) {
1634 switch (CC) {
1635 case OldCallingConv::C : return CallingConv::C;
1636 case OldCallingConv::CSRet : return CallingConv::C;
1637 case OldCallingConv::Fast : return CallingConv::Fast;
1638 case OldCallingConv::Cold : return CallingConv::Cold;
1639 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1640 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1641 default:
1642 return CC;
1643 }
1644}
1645
Reid Spencer950bf602007-01-26 08:19:09 +00001646Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1647 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001648{
1649 Upgradelineno = 1;
1650 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001651 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001652 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001653 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001654 ObsoleteVarArgs = false;
1655 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001656
Reid Spencer950bf602007-01-26 08:19:09 +00001657 CurModule.CurrentModule = new Module(CurFilename);
1658
1659 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001660 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001661 if (ParserResult)
1662 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001663 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001664 return 0;
1665 }
1666
Reid Spencer950bf602007-01-26 08:19:09 +00001667 // Check to make sure that parsing produced a result
1668 if (!ParserResult) {
1669 std::cerr << "llvm-upgrade: no parse result.\n";
1670 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001671 }
1672
Reid Spencer950bf602007-01-26 08:19:09 +00001673 // Reset ParserResult variable while saving its value for the result.
1674 Module *Result = ParserResult;
1675 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001676
Reid Spencer950bf602007-01-26 08:19:09 +00001677 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001678 {
Reid Spencer950bf602007-01-26 08:19:09 +00001679 Function* F;
Reid Spencer688b0492007-02-05 21:19:13 +00001680 if ((F = Result->getFunction("llvm.va_start"))
Reid Spencer950bf602007-01-26 08:19:09 +00001681 && F->getFunctionType()->getNumParams() == 0)
1682 ObsoleteVarArgs = true;
Reid Spencer688b0492007-02-05 21:19:13 +00001683 if((F = Result->getFunction("llvm.va_copy"))
Reid Spencer950bf602007-01-26 08:19:09 +00001684 && F->getFunctionType()->getNumParams() == 1)
1685 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001686 }
Reid Spencer319a7302007-01-05 17:20:02 +00001687
Reid Spencer950bf602007-01-26 08:19:09 +00001688 if (ObsoleteVarArgs && NewVarArgs) {
1689 error("This file is corrupt: it uses both new and old style varargs");
1690 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001691 }
Reid Spencer319a7302007-01-05 17:20:02 +00001692
Reid Spencer950bf602007-01-26 08:19:09 +00001693 if(ObsoleteVarArgs) {
Reid Spencer688b0492007-02-05 21:19:13 +00001694 if(Function* F = Result->getFunction("llvm.va_start")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001695 if (F->arg_size() != 0) {
1696 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001697 return 0;
1698 }
Reid Spencer950bf602007-01-26 08:19:09 +00001699
1700 //foo = va_start()
1701 // ->
1702 //bar = alloca typeof(foo)
1703 //va_start(bar)
1704 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001705
Reid Spencer950bf602007-01-26 08:19:09 +00001706 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1707 const Type* ArgTy = F->getFunctionType()->getReturnType();
1708 const Type* ArgTyPtr = PointerType::get(ArgTy);
1709 Function* NF = cast<Function>(Result->getOrInsertFunction(
1710 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1711
1712 while (!F->use_empty()) {
1713 CallInst* CI = cast<CallInst>(F->use_back());
1714 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1715 new CallInst(NF, bar, "", CI);
1716 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1717 CI->replaceAllUsesWith(foo);
1718 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001719 }
Reid Spencer950bf602007-01-26 08:19:09 +00001720 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001721 }
Reid Spencer950bf602007-01-26 08:19:09 +00001722
Reid Spencer688b0492007-02-05 21:19:13 +00001723 if(Function* F = Result->getFunction("llvm.va_end")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001724 if(F->arg_size() != 1) {
1725 error("Obsolete va_end takes 1 argument");
1726 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001727 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001728
Reid Spencer950bf602007-01-26 08:19:09 +00001729 //vaend foo
1730 // ->
1731 //bar = alloca 1 of typeof(foo)
1732 //vaend bar
1733 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1734 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1735 const Type* ArgTyPtr = PointerType::get(ArgTy);
1736 Function* NF = cast<Function>(Result->getOrInsertFunction(
1737 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001738
Reid Spencer950bf602007-01-26 08:19:09 +00001739 while (!F->use_empty()) {
1740 CallInst* CI = cast<CallInst>(F->use_back());
1741 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1742 new StoreInst(CI->getOperand(1), bar, CI);
1743 new CallInst(NF, bar, "", CI);
1744 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001745 }
Reid Spencer950bf602007-01-26 08:19:09 +00001746 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001747 }
Reid Spencer950bf602007-01-26 08:19:09 +00001748
Reid Spencer688b0492007-02-05 21:19:13 +00001749 if(Function* F = Result->getFunction("llvm.va_copy")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001750 if(F->arg_size() != 1) {
1751 error("Obsolete va_copy takes 1 argument");
1752 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001753 }
Reid Spencer950bf602007-01-26 08:19:09 +00001754 //foo = vacopy(bar)
1755 // ->
1756 //a = alloca 1 of typeof(foo)
1757 //b = alloca 1 of typeof(foo)
1758 //store bar -> b
1759 //vacopy(a, b)
1760 //foo = load a
1761
1762 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1763 const Type* ArgTy = F->getFunctionType()->getReturnType();
1764 const Type* ArgTyPtr = PointerType::get(ArgTy);
1765 Function* NF = cast<Function>(Result->getOrInsertFunction(
1766 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001767
Reid Spencer950bf602007-01-26 08:19:09 +00001768 while (!F->use_empty()) {
1769 CallInst* CI = cast<CallInst>(F->use_back());
1770 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1771 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1772 new StoreInst(CI->getOperand(1), b, CI);
1773 new CallInst(NF, a, b, "", CI);
1774 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1775 CI->replaceAllUsesWith(foo);
1776 CI->getParent()->getInstList().erase(CI);
1777 }
1778 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001779 }
1780 }
1781
Reid Spencer52402b02007-01-02 05:45:11 +00001782 return Result;
1783}
1784
Reid Spencer950bf602007-01-26 08:19:09 +00001785} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001786
Reid Spencer950bf602007-01-26 08:19:09 +00001787using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001788
1789
Reid Spencer319a7302007-01-05 17:20:02 +00001790
1791/* Enabling traces. */
1792#ifndef YYDEBUG
1793# define YYDEBUG 0
1794#endif
1795
1796/* Enabling verbose error messages. */
1797#ifdef YYERROR_VERBOSE
1798# undef YYERROR_VERBOSE
1799# define YYERROR_VERBOSE 1
1800#else
1801# define YYERROR_VERBOSE 0
1802#endif
1803
Reid Spencer950bf602007-01-26 08:19:09 +00001804/* Enabling the token table. */
1805#ifndef YYTOKEN_TABLE
1806# define YYTOKEN_TABLE 0
1807#endif
1808
Reid Spencerb7046c72007-01-29 05:41:34 +00001809#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spenceref9b9a72007-02-05 20:47:22 +00001810#line 1431 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00001811typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00001812 llvm::Module *ModuleVal;
1813 llvm::Function *FunctionVal;
1814 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1815 llvm::BasicBlock *BasicBlockVal;
1816 llvm::TerminatorInst *TermInstVal;
1817 llvm::InstrInfo InstVal;
1818 llvm::ConstInfo ConstVal;
1819 llvm::ValueInfo ValueVal;
1820 llvm::PATypeInfo TypeVal;
1821 llvm::TypeInfo PrimType;
1822 llvm::PHIListInfo PHIList;
1823 std::list<llvm::PATypeInfo> *TypeList;
1824 std::vector<llvm::ValueInfo> *ValueList;
1825 std::vector<llvm::ConstInfo> *ConstVector;
1826
1827
1828 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1829 // Represent the RHS of PHI node
1830 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1831
1832 llvm::GlobalValue::LinkageTypes Linkage;
1833 int64_t SInt64Val;
1834 uint64_t UInt64Val;
1835 int SIntVal;
1836 unsigned UIntVal;
1837 double FPVal;
1838 bool BoolVal;
1839
1840 char *StrVal; // This memory is strdup'd!
1841 llvm::ValID ValIDVal; // strdup'd memory maybe!
1842
1843 llvm::BinaryOps BinaryOpVal;
1844 llvm::TermOps TermOpVal;
1845 llvm::MemoryOps MemOpVal;
1846 llvm::OtherOps OtherOpVal;
1847 llvm::CastOps CastOpVal;
1848 llvm::ICmpInst::Predicate IPred;
1849 llvm::FCmpInst::Predicate FPred;
1850 llvm::Module::Endianness Endianness;
Reid Spencerb7046c72007-01-29 05:41:34 +00001851} YYSTYPE;
1852/* Line 196 of yacc.c. */
Reid Spenceref9b9a72007-02-05 20:47:22 +00001853#line 1854 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001854# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1855# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001856# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001857#endif
1858
Reid Spencer950bf602007-01-26 08:19:09 +00001859
Reid Spencere7c3c602006-11-30 06:36:44 +00001860
Reid Spencer319a7302007-01-05 17:20:02 +00001861/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001862
1863
Reid Spencerb7046c72007-01-29 05:41:34 +00001864/* Line 219 of yacc.c. */
Reid Spenceref9b9a72007-02-05 20:47:22 +00001865#line 1866 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001866
Reid Spencerb7046c72007-01-29 05:41:34 +00001867#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1868# define YYSIZE_T __SIZE_TYPE__
Reid Spencer950bf602007-01-26 08:19:09 +00001869#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001870#if ! defined (YYSIZE_T) && defined (size_t)
1871# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001872#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001873#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1874# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1875# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001876#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001877#if ! defined (YYSIZE_T)
1878# define YYSIZE_T unsigned int
Reid Spencer950bf602007-01-26 08:19:09 +00001879#endif
1880
1881#ifndef YY_
1882# if YYENABLE_NLS
1883# if ENABLE_NLS
1884# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1885# define YY_(msgid) dgettext ("bison-runtime", msgid)
1886# endif
1887# endif
1888# ifndef YY_
1889# define YY_(msgid) msgid
1890# endif
1891#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001892
Reid Spencerb7046c72007-01-29 05:41:34 +00001893#if ! defined (yyoverflow) || YYERROR_VERBOSE
Reid Spencer319a7302007-01-05 17:20:02 +00001894
1895/* The parser invokes alloca or malloc; define the necessary symbols. */
1896
Reid Spencer950bf602007-01-26 08:19:09 +00001897# ifdef YYSTACK_USE_ALLOCA
1898# if YYSTACK_USE_ALLOCA
1899# ifdef __GNUC__
1900# define YYSTACK_ALLOC __builtin_alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001901# else
Reid Spencer950bf602007-01-26 08:19:09 +00001902# define YYSTACK_ALLOC alloca
Reid Spencerb7046c72007-01-29 05:41:34 +00001903# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00001904# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Reid Spencerb7046c72007-01-29 05:41:34 +00001905# define YYINCLUDED_STDLIB_H
Reid Spencer319a7302007-01-05 17:20:02 +00001906# endif
1907# endif
1908# endif
1909# endif
1910
1911# ifdef YYSTACK_ALLOC
Reid Spencerb7046c72007-01-29 05:41:34 +00001912 /* Pacify GCC's `empty if-body' warning. */
1913# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00001914# ifndef YYSTACK_ALLOC_MAXIMUM
1915 /* The OS might guarantee only one guard page at the bottom of the stack,
1916 and a page size can be as small as 4096 bytes. So we cannot safely
1917 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1918 to allow for a few compiler-allocated temporary stack slots. */
Reid Spencerb7046c72007-01-29 05:41:34 +00001919# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer319a7302007-01-05 17:20:02 +00001920# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001921# else
1922# define YYSTACK_ALLOC YYMALLOC
1923# define YYSTACK_FREE YYFREE
1924# ifndef YYSTACK_ALLOC_MAXIMUM
Reid Spencerb7046c72007-01-29 05:41:34 +00001925# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
Reid Spencer950bf602007-01-26 08:19:09 +00001926# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001927# ifdef __cplusplus
1928extern "C" {
Reid Spencer950bf602007-01-26 08:19:09 +00001929# endif
1930# ifndef YYMALLOC
1931# define YYMALLOC malloc
Reid Spencerb7046c72007-01-29 05:41:34 +00001932# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1933 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001934void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1935# endif
1936# endif
1937# ifndef YYFREE
1938# define YYFREE free
Reid Spencerb7046c72007-01-29 05:41:34 +00001939# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1940 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001941void free (void *); /* INFRINGES ON USER NAME SPACE */
1942# endif
1943# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001944# ifdef __cplusplus
1945}
1946# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001947# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001948#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00001949
1950
Reid Spencerb7046c72007-01-29 05:41:34 +00001951#if (! defined (yyoverflow) \
1952 && (! defined (__cplusplus) \
1953 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001954
1955/* A type that is properly aligned for any stack member. */
1956union yyalloc
1957{
Reid Spencerb7046c72007-01-29 05:41:34 +00001958 short int yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001959 YYSTYPE yyvs;
1960 };
1961
1962/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00001963# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00001964
1965/* The size of an array large to enough to hold all stacks, each with
1966 N elements. */
1967# define YYSTACK_BYTES(N) \
Reid Spencerb7046c72007-01-29 05:41:34 +00001968 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer950bf602007-01-26 08:19:09 +00001969 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00001970
1971/* Copy COUNT objects from FROM to TO. The source and destination do
1972 not overlap. */
1973# ifndef YYCOPY
Reid Spencerb7046c72007-01-29 05:41:34 +00001974# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00001975# define YYCOPY(To, From, Count) \
1976 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1977# else
1978# define YYCOPY(To, From, Count) \
1979 do \
1980 { \
Reid Spencer950bf602007-01-26 08:19:09 +00001981 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00001982 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00001983 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00001984 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00001985 while (0)
Reid Spencer319a7302007-01-05 17:20:02 +00001986# endif
1987# endif
1988
1989/* Relocate STACK from its old location to the new one. The
1990 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1991 elements in the stack, and YYPTR gives the new location of the
1992 stack. Advance YYPTR to a properly aligned location for the next
1993 stack. */
1994# define YYSTACK_RELOCATE(Stack) \
1995 do \
1996 { \
1997 YYSIZE_T yynewbytes; \
1998 YYCOPY (&yyptr->Stack, Stack, yysize); \
1999 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00002000 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00002001 yyptr += yynewbytes / sizeof (*yyptr); \
2002 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00002003 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00002004
2005#endif
2006
Reid Spencerb7046c72007-01-29 05:41:34 +00002007#if defined (__STDC__) || defined (__cplusplus)
2008 typedef signed char yysigned_char;
2009#else
2010 typedef short int yysigned_char;
2011#endif
2012
2013/* YYFINAL -- State number of the termination state. */
Reid Spencer319a7302007-01-05 17:20:02 +00002014#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00002015/* YYLAST -- Last index in YYTABLE. */
Reid Spencer832254e2007-02-02 02:16:23 +00002016#define YYLAST 1736
Reid Spencer319a7302007-01-05 17:20:02 +00002017
Reid Spencerb7046c72007-01-29 05:41:34 +00002018/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002019#define YYNTOKENS 166
Reid Spencerb7046c72007-01-29 05:41:34 +00002020/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002021#define YYNNTS 79
Reid Spencerb7046c72007-01-29 05:41:34 +00002022/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00002023#define YYNRULES 308
Reid Spencerb7046c72007-01-29 05:41:34 +00002024/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00002025#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00002026
2027/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2028#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00002029#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00002030
Reid Spencer950bf602007-01-26 08:19:09 +00002031#define YYTRANSLATE(YYX) \
2032 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00002033
2034/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002035static const unsigned char yytranslate[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002036{
2037 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2038 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2039 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002041 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002042 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002043 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002044 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2045 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002046 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002049 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002050 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2051 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2052 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2053 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2057 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2058 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2059 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, 1, 2, 3, 4,
2063 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2064 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2065 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2066 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2067 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2068 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2069 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2070 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2071 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2072 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2073 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2074 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2075 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2076 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002077 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002078};
2079
2080#if YYDEBUG
2081/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2082 YYRHS. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002083static const unsigned short int yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002084{
2085 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2086 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2087 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2088 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2089 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2090 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2091 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2092 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2093 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002094 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002095 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2096 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2097 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2098 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2099 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002100 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2101 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2102 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2103 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2104 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2105 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2106 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2107 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2108 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2109 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2110 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2111 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2112 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2113 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2114 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2115 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002116};
2117
Reid Spencerb7046c72007-01-29 05:41:34 +00002118/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2119static const short int yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002120{
Reid Spencer950bf602007-01-26 08:19:09 +00002121 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002122 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2123 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
Reid Spencer832254e2007-02-02 02:16:23 +00002124 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2125 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
Reid Spencer950bf602007-01-26 08:19:09 +00002126 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2127 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2128 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2129 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2130 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
Reid Spencer832254e2007-02-02 02:16:23 +00002131 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
Reid Spencer950bf602007-01-26 08:19:09 +00002132 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2133 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2134 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2135 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2136 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2137 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2138 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2139 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2140 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2141 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2142 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2143 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002144 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002145 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2146 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2147 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2148 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2149 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2150 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2151 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2152 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2153 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2154 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2155 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2156 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2157 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2158 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2159 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
Reid Spencer832254e2007-02-02 02:16:23 +00002160 36, 191, 156, -1, 110, 155, 196, 242, 156, -1,
2161 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
Reid Spencer950bf602007-01-26 08:19:09 +00002162 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2163 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002164 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
Reid Spencer950bf602007-01-26 08:19:09 +00002165 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2166 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2167 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2168 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2169 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2170 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2171 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2172 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2173 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2174 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2175 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2176 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2177 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2178 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2179 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2180 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2181 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2182 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2183 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2184 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2185 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2186 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2187 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2188 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2189 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2190 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2191 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2192 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2193 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2194 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2195 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2196 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2197 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2198 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2199 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2200 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2201 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2202 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2203 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2204 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002205 103, 172, 191, 228, 153, 228, -1, 104, 173, 191,
Reid Spencer950bf602007-01-26 08:19:09 +00002206 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
Reid Spencer832254e2007-02-02 02:16:23 +00002207 229, -1, 175, 229, 36, 191, -1, 112, 229, 153,
Reid Spencer950bf602007-01-26 08:19:09 +00002208 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2209 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2210 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
Reid Spencer832254e2007-02-02 02:16:23 +00002211 -1, 116, 229, 153, 229, 153, 229, -1, 111, 237,
Reid Spencer950bf602007-01-26 08:19:09 +00002212 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
Reid Spencer832254e2007-02-02 02:16:23 +00002213 -1, 153, 238, -1, -1, 35, -1, -1, 105, 191,
2214 184, -1, 105, 191, 153, 15, 228, 184, -1, 106,
2215 191, 184, -1, 106, 191, 153, 15, 228, 184, -1,
2216 107, 229, -1, 243, 108, 191, 228, -1, 243, 109,
2217 229, 153, 191, 228, -1, 110, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002218};
2219
2220/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002221static const unsigned short int yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002222{
Reid Spenceref9b9a72007-02-05 20:47:22 +00002223 0, 1571, 1571, 1572, 1580, 1581, 1591, 1591, 1591, 1591,
2224 1591, 1591, 1591, 1591, 1591, 1591, 1591, 1595, 1595, 1595,
2225 1599, 1599, 1599, 1599, 1599, 1599, 1603, 1603, 1604, 1604,
2226 1605, 1605, 1606, 1606, 1607, 1607, 1611, 1611, 1612, 1612,
2227 1613, 1613, 1614, 1614, 1615, 1615, 1616, 1616, 1617, 1617,
2228 1618, 1619, 1622, 1622, 1622, 1622, 1626, 1626, 1626, 1626,
2229 1626, 1626, 1626, 1627, 1627, 1627, 1627, 1627, 1627, 1633,
2230 1633, 1633, 1633, 1637, 1637, 1637, 1637, 1641, 1641, 1645,
2231 1645, 1650, 1653, 1658, 1659, 1660, 1661, 1662, 1663, 1664,
2232 1665, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1686,
2233 1687, 1695, 1696, 1704, 1713, 1714, 1721, 1722, 1726, 1730,
2234 1746, 1747, 1754, 1755, 1762, 1770, 1770, 1770, 1770, 1770,
2235 1770, 1770, 1771, 1771, 1771, 1771, 1771, 1776, 1780, 1784,
2236 1789, 1798, 1818, 1824, 1837, 1846, 1850, 1861, 1865, 1878,
2237 1882, 1889, 1890, 1896, 1903, 1915, 1945, 1958, 1981, 2009,
2238 2031, 2042, 2064, 2075, 2084, 2089, 2147, 2154, 2162, 2169,
2239 2176, 2180, 2184, 2193, 2208, 2221, 2230, 2258, 2271, 2280,
2240 2286, 2292, 2303, 2309, 2315, 2326, 2327, 2336, 2337, 2349,
2241 2358, 2359, 2360, 2361, 2362, 2378, 2398, 2400, 2402, 2402,
2242 2409, 2409, 2416, 2416, 2423, 2423, 2431, 2433, 2435, 2440,
2243 2454, 2455, 2459, 2462, 2470, 2474, 2481, 2485, 2489, 2493,
Reid Spencer785a5ae2007-02-08 00:21:40 +00002244 2501, 2501, 2506, 2507, 2511, 2519, 2524, 2532, 2533, 2540,
2245 2547, 2551, 2711, 2711, 2715, 2725, 2725, 2729, 2733, 2735,
2246 2736, 2740, 2740, 2752, 2753, 2758, 2759, 2760, 2761, 2762,
2247 2763, 2764, 2765, 2766, 2787, 2790, 2805, 2806, 2811, 2811,
2248 2819, 2828, 2831, 2840, 2850, 2855, 2864, 2875, 2875, 2878,
2249 2881, 2884, 2888, 2894, 2909, 2915, 2971, 2974, 2980, 2990,
2250 3003, 3032, 3040, 3048, 3052, 3059, 3060, 3064, 3067, 3073,
2251 3090, 3106, 3120, 3132, 3144, 3155, 3173, 3182, 3191, 3198,
2252 3219, 3243, 3249, 3255, 3261, 3277, 3355, 3363, 3364, 3368,
2253 3369, 3373, 3379, 3385, 3391, 3397, 3404, 3416, 3430
Reid Spencer319a7302007-01-05 17:20:02 +00002254};
2255#endif
2256
Reid Spencer950bf602007-01-26 08:19:09 +00002257#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2258/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencerb7046c72007-01-29 05:41:34 +00002259 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer319a7302007-01-05 17:20:02 +00002260static const char *const yytname[] =
2261{
Reid Spencer950bf602007-01-26 08:19:09 +00002262 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2263 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2264 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2265 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2266 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2267 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2268 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2269 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2270 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2271 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2272 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2273 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2274 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2275 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
Reid Spencer832254e2007-02-02 02:16:23 +00002276 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2277 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2278 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2279 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
Reid Spencer950bf602007-01-26 08:19:09 +00002280 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2281 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2282 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2283 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2284 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2285 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2286 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2287 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2288 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2289 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2290 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2291 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2292 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2293 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2294 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2295 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2296 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2297 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2298 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2299 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2300 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002301 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002302};
2303#endif
2304
2305# ifdef YYPRINT
2306/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2307 token YYLEX-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002308static const unsigned short int yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002309{
2310 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2311 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2312 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2313 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2314 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2315 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2316 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2317 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2318 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2319 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2320 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2321 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2322 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2323 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2324 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002325 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2326 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002327};
2328# endif
2329
2330/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002331static const unsigned char yyr1[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002332{
Reid Spencer950bf602007-01-26 08:19:09 +00002333 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2334 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2335 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2336 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2337 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2338 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2339 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2340 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2341 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2342 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2343 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2344 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2345 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2346 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2347 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2348 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2349 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2350 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2351 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2352 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2353 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2354 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2355 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2356 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2357 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2358 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2359 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2360 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2361 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2362 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2363 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002364};
2365
2366/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002367static const unsigned char yyr2[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002368{
2369 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2370 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2371 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2372 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2373 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2374 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2375 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2376 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2377 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002378 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002379 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2381 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2382 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2383 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002384 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2385 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2386 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2387 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2388 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2389 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2390 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2391 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2392 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2393 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2394 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2395 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2396 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2397 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2398 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2399 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002400};
2401
2402/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2403 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2404 means the default is an error. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002405static const unsigned short int yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002406{
Reid Spencer950bf602007-01-26 08:19:09 +00002407 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2408 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2409 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2410 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2411 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2412 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2413 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2414 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2415 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2416 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2417 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2418 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2419 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2420 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
Reid Spencer832254e2007-02-02 02:16:23 +00002421 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2422 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002424 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2425 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2426 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2427 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2428 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2429 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2430 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2431 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2432 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2433 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2434 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2435 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002436 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002437 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2438 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002439 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002440 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2441 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2442 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2443 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2444 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2445 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2446 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2447 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2448 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2449 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2450 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2451 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2452 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2453 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2454 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2455 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2456 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2457 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2458 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2459 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2460 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2461 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2462 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2463 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2464 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2465 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2466 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2467 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002468};
2469
Reid Spencerb7046c72007-01-29 05:41:34 +00002470/* YYDEFGOTO[NTERM-NUM]. */
2471static const short int yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002472{
Reid Spencer950bf602007-01-26 08:19:09 +00002473 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2474 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2475 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2476 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2477 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2478 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2479 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2480 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002481};
2482
2483/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2484 STATE-NUM. */
Reid Spencer832254e2007-02-02 02:16:23 +00002485#define YYPACT_NINF -541
Reid Spencerb7046c72007-01-29 05:41:34 +00002486static const short int yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002487{
Reid Spencer832254e2007-02-02 02:16:23 +00002488 -541, 28, 61, 478, -541, -541, -541, -541, -541, -541,
2489 -541, -541, -541, -541, 23, 152, 45, -541, -541, -9,
2490 -541, -541, -20, -51, 76, 69, 12, -541, 97, 149,
2491 172, -541, -541, -541, -541, -541, -541, 1331, -19, -541,
2492 -541, 137, -541, -541, -541, -541, 49, 58, 60, 62,
2493 -541, 72, 149, 1331, 88, 88, 88, 88, -541, -541,
2494 -541, 152, -541, -541, -541, -541, -541, 75, -541, -541,
2495 -541, -541, -541, -541, -541, -541, -541, -541, -541, -541,
2496 -541, 227, 228, 3, 691, -541, 137, 79, -541, -541,
2497 -46, -541, -541, -541, -541, -541, 1585, -541, 212, 136,
2498 233, 214, 216, -541, -541, -541, -541, -541, 1392, 1392,
2499 1392, 1433, -541, -541, 83, 87, 711, -541, -541, -46,
2500 -70, 89, 777, -541, -541, 1392, -541, 183, 1453, 6,
2501 309, 152, -541, -541, -541, -541, -541, -541, -541, -541,
2502 -541, -541, -541, -541, -541, -541, -541, -541, -541, -541,
2503 -541, -541, -541, -541, -541, -541, -541, -541, -541, 59,
2504 142, 1392, 1392, 1392, 1392, 1392, 1392, 1392, 1392, 1392,
2505 1392, 1392, 1392, -541, -541, -541, -541, -541, -541, -541,
2506 -541, -541, -541, -541, -541, -541, 1392, 1392, 1392, 1392,
2507 1392, -541, -541, 152, -541, 86, -541, -541, -541, -541,
2508 -541, -541, -541, -541, -129, -541, -541, -541, 169, 196,
2509 242, 200, 246, 203, 252, 205, 253, 251, 258, 221,
2510 255, 259, 533, -541, 1392, 1392, 99, -63, 1392, -541,
2511 1173, -541, 128, 126, 894, -541, -541, 75, -541, 894,
2512 894, -541, -541, -541, -541, -541, -541, -541, -541, -541,
2513 -541, 894, 1331, -541, -541, -541, -541, -541, -541, -541,
2514 -541, -541, -541, 1392, -541, -541, -541, -541, -541, -541,
2515 -541, -541, -541, -541, -541, -541, -541, -541, -541, -541,
2516 1392, 130, 133, -541, 894, 132, 138, 139, 143, 144,
2517 151, 155, 156, 157, 894, 894, 894, 163, 254, 1331,
2518 1392, 1392, 271, -541, 164, 164, 164, -541, -541, -541,
2519 -541, -541, -541, -541, -541, -541, -541, 59, 142, 173,
2520 174, 175, 176, 177, 1214, 1494, 732, 281, 178, 179,
2521 180, 182, 190, -541, -541, 164, -42, -135, -541, 166,
2522 -46, -541, 137, -541, 193, 191, 1234, -541, -541, -541,
2523 -541, -541, -541, -541, -541, -541, 290, 1433, -541, -541,
2524 -541, -541, 201, -541, 202, 894, 894, 894, 7, -541,
2525 10, -541, 204, 894, 199, 1392, 1392, 1392, 1392, 1392,
2526 1392, 1392, 211, 215, 217, 1392, 1392, 894, 894, 223,
2527 -541, -21, -541, -541, -541, 210, 219, 1433, 1433, 1433,
2528 1433, 1433, -541, -541, 4, 752, -91, -541, -8, -541,
2529 1433, 1433, 1433, 1433, 1433, -541, -541, -541, -541, -541,
2530 -541, 1275, 324, -541, -541, 343, 37, 348, 356, 224,
2531 225, 229, 894, 376, 894, 1392, -541, 230, 894, 232,
2532 -541, -541, 234, 235, -541, -541, 894, 894, 894, -541,
2533 -541, 226, -541, 1392, 362, 385, -541, 164, 1433, 1433,
2534 204, 238, 239, 240, 241, 1433, -541, 243, -17, -5,
2535 -541, -541, 247, 250, 261, 262, 359, -541, -541, -541,
2536 339, 268, -541, 894, 894, 1392, 894, 894, 269, -541,
2537 269, -541, 270, 894, 272, 1392, 1392, 1392, -541, -541,
2538 -541, 1392, 894, -541, -541, -541, 273, 274, 249, 1433,
2539 1433, 1433, 1433, -541, -541, 245, 1433, 1433, 1433, 1433,
2540 1392, 395, -541, 383, 275, 267, 270, 279, -541, -541,
2541 351, -541, -541, 1392, 277, 894, -541, -541, -541, 282,
2542 -541, 1433, 1433, -541, 278, 283, 284, 288, -541, 289,
2543 291, 295, 296, 297, -541, -541, 423, 43, 410, -541,
2544 -541, 298, -541, 300, 305, 1433, -541, 1433, 1433, -541,
2545 -541, -541, -541, -541, 894, -541, 1020, 64, 441, -541,
2546 -541, -541, 307, 311, 314, -541, 312, -541, 1020, 894,
2547 -541, -541, -541, 450, 319, 150, 894, 452, 453, -541,
2548 894, 894, -541, -541
Reid Spencer319a7302007-01-05 17:20:02 +00002549};
2550
2551/* YYPGOTO[NTERM-NUM]. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002552static const short int yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002553{
Reid Spencer832254e2007-02-02 02:16:23 +00002554 -541, -541, -541, 379, 380, 381, 161, 162, 386, 388,
2555 -128, -127, -540, -541, 438, 456, -111, -541, -277, 63,
2556 -541, -297, -541, -47, -541, -37, -541, -53, 40, -541,
2557 -99, 264, -307, 84, -541, -541, -541, -541, -541, -541,
2558 -541, 435, -541, -541, -541, -541, 8, -541, 68, -541,
2559 -541, 427, -541, -541, -541, -541, -541, 487, -541, -541,
2560 -489, -199, 67, -124, -541, 472, -541, -103, -541, -541,
2561 -541, -541, 71, -7, -541, -541, 33, -541, -541
Reid Spencer319a7302007-01-05 17:20:02 +00002562};
2563
2564/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2565 positive, shift that token. If negative, reduce the rule which
2566 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002567 If YYTABLE_NINF, syntax error. */
2568#define YYTABLE_NINF -180
Reid Spencerb7046c72007-01-29 05:41:34 +00002569static const short int yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002570{
Reid Spencer832254e2007-02-02 02:16:23 +00002571 88, 235, 249, 250, 238, 371, 105, 115, 393, 394,
2572 93, 26, 223, 454, 39, 239, 88, 576, 406, 408,
2573 252, 42, 432, 334, 302, 434, 417, 240, 4, 123,
2574 303, 119, 46, 47, 48, 360, 455, 588, 415, 283,
2575 360, 360, 287, 288, 289, 290, 291, 292, 293, 26,
2576 426, 49, 360, 241, 242, 243, 244, 245, 246, 247,
2577 248, -179, 465, 119, 433, 297, 298, 433, 39, 119,
2578 470, 205, 206, 207, 241, 242, 243, 244, 245, 246,
2579 247, 248, 299, 228, 29, 360, 5, 586, 234, 53,
2580 228, 234, 6, 229, 121, 360, 360, 360, 469, 594,
2581 339, 51, 7, 8, 9, 10, 11, 12, 13, -112,
2582 7, 8, 9, 10, 54, 12, 55, 416, 123, 56,
2583 106, 107, 123, 14, 281, 282, 234, 284, 285, 234,
2584 234, 234, 234, 234, 234, 234, -139, 52, -112, 109,
2585 110, 111, 59, 94, 60, 465, -139, 123, 465, 294,
2586 295, 296, 234, 234, 43, 471, 227, 465, 515, 20,
2587 505, 21, 232, 466, 58, 116, 360, 360, 360, 264,
2588 265, 336, 337, 62, 360, 340, 64, 389, 253, 254,
2589 255, 256, 257, 258, 259, 260, 261, 262, 360, 360,
2590 465, 198, 199, 342, 300, 301, 307, 308, 482, -72,
2591 -72, 98, 575, -71, -71, 365, -70, -70, -69, -69,
2592 99, 531, 100, 532, 101, 88, 30, 31, 32, 33,
2593 34, 35, 36, 587, 309, 310, 366, 133, 134, 102,
2594 -113, 113, 114, 360, 122, 360, 197, 201, 202, 360,
2595 203, 224, 236, 367, 230, 225, -76, 360, 360, 360,
2596 -75, 439, 387, 441, 442, 443, -74, -73, -79, 312,
2597 338, 449, 88, 388, 234, -80, 313, 266, 267, 268,
2598 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
2599 279, 346, 347, 368, 360, 360, 370, 360, 360, 373,
2600 386, 374, 375, 340, 360, 390, 376, 377, 460, 461,
2601 462, 463, 464, 360, 378, 409, 362, 363, 379, 380,
2602 381, 472, 473, 474, 475, 476, 385, 391, 364, 241,
2603 242, 243, 244, 245, 246, 247, 248, 418, 397, 398,
2604 399, 400, 401, 410, 411, 412, 360, 413, 234, 440,
2605 234, 234, 234, 444, 445, 414, 421, 422, 234, 450,
2606 419, 372, 468, 424, 427, 428, 438, 435, 454, 506,
2607 507, 382, 383, 384, 446, 458, 513, 481, 447, 483,
2608 448, 536, 537, 538, 459, 360, 453, 484, 486, 485,
2609 489, 501, 487, 493, 342, 495, 503, 496, 497, 504,
2610 360, 509, 510, 511, 512, 520, 521, 360, 234, 554,
2611 516, 360, 360, 517, 514, 543, 548, 555, 433, 559,
2612 544, 545, 546, 547, 518, 519, 502, 549, 550, 551,
2613 552, 523, 530, 533, 557, 535, 541, 542, 556, 249,
2614 250, 565, 429, 430, 431, 558, 560, 567, 562, 566,
2615 437, 568, 563, 564, 574, 569, 578, 570, 234, 249,
2616 250, 571, 572, 573, 451, 452, 580, 579, 234, 234,
2617 234, 581, 589, 590, 234, 593, 582, 591, 583, 584,
2618 592, 596, 597, 600, 601, 186, 187, 188, 395, 96,
2619 396, 57, 189, 553, 190, 479, 333, 104, 112, 478,
2620 27, 45, 598, 508, 539, 0, 234, 0, -82, 488,
2621 20, 490, 21, 0, 0, 494, 492, 0, 0, 6,
2622 -82, -82, 0, 498, 499, 500, 0, 0, 0, -82,
2623 -82, -82, -82, -82, -82, -82, 0, 0, -82, 22,
2624 0, 0, 0, 0, 0, 0, 23, 0, 65, 66,
2625 24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2626 524, 525, 0, 528, 529, 20, 0, 21, 0, 314,
2627 534, 0, 0, 0, 0, 0, 0, 0, 0, 540,
2628 0, 315, 316, 0, 0, 0, 0, 0, 0, 0,
2629 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2630 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2631 0, 0, 561, 0, 0, 0, 0, 0, 0, 0,
2632 0, 0, 135, 136, 137, 138, 139, 140, 141, 142,
2633 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,
2634 153, 154, 155, 156, 157, 158, 317, 318, 0, 0,
2635 0, 585, 0, 319, 0, 320, 0, 321, 322, 323,
2636 0, 0, 0, 0, 0, 0, 595, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002637 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002638 0, 0, 173, 174, 175, 176, 177, 178, 179, 180,
2639 181, 182, 183, 184, 185, 0, 0, 0, 0, 0,
2640 324, 0, 0, 325, 0, 326, 65, 66, 327, 117,
Reid Spencer950bf602007-01-26 08:19:09 +00002641 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
Reid Spencer832254e2007-02-02 02:16:23 +00002642 78, 0, 79, 20, 0, 21, 65, 66, 0, 117,
2643 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2644 78, 0, 79, 20, 0, 21, 0, 65, 66, 80,
2645 117, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2646 217, 218, 0, 79, 20, 0, 21, 65, 66, 80,
2647 117, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2648 217, 218, 0, 79, 20, 0, 21, 0, 0, 0,
2649 80, 0, 65, 66, 0, 117, 68, 69, 70, 71,
2650 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2651 80, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2652 0, 0, 0, 0, 231, 0, 0, 0, 0, 0,
2653 0, 0, 0, 0, 0, 80, 0, 0, 0, 0,
Reid Spencerc4d96252007-01-13 00:03:30 +00002654 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002655 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2656 0, 83, 0, 84, 118, 0, 0, 0, 0, 0,
2657 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2658 0, 83, 0, 84, 226, 0, 0, 0, 0, 0,
2659 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
2660 0, 0, 83, 0, 84, 407, 0, 348, 349, 65,
2661 66, 350, 0, 0, 0, 0, 81, 0, 0, 82,
2662 0, 0, 83, 0, 84, 467, 20, 0, 21, 0,
2663 351, 352, 353, 0, 0, 0, 0, 0, 0, 0,
2664 0, 81, 354, 355, 82, 0, 0, 83, 0, 84,
Reid Spencer319a7302007-01-05 17:20:02 +00002665 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002666 0, 0, 0, 0, 0, 356, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002667 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002668 0, 0, 0, 135, 136, 137, 138, 139, 140, 141,
2669 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2670 152, 153, 154, 155, 156, 157, 158, 317, 318, 0,
2671 0, 0, 0, 0, 319, 0, 320, 0, 321, 322,
2672 323, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2673 0, 0, 0, 348, 349, 0, 0, 350, 0, 0,
2674 0, 0, 0, 173, 174, 175, 176, 177, 178, 179,
2675 180, 181, 182, 183, 184, 185, 351, 352, 353, 0,
2676 0, 0, 0, 0, 357, 0, 0, 0, 354, 355,
Reid Spencer950bf602007-01-26 08:19:09 +00002677 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002678 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002679 0, 356, 0, 0, 0, 0, 0, 0, 0, 0,
2680 0, 0, 0, 0, 0, 0, 0, 0, 0, 135,
2681 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2682 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
2683 156, 157, 158, 317, 318, 0, 0, 0, 0, 0,
2684 319, 0, 320, 0, 321, 322, 323, 0, 0, 0,
2685 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2686 0, 0, 0, 0, 0, 0, 0, 0, 0, 173,
2687 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2688 184, 185, 0, 0, 0, 0, 0, 0, 65, 66,
2689 357, 117, 68, 69, 70, 71, 72, 73, 74, 75,
2690 76, 77, 78, 0, 79, 20, 0, 21, 0, 0,
2691 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2692 341, 0, 0, 0, 0, 0, 0, 0, 0, 65,
2693 66, 80, 117, 208, 209, 210, 211, 212, 213, 214,
2694 215, 216, 217, 218, 0, 79, 20, 0, 21, 65,
2695 66, 0, 117, 68, 69, 70, 71, 72, 73, 74,
2696 75, 76, 77, 78, 0, 79, 20, 0, 21, 0,
2697 0, 0, 80, 0, 0, 0, 0, 0, 0, 0,
2698 0, 423, 0, 0, 0, 0, 0, 0, 0, 0,
2699 65, 66, 80, 117, 68, 69, 70, 71, 72, 73,
2700 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2701 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2702 0, 0, 477, 0, 0, 0, 0, 0, 0, 0,
2703 0, 0, 0, 80, 0, 0, 0, 81, 0, 0,
2704 82, 0, 0, 83, 0, 84, 65, 66, 0, 67,
Reid Spencer950bf602007-01-26 08:19:09 +00002705 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2706 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002707 0, 0, 0, 0, 0, 0, 0, 0, 81, 0,
2708 0, 82, 0, 402, 83, 0, 84, 0, 0, 80,
2709 0, 0, 0, 0, 0, 0, 0, 0, 81, 0,
2710 0, 82, 0, 0, 83, 0, 84, 65, 66, 0,
2711 117, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2712 77, 78, 0, 79, 20, 0, 21, 0, 0, 0,
2713 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2714 0, 0, 82, 0, 0, 83, 0, 84, 65, 66,
2715 80, 117, 208, 209, 210, 211, 212, 213, 214, 215,
2716 216, 217, 218, 0, 79, 20, 0, 21, 65, 66,
2717 0, 237, 68, 69, 70, 71, 72, 73, 74, 75,
2718 76, 77, 78, 0, 79, 20, 0, 21, 0, 0,
2719 0, 80, 0, 0, 0, 81, 0, 0, 82, 0,
2720 0, 83, 0, 84, 0, 0, 0, 0, 0, 65,
2721 66, 80, 117, 208, 209, 210, 211, 212, 213, 214,
2722 215, 216, 217, 218, 0, 79, 20, 0, 21, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002723 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2724 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002725 0, 0, 80, 0, 0, 0, 81, 0, 0, 82,
2726 0, 0, 83, 0, 84, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002727 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2728 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002729 0, 0, 0, 0, 0, 0, 0, 81, 0, 0,
2730 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2731 0, 0, 0, 0, 0, 0, 0, 81, 0, 0,
2732 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2733 124, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2734 0, 0, 0, 0, 125, 0, 0, 0, 0, 0,
2735 0, 0, 0, 0, 126, 127, 0, 0, 81, 0,
2736 0, 82, 0, 0, 83, 0, 405, 128, 129, 130,
2737 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
2738 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
2739 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
2740 161, 162, 163, 0, 0, 164, 165, 166, 167, 168,
2741 169, 170, 171, 172, 0, 0, 0, 0, 0, 0,
2742 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2743 0, 0, 0, 0, 173, 174, 175, 176, 177, 178,
2744 179, 180, 181, 182, 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002745};
2746
Reid Spencerb7046c72007-01-29 05:41:34 +00002747static const short int yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002748{
Reid Spencer832254e2007-02-02 02:16:23 +00002749 37, 125, 130, 130, 128, 282, 53, 4, 305, 306,
2750 29, 3, 111, 34, 23, 9, 53, 557, 325, 326,
2751 131, 30, 15, 222, 153, 15, 161, 21, 0, 164,
2752 159, 84, 52, 53, 54, 234, 57, 577, 335, 163,
2753 239, 240, 166, 167, 168, 169, 170, 171, 172, 41,
2754 357, 71, 251, 10, 11, 12, 13, 14, 15, 16,
2755 17, 0, 153, 116, 57, 189, 190, 57, 23, 122,
2756 161, 108, 109, 110, 10, 11, 12, 13, 14, 15,
2757 16, 17, 193, 153, 61, 284, 25, 576, 125, 20,
2758 153, 128, 31, 163, 86, 294, 295, 296, 405, 588,
2759 163, 152, 41, 42, 43, 44, 45, 46, 47, 155,
2760 41, 42, 43, 44, 45, 46, 47, 159, 164, 50,
2761 32, 33, 164, 62, 161, 162, 163, 164, 165, 166,
2762 167, 168, 169, 170, 171, 172, 153, 61, 155, 55,
2763 56, 57, 45, 162, 47, 153, 163, 164, 153, 186,
2764 187, 188, 189, 190, 163, 163, 116, 153, 163, 22,
2765 457, 24, 122, 159, 152, 162, 365, 366, 367, 27,
2766 28, 224, 225, 24, 373, 228, 4, 301, 119, 120,
2767 121, 122, 123, 124, 125, 126, 127, 128, 387, 388,
2768 153, 55, 56, 230, 108, 109, 27, 28, 161, 3,
2769 4, 152, 159, 3, 4, 252, 3, 4, 3, 4,
2770 152, 488, 152, 490, 152, 252, 64, 65, 66, 67,
2771 68, 69, 70, 159, 3, 4, 263, 77, 78, 157,
2772 155, 4, 4, 432, 155, 434, 24, 4, 24, 438,
2773 24, 158, 59, 280, 155, 158, 4, 446, 447, 448,
2774 4, 375, 299, 377, 378, 379, 4, 4, 7, 4,
2775 161, 385, 299, 300, 301, 7, 7, 125, 126, 127,
2776 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
2777 138, 153, 156, 153, 483, 484, 153, 486, 487, 157,
2778 36, 153, 153, 346, 493, 24, 153, 153, 397, 398,
2779 399, 400, 401, 502, 153, 24, 239, 240, 153, 153,
2780 153, 410, 411, 412, 413, 414, 153, 153, 251, 10,
2781 11, 12, 13, 14, 15, 16, 17, 161, 155, 155,
2782 155, 155, 155, 155, 155, 155, 535, 155, 375, 376,
2783 377, 378, 379, 380, 381, 155, 153, 156, 385, 386,
2784 342, 284, 405, 63, 153, 153, 157, 153, 34, 458,
2785 459, 294, 295, 296, 153, 155, 465, 24, 153, 21,
2786 153, 495, 496, 497, 155, 574, 153, 21, 153, 155,
2787 4, 155, 153, 153, 421, 153, 24, 153, 153, 4,
2788 589, 153, 153, 153, 153, 36, 57, 596, 435, 4,
2789 153, 600, 601, 153, 161, 156, 161, 24, 57, 533,
2790 509, 510, 511, 512, 153, 153, 453, 516, 517, 518,
2791 519, 153, 153, 153, 157, 153, 153, 153, 153, 557,
2792 557, 153, 365, 366, 367, 156, 159, 153, 156, 156,
2793 373, 153, 541, 542, 21, 156, 36, 156, 485, 577,
2794 577, 156, 156, 156, 387, 388, 156, 159, 495, 496,
2795 497, 156, 21, 156, 501, 153, 565, 156, 567, 568,
2796 156, 21, 153, 21, 21, 96, 96, 96, 317, 41,
2797 318, 25, 96, 520, 96, 422, 222, 52, 61, 421,
2798 3, 19, 595, 460, 501, -1, 533, -1, 20, 432,
2799 22, 434, 24, -1, -1, 438, 435, -1, -1, 31,
2800 32, 33, -1, 446, 447, 448, -1, -1, -1, 41,
2801 42, 43, 44, 45, 46, 47, -1, -1, 50, 51,
2802 -1, -1, -1, -1, -1, -1, 58, -1, 5, 6,
2803 62, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2804 483, 484, -1, 486, 487, 22, -1, 24, -1, 26,
2805 493, -1, -1, -1, -1, -1, -1, -1, -1, 502,
2806 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
2807 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2808 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2809 -1, -1, 535, -1, -1, -1, -1, -1, -1, -1,
2810 -1, -1, 79, 80, 81, 82, 83, 84, 85, 86,
2811 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
2812 97, 98, 99, 100, 101, 102, 103, 104, -1, -1,
2813 -1, 574, -1, 110, -1, 112, -1, 114, 115, 116,
2814 -1, -1, -1, -1, -1, -1, 589, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002815 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002816 -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
2817 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
2818 157, -1, -1, 160, -1, 162, 5, 6, 165, 8,
Reid Spencer950bf602007-01-26 08:19:09 +00002819 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Reid Spencer832254e2007-02-02 02:16:23 +00002820 19, -1, 21, 22, -1, 24, 5, 6, -1, 8,
2821 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2822 19, -1, 21, 22, -1, 24, -1, 5, 6, 48,
2823 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2824 18, 19, -1, 21, 22, -1, 24, 5, 6, 48,
2825 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2826 18, 19, -1, 21, 22, -1, 24, -1, -1, -1,
2827 48, -1, 5, 6, -1, 8, 9, 10, 11, 12,
2828 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2829 48, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2830 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
2831 -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002832 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002833 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2834 -1, 160, -1, 162, 163, -1, -1, -1, -1, -1,
2835 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2836 -1, 160, -1, 162, 163, -1, -1, -1, -1, -1,
2837 -1, -1, -1, -1, -1, -1, 154, -1, -1, 157,
2838 -1, -1, 160, -1, 162, 163, -1, 3, 4, 5,
2839 6, 7, -1, -1, -1, -1, 154, -1, -1, 157,
2840 -1, -1, 160, -1, 162, 163, 22, -1, 24, -1,
2841 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
2842 -1, 154, 38, 39, 157, -1, -1, 160, -1, 162,
Reid Spencer950bf602007-01-26 08:19:09 +00002843 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002844 -1, -1, -1, -1, -1, 61, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002845 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002846 -1, -1, -1, 79, 80, 81, 82, 83, 84, 85,
2847 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
2848 96, 97, 98, 99, 100, 101, 102, 103, 104, -1,
2849 -1, -1, -1, -1, 110, -1, 112, -1, 114, 115,
2850 116, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2851 -1, -1, -1, 3, 4, -1, -1, 7, -1, -1,
2852 -1, -1, -1, 139, 140, 141, 142, 143, 144, 145,
2853 146, 147, 148, 149, 150, 151, 26, 27, 28, -1,
2854 -1, -1, -1, -1, 160, -1, -1, -1, 38, 39,
Reid Spencer950bf602007-01-26 08:19:09 +00002855 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002856 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002857 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
2858 -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
2859 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2860 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
2861 100, 101, 102, 103, 104, -1, -1, -1, -1, -1,
2862 110, -1, 112, -1, 114, 115, 116, -1, -1, -1,
2863 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2864 -1, -1, -1, -1, -1, -1, -1, -1, -1, 139,
2865 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2866 150, 151, -1, -1, -1, -1, -1, -1, 5, 6,
2867 160, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2868 17, 18, 19, -1, 21, 22, -1, 24, -1, -1,
2869 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2870 37, -1, -1, -1, -1, -1, -1, -1, -1, 5,
2871 6, 48, 8, 9, 10, 11, 12, 13, 14, 15,
2872 16, 17, 18, 19, -1, 21, 22, -1, 24, 5,
2873 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
2874 16, 17, 18, 19, -1, 21, 22, -1, 24, -1,
2875 -1, -1, 48, -1, -1, -1, -1, -1, -1, -1,
2876 -1, 37, -1, -1, -1, -1, -1, -1, -1, -1,
2877 5, 6, 48, 8, 9, 10, 11, 12, 13, 14,
2878 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2879 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2880 -1, -1, 37, -1, -1, -1, -1, -1, -1, -1,
2881 -1, -1, -1, 48, -1, -1, -1, 154, -1, -1,
2882 157, -1, -1, 160, -1, 162, 5, 6, -1, 8,
Reid Spencer950bf602007-01-26 08:19:09 +00002883 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2884 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002885 -1, -1, -1, -1, -1, -1, -1, -1, 154, -1,
2886 -1, 157, -1, 159, 160, -1, 162, -1, -1, 48,
2887 -1, -1, -1, -1, -1, -1, -1, -1, 154, -1,
2888 -1, 157, -1, -1, 160, -1, 162, 5, 6, -1,
2889 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2890 18, 19, -1, 21, 22, -1, 24, -1, -1, -1,
2891 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2892 -1, -1, 157, -1, -1, 160, -1, 162, 5, 6,
2893 48, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2894 17, 18, 19, -1, 21, 22, -1, 24, 5, 6,
2895 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2896 17, 18, 19, -1, 21, 22, -1, 24, -1, -1,
2897 -1, 48, -1, -1, -1, 154, -1, -1, 157, -1,
2898 -1, 160, -1, 162, -1, -1, -1, -1, -1, 5,
2899 6, 48, 8, 9, 10, 11, 12, 13, 14, 15,
2900 16, 17, 18, 19, -1, 21, 22, -1, 24, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002901 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2902 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002903 -1, -1, 48, -1, -1, -1, 154, -1, -1, 157,
2904 -1, -1, 160, -1, 162, -1, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002905 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2906 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002907 -1, -1, -1, -1, -1, -1, -1, 154, -1, -1,
2908 157, -1, -1, 160, -1, 162, -1, -1, -1, -1,
2909 -1, -1, -1, -1, -1, -1, -1, 154, -1, -1,
2910 157, -1, -1, 160, -1, 162, -1, -1, -1, -1,
2911 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2912 -1, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2913 -1, -1, -1, -1, 59, 60, -1, -1, 154, -1,
2914 -1, 157, -1, -1, 160, -1, 162, 72, 73, 74,
2915 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2916 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2917 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2918 105, 106, 107, -1, -1, 110, 111, 112, 113, 114,
2919 115, 116, 117, 118, -1, -1, -1, -1, -1, -1,
2920 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2921 -1, -1, -1, -1, 139, 140, 141, 142, 143, 144,
2922 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002923};
2924
2925/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2926 symbol of state STATE-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002927static const unsigned char yystos[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002928{
Reid Spencer950bf602007-01-26 08:19:09 +00002929 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2930 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2931 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2932 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2933 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2934 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2935 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2936 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2937 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2938 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2939 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2940 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2941 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2942 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2943 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2944 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
Reid Spencer832254e2007-02-02 02:16:23 +00002945 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
Reid Spencer950bf602007-01-26 08:19:09 +00002946 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2947 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2948 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2949 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2950 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2951 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2952 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2953 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2954 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2955 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2956 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2957 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2958 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
Reid Spencer832254e2007-02-02 02:16:23 +00002959 108, 109, 153, 159, 205, 206, 204, 27, 28, 3,
2960 4, 168, 4, 7, 26, 38, 39, 103, 104, 110,
2961 112, 114, 115, 116, 157, 160, 162, 165, 169, 170,
Reid Spencer950bf602007-01-26 08:19:09 +00002962 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2963 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2964 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2965 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2966 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2967 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2968 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2969 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2970 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2971 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2972 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2973 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2974 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2975 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2976 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2977 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2978 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2979 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2980 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2981 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2982 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2983 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2984 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2985 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2986 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2987 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2988 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2989 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00002990};
Reid Spencere7c3c602006-11-30 06:36:44 +00002991
2992#define yyerrok (yyerrstatus = 0)
2993#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00002994#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00002995#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00002996
Reid Spencere7c3c602006-11-30 06:36:44 +00002997#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00002998#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00002999#define YYERROR goto yyerrorlab
3000
Reid Spencer319a7302007-01-05 17:20:02 +00003001
3002/* Like YYERROR except do call yyerror. This remains here temporarily
3003 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003004 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00003005
Reid Spencere7c3c602006-11-30 06:36:44 +00003006#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00003007
Reid Spencere7c3c602006-11-30 06:36:44 +00003008#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00003009
3010#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003011do \
3012 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00003013 { \
3014 yychar = (Token); \
3015 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00003016 yytoken = YYTRANSLATE (yychar); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003017 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003018 goto yybackup; \
3019 } \
3020 else \
Reid Spencer950bf602007-01-26 08:19:09 +00003021 { \
3022 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00003023 YYERROR; \
3024 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003025while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003026
Reid Spencer950bf602007-01-26 08:19:09 +00003027
Reid Spencere7c3c602006-11-30 06:36:44 +00003028#define YYTERROR 1
3029#define YYERRCODE 256
3030
Reid Spencer319a7302007-01-05 17:20:02 +00003031
Reid Spencer950bf602007-01-26 08:19:09 +00003032/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3033 If N is 0, then set CURRENT to the empty location which ends
3034 the previous symbol: RHS[0] (always defined). */
3035
3036#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00003037#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00003038# define YYLLOC_DEFAULT(Current, Rhs, N) \
3039 do \
Reid Spencerb7046c72007-01-29 05:41:34 +00003040 if (N) \
Reid Spencer950bf602007-01-26 08:19:09 +00003041 { \
3042 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3043 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3044 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3045 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3046 } \
3047 else \
3048 { \
3049 (Current).first_line = (Current).last_line = \
3050 YYRHSLOC (Rhs, 0).last_line; \
3051 (Current).first_column = (Current).last_column = \
3052 YYRHSLOC (Rhs, 0).last_column; \
3053 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003054 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003055#endif
3056
Reid Spencer950bf602007-01-26 08:19:09 +00003057
3058/* YY_LOCATION_PRINT -- Print the location on the stream.
3059 This macro was not mandated originally: define only if we know
3060 we won't break user code: when these are the locations we know. */
3061
3062#ifndef YY_LOCATION_PRINT
3063# if YYLTYPE_IS_TRIVIAL
3064# define YY_LOCATION_PRINT(File, Loc) \
3065 fprintf (File, "%d.%d-%d.%d", \
Reid Spencerb7046c72007-01-29 05:41:34 +00003066 (Loc).first_line, (Loc).first_column, \
3067 (Loc).last_line, (Loc).last_column)
Reid Spencer950bf602007-01-26 08:19:09 +00003068# else
3069# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3070# endif
3071#endif
3072
3073
Reid Spencer319a7302007-01-05 17:20:02 +00003074/* YYLEX -- calling `yylex' with the right arguments. */
3075
Reid Spencer950bf602007-01-26 08:19:09 +00003076#ifdef YYLEX_PARAM
3077# define YYLEX yylex (YYLEX_PARAM)
3078#else
3079# define YYLEX yylex ()
3080#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003081
3082/* Enable debugging if requested. */
3083#if YYDEBUG
3084
3085# ifndef YYFPRINTF
3086# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3087# define YYFPRINTF fprintf
3088# endif
3089
3090# define YYDPRINTF(Args) \
3091do { \
3092 if (yydebug) \
3093 YYFPRINTF Args; \
Reid Spencerb7046c72007-01-29 05:41:34 +00003094} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003095
Reid Spencerb7046c72007-01-29 05:41:34 +00003096# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3097do { \
3098 if (yydebug) \
3099 { \
3100 YYFPRINTF (stderr, "%s ", Title); \
3101 yysymprint (stderr, \
3102 Type, Value); \
3103 YYFPRINTF (stderr, "\n"); \
3104 } \
3105} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003106
3107/*------------------------------------------------------------------.
3108| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3109| TOP (included). |
3110`------------------------------------------------------------------*/
3111
Reid Spencerb7046c72007-01-29 05:41:34 +00003112#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003113static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003114yy_stack_print (short int *bottom, short int *top)
Reid Spencer950bf602007-01-26 08:19:09 +00003115#else
3116static void
3117yy_stack_print (bottom, top)
Reid Spencerb7046c72007-01-29 05:41:34 +00003118 short int *bottom;
3119 short int *top;
Reid Spencer950bf602007-01-26 08:19:09 +00003120#endif
3121{
3122 YYFPRINTF (stderr, "Stack now");
Reid Spencerb7046c72007-01-29 05:41:34 +00003123 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer950bf602007-01-26 08:19:09 +00003124 YYFPRINTF (stderr, " %d", *bottom);
3125 YYFPRINTF (stderr, "\n");
3126}
3127
3128# define YY_STACK_PRINT(Bottom, Top) \
3129do { \
3130 if (yydebug) \
3131 yy_stack_print ((Bottom), (Top)); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003132} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003133
3134
3135/*------------------------------------------------.
3136| Report that the YYRULE is going to be reduced. |
3137`------------------------------------------------*/
3138
Reid Spencerb7046c72007-01-29 05:41:34 +00003139#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003140static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003141yy_reduce_print (int yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003142#else
3143static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003144yy_reduce_print (yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003145 int yyrule;
3146#endif
3147{
3148 int yyi;
3149 unsigned long int yylno = yyrline[yyrule];
Reid Spencerb7046c72007-01-29 05:41:34 +00003150 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3151 yyrule - 1, yylno);
3152 /* Print the symbols being reduced, and their result. */
3153 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3154 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3155 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer950bf602007-01-26 08:19:09 +00003156}
3157
3158# define YY_REDUCE_PRINT(Rule) \
3159do { \
3160 if (yydebug) \
Reid Spencerb7046c72007-01-29 05:41:34 +00003161 yy_reduce_print (Rule); \
3162} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003163
Reid Spencer319a7302007-01-05 17:20:02 +00003164/* Nonzero means print parse trace. It is left uninitialized so that
3165 multiple parsers can coexist. */
3166int yydebug;
3167#else /* !YYDEBUG */
3168# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003169# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3170# define YY_STACK_PRINT(Bottom, Top)
3171# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003172#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003173
Reid Spencer950bf602007-01-26 08:19:09 +00003174
Reid Spencer319a7302007-01-05 17:20:02 +00003175/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003176#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003177# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003178#endif
3179
Reid Spencer319a7302007-01-05 17:20:02 +00003180/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3181 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003182
Reid Spencer319a7302007-01-05 17:20:02 +00003183 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003184 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003185 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003186
3187#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003188# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003189#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003190
Reid Spencere7c3c602006-11-30 06:36:44 +00003191
3192
Reid Spencer319a7302007-01-05 17:20:02 +00003193#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003194
Reid Spencer319a7302007-01-05 17:20:02 +00003195# ifndef yystrlen
Reid Spencerb7046c72007-01-29 05:41:34 +00003196# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer319a7302007-01-05 17:20:02 +00003197# define yystrlen strlen
3198# else
3199/* Return the length of YYSTR. */
3200static YYSIZE_T
Reid Spencerb7046c72007-01-29 05:41:34 +00003201# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003202yystrlen (const char *yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003203# else
Reid Spencer319a7302007-01-05 17:20:02 +00003204yystrlen (yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003205 const char *yystr;
3206# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003207{
Reid Spencerb7046c72007-01-29 05:41:34 +00003208 const char *yys = yystr;
3209
3210 while (*yys++ != '\0')
Reid Spencer319a7302007-01-05 17:20:02 +00003211 continue;
Reid Spencerb7046c72007-01-29 05:41:34 +00003212
3213 return yys - yystr - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003214}
Reid Spencer319a7302007-01-05 17:20:02 +00003215# endif
3216# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003217
Reid Spencer319a7302007-01-05 17:20:02 +00003218# ifndef yystpcpy
Reid Spencerb7046c72007-01-29 05:41:34 +00003219# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer319a7302007-01-05 17:20:02 +00003220# define yystpcpy stpcpy
3221# else
3222/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3223 YYDEST. */
3224static char *
Reid Spencerb7046c72007-01-29 05:41:34 +00003225# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003226yystpcpy (char *yydest, const char *yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003227# else
Reid Spencer319a7302007-01-05 17:20:02 +00003228yystpcpy (yydest, yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003229 char *yydest;
3230 const char *yysrc;
3231# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003232{
Reid Spencer950bf602007-01-26 08:19:09 +00003233 char *yyd = yydest;
3234 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003235
Reid Spencer319a7302007-01-05 17:20:02 +00003236 while ((*yyd++ = *yys++) != '\0')
3237 continue;
3238
3239 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003240}
Reid Spencer319a7302007-01-05 17:20:02 +00003241# endif
3242# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003243
Reid Spencer950bf602007-01-26 08:19:09 +00003244# ifndef yytnamerr
3245/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3246 quotes and backslashes, so that it's suitable for yyerror. The
3247 heuristic is that double-quoting is unnecessary unless the string
3248 contains an apostrophe, a comma, or backslash (other than
3249 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3250 null, do not copy; instead, return the length of what the result
3251 would have been. */
3252static YYSIZE_T
3253yytnamerr (char *yyres, const char *yystr)
3254{
3255 if (*yystr == '"')
3256 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003257 size_t yyn = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00003258 char const *yyp = yystr;
3259
3260 for (;;)
3261 switch (*++yyp)
3262 {
3263 case '\'':
3264 case ',':
3265 goto do_not_strip_quotes;
3266
3267 case '\\':
3268 if (*++yyp != '\\')
3269 goto do_not_strip_quotes;
3270 /* Fall through. */
3271 default:
3272 if (yyres)
3273 yyres[yyn] = *yyp;
3274 yyn++;
3275 break;
3276
3277 case '"':
3278 if (yyres)
3279 yyres[yyn] = '\0';
3280 return yyn;
3281 }
3282 do_not_strip_quotes: ;
3283 }
3284
3285 if (! yyres)
3286 return yystrlen (yystr);
3287
3288 return yystpcpy (yyres, yystr) - yyres;
3289}
3290# endif
3291
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003292#endif /* YYERROR_VERBOSE */
Reid Spencerb7046c72007-01-29 05:41:34 +00003293
Reid Spencere7c3c602006-11-30 06:36:44 +00003294
3295
Reid Spencerb7046c72007-01-29 05:41:34 +00003296#if YYDEBUG
3297/*--------------------------------.
3298| Print this symbol on YYOUTPUT. |
3299`--------------------------------*/
3300
3301#if defined (__STDC__) || defined (__cplusplus)
3302static void
3303yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
3304#else
3305static void
3306yysymprint (yyoutput, yytype, yyvaluep)
3307 FILE *yyoutput;
3308 int yytype;
3309 YYSTYPE *yyvaluep;
3310#endif
3311{
3312 /* Pacify ``unused variable'' warnings. */
3313 (void) yyvaluep;
3314
3315 if (yytype < YYNTOKENS)
3316 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3317 else
3318 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3319
3320
3321# ifdef YYPRINT
3322 if (yytype < YYNTOKENS)
3323 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3324# endif
3325 switch (yytype)
3326 {
3327 default:
3328 break;
3329 }
3330 YYFPRINTF (yyoutput, ")");
3331}
3332
3333#endif /* ! YYDEBUG */
Reid Spencer319a7302007-01-05 17:20:02 +00003334/*-----------------------------------------------.
3335| Release the memory associated to this symbol. |
3336`-----------------------------------------------*/
3337
Reid Spencerb7046c72007-01-29 05:41:34 +00003338#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003339static void
3340yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003341#else
Reid Spencer950bf602007-01-26 08:19:09 +00003342static void
3343yydestruct (yymsg, yytype, yyvaluep)
3344 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003345 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003346 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003347#endif
3348{
Reid Spencerb7046c72007-01-29 05:41:34 +00003349 /* Pacify ``unused variable'' warnings. */
3350 (void) yyvaluep;
Reid Spencer950bf602007-01-26 08:19:09 +00003351
3352 if (!yymsg)
3353 yymsg = "Deleting";
3354 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003355
3356 switch (yytype)
3357 {
Reid Spencer950bf602007-01-26 08:19:09 +00003358
Reid Spencer319a7302007-01-05 17:20:02 +00003359 default:
Reid Spencerb7046c72007-01-29 05:41:34 +00003360 break;
Reid Spencer319a7302007-01-05 17:20:02 +00003361 }
3362}
3363
3364
Reid Spencer950bf602007-01-26 08:19:09 +00003365/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003366
3367#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003368# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003369int yyparse (void *YYPARSE_PARAM);
Reid Spencerb7046c72007-01-29 05:41:34 +00003370# else
Reid Spencer950bf602007-01-26 08:19:09 +00003371int yyparse ();
Reid Spencerb7046c72007-01-29 05:41:34 +00003372# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003373#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003374#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003375int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003376#else
3377int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003378#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003379#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003380
3381
Reid Spencer950bf602007-01-26 08:19:09 +00003382
3383/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003384int yychar;
3385
Reid Spencer950bf602007-01-26 08:19:09 +00003386/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003387YYSTYPE yylval;
3388
Reid Spencer950bf602007-01-26 08:19:09 +00003389/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003390int yynerrs;
3391
3392
Reid Spencer950bf602007-01-26 08:19:09 +00003393
3394/*----------.
3395| yyparse. |
3396`----------*/
3397
3398#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003399# if defined (__STDC__) || defined (__cplusplus)
3400int yyparse (void *YYPARSE_PARAM)
3401# else
3402int yyparse (YYPARSE_PARAM)
3403 void *YYPARSE_PARAM;
3404# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003405#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003406#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003407int
Reid Spencer950bf602007-01-26 08:19:09 +00003408yyparse (void)
3409#else
3410int
3411yyparse ()
3412
3413#endif
3414#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003415{
3416
Reid Spencer950bf602007-01-26 08:19:09 +00003417 int yystate;
3418 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003419 int yyresult;
3420 /* Number of tokens to shift before error messages enabled. */
3421 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003422 /* Look-ahead token as an internal (translated) token number. */
3423 int yytoken = 0;
Reid Spencer319a7302007-01-05 17:20:02 +00003424
3425 /* Three stacks and their tools:
3426 `yyss': related to states,
3427 `yyvs': related to semantic values,
3428 `yyls': related to locations.
3429
3430 Refer to the stacks thru separate pointers, to allow yyoverflow
3431 to reallocate them elsewhere. */
3432
3433 /* The state stack. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003434 short int yyssa[YYINITDEPTH];
3435 short int *yyss = yyssa;
3436 short int *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003437
3438 /* The semantic value stack. */
3439 YYSTYPE yyvsa[YYINITDEPTH];
3440 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003441 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003442
3443
3444
Reid Spencerb7046c72007-01-29 05:41:34 +00003445#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003446
Reid Spencer319a7302007-01-05 17:20:02 +00003447 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003448
Reid Spencer319a7302007-01-05 17:20:02 +00003449 /* The variables used to return semantic value and location from the
3450 action routines. */
3451 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003452
3453
Reid Spencerb7046c72007-01-29 05:41:34 +00003454 /* When reducing, the number of symbols on the RHS of the reduced
3455 rule. */
3456 int yylen;
Reid Spencere7c3c602006-11-30 06:36:44 +00003457
Reid Spencer319a7302007-01-05 17:20:02 +00003458 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003459
3460 yystate = 0;
3461 yyerrstatus = 0;
3462 yynerrs = 0;
3463 yychar = YYEMPTY; /* Cause a token to be read. */
3464
3465 /* Initialize stack pointers.
3466 Waste one element of value and location stack
3467 so that they stay on the same level as the state stack.
3468 The wasted elements are never initialized. */
3469
Reid Spencer319a7302007-01-05 17:20:02 +00003470 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003471 yyvsp = yyvs;
3472
Reid Spencer319a7302007-01-05 17:20:02 +00003473 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003474
Reid Spencer319a7302007-01-05 17:20:02 +00003475/*------------------------------------------------------------.
3476| yynewstate -- Push a new state, which is found in yystate. |
3477`------------------------------------------------------------*/
3478 yynewstate:
3479 /* In all cases, when you get here, the value and location stacks
Reid Spencerb7046c72007-01-29 05:41:34 +00003480 have just been pushed. so pushing a state here evens the stacks.
3481 */
Reid Spencer319a7302007-01-05 17:20:02 +00003482 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003483
Reid Spencer319a7302007-01-05 17:20:02 +00003484 yysetstate:
3485 *yyssp = yystate;
3486
Reid Spencer950bf602007-01-26 08:19:09 +00003487 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003488 {
3489 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003490 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003491
3492#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003493 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003494 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer319a7302007-01-05 17:20:02 +00003495 these so that the &'s don't force the real ones into
3496 memory. */
3497 YYSTYPE *yyvs1 = yyvs;
Reid Spencerb7046c72007-01-29 05:41:34 +00003498 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003499
Reid Spencer319a7302007-01-05 17:20:02 +00003500
3501 /* Each stack pointer address is followed by the size of the
3502 data in use in that stack, in bytes. This used to be a
3503 conditional around just the two extra args, but that might
3504 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003505 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003506 &yyss1, yysize * sizeof (*yyssp),
3507 &yyvs1, yysize * sizeof (*yyvsp),
3508
3509 &yystacksize);
3510
3511 yyss = yyss1;
3512 yyvs = yyvs1;
3513 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003514#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003515# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003516 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003517# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003518 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003519 if (YYMAXDEPTH <= yystacksize)
3520 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003521 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003522 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003523 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003524
3525 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003526 short int *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003527 union yyalloc *yyptr =
3528 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3529 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003530 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003531 YYSTACK_RELOCATE (yyss);
3532 YYSTACK_RELOCATE (yyvs);
3533
3534# undef YYSTACK_RELOCATE
3535 if (yyss1 != yyssa)
3536 YYSTACK_FREE (yyss1);
3537 }
3538# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003539#endif /* no yyoverflow */
3540
Reid Spencer319a7302007-01-05 17:20:02 +00003541 yyssp = yyss + yysize - 1;
3542 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003543
3544
Reid Spencer319a7302007-01-05 17:20:02 +00003545 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3546 (unsigned long int) yystacksize));
3547
Reid Spencer950bf602007-01-26 08:19:09 +00003548 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003549 YYABORT;
3550 }
3551
Reid Spencer319a7302007-01-05 17:20:02 +00003552 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003553
3554 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003555
3556/*-----------.
3557| yybackup. |
3558`-----------*/
3559yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003560
Reid Spencerb7046c72007-01-29 05:41:34 +00003561/* Do appropriate processing given the current state. */
3562/* Read a look-ahead token if we need one and don't already have one. */
3563/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003564
Reid Spencer950bf602007-01-26 08:19:09 +00003565 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003566
Reid Spencere7c3c602006-11-30 06:36:44 +00003567 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003568 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003569 goto yydefault;
3570
Reid Spencer950bf602007-01-26 08:19:09 +00003571 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003572
Reid Spencer950bf602007-01-26 08:19:09 +00003573 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003574 if (yychar == YYEMPTY)
3575 {
Reid Spencer319a7302007-01-05 17:20:02 +00003576 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003577 yychar = YYLEX;
3578 }
3579
Reid Spencer950bf602007-01-26 08:19:09 +00003580 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003581 {
Reid Spencer950bf602007-01-26 08:19:09 +00003582 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003583 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003584 }
3585 else
3586 {
Reid Spencer950bf602007-01-26 08:19:09 +00003587 yytoken = YYTRANSLATE (yychar);
3588 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003589 }
3590
Reid Spencer950bf602007-01-26 08:19:09 +00003591 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003592 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003593 yyn += yytoken;
3594 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003595 goto yydefault;
3596 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003597 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003598 {
Reid Spencer319a7302007-01-05 17:20:02 +00003599 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003600 goto yyerrlab;
3601 yyn = -yyn;
3602 goto yyreduce;
3603 }
3604
3605 if (yyn == YYFINAL)
3606 YYACCEPT;
3607
Reid Spencerb7046c72007-01-29 05:41:34 +00003608 /* Shift the look-ahead token. */
3609 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3610
3611 /* Discard the token being shifted unless it is eof. */
3612 if (yychar != YYEOF)
3613 yychar = YYEMPTY;
3614
3615 *++yyvsp = yylval;
3616
3617
Reid Spencer319a7302007-01-05 17:20:02 +00003618 /* Count tokens shifted since error; after three, turn off error
3619 status. */
3620 if (yyerrstatus)
3621 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003622
3623 yystate = yyn;
3624 goto yynewstate;
3625
Chris Lattner37e01c52007-01-04 18:46:42 +00003626
Reid Spencer319a7302007-01-05 17:20:02 +00003627/*-----------------------------------------------------------.
3628| yydefault -- do the default action for the current state. |
3629`-----------------------------------------------------------*/
3630yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003631 yyn = yydefact[yystate];
3632 if (yyn == 0)
3633 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003634 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003635
Reid Spencer319a7302007-01-05 17:20:02 +00003636
3637/*-----------------------------.
3638| yyreduce -- Do a reduction. |
3639`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003640yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003641 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003642 yylen = yyr2[yyn];
3643
Reid Spencer319a7302007-01-05 17:20:02 +00003644 /* If YYLEN is nonzero, implement the default value of the action:
3645 `$$ = $1'.
3646
3647 Otherwise, the following line sets YYVAL to garbage.
3648 This behavior is undocumented and Bison
3649 users should not rely upon it. Assigning to YYVAL
3650 unconditionally makes the parser a bit smaller, and it avoids a
3651 GCC warning that YYVAL may be used uninitialized. */
3652 yyval = yyvsp[1-yylen];
3653
3654
Reid Spencer950bf602007-01-26 08:19:09 +00003655 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003656 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003657 {
Reid Spencer950bf602007-01-26 08:19:09 +00003658 case 3:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003659#line 1572 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003660 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003661 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003662 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003663 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003664 ;}
3665 break;
3666
3667 case 5:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003668#line 1581 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003669 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003670 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003671 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003672 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003673 ;}
3674 break;
3675
3676 case 26:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003677#line 1603 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003678 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3679 break;
3680
3681 case 27:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003682#line 1603 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003683 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3684 break;
3685
3686 case 28:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003687#line 1604 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003688 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3689 break;
3690
3691 case 29:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003692#line 1604 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003693 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3694 break;
3695
3696 case 30:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003697#line 1605 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003698 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3699 break;
3700
3701 case 31:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003702#line 1605 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003703 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3704 break;
3705
3706 case 32:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003707#line 1606 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003708 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3709 break;
3710
3711 case 33:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003712#line 1606 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003713 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3714 break;
3715
3716 case 34:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003717#line 1607 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003718 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3719 break;
3720
3721 case 35:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003722#line 1607 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003723 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3724 break;
3725
3726 case 36:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003727#line 1611 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003728 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3729 break;
3730
3731 case 37:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003732#line 1611 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003733 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3734 break;
3735
3736 case 38:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003737#line 1612 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003738 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3739 break;
3740
3741 case 39:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003742#line 1612 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003743 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3744 break;
3745
3746 case 40:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003747#line 1613 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003748 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3749 break;
3750
3751 case 41:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003752#line 1613 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003753 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3754 break;
3755
3756 case 42:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003757#line 1614 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003758 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3759 break;
3760
3761 case 43:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003762#line 1614 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003763 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3764 break;
3765
3766 case 44:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003767#line 1615 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003768 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3769 break;
3770
3771 case 45:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003772#line 1615 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003773 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3774 break;
3775
3776 case 46:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003777#line 1616 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003778 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3779 break;
3780
3781 case 47:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003782#line 1616 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003783 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3784 break;
3785
3786 case 48:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003787#line 1617 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003788 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3789 break;
3790
3791 case 49:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003792#line 1617 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003793 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3794 break;
3795
3796 case 50:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003797#line 1618 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003798 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3799 break;
3800
3801 case 51:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003802#line 1619 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003803 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3804 break;
3805
3806 case 81:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003807#line 1650 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003808 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003809 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003810 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003811 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003812
Reid Spencer319a7302007-01-05 17:20:02 +00003813 case 82:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003814#line 1653 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003815 {
Reid Spencer950bf602007-01-26 08:19:09 +00003816 (yyval.StrVal) = 0;
3817 ;}
3818 break;
3819
3820 case 83:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003821#line 1658 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003822 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3823 break;
3824
3825 case 84:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003826#line 1659 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003827 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3828 break;
3829
3830 case 85:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003831#line 1660 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003832 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3833 break;
3834
3835 case 86:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003836#line 1661 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003837 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3838 break;
3839
3840 case 87:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003841#line 1662 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003842 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3843 break;
3844
3845 case 88:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003846#line 1663 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003847 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3848 break;
3849
3850 case 89:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003851#line 1664 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003852 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003853 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003854
Reid Spencer319a7302007-01-05 17:20:02 +00003855 case 90:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003856#line 1665 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003857 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3858 break;
3859
3860 case 91:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003861#line 1669 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003862 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003863 break;
3864
3865 case 92:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003866#line 1670 "/proj/llvm/llvm-3/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 93:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003871#line 1671 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003872 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::CSRet; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003873 break;
3874
3875 case 94:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003876#line 1672 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003877 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::Fast; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003878 break;
3879
3880 case 95:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003881#line 1673 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003882 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::Cold; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003883 break;
3884
3885 case 96:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003886#line 1674 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003887 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003888 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00003889
Reid Spencer319a7302007-01-05 17:20:02 +00003890 case 97:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003891#line 1675 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003892 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003893 break;
Reid Spencer16244f42006-12-01 21:10:07 +00003894
Reid Spencer319a7302007-01-05 17:20:02 +00003895 case 98:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003896#line 1676 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003897 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003898 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00003899 error("Calling conv too large");
Reid Spencerb7046c72007-01-29 05:41:34 +00003900 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003901 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003902 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003903
Reid Spencer319a7302007-01-05 17:20:02 +00003904 case 99:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003905#line 1686 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003906 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003907 break;
3908
Reid Spencerc4d96252007-01-13 00:03:30 +00003909 case 100:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003910#line 1687 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003911 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003912 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003913 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3914 error("Alignment must be a power of two");
3915 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003916 break;
3917
3918 case 101:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003919#line 1695 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003920 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003921 break;
3922
3923 case 102:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003924#line 1696 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003925 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003926 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003927 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3928 error("Alignment must be a power of two");
3929 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003930 break;
3931
3932 case 103:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003933#line 1704 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003934 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003935 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3936 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00003937 error("Invalid character in section name");
Reid Spencerb7046c72007-01-29 05:41:34 +00003938 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003939 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003940 break;
3941
3942 case 104:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003943#line 1713 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003944 { (yyval.StrVal) = 0; ;}
3945 break;
3946
3947 case 105:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003948#line 1714 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003949 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003950 break;
3951
Reid Spencerc4d96252007-01-13 00:03:30 +00003952 case 106:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003953#line 1721 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003954 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003955 break;
3956
Reid Spencer319a7302007-01-05 17:20:02 +00003957 case 107:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003958#line 1722 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003959 {;}
3960 break;
3961
3962 case 108:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003963#line 1726 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003964 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003965 CurGV->setSection((yyvsp[0].StrVal));
3966 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00003967 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003968 break;
3969
3970 case 109:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003971#line 1730 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003972 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003973 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00003974 error("Alignment must be a power of two");
Reid Spencerb7046c72007-01-29 05:41:34 +00003975 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00003976
3977 ;}
3978 break;
3979
3980 case 111:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003981#line 1747 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003982 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003983 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00003984 (yyval.TypeVal).S = Signless;
3985 ;}
3986 break;
3987
3988 case 113:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003989#line 1755 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003990 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003991 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00003992 (yyval.TypeVal).S = Signless;
3993 ;}
3994 break;
3995
3996 case 114:
Reid Spenceref9b9a72007-02-05 20:47:22 +00003997#line 1762 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003998 {
3999 if (!UpRefs.empty())
Reid Spencerb7046c72007-01-29 05:41:34 +00004000 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).T)->getDescription());
4001 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004002 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004003 break;
4004
4005 case 127:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004006#line 1776 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004007 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004008 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
4009 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004010 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004011 break;
4012
4013 case 128:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004014#line 1780 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004015 {
4016 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4017 (yyval.TypeVal).S = Signless;
4018 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004019 break;
4020
4021 case 129:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004022#line 1784 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004023 { // Named types are also simple types...
Reid Spencerb7046c72007-01-29 05:41:34 +00004024 const Type* tmp = getType((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004025 (yyval.TypeVal).T = new PATypeHolder(tmp);
4026 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4027 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004028 break;
4029
4030 case 130:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004031#line 1789 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004032 { // Type UpReference
Reid Spencerb7046c72007-01-29 05:41:34 +00004033 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004034 error("Value out of range");
4035 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencerb7046c72007-01-29 05:41:34 +00004036 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Reid Spencer950bf602007-01-26 08:19:09 +00004037 (yyval.TypeVal).T = new PATypeHolder(OT);
4038 (yyval.TypeVal).S = Signless;
4039 UR_OUT("New Upreference!\n");
4040 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004041 break;
4042
4043 case 131:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004044#line 1798 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004045 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004046 std::vector<const Type*> Params;
Reid Spencerb7046c72007-01-29 05:41:34 +00004047 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4048 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004049 Params.push_back(I->T->get());
Reid Spencer52402b02007-01-02 05:45:11 +00004050 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004051 FunctionType::ParamAttrsList ParamAttrs;
4052 if (CurFun.LastCC == OldCallingConv::CSRet) {
4053 ParamAttrs.push_back(FunctionType::NoAttributeSet);
4054 ParamAttrs.push_back(FunctionType::StructRetAttribute);
4055 }
Reid Spencer950bf602007-01-26 08:19:09 +00004056 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4057 if (isVarArg) Params.pop_back();
4058
Reid Spencerb7046c72007-01-29 05:41:34 +00004059 (yyval.TypeVal).T = new PATypeHolder(
4060 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).T->get(),Params,isVarArg, ParamAttrs)));
4061 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
4062 delete (yyvsp[-3].TypeVal).T; // Delete the return type handle
4063 delete (yyvsp[-1].TypeList); // Delete the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00004064 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004065 break;
4066
4067 case 132:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004068#line 1818 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004069 { // Sized array type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004070 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).T->get(),
4071 (unsigned)(yyvsp[-3].UInt64Val))));
4072 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4073 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004074 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004075 break;
4076
4077 case 133:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004078#line 1824 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004079 { // Packed array type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004080 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).T->get();
4081 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004082 error("Unsigned result not equal to signed result");
4083 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4084 error("Elements of a PackedType must be integer or floating point");
Reid Spencerb7046c72007-01-29 05:41:34 +00004085 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004086 error("PackedType length should be a power of 2");
4087 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
Reid Spencerb7046c72007-01-29 05:41:34 +00004088 (unsigned)(yyvsp[-3].UInt64Val))));
4089 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4090 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004091 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004092 break;
4093
4094 case 134:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004095#line 1837 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004096 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004097 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004098 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4099 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer950bf602007-01-26 08:19:09 +00004100 Elements.push_back(I->T->get());
4101 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4102 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004103 delete (yyvsp[-1].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004104 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004105 break;
4106
4107 case 135:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004108#line 1846 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004109 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004110 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4111 (yyval.TypeVal).S = Signless;
4112 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004113 break;
4114
4115 case 136:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004116#line 1850 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004117 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004118 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004119 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4120 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004121 Elements.push_back(I->T->get());
4122 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004123 }
Reid Spencer950bf602007-01-26 08:19:09 +00004124 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4125 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004126 delete (yyvsp[-2].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004127 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004128 break;
4129
4130 case 137:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004131#line 1861 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004132 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004133 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4134 (yyval.TypeVal).S = Signless;
4135 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004136 break;
4137
4138 case 138:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004139#line 1865 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004140 { // Pointer type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004141 if ((yyvsp[-1].TypeVal).T->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004142 error("Cannot form a pointer to a basic block");
Reid Spencerb7046c72007-01-29 05:41:34 +00004143 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).T->get())));
4144 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4145 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004146 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004147 break;
4148
4149 case 139:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004150#line 1878 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004151 {
Reid Spencer950bf602007-01-26 08:19:09 +00004152 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004153 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004154 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004155 break;
4156
4157 case 140:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004158#line 1882 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004159 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004160 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004161 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004162 break;
4163
4164 case 142:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004165#line 1890 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004166 {
Reid Spencer950bf602007-01-26 08:19:09 +00004167 PATypeInfo VoidTI;
4168 VoidTI.T = new PATypeHolder(Type::VoidTy);
4169 VoidTI.S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004170 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
Reid Spencer950bf602007-01-26 08:19:09 +00004171 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004172 break;
4173
4174 case 143:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004175#line 1896 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004176 {
Reid Spencer950bf602007-01-26 08:19:09 +00004177 (yyval.TypeList) = new std::list<PATypeInfo>();
4178 PATypeInfo VoidTI;
4179 VoidTI.T = new PATypeHolder(Type::VoidTy);
4180 VoidTI.S = Signless;
4181 (yyval.TypeList)->push_back(VoidTI);
4182 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004183 break;
4184
4185 case 144:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004186#line 1903 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004187 {
Reid Spencer950bf602007-01-26 08:19:09 +00004188 (yyval.TypeList) = new std::list<PATypeInfo>();
4189 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004190 break;
4191
4192 case 145:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004193#line 1915 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004194 { // Nonempty unsized arr
Reid Spencerb7046c72007-01-29 05:41:34 +00004195 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004196 if (ATy == 0)
4197 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004198 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004199 const Type *ETy = ATy->getElementType();
4200 int NumElements = ATy->getNumElements();
4201
4202 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004203 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004204 error("Type mismatch: constant sized array initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004205 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004206 itostr(NumElements) + "");
4207
4208 // Verify all elements are correct type!
4209 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004210 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4211 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004212 const Type* ValTy = C->getType();
4213 if (ETy != ValTy)
4214 error("Element #" + utostr(i) + " is not of type '" +
4215 ETy->getDescription() +"' as required!\nIt is of type '"+
4216 ValTy->getDescription() + "'");
4217 Elems.push_back(C);
4218 }
4219 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004220 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4221 delete (yyvsp[-3].TypeVal).T;
4222 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004223 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004224 break;
4225
4226 case 146:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004227#line 1945 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004228 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004229 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004230 if (ATy == 0)
4231 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004232 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004233 int NumElements = ATy->getNumElements();
4234 if (NumElements != -1 && NumElements != 0)
4235 error("Type mismatch: constant sized array initialized with 0"
4236 " arguments, but has size of " + itostr(NumElements) +"");
4237 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004238 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4239 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004240 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004241 break;
4242
4243 case 147:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004244#line 1958 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004245 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004246 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004247 if (ATy == 0)
4248 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004249 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004250 int NumElements = ATy->getNumElements();
4251 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4252 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4253 error("String arrays require type i8, not '" + ETy->getDescription() +
4254 "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004255 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4256 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004257 error("Can't build string constant of size " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004258 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004259 itostr(NumElements) + "");
4260 std::vector<Constant*> Vals;
Reid Spencerb7046c72007-01-29 05:41:34 +00004261 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004262 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencerb7046c72007-01-29 05:41:34 +00004263 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004264 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerb7046c72007-01-29 05:41:34 +00004265 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4266 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004267 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004268 break;
4269
4270 case 148:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004271#line 1981 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004272 { // Nonempty unsized arr
Reid Spencerb7046c72007-01-29 05:41:34 +00004273 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004274 if (PTy == 0)
4275 error("Cannot make packed constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004276 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004277 const Type *ETy = PTy->getElementType();
4278 int NumElements = PTy->getNumElements();
4279 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004280 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004281 error("Type mismatch: constant sized packed initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004282 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004283 itostr(NumElements) + "");
4284 // Verify all elements are correct type!
4285 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004286 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4287 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004288 const Type* ValTy = C->getType();
4289 if (ETy != ValTy)
4290 error("Element #" + utostr(i) + " is not of type '" +
4291 ETy->getDescription() +"' as required!\nIt is of type '"+
4292 ValTy->getDescription() + "'");
4293 Elems.push_back(C);
4294 }
4295 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004296 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4297 delete (yyvsp[-3].TypeVal).T;
4298 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004299 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004300 break;
4301
4302 case 149:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004303#line 2009 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004304 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004305 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004306 if (STy == 0)
4307 error("Cannot make struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004308 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4309 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004310 error("Illegal number of initializers for structure type");
4311
4312 // Check to ensure that constants are compatible with the type initializer!
4313 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004314 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4315 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004316 if (C->getType() != STy->getElementType(i))
4317 error("Expected type '" + STy->getElementType(i)->getDescription() +
4318 "' for element #" + utostr(i) + " of structure initializer");
4319 Fields.push_back(C);
4320 }
4321 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004322 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4323 delete (yyvsp[-3].TypeVal).T;
4324 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004325 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004326 break;
4327
4328 case 150:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004329#line 2031 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004330 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004331 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004332 if (STy == 0)
4333 error("Cannot make struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004334 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004335 if (STy->getNumContainedTypes() != 0)
4336 error("Illegal number of initializers for structure type");
4337 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004338 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4339 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004340 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004341 break;
4342
4343 case 151:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004344#line 2042 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004345 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004346 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004347 if (STy == 0)
4348 error("Cannot make packed struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004349 (yyvsp[-5].TypeVal).T->get()->getDescription() + "'");
4350 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004351 error("Illegal number of initializers for packed structure type");
4352
4353 // Check to ensure that constants are compatible with the type initializer!
4354 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004355 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4356 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004357 if (C->getType() != STy->getElementType(i))
4358 error("Expected type '" + STy->getElementType(i)->getDescription() +
4359 "' for element #" + utostr(i) + " of packed struct initializer");
4360 Fields.push_back(C);
4361 }
4362 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004363 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4364 delete (yyvsp[-5].TypeVal).T;
4365 delete (yyvsp[-2].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004366 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004367 break;
4368
4369 case 152:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004370#line 2064 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004371 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004372 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004373 if (STy == 0)
4374 error("Cannot make packed struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004375 (yyvsp[-4].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004376 if (STy->getNumContainedTypes() != 0)
4377 error("Illegal number of initializers for packed structure type");
4378 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004379 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4380 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004381 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004382 break;
4383
4384 case 153:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004385#line 2075 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004386 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004387 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004388 if (PTy == 0)
4389 error("Cannot make null pointer constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004390 (yyvsp[-1].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004391 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00004392 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4393 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004394 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004395 break;
4396
4397 case 154:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004398#line 2084 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004399 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004400 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).T->get());
4401 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4402 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004403 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004404 break;
4405
4406 case 155:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004407#line 2089 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004408 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004409 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004410 if (Ty == 0)
4411 error("Global const reference must be a pointer type, not" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004412 (yyvsp[-1].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004413
4414 // ConstExprs can exist in the body of a function, thus creating
4415 // GlobalValues whenever they refer to a variable. Because we are in
4416 // the context of a function, getExistingValue will search the functions
4417 // symbol table instead of the module symbol table for the global symbol,
4418 // which throws things all off. To get around this, we just tell
4419 // getExistingValue that we are at global scope here.
4420 //
4421 Function *SavedCurFn = CurFun.CurrentFunction;
4422 CurFun.CurrentFunction = 0;
Reid Spencerb7046c72007-01-29 05:41:34 +00004423 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004424 CurFun.CurrentFunction = SavedCurFn;
4425
4426 // If this is an initializer for a constant pointer, which is referencing a
4427 // (currently) undefined variable, create a stub now that shall be replaced
4428 // in the future with the right type of variable.
4429 //
4430 if (V == 0) {
4431 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4432 const PointerType *PT = cast<PointerType>(Ty);
4433
4434 // First check to see if the forward references value is already created!
4435 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencerb7046c72007-01-29 05:41:34 +00004436 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004437
4438 if (I != CurModule.GlobalRefs.end()) {
4439 V = I->second; // Placeholder already exists, use it...
Reid Spencerb7046c72007-01-29 05:41:34 +00004440 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004441 } else {
4442 std::string Name;
Reid Spencerb7046c72007-01-29 05:41:34 +00004443 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004444
4445 // Create the forward referenced global.
4446 GlobalValue *GV;
4447 if (const FunctionType *FTy =
4448 dyn_cast<FunctionType>(PT->getElementType())) {
4449 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4450 CurModule.CurrentModule);
4451 } else {
4452 GV = new GlobalVariable(PT->getElementType(), false,
4453 GlobalValue::ExternalLinkage, 0,
4454 Name, CurModule.CurrentModule);
4455 }
4456
4457 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencerb7046c72007-01-29 05:41:34 +00004458 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004459 V = GV;
4460 }
4461 }
4462 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerb7046c72007-01-29 05:41:34 +00004463 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4464 delete (yyvsp[-1].TypeVal).T; // Free the type handle
Reid Spencer950bf602007-01-26 08:19:09 +00004465 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004466 break;
4467
4468 case 156:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004469#line 2147 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004470 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004471 if ((yyvsp[-1].TypeVal).T->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004472 error("Mismatched types for constant expression");
Reid Spencerb7046c72007-01-29 05:41:34 +00004473 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4474 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4475 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004476 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004477 break;
4478
4479 case 157:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004480#line 2154 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004481 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004482 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004483 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4484 error("Cannot create a null initialized value of this type");
4485 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00004486 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4487 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004488 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004489 break;
4490
4491 case 158:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004492#line 2162 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004493 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004494 const Type *Ty = (yyvsp[-1].PrimType).T;
4495 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004496 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004497 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004498 (yyval.ConstVal).S = Signed;
4499 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004500 break;
4501
4502 case 159:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004503#line 2169 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004504 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004505 const Type *Ty = (yyvsp[-1].PrimType).T;
4506 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004507 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004508 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004509 (yyval.ConstVal).S = Unsigned;
4510 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004511 break;
4512
4513 case 160:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004514#line 2176 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004515 { // Boolean constants
4516 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4517 (yyval.ConstVal).S = Unsigned;
4518 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004519 break;
4520
4521 case 161:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004522#line 2180 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004523 { // Boolean constants
4524 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4525 (yyval.ConstVal).S = Unsigned;
4526 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004527 break;
4528
4529 case 162:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004530#line 2184 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004531 { // Float & Double constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004532 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004533 error("Floating point constant invalid for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004534 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004535 (yyval.ConstVal).S = Signless;
4536 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004537 break;
4538
4539 case 163:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004540#line 2193 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004541 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004542 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4543 const Type* DstTy = (yyvsp[-1].TypeVal).T->get();
4544 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4545 Signedness DstSign = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004546 if (!SrcTy->isFirstClassType())
4547 error("cast constant expression from a non-primitive type: '" +
4548 SrcTy->getDescription() + "'");
4549 if (!DstTy->isFirstClassType())
4550 error("cast constant expression to a non-primitive type: '" +
4551 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004552 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencer950bf602007-01-26 08:19:09 +00004553 (yyval.ConstVal).S = DstSign;
Reid Spencerb7046c72007-01-29 05:41:34 +00004554 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004555 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004556 break;
4557
4558 case 164:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004559#line 2208 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004560 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004561 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004562 if (!isa<PointerType>(Ty))
4563 error("GetElementPtr requires a pointer operand");
4564
4565 std::vector<Value*> VIndices;
4566 std::vector<Constant*> CIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00004567 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004568
Reid Spencerb7046c72007-01-29 05:41:34 +00004569 delete (yyvsp[-1].ValueList);
4570 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004571 (yyval.ConstVal).S = Signless;
4572 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004573 break;
4574
4575 case 165:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004576#line 2221 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004577 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004578 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4579 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004580 error("Select condition must be bool type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004581 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004582 error("Select operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004583 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004584 (yyval.ConstVal).S = Unsigned;
4585 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004586 break;
4587
4588 case 166:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004589#line 2230 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004590 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004591 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4592 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004593 error("Binary operator types must match");
4594 // First, make sure we're dealing with the right opcode by upgrading from
4595 // obsolete versions.
Reid Spencerb7046c72007-01-29 05:41:34 +00004596 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004597
4598 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4599 // To retain backward compatibility with these early compilers, we emit a
4600 // cast to the appropriate integer type automatically if we are in the
4601 // broken case. See PR424 for more information.
4602 if (!isa<PointerType>(Ty)) {
Reid Spencerb7046c72007-01-29 05:41:34 +00004603 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004604 } else {
4605 const Type *IntPtrTy = 0;
4606 switch (CurModule.CurrentModule->getPointerSize()) {
4607 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4608 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4609 default: error("invalid pointer binary constant expr");
4610 }
4611 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
Reid Spencerb7046c72007-01-29 05:41:34 +00004612 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4613 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
Reid Spencer950bf602007-01-26 08:19:09 +00004614 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4615 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004616 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004617 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004618 break;
4619
4620 case 167:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004621#line 2258 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004622 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004623 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4624 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004625 error("Logical operator types must match");
4626 if (!Ty->isInteger()) {
4627 if (!isa<PackedType>(Ty) ||
4628 !cast<PackedType>(Ty)->getElementType()->isInteger())
4629 error("Logical operator requires integer operands");
4630 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004631 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4632 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4633 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004634 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004635 break;
4636
4637 case 168:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004638#line 2271 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004639 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004640 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4641 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004642 error("setcc operand types must match");
4643 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00004644 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4645 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004646 (yyval.ConstVal).S = Unsigned;
4647 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004648 break;
4649
4650 case 169:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004651#line 2280 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004652 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004653 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004654 error("icmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004655 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004656 (yyval.ConstVal).S = Unsigned;
4657 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004658 break;
4659
4660 case 170:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004661#line 2286 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004662 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004663 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004664 error("fcmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004665 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004666 (yyval.ConstVal).S = Unsigned;
4667 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004668 break;
4669
4670 case 171:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004671#line 2292 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004672 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004673 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4674 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004675 error("Shift count for shift constant must be unsigned byte");
Reid Spencer832254e2007-02-02 02:16:23 +00004676 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
Reid Spencerb7046c72007-01-29 05:41:34 +00004677 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004678 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00004679 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4680 (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, ShiftAmt);
Reid Spencerb7046c72007-01-29 05:41:34 +00004681 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004682 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004683 break;
4684
4685 case 172:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004686#line 2303 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004687 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004688 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004689 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004690 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4691 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004692 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004693 break;
4694
4695 case 173:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004696#line 2309 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004697 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004698 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004699 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004700 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4701 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004702 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004703 break;
4704
4705 case 174:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004706#line 2315 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004707 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004708 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004709 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004710 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4711 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004712 ;}
4713 break;
4714
4715 case 175:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004716#line 2326 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004717 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004718 break;
4719
4720 case 176:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004721#line 2327 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004722 {
4723 (yyval.ConstVector) = new std::vector<ConstInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004724 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004725 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004726 break;
4727
4728 case 177:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004729#line 2336 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004730 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004731 break;
4732
4733 case 178:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004734#line 2337 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004735 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004736 break;
4737
4738 case 179:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004739#line 2349 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004740 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004741 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004742 CurModule.ModuleDone();
4743 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004744 break;
4745
4746 case 180:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004747#line 2358 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004748 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004749 break;
4750
4751 case 181:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004752#line 2359 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004753 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004754 break;
4755
4756 case 182:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004757#line 2360 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004758 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004759 break;
4760
4761 case 183:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004762#line 2361 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004763 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004764 break;
4765
4766 case 184:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004767#line 2362 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004768 {
4769 (yyval.ModuleVal) = CurModule.CurrentModule;
4770 // Emit an error if there are any unresolved types left.
4771 if (!CurModule.LateResolveTypes.empty()) {
4772 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4773 if (DID.Type == ValID::NameVal) {
4774 error("Reference to an undefined type: '"+DID.getName() + "'");
4775 } else {
4776 error("Reference to an undefined type: #" + itostr(DID.Num));
4777 }
4778 }
4779 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004780 break;
4781
4782 case 185:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004783#line 2378 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004784 {
Reid Spencer950bf602007-01-26 08:19:09 +00004785 // Eagerly resolve types. This is not an optimization, this is a
4786 // requirement that is due to the fact that we could have this:
4787 //
4788 // %list = type { %list * }
4789 // %list = type { %list * } ; repeated type decl
4790 //
4791 // If types are not resolved eagerly, then the two types will not be
4792 // determined to be the same type!
4793 //
Reid Spencerb7046c72007-01-29 05:41:34 +00004794 const Type* Ty = (yyvsp[0].TypeVal).T->get();
4795 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004796
Reid Spencerb7046c72007-01-29 05:41:34 +00004797 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer950bf602007-01-26 08:19:09 +00004798 // If this is a named type that is not a redefinition, add it to the slot
4799 // table.
4800 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004801 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004802 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004803 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004804 break;
4805
4806 case 186:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004807#line 2398 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004808 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004809 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004810 break;
4811
4812 case 187:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004813#line 2400 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004814 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004815 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004816 break;
4817
4818 case 188:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004819#line 2402 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004820 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004821 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00004822 error("Global value initializer is not a constant");
Reid Spencerb7046c72007-01-29 05:41:34 +00004823 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 +00004824 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004825 break;
4826
4827 case 189:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004828#line 2406 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004829 {
Reid Spencer950bf602007-01-26 08:19:09 +00004830 CurGV = 0;
4831 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004832 break;
4833
4834 case 190:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004835#line 2409 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004836 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004837 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4838 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4839 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004840 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004841 break;
4842
4843 case 191:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004844#line 2413 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004845 {
Reid Spencer950bf602007-01-26 08:19:09 +00004846 CurGV = 0;
4847 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004848 break;
4849
4850 case 192:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004851#line 2416 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004852 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004853 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4854 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4855 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004856 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004857 break;
4858
4859 case 193:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004860#line 2420 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004861 {
Reid Spencer950bf602007-01-26 08:19:09 +00004862 CurGV = 0;
4863 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004864 break;
4865
4866 case 194:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004867#line 2423 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004868 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004869 const Type *Ty = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004870 CurGV =
Reid Spencerb7046c72007-01-29 05:41:34 +00004871 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4872 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004873 ;}
4874 break;
4875
4876 case 195:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004877#line 2428 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004878 {
4879 CurGV = 0;
4880 ;}
4881 break;
4882
4883 case 196:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004884#line 2431 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004885 {
Reid Spencer950bf602007-01-26 08:19:09 +00004886 ;}
4887 break;
4888
4889 case 197:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004890#line 2433 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004891 {
4892 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004893 break;
4894
4895 case 198:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004896#line 2435 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004897 {
4898 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004899 break;
4900
4901 case 199:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004902#line 2440 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004903 {
Reid Spencer950bf602007-01-26 08:19:09 +00004904 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencerb7046c72007-01-29 05:41:34 +00004905 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4906 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4907 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004908
4909 if (AsmSoFar.empty())
4910 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4911 else
4912 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4913 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004914 break;
4915
4916 case 200:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004917#line 2454 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004918 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004919 break;
4920
4921 case 201:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004922#line 2455 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004923 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004924 break;
4925
4926 case 202:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004927#line 2459 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004928 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004929 CurModule.setEndianness((yyvsp[0].Endianness));
Reid Spencer950bf602007-01-26 08:19:09 +00004930 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004931 break;
4932
4933 case 203:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004934#line 2462 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004935 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004936 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00004937 CurModule.setPointerSize(Module::Pointer32);
Reid Spencerb7046c72007-01-29 05:41:34 +00004938 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00004939 CurModule.setPointerSize(Module::Pointer64);
4940 else
Reid Spencerb7046c72007-01-29 05:41:34 +00004941 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004942 ;}
4943 break;
4944
4945 case 204:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004946#line 2470 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004947 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004948 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4949 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004950 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004951 break;
4952
4953 case 205:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004954#line 2474 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004955 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004956 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4957 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004958 ;}
4959 break;
4960
4961 case 207:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004962#line 2485 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004963 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004964 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4965 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004966 ;}
4967 break;
4968
4969 case 208:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004970#line 2489 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004971 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004972 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4973 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004974 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004975 break;
4976
4977 case 209:
Reid Spenceref9b9a72007-02-05 20:47:22 +00004978#line 2493 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004979 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004980 break;
4981
Reid Spencerc4d96252007-01-13 00:03:30 +00004982 case 213:
Reid Spencer785a5ae2007-02-08 00:21:40 +00004983#line 2507 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004984 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004985 break;
4986
Reid Spencer319a7302007-01-05 17:20:02 +00004987 case 214:
Reid Spencer785a5ae2007-02-08 00:21:40 +00004988#line 2511 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004989 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004990 if ((yyvsp[-1].TypeVal).T->get() == Type::VoidTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004991 error("void typed arguments are invalid");
Reid Spencerb7046c72007-01-29 05:41:34 +00004992 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004993 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004994 break;
4995
4996 case 215:
Reid Spencer785a5ae2007-02-08 00:21:40 +00004997#line 2519 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004998 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004999 (yyval.ArgList) = (yyvsp[-2].ArgList);
5000 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5001 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005002 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005003 break;
5004
5005 case 216:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005006#line 2524 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005007 {
5008 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005009 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5010 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005011 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005012 break;
5013
5014 case 217:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005015#line 2532 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005016 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005017 break;
5018
5019 case 218:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005020#line 2533 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005021 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005022 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer950bf602007-01-26 08:19:09 +00005023 PATypeInfo VoidTI;
5024 VoidTI.T = new PATypeHolder(Type::VoidTy);
5025 VoidTI.S = Signless;
5026 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5027 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005028 break;
5029
5030 case 219:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005031#line 2540 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005032 {
5033 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5034 PATypeInfo VoidTI;
5035 VoidTI.T = new PATypeHolder(Type::VoidTy);
5036 VoidTI.S = Signless;
5037 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5038 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005039 break;
5040
5041 case 220:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005042#line 2547 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005043 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005044 break;
5045
5046 case 221:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005047#line 2551 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005048 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005049 UnEscapeLexed((yyvsp[-5].StrVal));
5050 std::string FunctionName((yyvsp[-5].StrVal));
5051 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer950bf602007-01-26 08:19:09 +00005052
Reid Spencerb7046c72007-01-29 05:41:34 +00005053 const Type* RetTy = (yyvsp[-6].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005054
5055 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5056 error("LLVM functions cannot return aggregate types");
5057
Reid Spenceref9b9a72007-02-05 20:47:22 +00005058 std::vector<const Type*> ParamTyList;
Reid Spencer950bf602007-01-26 08:19:09 +00005059
5060 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5061 // i8*. We check here for those names and override the parameter list
5062 // types to ensure the prototype is correct.
5063 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005064 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00005065 } else if (FunctionName == "llvm.va_copy") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005066 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5067 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencerb7046c72007-01-29 05:41:34 +00005068 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005069 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencerb7046c72007-01-29 05:41:34 +00005070 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005071 const Type *Ty = I->first.T->get();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005072 ParamTyList.push_back(Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00005073 }
5074 }
5075
Reid Spenceref9b9a72007-02-05 20:47:22 +00005076 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5077 if (isVarArg)
5078 ParamTyList.pop_back();
Reid Spencer950bf602007-01-26 08:19:09 +00005079
Reid Spencerb7046c72007-01-29 05:41:34 +00005080 // Convert the CSRet calling convention into the corresponding parameter
5081 // attribute.
5082 FunctionType::ParamAttrsList ParamAttrs;
5083 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
5084 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5085 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5086 }
5087
Reid Spenceref9b9a72007-02-05 20:47:22 +00005088 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
Reid Spencerb7046c72007-01-29 05:41:34 +00005089 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005090 const PointerType *PFT = PointerType::get(FT);
Reid Spencerb7046c72007-01-29 05:41:34 +00005091 delete (yyvsp[-6].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005092
5093 ValID ID;
5094 if (!FunctionName.empty()) {
5095 ID = ValID::create((char*)FunctionName.c_str());
5096 } else {
5097 ID = ValID::create((int)CurModule.Values[PFT].size());
5098 }
5099
5100 Function *Fn = 0;
5101 // See if this function was forward referenced. If so, recycle the object.
5102 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5103 // Move the function to the end of the list, from whereever it was
5104 // previously inserted.
5105 Fn = cast<Function>(FWRef);
5106 CurModule.CurrentModule->getFunctionList().remove(Fn);
5107 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5108 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005109 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
5110 if (Fn->getFunctionType() != FT ) {
5111 // The existing function doesn't have the same type. Previously this was
5112 // permitted because the symbol tables had "type planes" and names were
5113 // distinct within a type plane. After PR411 was fixed, this is no
5114 // longer the case. To resolve this we must rename this function.
5115 // However, renaming it can cause problems if its linkage is external
5116 // because it could cause a link failure. We warn about this.
5117 std::string NewName = makeNameUnique(FunctionName);
5118 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5119 "' may cause linkage errors");
5120
5121 Fn = new Function(FT, GlobalValue::ExternalLinkage, NewName,
5122 CurModule.CurrentModule);
5123 InsertValue(Fn, CurModule.Values);
5124 RenameMapKey Key = std::make_pair(FunctionName,PFT);
5125 CurModule.RenameMap[Key] = NewName;
Reid Spencer785a5ae2007-02-08 00:21:40 +00005126 } else if (Fn->hasInternalLinkage()) {
5127 // The function we are creating conflicts in name with another function
5128 // that has internal linkage. We'll rename that one quietly to get rid
5129 // of the conflict.
5130 Fn->setName(makeNameUnique(Fn->getName()));
5131 RenameMapKey Key = std::make_pair(FunctionName,PFT);
5132 CurModule.RenameMap[Key] = Fn->getName();
5133
5134 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5135 CurModule.CurrentModule);
5136
5137 InsertValue(Fn, CurModule.Values);
5138 } else if (CurFun.Linkage == GlobalValue::InternalLinkage) {
5139 // The function we are creating has internal linkage and conflicts with
5140 // another function of the same name. We'll just rename this one
5141 // quietly because its internal linkage can't conflict with anything
5142 // else.
5143 std::string NewName = makeNameUnique(FunctionName);
5144 Fn = new Function(FT, GlobalValue::ExternalLinkage, NewName,
5145 CurModule.CurrentModule);
5146 InsertValue(Fn, CurModule.Values);
5147 RenameMapKey Key = std::make_pair(FunctionName,PFT);
5148 CurModule.RenameMap[Key] = NewName;
Reid Spenceref9b9a72007-02-05 20:47:22 +00005149 } else {
Reid Spencer785a5ae2007-02-08 00:21:40 +00005150 // The types are the same and they are both external linkage. Either
5151 // the existing or the current function needs to be a forward
5152 // declaration. If not, they're attempting to redefine two external
5153 // functions. This wasn't allowed in llvm 1.9 and it isn't allowed now.
Reid Spenceref9b9a72007-02-05 20:47:22 +00005154 if (!CurFun.isDeclare && !Fn->isDeclaration())
5155 error("Redefinition of function '" + FunctionName + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00005156
Reid Spenceref9b9a72007-02-05 20:47:22 +00005157 // Make sure to strip off any argument names so we can't get conflicts.
5158 if (Fn->isDeclaration())
5159 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5160 AI != AE; ++AI)
5161 AI->setName("");
5162 }
5163 } else { // Not already defined?
Reid Spencer950bf602007-01-26 08:19:09 +00005164 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5165 CurModule.CurrentModule);
5166
5167 InsertValue(Fn, CurModule.Values);
5168 }
5169
5170 CurFun.FunctionStart(Fn);
5171
5172 if (CurFun.isDeclare) {
5173 // If we have declaration, always overwrite linkage. This will allow us
5174 // to correctly handle cases, when pointer to function is passed as
5175 // argument to another function.
5176 Fn->setLinkage(CurFun.Linkage);
5177 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005178 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5179 Fn->setAlignment((yyvsp[0].UIntVal));
5180 if ((yyvsp[-1].StrVal)) {
5181 Fn->setSection((yyvsp[-1].StrVal));
5182 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005183 }
5184
5185 // Add all of the arguments we parsed to the function...
Reid Spencerb7046c72007-01-29 05:41:34 +00005186 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005187 if (isVarArg) { // Nuke the last entry
Reid Spencerb7046c72007-01-29 05:41:34 +00005188 assert((yyvsp[-3].ArgList)->back().first.T->get() == Type::VoidTy &&
5189 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5190 delete (yyvsp[-3].ArgList)->back().first.T;
5191 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005192 }
5193 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005194 Function::arg_iterator ArgEnd = Fn->arg_end();
5195 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
5196 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end();
5197 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer950bf602007-01-26 08:19:09 +00005198 delete I->first.T; // Delete the typeholder...
5199 setValueName(ArgIt, I->second); // Insert arg into symtab...
5200 InsertValue(ArgIt);
5201 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005202 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005203 }
5204 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005205 break;
5206
5207 case 224:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005208#line 2715 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005209 {
5210 (yyval.FunctionVal) = CurFun.CurrentFunction;
5211
5212 // Make sure that we keep track of the linkage type even if there was a
5213 // previous "declare".
Reid Spencerb7046c72007-01-29 05:41:34 +00005214 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Reid Spencer950bf602007-01-26 08:19:09 +00005215 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005216 break;
5217
5218 case 227:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005219#line 2729 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005220 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005221 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005222 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005223 break;
5224
5225 case 229:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005226#line 2735 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005227 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5228 break;
5229
5230 case 230:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005231#line 2736 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005232 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5233 break;
5234
5235 case 231:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005236#line 2740 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005237 { CurFun.isDeclare = true; ;}
5238 break;
5239
5240 case 232:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005241#line 2740 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005242 {
5243 (yyval.FunctionVal) = CurFun.CurrentFunction;
5244 CurFun.FunctionDone();
5245
5246 ;}
5247 break;
5248
5249 case 233:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005250#line 2752 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005251 { (yyval.BoolVal) = false; ;}
5252 break;
5253
5254 case 234:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005255#line 2753 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005256 { (yyval.BoolVal) = true; ;}
5257 break;
5258
5259 case 235:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005260#line 2758 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005261 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005262 break;
5263
5264 case 236:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005265#line 2759 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005266 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005267 break;
5268
5269 case 237:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005270#line 2760 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005271 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005272 break;
5273
5274 case 238:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005275#line 2761 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005276 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005277 break;
5278
Reid Spencerc4d96252007-01-13 00:03:30 +00005279 case 239:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005280#line 2762 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005281 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5282 break;
5283
5284 case 240:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005285#line 2763 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005286 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005287 break;
5288
Reid Spencerc4d96252007-01-13 00:03:30 +00005289 case 241:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005290#line 2764 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005291 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5292 break;
5293
5294 case 242:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005295#line 2765 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005296 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5297 break;
5298
5299 case 243:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005300#line 2766 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005301 { // Nonempty unsized packed vector
Reid Spencerb7046c72007-01-29 05:41:34 +00005302 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5303 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer950bf602007-01-26 08:19:09 +00005304 PackedType* pt = PackedType::get(ETy, NumElements);
5305 PATypeHolder* PTy = new PATypeHolder(
5306 HandleUpRefs(PackedType::get(ETy, NumElements)));
5307
5308 // Verify all elements are correct type!
5309 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00005310 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5311 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005312 const Type *CTy = C->getType();
5313 if (ETy != CTy)
5314 error("Element #" + utostr(i) + " is not of type '" +
5315 ETy->getDescription() +"' as required!\nIt is of type '" +
5316 CTy->getDescription() + "'");
5317 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005318 }
Reid Spencer950bf602007-01-26 08:19:09 +00005319 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
Reid Spencerb7046c72007-01-29 05:41:34 +00005320 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00005321 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005322 break;
5323
Reid Spencerc4d96252007-01-13 00:03:30 +00005324 case 244:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005325#line 2787 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005326 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005327 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00005328 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005329 break;
5330
Reid Spencerc4d96252007-01-13 00:03:30 +00005331 case 245:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005332#line 2790 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005333 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005334 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5335 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5336 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5337 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5338 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5339 free((yyvsp[-2].StrVal));
5340 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005341 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005342 break;
5343
Reid Spencerc4d96252007-01-13 00:03:30 +00005344 case 246:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005345#line 2805 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005346 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005347 break;
5348
Reid Spencer319a7302007-01-05 17:20:02 +00005349 case 247:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005350#line 2806 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005351 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005352 break;
5353
5354 case 250:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005355#line 2819 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005356 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005357 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5358 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5359 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5360 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005361 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005362 break;
5363
Reid Spencerc4d96252007-01-13 00:03:30 +00005364 case 251:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005365#line 2828 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005366 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005367 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005368 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005369 break;
5370
Reid Spencerc4d96252007-01-13 00:03:30 +00005371 case 252:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005372#line 2831 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005373 { // Do not allow functions with 0 basic blocks
Reid Spencerb7046c72007-01-29 05:41:34 +00005374 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005375 ;}
5376 break;
5377
5378 case 253:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005379#line 2840 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005380 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005381 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5382 InsertValue((yyvsp[0].TermInstVal));
5383 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5384 InsertValue((yyvsp[-2].BasicBlockVal));
5385 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005386 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005387 break;
5388
Reid Spencerc4d96252007-01-13 00:03:30 +00005389 case 254:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005390#line 2850 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005391 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005392 if ((yyvsp[0].InstVal).I)
5393 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5394 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005395 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005396 break;
5397
Reid Spencerc4d96252007-01-13 00:03:30 +00005398 case 255:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005399#line 2855 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005400 {
5401 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5402 // Make sure to move the basic block to the correct location in the
5403 // function, instead of leaving it inserted wherever it was first
5404 // referenced.
5405 Function::BasicBlockListType &BBL =
5406 CurFun.CurrentFunction->getBasicBlockList();
5407 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5408 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005409 break;
5410
Reid Spencerc4d96252007-01-13 00:03:30 +00005411 case 256:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005412#line 2864 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005413 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005414 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005415 // Make sure to move the basic block to the correct location in the
5416 // function, instead of leaving it inserted wherever it was first
5417 // referenced.
5418 Function::BasicBlockListType &BBL =
5419 CurFun.CurrentFunction->getBasicBlockList();
5420 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5421 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005422 break;
5423
Reid Spencerc4d96252007-01-13 00:03:30 +00005424 case 259:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005425#line 2878 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005426 { // Return with a result...
Reid Spencerb7046c72007-01-29 05:41:34 +00005427 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005428 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005429 break;
5430
Reid Spencerc4d96252007-01-13 00:03:30 +00005431 case 260:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005432#line 2881 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005433 { // Return with no result...
5434 (yyval.TermInstVal) = new ReturnInst();
5435 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005436 break;
5437
Reid Spencerc4d96252007-01-13 00:03:30 +00005438 case 261:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005439#line 2884 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005440 { // Unconditional Branch...
Reid Spencerb7046c72007-01-29 05:41:34 +00005441 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005442 (yyval.TermInstVal) = new BranchInst(tmpBB);
5443 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005444 break;
5445
Reid Spencer319a7302007-01-05 17:20:02 +00005446 case 262:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005447#line 2888 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005448 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005449 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5450 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5451 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005452 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5453 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005454 break;
5455
5456 case 263:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005457#line 2894 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005458 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005459 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5460 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5461 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencer950bf602007-01-26 08:19:09 +00005462 (yyval.TermInstVal) = S;
Reid Spencerb7046c72007-01-29 05:41:34 +00005463 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5464 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005465 for (; I != E; ++I) {
5466 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5467 S->addCase(CI, I->second);
5468 else
5469 error("Switch case is constant, but not a simple integer");
5470 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005471 delete (yyvsp[-1].JumpTable);
Reid Spencer950bf602007-01-26 08:19:09 +00005472 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005473 break;
5474
5475 case 264:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005476#line 2909 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005477 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005478 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5479 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005480 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5481 (yyval.TermInstVal) = S;
5482 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005483 break;
5484
Reid Spencerc4d96252007-01-13 00:03:30 +00005485 case 265:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005486#line 2916 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005487 {
Reid Spencer950bf602007-01-26 08:19:09 +00005488 const PointerType *PFTy;
5489 const FunctionType *Ty;
5490
Reid Spencerb7046c72007-01-29 05:41:34 +00005491 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005492 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5493 // Pull out the types of all of the arguments...
5494 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005495 if ((yyvsp[-7].ValueList)) {
5496 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005497 I != E; ++I)
5498 ParamTypes.push_back((*I).V->getType());
5499 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005500 FunctionType::ParamAttrsList ParamAttrs;
5501 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
5502 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5503 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5504 }
Reid Spencer950bf602007-01-26 08:19:09 +00005505 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5506 if (isVarArg) ParamTypes.pop_back();
Reid Spencerb7046c72007-01-29 05:41:34 +00005507 Ty = FunctionType::get((yyvsp[-10].TypeVal).T->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005508 PFTy = PointerType::get(Ty);
5509 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005510 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5511 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5512 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005513
5514 // Create the call node...
Reid Spencerb7046c72007-01-29 05:41:34 +00005515 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005516 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5517 } else { // Has arguments?
5518 // Loop through FunctionType's arguments and ensure they are specified
5519 // correctly!
5520 //
5521 FunctionType::param_iterator I = Ty->param_begin();
5522 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00005523 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005524
5525 std::vector<Value*> Args;
5526 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5527 if ((*ArgI).V->getType() != *I)
5528 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5529 (*I)->getDescription() + "'");
5530 Args.push_back((*ArgI).V);
5531 }
5532
5533 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5534 error("Invalid number of parameters detected");
5535
5536 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5537 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005538 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
5539 delete (yyvsp[-10].TypeVal).T;
5540 delete (yyvsp[-7].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005541 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005542 break;
5543
Reid Spencerc4d96252007-01-13 00:03:30 +00005544 case 266:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005545#line 2971 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005546 {
Reid Spencer950bf602007-01-26 08:19:09 +00005547 (yyval.TermInstVal) = new UnwindInst();
5548 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005549 break;
5550
Reid Spencerc4d96252007-01-13 00:03:30 +00005551 case 267:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005552#line 2974 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005553 {
5554 (yyval.TermInstVal) = new UnreachableInst();
5555 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005556 break;
5557
Reid Spencerc4d96252007-01-13 00:03:30 +00005558 case 268:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005559#line 2980 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005560 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005561 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5562 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005563
5564 if (V == 0)
5565 error("May only switch on a constant pool value");
5566
Reid Spencerb7046c72007-01-29 05:41:34 +00005567 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005568 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5569 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005570 break;
5571
Reid Spencerc4d96252007-01-13 00:03:30 +00005572 case 269:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005573#line 2990 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005574 {
Reid Spencer950bf602007-01-26 08:19:09 +00005575 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005576 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005577
5578 if (V == 0)
5579 error("May only switch on a constant pool value");
5580
Reid Spencerb7046c72007-01-29 05:41:34 +00005581 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005582 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5583 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005584 break;
5585
Reid Spencerc4d96252007-01-13 00:03:30 +00005586 case 270:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005587#line 3003 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005588 {
Reid Spencer950bf602007-01-26 08:19:09 +00005589 bool omit = false;
Reid Spencerb7046c72007-01-29 05:41:34 +00005590 if ((yyvsp[-1].StrVal))
5591 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005592 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005593 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005594 // This is a useless bit cast causing a name redefinition. It is
5595 // a bit cast from a type to the same type of an operand with the
5596 // same name as the name we would give this instruction. Since this
5597 // instruction results in no code generation, it is safe to omit
5598 // the instruction. This situation can occur because of collapsed
5599 // type planes. For example:
5600 // %X = add int %Y, %Z
5601 // %X = cast int %Y to uint
5602 // After upgrade, this looks like:
5603 // %X = add i32 %Y, %Z
5604 // %X = bitcast i32 to i32
5605 // The bitcast is clearly useless so we omit it.
5606 omit = true;
5607 if (omit) {
5608 (yyval.InstVal).I = 0;
5609 (yyval.InstVal).S = Signless;
5610 } else {
Reid Spencerb7046c72007-01-29 05:41:34 +00005611 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5612 InsertValue((yyvsp[0].InstVal).I);
5613 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005614 }
5615 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005616 break;
5617
Reid Spencerc4d96252007-01-13 00:03:30 +00005618 case 271:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005619#line 3032 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005620 { // Used for PHI nodes
5621 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005622 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5623 Value* tmpVal = getVal((yyvsp[-5].TypeVal).T->get(), (yyvsp[-3].ValIDVal));
5624 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005625 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencerb7046c72007-01-29 05:41:34 +00005626 delete (yyvsp[-5].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005627 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005628 break;
5629
Reid Spencerc4d96252007-01-13 00:03:30 +00005630 case 272:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005631#line 3040 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005632 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005633 (yyval.PHIList) = (yyvsp[-6].PHIList);
5634 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5635 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5636 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer950bf602007-01-26 08:19:09 +00005637 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005638 break;
5639
Reid Spencerc4d96252007-01-13 00:03:30 +00005640 case 273:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005641#line 3048 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005642 { // Used for call statements, and memory insts...
5643 (yyval.ValueList) = new std::vector<ValueInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00005644 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005645 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005646 break;
5647
Reid Spencer950bf602007-01-26 08:19:09 +00005648 case 274:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005649#line 3052 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005650 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005651 (yyval.ValueList) = (yyvsp[-2].ValueList);
5652 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005653 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005654 break;
5655
Reid Spencerc4d96252007-01-13 00:03:30 +00005656 case 276:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005657#line 3060 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005658 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005659 break;
5660
Reid Spencerc4d96252007-01-13 00:03:30 +00005661 case 277:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005662#line 3064 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005663 {
Reid Spencer950bf602007-01-26 08:19:09 +00005664 (yyval.BoolVal) = true;
5665 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005666 break;
5667
Reid Spencer319a7302007-01-05 17:20:02 +00005668 case 278:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005669#line 3067 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005670 {
Reid Spencer950bf602007-01-26 08:19:09 +00005671 (yyval.BoolVal) = false;
5672 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005673 break;
5674
5675 case 279:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005676#line 3073 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +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 (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5680 error("Arithmetic operator requires integer, FP, or packed operands");
5681 if (isa<PackedType>(Ty) &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005682 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Reid Spencer950bf602007-01-26 08:19:09 +00005683 error("Remainder not supported on packed types");
5684 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencerb7046c72007-01-29 05:41:34 +00005685 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5686 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5687 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005688 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5689 if ((yyval.InstVal).I == 0)
5690 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005691 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5692 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005693 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005694 break;
5695
5696 case 280:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005697#line 3090 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005698 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005699 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005700 if (!Ty->isInteger()) {
5701 if (!isa<PackedType>(Ty) ||
5702 !cast<PackedType>(Ty)->getElementType()->isInteger())
5703 error("Logical operator requires integral operands");
5704 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005705 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5706 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5707 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005708 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5709 if ((yyval.InstVal).I == 0)
5710 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005711 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5712 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005713 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005714 break;
5715
Reid Spencerc4d96252007-01-13 00:03:30 +00005716 case 281:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005717#line 3106 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005718 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005719 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005720 if(isa<PackedType>(Ty))
5721 error("PackedTypes currently not supported in setcc instructions");
5722 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00005723 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5724 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5725 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005726 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5727 if ((yyval.InstVal).I == 0)
5728 error("binary operator returned null");
5729 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005730 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005731 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005732 break;
5733
Reid Spencerc4d96252007-01-13 00:03:30 +00005734 case 282:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005735#line 3120 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005736 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005737 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005738 if (isa<PackedType>(Ty))
5739 error("PackedTypes currently not supported in icmp instructions");
5740 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5741 error("icmp requires integer or pointer typed operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005742 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5743 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5744 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005745 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005746 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005747 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005748 break;
5749
Reid Spencerc4d96252007-01-13 00:03:30 +00005750 case 283:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005751#line 3132 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005752 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005753 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005754 if (isa<PackedType>(Ty))
5755 error("PackedTypes currently not supported in fcmp instructions");
5756 else if (!Ty->isFloatingPoint())
5757 error("fcmp instruction requires floating point operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005758 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5759 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5760 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005761 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005762 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005763 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005764 break;
5765
Reid Spencerc4d96252007-01-13 00:03:30 +00005766 case 284:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005767#line 3144 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005768 {
Reid Spencer950bf602007-01-26 08:19:09 +00005769 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencerb7046c72007-01-29 05:41:34 +00005770 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005771 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5772 if (Ones == 0)
5773 error("Expected integral type for not instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005774 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
Reid Spencer950bf602007-01-26 08:19:09 +00005775 if ((yyval.InstVal).I == 0)
5776 error("Could not create a xor instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005777 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
Reid Spencer950bf602007-01-26 08:19:09 +00005778 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005779 break;
5780
5781 case 285:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005782#line 3155 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005783 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005784 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5785 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005786 error("Shift amount must be int8");
Reid Spencer832254e2007-02-02 02:16:23 +00005787 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
5788 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005789 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00005790 Value* ShiftAmt = 0;
5791 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
5792 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
5793 ShiftAmt = ConstantExpr::getZExt(C, Ty);
5794 else
5795 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
5796 else
5797 ShiftAmt = (yyvsp[0].ValueVal).V;
5798 (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[-3].BinaryOpVal), Ty, (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, ShiftAmt);
Reid Spencerb7046c72007-01-29 05:41:34 +00005799 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005800 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005801 break;
5802
5803 case 286:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005804#line 3173 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005805 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005806 const Type *DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005807 if (!DstTy->isFirstClassType())
5808 error("cast instruction to a non-primitive type: '" +
5809 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00005810 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5811 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5812 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005813 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005814 break;
5815
5816 case 287:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005817#line 3182 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005818 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005819 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5820 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005821 error("select condition must be bool");
Reid Spencerb7046c72007-01-29 05:41:34 +00005822 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005823 error("select value types should match");
Reid Spencerb7046c72007-01-29 05:41:34 +00005824 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5825 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005826 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005827 break;
5828
Reid Spencerc4d96252007-01-13 00:03:30 +00005829 case 288:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005830#line 3191 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005831 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005832 const Type *Ty = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005833 NewVarArgs = true;
Reid Spencerb7046c72007-01-29 05:41:34 +00005834 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5835 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5836 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005837 ;}
5838 break;
5839
5840 case 289:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005841#line 3198 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005842 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005843 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5844 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005845 ObsoleteVarArgs = true;
5846 Function* NF = cast<Function>(CurModule.CurrentModule->
5847 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5848
5849 //b = vaarg a, t ->
5850 //foo = alloca 1 of t
5851 //bar = vacopy a
5852 //store bar -> foo
5853 //b = vaarg foo, t
5854 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5855 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005856 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005857 CurBB->getInstList().push_back(bar);
5858 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5859 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00005860 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5861 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005862 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005863 break;
5864
Reid Spencerc4d96252007-01-13 00:03:30 +00005865 case 290:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005866#line 3219 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005867 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005868 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5869 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005870 ObsoleteVarArgs = true;
5871 Function* NF = cast<Function>(CurModule.CurrentModule->
5872 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5873
5874 //b = vanext a, t ->
5875 //foo = alloca 1 of t
5876 //bar = vacopy a
5877 //store bar -> foo
5878 //tmp = vaarg foo, t
5879 //b = load foo
5880 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5881 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005882 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005883 CurBB->getInstList().push_back(bar);
5884 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5885 Instruction* tmp = new VAArgInst(foo, DstTy);
5886 CurBB->getInstList().push_back(tmp);
5887 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005888 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5889 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005890 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005891 break;
5892
Reid Spencerc4d96252007-01-13 00:03:30 +00005893 case 291:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005894#line 3243 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005895 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005896 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005897 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005898 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5899 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005900 ;}
5901 break;
5902
5903 case 292:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005904#line 3249 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005905 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005906 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005907 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005908 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5909 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005910 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005911 break;
5912
Reid Spencerc4d96252007-01-13 00:03:30 +00005913 case 293:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005914#line 3255 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005915 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005916 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005917 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005918 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5919 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005920 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005921 break;
5922
Reid Spencerc4d96252007-01-13 00:03:30 +00005923 case 294:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005924#line 3261 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005925 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005926 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005927 if (!Ty->isFirstClassType())
5928 error("PHI node operands must be of first class type");
5929 PHINode *PHI = new PHINode(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00005930 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5931 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5932 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00005933 error("All elements of a PHI node must be of the same type");
Reid Spencerb7046c72007-01-29 05:41:34 +00005934 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5935 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00005936 }
5937 (yyval.InstVal).I = PHI;
Reid Spencerb7046c72007-01-29 05:41:34 +00005938 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5939 delete (yyvsp[0].PHIList).P; // Free the list...
Reid Spencer950bf602007-01-26 08:19:09 +00005940 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005941 break;
5942
5943 case 295:
Reid Spencer785a5ae2007-02-08 00:21:40 +00005944#line 3277 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005945 {
Reid Spencer950bf602007-01-26 08:19:09 +00005946
5947 // Handle the short call syntax
5948 const PointerType *PFTy;
5949 const FunctionType *FTy;
Reid Spencerb7046c72007-01-29 05:41:34 +00005950 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005951 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5952 // Pull out the types of all of the arguments...
5953 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005954 if ((yyvsp[-1].ValueList)) {
5955 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005956 I != E; ++I)
5957 ParamTypes.push_back((*I).V->getType());
5958 }
5959
Reid Spencerb7046c72007-01-29 05:41:34 +00005960 FunctionType::ParamAttrsList ParamAttrs;
5961 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
5962 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5963 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5964 }
Reid Spencer950bf602007-01-26 08:19:09 +00005965 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5966 if (isVarArg) ParamTypes.pop_back();
5967
Reid Spencerb7046c72007-01-29 05:41:34 +00005968 const Type *RetTy = (yyvsp[-4].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005969 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5970 error("Functions cannot return aggregate types");
5971
Reid Spencerb7046c72007-01-29 05:41:34 +00005972 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005973 PFTy = PointerType::get(FTy);
5974 }
5975
5976 // First upgrade any intrinsic calls.
5977 std::vector<Value*> Args;
Reid Spencerb7046c72007-01-29 05:41:34 +00005978 if ((yyvsp[-1].ValueList))
5979 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
5980 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
5981 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00005982
5983 // If we got an upgraded intrinsic
5984 if (Inst) {
5985 (yyval.InstVal).I = Inst;
5986 (yyval.InstVal).S = Signless;
5987 } else {
5988 // Get the function we're calling
Reid Spencerb7046c72007-01-29 05:41:34 +00005989 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005990
5991 // Check the argument values match
Reid Spencerb7046c72007-01-29 05:41:34 +00005992 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005993 // Make sure no arguments is a good thing!
5994 if (FTy->getNumParams() != 0)
5995 error("No arguments passed to a function that expects arguments");
5996 } else { // Has arguments?
5997 // Loop through FunctionType's arguments and ensure they are specified
5998 // correctly!
5999 //
6000 FunctionType::param_iterator I = FTy->param_begin();
6001 FunctionType::param_iterator E = FTy->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00006002 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006003
6004 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6005 if ((*ArgI).V->getType() != *I)
6006 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6007 (*I)->getDescription() + "'");
6008
6009 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6010 error("Invalid number of parameters detected");
6011 }
6012
6013 // Create the call instruction
6014 CallInst *CI = new CallInst(V, Args);
Reid Spencerb7046c72007-01-29 05:41:34 +00006015 CI->setTailCall((yyvsp[-6].BoolVal));
6016 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00006017 (yyval.InstVal).I = CI;
Reid Spencerb7046c72007-01-29 05:41:34 +00006018 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006019 }
Reid Spencerb7046c72007-01-29 05:41:34 +00006020 delete (yyvsp[-4].TypeVal).T;
6021 delete (yyvsp[-1].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006022 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006023 break;
6024
Reid Spencerc4d96252007-01-13 00:03:30 +00006025 case 296:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006026#line 3355 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00006027 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006028 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00006029 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00006030 break;
6031
Reid Spencer609ca3e2007-01-12 20:10:51 +00006032 case 297:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006033#line 3363 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00006034 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00006035 break;
6036
6037 case 298:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006038#line 3364 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006039 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006040 break;
6041
Reid Spencerc4d96252007-01-13 00:03:30 +00006042 case 299:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006043#line 3368 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006044 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006045 break;
6046
Reid Spencerc4d96252007-01-13 00:03:30 +00006047 case 300:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006048#line 3369 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006049 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006050 break;
6051
Reid Spencerc4d96252007-01-13 00:03:30 +00006052 case 301:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006053#line 3373 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006054 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006055 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
6056 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6057 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6058 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006059 ;}
6060 break;
6061
6062 case 302:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006063#line 3379 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006064 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006065 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6066 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6067 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6068 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006069 ;}
6070 break;
6071
6072 case 303:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006073#line 3385 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006074 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006075 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
6076 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6077 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6078 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006079 ;}
6080 break;
6081
6082 case 304:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006083#line 3391 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006084 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006085 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6086 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6087 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6088 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006089 ;}
6090 break;
6091
6092 case 305:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006093#line 3397 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006094 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006095 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006096 if (!isa<PointerType>(PTy))
6097 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006098 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006099 (yyval.InstVal).S = Signless;
6100 ;}
6101 break;
6102
6103 case 306:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006104#line 3404 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006105 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006106 const Type* Ty = (yyvsp[-1].TypeVal).T->get();
6107 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006108 if (!isa<PointerType>(Ty))
6109 error("Can't load from nonpointer type: " + Ty->getDescription());
6110 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6111 error("Can't load from pointer of non-first-class type: " +
6112 Ty->getDescription());
Reid Spencerb7046c72007-01-29 05:41:34 +00006113 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6114 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
6115 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006116 ;}
6117 break;
6118
6119 case 307:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006120#line 3416 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006121 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006122 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00006123 if (!PTy)
6124 error("Can't store to a nonpointer type: " +
Reid Spencerb7046c72007-01-29 05:41:34 +00006125 (yyvsp[-1].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00006126 const Type *ElTy = PTy->getElementType();
Reid Spencerb7046c72007-01-29 05:41:34 +00006127 if (ElTy != (yyvsp[-3].ValueVal).V->getType())
6128 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencer950bf602007-01-26 08:19:09 +00006129 "' into space of type '" + ElTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006130 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6131 (yyval.InstVal).I = new StoreInst((yyvsp[-3].ValueVal).V, tmpVal, (yyvsp[-5].BoolVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006132 (yyval.InstVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00006133 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006134 ;}
6135 break;
6136
6137 case 308:
Reid Spencer785a5ae2007-02-08 00:21:40 +00006138#line 3430 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006139 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006140 const Type* Ty = (yyvsp[-2].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006141 if (!isa<PointerType>(Ty))
6142 error("getelementptr insn requires pointer operand");
6143
6144 std::vector<Value*> VIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00006145 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006146
Reid Spencerb7046c72007-01-29 05:41:34 +00006147 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006148 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6149 (yyval.InstVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00006150 delete (yyvsp[-2].TypeVal).T;
6151 delete (yyvsp[0].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006152 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006153 break;
6154
6155
Reid Spencer950bf602007-01-26 08:19:09 +00006156 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006157 }
6158
Reid Spencerb7046c72007-01-29 05:41:34 +00006159/* Line 1126 of yacc.c. */
Reid Spencer785a5ae2007-02-08 00:21:40 +00006160#line 6161 "UpgradeParser.tab.c"
Reid Spencerb7046c72007-01-29 05:41:34 +00006161
6162 yyvsp -= yylen;
6163 yyssp -= yylen;
6164
6165
Reid Spencer950bf602007-01-26 08:19:09 +00006166 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006167
6168 *++yyvsp = yyval;
6169
6170
Reid Spencer319a7302007-01-05 17:20:02 +00006171 /* Now `shift' the result of the reduction. Determine what state
6172 that goes to, based on the state we popped back to and the rule
6173 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006174
6175 yyn = yyr1[yyn];
6176
Reid Spencer319a7302007-01-05 17:20:02 +00006177 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6178 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006179 yystate = yytable[yystate];
6180 else
Reid Spencer319a7302007-01-05 17:20:02 +00006181 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006182
6183 goto yynewstate;
6184
6185
Reid Spencer319a7302007-01-05 17:20:02 +00006186/*------------------------------------.
6187| yyerrlab -- here on detecting error |
6188`------------------------------------*/
6189yyerrlab:
6190 /* If not already recovering from an error, report this error. */
6191 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006192 {
6193 ++yynerrs;
Reid Spencerb7046c72007-01-29 05:41:34 +00006194#if YYERROR_VERBOSE
6195 yyn = yypact[yystate];
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006196
Reid Spencerb7046c72007-01-29 05:41:34 +00006197 if (YYPACT_NINF < yyn && yyn < YYLAST)
6198 {
6199 int yytype = YYTRANSLATE (yychar);
6200 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6201 YYSIZE_T yysize = yysize0;
6202 YYSIZE_T yysize1;
6203 int yysize_overflow = 0;
6204 char *yymsg = 0;
6205# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6206 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6207 int yyx;
6208
6209#if 0
6210 /* This is so xgettext sees the translatable formats that are
6211 constructed on the fly. */
6212 YY_("syntax error, unexpected %s");
6213 YY_("syntax error, unexpected %s, expecting %s");
6214 YY_("syntax error, unexpected %s, expecting %s or %s");
6215 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6216 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006217#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006218 char *yyfmt;
6219 char const *yyf;
6220 static char const yyunexpected[] = "syntax error, unexpected %s";
6221 static char const yyexpecting[] = ", expecting %s";
6222 static char const yyor[] = " or %s";
6223 char yyformat[sizeof yyunexpected
6224 + sizeof yyexpecting - 1
6225 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6226 * (sizeof yyor - 1))];
6227 char const *yyprefix = yyexpecting;
6228
6229 /* Start YYX at -YYN if negative to avoid negative indexes in
6230 YYCHECK. */
6231 int yyxbegin = yyn < 0 ? -yyn : 0;
6232
6233 /* Stay within bounds of both yycheck and yytname. */
6234 int yychecklim = YYLAST - yyn;
6235 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6236 int yycount = 1;
6237
6238 yyarg[0] = yytname[yytype];
6239 yyfmt = yystpcpy (yyformat, yyunexpected);
6240
6241 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6242 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6243 {
6244 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6245 {
6246 yycount = 1;
6247 yysize = yysize0;
6248 yyformat[sizeof yyunexpected - 1] = '\0';
6249 break;
6250 }
6251 yyarg[yycount++] = yytname[yyx];
6252 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6253 yysize_overflow |= yysize1 < yysize;
6254 yysize = yysize1;
6255 yyfmt = yystpcpy (yyfmt, yyprefix);
6256 yyprefix = yyor;
6257 }
6258
6259 yyf = YY_(yyformat);
6260 yysize1 = yysize + yystrlen (yyf);
6261 yysize_overflow |= yysize1 < yysize;
6262 yysize = yysize1;
6263
6264 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6265 yymsg = (char *) YYSTACK_ALLOC (yysize);
6266 if (yymsg)
6267 {
6268 /* Avoid sprintf, as that infringes on the user's name space.
6269 Don't have undefined behavior even if the translation
6270 produced a string with the wrong number of "%s"s. */
6271 char *yyp = yymsg;
6272 int yyi = 0;
6273 while ((*yyp = *yyf))
6274 {
6275 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6276 {
6277 yyp += yytnamerr (yyp, yyarg[yyi++]);
6278 yyf += 2;
6279 }
6280 else
6281 {
6282 yyp++;
6283 yyf++;
6284 }
6285 }
6286 yyerror (yymsg);
6287 YYSTACK_FREE (yymsg);
6288 }
6289 else
6290 {
6291 yyerror (YY_("syntax error"));
6292 goto yyexhaustedlab;
6293 }
6294 }
6295 else
6296#endif /* YYERROR_VERBOSE */
6297 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006298 }
Reid Spencer950bf602007-01-26 08:19:09 +00006299
6300
6301
6302 if (yyerrstatus == 3)
6303 {
6304 /* If just tried and failed to reuse look-ahead token after an
6305 error, discard it. */
6306
6307 if (yychar <= YYEOF)
Reid Spencerb7046c72007-01-29 05:41:34 +00006308 {
Reid Spencer950bf602007-01-26 08:19:09 +00006309 /* Return failure if at end of input. */
6310 if (yychar == YYEOF)
6311 YYABORT;
Reid Spencerb7046c72007-01-29 05:41:34 +00006312 }
Reid Spencer950bf602007-01-26 08:19:09 +00006313 else
6314 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006315 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer950bf602007-01-26 08:19:09 +00006316 yychar = YYEMPTY;
6317 }
6318 }
6319
6320 /* Else will try to reuse look-ahead token after shifting the error
6321 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006322 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006323
Reid Spencer319a7302007-01-05 17:20:02 +00006324
Reid Spencer950bf602007-01-26 08:19:09 +00006325/*---------------------------------------------------.
6326| yyerrorlab -- error raised explicitly by YYERROR. |
6327`---------------------------------------------------*/
6328yyerrorlab:
6329
6330 /* Pacify compilers like GCC when the user code never invokes
6331 YYERROR and the label yyerrorlab therefore never appears in user
6332 code. */
Reid Spencerb7046c72007-01-29 05:41:34 +00006333 if (0)
Reid Spencer950bf602007-01-26 08:19:09 +00006334 goto yyerrorlab;
6335
Reid Spencerb7046c72007-01-29 05:41:34 +00006336yyvsp -= yylen;
6337 yyssp -= yylen;
Reid Spencer950bf602007-01-26 08:19:09 +00006338 yystate = *yyssp;
6339 goto yyerrlab1;
6340
6341
6342/*-------------------------------------------------------------.
6343| yyerrlab1 -- common code for both syntax error and YYERROR. |
6344`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006345yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006346 yyerrstatus = 3; /* Each real token shifted decrements this. */
6347
6348 for (;;)
6349 {
6350 yyn = yypact[yystate];
6351 if (yyn != YYPACT_NINF)
6352 {
6353 yyn += YYTERROR;
6354 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6355 {
6356 yyn = yytable[yyn];
6357 if (0 < yyn)
6358 break;
6359 }
6360 }
6361
6362 /* Pop the current state because it cannot handle the error token. */
6363 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006364 YYABORT;
6365
6366
Reid Spencerb7046c72007-01-29 05:41:34 +00006367 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6368 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006369 yystate = *yyssp;
6370 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006371 }
6372
6373 if (yyn == YYFINAL)
6374 YYACCEPT;
6375
6376 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006377
6378
Reid Spencerb7046c72007-01-29 05:41:34 +00006379 /* Shift the error token. */
Reid Spencer950bf602007-01-26 08:19:09 +00006380 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6381
Reid Spencere7c3c602006-11-30 06:36:44 +00006382 yystate = yyn;
6383 goto yynewstate;
6384
Chris Lattner37e01c52007-01-04 18:46:42 +00006385
Reid Spencer319a7302007-01-05 17:20:02 +00006386/*-------------------------------------.
6387| yyacceptlab -- YYACCEPT comes here. |
6388`-------------------------------------*/
6389yyacceptlab:
6390 yyresult = 0;
6391 goto yyreturn;
6392
6393/*-----------------------------------.
6394| yyabortlab -- YYABORT comes here. |
6395`-----------------------------------*/
6396yyabortlab:
6397 yyresult = 1;
6398 goto yyreturn;
6399
6400#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006401/*-------------------------------------------------.
6402| yyexhaustedlab -- memory exhaustion comes here. |
6403`-------------------------------------------------*/
6404yyexhaustedlab:
6405 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006406 yyresult = 2;
6407 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006408#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006409
6410yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006411 if (yychar != YYEOF && yychar != YYEMPTY)
6412 yydestruct ("Cleanup: discarding lookahead",
6413 yytoken, &yylval);
6414 while (yyssp != yyss)
6415 {
6416 yydestruct ("Cleanup: popping",
6417 yystos[*yyssp], yyvsp);
Reid Spencerb7046c72007-01-29 05:41:34 +00006418 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006419 }
Reid Spencer319a7302007-01-05 17:20:02 +00006420#ifndef yyoverflow
6421 if (yyss != yyssa)
6422 YYSTACK_FREE (yyss);
6423#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006424 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006425}
Reid Spencer319a7302007-01-05 17:20:02 +00006426
6427
Reid Spencer785a5ae2007-02-08 00:21:40 +00006428#line 3446 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006429
6430
6431int yyerror(const char *ErrorMsg) {
6432 std::string where
6433 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006434 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6435 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6436 if (yychar != YYEMPTY && yychar != 0)
6437 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6438 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006439 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006440 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006441 exit(1);
6442}
Reid Spencer319a7302007-01-05 17:20:02 +00006443
Reid Spencer30d0c582007-01-15 00:26:18 +00006444void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006445 std::string where
6446 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006447 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6448 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6449 if (yychar != YYEMPTY && yychar != 0)
6450 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6451 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006452 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6453}
6454
Reid Spencer950bf602007-01-26 08:19:09 +00006455void error(const std::string& ErrorMsg, int LineNo) {
6456 if (LineNo == -1) LineNo = Upgradelineno;
6457 Upgradelineno = LineNo;
6458 yyerror(ErrorMsg.c_str());
6459}
6460
6461