blob: c93b7e9a465ffb77caa0a3a4a2fb070b60c6cf98 [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 Spencer950bf602007-01-26 08:19:09 +0000534 unsigned NextBBNum;
535
536 inline PerFunctionInfo() {
537 CurrentFunction = 0;
538 isDeclare = false;
539 Linkage = GlobalValue::ExternalLinkage;
540 }
541
542 inline void FunctionStart(Function *M) {
543 CurrentFunction = M;
544 NextBBNum = 0;
545 }
546
547 void FunctionDone() {
548 NumberedBlocks.clear();
549
550 // Any forward referenced blocks left?
551 if (!BBForwardRefs.empty()) {
552 error("Undefined reference to label " +
553 BBForwardRefs.begin()->first->getName());
554 return;
555 }
556
557 // Resolve all forward references now.
558 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
559
560 Values.clear(); // Clear out function local definitions
561 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000562 CurrentFunction = 0;
563 isDeclare = false;
564 Linkage = GlobalValue::ExternalLinkage;
565 }
566} CurFun; // Info for the current function...
567
568static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
569
570
571//===----------------------------------------------------------------------===//
572// Code to handle definitions of all the types
573//===----------------------------------------------------------------------===//
574
575static int InsertValue(Value *V,
576 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
577 if (V->hasName()) return -1; // Is this a numbered definition?
578
579 // Yes, insert the value into the value table...
580 ValueList &List = ValueTab[V->getType()];
581 List.push_back(V);
582 return List.size()-1;
583}
584
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000585static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000586 switch (D.Type) {
587 case ValID::NumberVal: // Is it a numbered definition?
588 // Module constants occupy the lowest numbered slots...
589 if ((unsigned)D.Num < CurModule.Types.size()) {
590 return CurModule.Types[(unsigned)D.Num];
591 }
592 break;
593 case ValID::NameVal: // Is it a named definition?
594 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
595 D.destroy(); // Free old strdup'd memory...
596 return N;
597 }
598 break;
599 default:
600 error("Internal parser error: Invalid symbol type reference");
601 return 0;
602 }
603
604 // If we reached here, we referenced either a symbol that we don't know about
605 // or an id number that hasn't been read yet. We may be referencing something
606 // forward, so just create an entry to be resolved later and get to it...
607 //
608 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
609
610
611 if (inFunctionScope()) {
612 if (D.Type == ValID::NameVal) {
613 error("Reference to an undefined type: '" + D.getName() + "'");
614 return 0;
615 } else {
616 error("Reference to an undefined type: #" + itostr(D.Num));
617 return 0;
618 }
619 }
620
621 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
622 if (I != CurModule.LateResolveTypes.end())
623 return I->second;
624
625 Type *Typ = OpaqueType::get();
626 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
627 return Typ;
628 }
629
Reid Spencered96d1e2007-02-08 09:08:52 +0000630/// This function determines if two function types differ only in their use of
631/// the sret parameter attribute in the first argument. If they are identical
632/// in all other respects, it returns true. Otherwise, it returns false.
633bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
634 const FunctionType *F2) {
635 if (F1->getReturnType() != F2->getReturnType() ||
636 F1->getNumParams() != F2->getNumParams() ||
637 F1->getParamAttrs(0) != F2->getParamAttrs(0))
638 return false;
639 unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute);
640 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
641 if (F1->getParamType(i) != F2->getParamType(i) ||
642 unsigned(F1->getParamAttrs(i+1)) & SRetMask !=
643 unsigned(F2->getParamAttrs(i+1)) & SRetMask)
644 return false;
645 }
646 return true;
647}
648
649// The upgrade of csretcc to sret param attribute may have caused a function
650// to not be found because the param attribute changed the type of the called
651// function. This helper function, used in getExistingValue, detects that
652// situation and returns V if it occurs and 0 otherwise.
653static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
654 // Handle degenerate cases
655 if (!V)
656 return 0;
657 if (V->getType() == Ty)
658 return V;
659
660 Value* Result = 0;
661 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
662 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
663 if (PF1 && PF2) {
664 const FunctionType *FT1 =
665 dyn_cast<FunctionType>(PF1->getElementType());
666 const FunctionType *FT2 =
667 dyn_cast<FunctionType>(PF2->getElementType());
668 if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2))
669 if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute))
670 Result = V;
671 else if (Constant *C = dyn_cast<Constant>(V))
672 Result = ConstantExpr::getBitCast(C, PF1);
673 else
674 Result = new BitCastInst(V, PF1, "upgrd.cast", CurBB);
675 }
676 return Result;
677}
678
Reid Spencer950bf602007-01-26 08:19:09 +0000679// getExistingValue - Look up the value specified by the provided type and
680// the provided ValID. If the value exists and has already been defined, return
681// it. Otherwise return null.
682//
683static Value *getExistingValue(const Type *Ty, const ValID &D) {
684 if (isa<FunctionType>(Ty)) {
685 error("Functions are not values and must be referenced as pointers");
686 }
687
688 switch (D.Type) {
689 case ValID::NumberVal: { // Is it a numbered definition?
690 unsigned Num = (unsigned)D.Num;
691
692 // Module constants occupy the lowest numbered slots...
693 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
694 if (VI != CurModule.Values.end()) {
695 if (Num < VI->second.size())
696 return VI->second[Num];
697 Num -= VI->second.size();
698 }
699
700 // Make sure that our type is within bounds
701 VI = CurFun.Values.find(Ty);
702 if (VI == CurFun.Values.end()) return 0;
703
704 // Check that the number is within bounds...
705 if (VI->second.size() <= Num) return 0;
706
707 return VI->second[Num];
708 }
709
710 case ValID::NameVal: { // Is it a named definition?
711 // Get the name out of the ID
712 std::string Name(D.Name);
713 Value* V = 0;
714 RenameMapKey Key = std::make_pair(Name, Ty);
715 if (inFunctionScope()) {
716 // See if the name was renamed
717 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
718 std::string LookupName;
719 if (I != CurFun.RenameMap.end())
720 LookupName = I->second;
721 else
722 LookupName = Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000723 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
724 V = SymTab.lookup(LookupName);
Reid Spencered96d1e2007-02-08 09:08:52 +0000725 V = handleSRetFuncTypeMerge(V, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +0000726 }
727 if (!V) {
728 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
729 std::string LookupName;
730 if (I != CurModule.RenameMap.end())
731 LookupName = I->second;
732 else
733 LookupName = Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000734 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
Reid Spencered96d1e2007-02-08 09:08:52 +0000735 V = handleSRetFuncTypeMerge(V, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +0000736 }
Reid Spenceref9b9a72007-02-05 20:47:22 +0000737 if (!V)
Reid Spencer950bf602007-01-26 08:19:09 +0000738 return 0;
739
740 D.destroy(); // Free old strdup'd memory...
741 return V;
742 }
743
744 // Check to make sure that "Ty" is an integral type, and that our
745 // value will fit into the specified type...
746 case ValID::ConstSIntVal: // Is it a constant pool reference??
747 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
748 error("Signed integral constant '" + itostr(D.ConstPool64) +
749 "' is invalid for type '" + Ty->getDescription() + "'");
750 }
751 return ConstantInt::get(Ty, D.ConstPool64);
752
753 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
754 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
755 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
756 error("Integral constant '" + utostr(D.UConstPool64) +
757 "' is invalid or out of range");
758 else // This is really a signed reference. Transmogrify.
759 return ConstantInt::get(Ty, D.ConstPool64);
760 } else
761 return ConstantInt::get(Ty, D.UConstPool64);
762
763 case ValID::ConstFPVal: // Is it a floating point const pool reference?
764 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
765 error("FP constant invalid for type");
766 return ConstantFP::get(Ty, D.ConstPoolFP);
767
768 case ValID::ConstNullVal: // Is it a null value?
769 if (!isa<PointerType>(Ty))
770 error("Cannot create a a non pointer null");
771 return ConstantPointerNull::get(cast<PointerType>(Ty));
772
773 case ValID::ConstUndefVal: // Is it an undef value?
774 return UndefValue::get(Ty);
775
776 case ValID::ConstZeroVal: // Is it a zero value?
777 return Constant::getNullValue(Ty);
778
779 case ValID::ConstantVal: // Fully resolved constant?
780 if (D.ConstantValue->getType() != Ty)
781 error("Constant expression type different from required type");
782 return D.ConstantValue;
783
784 case ValID::InlineAsmVal: { // Inline asm expression
785 const PointerType *PTy = dyn_cast<PointerType>(Ty);
786 const FunctionType *FTy =
787 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
788 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
789 error("Invalid type for asm constraint string");
790 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
791 D.IAD->HasSideEffects);
792 D.destroy(); // Free InlineAsmDescriptor.
793 return IA;
794 }
795 default:
796 assert(0 && "Unhandled case");
797 return 0;
798 } // End of switch
799
800 assert(0 && "Unhandled case");
801 return 0;
802}
803
804// getVal - This function is identical to getExistingValue, except that if a
805// value is not already defined, it "improvises" by creating a placeholder var
806// that looks and acts just like the requested variable. When the value is
807// defined later, all uses of the placeholder variable are replaced with the
808// real thing.
809//
810static Value *getVal(const Type *Ty, const ValID &ID) {
811 if (Ty == Type::LabelTy)
812 error("Cannot use a basic block here");
813
814 // See if the value has already been defined.
815 Value *V = getExistingValue(Ty, ID);
816 if (V) return V;
817
818 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
819 error("Invalid use of a composite type");
820
821 // If we reached here, we referenced either a symbol that we don't know about
822 // or an id number that hasn't been read yet. We may be referencing something
823 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000824 V = new Argument(Ty);
825
826 // Remember where this forward reference came from. FIXME, shouldn't we try
827 // to recycle these things??
828 CurModule.PlaceHolderInfo.insert(
Reid Spenceref9b9a72007-02-05 20:47:22 +0000829 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
Reid Spencer950bf602007-01-26 08:19:09 +0000830
831 if (inFunctionScope())
832 InsertValue(V, CurFun.LateResolveValues);
833 else
834 InsertValue(V, CurModule.LateResolveValues);
835 return V;
836}
837
Reid Spencered96d1e2007-02-08 09:08:52 +0000838/// @brief This just makes any name given to it unique, up to MAX_UINT times.
839static std::string makeNameUnique(const std::string& Name) {
840 static unsigned UniqueNameCounter = 1;
841 std::string Result(Name);
842 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
843 return Result;
844}
845
Reid Spencer950bf602007-01-26 08:19:09 +0000846/// getBBVal - This is used for two purposes:
847/// * If isDefinition is true, a new basic block with the specified ID is being
848/// defined.
849/// * If isDefinition is true, this is a reference to a basic block, which may
850/// or may not be a forward reference.
851///
852static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
853 assert(inFunctionScope() && "Can't get basic block at global scope");
854
855 std::string Name;
856 BasicBlock *BB = 0;
857 switch (ID.Type) {
858 default:
859 error("Illegal label reference " + ID.getName());
860 break;
861 case ValID::NumberVal: // Is it a numbered definition?
862 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
863 CurFun.NumberedBlocks.resize(ID.Num+1);
864 BB = CurFun.NumberedBlocks[ID.Num];
865 break;
866 case ValID::NameVal: // Is it a named definition?
867 Name = ID.Name;
868 if (Value *N = CurFun.CurrentFunction->
Reid Spenceref9b9a72007-02-05 20:47:22 +0000869 getValueSymbolTable().lookup(Name)) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000870 if (N->getType() != Type::LabelTy) {
871 // Register names didn't use to conflict with basic block names
872 // because of type planes. Now they all have to be unique. So, we just
873 // rename the register and treat this name as if no basic block
874 // had been found.
875 RenameMapKey Key = std::make_pair(N->getName(),N->getType());
876 N->setName(makeNameUnique(N->getName()));
877 CurModule.RenameMap[Key] = N->getName();
878 BB = 0;
879 } else {
880 BB = cast<BasicBlock>(N);
881 }
Reid Spencer950bf602007-01-26 08:19:09 +0000882 }
883 break;
884 }
885
886 // See if the block has already been defined.
887 if (BB) {
888 // If this is the definition of the block, make sure the existing value was
889 // just a forward reference. If it was a forward reference, there will be
890 // an entry for it in the PlaceHolderInfo map.
891 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
892 // The existing value was a definition, not a forward reference.
893 error("Redefinition of label " + ID.getName());
894
895 ID.destroy(); // Free strdup'd memory.
896 return BB;
897 }
898
899 // Otherwise this block has not been seen before.
900 BB = new BasicBlock("", CurFun.CurrentFunction);
901 if (ID.Type == ValID::NameVal) {
902 BB->setName(ID.Name);
903 } else {
904 CurFun.NumberedBlocks[ID.Num] = BB;
905 }
906
907 // If this is not a definition, keep track of it so we can use it as a forward
908 // reference.
909 if (!isDefinition) {
910 // Remember where this forward reference came from.
911 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
912 } else {
913 // The forward declaration could have been inserted anywhere in the
914 // function: insert it into the correct place now.
915 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
916 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
917 }
918 ID.destroy();
919 return BB;
920}
921
922
923//===----------------------------------------------------------------------===//
924// Code to handle forward references in instructions
925//===----------------------------------------------------------------------===//
926//
927// This code handles the late binding needed with statements that reference
928// values not defined yet... for example, a forward branch, or the PHI node for
929// a loop body.
930//
931// This keeps a table (CurFun.LateResolveValues) of all such forward references
932// and back patchs after we are done.
933//
934
935// ResolveDefinitions - If we could not resolve some defs at parsing
936// time (forward branches, phi functions for loops, etc...) resolve the
937// defs now...
938//
939static void
940ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
941 std::map<const Type*,ValueList> *FutureLateResolvers) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000942
Reid Spencer950bf602007-01-26 08:19:09 +0000943 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
944 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
945 E = LateResolvers.end(); LRI != E; ++LRI) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000946 const Type* Ty = LRI->first;
Reid Spencer950bf602007-01-26 08:19:09 +0000947 ValueList &List = LRI->second;
948 while (!List.empty()) {
949 Value *V = List.back();
950 List.pop_back();
951
952 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
953 CurModule.PlaceHolderInfo.find(V);
954 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
955
956 ValID &DID = PHI->second.first;
957
Reid Spencered96d1e2007-02-08 09:08:52 +0000958 Value *TheRealValue = getExistingValue(Ty, DID);
Reid Spencer950bf602007-01-26 08:19:09 +0000959 if (TheRealValue) {
960 V->replaceAllUsesWith(TheRealValue);
961 delete V;
962 CurModule.PlaceHolderInfo.erase(PHI);
963 } else if (FutureLateResolvers) {
964 // Functions have their unresolved items forwarded to the module late
965 // resolver table
966 InsertValue(V, *FutureLateResolvers);
967 } else {
968 if (DID.Type == ValID::NameVal) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000969 error("Reference to an invalid definition: '" + DID.getName() +
970 "' of type '" + V->getType()->getDescription() + "'",
971 PHI->second.second);
Reid Spencer7de2e012007-01-29 19:08:46 +0000972 return;
Reid Spencer950bf602007-01-26 08:19:09 +0000973 } else {
974 error("Reference to an invalid definition: #" +
975 itostr(DID.Num) + " of type '" +
976 V->getType()->getDescription() + "'", PHI->second.second);
977 return;
978 }
979 }
980 }
981 }
982
983 LateResolvers.clear();
984}
985
986// ResolveTypeTo - A brand new type was just declared. This means that (if
987// name is not null) things referencing Name can be resolved. Otherwise, things
988// refering to the number can be resolved. Do this now.
989//
990static void ResolveTypeTo(char *Name, const Type *ToTy) {
991 ValID D;
992 if (Name) D = ValID::create(Name);
993 else D = ValID::create((int)CurModule.Types.size());
994
995 std::map<ValID, PATypeHolder>::iterator I =
996 CurModule.LateResolveTypes.find(D);
997 if (I != CurModule.LateResolveTypes.end()) {
998 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
999 CurModule.LateResolveTypes.erase(I);
1000 }
1001}
1002
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001003/// This is the implementation portion of TypeHasInteger. It traverses the
1004/// type given, avoiding recursive types, and returns true as soon as it finds
1005/// an integer type. If no integer type is found, it returns false.
1006static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
1007 // Handle some easy cases
1008 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
1009 return false;
1010 if (Ty->isInteger())
1011 return true;
1012 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
1013 return STy->getElementType()->isInteger();
1014
1015 // Avoid type structure recursion
1016 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
1017 I != E; ++I)
1018 if (Ty == *I)
1019 return false;
1020
1021 // Push us on the type stack
1022 Stack.push_back(Ty);
1023
1024 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1025 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1026 return true;
1027 FunctionType::param_iterator I = FTy->param_begin();
1028 FunctionType::param_iterator E = FTy->param_end();
1029 for (; I != E; ++I)
1030 if (TypeHasIntegerI(*I, Stack))
1031 return true;
1032 return false;
1033 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1034 StructType::element_iterator I = STy->element_begin();
1035 StructType::element_iterator E = STy->element_end();
1036 for (; I != E; ++I) {
1037 if (TypeHasIntegerI(*I, Stack))
1038 return true;
1039 }
1040 return false;
1041 }
1042 // There shouldn't be anything else, but its definitely not integer
1043 assert(0 && "What type is this?");
1044 return false;
1045}
1046
1047/// This is the interface to TypeHasIntegerI. It just provides the type stack,
1048/// to avoid recursion, and then calls TypeHasIntegerI.
1049static inline bool TypeHasInteger(const Type *Ty) {
1050 std::vector<const Type*> TyStack;
1051 return TypeHasIntegerI(Ty, TyStack);
1052}
1053
Reid Spencer950bf602007-01-26 08:19:09 +00001054// setValueName - Set the specified value to the name given. The name may be
1055// null potentially, in which case this is a noop. The string passed in is
1056// assumed to be a malloc'd string buffer, and is free'd by this function.
1057//
1058static void setValueName(Value *V, char *NameStr) {
1059 if (NameStr) {
1060 std::string Name(NameStr); // Copy string
1061 free(NameStr); // Free old string
1062
1063 if (V->getType() == Type::VoidTy) {
1064 error("Can't assign name '" + Name + "' to value with void type");
1065 return;
1066 }
1067
Reid Spencer950bf602007-01-26 08:19:09 +00001068 assert(inFunctionScope() && "Must be in function scope");
1069
1070 // Search the function's symbol table for an existing value of this name
Reid Spenceref9b9a72007-02-05 20:47:22 +00001071 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1072 Value* Existing = ST.lookup(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001073 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001074 // An existing value of the same name was found. This might have happened
1075 // because of the integer type planes collapsing in LLVM 2.0.
1076 if (Existing->getType() == V->getType() &&
1077 !TypeHasInteger(Existing->getType())) {
1078 // If the type does not contain any integers in them then this can't be
1079 // a type plane collapsing issue. It truly is a redefinition and we
1080 // should error out as the assembly is invalid.
1081 error("Redefinition of value named '" + Name + "' of type '" +
1082 V->getType()->getDescription() + "'");
1083 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001084 }
1085 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1086 // function, regardless of Type. Previously re-use of names was okay as
1087 // long as they were distinct types. With type planes collapsing because
1088 // of the signedness change and because of PR411, this can no longer be
1089 // supported. We must search the entire symbol table for a conflicting
1090 // name and make the name unique. No warning is needed as this can't
1091 // cause a problem.
1092 std::string NewName = makeNameUnique(Name);
1093 // We're changing the name but it will probably be used by other
1094 // instructions as operands later on. Consequently we have to retain
1095 // a mapping of the renaming that we're doing.
1096 RenameMapKey Key = std::make_pair(Name,V->getType());
1097 CurFun.RenameMap[Key] = NewName;
1098 Name = NewName;
1099 }
1100
1101 // Set the name.
1102 V->setName(Name);
1103 }
1104}
1105
1106/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1107/// this is a declaration, otherwise it is a definition.
1108static GlobalVariable *
1109ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1110 bool isConstantGlobal, const Type *Ty,
1111 Constant *Initializer) {
1112 if (isa<FunctionType>(Ty))
1113 error("Cannot declare global vars of function type");
1114
1115 const PointerType *PTy = PointerType::get(Ty);
1116
1117 std::string Name;
1118 if (NameStr) {
1119 Name = NameStr; // Copy string
1120 free(NameStr); // Free old string
1121 }
1122
1123 // See if this global value was forward referenced. If so, recycle the
1124 // object.
1125 ValID ID;
1126 if (!Name.empty()) {
1127 ID = ValID::create((char*)Name.c_str());
1128 } else {
1129 ID = ValID::create((int)CurModule.Values[PTy].size());
1130 }
1131
1132 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1133 // Move the global to the end of the list, from whereever it was
1134 // previously inserted.
1135 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1136 CurModule.CurrentModule->getGlobalList().remove(GV);
1137 CurModule.CurrentModule->getGlobalList().push_back(GV);
1138 GV->setInitializer(Initializer);
1139 GV->setLinkage(Linkage);
1140 GV->setConstant(isConstantGlobal);
1141 InsertValue(GV, CurModule.Values);
1142 return GV;
1143 }
1144
1145 // If this global has a name, check to see if there is already a definition
1146 // of this global in the module and emit warnings if there are conflicts.
1147 if (!Name.empty()) {
1148 // The global has a name. See if there's an existing one of the same name.
1149 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1150 // We found an existing global ov the same name. This isn't allowed
1151 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1152 // can at least compile. This can happen because of type planes
1153 // There is alread a global of the same name which means there is a
1154 // conflict. Let's see what we can do about it.
1155 std::string NewName(makeNameUnique(Name));
1156 if (Linkage == GlobalValue::InternalLinkage) {
1157 // The linkage type is internal so just warn about the rename without
1158 // invoking "scarey language" about linkage failures. GVars with
1159 // InternalLinkage can be renamed at will.
1160 warning("Global variable '" + Name + "' was renamed to '"+
1161 NewName + "'");
1162 } else {
1163 // The linkage of this gval is external so we can't reliably rename
1164 // it because it could potentially create a linking problem.
1165 // However, we can't leave the name conflict in the output either or
1166 // it won't assemble with LLVM 2.0. So, all we can do is rename
1167 // this one to something unique and emit a warning about the problem.
1168 warning("Renaming global variable '" + Name + "' to '" + NewName +
1169 "' may cause linkage errors");
1170 }
1171
1172 // Put the renaming in the global rename map
1173 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1174 CurModule.RenameMap[Key] = NewName;
1175
1176 // Rename it
1177 Name = NewName;
1178 }
1179 }
1180
1181 // Otherwise there is no existing GV to use, create one now.
1182 GlobalVariable *GV =
1183 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1184 CurModule.CurrentModule);
1185 InsertValue(GV, CurModule.Values);
1186 return GV;
1187}
1188
1189// setTypeName - Set the specified type to the name given. The name may be
1190// null potentially, in which case this is a noop. The string passed in is
1191// assumed to be a malloc'd string buffer, and is freed by this function.
1192//
1193// This function returns true if the type has already been defined, but is
1194// allowed to be redefined in the specified context. If the name is a new name
1195// for the type plane, it is inserted and false is returned.
1196static bool setTypeName(const Type *T, char *NameStr) {
1197 assert(!inFunctionScope() && "Can't give types function-local names");
1198 if (NameStr == 0) return false;
1199
1200 std::string Name(NameStr); // Copy string
1201 free(NameStr); // Free old string
1202
1203 // We don't allow assigning names to void type
1204 if (T == Type::VoidTy) {
1205 error("Can't assign name '" + Name + "' to the void type");
1206 return false;
1207 }
1208
1209 // Set the type name, checking for conflicts as we do so.
1210 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1211
1212 if (AlreadyExists) { // Inserting a name that is already defined???
1213 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1214 assert(Existing && "Conflict but no matching type?");
1215
1216 // There is only one case where this is allowed: when we are refining an
1217 // opaque type. In this case, Existing will be an opaque type.
1218 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1219 // We ARE replacing an opaque type!
1220 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1221 return true;
1222 }
1223
1224 // Otherwise, this is an attempt to redefine a type. That's okay if
1225 // the redefinition is identical to the original. This will be so if
1226 // Existing and T point to the same Type object. In this one case we
1227 // allow the equivalent redefinition.
1228 if (Existing == T) return true; // Yes, it's equal.
1229
1230 // Any other kind of (non-equivalent) redefinition is an error.
1231 error("Redefinition of type named '" + Name + "' in the '" +
1232 T->getDescription() + "' type plane");
1233 }
1234
1235 return false;
1236}
1237
1238//===----------------------------------------------------------------------===//
1239// Code for handling upreferences in type names...
1240//
1241
1242// TypeContains - Returns true if Ty directly contains E in it.
1243//
1244static bool TypeContains(const Type *Ty, const Type *E) {
1245 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1246 E) != Ty->subtype_end();
1247}
1248
1249namespace {
1250 struct UpRefRecord {
1251 // NestingLevel - The number of nesting levels that need to be popped before
1252 // this type is resolved.
1253 unsigned NestingLevel;
1254
1255 // LastContainedTy - This is the type at the current binding level for the
1256 // type. Every time we reduce the nesting level, this gets updated.
1257 const Type *LastContainedTy;
1258
1259 // UpRefTy - This is the actual opaque type that the upreference is
1260 // represented with.
1261 OpaqueType *UpRefTy;
1262
1263 UpRefRecord(unsigned NL, OpaqueType *URTy)
1264 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1265 };
1266}
1267
1268// UpRefs - A list of the outstanding upreferences that need to be resolved.
1269static std::vector<UpRefRecord> UpRefs;
1270
1271/// HandleUpRefs - Every time we finish a new layer of types, this function is
1272/// called. It loops through the UpRefs vector, which is a list of the
1273/// currently active types. For each type, if the up reference is contained in
1274/// the newly completed type, we decrement the level count. When the level
1275/// count reaches zero, the upreferenced type is the type that is passed in:
1276/// thus we can complete the cycle.
1277///
1278static PATypeHolder HandleUpRefs(const Type *ty) {
1279 // If Ty isn't abstract, or if there are no up-references in it, then there is
1280 // nothing to resolve here.
1281 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1282
1283 PATypeHolder Ty(ty);
1284 UR_OUT("Type '" << Ty->getDescription() <<
1285 "' newly formed. Resolving upreferences.\n" <<
1286 UpRefs.size() << " upreferences active!\n");
1287
1288 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1289 // to zero), we resolve them all together before we resolve them to Ty. At
1290 // the end of the loop, if there is anything to resolve to Ty, it will be in
1291 // this variable.
1292 OpaqueType *TypeToResolve = 0;
1293
1294 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1295 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1296 << UpRefs[i].second->getDescription() << ") = "
1297 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1298 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1299 // Decrement level of upreference
1300 unsigned Level = --UpRefs[i].NestingLevel;
1301 UpRefs[i].LastContainedTy = Ty;
1302 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1303 if (Level == 0) { // Upreference should be resolved!
1304 if (!TypeToResolve) {
1305 TypeToResolve = UpRefs[i].UpRefTy;
1306 } else {
1307 UR_OUT(" * Resolving upreference for "
1308 << UpRefs[i].second->getDescription() << "\n";
1309 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1310 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1311 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1312 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1313 }
1314 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1315 --i; // Do not skip the next element...
1316 }
1317 }
1318 }
1319
1320 if (TypeToResolve) {
1321 UR_OUT(" * Resolving upreference for "
1322 << UpRefs[i].second->getDescription() << "\n";
1323 std::string OldName = TypeToResolve->getDescription());
1324 TypeToResolve->refineAbstractTypeTo(Ty);
1325 }
1326
1327 return Ty;
1328}
1329
1330static inline Instruction::TermOps
1331getTermOp(TermOps op) {
1332 switch (op) {
1333 default : assert(0 && "Invalid OldTermOp");
1334 case RetOp : return Instruction::Ret;
1335 case BrOp : return Instruction::Br;
1336 case SwitchOp : return Instruction::Switch;
1337 case InvokeOp : return Instruction::Invoke;
1338 case UnwindOp : return Instruction::Unwind;
1339 case UnreachableOp: return Instruction::Unreachable;
1340 }
1341}
1342
1343static inline Instruction::BinaryOps
1344getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1345 switch (op) {
1346 default : assert(0 && "Invalid OldBinaryOps");
1347 case SetEQ :
1348 case SetNE :
1349 case SetLE :
1350 case SetGE :
1351 case SetLT :
1352 case SetGT : assert(0 && "Should use getCompareOp");
1353 case AddOp : return Instruction::Add;
1354 case SubOp : return Instruction::Sub;
1355 case MulOp : return Instruction::Mul;
1356 case DivOp : {
1357 // This is an obsolete instruction so we must upgrade it based on the
1358 // types of its operands.
1359 bool isFP = Ty->isFloatingPoint();
1360 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1361 // If its a packed type we want to use the element type
1362 isFP = PTy->getElementType()->isFloatingPoint();
1363 if (isFP)
1364 return Instruction::FDiv;
1365 else if (Sign == Signed)
1366 return Instruction::SDiv;
1367 return Instruction::UDiv;
1368 }
1369 case UDivOp : return Instruction::UDiv;
1370 case SDivOp : return Instruction::SDiv;
1371 case FDivOp : return Instruction::FDiv;
1372 case RemOp : {
1373 // This is an obsolete instruction so we must upgrade it based on the
1374 // types of its operands.
1375 bool isFP = Ty->isFloatingPoint();
1376 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1377 // If its a packed type we want to use the element type
1378 isFP = PTy->getElementType()->isFloatingPoint();
1379 // Select correct opcode
1380 if (isFP)
1381 return Instruction::FRem;
1382 else if (Sign == Signed)
1383 return Instruction::SRem;
1384 return Instruction::URem;
1385 }
1386 case URemOp : return Instruction::URem;
1387 case SRemOp : return Instruction::SRem;
1388 case FRemOp : return Instruction::FRem;
Reid Spencer832254e2007-02-02 02:16:23 +00001389 case LShrOp : return Instruction::LShr;
1390 case AShrOp : return Instruction::AShr;
1391 case ShlOp : return Instruction::Shl;
1392 case ShrOp :
1393 if (Sign == Signed)
1394 return Instruction::AShr;
1395 return Instruction::LShr;
Reid Spencer950bf602007-01-26 08:19:09 +00001396 case AndOp : return Instruction::And;
1397 case OrOp : return Instruction::Or;
1398 case XorOp : return Instruction::Xor;
1399 }
1400}
1401
1402static inline Instruction::OtherOps
1403getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1404 Signedness Sign) {
1405 bool isSigned = Sign == Signed;
1406 bool isFP = Ty->isFloatingPoint();
1407 switch (op) {
1408 default : assert(0 && "Invalid OldSetCC");
1409 case SetEQ :
1410 if (isFP) {
1411 predicate = FCmpInst::FCMP_OEQ;
1412 return Instruction::FCmp;
1413 } else {
1414 predicate = ICmpInst::ICMP_EQ;
1415 return Instruction::ICmp;
1416 }
1417 case SetNE :
1418 if (isFP) {
1419 predicate = FCmpInst::FCMP_UNE;
1420 return Instruction::FCmp;
1421 } else {
1422 predicate = ICmpInst::ICMP_NE;
1423 return Instruction::ICmp;
1424 }
1425 case SetLE :
1426 if (isFP) {
1427 predicate = FCmpInst::FCMP_OLE;
1428 return Instruction::FCmp;
1429 } else {
1430 if (isSigned)
1431 predicate = ICmpInst::ICMP_SLE;
1432 else
1433 predicate = ICmpInst::ICMP_ULE;
1434 return Instruction::ICmp;
1435 }
1436 case SetGE :
1437 if (isFP) {
1438 predicate = FCmpInst::FCMP_OGE;
1439 return Instruction::FCmp;
1440 } else {
1441 if (isSigned)
1442 predicate = ICmpInst::ICMP_SGE;
1443 else
1444 predicate = ICmpInst::ICMP_UGE;
1445 return Instruction::ICmp;
1446 }
1447 case SetLT :
1448 if (isFP) {
1449 predicate = FCmpInst::FCMP_OLT;
1450 return Instruction::FCmp;
1451 } else {
1452 if (isSigned)
1453 predicate = ICmpInst::ICMP_SLT;
1454 else
1455 predicate = ICmpInst::ICMP_ULT;
1456 return Instruction::ICmp;
1457 }
1458 case SetGT :
1459 if (isFP) {
1460 predicate = FCmpInst::FCMP_OGT;
1461 return Instruction::FCmp;
1462 } else {
1463 if (isSigned)
1464 predicate = ICmpInst::ICMP_SGT;
1465 else
1466 predicate = ICmpInst::ICMP_UGT;
1467 return Instruction::ICmp;
1468 }
1469 }
1470}
1471
1472static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1473 switch (op) {
1474 default : assert(0 && "Invalid OldMemoryOps");
1475 case MallocOp : return Instruction::Malloc;
1476 case FreeOp : return Instruction::Free;
1477 case AllocaOp : return Instruction::Alloca;
1478 case LoadOp : return Instruction::Load;
1479 case StoreOp : return Instruction::Store;
1480 case GetElementPtrOp : return Instruction::GetElementPtr;
1481 }
1482}
1483
1484static inline Instruction::OtherOps
1485getOtherOp(OtherOps op, Signedness Sign) {
1486 switch (op) {
1487 default : assert(0 && "Invalid OldOtherOps");
1488 case PHIOp : return Instruction::PHI;
1489 case CallOp : return Instruction::Call;
Reid Spencer950bf602007-01-26 08:19:09 +00001490 case SelectOp : return Instruction::Select;
1491 case UserOp1 : return Instruction::UserOp1;
1492 case UserOp2 : return Instruction::UserOp2;
1493 case VAArg : return Instruction::VAArg;
1494 case ExtractElementOp : return Instruction::ExtractElement;
1495 case InsertElementOp : return Instruction::InsertElement;
1496 case ShuffleVectorOp : return Instruction::ShuffleVector;
1497 case ICmpOp : return Instruction::ICmp;
1498 case FCmpOp : return Instruction::FCmp;
Reid Spencer950bf602007-01-26 08:19:09 +00001499 };
1500}
1501
1502static inline Value*
1503getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1504 Signedness DstSign, bool ForceInstruction = false) {
1505 Instruction::CastOps Opcode;
1506 const Type* SrcTy = Src->getType();
1507 if (op == CastOp) {
1508 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1509 // fp -> ptr cast is no longer supported but we must upgrade this
1510 // by doing a double cast: fp -> int -> ptr
1511 SrcTy = Type::Int64Ty;
1512 Opcode = Instruction::IntToPtr;
1513 if (isa<Constant>(Src)) {
1514 Src = ConstantExpr::getCast(Instruction::FPToUI,
1515 cast<Constant>(Src), SrcTy);
1516 } else {
1517 std::string NewName(makeNameUnique(Src->getName()));
1518 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1519 }
1520 } else if (isa<IntegerType>(DstTy) &&
1521 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1522 // cast type %x to bool was previously defined as setne type %x, null
1523 // The cast semantic is now to truncate, not compare so we must retain
1524 // the original intent by replacing the cast with a setne
1525 Constant* Null = Constant::getNullValue(SrcTy);
1526 Instruction::OtherOps Opcode = Instruction::ICmp;
1527 unsigned short predicate = ICmpInst::ICMP_NE;
1528 if (SrcTy->isFloatingPoint()) {
1529 Opcode = Instruction::FCmp;
1530 predicate = FCmpInst::FCMP_ONE;
1531 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1532 error("Invalid cast to bool");
1533 }
1534 if (isa<Constant>(Src) && !ForceInstruction)
1535 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1536 else
1537 return CmpInst::create(Opcode, predicate, Src, Null);
1538 }
1539 // Determine the opcode to use by calling CastInst::getCastOpcode
1540 Opcode =
1541 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1542
1543 } else switch (op) {
1544 default: assert(0 && "Invalid cast token");
1545 case TruncOp: Opcode = Instruction::Trunc; break;
1546 case ZExtOp: Opcode = Instruction::ZExt; break;
1547 case SExtOp: Opcode = Instruction::SExt; break;
1548 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1549 case FPExtOp: Opcode = Instruction::FPExt; break;
1550 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1551 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1552 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1553 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1554 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1555 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1556 case BitCastOp: Opcode = Instruction::BitCast; break;
1557 }
1558
1559 if (isa<Constant>(Src) && !ForceInstruction)
1560 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1561 return CastInst::create(Opcode, Src, DstTy);
1562}
1563
1564static Instruction *
1565upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1566 std::vector<Value*>& Args) {
1567
1568 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1569 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1570 if (Args.size() != 2)
1571 error("Invalid prototype for " + Name + " prototype");
1572 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1573 } else {
Reid Spencer950bf602007-01-26 08:19:09 +00001574 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1575 std::vector<const Type*> Params;
1576 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1577 if (Args.size() != 1)
1578 error("Invalid prototype for " + Name + " prototype");
1579 Params.push_back(PtrTy);
1580 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1581 const PointerType *PFTy = PointerType::get(FTy);
1582 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001583 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
Reid Spencer950bf602007-01-26 08:19:09 +00001584 return new CallInst(Func, Args);
1585 } else if (Name == "llvm.va_copy") {
1586 if (Args.size() != 2)
1587 error("Invalid prototype for " + Name + " prototype");
1588 Params.push_back(PtrTy);
1589 Params.push_back(PtrTy);
1590 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1591 const PointerType *PFTy = PointerType::get(FTy);
1592 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001593 std::string InstName0(makeNameUnique("va0"));
1594 std::string InstName1(makeNameUnique("va1"));
Reid Spencer950bf602007-01-26 08:19:09 +00001595 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1596 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1597 return new CallInst(Func, Args);
1598 }
1599 }
1600 return 0;
1601}
1602
1603const Type* upgradeGEPIndices(const Type* PTy,
1604 std::vector<ValueInfo> *Indices,
1605 std::vector<Value*> &VIndices,
1606 std::vector<Constant*> *CIndices = 0) {
1607 // Traverse the indices with a gep_type_iterator so we can build the list
1608 // of constant and value indices for use later. Also perform upgrades
1609 VIndices.clear();
1610 if (CIndices) CIndices->clear();
1611 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1612 VIndices.push_back((*Indices)[i].V);
1613 generic_gep_type_iterator<std::vector<Value*>::iterator>
1614 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1615 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1616 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1617 Value *Index = VIndices[i];
1618 if (CIndices && !isa<Constant>(Index))
1619 error("Indices to constant getelementptr must be constants");
1620 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1621 // struct indices to i32 struct indices with ZExt for compatibility.
1622 else if (isa<StructType>(*GTI)) { // Only change struct indices
1623 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1624 if (CUI->getType()->getBitWidth() == 8)
1625 Index =
1626 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1627 } else {
1628 // Make sure that unsigned SequentialType indices are zext'd to
1629 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1630 // all indices for SequentialType elements. We must retain the same
1631 // semantic (zext) for unsigned types.
1632 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001633 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001634 if (CIndices)
1635 Index = ConstantExpr::getCast(Instruction::ZExt,
1636 cast<Constant>(Index), Type::Int64Ty);
1637 else
1638 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001639 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001640 VIndices[i] = Index;
1641 }
Reid Spencer950bf602007-01-26 08:19:09 +00001642 }
1643 // Add to the CIndices list, if requested.
1644 if (CIndices)
1645 CIndices->push_back(cast<Constant>(Index));
1646 }
1647
1648 const Type *IdxTy =
1649 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1650 if (!IdxTy)
1651 error("Index list invalid for constant getelementptr");
1652 return IdxTy;
1653}
1654
Reid Spencerb7046c72007-01-29 05:41:34 +00001655unsigned upgradeCallingConv(unsigned CC) {
1656 switch (CC) {
1657 case OldCallingConv::C : return CallingConv::C;
1658 case OldCallingConv::CSRet : return CallingConv::C;
1659 case OldCallingConv::Fast : return CallingConv::Fast;
1660 case OldCallingConv::Cold : return CallingConv::Cold;
1661 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1662 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1663 default:
1664 return CC;
1665 }
1666}
1667
Reid Spencer950bf602007-01-26 08:19:09 +00001668Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1669 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001670{
1671 Upgradelineno = 1;
1672 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001673 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001674 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001675 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001676 ObsoleteVarArgs = false;
1677 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001678
Reid Spencer950bf602007-01-26 08:19:09 +00001679 CurModule.CurrentModule = new Module(CurFilename);
1680
1681 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001682 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001683 if (ParserResult)
1684 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001685 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001686 return 0;
1687 }
1688
Reid Spencer950bf602007-01-26 08:19:09 +00001689 // Check to make sure that parsing produced a result
1690 if (!ParserResult) {
1691 std::cerr << "llvm-upgrade: no parse result.\n";
1692 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001693 }
1694
Reid Spencer950bf602007-01-26 08:19:09 +00001695 // Reset ParserResult variable while saving its value for the result.
1696 Module *Result = ParserResult;
1697 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001698
Reid Spencer950bf602007-01-26 08:19:09 +00001699 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001700 {
Reid Spencer950bf602007-01-26 08:19:09 +00001701 Function* F;
Reid Spencer688b0492007-02-05 21:19:13 +00001702 if ((F = Result->getFunction("llvm.va_start"))
Reid Spencer950bf602007-01-26 08:19:09 +00001703 && F->getFunctionType()->getNumParams() == 0)
1704 ObsoleteVarArgs = true;
Reid Spencer688b0492007-02-05 21:19:13 +00001705 if((F = Result->getFunction("llvm.va_copy"))
Reid Spencer950bf602007-01-26 08:19:09 +00001706 && F->getFunctionType()->getNumParams() == 1)
1707 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001708 }
Reid Spencer319a7302007-01-05 17:20:02 +00001709
Reid Spencer950bf602007-01-26 08:19:09 +00001710 if (ObsoleteVarArgs && NewVarArgs) {
1711 error("This file is corrupt: it uses both new and old style varargs");
1712 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001713 }
Reid Spencer319a7302007-01-05 17:20:02 +00001714
Reid Spencer950bf602007-01-26 08:19:09 +00001715 if(ObsoleteVarArgs) {
Reid Spencer688b0492007-02-05 21:19:13 +00001716 if(Function* F = Result->getFunction("llvm.va_start")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001717 if (F->arg_size() != 0) {
1718 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001719 return 0;
1720 }
Reid Spencer950bf602007-01-26 08:19:09 +00001721
1722 //foo = va_start()
1723 // ->
1724 //bar = alloca typeof(foo)
1725 //va_start(bar)
1726 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001727
Reid Spencer950bf602007-01-26 08:19:09 +00001728 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1729 const Type* ArgTy = F->getFunctionType()->getReturnType();
1730 const Type* ArgTyPtr = PointerType::get(ArgTy);
1731 Function* NF = cast<Function>(Result->getOrInsertFunction(
1732 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1733
1734 while (!F->use_empty()) {
1735 CallInst* CI = cast<CallInst>(F->use_back());
1736 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1737 new CallInst(NF, bar, "", CI);
1738 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1739 CI->replaceAllUsesWith(foo);
1740 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001741 }
Reid Spencer950bf602007-01-26 08:19:09 +00001742 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001743 }
Reid Spencer950bf602007-01-26 08:19:09 +00001744
Reid Spencer688b0492007-02-05 21:19:13 +00001745 if(Function* F = Result->getFunction("llvm.va_end")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001746 if(F->arg_size() != 1) {
1747 error("Obsolete va_end takes 1 argument");
1748 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001749 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001750
Reid Spencer950bf602007-01-26 08:19:09 +00001751 //vaend foo
1752 // ->
1753 //bar = alloca 1 of typeof(foo)
1754 //vaend bar
1755 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1756 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1757 const Type* ArgTyPtr = PointerType::get(ArgTy);
1758 Function* NF = cast<Function>(Result->getOrInsertFunction(
1759 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001760
Reid Spencer950bf602007-01-26 08:19:09 +00001761 while (!F->use_empty()) {
1762 CallInst* CI = cast<CallInst>(F->use_back());
1763 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1764 new StoreInst(CI->getOperand(1), bar, CI);
1765 new CallInst(NF, bar, "", CI);
1766 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001767 }
Reid Spencer950bf602007-01-26 08:19:09 +00001768 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001769 }
Reid Spencer950bf602007-01-26 08:19:09 +00001770
Reid Spencer688b0492007-02-05 21:19:13 +00001771 if(Function* F = Result->getFunction("llvm.va_copy")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001772 if(F->arg_size() != 1) {
1773 error("Obsolete va_copy takes 1 argument");
1774 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001775 }
Reid Spencer950bf602007-01-26 08:19:09 +00001776 //foo = vacopy(bar)
1777 // ->
1778 //a = alloca 1 of typeof(foo)
1779 //b = alloca 1 of typeof(foo)
1780 //store bar -> b
1781 //vacopy(a, b)
1782 //foo = load a
1783
1784 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1785 const Type* ArgTy = F->getFunctionType()->getReturnType();
1786 const Type* ArgTyPtr = PointerType::get(ArgTy);
1787 Function* NF = cast<Function>(Result->getOrInsertFunction(
1788 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001789
Reid Spencer950bf602007-01-26 08:19:09 +00001790 while (!F->use_empty()) {
1791 CallInst* CI = cast<CallInst>(F->use_back());
1792 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1793 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1794 new StoreInst(CI->getOperand(1), b, CI);
1795 new CallInst(NF, a, b, "", CI);
1796 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1797 CI->replaceAllUsesWith(foo);
1798 CI->getParent()->getInstList().erase(CI);
1799 }
1800 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001801 }
1802 }
1803
Reid Spencer52402b02007-01-02 05:45:11 +00001804 return Result;
1805}
1806
Reid Spencer950bf602007-01-26 08:19:09 +00001807} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001808
Reid Spencer950bf602007-01-26 08:19:09 +00001809using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001810
1811
Reid Spencer319a7302007-01-05 17:20:02 +00001812
1813/* Enabling traces. */
1814#ifndef YYDEBUG
1815# define YYDEBUG 0
1816#endif
1817
1818/* Enabling verbose error messages. */
1819#ifdef YYERROR_VERBOSE
1820# undef YYERROR_VERBOSE
1821# define YYERROR_VERBOSE 1
1822#else
1823# define YYERROR_VERBOSE 0
1824#endif
1825
Reid Spencer950bf602007-01-26 08:19:09 +00001826/* Enabling the token table. */
1827#ifndef YYTOKEN_TABLE
1828# define YYTOKEN_TABLE 0
1829#endif
1830
Reid Spencerb7046c72007-01-29 05:41:34 +00001831#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencered96d1e2007-02-08 09:08:52 +00001832#line 1453 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00001833typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00001834 llvm::Module *ModuleVal;
1835 llvm::Function *FunctionVal;
1836 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1837 llvm::BasicBlock *BasicBlockVal;
1838 llvm::TerminatorInst *TermInstVal;
1839 llvm::InstrInfo InstVal;
1840 llvm::ConstInfo ConstVal;
1841 llvm::ValueInfo ValueVal;
1842 llvm::PATypeInfo TypeVal;
1843 llvm::TypeInfo PrimType;
1844 llvm::PHIListInfo PHIList;
1845 std::list<llvm::PATypeInfo> *TypeList;
1846 std::vector<llvm::ValueInfo> *ValueList;
1847 std::vector<llvm::ConstInfo> *ConstVector;
1848
1849
1850 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1851 // Represent the RHS of PHI node
1852 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1853
1854 llvm::GlobalValue::LinkageTypes Linkage;
1855 int64_t SInt64Val;
1856 uint64_t UInt64Val;
1857 int SIntVal;
1858 unsigned UIntVal;
1859 double FPVal;
1860 bool BoolVal;
1861
1862 char *StrVal; // This memory is strdup'd!
1863 llvm::ValID ValIDVal; // strdup'd memory maybe!
1864
1865 llvm::BinaryOps BinaryOpVal;
1866 llvm::TermOps TermOpVal;
1867 llvm::MemoryOps MemOpVal;
1868 llvm::OtherOps OtherOpVal;
1869 llvm::CastOps CastOpVal;
1870 llvm::ICmpInst::Predicate IPred;
1871 llvm::FCmpInst::Predicate FPred;
1872 llvm::Module::Endianness Endianness;
Reid Spencerb7046c72007-01-29 05:41:34 +00001873} YYSTYPE;
1874/* Line 196 of yacc.c. */
Reid Spencered96d1e2007-02-08 09:08:52 +00001875#line 1876 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001876# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1877# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001878# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001879#endif
1880
Reid Spencer950bf602007-01-26 08:19:09 +00001881
Reid Spencere7c3c602006-11-30 06:36:44 +00001882
Reid Spencer319a7302007-01-05 17:20:02 +00001883/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001884
1885
Reid Spencerb7046c72007-01-29 05:41:34 +00001886/* Line 219 of yacc.c. */
Reid Spencered96d1e2007-02-08 09:08:52 +00001887#line 1888 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001888
Reid Spencerb7046c72007-01-29 05:41:34 +00001889#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1890# define YYSIZE_T __SIZE_TYPE__
Reid Spencer950bf602007-01-26 08:19:09 +00001891#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001892#if ! defined (YYSIZE_T) && defined (size_t)
1893# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001894#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001895#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1896# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1897# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001898#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001899#if ! defined (YYSIZE_T)
1900# define YYSIZE_T unsigned int
Reid Spencer950bf602007-01-26 08:19:09 +00001901#endif
1902
1903#ifndef YY_
1904# if YYENABLE_NLS
1905# if ENABLE_NLS
1906# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1907# define YY_(msgid) dgettext ("bison-runtime", msgid)
1908# endif
1909# endif
1910# ifndef YY_
1911# define YY_(msgid) msgid
1912# endif
1913#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001914
Reid Spencerb7046c72007-01-29 05:41:34 +00001915#if ! defined (yyoverflow) || YYERROR_VERBOSE
Reid Spencer319a7302007-01-05 17:20:02 +00001916
1917/* The parser invokes alloca or malloc; define the necessary symbols. */
1918
Reid Spencer950bf602007-01-26 08:19:09 +00001919# ifdef YYSTACK_USE_ALLOCA
1920# if YYSTACK_USE_ALLOCA
1921# ifdef __GNUC__
1922# define YYSTACK_ALLOC __builtin_alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001923# else
Reid Spencer950bf602007-01-26 08:19:09 +00001924# define YYSTACK_ALLOC alloca
Reid Spencerb7046c72007-01-29 05:41:34 +00001925# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00001926# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Reid Spencerb7046c72007-01-29 05:41:34 +00001927# define YYINCLUDED_STDLIB_H
Reid Spencer319a7302007-01-05 17:20:02 +00001928# endif
1929# endif
1930# endif
1931# endif
1932
1933# ifdef YYSTACK_ALLOC
Reid Spencerb7046c72007-01-29 05:41:34 +00001934 /* Pacify GCC's `empty if-body' warning. */
1935# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00001936# ifndef YYSTACK_ALLOC_MAXIMUM
1937 /* The OS might guarantee only one guard page at the bottom of the stack,
1938 and a page size can be as small as 4096 bytes. So we cannot safely
1939 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1940 to allow for a few compiler-allocated temporary stack slots. */
Reid Spencerb7046c72007-01-29 05:41:34 +00001941# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer319a7302007-01-05 17:20:02 +00001942# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001943# else
1944# define YYSTACK_ALLOC YYMALLOC
1945# define YYSTACK_FREE YYFREE
1946# ifndef YYSTACK_ALLOC_MAXIMUM
Reid Spencerb7046c72007-01-29 05:41:34 +00001947# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
Reid Spencer950bf602007-01-26 08:19:09 +00001948# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001949# ifdef __cplusplus
1950extern "C" {
Reid Spencer950bf602007-01-26 08:19:09 +00001951# endif
1952# ifndef YYMALLOC
1953# define YYMALLOC malloc
Reid Spencerb7046c72007-01-29 05:41:34 +00001954# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1955 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001956void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1957# endif
1958# endif
1959# ifndef YYFREE
1960# define YYFREE free
Reid Spencerb7046c72007-01-29 05:41:34 +00001961# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1962 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001963void free (void *); /* INFRINGES ON USER NAME SPACE */
1964# endif
1965# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001966# ifdef __cplusplus
1967}
1968# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001969# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001970#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00001971
1972
Reid Spencerb7046c72007-01-29 05:41:34 +00001973#if (! defined (yyoverflow) \
1974 && (! defined (__cplusplus) \
1975 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001976
1977/* A type that is properly aligned for any stack member. */
1978union yyalloc
1979{
Reid Spencerb7046c72007-01-29 05:41:34 +00001980 short int yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001981 YYSTYPE yyvs;
1982 };
1983
1984/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00001985# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00001986
1987/* The size of an array large to enough to hold all stacks, each with
1988 N elements. */
1989# define YYSTACK_BYTES(N) \
Reid Spencerb7046c72007-01-29 05:41:34 +00001990 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer950bf602007-01-26 08:19:09 +00001991 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00001992
1993/* Copy COUNT objects from FROM to TO. The source and destination do
1994 not overlap. */
1995# ifndef YYCOPY
Reid Spencerb7046c72007-01-29 05:41:34 +00001996# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00001997# define YYCOPY(To, From, Count) \
1998 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1999# else
2000# define YYCOPY(To, From, Count) \
2001 do \
2002 { \
Reid Spencer950bf602007-01-26 08:19:09 +00002003 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00002004 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00002005 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00002006 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00002007 while (0)
Reid Spencer319a7302007-01-05 17:20:02 +00002008# endif
2009# endif
2010
2011/* Relocate STACK from its old location to the new one. The
2012 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2013 elements in the stack, and YYPTR gives the new location of the
2014 stack. Advance YYPTR to a properly aligned location for the next
2015 stack. */
2016# define YYSTACK_RELOCATE(Stack) \
2017 do \
2018 { \
2019 YYSIZE_T yynewbytes; \
2020 YYCOPY (&yyptr->Stack, Stack, yysize); \
2021 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00002022 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00002023 yyptr += yynewbytes / sizeof (*yyptr); \
2024 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00002025 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00002026
2027#endif
2028
Reid Spencerb7046c72007-01-29 05:41:34 +00002029#if defined (__STDC__) || defined (__cplusplus)
2030 typedef signed char yysigned_char;
2031#else
2032 typedef short int yysigned_char;
2033#endif
2034
2035/* YYFINAL -- State number of the termination state. */
Reid Spencer319a7302007-01-05 17:20:02 +00002036#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00002037/* YYLAST -- Last index in YYTABLE. */
Reid Spencered96d1e2007-02-08 09:08:52 +00002038#define YYLAST 1762
Reid Spencer319a7302007-01-05 17:20:02 +00002039
Reid Spencerb7046c72007-01-29 05:41:34 +00002040/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002041#define YYNTOKENS 166
Reid Spencerb7046c72007-01-29 05:41:34 +00002042/* YYNNTS -- Number of nonterminals. */
Reid Spencered96d1e2007-02-08 09:08:52 +00002043#define YYNNTS 80
Reid Spencerb7046c72007-01-29 05:41:34 +00002044/* YYNRULES -- Number of rules. */
Reid Spencered96d1e2007-02-08 09:08:52 +00002045#define YYNRULES 309
Reid Spencerb7046c72007-01-29 05:41:34 +00002046/* YYNRULES -- Number of states. */
Reid Spencered96d1e2007-02-08 09:08:52 +00002047#define YYNSTATES 605
Reid Spencer319a7302007-01-05 17:20:02 +00002048
2049/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2050#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00002051#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00002052
Reid Spencer950bf602007-01-26 08:19:09 +00002053#define YYTRANSLATE(YYX) \
2054 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00002055
2056/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002057static const unsigned char yytranslate[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002058{
2059 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2060 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2061 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2062 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002063 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002064 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002065 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002066 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2067 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002068 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002071 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002072 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2073 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2074 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2075 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2077 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2079 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2080 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2081 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2082 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2084 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2085 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2086 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2087 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2088 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2089 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2090 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2091 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2092 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2093 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2094 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2095 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2096 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2097 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2098 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002099 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002100};
2101
2102#if YYDEBUG
2103/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2104 YYRHS. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002105static const unsigned short int yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002106{
2107 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2108 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2109 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2110 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2111 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2112 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2113 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2114 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2115 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002116 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002117 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2118 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2119 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2120 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2121 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002122 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2123 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2124 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2125 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2126 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2127 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2128 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2129 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
Reid Spencered96d1e2007-02-08 09:08:52 +00002130 650, 652, 653, 654, 660, 661, 663, 665, 667, 669,
2131 671, 673, 675, 677, 679, 683, 685, 691, 693, 695,
2132 697, 699, 702, 705, 708, 712, 715, 716, 718, 720,
2133 722, 725, 728, 732, 742, 752, 761, 775, 777, 779,
2134 786, 792, 795, 802, 810, 812, 816, 818, 819, 822,
2135 824, 830, 836, 842, 849, 856, 859, 864, 869, 876,
2136 881, 886, 891, 896, 903, 910, 913, 921, 923, 926,
2137 927, 929, 930, 934, 941, 945, 952, 955, 960, 967
Reid Spencer319a7302007-01-05 17:20:02 +00002138};
2139
Reid Spencerb7046c72007-01-29 05:41:34 +00002140/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2141static const short int yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002142{
Reid Spencer950bf602007-01-26 08:19:09 +00002143 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002144 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2145 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
Reid Spencer832254e2007-02-02 02:16:23 +00002146 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2147 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
Reid Spencer950bf602007-01-26 08:19:09 +00002148 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2149 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2150 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2151 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2152 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
Reid Spencer832254e2007-02-02 02:16:23 +00002153 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
Reid Spencer950bf602007-01-26 08:19:09 +00002154 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2155 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2156 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2157 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2158 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2159 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2160 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2161 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2162 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2163 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2164 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2165 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002166 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002167 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
Reid Spencered96d1e2007-02-08 09:08:52 +00002168 -1, 19, -1, 21, -1, 192, -1, 48, -1, 228,
Reid Spencer950bf602007-01-26 08:19:09 +00002169 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2170 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2171 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2172 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2173 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2174 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2175 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2176 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2177 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2178 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002179 191, 39, -1, 191, 228, -1, 191, 197, -1, 191,
Reid Spencer950bf602007-01-26 08:19:09 +00002180 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2181 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
Reid Spencered96d1e2007-02-08 09:08:52 +00002182 36, 191, 156, -1, 110, 155, 196, 243, 156, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002183 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
Reid Spencer950bf602007-01-26 08:19:09 +00002184 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2185 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002186 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
Reid Spencer950bf602007-01-26 08:19:09 +00002187 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2188 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2189 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2190 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2191 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2192 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2193 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2194 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2195 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2196 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2197 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2198 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2199 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2200 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2201 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2202 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2203 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2204 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2205 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2206 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002207 30, -1, 163, -1, 231, 220, -1, -1, 45, -1,
2208 47, -1, -1, -1, 31, 224, 222, 225, 217, -1,
2209 -1, 63, -1, 3, -1, 4, -1, 7, -1, 27,
2210 -1, 28, -1, 38, -1, 39, -1, 26, -1, 160,
2211 198, 161, -1, 197, -1, 61, 226, 24, 153, 24,
2212 -1, 167, -1, 212, -1, 228, -1, 227, -1, 191,
2213 229, -1, 231, 232, -1, 219, 232, -1, 233, 180,
2214 235, -1, 233, 237, -1, -1, 23, -1, 77, -1,
2215 78, -1, 72, 230, -1, 72, 8, -1, 73, 21,
2216 229, -1, 73, 9, 229, 153, 21, 229, 153, 21,
2217 229, -1, 74, 178, 229, 153, 21, 229, 157, 236,
2218 159, -1, 74, 178, 229, 153, 21, 229, 157, 159,
2219 -1, 75, 182, 189, 229, 155, 240, 156, 36, 21,
2220 229, 234, 21, 229, -1, 234, -1, 76, -1, 236,
2221 178, 227, 153, 21, 229, -1, 178, 227, 153, 21,
2222 229, -1, 180, 242, -1, 191, 157, 229, 153, 229,
2223 159, -1, 238, 153, 157, 229, 153, 229, 159, -1,
2224 230, -1, 239, 153, 230, -1, 239, -1, -1, 60,
2225 59, -1, 59, -1, 169, 191, 229, 153, 229, -1,
2226 170, 191, 229, 153, 229, -1, 171, 191, 229, 153,
2227 229, -1, 103, 172, 191, 229, 153, 229, -1, 104,
2228 173, 191, 229, 153, 229, -1, 49, 230, -1, 174,
2229 230, 153, 230, -1, 175, 230, 36, 191, -1, 112,
2230 230, 153, 230, 153, 230, -1, 113, 230, 153, 191,
2231 -1, 117, 230, 153, 191, -1, 118, 230, 153, 191,
2232 -1, 114, 230, 153, 230, -1, 115, 230, 153, 230,
2233 153, 230, -1, 116, 230, 153, 230, 153, 230, -1,
2234 111, 238, -1, 241, 182, 189, 229, 155, 240, 156,
2235 -1, 245, -1, 153, 239, -1, -1, 35, -1, -1,
2236 105, 191, 184, -1, 105, 191, 153, 15, 229, 184,
2237 -1, 106, 191, 184, -1, 106, 191, 153, 15, 229,
2238 184, -1, 107, 230, -1, 244, 108, 191, 229, -1,
2239 244, 109, 230, 153, 191, 229, -1, 110, 191, 229,
2240 243, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002241};
2242
2243/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002244static const unsigned short int yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002245{
Reid Spencered96d1e2007-02-08 09:08:52 +00002246 0, 1593, 1593, 1594, 1602, 1603, 1613, 1613, 1613, 1613,
2247 1613, 1613, 1613, 1613, 1613, 1613, 1613, 1617, 1617, 1617,
2248 1621, 1621, 1621, 1621, 1621, 1621, 1625, 1625, 1626, 1626,
2249 1627, 1627, 1628, 1628, 1629, 1629, 1633, 1633, 1634, 1634,
2250 1635, 1635, 1636, 1636, 1637, 1637, 1638, 1638, 1639, 1639,
2251 1640, 1641, 1644, 1644, 1644, 1644, 1648, 1648, 1648, 1648,
2252 1648, 1648, 1648, 1649, 1649, 1649, 1649, 1649, 1649, 1655,
2253 1655, 1655, 1655, 1659, 1659, 1659, 1659, 1663, 1663, 1667,
2254 1667, 1672, 1675, 1680, 1681, 1682, 1683, 1684, 1685, 1686,
2255 1687, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1708,
2256 1709, 1717, 1718, 1726, 1735, 1736, 1743, 1744, 1748, 1752,
2257 1768, 1769, 1776, 1777, 1784, 1792, 1792, 1792, 1792, 1792,
2258 1792, 1792, 1793, 1793, 1793, 1793, 1793, 1798, 1802, 1806,
2259 1811, 1820, 1837, 1843, 1856, 1865, 1869, 1880, 1884, 1897,
2260 1901, 1908, 1909, 1915, 1922, 1934, 1964, 1977, 2000, 2028,
2261 2050, 2061, 2083, 2094, 2103, 2108, 2166, 2173, 2181, 2188,
2262 2195, 2199, 2203, 2212, 2227, 2240, 2249, 2277, 2290, 2299,
2263 2305, 2311, 2322, 2328, 2334, 2345, 2346, 2355, 2356, 2368,
2264 2377, 2378, 2379, 2380, 2381, 2397, 2417, 2419, 2421, 2421,
2265 2428, 2428, 2435, 2435, 2442, 2442, 2450, 2452, 2454, 2459,
2266 2473, 2474, 2478, 2481, 2489, 2493, 2500, 2504, 2508, 2512,
2267 2520, 2520, 2524, 2525, 2529, 2537, 2542, 2550, 2551, 2558,
2268 2565, 2569, 2745, 2745, 2749, 2759, 2759, 2763, 2768, 2769,
2269 2770, 2774, 2775, 2774, 2787, 2788, 2793, 2794, 2795, 2796,
2270 2797, 2798, 2799, 2800, 2801, 2822, 2825, 2840, 2841, 2846,
2271 2846, 2854, 2863, 2866, 2875, 2885, 2890, 2899, 2910, 2910,
2272 2913, 2916, 2919, 2923, 2929, 2944, 2950, 3006, 3009, 3015,
2273 3025, 3038, 3067, 3075, 3083, 3087, 3094, 3095, 3099, 3102,
2274 3108, 3125, 3141, 3155, 3167, 3179, 3190, 3208, 3217, 3226,
2275 3233, 3254, 3278, 3284, 3290, 3296, 3312, 3390, 3398, 3399,
2276 3403, 3404, 3408, 3414, 3420, 3426, 3432, 3439, 3451, 3476
Reid Spencer319a7302007-01-05 17:20:02 +00002277};
2278#endif
2279
Reid Spencer950bf602007-01-26 08:19:09 +00002280#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2281/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencerb7046c72007-01-29 05:41:34 +00002282 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer319a7302007-01-05 17:20:02 +00002283static const char *const yytname[] =
2284{
Reid Spencer950bf602007-01-26 08:19:09 +00002285 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2286 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2287 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2288 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2289 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2290 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2291 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2292 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2293 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2294 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2295 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2296 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2297 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2298 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
Reid Spencer832254e2007-02-02 02:16:23 +00002299 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2300 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2301 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2302 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
Reid Spencer950bf602007-01-26 08:19:09 +00002303 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2304 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2305 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2306 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2307 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2308 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2309 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2310 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2311 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2312 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2313 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2314 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2315 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2316 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2317 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2318 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
Reid Spencered96d1e2007-02-08 09:08:52 +00002319 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5", "@6",
Reid Spencer950bf602007-01-26 08:19:09 +00002320 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2321 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2322 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2323 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002324 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002325};
2326#endif
2327
2328# ifdef YYPRINT
2329/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2330 token YYLEX-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002331static const unsigned short int yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002332{
2333 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2334 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2335 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2336 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2337 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2338 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2339 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2340 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2341 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2342 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2343 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2344 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2345 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2346 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2347 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002348 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2349 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002350};
2351# endif
2352
2353/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002354static const unsigned char yyr1[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002355{
Reid Spencer950bf602007-01-26 08:19:09 +00002356 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2357 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2358 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2359 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2360 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2361 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2362 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2363 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2364 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2365 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2366 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2367 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2368 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2369 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2370 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2371 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2372 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2373 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2374 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2375 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2376 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2377 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2378 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
Reid Spencered96d1e2007-02-08 09:08:52 +00002379 222, 224, 225, 223, 226, 226, 227, 227, 227, 227,
2380 227, 227, 227, 227, 227, 227, 227, 228, 228, 229,
2381 229, 230, 231, 231, 232, 233, 233, 233, 234, 234,
2382 235, 235, 235, 235, 235, 235, 235, 235, 235, 236,
2383 236, 237, 238, 238, 239, 239, 240, 240, 241, 241,
2384 242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
2385 242, 242, 242, 242, 242, 242, 242, 242, 243, 243,
2386 244, 244, 245, 245, 245, 245, 245, 245, 245, 245
Reid Spencer319a7302007-01-05 17:20:02 +00002387};
2388
2389/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002390static const unsigned char yyr2[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002391{
2392 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2393 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2398 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2399 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2400 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002401 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002402 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2405 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2406 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002407 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2408 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2409 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2410 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2411 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2412 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2413 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2414 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002415 1, 0, 0, 5, 0, 1, 1, 1, 1, 1,
2416 1, 1, 1, 1, 3, 1, 5, 1, 1, 1,
2417 1, 2, 2, 2, 3, 2, 0, 1, 1, 1,
2418 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
2419 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
2420 5, 5, 5, 6, 6, 2, 4, 4, 6, 4,
2421 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
2422 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002423};
2424
2425/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2426 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2427 means the default is an error. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002428static const unsigned short int yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002429{
Reid Spencer950bf602007-01-26 08:19:09 +00002430 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
Reid Spencered96d1e2007-02-08 09:08:52 +00002431 86, 87, 88, 89, 0, 91, 256, 180, 181, 256,
Reid Spencer950bf602007-01-26 08:19:09 +00002432 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002433 0, 92, 93, 94, 95, 96, 97, 0, 0, 257,
2434 253, 82, 225, 226, 227, 252, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002435 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
Reid Spencered96d1e2007-02-08 09:08:52 +00002436 230, 232, 199, 182, 98, 2, 3, 111, 115, 116,
Reid Spencer950bf602007-01-26 08:19:09 +00002437 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
Reid Spencered96d1e2007-02-08 09:08:52 +00002438 128, 0, 0, 0, 0, 247, 0, 0, 110, 127,
2439 114, 248, 129, 222, 223, 224, 301, 255, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002440 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002441 0, 0, 91, 130, 0, 0, 0, 113, 135, 139,
2442 0, 0, 144, 138, 300, 0, 279, 0, 0, 0,
2443 0, 91, 268, 258, 259, 6, 7, 8, 9, 10,
Reid Spencer832254e2007-02-02 02:16:23 +00002444 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2445 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2446 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002447 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2448 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002449 0, 267, 254, 91, 271, 0, 297, 204, 201, 200,
Reid Spencer950bf602007-01-26 08:19:09 +00002450 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2451 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002452 0, 0, 0, 188, 233, 0, 0, 0, 0, 0,
2453 134, 220, 143, 141, 0, 0, 285, 278, 261, 260,
2454 0, 0, 72, 76, 71, 75, 70, 74, 69, 73,
2455 77, 78, 0, 0, 26, 27, 28, 29, 30, 31,
2456 32, 33, 34, 35, 0, 50, 51, 46, 47, 48,
2457 49, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2458 45, 0, 101, 101, 306, 0, 0, 295, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002459 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002460 0, 0, 0, 0, 206, 106, 106, 106, 160, 161,
2461 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002462 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002463 0, 0, 0, 0, 156, 155, 106, 112, 112, 137,
2464 0, 140, 219, 213, 216, 217, 0, 0, 131, 236,
2465 237, 238, 243, 239, 240, 241, 242, 234, 0, 245,
2466 250, 249, 251, 0, 262, 0, 0, 0, 0, 0,
2467 302, 0, 304, 299, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002468 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002469 0, 207, 0, 193, 195, 191, 0, 0, 0, 0,
2470 0, 0, 0, 146, 176, 0, 0, 0, 150, 0,
2471 147, 0, 0, 0, 0, 0, 189, 132, 133, 136,
2472 212, 214, 0, 104, 142, 235, 0, 0, 0, 0,
2473 0, 0, 0, 0, 0, 0, 0, 309, 0, 0,
2474 0, 289, 292, 0, 0, 290, 291, 0, 0, 0,
2475 286, 287, 0, 307, 0, 0, 0, 108, 106, 0,
2476 0, 299, 0, 0, 0, 0, 0, 145, 135, 114,
2477 0, 148, 149, 0, 0, 0, 0, 0, 218, 215,
2478 105, 99, 0, 244, 0, 0, 277, 0, 0, 101,
2479 102, 101, 274, 298, 0, 0, 0, 0, 0, 280,
2480 281, 282, 277, 0, 103, 109, 107, 0, 0, 0,
2481 0, 0, 0, 0, 175, 152, 0, 0, 0, 0,
2482 0, 0, 0, 221, 0, 0, 0, 276, 0, 283,
2483 284, 0, 303, 305, 0, 0, 0, 288, 293, 294,
2484 0, 308, 0, 0, 164, 0, 0, 0, 0, 151,
2485 0, 0, 0, 0, 0, 100, 246, 0, 0, 0,
2486 275, 272, 0, 296, 0, 0, 0, 172, 0, 0,
2487 166, 167, 168, 171, 163, 0, 265, 0, 0, 0,
2488 273, 169, 170, 0, 0, 0, 263, 0, 264, 0,
2489 0, 165, 173, 174, 0, 0, 0, 0, 0, 0,
2490 270, 0, 0, 269, 266
Reid Spencer319a7302007-01-05 17:20:02 +00002491};
2492
Reid Spencerb7046c72007-01-29 05:41:34 +00002493/* YYDEFGOTO[NTERM-NUM]. */
2494static const short int yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002495{
Reid Spencered96d1e2007-02-08 09:08:52 +00002496 -1, 85, 312, 329, 330, 331, 264, 281, 332, 333,
2497 219, 220, 252, 221, 25, 15, 37, 523, 370, 457,
2498 481, 393, 458, 86, 87, 222, 89, 90, 120, 234,
2499 404, 359, 405, 108, 1, 2, 3, 336, 307, 305,
2500 306, 63, 200, 50, 103, 204, 91, 421, 344, 345,
2501 346, 38, 95, 16, 44, 17, 61, 18, 28, 112,
2502 426, 360, 92, 362, 492, 19, 40, 41, 191, 192,
2503 578, 97, 287, 527, 528, 193, 194, 437, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002504};
2505
2506/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2507 STATE-NUM. */
Reid Spencered96d1e2007-02-08 09:08:52 +00002508#define YYPACT_NINF -555
Reid Spencerb7046c72007-01-29 05:41:34 +00002509static const short int yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002510{
Reid Spencered96d1e2007-02-08 09:08:52 +00002511 -555, 136, 58, 247, -555, -555, -555, -555, -555, -555,
2512 -555, -555, -555, -555, 96, 181, 141, -555, -555, -9,
2513 -555, -555, 16, 7, 114, 65, 39, -555, 50, 188,
2514 210, -555, -555, -555, -555, -555, -555, 1357, -19, -555,
2515 -555, 134, -555, -555, -555, -555, 68, 69, 70, 73,
2516 -555, 60, 188, 1357, 4, 4, 4, 4, -555, -555,
2517 -555, -555, -555, -555, -555, -555, -555, 63, -555, -555,
2518 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2519 -555, 222, 224, 1, 171, -555, 134, 84, -555, -555,
2520 -103, -555, -555, -555, -555, -555, 1611, -555, 216, 66,
2521 238, 219, 233, -555, -555, -555, -555, -555, 1418, 1418,
2522 1418, 1459, 181, -555, 100, 101, 737, -555, -555, -103,
2523 -112, 105, 803, -555, -555, 1418, -555, 202, 1479, 13,
2524 221, 181, -555, -555, -555, -555, -555, -555, -555, -555,
2525 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2526 -555, -555, -555, -555, -555, -555, -555, -555, -555, 77,
2527 377, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418,
2528 1418, 1418, 1418, -555, -555, -555, -555, -555, -555, -555,
2529 -555, -555, -555, -555, -555, -555, 1418, 1418, 1418, 1418,
2530 1418, -555, -555, 181, -555, 33, -555, -555, -555, -555,
2531 -555, -555, -555, -555, -15, -555, -555, -555, 36, 158,
2532 262, 164, 264, 167, 266, 169, 268, 269, 270, 204,
2533 271, 274, 579, -555, -555, 1418, 1418, 121, -67, 1418,
2534 -555, 1199, -555, 120, 127, 920, -555, -555, 63, -555,
2535 920, 920, -555, -555, -555, -555, -555, -555, -555, -555,
2536 -555, -555, 920, 1357, -555, -555, -555, -555, -555, -555,
2537 -555, -555, -555, -555, 1418, -555, -555, -555, -555, -555,
2538 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2539 -555, 1418, 142, 143, -555, 920, 147, 153, 154, 155,
2540 157, 165, 166, 168, 170, 920, 920, 920, 173, 275,
2541 1357, 1418, 1418, 293, -555, 174, 174, 174, -555, -555,
2542 -555, -555, -555, -555, -555, -555, -555, -555, 77, 377,
2543 175, 177, 180, 182, 183, 1240, 1520, 757, 296, 192,
2544 193, 199, 203, 207, -555, -555, 174, -45, -71, -555,
2545 161, -103, -555, 134, -555, 176, 209, 1260, -555, -555,
2546 -555, -555, -555, -555, -555, -555, -555, 261, 1459, -555,
2547 -555, -555, -555, 206, -555, 213, 920, 920, 920, -2,
2548 -555, 0, -555, 215, 920, 179, 1418, 1418, 1418, 1418,
2549 1418, 1418, 1418, 217, 218, 223, 1418, 1418, 920, 920,
2550 226, -555, -17, -555, -555, -555, 214, 220, 1459, 1459,
2551 1459, 1459, 1459, -555, -555, -13, 778, -94, -555, -40,
2552 -555, 1459, 1459, 1459, 1459, 1459, -555, -555, -555, -555,
2553 -555, -555, 1301, 346, -555, -555, 357, -69, 361, 362,
2554 229, 234, 235, 920, 382, 920, 1418, -555, 236, 920,
2555 237, -555, -555, 239, 240, -555, -555, 920, 920, 920,
2556 -555, -555, 241, -555, 1418, 367, 390, -555, 174, 1459,
2557 1459, 215, 242, 245, 248, 249, 1459, -555, 254, -16,
2558 -8, -555, -555, 250, 253, 263, 272, 364, -555, -555,
2559 -555, 366, 273, -555, 920, 920, 1418, 920, 920, 276,
2560 -555, 276, -555, 279, 920, 280, 1418, 1418, 1418, -555,
2561 -555, -555, 1418, 920, -555, -555, -555, 281, 282, 283,
2562 1459, 1459, 1459, 1459, -555, -555, 284, 1459, 1459, 1459,
2563 1459, 1418, 423, -555, 416, 288, 285, 279, 290, -555,
2564 -555, 391, -555, -555, 1418, 294, 920, -555, -555, -555,
2565 291, -555, 1459, 1459, -555, 299, 298, 302, 303, -555,
2566 301, 306, 307, 308, 310, -555, -555, 437, 15, 432,
2567 -555, -555, 312, -555, 316, 319, 1459, -555, 1459, 1459,
2568 -555, -555, -555, -555, -555, 920, -555, 1046, 64, 460,
2569 -555, -555, -555, 326, 329, 331, -555, 335, -555, 1046,
2570 920, -555, -555, -555, 468, 337, 132, 920, 470, 472,
2571 -555, 920, 920, -555, -555
Reid Spencer319a7302007-01-05 17:20:02 +00002572};
2573
2574/* YYPGOTO[NTERM-NUM]. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002575static const short int yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002576{
Reid Spencered96d1e2007-02-08 09:08:52 +00002577 -555, -555, -555, 398, 399, 400, 198, 200, 402, 403,
2578 -128, -127, -525, -555, 476, 493, -111, -555, -276, 97,
2579 -555, -298, -555, -47, -555, -37, -555, -60, -62, -555,
2580 -99, 300, -308, 61, -555, -555, -555, -555, -555, -555,
2581 -555, 469, -555, -555, -555, -555, 8, -555, 102, -555,
2582 -555, 411, -555, -555, -555, -555, -555, 523, -555, -555,
2583 -555, -554, -11, 112, -124, -555, 508, -555, -68, -555,
2584 -555, -555, -555, 93, 28, -555, -555, 71, -555, -555
Reid Spencer319a7302007-01-05 17:20:02 +00002585};
2586
2587/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2588 positive, shift that token. If negative, reduce the rule which
2589 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002590 If YYTABLE_NINF, syntax error. */
2591#define YYTABLE_NINF -180
Reid Spencerb7046c72007-01-29 05:41:34 +00002592static const short int yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002593{
Reid Spencered96d1e2007-02-08 09:08:52 +00002594 88, 236, 250, 251, 239, 115, 105, 372, 394, 395,
2595 93, 26, 223, 433, 39, 435, 88, 455, 407, 409,
2596 253, 42, 240, 587, 119, 242, 243, 244, 245, 246,
2597 247, 248, 249, 577, 241, 595, 106, 107, 416, 284,
2598 456, 229, 288, 289, 290, 291, 292, 293, 294, 26,
2599 427, 230, -112, 589, 228, 434, 119, 434, -179, 466,
2600 233, 123, 119, 308, 309, 298, 299, 471, 46, 47,
2601 48, 205, 206, 207, 242, 243, 244, 245, 246, 247,
2602 248, 249, 300, 5, 466, 53, 229, 49, 235, 6,
2603 418, 235, 483, 123, 121, 59, 340, 60, 470, 7,
2604 8, 9, 10, 11, 12, 13, 7, 8, 9, 10,
2605 54, 12, 55, 466, 417, 56, 109, 110, 111, 123,
2606 14, 198, 199, 472, 282, 283, 235, 285, 286, 235,
2607 235, 235, 235, 235, 235, 235, 4, -139, 303, -112,
2608 466, 301, 302, 94, 304, 466, 467, -139, 123, 295,
2609 296, 297, 235, 235, 43, 516, 20, 29, 21, 51,
2610 506, -72, -72, 116, 39, 337, 338, -71, -71, 341,
2611 -70, -70, -69, -69, 576, 52, 65, 66, 390, 117,
2612 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2613 78, 58, 79, 20, 343, 21, 254, 255, 256, 257,
2614 258, 259, 260, 261, 262, 263, 366, 310, 311, 133,
2615 134, 335, 62, 532, 64, 533, 88, 102, -113, 80,
2616 98, 99, 100, 588, 361, 101, 113, 367, 114, 361,
2617 361, 242, 243, 244, 245, 246, 247, 248, 249, 122,
2618 197, 361, 201, 202, 368, 30, 31, 32, 33, 34,
2619 35, 36, 440, 388, 442, 443, 444, 203, 225, 226,
2620 231, 237, 450, 88, 389, 235, -76, -82, -75, 20,
2621 -74, 21, -73, 347, 361, 313, -79, -80, 6, -82,
2622 -82, 314, 339, 348, 361, 361, 361, 341, -82, -82,
2623 -82, -82, -82, -82, -82, 369, 371, -82, 22, 461,
2624 462, 463, 464, 465, 374, 23, 375, 376, 377, 24,
2625 378, 387, 473, 474, 475, 476, 477, 391, 379, 380,
2626 410, 381, 419, 382, 425, 81, 386, 392, 82, 422,
2627 398, 83, 399, 84, 118, 400, 439, 401, 402, 235,
2628 441, 235, 235, 235, 445, 446, 469, 411, 412, 235,
2629 451, 420, 363, 364, 413, 361, 361, 361, 414, 428,
2630 507, 508, 415, 361, 365, 423, 429, 514, 436, 459,
2631 447, 448, 537, 538, 539, 460, 449, 361, 361, 454,
2632 455, 482, 484, 485, 486, 343, 490, 487, 488, 494,
2633 496, 504, 497, 498, 505, 510, 502, 373, 511, 235,
2634 521, 512, 513, 517, 265, 266, 518, 383, 384, 385,
2635 560, 545, 546, 547, 548, 515, 519, 503, 550, 551,
2636 552, 553, 361, 522, 361, 520, 524, 555, 361, 531,
2637 250, 251, 534, 536, 542, 543, 361, 361, 361, 544,
2638 556, 557, 558, 564, 565, 549, 559, 563, 434, 235,
2639 250, 251, 566, 561, 567, 568, 569, 570, 575, 235,
2640 235, 235, 571, 572, 573, 235, 574, 583, 579, 584,
2641 585, 580, 581, 361, 361, 582, 361, 361, 430, 431,
2642 432, 590, 591, 361, 554, 592, 438, 593, 594, 597,
2643 598, 601, 361, 602, 186, 187, 188, 235, 189, 190,
2644 452, 453, 267, 268, 269, 270, 271, 272, 273, 274,
2645 275, 276, 277, 278, 279, 280, 396, 96, 57, 397,
2646 480, 104, 334, 224, 479, 361, 27, 45, 599, 493,
2647 540, 0, 509, 0, 0, 0, 0, 0, 0, 0,
2648 0, 0, 0, 0, 0, 489, 0, 491, 0, 0,
2649 0, 495, 0, 0, 0, 0, 0, 0, 0, 499,
2650 500, 501, 0, 0, 361, 0, 0, 0, 0, 0,
2651 0, 0, 0, 0, 0, 0, 0, 0, 0, 361,
2652 0, 0, 0, 0, 65, 66, 361, 0, 0, 0,
2653 361, 361, 0, 0, 0, 0, 525, 526, 0, 529,
2654 530, 20, 0, 21, 0, 315, 535, 0, 0, 0,
2655 0, 0, 0, 0, 0, 541, 0, 316, 317, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002656 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2657 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002658 0, 0, 0, 0, 0, 0, 0, 0, 562, 0,
2659 0, 0, 0, 0, 0, 0, 0, 0, 135, 136,
2660 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
2661 147, 148, 149, 150, 151, 152, 153, 154, 155, 156,
2662 157, 158, 318, 319, 0, 0, 0, 586, 0, 320,
2663 0, 321, 0, 322, 323, 324, 0, 0, 0, 0,
2664 0, 0, 596, 0, 0, 0, 0, 0, 0, 600,
2665 0, 0, 0, 603, 604, 0, 0, 0, 173, 174,
2666 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
2667 185, 0, 0, 0, 0, 0, 325, 0, 0, 326,
2668 0, 327, 65, 66, 328, 117, 68, 69, 70, 71,
Reid Spencer832254e2007-02-02 02:16:23 +00002669 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
Reid Spencered96d1e2007-02-08 09:08:52 +00002670 0, 21, 65, 66, 0, 117, 208, 209, 210, 211,
2671 212, 213, 214, 215, 216, 217, 218, 0, 79, 20,
2672 0, 21, 0, 65, 66, 80, 117, 208, 209, 210,
2673 211, 212, 213, 214, 215, 216, 217, 218, 0, 79,
2674 20, 0, 21, 0, 0, 80, 0, 0, 65, 66,
2675 0, 117, 68, 69, 70, 71, 72, 73, 74, 75,
2676 76, 77, 78, 0, 79, 20, 80, 21, 0, 0,
Reid Spencerc4d96252007-01-13 00:03:30 +00002677 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002678 232, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2679 0, 80, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002680 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002682 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2683 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2684 227, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2685 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2686 408, 0, 0, 349, 350, 65, 66, 351, 0, 0,
2687 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2688 84, 468, 20, 0, 21, 0, 352, 353, 354, 0,
2689 0, 0, 0, 0, 0, 0, 0, 81, 355, 356,
2690 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2691 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2692 0, 357, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002693 0, 0, 0, 0, 0, 0, 0, 0, 0, 135,
2694 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2695 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
Reid Spencered96d1e2007-02-08 09:08:52 +00002696 156, 157, 158, 318, 319, 0, 0, 0, 0, 0,
2697 320, 0, 321, 0, 322, 323, 324, 0, 0, 0,
2698 0, 0, 0, 0, 0, 0, 0, 0, 0, 349,
2699 350, 0, 0, 351, 0, 0, 0, 0, 0, 173,
Reid Spencer832254e2007-02-02 02:16:23 +00002700 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
Reid Spencered96d1e2007-02-08 09:08:52 +00002701 184, 185, 352, 353, 354, 0, 0, 0, 0, 0,
2702 358, 0, 0, 0, 355, 356, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002703 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002704 0, 0, 0, 0, 0, 0, 0, 357, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002706 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2707 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2708 150, 151, 152, 153, 154, 155, 156, 157, 158, 318,
2709 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
2710 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
2711 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2712 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2713 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2714 0, 0, 0, 0, 65, 66, 358, 117, 68, 69,
2715 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2716 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2717 0, 0, 0, 0, 0, 0, 342, 0, 0, 0,
2718 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2719 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2720 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2721 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2722 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2723 0, 0, 0, 0, 0, 0, 0, 424, 0, 0,
2724 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
Reid Spencer950bf602007-01-26 08:19:09 +00002725 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2726 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002727 0, 0, 0, 0, 0, 0, 0, 0, 478, 0,
2728 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2729 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2730 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2731 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2732 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2733 0, 0, 0, 0, 81, 0, 0, 82, 0, 403,
2734 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2735 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2736 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2737 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2738 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2739 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2740 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2741 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2742 79, 20, 0, 21, 65, 66, 0, 238, 68, 69,
2743 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2744 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2745 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2746 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2747 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2748 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2749 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2750 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2751 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2752 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002753 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2754 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002755 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2756 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2757 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2758 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
2759 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2760 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2761 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2762 83, 0, 406, 128, 129, 130, 131, 132, 133, 134,
2763 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2764 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2765 155, 156, 157, 158, 159, 160, 161, 162, 163, 0,
2766 0, 164, 165, 166, 167, 168, 169, 170, 171, 172,
Reid Spencer950bf602007-01-26 08:19:09 +00002767 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2768 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencered96d1e2007-02-08 09:08:52 +00002769 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2770 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002771};
2772
Reid Spencerb7046c72007-01-29 05:41:34 +00002773static const short int yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002774{
Reid Spencered96d1e2007-02-08 09:08:52 +00002775 37, 125, 130, 130, 128, 4, 53, 283, 306, 307,
2776 29, 3, 111, 15, 23, 15, 53, 34, 326, 327,
2777 131, 30, 9, 577, 84, 10, 11, 12, 13, 14,
2778 15, 16, 17, 558, 21, 589, 32, 33, 336, 163,
2779 57, 153, 166, 167, 168, 169, 170, 171, 172, 41,
2780 358, 163, 155, 578, 116, 57, 116, 57, 0, 153,
2781 122, 164, 122, 27, 28, 189, 190, 161, 52, 53,
2782 54, 108, 109, 110, 10, 11, 12, 13, 14, 15,
2783 16, 17, 193, 25, 153, 20, 153, 71, 125, 31,
2784 161, 128, 161, 164, 86, 45, 163, 47, 406, 41,
2785 42, 43, 44, 45, 46, 47, 41, 42, 43, 44,
2786 45, 46, 47, 153, 159, 50, 55, 56, 57, 164,
2787 62, 55, 56, 163, 161, 162, 163, 164, 165, 166,
2788 167, 168, 169, 170, 171, 172, 0, 153, 153, 155,
2789 153, 108, 109, 162, 159, 153, 159, 163, 164, 186,
2790 187, 188, 189, 190, 163, 163, 22, 61, 24, 152,
2791 458, 3, 4, 162, 23, 225, 226, 3, 4, 229,
2792 3, 4, 3, 4, 159, 61, 5, 6, 302, 8,
2793 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2794 19, 152, 21, 22, 231, 24, 119, 120, 121, 122,
2795 123, 124, 125, 126, 127, 128, 253, 3, 4, 77,
2796 78, 222, 24, 489, 4, 491, 253, 157, 155, 48,
2797 152, 152, 152, 159, 235, 152, 4, 264, 4, 240,
2798 241, 10, 11, 12, 13, 14, 15, 16, 17, 155,
2799 24, 252, 4, 24, 281, 64, 65, 66, 67, 68,
2800 69, 70, 376, 300, 378, 379, 380, 24, 158, 158,
2801 155, 59, 386, 300, 301, 302, 4, 20, 4, 22,
2802 4, 24, 4, 153, 285, 4, 7, 7, 31, 32,
2803 33, 7, 161, 156, 295, 296, 297, 347, 41, 42,
2804 43, 44, 45, 46, 47, 153, 153, 50, 51, 398,
2805 399, 400, 401, 402, 157, 58, 153, 153, 153, 62,
2806 153, 36, 411, 412, 413, 414, 415, 24, 153, 153,
2807 24, 153, 161, 153, 63, 154, 153, 153, 157, 153,
2808 155, 160, 155, 162, 163, 155, 157, 155, 155, 376,
2809 377, 378, 379, 380, 381, 382, 406, 155, 155, 386,
2810 387, 343, 240, 241, 155, 366, 367, 368, 155, 153,
2811 459, 460, 155, 374, 252, 156, 153, 466, 153, 155,
2812 153, 153, 496, 497, 498, 155, 153, 388, 389, 153,
2813 34, 24, 21, 21, 155, 422, 4, 153, 153, 153,
2814 153, 24, 153, 153, 4, 153, 155, 285, 153, 436,
2815 36, 153, 153, 153, 27, 28, 153, 295, 296, 297,
2816 534, 510, 511, 512, 513, 161, 153, 454, 517, 518,
2817 519, 520, 433, 57, 435, 153, 153, 4, 439, 153,
2818 558, 558, 153, 153, 153, 153, 447, 448, 449, 156,
2819 24, 153, 157, 542, 543, 161, 156, 156, 57, 486,
2820 578, 578, 153, 159, 156, 153, 153, 156, 21, 496,
2821 497, 498, 156, 156, 156, 502, 156, 566, 36, 568,
2822 569, 159, 156, 484, 485, 156, 487, 488, 366, 367,
2823 368, 21, 156, 494, 521, 156, 374, 156, 153, 21,
2824 153, 21, 503, 21, 96, 96, 96, 534, 96, 96,
2825 388, 389, 125, 126, 127, 128, 129, 130, 131, 132,
2826 133, 134, 135, 136, 137, 138, 318, 41, 25, 319,
2827 423, 52, 222, 112, 422, 536, 3, 19, 596, 436,
2828 502, -1, 461, -1, -1, -1, -1, -1, -1, -1,
2829 -1, -1, -1, -1, -1, 433, -1, 435, -1, -1,
2830 -1, 439, -1, -1, -1, -1, -1, -1, -1, 447,
2831 448, 449, -1, -1, 575, -1, -1, -1, -1, -1,
2832 -1, -1, -1, -1, -1, -1, -1, -1, -1, 590,
2833 -1, -1, -1, -1, 5, 6, 597, -1, -1, -1,
2834 601, 602, -1, -1, -1, -1, 484, 485, -1, 487,
2835 488, 22, -1, 24, -1, 26, 494, -1, -1, -1,
2836 -1, -1, -1, -1, -1, 503, -1, 38, 39, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002837 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2838 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002839 -1, -1, -1, -1, -1, -1, -1, -1, 536, -1,
2840 -1, -1, -1, -1, -1, -1, -1, -1, 79, 80,
2841 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2842 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
2843 101, 102, 103, 104, -1, -1, -1, 575, -1, 110,
2844 -1, 112, -1, 114, 115, 116, -1, -1, -1, -1,
2845 -1, -1, 590, -1, -1, -1, -1, -1, -1, 597,
2846 -1, -1, -1, 601, 602, -1, -1, -1, 139, 140,
2847 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
2848 151, -1, -1, -1, -1, -1, 157, -1, -1, 160,
2849 -1, 162, 5, 6, 165, 8, 9, 10, 11, 12,
Reid Spencer832254e2007-02-02 02:16:23 +00002850 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
Reid Spencered96d1e2007-02-08 09:08:52 +00002851 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
2852 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2853 -1, 24, -1, 5, 6, 48, 8, 9, 10, 11,
2854 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2855 22, -1, 24, -1, -1, 48, -1, -1, 5, 6,
2856 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2857 17, 18, 19, -1, 21, 22, 48, 24, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002858 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002859 37, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2860 -1, 48, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002861 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002862 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002863 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002864 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2865 163, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2866 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2867 163, -1, -1, 3, 4, 5, 6, 7, -1, -1,
2868 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2869 162, 163, 22, -1, 24, -1, 26, 27, 28, -1,
2870 -1, -1, -1, -1, -1, -1, -1, 154, 38, 39,
2871 157, -1, -1, 160, -1, 162, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002872 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002873 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
2874 -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
2875 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2876 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
2877 100, 101, 102, 103, 104, -1, -1, -1, -1, -1,
2878 110, -1, 112, -1, 114, 115, 116, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002879 -1, -1, -1, -1, -1, -1, -1, -1, -1, 3,
2880 4, -1, -1, 7, -1, -1, -1, -1, -1, 139,
Reid Spencer832254e2007-02-02 02:16:23 +00002881 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
Reid Spencered96d1e2007-02-08 09:08:52 +00002882 150, 151, 26, 27, 28, -1, -1, -1, -1, -1,
2883 160, -1, -1, -1, 38, 39, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002884 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002885 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002886 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002887 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2888 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2889 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2890 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
2891 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2892 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2893 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2894 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2895 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2896 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2897 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2898 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2899 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2900 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2901 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2902 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2903 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2904 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2905 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
Reid Spencer950bf602007-01-26 08:19:09 +00002906 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2907 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002908 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2909 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2910 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2911 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2912 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2913 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2914 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2915 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2916 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2917 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2918 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2919 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2920 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2921 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2922 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2923 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2924 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2925 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2926 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2927 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2928 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2929 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2930 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2931 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2932 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2933 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002934 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2935 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002936 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2937 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2938 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2939 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2940 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2941 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2942 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2943 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2944 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2945 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2946 99, 100, 101, 102, 103, 104, 105, 106, 107, -1,
2947 -1, 110, 111, 112, 113, 114, 115, 116, 117, 118,
Reid Spencer950bf602007-01-26 08:19:09 +00002948 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2949 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencered96d1e2007-02-08 09:08:52 +00002950 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2951 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002952};
2953
2954/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2955 symbol of state STATE-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002956static const unsigned char yystos[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002957{
Reid Spencer950bf602007-01-26 08:19:09 +00002958 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
Reid Spencered96d1e2007-02-08 09:08:52 +00002959 44, 45, 46, 47, 62, 181, 219, 221, 223, 231,
Reid Spencer950bf602007-01-26 08:19:09 +00002960 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2961 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
Reid Spencered96d1e2007-02-08 09:08:52 +00002962 232, 233, 30, 163, 220, 232, 52, 53, 54, 71,
Reid Spencer950bf602007-01-26 08:19:09 +00002963 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2964 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2965 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2966 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
Reid Spencered96d1e2007-02-08 09:08:52 +00002967 193, 212, 228, 29, 162, 218, 180, 237, 152, 152,
Reid Spencer950bf602007-01-26 08:19:09 +00002968 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
Reid Spencered96d1e2007-02-08 09:08:52 +00002969 199, 199, 225, 4, 4, 4, 162, 8, 163, 193,
Reid Spencer950bf602007-01-26 08:19:09 +00002970 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2971 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2972 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2973 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
Reid Spencer832254e2007-02-02 02:16:23 +00002974 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
Reid Spencer950bf602007-01-26 08:19:09 +00002975 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2976 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
Reid Spencered96d1e2007-02-08 09:08:52 +00002977 175, 234, 235, 241, 242, 244, 245, 24, 55, 56,
Reid Spencer950bf602007-01-26 08:19:09 +00002978 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2979 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
Reid Spencered96d1e2007-02-08 09:08:52 +00002980 177, 179, 191, 196, 217, 158, 158, 163, 194, 153,
2981 163, 155, 37, 194, 195, 191, 230, 59, 8, 230,
2982 9, 21, 10, 11, 12, 13, 14, 15, 16, 17,
2983 176, 177, 178, 182, 119, 120, 121, 122, 123, 124,
2984 125, 126, 127, 128, 172, 27, 28, 125, 126, 127,
2985 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
2986 138, 173, 191, 191, 230, 191, 191, 238, 230, 230,
2987 230, 230, 230, 230, 230, 191, 191, 191, 230, 230,
2988 182, 108, 109, 153, 159, 205, 206, 204, 27, 28,
2989 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
2990 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
2991 170, 171, 174, 175, 197, 228, 203, 193, 193, 161,
2992 163, 193, 37, 191, 214, 215, 216, 153, 156, 3,
2993 4, 7, 26, 27, 28, 38, 39, 61, 160, 197,
2994 227, 228, 229, 229, 229, 229, 189, 191, 191, 153,
2995 184, 153, 184, 229, 157, 153, 153, 153, 153, 153,
2996 153, 153, 153, 229, 229, 229, 153, 36, 189, 191,
2997 230, 24, 153, 187, 187, 187, 172, 173, 155, 155,
2998 155, 155, 155, 159, 196, 198, 162, 198, 163, 198,
2999 24, 155, 155, 155, 155, 155, 187, 159, 161, 161,
3000 212, 213, 153, 156, 37, 63, 226, 198, 153, 153,
3001 229, 229, 229, 15, 57, 15, 153, 243, 229, 157,
3002 230, 191, 230, 230, 230, 191, 191, 153, 153, 153,
3003 230, 191, 229, 229, 153, 34, 57, 185, 188, 155,
3004 155, 196, 196, 196, 196, 196, 153, 159, 163, 193,
3005 198, 161, 163, 196, 196, 196, 196, 196, 37, 214,
3006 185, 186, 24, 161, 21, 21, 155, 153, 153, 229,
3007 4, 229, 230, 239, 153, 229, 153, 153, 153, 229,
3008 229, 229, 155, 191, 24, 4, 187, 196, 196, 243,
3009 153, 153, 153, 153, 196, 161, 163, 153, 153, 153,
3010 153, 36, 57, 183, 153, 229, 229, 239, 240, 229,
3011 229, 153, 184, 184, 153, 229, 153, 230, 230, 230,
3012 240, 229, 153, 153, 156, 196, 196, 196, 196, 161,
3013 196, 196, 196, 196, 191, 4, 24, 153, 157, 156,
3014 230, 159, 229, 156, 196, 196, 153, 156, 153, 153,
3015 156, 156, 156, 156, 156, 21, 159, 178, 236, 36,
3016 159, 156, 156, 196, 196, 196, 229, 227, 159, 178,
3017 21, 156, 156, 156, 153, 227, 229, 21, 153, 234,
3018 229, 21, 21, 229, 229
Reid Spencer319a7302007-01-05 17:20:02 +00003019};
Reid Spencere7c3c602006-11-30 06:36:44 +00003020
3021#define yyerrok (yyerrstatus = 0)
3022#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00003023#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003024#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00003025
Reid Spencere7c3c602006-11-30 06:36:44 +00003026#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00003027#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00003028#define YYERROR goto yyerrorlab
3029
Reid Spencer319a7302007-01-05 17:20:02 +00003030
3031/* Like YYERROR except do call yyerror. This remains here temporarily
3032 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003033 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00003034
Reid Spencere7c3c602006-11-30 06:36:44 +00003035#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00003036
Reid Spencere7c3c602006-11-30 06:36:44 +00003037#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00003038
3039#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003040do \
3041 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00003042 { \
3043 yychar = (Token); \
3044 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00003045 yytoken = YYTRANSLATE (yychar); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003046 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003047 goto yybackup; \
3048 } \
3049 else \
Reid Spencer950bf602007-01-26 08:19:09 +00003050 { \
3051 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00003052 YYERROR; \
3053 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003054while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003055
Reid Spencer950bf602007-01-26 08:19:09 +00003056
Reid Spencere7c3c602006-11-30 06:36:44 +00003057#define YYTERROR 1
3058#define YYERRCODE 256
3059
Reid Spencer319a7302007-01-05 17:20:02 +00003060
Reid Spencer950bf602007-01-26 08:19:09 +00003061/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3062 If N is 0, then set CURRENT to the empty location which ends
3063 the previous symbol: RHS[0] (always defined). */
3064
3065#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00003066#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00003067# define YYLLOC_DEFAULT(Current, Rhs, N) \
3068 do \
Reid Spencerb7046c72007-01-29 05:41:34 +00003069 if (N) \
Reid Spencer950bf602007-01-26 08:19:09 +00003070 { \
3071 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3072 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3073 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3074 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3075 } \
3076 else \
3077 { \
3078 (Current).first_line = (Current).last_line = \
3079 YYRHSLOC (Rhs, 0).last_line; \
3080 (Current).first_column = (Current).last_column = \
3081 YYRHSLOC (Rhs, 0).last_column; \
3082 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003083 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003084#endif
3085
Reid Spencer950bf602007-01-26 08:19:09 +00003086
3087/* YY_LOCATION_PRINT -- Print the location on the stream.
3088 This macro was not mandated originally: define only if we know
3089 we won't break user code: when these are the locations we know. */
3090
3091#ifndef YY_LOCATION_PRINT
3092# if YYLTYPE_IS_TRIVIAL
3093# define YY_LOCATION_PRINT(File, Loc) \
3094 fprintf (File, "%d.%d-%d.%d", \
Reid Spencerb7046c72007-01-29 05:41:34 +00003095 (Loc).first_line, (Loc).first_column, \
3096 (Loc).last_line, (Loc).last_column)
Reid Spencer950bf602007-01-26 08:19:09 +00003097# else
3098# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3099# endif
3100#endif
3101
3102
Reid Spencer319a7302007-01-05 17:20:02 +00003103/* YYLEX -- calling `yylex' with the right arguments. */
3104
Reid Spencer950bf602007-01-26 08:19:09 +00003105#ifdef YYLEX_PARAM
3106# define YYLEX yylex (YYLEX_PARAM)
3107#else
3108# define YYLEX yylex ()
3109#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003110
3111/* Enable debugging if requested. */
3112#if YYDEBUG
3113
3114# ifndef YYFPRINTF
3115# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3116# define YYFPRINTF fprintf
3117# endif
3118
3119# define YYDPRINTF(Args) \
3120do { \
3121 if (yydebug) \
3122 YYFPRINTF Args; \
Reid Spencerb7046c72007-01-29 05:41:34 +00003123} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003124
Reid Spencerb7046c72007-01-29 05:41:34 +00003125# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3126do { \
3127 if (yydebug) \
3128 { \
3129 YYFPRINTF (stderr, "%s ", Title); \
3130 yysymprint (stderr, \
3131 Type, Value); \
3132 YYFPRINTF (stderr, "\n"); \
3133 } \
3134} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003135
3136/*------------------------------------------------------------------.
3137| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3138| TOP (included). |
3139`------------------------------------------------------------------*/
3140
Reid Spencerb7046c72007-01-29 05:41:34 +00003141#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003142static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003143yy_stack_print (short int *bottom, short int *top)
Reid Spencer950bf602007-01-26 08:19:09 +00003144#else
3145static void
3146yy_stack_print (bottom, top)
Reid Spencerb7046c72007-01-29 05:41:34 +00003147 short int *bottom;
3148 short int *top;
Reid Spencer950bf602007-01-26 08:19:09 +00003149#endif
3150{
3151 YYFPRINTF (stderr, "Stack now");
Reid Spencerb7046c72007-01-29 05:41:34 +00003152 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer950bf602007-01-26 08:19:09 +00003153 YYFPRINTF (stderr, " %d", *bottom);
3154 YYFPRINTF (stderr, "\n");
3155}
3156
3157# define YY_STACK_PRINT(Bottom, Top) \
3158do { \
3159 if (yydebug) \
3160 yy_stack_print ((Bottom), (Top)); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003161} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003162
3163
3164/*------------------------------------------------.
3165| Report that the YYRULE is going to be reduced. |
3166`------------------------------------------------*/
3167
Reid Spencerb7046c72007-01-29 05:41:34 +00003168#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003169static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003170yy_reduce_print (int yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003171#else
3172static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003173yy_reduce_print (yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003174 int yyrule;
3175#endif
3176{
3177 int yyi;
3178 unsigned long int yylno = yyrline[yyrule];
Reid Spencerb7046c72007-01-29 05:41:34 +00003179 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3180 yyrule - 1, yylno);
3181 /* Print the symbols being reduced, and their result. */
3182 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3183 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3184 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer950bf602007-01-26 08:19:09 +00003185}
3186
3187# define YY_REDUCE_PRINT(Rule) \
3188do { \
3189 if (yydebug) \
Reid Spencerb7046c72007-01-29 05:41:34 +00003190 yy_reduce_print (Rule); \
3191} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003192
Reid Spencer319a7302007-01-05 17:20:02 +00003193/* Nonzero means print parse trace. It is left uninitialized so that
3194 multiple parsers can coexist. */
3195int yydebug;
3196#else /* !YYDEBUG */
3197# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003198# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3199# define YY_STACK_PRINT(Bottom, Top)
3200# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003201#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003202
Reid Spencer950bf602007-01-26 08:19:09 +00003203
Reid Spencer319a7302007-01-05 17:20:02 +00003204/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003205#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003206# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003207#endif
3208
Reid Spencer319a7302007-01-05 17:20:02 +00003209/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3210 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003211
Reid Spencer319a7302007-01-05 17:20:02 +00003212 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003213 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003214 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003215
3216#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003217# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003218#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003219
Reid Spencere7c3c602006-11-30 06:36:44 +00003220
3221
Reid Spencer319a7302007-01-05 17:20:02 +00003222#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003223
Reid Spencer319a7302007-01-05 17:20:02 +00003224# ifndef yystrlen
Reid Spencerb7046c72007-01-29 05:41:34 +00003225# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer319a7302007-01-05 17:20:02 +00003226# define yystrlen strlen
3227# else
3228/* Return the length of YYSTR. */
3229static YYSIZE_T
Reid Spencerb7046c72007-01-29 05:41:34 +00003230# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003231yystrlen (const char *yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003232# else
Reid Spencer319a7302007-01-05 17:20:02 +00003233yystrlen (yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003234 const char *yystr;
3235# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003236{
Reid Spencerb7046c72007-01-29 05:41:34 +00003237 const char *yys = yystr;
3238
3239 while (*yys++ != '\0')
Reid Spencer319a7302007-01-05 17:20:02 +00003240 continue;
Reid Spencerb7046c72007-01-29 05:41:34 +00003241
3242 return yys - yystr - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003243}
Reid Spencer319a7302007-01-05 17:20:02 +00003244# endif
3245# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003246
Reid Spencer319a7302007-01-05 17:20:02 +00003247# ifndef yystpcpy
Reid Spencerb7046c72007-01-29 05:41:34 +00003248# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer319a7302007-01-05 17:20:02 +00003249# define yystpcpy stpcpy
3250# else
3251/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3252 YYDEST. */
3253static char *
Reid Spencerb7046c72007-01-29 05:41:34 +00003254# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003255yystpcpy (char *yydest, const char *yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003256# else
Reid Spencer319a7302007-01-05 17:20:02 +00003257yystpcpy (yydest, yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003258 char *yydest;
3259 const char *yysrc;
3260# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003261{
Reid Spencer950bf602007-01-26 08:19:09 +00003262 char *yyd = yydest;
3263 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003264
Reid Spencer319a7302007-01-05 17:20:02 +00003265 while ((*yyd++ = *yys++) != '\0')
3266 continue;
3267
3268 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003269}
Reid Spencer319a7302007-01-05 17:20:02 +00003270# endif
3271# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003272
Reid Spencer950bf602007-01-26 08:19:09 +00003273# ifndef yytnamerr
3274/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3275 quotes and backslashes, so that it's suitable for yyerror. The
3276 heuristic is that double-quoting is unnecessary unless the string
3277 contains an apostrophe, a comma, or backslash (other than
3278 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3279 null, do not copy; instead, return the length of what the result
3280 would have been. */
3281static YYSIZE_T
3282yytnamerr (char *yyres, const char *yystr)
3283{
3284 if (*yystr == '"')
3285 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003286 size_t yyn = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00003287 char const *yyp = yystr;
3288
3289 for (;;)
3290 switch (*++yyp)
3291 {
3292 case '\'':
3293 case ',':
3294 goto do_not_strip_quotes;
3295
3296 case '\\':
3297 if (*++yyp != '\\')
3298 goto do_not_strip_quotes;
3299 /* Fall through. */
3300 default:
3301 if (yyres)
3302 yyres[yyn] = *yyp;
3303 yyn++;
3304 break;
3305
3306 case '"':
3307 if (yyres)
3308 yyres[yyn] = '\0';
3309 return yyn;
3310 }
3311 do_not_strip_quotes: ;
3312 }
3313
3314 if (! yyres)
3315 return yystrlen (yystr);
3316
3317 return yystpcpy (yyres, yystr) - yyres;
3318}
3319# endif
3320
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003321#endif /* YYERROR_VERBOSE */
Reid Spencerb7046c72007-01-29 05:41:34 +00003322
Reid Spencere7c3c602006-11-30 06:36:44 +00003323
3324
Reid Spencerb7046c72007-01-29 05:41:34 +00003325#if YYDEBUG
3326/*--------------------------------.
3327| Print this symbol on YYOUTPUT. |
3328`--------------------------------*/
3329
3330#if defined (__STDC__) || defined (__cplusplus)
3331static void
3332yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
3333#else
3334static void
3335yysymprint (yyoutput, yytype, yyvaluep)
3336 FILE *yyoutput;
3337 int yytype;
3338 YYSTYPE *yyvaluep;
3339#endif
3340{
3341 /* Pacify ``unused variable'' warnings. */
3342 (void) yyvaluep;
3343
3344 if (yytype < YYNTOKENS)
3345 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3346 else
3347 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3348
3349
3350# ifdef YYPRINT
3351 if (yytype < YYNTOKENS)
3352 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3353# endif
3354 switch (yytype)
3355 {
3356 default:
3357 break;
3358 }
3359 YYFPRINTF (yyoutput, ")");
3360}
3361
3362#endif /* ! YYDEBUG */
Reid Spencer319a7302007-01-05 17:20:02 +00003363/*-----------------------------------------------.
3364| Release the memory associated to this symbol. |
3365`-----------------------------------------------*/
3366
Reid Spencerb7046c72007-01-29 05:41:34 +00003367#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003368static void
3369yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003370#else
Reid Spencer950bf602007-01-26 08:19:09 +00003371static void
3372yydestruct (yymsg, yytype, yyvaluep)
3373 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003374 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003375 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003376#endif
3377{
Reid Spencerb7046c72007-01-29 05:41:34 +00003378 /* Pacify ``unused variable'' warnings. */
3379 (void) yyvaluep;
Reid Spencer950bf602007-01-26 08:19:09 +00003380
3381 if (!yymsg)
3382 yymsg = "Deleting";
3383 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003384
3385 switch (yytype)
3386 {
Reid Spencer950bf602007-01-26 08:19:09 +00003387
Reid Spencer319a7302007-01-05 17:20:02 +00003388 default:
Reid Spencerb7046c72007-01-29 05:41:34 +00003389 break;
Reid Spencer319a7302007-01-05 17:20:02 +00003390 }
3391}
3392
3393
Reid Spencer950bf602007-01-26 08:19:09 +00003394/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003395
3396#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003397# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003398int yyparse (void *YYPARSE_PARAM);
Reid Spencerb7046c72007-01-29 05:41:34 +00003399# else
Reid Spencer950bf602007-01-26 08:19:09 +00003400int yyparse ();
Reid Spencerb7046c72007-01-29 05:41:34 +00003401# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003402#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003403#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003404int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003405#else
3406int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003407#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003408#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003409
3410
Reid Spencer950bf602007-01-26 08:19:09 +00003411
3412/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003413int yychar;
3414
Reid Spencer950bf602007-01-26 08:19:09 +00003415/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003416YYSTYPE yylval;
3417
Reid Spencer950bf602007-01-26 08:19:09 +00003418/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003419int yynerrs;
3420
3421
Reid Spencer950bf602007-01-26 08:19:09 +00003422
3423/*----------.
3424| yyparse. |
3425`----------*/
3426
3427#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003428# if defined (__STDC__) || defined (__cplusplus)
3429int yyparse (void *YYPARSE_PARAM)
3430# else
3431int yyparse (YYPARSE_PARAM)
3432 void *YYPARSE_PARAM;
3433# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003434#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003435#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003436int
Reid Spencer950bf602007-01-26 08:19:09 +00003437yyparse (void)
3438#else
3439int
3440yyparse ()
3441
3442#endif
3443#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003444{
3445
Reid Spencer950bf602007-01-26 08:19:09 +00003446 int yystate;
3447 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003448 int yyresult;
3449 /* Number of tokens to shift before error messages enabled. */
3450 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003451 /* Look-ahead token as an internal (translated) token number. */
3452 int yytoken = 0;
Reid Spencer319a7302007-01-05 17:20:02 +00003453
3454 /* Three stacks and their tools:
3455 `yyss': related to states,
3456 `yyvs': related to semantic values,
3457 `yyls': related to locations.
3458
3459 Refer to the stacks thru separate pointers, to allow yyoverflow
3460 to reallocate them elsewhere. */
3461
3462 /* The state stack. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003463 short int yyssa[YYINITDEPTH];
3464 short int *yyss = yyssa;
3465 short int *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003466
3467 /* The semantic value stack. */
3468 YYSTYPE yyvsa[YYINITDEPTH];
3469 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003470 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003471
3472
3473
Reid Spencerb7046c72007-01-29 05:41:34 +00003474#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003475
Reid Spencer319a7302007-01-05 17:20:02 +00003476 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003477
Reid Spencer319a7302007-01-05 17:20:02 +00003478 /* The variables used to return semantic value and location from the
3479 action routines. */
3480 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003481
3482
Reid Spencerb7046c72007-01-29 05:41:34 +00003483 /* When reducing, the number of symbols on the RHS of the reduced
3484 rule. */
3485 int yylen;
Reid Spencere7c3c602006-11-30 06:36:44 +00003486
Reid Spencer319a7302007-01-05 17:20:02 +00003487 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003488
3489 yystate = 0;
3490 yyerrstatus = 0;
3491 yynerrs = 0;
3492 yychar = YYEMPTY; /* Cause a token to be read. */
3493
3494 /* Initialize stack pointers.
3495 Waste one element of value and location stack
3496 so that they stay on the same level as the state stack.
3497 The wasted elements are never initialized. */
3498
Reid Spencer319a7302007-01-05 17:20:02 +00003499 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003500 yyvsp = yyvs;
3501
Reid Spencer319a7302007-01-05 17:20:02 +00003502 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003503
Reid Spencer319a7302007-01-05 17:20:02 +00003504/*------------------------------------------------------------.
3505| yynewstate -- Push a new state, which is found in yystate. |
3506`------------------------------------------------------------*/
3507 yynewstate:
3508 /* In all cases, when you get here, the value and location stacks
Reid Spencerb7046c72007-01-29 05:41:34 +00003509 have just been pushed. so pushing a state here evens the stacks.
3510 */
Reid Spencer319a7302007-01-05 17:20:02 +00003511 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003512
Reid Spencer319a7302007-01-05 17:20:02 +00003513 yysetstate:
3514 *yyssp = yystate;
3515
Reid Spencer950bf602007-01-26 08:19:09 +00003516 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003517 {
3518 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003519 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003520
3521#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003522 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003523 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer319a7302007-01-05 17:20:02 +00003524 these so that the &'s don't force the real ones into
3525 memory. */
3526 YYSTYPE *yyvs1 = yyvs;
Reid Spencerb7046c72007-01-29 05:41:34 +00003527 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003528
Reid Spencer319a7302007-01-05 17:20:02 +00003529
3530 /* Each stack pointer address is followed by the size of the
3531 data in use in that stack, in bytes. This used to be a
3532 conditional around just the two extra args, but that might
3533 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003534 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003535 &yyss1, yysize * sizeof (*yyssp),
3536 &yyvs1, yysize * sizeof (*yyvsp),
3537
3538 &yystacksize);
3539
3540 yyss = yyss1;
3541 yyvs = yyvs1;
3542 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003543#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003544# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003545 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003546# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003547 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003548 if (YYMAXDEPTH <= yystacksize)
3549 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003550 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003551 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003552 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003553
3554 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003555 short int *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003556 union yyalloc *yyptr =
3557 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3558 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003559 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003560 YYSTACK_RELOCATE (yyss);
3561 YYSTACK_RELOCATE (yyvs);
3562
3563# undef YYSTACK_RELOCATE
3564 if (yyss1 != yyssa)
3565 YYSTACK_FREE (yyss1);
3566 }
3567# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003568#endif /* no yyoverflow */
3569
Reid Spencer319a7302007-01-05 17:20:02 +00003570 yyssp = yyss + yysize - 1;
3571 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003572
3573
Reid Spencer319a7302007-01-05 17:20:02 +00003574 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3575 (unsigned long int) yystacksize));
3576
Reid Spencer950bf602007-01-26 08:19:09 +00003577 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003578 YYABORT;
3579 }
3580
Reid Spencer319a7302007-01-05 17:20:02 +00003581 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003582
3583 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003584
3585/*-----------.
3586| yybackup. |
3587`-----------*/
3588yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003589
Reid Spencerb7046c72007-01-29 05:41:34 +00003590/* Do appropriate processing given the current state. */
3591/* Read a look-ahead token if we need one and don't already have one. */
3592/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003593
Reid Spencer950bf602007-01-26 08:19:09 +00003594 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003595
Reid Spencere7c3c602006-11-30 06:36:44 +00003596 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003597 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003598 goto yydefault;
3599
Reid Spencer950bf602007-01-26 08:19:09 +00003600 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003601
Reid Spencer950bf602007-01-26 08:19:09 +00003602 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003603 if (yychar == YYEMPTY)
3604 {
Reid Spencer319a7302007-01-05 17:20:02 +00003605 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003606 yychar = YYLEX;
3607 }
3608
Reid Spencer950bf602007-01-26 08:19:09 +00003609 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003610 {
Reid Spencer950bf602007-01-26 08:19:09 +00003611 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003612 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003613 }
3614 else
3615 {
Reid Spencer950bf602007-01-26 08:19:09 +00003616 yytoken = YYTRANSLATE (yychar);
3617 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003618 }
3619
Reid Spencer950bf602007-01-26 08:19:09 +00003620 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003621 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003622 yyn += yytoken;
3623 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003624 goto yydefault;
3625 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003626 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003627 {
Reid Spencer319a7302007-01-05 17:20:02 +00003628 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003629 goto yyerrlab;
3630 yyn = -yyn;
3631 goto yyreduce;
3632 }
3633
3634 if (yyn == YYFINAL)
3635 YYACCEPT;
3636
Reid Spencerb7046c72007-01-29 05:41:34 +00003637 /* Shift the look-ahead token. */
3638 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3639
3640 /* Discard the token being shifted unless it is eof. */
3641 if (yychar != YYEOF)
3642 yychar = YYEMPTY;
3643
3644 *++yyvsp = yylval;
3645
3646
Reid Spencer319a7302007-01-05 17:20:02 +00003647 /* Count tokens shifted since error; after three, turn off error
3648 status. */
3649 if (yyerrstatus)
3650 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003651
3652 yystate = yyn;
3653 goto yynewstate;
3654
Chris Lattner37e01c52007-01-04 18:46:42 +00003655
Reid Spencer319a7302007-01-05 17:20:02 +00003656/*-----------------------------------------------------------.
3657| yydefault -- do the default action for the current state. |
3658`-----------------------------------------------------------*/
3659yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003660 yyn = yydefact[yystate];
3661 if (yyn == 0)
3662 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003663 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003664
Reid Spencer319a7302007-01-05 17:20:02 +00003665
3666/*-----------------------------.
3667| yyreduce -- Do a reduction. |
3668`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003669yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003670 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003671 yylen = yyr2[yyn];
3672
Reid Spencer319a7302007-01-05 17:20:02 +00003673 /* If YYLEN is nonzero, implement the default value of the action:
3674 `$$ = $1'.
3675
3676 Otherwise, the following line sets YYVAL to garbage.
3677 This behavior is undocumented and Bison
3678 users should not rely upon it. Assigning to YYVAL
3679 unconditionally makes the parser a bit smaller, and it avoids a
3680 GCC warning that YYVAL may be used uninitialized. */
3681 yyval = yyvsp[1-yylen];
3682
3683
Reid Spencer950bf602007-01-26 08:19:09 +00003684 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003685 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003686 {
Reid Spencer950bf602007-01-26 08:19:09 +00003687 case 3:
Reid Spencered96d1e2007-02-08 09:08:52 +00003688#line 1594 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003689 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003690 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003691 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003692 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003693 ;}
3694 break;
3695
3696 case 5:
Reid Spencered96d1e2007-02-08 09:08:52 +00003697#line 1603 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003698 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003699 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003700 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003701 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003702 ;}
3703 break;
3704
3705 case 26:
Reid Spencered96d1e2007-02-08 09:08:52 +00003706#line 1625 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003707 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3708 break;
3709
3710 case 27:
Reid Spencered96d1e2007-02-08 09:08:52 +00003711#line 1625 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003712 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3713 break;
3714
3715 case 28:
Reid Spencered96d1e2007-02-08 09:08:52 +00003716#line 1626 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003717 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3718 break;
3719
3720 case 29:
Reid Spencered96d1e2007-02-08 09:08:52 +00003721#line 1626 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003722 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3723 break;
3724
3725 case 30:
Reid Spencered96d1e2007-02-08 09:08:52 +00003726#line 1627 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003727 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3728 break;
3729
3730 case 31:
Reid Spencered96d1e2007-02-08 09:08:52 +00003731#line 1627 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003732 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3733 break;
3734
3735 case 32:
Reid Spencered96d1e2007-02-08 09:08:52 +00003736#line 1628 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003737 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3738 break;
3739
3740 case 33:
Reid Spencered96d1e2007-02-08 09:08:52 +00003741#line 1628 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003742 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3743 break;
3744
3745 case 34:
Reid Spencered96d1e2007-02-08 09:08:52 +00003746#line 1629 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003747 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3748 break;
3749
3750 case 35:
Reid Spencered96d1e2007-02-08 09:08:52 +00003751#line 1629 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003752 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3753 break;
3754
3755 case 36:
Reid Spencered96d1e2007-02-08 09:08:52 +00003756#line 1633 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003757 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3758 break;
3759
3760 case 37:
Reid Spencered96d1e2007-02-08 09:08:52 +00003761#line 1633 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003762 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3763 break;
3764
3765 case 38:
Reid Spencered96d1e2007-02-08 09:08:52 +00003766#line 1634 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003767 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3768 break;
3769
3770 case 39:
Reid Spencered96d1e2007-02-08 09:08:52 +00003771#line 1634 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003772 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3773 break;
3774
3775 case 40:
Reid Spencered96d1e2007-02-08 09:08:52 +00003776#line 1635 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003777 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3778 break;
3779
3780 case 41:
Reid Spencered96d1e2007-02-08 09:08:52 +00003781#line 1635 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003782 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3783 break;
3784
3785 case 42:
Reid Spencered96d1e2007-02-08 09:08:52 +00003786#line 1636 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003787 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3788 break;
3789
3790 case 43:
Reid Spencered96d1e2007-02-08 09:08:52 +00003791#line 1636 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003792 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3793 break;
3794
3795 case 44:
Reid Spencered96d1e2007-02-08 09:08:52 +00003796#line 1637 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003797 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3798 break;
3799
3800 case 45:
Reid Spencered96d1e2007-02-08 09:08:52 +00003801#line 1637 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003802 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3803 break;
3804
3805 case 46:
Reid Spencered96d1e2007-02-08 09:08:52 +00003806#line 1638 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003807 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3808 break;
3809
3810 case 47:
Reid Spencered96d1e2007-02-08 09:08:52 +00003811#line 1638 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003812 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3813 break;
3814
3815 case 48:
Reid Spencered96d1e2007-02-08 09:08:52 +00003816#line 1639 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003817 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3818 break;
3819
3820 case 49:
Reid Spencered96d1e2007-02-08 09:08:52 +00003821#line 1639 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003822 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3823 break;
3824
3825 case 50:
Reid Spencered96d1e2007-02-08 09:08:52 +00003826#line 1640 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003827 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3828 break;
3829
3830 case 51:
Reid Spencered96d1e2007-02-08 09:08:52 +00003831#line 1641 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003832 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3833 break;
3834
3835 case 81:
Reid Spencered96d1e2007-02-08 09:08:52 +00003836#line 1672 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003837 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003838 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003839 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003840 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003841
Reid Spencer319a7302007-01-05 17:20:02 +00003842 case 82:
Reid Spencered96d1e2007-02-08 09:08:52 +00003843#line 1675 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003844 {
Reid Spencer950bf602007-01-26 08:19:09 +00003845 (yyval.StrVal) = 0;
3846 ;}
3847 break;
3848
3849 case 83:
Reid Spencered96d1e2007-02-08 09:08:52 +00003850#line 1680 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003851 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3852 break;
3853
3854 case 84:
Reid Spencered96d1e2007-02-08 09:08:52 +00003855#line 1681 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003856 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3857 break;
3858
3859 case 85:
Reid Spencered96d1e2007-02-08 09:08:52 +00003860#line 1682 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003861 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3862 break;
3863
3864 case 86:
Reid Spencered96d1e2007-02-08 09:08:52 +00003865#line 1683 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003866 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3867 break;
3868
3869 case 87:
Reid Spencered96d1e2007-02-08 09:08:52 +00003870#line 1684 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003871 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3872 break;
3873
3874 case 88:
Reid Spencered96d1e2007-02-08 09:08:52 +00003875#line 1685 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003876 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3877 break;
3878
3879 case 89:
Reid Spencered96d1e2007-02-08 09:08:52 +00003880#line 1686 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003881 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003882 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003883
Reid Spencer319a7302007-01-05 17:20:02 +00003884 case 90:
Reid Spencered96d1e2007-02-08 09:08:52 +00003885#line 1687 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003886 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3887 break;
3888
3889 case 91:
Reid Spencered96d1e2007-02-08 09:08:52 +00003890#line 1691 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
3891 { (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003892 break;
3893
3894 case 92:
Reid Spencered96d1e2007-02-08 09:08:52 +00003895#line 1692 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
3896 { (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003897 break;
3898
3899 case 93:
Reid Spencered96d1e2007-02-08 09:08:52 +00003900#line 1693 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
3901 { (yyval.UIntVal) = OldCallingConv::CSRet; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003902 break;
3903
3904 case 94:
Reid Spencered96d1e2007-02-08 09:08:52 +00003905#line 1694 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
3906 { (yyval.UIntVal) = OldCallingConv::Fast; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003907 break;
3908
3909 case 95:
Reid Spencered96d1e2007-02-08 09:08:52 +00003910#line 1695 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
3911 { (yyval.UIntVal) = OldCallingConv::Cold; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003912 break;
3913
3914 case 96:
Reid Spencered96d1e2007-02-08 09:08:52 +00003915#line 1696 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
3916 { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003917 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00003918
Reid Spencer319a7302007-01-05 17:20:02 +00003919 case 97:
Reid Spencered96d1e2007-02-08 09:08:52 +00003920#line 1697 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
3921 { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003922 break;
Reid Spencer16244f42006-12-01 21:10:07 +00003923
Reid Spencer319a7302007-01-05 17:20:02 +00003924 case 98:
Reid Spencered96d1e2007-02-08 09:08:52 +00003925#line 1698 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003926 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003927 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00003928 error("Calling conv too large");
Reid Spencerb7046c72007-01-29 05:41:34 +00003929 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003930 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003931 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003932
Reid Spencer319a7302007-01-05 17:20:02 +00003933 case 99:
Reid Spencered96d1e2007-02-08 09:08:52 +00003934#line 1708 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003935 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003936 break;
3937
Reid Spencerc4d96252007-01-13 00:03:30 +00003938 case 100:
Reid Spencered96d1e2007-02-08 09:08:52 +00003939#line 1709 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003940 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003941 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003942 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3943 error("Alignment must be a power of two");
3944 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003945 break;
3946
3947 case 101:
Reid Spencered96d1e2007-02-08 09:08:52 +00003948#line 1717 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003949 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003950 break;
3951
3952 case 102:
Reid Spencered96d1e2007-02-08 09:08:52 +00003953#line 1718 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003954 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003955 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003956 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3957 error("Alignment must be a power of two");
3958 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003959 break;
3960
3961 case 103:
Reid Spencered96d1e2007-02-08 09:08:52 +00003962#line 1726 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003963 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003964 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3965 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00003966 error("Invalid character in section name");
Reid Spencerb7046c72007-01-29 05:41:34 +00003967 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003968 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003969 break;
3970
3971 case 104:
Reid Spencered96d1e2007-02-08 09:08:52 +00003972#line 1735 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003973 { (yyval.StrVal) = 0; ;}
3974 break;
3975
3976 case 105:
Reid Spencered96d1e2007-02-08 09:08:52 +00003977#line 1736 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003978 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003979 break;
3980
Reid Spencerc4d96252007-01-13 00:03:30 +00003981 case 106:
Reid Spencered96d1e2007-02-08 09:08:52 +00003982#line 1743 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003983 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003984 break;
3985
Reid Spencer319a7302007-01-05 17:20:02 +00003986 case 107:
Reid Spencered96d1e2007-02-08 09:08:52 +00003987#line 1744 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003988 {;}
3989 break;
3990
3991 case 108:
Reid Spencered96d1e2007-02-08 09:08:52 +00003992#line 1748 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003993 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003994 CurGV->setSection((yyvsp[0].StrVal));
3995 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00003996 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003997 break;
3998
3999 case 109:
Reid Spencered96d1e2007-02-08 09:08:52 +00004000#line 1752 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004001 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004002 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004003 error("Alignment must be a power of two");
Reid Spencerb7046c72007-01-29 05:41:34 +00004004 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004005
4006 ;}
4007 break;
4008
4009 case 111:
Reid Spencered96d1e2007-02-08 09:08:52 +00004010#line 1769 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004011 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004012 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00004013 (yyval.TypeVal).S = Signless;
4014 ;}
4015 break;
4016
4017 case 113:
Reid Spencered96d1e2007-02-08 09:08:52 +00004018#line 1777 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004019 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004020 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00004021 (yyval.TypeVal).S = Signless;
4022 ;}
4023 break;
4024
4025 case 114:
Reid Spencered96d1e2007-02-08 09:08:52 +00004026#line 1784 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004027 {
4028 if (!UpRefs.empty())
Reid Spencered96d1e2007-02-08 09:08:52 +00004029 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription());
Reid Spencerb7046c72007-01-29 05:41:34 +00004030 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004031 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004032 break;
4033
4034 case 127:
Reid Spencered96d1e2007-02-08 09:08:52 +00004035#line 1798 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004036 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004037 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerb7046c72007-01-29 05:41:34 +00004038 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004039 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004040 break;
4041
4042 case 128:
Reid Spencered96d1e2007-02-08 09:08:52 +00004043#line 1802 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004044 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004045 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
Reid Spencer950bf602007-01-26 08:19:09 +00004046 (yyval.TypeVal).S = Signless;
4047 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004048 break;
4049
4050 case 129:
Reid Spencered96d1e2007-02-08 09:08:52 +00004051#line 1806 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004052 { // Named types are also simple types...
Reid Spencerb7046c72007-01-29 05:41:34 +00004053 const Type* tmp = getType((yyvsp[0].ValIDVal));
Reid Spencered96d1e2007-02-08 09:08:52 +00004054 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
Reid Spencer950bf602007-01-26 08:19:09 +00004055 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4056 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004057 break;
4058
4059 case 130:
Reid Spencered96d1e2007-02-08 09:08:52 +00004060#line 1811 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004061 { // Type UpReference
Reid Spencerb7046c72007-01-29 05:41:34 +00004062 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004063 error("Value out of range");
4064 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencerb7046c72007-01-29 05:41:34 +00004065 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Reid Spencered96d1e2007-02-08 09:08:52 +00004066 (yyval.TypeVal).PAT = new PATypeHolder(OT);
Reid Spencer950bf602007-01-26 08:19:09 +00004067 (yyval.TypeVal).S = Signless;
4068 UR_OUT("New Upreference!\n");
4069 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004070 break;
4071
4072 case 131:
Reid Spencered96d1e2007-02-08 09:08:52 +00004073#line 1820 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004074 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004075 std::vector<const Type*> Params;
Reid Spencerb7046c72007-01-29 05:41:34 +00004076 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4077 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004078 Params.push_back(I->PAT->get());
Reid Spencer52402b02007-01-02 05:45:11 +00004079 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004080 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00004081 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4082 if (isVarArg) Params.pop_back();
4083
Reid Spencered96d1e2007-02-08 09:08:52 +00004084 (yyval.TypeVal).PAT = new PATypeHolder(
4085 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg,
4086 ParamAttrs)));
Reid Spencerb7046c72007-01-29 05:41:34 +00004087 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004088 delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle
Reid Spencerb7046c72007-01-29 05:41:34 +00004089 delete (yyvsp[-1].TypeList); // Delete the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00004090 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004091 break;
4092
4093 case 132:
Reid Spencered96d1e2007-02-08 09:08:52 +00004094#line 1837 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004095 { // Sized array type?
Reid Spencered96d1e2007-02-08 09:08:52 +00004096 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(),
Reid Spencerb7046c72007-01-29 05:41:34 +00004097 (unsigned)(yyvsp[-3].UInt64Val))));
4098 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004099 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004100 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004101 break;
4102
4103 case 133:
Reid Spencered96d1e2007-02-08 09:08:52 +00004104#line 1843 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004105 { // Packed array type?
Reid Spencered96d1e2007-02-08 09:08:52 +00004106 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerb7046c72007-01-29 05:41:34 +00004107 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004108 error("Unsigned result not equal to signed result");
4109 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4110 error("Elements of a PackedType must be integer or floating point");
Reid Spencerb7046c72007-01-29 05:41:34 +00004111 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004112 error("PackedType length should be a power of 2");
Reid Spencered96d1e2007-02-08 09:08:52 +00004113 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
Reid Spencerb7046c72007-01-29 05:41:34 +00004114 (unsigned)(yyvsp[-3].UInt64Val))));
4115 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004116 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004117 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004118 break;
4119
4120 case 134:
Reid Spencered96d1e2007-02-08 09:08:52 +00004121#line 1856 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004122 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004123 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004124 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4125 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencered96d1e2007-02-08 09:08:52 +00004126 Elements.push_back(I->PAT->get());
4127 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
Reid Spencer950bf602007-01-26 08:19:09 +00004128 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004129 delete (yyvsp[-1].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004130 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004131 break;
4132
4133 case 135:
Reid Spencered96d1e2007-02-08 09:08:52 +00004134#line 1865 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004135 { // Empty structure type?
Reid Spencered96d1e2007-02-08 09:08:52 +00004136 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer950bf602007-01-26 08:19:09 +00004137 (yyval.TypeVal).S = Signless;
4138 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004139 break;
4140
4141 case 136:
Reid Spencered96d1e2007-02-08 09:08:52 +00004142#line 1869 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004143 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004144 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004145 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4146 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004147 Elements.push_back(I->PAT->get());
4148 delete I->PAT;
Reid Spencer52402b02007-01-02 05:45:11 +00004149 }
Reid Spencered96d1e2007-02-08 09:08:52 +00004150 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
Reid Spencer950bf602007-01-26 08:19:09 +00004151 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004152 delete (yyvsp[-2].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004153 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004154 break;
4155
4156 case 137:
Reid Spencered96d1e2007-02-08 09:08:52 +00004157#line 1880 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004158 { // Empty packed structure type?
Reid Spencered96d1e2007-02-08 09:08:52 +00004159 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
Reid Spencer950bf602007-01-26 08:19:09 +00004160 (yyval.TypeVal).S = Signless;
4161 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004162 break;
4163
4164 case 138:
Reid Spencered96d1e2007-02-08 09:08:52 +00004165#line 1884 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004166 { // Pointer type?
Reid Spencered96d1e2007-02-08 09:08:52 +00004167 if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004168 error("Cannot form a pointer to a basic block");
Reid Spencered96d1e2007-02-08 09:08:52 +00004169 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get())));
Reid Spencerb7046c72007-01-29 05:41:34 +00004170 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004171 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004172 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004173 break;
4174
4175 case 139:
Reid Spencered96d1e2007-02-08 09:08:52 +00004176#line 1897 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004177 {
Reid Spencer950bf602007-01-26 08:19:09 +00004178 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004179 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004180 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004181 break;
4182
4183 case 140:
Reid Spencered96d1e2007-02-08 09:08:52 +00004184#line 1901 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004185 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004186 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004187 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004188 break;
4189
4190 case 142:
Reid Spencered96d1e2007-02-08 09:08:52 +00004191#line 1909 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004192 {
Reid Spencer950bf602007-01-26 08:19:09 +00004193 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004194 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencer950bf602007-01-26 08:19:09 +00004195 VoidTI.S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004196 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
Reid Spencer950bf602007-01-26 08:19:09 +00004197 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004198 break;
4199
4200 case 143:
Reid Spencered96d1e2007-02-08 09:08:52 +00004201#line 1915 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004202 {
Reid Spencer950bf602007-01-26 08:19:09 +00004203 (yyval.TypeList) = new std::list<PATypeInfo>();
4204 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004205 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencer950bf602007-01-26 08:19:09 +00004206 VoidTI.S = Signless;
4207 (yyval.TypeList)->push_back(VoidTI);
4208 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004209 break;
4210
4211 case 144:
Reid Spencered96d1e2007-02-08 09:08:52 +00004212#line 1922 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004213 {
Reid Spencer950bf602007-01-26 08:19:09 +00004214 (yyval.TypeList) = new std::list<PATypeInfo>();
4215 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004216 break;
4217
4218 case 145:
Reid Spencered96d1e2007-02-08 09:08:52 +00004219#line 1934 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004220 { // Nonempty unsized arr
Reid Spencered96d1e2007-02-08 09:08:52 +00004221 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004222 if (ATy == 0)
4223 error("Cannot make array constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004224 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004225 const Type *ETy = ATy->getElementType();
4226 int NumElements = ATy->getNumElements();
4227
4228 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004229 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004230 error("Type mismatch: constant sized array initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004231 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004232 itostr(NumElements) + "");
4233
4234 // Verify all elements are correct type!
4235 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004236 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4237 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004238 const Type* ValTy = C->getType();
4239 if (ETy != ValTy)
4240 error("Element #" + utostr(i) + " is not of type '" +
4241 ETy->getDescription() +"' as required!\nIt is of type '"+
4242 ValTy->getDescription() + "'");
4243 Elems.push_back(C);
4244 }
4245 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004246 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004247 delete (yyvsp[-3].TypeVal).PAT;
Reid Spencerb7046c72007-01-29 05:41:34 +00004248 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004249 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004250 break;
4251
4252 case 146:
Reid Spencered96d1e2007-02-08 09:08:52 +00004253#line 1964 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004254 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004255 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004256 if (ATy == 0)
4257 error("Cannot make array constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004258 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004259 int NumElements = ATy->getNumElements();
4260 if (NumElements != -1 && NumElements != 0)
4261 error("Type mismatch: constant sized array initialized with 0"
4262 " arguments, but has size of " + itostr(NumElements) +"");
4263 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004264 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004265 delete (yyvsp[-2].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004266 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004267 break;
4268
4269 case 147:
Reid Spencered96d1e2007-02-08 09:08:52 +00004270#line 1977 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004271 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004272 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004273 if (ATy == 0)
4274 error("Cannot make array constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004275 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004276 int NumElements = ATy->getNumElements();
4277 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4278 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4279 error("String arrays require type i8, not '" + ETy->getDescription() +
4280 "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004281 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4282 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004283 error("Can't build string constant of size " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004284 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004285 itostr(NumElements) + "");
4286 std::vector<Constant*> Vals;
Reid Spencerb7046c72007-01-29 05:41:34 +00004287 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004288 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencerb7046c72007-01-29 05:41:34 +00004289 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004290 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerb7046c72007-01-29 05:41:34 +00004291 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004292 delete (yyvsp[-2].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004293 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004294 break;
4295
4296 case 148:
Reid Spencered96d1e2007-02-08 09:08:52 +00004297#line 2000 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004298 { // Nonempty unsized arr
Reid Spencered96d1e2007-02-08 09:08:52 +00004299 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004300 if (PTy == 0)
4301 error("Cannot make packed constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004302 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004303 const Type *ETy = PTy->getElementType();
4304 int NumElements = PTy->getNumElements();
4305 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004306 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004307 error("Type mismatch: constant sized packed initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004308 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004309 itostr(NumElements) + "");
4310 // Verify all elements are correct type!
4311 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004312 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4313 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004314 const Type* ValTy = C->getType();
4315 if (ETy != ValTy)
4316 error("Element #" + utostr(i) + " is not of type '" +
4317 ETy->getDescription() +"' as required!\nIt is of type '"+
4318 ValTy->getDescription() + "'");
4319 Elems.push_back(C);
4320 }
4321 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004322 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004323 delete (yyvsp[-3].TypeVal).PAT;
Reid Spencerb7046c72007-01-29 05:41:34 +00004324 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004325 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004326 break;
4327
4328 case 149:
Reid Spencered96d1e2007-02-08 09:08:52 +00004329#line 2028 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004330 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004331 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004332 if (STy == 0)
4333 error("Cannot make struct constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004334 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004335 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004336 error("Illegal number of initializers for structure type");
4337
4338 // Check to ensure that constants are compatible with the type initializer!
4339 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004340 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4341 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004342 if (C->getType() != STy->getElementType(i))
4343 error("Expected type '" + STy->getElementType(i)->getDescription() +
4344 "' for element #" + utostr(i) + " of structure initializer");
4345 Fields.push_back(C);
4346 }
4347 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004348 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004349 delete (yyvsp[-3].TypeVal).PAT;
Reid Spencerb7046c72007-01-29 05:41:34 +00004350 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004351 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004352 break;
4353
4354 case 150:
Reid Spencered96d1e2007-02-08 09:08:52 +00004355#line 2050 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004356 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004357 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004358 if (STy == 0)
4359 error("Cannot make struct constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004360 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004361 if (STy->getNumContainedTypes() != 0)
4362 error("Illegal number of initializers for structure type");
4363 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004364 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004365 delete (yyvsp[-2].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004366 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004367 break;
4368
4369 case 151:
Reid Spencered96d1e2007-02-08 09:08:52 +00004370#line 2061 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004371 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004372 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004373 if (STy == 0)
4374 error("Cannot make packed struct constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004375 (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004376 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004377 error("Illegal number of initializers for packed structure type");
4378
4379 // Check to ensure that constants are compatible with the type initializer!
4380 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004381 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4382 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004383 if (C->getType() != STy->getElementType(i))
4384 error("Expected type '" + STy->getElementType(i)->getDescription() +
4385 "' for element #" + utostr(i) + " of packed struct initializer");
4386 Fields.push_back(C);
4387 }
4388 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004389 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004390 delete (yyvsp[-5].TypeVal).PAT;
Reid Spencerb7046c72007-01-29 05:41:34 +00004391 delete (yyvsp[-2].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004392 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004393 break;
4394
4395 case 152:
Reid Spencered96d1e2007-02-08 09:08:52 +00004396#line 2083 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004397 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004398 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004399 if (STy == 0)
4400 error("Cannot make packed struct constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004401 (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004402 if (STy->getNumContainedTypes() != 0)
4403 error("Illegal number of initializers for packed structure type");
4404 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004405 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004406 delete (yyvsp[-4].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004407 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004408 break;
4409
4410 case 153:
Reid Spencered96d1e2007-02-08 09:08:52 +00004411#line 2094 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004412 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004413 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004414 if (PTy == 0)
4415 error("Cannot make null pointer constant with type: '" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004416 (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004417 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00004418 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004419 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004420 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004421 break;
4422
4423 case 154:
Reid Spencered96d1e2007-02-08 09:08:52 +00004424#line 2103 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004425 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004426 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get());
Reid Spencerb7046c72007-01-29 05:41:34 +00004427 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004428 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004429 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004430 break;
4431
4432 case 155:
Reid Spencered96d1e2007-02-08 09:08:52 +00004433#line 2108 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004434 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004435 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004436 if (Ty == 0)
4437 error("Global const reference must be a pointer type, not" +
Reid Spencered96d1e2007-02-08 09:08:52 +00004438 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004439
4440 // ConstExprs can exist in the body of a function, thus creating
4441 // GlobalValues whenever they refer to a variable. Because we are in
4442 // the context of a function, getExistingValue will search the functions
4443 // symbol table instead of the module symbol table for the global symbol,
4444 // which throws things all off. To get around this, we just tell
4445 // getExistingValue that we are at global scope here.
4446 //
4447 Function *SavedCurFn = CurFun.CurrentFunction;
4448 CurFun.CurrentFunction = 0;
Reid Spencerb7046c72007-01-29 05:41:34 +00004449 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004450 CurFun.CurrentFunction = SavedCurFn;
4451
4452 // If this is an initializer for a constant pointer, which is referencing a
4453 // (currently) undefined variable, create a stub now that shall be replaced
4454 // in the future with the right type of variable.
4455 //
4456 if (V == 0) {
4457 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4458 const PointerType *PT = cast<PointerType>(Ty);
4459
4460 // First check to see if the forward references value is already created!
4461 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencerb7046c72007-01-29 05:41:34 +00004462 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004463
4464 if (I != CurModule.GlobalRefs.end()) {
4465 V = I->second; // Placeholder already exists, use it...
Reid Spencerb7046c72007-01-29 05:41:34 +00004466 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004467 } else {
4468 std::string Name;
Reid Spencerb7046c72007-01-29 05:41:34 +00004469 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004470
4471 // Create the forward referenced global.
4472 GlobalValue *GV;
4473 if (const FunctionType *FTy =
4474 dyn_cast<FunctionType>(PT->getElementType())) {
4475 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4476 CurModule.CurrentModule);
4477 } else {
4478 GV = new GlobalVariable(PT->getElementType(), false,
4479 GlobalValue::ExternalLinkage, 0,
4480 Name, CurModule.CurrentModule);
4481 }
4482
4483 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencerb7046c72007-01-29 05:41:34 +00004484 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004485 V = GV;
4486 }
4487 }
4488 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerb7046c72007-01-29 05:41:34 +00004489 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004490 delete (yyvsp[-1].TypeVal).PAT; // Free the type handle
Reid Spencer950bf602007-01-26 08:19:09 +00004491 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004492 break;
4493
4494 case 156:
Reid Spencered96d1e2007-02-08 09:08:52 +00004495#line 2166 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004496 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004497 if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004498 error("Mismatched types for constant expression");
Reid Spencerb7046c72007-01-29 05:41:34 +00004499 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4500 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004501 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004502 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004503 break;
4504
4505 case 157:
Reid Spencered96d1e2007-02-08 09:08:52 +00004506#line 2173 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004507 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004508 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004509 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4510 error("Cannot create a null initialized value of this type");
4511 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00004512 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00004513 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004514 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004515 break;
4516
4517 case 158:
Reid Spencered96d1e2007-02-08 09:08:52 +00004518#line 2181 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004519 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004520 const Type *Ty = (yyvsp[-1].PrimType).T;
4521 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004522 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004523 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004524 (yyval.ConstVal).S = Signed;
4525 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004526 break;
4527
4528 case 159:
Reid Spencered96d1e2007-02-08 09:08:52 +00004529#line 2188 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004530 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004531 const Type *Ty = (yyvsp[-1].PrimType).T;
4532 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004533 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004534 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004535 (yyval.ConstVal).S = Unsigned;
4536 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004537 break;
4538
4539 case 160:
Reid Spencered96d1e2007-02-08 09:08:52 +00004540#line 2195 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004541 { // Boolean constants
4542 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4543 (yyval.ConstVal).S = Unsigned;
4544 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004545 break;
4546
4547 case 161:
Reid Spencered96d1e2007-02-08 09:08:52 +00004548#line 2199 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004549 { // Boolean constants
4550 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4551 (yyval.ConstVal).S = Unsigned;
4552 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004553 break;
4554
4555 case 162:
Reid Spencered96d1e2007-02-08 09:08:52 +00004556#line 2203 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004557 { // Float & Double constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004558 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004559 error("Floating point constant invalid for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004560 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004561 (yyval.ConstVal).S = Signless;
4562 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004563 break;
4564
4565 case 163:
Reid Spencered96d1e2007-02-08 09:08:52 +00004566#line 2212 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004567 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004568 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
Reid Spencered96d1e2007-02-08 09:08:52 +00004569 const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerb7046c72007-01-29 05:41:34 +00004570 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4571 Signedness DstSign = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004572 if (!SrcTy->isFirstClassType())
4573 error("cast constant expression from a non-primitive type: '" +
4574 SrcTy->getDescription() + "'");
4575 if (!DstTy->isFirstClassType())
4576 error("cast constant expression to a non-primitive type: '" +
4577 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004578 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencer950bf602007-01-26 08:19:09 +00004579 (yyval.ConstVal).S = DstSign;
Reid Spencered96d1e2007-02-08 09:08:52 +00004580 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004581 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004582 break;
4583
4584 case 164:
Reid Spencered96d1e2007-02-08 09:08:52 +00004585#line 2227 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004586 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004587 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004588 if (!isa<PointerType>(Ty))
4589 error("GetElementPtr requires a pointer operand");
4590
4591 std::vector<Value*> VIndices;
4592 std::vector<Constant*> CIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00004593 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004594
Reid Spencerb7046c72007-01-29 05:41:34 +00004595 delete (yyvsp[-1].ValueList);
4596 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004597 (yyval.ConstVal).S = Signless;
4598 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004599 break;
4600
4601 case 165:
Reid Spencered96d1e2007-02-08 09:08:52 +00004602#line 2240 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004603 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004604 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4605 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004606 error("Select condition must be bool type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004607 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004608 error("Select operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004609 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004610 (yyval.ConstVal).S = Unsigned;
4611 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004612 break;
4613
4614 case 166:
Reid Spencered96d1e2007-02-08 09:08:52 +00004615#line 2249 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004616 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004617 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4618 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004619 error("Binary operator types must match");
4620 // First, make sure we're dealing with the right opcode by upgrading from
4621 // obsolete versions.
Reid Spencerb7046c72007-01-29 05:41:34 +00004622 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004623
4624 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4625 // To retain backward compatibility with these early compilers, we emit a
4626 // cast to the appropriate integer type automatically if we are in the
4627 // broken case. See PR424 for more information.
4628 if (!isa<PointerType>(Ty)) {
Reid Spencerb7046c72007-01-29 05:41:34 +00004629 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004630 } else {
4631 const Type *IntPtrTy = 0;
4632 switch (CurModule.CurrentModule->getPointerSize()) {
4633 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4634 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4635 default: error("invalid pointer binary constant expr");
4636 }
4637 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
Reid Spencerb7046c72007-01-29 05:41:34 +00004638 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4639 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
Reid Spencer950bf602007-01-26 08:19:09 +00004640 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4641 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004642 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004643 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004644 break;
4645
4646 case 167:
Reid Spencered96d1e2007-02-08 09:08:52 +00004647#line 2277 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004648 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004649 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4650 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004651 error("Logical operator types must match");
4652 if (!Ty->isInteger()) {
4653 if (!isa<PackedType>(Ty) ||
4654 !cast<PackedType>(Ty)->getElementType()->isInteger())
4655 error("Logical operator requires integer operands");
4656 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004657 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4658 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4659 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004660 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004661 break;
4662
4663 case 168:
Reid Spencered96d1e2007-02-08 09:08:52 +00004664#line 2290 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004665 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004666 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4667 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004668 error("setcc operand types must match");
4669 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00004670 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4671 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004672 (yyval.ConstVal).S = Unsigned;
4673 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004674 break;
4675
4676 case 169:
Reid Spencered96d1e2007-02-08 09:08:52 +00004677#line 2299 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004678 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004679 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004680 error("icmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004681 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004682 (yyval.ConstVal).S = Unsigned;
4683 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004684 break;
4685
4686 case 170:
Reid Spencered96d1e2007-02-08 09:08:52 +00004687#line 2305 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004688 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004689 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004690 error("fcmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004691 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004692 (yyval.ConstVal).S = Unsigned;
4693 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004694 break;
4695
4696 case 171:
Reid Spencered96d1e2007-02-08 09:08:52 +00004697#line 2311 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004698 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004699 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4700 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004701 error("Shift count for shift constant must be unsigned byte");
Reid Spencer832254e2007-02-02 02:16:23 +00004702 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
Reid Spencerb7046c72007-01-29 05:41:34 +00004703 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004704 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00004705 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4706 (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 +00004707 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004708 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004709 break;
4710
4711 case 172:
Reid Spencered96d1e2007-02-08 09:08:52 +00004712#line 2322 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004713 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004714 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004715 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004716 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4717 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004718 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004719 break;
4720
4721 case 173:
Reid Spencered96d1e2007-02-08 09:08:52 +00004722#line 2328 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004723 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004724 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004725 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004726 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4727 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004728 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004729 break;
4730
4731 case 174:
Reid Spencered96d1e2007-02-08 09:08:52 +00004732#line 2334 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004733 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004734 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004735 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004736 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4737 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004738 ;}
4739 break;
4740
4741 case 175:
Reid Spencered96d1e2007-02-08 09:08:52 +00004742#line 2345 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004743 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004744 break;
4745
4746 case 176:
Reid Spencered96d1e2007-02-08 09:08:52 +00004747#line 2346 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004748 {
4749 (yyval.ConstVector) = new std::vector<ConstInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004750 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004751 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004752 break;
4753
4754 case 177:
Reid Spencered96d1e2007-02-08 09:08:52 +00004755#line 2355 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004756 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004757 break;
4758
4759 case 178:
Reid Spencered96d1e2007-02-08 09:08:52 +00004760#line 2356 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004761 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004762 break;
4763
4764 case 179:
Reid Spencered96d1e2007-02-08 09:08:52 +00004765#line 2368 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004766 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004767 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004768 CurModule.ModuleDone();
4769 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004770 break;
4771
4772 case 180:
Reid Spencered96d1e2007-02-08 09:08:52 +00004773#line 2377 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004774 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004775 break;
4776
4777 case 181:
Reid Spencered96d1e2007-02-08 09:08:52 +00004778#line 2378 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004779 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004780 break;
4781
4782 case 182:
Reid Spencered96d1e2007-02-08 09:08:52 +00004783#line 2379 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004784 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004785 break;
4786
4787 case 183:
Reid Spencered96d1e2007-02-08 09:08:52 +00004788#line 2380 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004789 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004790 break;
4791
4792 case 184:
Reid Spencered96d1e2007-02-08 09:08:52 +00004793#line 2381 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004794 {
4795 (yyval.ModuleVal) = CurModule.CurrentModule;
4796 // Emit an error if there are any unresolved types left.
4797 if (!CurModule.LateResolveTypes.empty()) {
4798 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4799 if (DID.Type == ValID::NameVal) {
4800 error("Reference to an undefined type: '"+DID.getName() + "'");
4801 } else {
4802 error("Reference to an undefined type: #" + itostr(DID.Num));
4803 }
4804 }
4805 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004806 break;
4807
4808 case 185:
Reid Spencered96d1e2007-02-08 09:08:52 +00004809#line 2397 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004810 {
Reid Spencer950bf602007-01-26 08:19:09 +00004811 // Eagerly resolve types. This is not an optimization, this is a
4812 // requirement that is due to the fact that we could have this:
4813 //
4814 // %list = type { %list * }
4815 // %list = type { %list * } ; repeated type decl
4816 //
4817 // If types are not resolved eagerly, then the two types will not be
4818 // determined to be the same type!
4819 //
Reid Spencered96d1e2007-02-08 09:08:52 +00004820 const Type* Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerb7046c72007-01-29 05:41:34 +00004821 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004822
Reid Spencerb7046c72007-01-29 05:41:34 +00004823 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer950bf602007-01-26 08:19:09 +00004824 // If this is a named type that is not a redefinition, add it to the slot
4825 // table.
4826 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004827 }
Reid Spencered96d1e2007-02-08 09:08:52 +00004828 delete (yyvsp[0].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004829 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004830 break;
4831
4832 case 186:
Reid Spencered96d1e2007-02-08 09:08:52 +00004833#line 2417 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004834 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004835 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004836 break;
4837
4838 case 187:
Reid Spencered96d1e2007-02-08 09:08:52 +00004839#line 2419 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004840 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004841 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004842 break;
4843
4844 case 188:
Reid Spencered96d1e2007-02-08 09:08:52 +00004845#line 2421 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004846 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004847 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00004848 error("Global value initializer is not a constant");
Reid Spencerb7046c72007-01-29 05:41:34 +00004849 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 +00004850 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004851 break;
4852
4853 case 189:
Reid Spencered96d1e2007-02-08 09:08:52 +00004854#line 2425 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004855 {
Reid Spencer950bf602007-01-26 08:19:09 +00004856 CurGV = 0;
4857 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004858 break;
4859
4860 case 190:
Reid Spencered96d1e2007-02-08 09:08:52 +00004861#line 2428 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004862 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004863 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerb7046c72007-01-29 05:41:34 +00004864 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
Reid Spencered96d1e2007-02-08 09:08:52 +00004865 delete (yyvsp[0].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004866 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004867 break;
4868
4869 case 191:
Reid Spencered96d1e2007-02-08 09:08:52 +00004870#line 2432 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004871 {
Reid Spencer950bf602007-01-26 08:19:09 +00004872 CurGV = 0;
4873 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004874 break;
4875
4876 case 192:
Reid Spencered96d1e2007-02-08 09:08:52 +00004877#line 2435 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004878 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004879 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerb7046c72007-01-29 05:41:34 +00004880 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
Reid Spencered96d1e2007-02-08 09:08:52 +00004881 delete (yyvsp[0].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004882 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004883 break;
4884
4885 case 193:
Reid Spencered96d1e2007-02-08 09:08:52 +00004886#line 2439 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004887 {
Reid Spencer950bf602007-01-26 08:19:09 +00004888 CurGV = 0;
4889 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004890 break;
4891
4892 case 194:
Reid Spencered96d1e2007-02-08 09:08:52 +00004893#line 2442 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004894 {
Reid Spencered96d1e2007-02-08 09:08:52 +00004895 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004896 CurGV =
Reid Spencerb7046c72007-01-29 05:41:34 +00004897 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
Reid Spencered96d1e2007-02-08 09:08:52 +00004898 delete (yyvsp[0].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00004899 ;}
4900 break;
4901
4902 case 195:
Reid Spencered96d1e2007-02-08 09:08:52 +00004903#line 2447 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004904 {
4905 CurGV = 0;
4906 ;}
4907 break;
4908
4909 case 196:
Reid Spencered96d1e2007-02-08 09:08:52 +00004910#line 2450 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004911 {
Reid Spencer950bf602007-01-26 08:19:09 +00004912 ;}
4913 break;
4914
4915 case 197:
Reid Spencered96d1e2007-02-08 09:08:52 +00004916#line 2452 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004917 {
4918 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004919 break;
4920
4921 case 198:
Reid Spencered96d1e2007-02-08 09:08:52 +00004922#line 2454 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004923 {
4924 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004925 break;
4926
4927 case 199:
Reid Spencered96d1e2007-02-08 09:08:52 +00004928#line 2459 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004929 {
Reid Spencer950bf602007-01-26 08:19:09 +00004930 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencerb7046c72007-01-29 05:41:34 +00004931 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4932 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4933 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004934
4935 if (AsmSoFar.empty())
4936 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4937 else
4938 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4939 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004940 break;
4941
4942 case 200:
Reid Spencered96d1e2007-02-08 09:08:52 +00004943#line 2473 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004944 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004945 break;
4946
4947 case 201:
Reid Spencered96d1e2007-02-08 09:08:52 +00004948#line 2474 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004949 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004950 break;
4951
4952 case 202:
Reid Spencered96d1e2007-02-08 09:08:52 +00004953#line 2478 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004954 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004955 CurModule.setEndianness((yyvsp[0].Endianness));
Reid Spencer950bf602007-01-26 08:19:09 +00004956 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004957 break;
4958
4959 case 203:
Reid Spencered96d1e2007-02-08 09:08:52 +00004960#line 2481 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004961 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004962 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00004963 CurModule.setPointerSize(Module::Pointer32);
Reid Spencerb7046c72007-01-29 05:41:34 +00004964 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00004965 CurModule.setPointerSize(Module::Pointer64);
4966 else
Reid Spencerb7046c72007-01-29 05:41:34 +00004967 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004968 ;}
4969 break;
4970
4971 case 204:
Reid Spencered96d1e2007-02-08 09:08:52 +00004972#line 2489 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004973 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004974 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4975 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004976 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004977 break;
4978
4979 case 205:
Reid Spencered96d1e2007-02-08 09:08:52 +00004980#line 2493 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004981 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004982 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4983 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004984 ;}
4985 break;
4986
4987 case 207:
Reid Spencered96d1e2007-02-08 09:08:52 +00004988#line 2504 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004989 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004990 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4991 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004992 ;}
4993 break;
4994
4995 case 208:
Reid Spencered96d1e2007-02-08 09:08:52 +00004996#line 2508 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004997 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004998 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4999 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005000 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005001 break;
5002
5003 case 209:
Reid Spencered96d1e2007-02-08 09:08:52 +00005004#line 2512 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005005 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005006 break;
5007
Reid Spencerc4d96252007-01-13 00:03:30 +00005008 case 213:
Reid Spencered96d1e2007-02-08 09:08:52 +00005009#line 2525 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005010 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005011 break;
5012
Reid Spencer319a7302007-01-05 17:20:02 +00005013 case 214:
Reid Spencered96d1e2007-02-08 09:08:52 +00005014#line 2529 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005015 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005016 if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy)
Reid Spencer950bf602007-01-26 08:19:09 +00005017 error("void typed arguments are invalid");
Reid Spencerb7046c72007-01-29 05:41:34 +00005018 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005019 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005020 break;
5021
5022 case 215:
Reid Spencered96d1e2007-02-08 09:08:52 +00005023#line 2537 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005024 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005025 (yyval.ArgList) = (yyvsp[-2].ArgList);
5026 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5027 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005028 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005029 break;
5030
5031 case 216:
Reid Spencered96d1e2007-02-08 09:08:52 +00005032#line 2542 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005033 {
5034 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005035 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5036 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005037 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005038 break;
5039
5040 case 217:
Reid Spencered96d1e2007-02-08 09:08:52 +00005041#line 2550 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005042 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005043 break;
5044
5045 case 218:
Reid Spencered96d1e2007-02-08 09:08:52 +00005046#line 2551 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005047 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005048 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer950bf602007-01-26 08:19:09 +00005049 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00005050 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencer950bf602007-01-26 08:19:09 +00005051 VoidTI.S = Signless;
5052 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5053 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005054 break;
5055
5056 case 219:
Reid Spencered96d1e2007-02-08 09:08:52 +00005057#line 2558 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005058 {
5059 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5060 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00005061 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencer950bf602007-01-26 08:19:09 +00005062 VoidTI.S = Signless;
5063 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5064 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005065 break;
5066
5067 case 220:
Reid Spencered96d1e2007-02-08 09:08:52 +00005068#line 2565 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005069 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005070 break;
5071
5072 case 221:
Reid Spencered96d1e2007-02-08 09:08:52 +00005073#line 2569 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005074 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005075 UnEscapeLexed((yyvsp[-5].StrVal));
5076 std::string FunctionName((yyvsp[-5].StrVal));
5077 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer950bf602007-01-26 08:19:09 +00005078
Reid Spencered96d1e2007-02-08 09:08:52 +00005079 const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005080
5081 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5082 error("LLVM functions cannot return aggregate types");
5083
Reid Spenceref9b9a72007-02-05 20:47:22 +00005084 std::vector<const Type*> ParamTyList;
Reid Spencer950bf602007-01-26 08:19:09 +00005085
5086 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5087 // i8*. We check here for those names and override the parameter list
5088 // types to ensure the prototype is correct.
5089 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005090 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00005091 } else if (FunctionName == "llvm.va_copy") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005092 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5093 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencerb7046c72007-01-29 05:41:34 +00005094 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005095 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencerb7046c72007-01-29 05:41:34 +00005096 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005097 const Type *Ty = I->first.PAT->get();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005098 ParamTyList.push_back(Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00005099 }
5100 }
5101
Reid Spenceref9b9a72007-02-05 20:47:22 +00005102 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5103 if (isVarArg)
5104 ParamTyList.pop_back();
Reid Spencer950bf602007-01-26 08:19:09 +00005105
Reid Spencerb7046c72007-01-29 05:41:34 +00005106 // Convert the CSRet calling convention into the corresponding parameter
5107 // attribute.
5108 FunctionType::ParamAttrsList ParamAttrs;
5109 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
5110 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5111 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5112 }
5113
Reid Spenceref9b9a72007-02-05 20:47:22 +00005114 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
Reid Spencerb7046c72007-01-29 05:41:34 +00005115 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005116 const PointerType *PFT = PointerType::get(FT);
Reid Spencered96d1e2007-02-08 09:08:52 +00005117 delete (yyvsp[-6].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005118
5119 ValID ID;
5120 if (!FunctionName.empty()) {
5121 ID = ValID::create((char*)FunctionName.c_str());
5122 } else {
5123 ID = ValID::create((int)CurModule.Values[PFT].size());
5124 }
5125
5126 Function *Fn = 0;
Reid Spencered96d1e2007-02-08 09:08:52 +00005127 Module* M = CurModule.CurrentModule;
5128
Reid Spencer950bf602007-01-26 08:19:09 +00005129 // See if this function was forward referenced. If so, recycle the object.
5130 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5131 // Move the function to the end of the list, from whereever it was
5132 // previously inserted.
5133 Fn = cast<Function>(FWRef);
Reid Spencered96d1e2007-02-08 09:08:52 +00005134 M->getFunctionList().remove(Fn);
5135 M->getFunctionList().push_back(Fn);
5136 } else if (!FunctionName.empty()) {
5137 GlobalValue *Conflict = M->getFunction(FunctionName);
5138 if (!Conflict)
5139 Conflict = M->getNamedGlobal(FunctionName);
5140 if (Conflict && PFT == Conflict->getType()) {
5141 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5142 // We have two function definitions that conflict, same type, same
5143 // name. We should really check to make sure that this is the result
5144 // of integer type planes collapsing and generate an error if it is
5145 // not, but we'll just rename on the assumption that it is. However,
5146 // let's do it intelligently and rename the internal linkage one
5147 // if there is one.
5148 std::string NewName(makeNameUnique(FunctionName));
5149 if (Conflict->hasInternalLinkage()) {
5150 Conflict->setName(NewName);
5151 RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
5152 CurModule.RenameMap[Key] = NewName;
5153 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5154 InsertValue(Fn, CurModule.Values);
5155 } else {
5156 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5157 InsertValue(Fn, CurModule.Values);
5158 RenameMapKey Key = std::make_pair(FunctionName,PFT);
5159 CurModule.RenameMap[Key] = NewName;
5160 }
5161 } else {
5162 // If they are not both definitions, then just use the function we
5163 // found since the types are the same.
5164 Fn = cast<Function>(Conflict);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005165
Reid Spencered96d1e2007-02-08 09:08:52 +00005166 // Make sure to strip off any argument names so we can't get
5167 // conflicts.
5168 if (Fn->isDeclaration())
5169 for (Function::arg_iterator AI = Fn->arg_begin(),
5170 AE = Fn->arg_end(); AI != AE; ++AI)
5171 AI->setName("");
5172 }
5173 } else if (Conflict) {
5174 // We have two globals with the same name and different types.
5175 // Previously, this was permitted because the symbol table had
5176 // "type planes" and names only needed to be distinct within a
5177 // type plane. After PR411 was fixed, this is no loner the case.
5178 // To resolve this we must rename one of the two.
5179 if (Conflict->hasInternalLinkage()) {
5180 // We can safely renamed the Conflict.
5181 Conflict->setName(makeNameUnique(Conflict->getName()));
5182 RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
5183 CurModule.RenameMap[Key] = Conflict->getName();
5184 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5185 InsertValue(Fn, CurModule.Values);
5186 } else if (CurFun.Linkage == GlobalValue::InternalLinkage) {
5187 // We can safely rename the function we're defining
5188 std::string NewName = makeNameUnique(FunctionName);
5189 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5190 InsertValue(Fn, CurModule.Values);
5191 RenameMapKey Key = std::make_pair(FunctionName,PFT);
5192 CurModule.RenameMap[Key] = NewName;
5193 } else {
5194 // We can't quietly rename either of these things, but we must
5195 // rename one of them. Generate a warning about the renaming and
5196 // elect to rename the thing we're now defining.
5197 std::string NewName = makeNameUnique(FunctionName);
5198 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5199 "' may cause linkage errors");
5200 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5201 InsertValue(Fn, CurModule.Values);
5202 RenameMapKey Key = std::make_pair(FunctionName,PFT);
5203 CurModule.RenameMap[Key] = NewName;
5204 }
Reid Spenceref9b9a72007-02-05 20:47:22 +00005205 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005206 // There's no conflict, just define the function
5207 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5208 InsertValue(Fn, CurModule.Values);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005209 }
Reid Spencer950bf602007-01-26 08:19:09 +00005210 }
5211
5212 CurFun.FunctionStart(Fn);
5213
5214 if (CurFun.isDeclare) {
5215 // If we have declaration, always overwrite linkage. This will allow us
5216 // to correctly handle cases, when pointer to function is passed as
5217 // argument to another function.
5218 Fn->setLinkage(CurFun.Linkage);
5219 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005220 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5221 Fn->setAlignment((yyvsp[0].UIntVal));
5222 if ((yyvsp[-1].StrVal)) {
5223 Fn->setSection((yyvsp[-1].StrVal));
5224 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005225 }
5226
5227 // Add all of the arguments we parsed to the function...
Reid Spencerb7046c72007-01-29 05:41:34 +00005228 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005229 if (isVarArg) { // Nuke the last entry
Reid Spencered96d1e2007-02-08 09:08:52 +00005230 assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005231 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
Reid Spencered96d1e2007-02-08 09:08:52 +00005232 delete (yyvsp[-3].ArgList)->back().first.PAT;
Reid Spencerb7046c72007-01-29 05:41:34 +00005233 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005234 }
5235 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005236 Function::arg_iterator ArgEnd = Fn->arg_end();
5237 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
5238 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end();
5239 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005240 delete I->first.PAT; // Delete the typeholder...
Reid Spencer950bf602007-01-26 08:19:09 +00005241 setValueName(ArgIt, I->second); // Insert arg into symtab...
5242 InsertValue(ArgIt);
5243 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005244 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005245 }
5246 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005247 break;
5248
5249 case 224:
Reid Spencered96d1e2007-02-08 09:08:52 +00005250#line 2749 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005251 {
5252 (yyval.FunctionVal) = CurFun.CurrentFunction;
5253
5254 // Make sure that we keep track of the linkage type even if there was a
5255 // previous "declare".
Reid Spencerb7046c72007-01-29 05:41:34 +00005256 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Reid Spencer950bf602007-01-26 08:19:09 +00005257 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005258 break;
5259
5260 case 227:
Reid Spencered96d1e2007-02-08 09:08:52 +00005261#line 2763 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005262 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005263 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005264 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005265 break;
5266
Reid Spencered96d1e2007-02-08 09:08:52 +00005267 case 228:
5268#line 2768 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
5269 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5270 break;
5271
Reid Spencerc4d96252007-01-13 00:03:30 +00005272 case 229:
Reid Spencered96d1e2007-02-08 09:08:52 +00005273#line 2769 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
5274 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005275 break;
5276
5277 case 230:
Reid Spencered96d1e2007-02-08 09:08:52 +00005278#line 2770 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
5279 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005280 break;
5281
5282 case 231:
Reid Spencered96d1e2007-02-08 09:08:52 +00005283#line 2774 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005284 { CurFun.isDeclare = true; ;}
5285 break;
5286
5287 case 232:
Reid Spencered96d1e2007-02-08 09:08:52 +00005288#line 2775 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
5289 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5290 break;
5291
5292 case 233:
5293#line 2775 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005294 {
5295 (yyval.FunctionVal) = CurFun.CurrentFunction;
5296 CurFun.FunctionDone();
5297
5298 ;}
5299 break;
5300
Reid Spencered96d1e2007-02-08 09:08:52 +00005301 case 234:
5302#line 2787 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005303 { (yyval.BoolVal) = false; ;}
5304 break;
5305
Reid Spencered96d1e2007-02-08 09:08:52 +00005306 case 235:
5307#line 2788 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005308 { (yyval.BoolVal) = true; ;}
5309 break;
5310
Reid Spencered96d1e2007-02-08 09:08:52 +00005311 case 236:
5312#line 2793 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005313 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005314 break;
5315
Reid Spencered96d1e2007-02-08 09:08:52 +00005316 case 237:
5317#line 2794 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005318 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005319 break;
5320
Reid Spencered96d1e2007-02-08 09:08:52 +00005321 case 238:
5322#line 2795 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005323 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005324 break;
5325
Reid Spencered96d1e2007-02-08 09:08:52 +00005326 case 239:
5327#line 2796 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005328 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005329 break;
5330
Reid Spencered96d1e2007-02-08 09:08:52 +00005331 case 240:
5332#line 2797 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005333 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5334 break;
5335
Reid Spencered96d1e2007-02-08 09:08:52 +00005336 case 241:
5337#line 2798 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005338 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005339 break;
5340
Reid Spencered96d1e2007-02-08 09:08:52 +00005341 case 242:
5342#line 2799 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005343 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5344 break;
5345
Reid Spencered96d1e2007-02-08 09:08:52 +00005346 case 243:
5347#line 2800 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005348 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5349 break;
5350
Reid Spencered96d1e2007-02-08 09:08:52 +00005351 case 244:
5352#line 2801 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005353 { // Nonempty unsized packed vector
Reid Spencerb7046c72007-01-29 05:41:34 +00005354 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5355 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer950bf602007-01-26 08:19:09 +00005356 PackedType* pt = PackedType::get(ETy, NumElements);
5357 PATypeHolder* PTy = new PATypeHolder(
5358 HandleUpRefs(PackedType::get(ETy, NumElements)));
5359
5360 // Verify all elements are correct type!
5361 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00005362 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5363 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005364 const Type *CTy = C->getType();
5365 if (ETy != CTy)
5366 error("Element #" + utostr(i) + " is not of type '" +
5367 ETy->getDescription() +"' as required!\nIt is of type '" +
5368 CTy->getDescription() + "'");
5369 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005370 }
Reid Spencer950bf602007-01-26 08:19:09 +00005371 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
Reid Spencerb7046c72007-01-29 05:41:34 +00005372 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00005373 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005374 break;
5375
Reid Spencered96d1e2007-02-08 09:08:52 +00005376 case 245:
5377#line 2822 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005378 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005379 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00005380 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005381 break;
5382
Reid Spencered96d1e2007-02-08 09:08:52 +00005383 case 246:
5384#line 2825 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005385 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005386 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5387 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5388 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5389 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5390 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5391 free((yyvsp[-2].StrVal));
5392 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005393 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005394 break;
5395
Reid Spencered96d1e2007-02-08 09:08:52 +00005396 case 247:
5397#line 2840 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005398 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005399 break;
5400
Reid Spencered96d1e2007-02-08 09:08:52 +00005401 case 248:
5402#line 2841 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005403 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005404 break;
5405
Reid Spencered96d1e2007-02-08 09:08:52 +00005406 case 251:
5407#line 2854 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005408 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005409 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerb7046c72007-01-29 05:41:34 +00005410 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5411 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencered96d1e2007-02-08 09:08:52 +00005412 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005413 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005414 break;
5415
Reid Spencered96d1e2007-02-08 09:08:52 +00005416 case 252:
5417#line 2863 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005418 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005419 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005420 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005421 break;
5422
Reid Spencered96d1e2007-02-08 09:08:52 +00005423 case 253:
5424#line 2866 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005425 { // Do not allow functions with 0 basic blocks
Reid Spencerb7046c72007-01-29 05:41:34 +00005426 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005427 ;}
5428 break;
5429
Reid Spencered96d1e2007-02-08 09:08:52 +00005430 case 254:
5431#line 2875 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005432 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005433 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5434 InsertValue((yyvsp[0].TermInstVal));
5435 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5436 InsertValue((yyvsp[-2].BasicBlockVal));
5437 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005438 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005439 break;
5440
Reid Spencered96d1e2007-02-08 09:08:52 +00005441 case 255:
5442#line 2885 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005443 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005444 if ((yyvsp[0].InstVal).I)
5445 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5446 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005447 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005448 break;
5449
Reid Spencered96d1e2007-02-08 09:08:52 +00005450 case 256:
5451#line 2890 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005452 {
5453 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5454 // Make sure to move the basic block to the correct location in the
5455 // function, instead of leaving it inserted wherever it was first
5456 // referenced.
5457 Function::BasicBlockListType &BBL =
5458 CurFun.CurrentFunction->getBasicBlockList();
5459 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5460 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005461 break;
5462
Reid Spencered96d1e2007-02-08 09:08:52 +00005463 case 257:
5464#line 2899 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005465 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005466 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005467 // Make sure to move the basic block to the correct location in the
5468 // function, instead of leaving it inserted wherever it was first
5469 // referenced.
5470 Function::BasicBlockListType &BBL =
5471 CurFun.CurrentFunction->getBasicBlockList();
5472 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5473 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005474 break;
5475
Reid Spencered96d1e2007-02-08 09:08:52 +00005476 case 260:
5477#line 2913 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005478 { // Return with a result...
Reid Spencerb7046c72007-01-29 05:41:34 +00005479 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005480 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005481 break;
5482
Reid Spencered96d1e2007-02-08 09:08:52 +00005483 case 261:
5484#line 2916 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005485 { // Return with no result...
5486 (yyval.TermInstVal) = new ReturnInst();
5487 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005488 break;
5489
Reid Spencered96d1e2007-02-08 09:08:52 +00005490 case 262:
5491#line 2919 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005492 { // Unconditional Branch...
Reid Spencerb7046c72007-01-29 05:41:34 +00005493 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005494 (yyval.TermInstVal) = new BranchInst(tmpBB);
5495 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005496 break;
5497
Reid Spencered96d1e2007-02-08 09:08:52 +00005498 case 263:
5499#line 2923 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005500 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005501 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5502 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5503 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005504 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5505 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005506 break;
5507
Reid Spencered96d1e2007-02-08 09:08:52 +00005508 case 264:
5509#line 2929 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005510 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005511 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5512 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5513 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencer950bf602007-01-26 08:19:09 +00005514 (yyval.TermInstVal) = S;
Reid Spencerb7046c72007-01-29 05:41:34 +00005515 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5516 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005517 for (; I != E; ++I) {
5518 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5519 S->addCase(CI, I->second);
5520 else
5521 error("Switch case is constant, but not a simple integer");
5522 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005523 delete (yyvsp[-1].JumpTable);
Reid Spencer950bf602007-01-26 08:19:09 +00005524 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005525 break;
5526
Reid Spencered96d1e2007-02-08 09:08:52 +00005527 case 265:
5528#line 2944 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005529 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005530 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5531 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005532 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5533 (yyval.TermInstVal) = S;
5534 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005535 break;
5536
Reid Spencered96d1e2007-02-08 09:08:52 +00005537 case 266:
5538#line 2951 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005539 {
Reid Spencer950bf602007-01-26 08:19:09 +00005540 const PointerType *PFTy;
5541 const FunctionType *Ty;
5542
Reid Spencered96d1e2007-02-08 09:08:52 +00005543 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005544 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5545 // Pull out the types of all of the arguments...
5546 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005547 if ((yyvsp[-7].ValueList)) {
5548 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005549 I != E; ++I)
5550 ParamTypes.push_back((*I).V->getType());
5551 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005552 FunctionType::ParamAttrsList ParamAttrs;
5553 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
5554 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5555 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5556 }
Reid Spencer950bf602007-01-26 08:19:09 +00005557 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5558 if (isVarArg) ParamTypes.pop_back();
Reid Spencered96d1e2007-02-08 09:08:52 +00005559 Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005560 PFTy = PointerType::get(Ty);
5561 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005562 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5563 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5564 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005565
5566 // Create the call node...
Reid Spencerb7046c72007-01-29 05:41:34 +00005567 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005568 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5569 } else { // Has arguments?
5570 // Loop through FunctionType's arguments and ensure they are specified
5571 // correctly!
5572 //
5573 FunctionType::param_iterator I = Ty->param_begin();
5574 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00005575 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005576
5577 std::vector<Value*> Args;
5578 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5579 if ((*ArgI).V->getType() != *I)
5580 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5581 (*I)->getDescription() + "'");
5582 Args.push_back((*ArgI).V);
5583 }
5584
5585 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5586 error("Invalid number of parameters detected");
5587
5588 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5589 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005590 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
Reid Spencered96d1e2007-02-08 09:08:52 +00005591 delete (yyvsp[-10].TypeVal).PAT;
Reid Spencerb7046c72007-01-29 05:41:34 +00005592 delete (yyvsp[-7].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005593 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005594 break;
5595
Reid Spencered96d1e2007-02-08 09:08:52 +00005596 case 267:
5597#line 3006 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005598 {
Reid Spencer950bf602007-01-26 08:19:09 +00005599 (yyval.TermInstVal) = new UnwindInst();
5600 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005601 break;
5602
Reid Spencered96d1e2007-02-08 09:08:52 +00005603 case 268:
5604#line 3009 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005605 {
5606 (yyval.TermInstVal) = new UnreachableInst();
5607 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005608 break;
5609
Reid Spencered96d1e2007-02-08 09:08:52 +00005610 case 269:
5611#line 3015 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005612 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005613 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5614 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005615
5616 if (V == 0)
5617 error("May only switch on a constant pool value");
5618
Reid Spencerb7046c72007-01-29 05:41:34 +00005619 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005620 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5621 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005622 break;
5623
Reid Spencered96d1e2007-02-08 09:08:52 +00005624 case 270:
5625#line 3025 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005626 {
Reid Spencer950bf602007-01-26 08:19:09 +00005627 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005628 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005629
5630 if (V == 0)
5631 error("May only switch on a constant pool value");
5632
Reid Spencerb7046c72007-01-29 05:41:34 +00005633 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005634 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5635 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005636 break;
5637
Reid Spencered96d1e2007-02-08 09:08:52 +00005638 case 271:
5639#line 3038 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005640 {
Reid Spencer950bf602007-01-26 08:19:09 +00005641 bool omit = false;
Reid Spencerb7046c72007-01-29 05:41:34 +00005642 if ((yyvsp[-1].StrVal))
5643 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005644 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005645 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005646 // This is a useless bit cast causing a name redefinition. It is
5647 // a bit cast from a type to the same type of an operand with the
5648 // same name as the name we would give this instruction. Since this
5649 // instruction results in no code generation, it is safe to omit
5650 // the instruction. This situation can occur because of collapsed
5651 // type planes. For example:
5652 // %X = add int %Y, %Z
5653 // %X = cast int %Y to uint
5654 // After upgrade, this looks like:
5655 // %X = add i32 %Y, %Z
5656 // %X = bitcast i32 to i32
5657 // The bitcast is clearly useless so we omit it.
5658 omit = true;
5659 if (omit) {
5660 (yyval.InstVal).I = 0;
5661 (yyval.InstVal).S = Signless;
5662 } else {
Reid Spencerb7046c72007-01-29 05:41:34 +00005663 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5664 InsertValue((yyvsp[0].InstVal).I);
5665 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005666 }
5667 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005668 break;
5669
Reid Spencered96d1e2007-02-08 09:08:52 +00005670 case 272:
5671#line 3067 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005672 { // Used for PHI nodes
5673 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005674 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00005675 Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal));
Reid Spencerb7046c72007-01-29 05:41:34 +00005676 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005677 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencered96d1e2007-02-08 09:08:52 +00005678 delete (yyvsp[-5].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005679 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005680 break;
5681
Reid Spencered96d1e2007-02-08 09:08:52 +00005682 case 273:
5683#line 3075 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005684 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005685 (yyval.PHIList) = (yyvsp[-6].PHIList);
5686 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5687 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5688 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer950bf602007-01-26 08:19:09 +00005689 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005690 break;
5691
Reid Spencered96d1e2007-02-08 09:08:52 +00005692 case 274:
5693#line 3083 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005694 { // Used for call statements, and memory insts...
5695 (yyval.ValueList) = new std::vector<ValueInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00005696 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005697 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005698 break;
5699
Reid Spencered96d1e2007-02-08 09:08:52 +00005700 case 275:
5701#line 3087 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005702 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005703 (yyval.ValueList) = (yyvsp[-2].ValueList);
5704 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005705 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005706 break;
5707
Reid Spencered96d1e2007-02-08 09:08:52 +00005708 case 277:
5709#line 3095 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005710 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005711 break;
5712
Reid Spencered96d1e2007-02-08 09:08:52 +00005713 case 278:
5714#line 3099 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005715 {
Reid Spencer950bf602007-01-26 08:19:09 +00005716 (yyval.BoolVal) = true;
5717 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005718 break;
5719
Reid Spencered96d1e2007-02-08 09:08:52 +00005720 case 279:
5721#line 3102 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005722 {
Reid Spencer950bf602007-01-26 08:19:09 +00005723 (yyval.BoolVal) = false;
5724 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005725 break;
5726
Reid Spencered96d1e2007-02-08 09:08:52 +00005727 case 280:
5728#line 3108 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005729 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005730 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005731 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5732 error("Arithmetic operator requires integer, FP, or packed operands");
5733 if (isa<PackedType>(Ty) &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005734 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Reid Spencer950bf602007-01-26 08:19:09 +00005735 error("Remainder not supported on packed types");
5736 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencerb7046c72007-01-29 05:41:34 +00005737 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5738 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5739 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005740 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5741 if ((yyval.InstVal).I == 0)
5742 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005743 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00005744 delete (yyvsp[-3].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005745 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005746 break;
5747
Reid Spencered96d1e2007-02-08 09:08:52 +00005748 case 281:
5749#line 3125 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005750 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005751 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005752 if (!Ty->isInteger()) {
5753 if (!isa<PackedType>(Ty) ||
5754 !cast<PackedType>(Ty)->getElementType()->isInteger())
5755 error("Logical operator requires integral operands");
5756 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005757 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5758 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5759 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005760 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5761 if ((yyval.InstVal).I == 0)
5762 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005763 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00005764 delete (yyvsp[-3].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005765 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005766 break;
5767
Reid Spencered96d1e2007-02-08 09:08:52 +00005768 case 282:
5769#line 3141 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005770 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005771 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005772 if(isa<PackedType>(Ty))
5773 error("PackedTypes currently not supported in setcc instructions");
5774 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00005775 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5776 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5777 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005778 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5779 if ((yyval.InstVal).I == 0)
5780 error("binary operator returned null");
5781 (yyval.InstVal).S = Unsigned;
Reid Spencered96d1e2007-02-08 09:08:52 +00005782 delete (yyvsp[-3].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005783 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005784 break;
5785
Reid Spencered96d1e2007-02-08 09:08:52 +00005786 case 283:
5787#line 3155 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005788 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005789 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005790 if (isa<PackedType>(Ty))
5791 error("PackedTypes currently not supported in icmp instructions");
5792 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5793 error("icmp requires integer or pointer typed operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005794 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5795 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5796 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005797 (yyval.InstVal).S = Unsigned;
Reid Spencered96d1e2007-02-08 09:08:52 +00005798 delete (yyvsp[-3].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005799 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005800 break;
5801
Reid Spencered96d1e2007-02-08 09:08:52 +00005802 case 284:
5803#line 3167 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005804 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005805 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005806 if (isa<PackedType>(Ty))
5807 error("PackedTypes currently not supported in fcmp instructions");
5808 else if (!Ty->isFloatingPoint())
5809 error("fcmp instruction requires floating point operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005810 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5811 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5812 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005813 (yyval.InstVal).S = Unsigned;
Reid Spencered96d1e2007-02-08 09:08:52 +00005814 delete (yyvsp[-3].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005815 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005816 break;
5817
Reid Spencered96d1e2007-02-08 09:08:52 +00005818 case 285:
5819#line 3179 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005820 {
Reid Spencer950bf602007-01-26 08:19:09 +00005821 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencerb7046c72007-01-29 05:41:34 +00005822 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005823 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5824 if (Ones == 0)
5825 error("Expected integral type for not instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005826 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
Reid Spencer950bf602007-01-26 08:19:09 +00005827 if ((yyval.InstVal).I == 0)
5828 error("Could not create a xor instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005829 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
Reid Spencer950bf602007-01-26 08:19:09 +00005830 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005831 break;
5832
Reid Spencered96d1e2007-02-08 09:08:52 +00005833 case 286:
5834#line 3190 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005835 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005836 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5837 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005838 error("Shift amount must be int8");
Reid Spencer832254e2007-02-02 02:16:23 +00005839 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
5840 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005841 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00005842 Value* ShiftAmt = 0;
5843 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
5844 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
5845 ShiftAmt = ConstantExpr::getZExt(C, Ty);
5846 else
5847 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
5848 else
5849 ShiftAmt = (yyvsp[0].ValueVal).V;
5850 (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 +00005851 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005852 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005853 break;
5854
Reid Spencered96d1e2007-02-08 09:08:52 +00005855 case 287:
5856#line 3208 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005857 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005858 const Type *DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005859 if (!DstTy->isFirstClassType())
5860 error("cast instruction to a non-primitive type: '" +
5861 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00005862 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5863 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00005864 delete (yyvsp[0].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005865 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005866 break;
5867
Reid Spencered96d1e2007-02-08 09:08:52 +00005868 case 288:
5869#line 3217 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005870 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005871 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5872 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005873 error("select condition must be bool");
Reid Spencerb7046c72007-01-29 05:41:34 +00005874 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005875 error("select value types should match");
Reid Spencerb7046c72007-01-29 05:41:34 +00005876 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5877 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005878 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005879 break;
5880
Reid Spencered96d1e2007-02-08 09:08:52 +00005881 case 289:
5882#line 3226 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005883 {
Reid Spencered96d1e2007-02-08 09:08:52 +00005884 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005885 NewVarArgs = true;
Reid Spencerb7046c72007-01-29 05:41:34 +00005886 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5887 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00005888 delete (yyvsp[0].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005889 ;}
5890 break;
5891
Reid Spencered96d1e2007-02-08 09:08:52 +00005892 case 290:
5893#line 3233 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005894 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005895 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
Reid Spencered96d1e2007-02-08 09:08:52 +00005896 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005897 ObsoleteVarArgs = true;
5898 Function* NF = cast<Function>(CurModule.CurrentModule->
5899 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5900
5901 //b = vaarg a, t ->
5902 //foo = alloca 1 of t
5903 //bar = vacopy a
5904 //store bar -> foo
5905 //b = vaarg foo, t
5906 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5907 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005908 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005909 CurBB->getInstList().push_back(bar);
5910 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5911 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00005912 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00005913 delete (yyvsp[0].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005914 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005915 break;
5916
Reid Spencered96d1e2007-02-08 09:08:52 +00005917 case 291:
5918#line 3254 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005919 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005920 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
Reid Spencered96d1e2007-02-08 09:08:52 +00005921 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005922 ObsoleteVarArgs = true;
5923 Function* NF = cast<Function>(CurModule.CurrentModule->
5924 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5925
5926 //b = vanext a, t ->
5927 //foo = alloca 1 of t
5928 //bar = vacopy a
5929 //store bar -> foo
5930 //tmp = vaarg foo, t
5931 //b = load foo
5932 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5933 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005934 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005935 CurBB->getInstList().push_back(bar);
5936 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5937 Instruction* tmp = new VAArgInst(foo, DstTy);
5938 CurBB->getInstList().push_back(tmp);
5939 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005940 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
Reid Spencered96d1e2007-02-08 09:08:52 +00005941 delete (yyvsp[0].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005942 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005943 break;
5944
Reid Spencered96d1e2007-02-08 09:08:52 +00005945 case 292:
5946#line 3278 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005947 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005948 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005949 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005950 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5951 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005952 ;}
5953 break;
5954
Reid Spencered96d1e2007-02-08 09:08:52 +00005955 case 293:
5956#line 3284 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005957 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005958 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005959 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005960 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5961 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005962 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005963 break;
5964
Reid Spencered96d1e2007-02-08 09:08:52 +00005965 case 294:
5966#line 3290 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005967 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005968 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005969 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005970 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5971 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005972 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005973 break;
5974
Reid Spencered96d1e2007-02-08 09:08:52 +00005975 case 295:
5976#line 3296 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005977 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005978 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005979 if (!Ty->isFirstClassType())
5980 error("PHI node operands must be of first class type");
5981 PHINode *PHI = new PHINode(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00005982 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5983 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5984 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00005985 error("All elements of a PHI node must be of the same type");
Reid Spencerb7046c72007-01-29 05:41:34 +00005986 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5987 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00005988 }
5989 (yyval.InstVal).I = PHI;
Reid Spencerb7046c72007-01-29 05:41:34 +00005990 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5991 delete (yyvsp[0].PHIList).P; // Free the list...
Reid Spencer950bf602007-01-26 08:19:09 +00005992 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005993 break;
5994
Reid Spencered96d1e2007-02-08 09:08:52 +00005995 case 296:
5996#line 3312 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005997 {
Reid Spencer950bf602007-01-26 08:19:09 +00005998
5999 // Handle the short call syntax
6000 const PointerType *PFTy;
6001 const FunctionType *FTy;
Reid Spencered96d1e2007-02-08 09:08:52 +00006002 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006003 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6004 // Pull out the types of all of the arguments...
6005 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00006006 if ((yyvsp[-1].ValueList)) {
6007 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006008 I != E; ++I)
6009 ParamTypes.push_back((*I).V->getType());
6010 }
6011
Reid Spencerb7046c72007-01-29 05:41:34 +00006012 FunctionType::ParamAttrsList ParamAttrs;
6013 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
6014 ParamAttrs.push_back(FunctionType::NoAttributeSet);
6015 ParamAttrs.push_back(FunctionType::StructRetAttribute);
6016 }
Reid Spencer950bf602007-01-26 08:19:09 +00006017 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6018 if (isVarArg) ParamTypes.pop_back();
6019
Reid Spencered96d1e2007-02-08 09:08:52 +00006020 const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006021 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6022 error("Functions cannot return aggregate types");
6023
Reid Spencerb7046c72007-01-29 05:41:34 +00006024 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00006025 PFTy = PointerType::get(FTy);
6026 }
6027
6028 // First upgrade any intrinsic calls.
6029 std::vector<Value*> Args;
Reid Spencerb7046c72007-01-29 05:41:34 +00006030 if ((yyvsp[-1].ValueList))
6031 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
6032 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
6033 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006034
6035 // If we got an upgraded intrinsic
6036 if (Inst) {
6037 (yyval.InstVal).I = Inst;
6038 (yyval.InstVal).S = Signless;
6039 } else {
6040 // Get the function we're calling
Reid Spencerb7046c72007-01-29 05:41:34 +00006041 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006042
6043 // Check the argument values match
Reid Spencerb7046c72007-01-29 05:41:34 +00006044 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006045 // Make sure no arguments is a good thing!
6046 if (FTy->getNumParams() != 0)
6047 error("No arguments passed to a function that expects arguments");
6048 } else { // Has arguments?
6049 // Loop through FunctionType's arguments and ensure they are specified
6050 // correctly!
6051 //
6052 FunctionType::param_iterator I = FTy->param_begin();
6053 FunctionType::param_iterator E = FTy->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00006054 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006055
6056 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6057 if ((*ArgI).V->getType() != *I)
6058 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6059 (*I)->getDescription() + "'");
6060
6061 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6062 error("Invalid number of parameters detected");
6063 }
6064
6065 // Create the call instruction
6066 CallInst *CI = new CallInst(V, Args);
Reid Spencerb7046c72007-01-29 05:41:34 +00006067 CI->setTailCall((yyvsp[-6].BoolVal));
6068 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00006069 (yyval.InstVal).I = CI;
Reid Spencerb7046c72007-01-29 05:41:34 +00006070 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006071 }
Reid Spencered96d1e2007-02-08 09:08:52 +00006072 delete (yyvsp[-4].TypeVal).PAT;
Reid Spencerb7046c72007-01-29 05:41:34 +00006073 delete (yyvsp[-1].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006074 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006075 break;
6076
Reid Spencered96d1e2007-02-08 09:08:52 +00006077 case 297:
6078#line 3390 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00006079 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006080 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00006081 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00006082 break;
6083
Reid Spencered96d1e2007-02-08 09:08:52 +00006084 case 298:
6085#line 3398 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00006086 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00006087 break;
6088
Reid Spencered96d1e2007-02-08 09:08:52 +00006089 case 299:
6090#line 3399 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006091 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006092 break;
6093
Reid Spencered96d1e2007-02-08 09:08:52 +00006094 case 300:
6095#line 3403 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006096 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006097 break;
6098
Reid Spencered96d1e2007-02-08 09:08:52 +00006099 case 301:
6100#line 3404 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006101 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006102 break;
6103
Reid Spencered96d1e2007-02-08 09:08:52 +00006104 case 302:
6105#line 3408 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006106 {
Reid Spencered96d1e2007-02-08 09:08:52 +00006107 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerb7046c72007-01-29 05:41:34 +00006108 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6109 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
Reid Spencered96d1e2007-02-08 09:08:52 +00006110 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00006111 ;}
6112 break;
6113
6114 case 303:
Reid Spencered96d1e2007-02-08 09:08:52 +00006115#line 3414 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006116 {
Reid Spencered96d1e2007-02-08 09:08:52 +00006117 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
6118 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6119 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6120 delete (yyvsp[-4].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00006121 ;}
6122 break;
6123
6124 case 304:
Reid Spencered96d1e2007-02-08 09:08:52 +00006125#line 3420 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006126 {
Reid Spencered96d1e2007-02-08 09:08:52 +00006127 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
6128 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6129 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6130 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00006131 ;}
6132 break;
6133
6134 case 305:
Reid Spencered96d1e2007-02-08 09:08:52 +00006135#line 3426 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
6136 {
6137 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
6138 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6139 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6140 delete (yyvsp[-4].TypeVal).PAT;
6141 ;}
6142 break;
6143
6144 case 306:
6145#line 3432 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006146 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006147 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006148 if (!isa<PointerType>(PTy))
6149 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006150 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006151 (yyval.InstVal).S = Signless;
6152 ;}
6153 break;
6154
Reid Spencered96d1e2007-02-08 09:08:52 +00006155 case 307:
6156#line 3439 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006157 {
Reid Spencered96d1e2007-02-08 09:08:52 +00006158 const Type* Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerb7046c72007-01-29 05:41:34 +00006159 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006160 if (!isa<PointerType>(Ty))
6161 error("Can't load from nonpointer type: " + Ty->getDescription());
6162 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6163 error("Can't load from pointer of non-first-class type: " +
6164 Ty->getDescription());
Reid Spencerb7046c72007-01-29 05:41:34 +00006165 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6166 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
Reid Spencered96d1e2007-02-08 09:08:52 +00006167 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00006168 ;}
6169 break;
6170
6171 case 308:
Reid Spencered96d1e2007-02-08 09:08:52 +00006172#line 3451 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006173 {
Reid Spencered96d1e2007-02-08 09:08:52 +00006174 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
6175 if (!PTy)
6176 error("Can't store to a nonpointer type: " +
6177 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
6178 const Type *ElTy = PTy->getElementType();
6179 Value *StoreVal = (yyvsp[-3].ValueVal).V;
6180 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6181 if (ElTy != (yyvsp[-3].ValueVal).V->getType()) {
6182 StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy);
6183 if (!StoreVal)
6184 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
6185 "' into space of type '" + ElTy->getDescription() + "'");
6186 else {
6187 PTy = PointerType::get(StoreVal->getType());
6188 if (Constant *C = dyn_cast<Constant>(tmpVal))
6189 tmpVal = ConstantExpr::getBitCast(C, PTy);
6190 else
6191 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6192 }
6193 }
6194 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal));
6195 (yyval.InstVal).S = Signless;
6196 delete (yyvsp[-1].TypeVal).PAT;
6197 ;}
6198 break;
6199
6200 case 309:
6201#line 3476 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
6202 {
6203 const Type* Ty = (yyvsp[-2].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006204 if (!isa<PointerType>(Ty))
6205 error("getelementptr insn requires pointer operand");
6206
6207 std::vector<Value*> VIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00006208 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006209
Reid Spencerb7046c72007-01-29 05:41:34 +00006210 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006211 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6212 (yyval.InstVal).S = Signless;
Reid Spencered96d1e2007-02-08 09:08:52 +00006213 delete (yyvsp[-2].TypeVal).PAT;
Reid Spencerb7046c72007-01-29 05:41:34 +00006214 delete (yyvsp[0].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006215 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006216 break;
6217
6218
Reid Spencer950bf602007-01-26 08:19:09 +00006219 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006220 }
6221
Reid Spencerb7046c72007-01-29 05:41:34 +00006222/* Line 1126 of yacc.c. */
Reid Spencered96d1e2007-02-08 09:08:52 +00006223#line 6224 "UpgradeParser.tab.c"
Reid Spencerb7046c72007-01-29 05:41:34 +00006224
6225 yyvsp -= yylen;
6226 yyssp -= yylen;
6227
6228
Reid Spencer950bf602007-01-26 08:19:09 +00006229 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006230
6231 *++yyvsp = yyval;
6232
6233
Reid Spencer319a7302007-01-05 17:20:02 +00006234 /* Now `shift' the result of the reduction. Determine what state
6235 that goes to, based on the state we popped back to and the rule
6236 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006237
6238 yyn = yyr1[yyn];
6239
Reid Spencer319a7302007-01-05 17:20:02 +00006240 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6241 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006242 yystate = yytable[yystate];
6243 else
Reid Spencer319a7302007-01-05 17:20:02 +00006244 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006245
6246 goto yynewstate;
6247
6248
Reid Spencer319a7302007-01-05 17:20:02 +00006249/*------------------------------------.
6250| yyerrlab -- here on detecting error |
6251`------------------------------------*/
6252yyerrlab:
6253 /* If not already recovering from an error, report this error. */
6254 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006255 {
6256 ++yynerrs;
Reid Spencerb7046c72007-01-29 05:41:34 +00006257#if YYERROR_VERBOSE
6258 yyn = yypact[yystate];
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006259
Reid Spencerb7046c72007-01-29 05:41:34 +00006260 if (YYPACT_NINF < yyn && yyn < YYLAST)
6261 {
6262 int yytype = YYTRANSLATE (yychar);
6263 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6264 YYSIZE_T yysize = yysize0;
6265 YYSIZE_T yysize1;
6266 int yysize_overflow = 0;
6267 char *yymsg = 0;
6268# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6269 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6270 int yyx;
6271
6272#if 0
6273 /* This is so xgettext sees the translatable formats that are
6274 constructed on the fly. */
6275 YY_("syntax error, unexpected %s");
6276 YY_("syntax error, unexpected %s, expecting %s");
6277 YY_("syntax error, unexpected %s, expecting %s or %s");
6278 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6279 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006280#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006281 char *yyfmt;
6282 char const *yyf;
6283 static char const yyunexpected[] = "syntax error, unexpected %s";
6284 static char const yyexpecting[] = ", expecting %s";
6285 static char const yyor[] = " or %s";
6286 char yyformat[sizeof yyunexpected
6287 + sizeof yyexpecting - 1
6288 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6289 * (sizeof yyor - 1))];
6290 char const *yyprefix = yyexpecting;
6291
6292 /* Start YYX at -YYN if negative to avoid negative indexes in
6293 YYCHECK. */
6294 int yyxbegin = yyn < 0 ? -yyn : 0;
6295
6296 /* Stay within bounds of both yycheck and yytname. */
6297 int yychecklim = YYLAST - yyn;
6298 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6299 int yycount = 1;
6300
6301 yyarg[0] = yytname[yytype];
6302 yyfmt = yystpcpy (yyformat, yyunexpected);
6303
6304 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6305 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6306 {
6307 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6308 {
6309 yycount = 1;
6310 yysize = yysize0;
6311 yyformat[sizeof yyunexpected - 1] = '\0';
6312 break;
6313 }
6314 yyarg[yycount++] = yytname[yyx];
6315 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6316 yysize_overflow |= yysize1 < yysize;
6317 yysize = yysize1;
6318 yyfmt = yystpcpy (yyfmt, yyprefix);
6319 yyprefix = yyor;
6320 }
6321
6322 yyf = YY_(yyformat);
6323 yysize1 = yysize + yystrlen (yyf);
6324 yysize_overflow |= yysize1 < yysize;
6325 yysize = yysize1;
6326
6327 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6328 yymsg = (char *) YYSTACK_ALLOC (yysize);
6329 if (yymsg)
6330 {
6331 /* Avoid sprintf, as that infringes on the user's name space.
6332 Don't have undefined behavior even if the translation
6333 produced a string with the wrong number of "%s"s. */
6334 char *yyp = yymsg;
6335 int yyi = 0;
6336 while ((*yyp = *yyf))
6337 {
6338 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6339 {
6340 yyp += yytnamerr (yyp, yyarg[yyi++]);
6341 yyf += 2;
6342 }
6343 else
6344 {
6345 yyp++;
6346 yyf++;
6347 }
6348 }
6349 yyerror (yymsg);
6350 YYSTACK_FREE (yymsg);
6351 }
6352 else
6353 {
6354 yyerror (YY_("syntax error"));
6355 goto yyexhaustedlab;
6356 }
6357 }
6358 else
6359#endif /* YYERROR_VERBOSE */
6360 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006361 }
Reid Spencer950bf602007-01-26 08:19:09 +00006362
6363
6364
6365 if (yyerrstatus == 3)
6366 {
6367 /* If just tried and failed to reuse look-ahead token after an
6368 error, discard it. */
6369
6370 if (yychar <= YYEOF)
Reid Spencerb7046c72007-01-29 05:41:34 +00006371 {
Reid Spencer950bf602007-01-26 08:19:09 +00006372 /* Return failure if at end of input. */
6373 if (yychar == YYEOF)
6374 YYABORT;
Reid Spencerb7046c72007-01-29 05:41:34 +00006375 }
Reid Spencer950bf602007-01-26 08:19:09 +00006376 else
6377 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006378 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer950bf602007-01-26 08:19:09 +00006379 yychar = YYEMPTY;
6380 }
6381 }
6382
6383 /* Else will try to reuse look-ahead token after shifting the error
6384 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006385 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006386
Reid Spencer319a7302007-01-05 17:20:02 +00006387
Reid Spencer950bf602007-01-26 08:19:09 +00006388/*---------------------------------------------------.
6389| yyerrorlab -- error raised explicitly by YYERROR. |
6390`---------------------------------------------------*/
6391yyerrorlab:
6392
6393 /* Pacify compilers like GCC when the user code never invokes
6394 YYERROR and the label yyerrorlab therefore never appears in user
6395 code. */
Reid Spencerb7046c72007-01-29 05:41:34 +00006396 if (0)
Reid Spencer950bf602007-01-26 08:19:09 +00006397 goto yyerrorlab;
6398
Reid Spencerb7046c72007-01-29 05:41:34 +00006399yyvsp -= yylen;
6400 yyssp -= yylen;
Reid Spencer950bf602007-01-26 08:19:09 +00006401 yystate = *yyssp;
6402 goto yyerrlab1;
6403
6404
6405/*-------------------------------------------------------------.
6406| yyerrlab1 -- common code for both syntax error and YYERROR. |
6407`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006408yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006409 yyerrstatus = 3; /* Each real token shifted decrements this. */
6410
6411 for (;;)
6412 {
6413 yyn = yypact[yystate];
6414 if (yyn != YYPACT_NINF)
6415 {
6416 yyn += YYTERROR;
6417 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6418 {
6419 yyn = yytable[yyn];
6420 if (0 < yyn)
6421 break;
6422 }
6423 }
6424
6425 /* Pop the current state because it cannot handle the error token. */
6426 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006427 YYABORT;
6428
6429
Reid Spencerb7046c72007-01-29 05:41:34 +00006430 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6431 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006432 yystate = *yyssp;
6433 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006434 }
6435
6436 if (yyn == YYFINAL)
6437 YYACCEPT;
6438
6439 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006440
6441
Reid Spencerb7046c72007-01-29 05:41:34 +00006442 /* Shift the error token. */
Reid Spencer950bf602007-01-26 08:19:09 +00006443 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6444
Reid Spencere7c3c602006-11-30 06:36:44 +00006445 yystate = yyn;
6446 goto yynewstate;
6447
Chris Lattner37e01c52007-01-04 18:46:42 +00006448
Reid Spencer319a7302007-01-05 17:20:02 +00006449/*-------------------------------------.
6450| yyacceptlab -- YYACCEPT comes here. |
6451`-------------------------------------*/
6452yyacceptlab:
6453 yyresult = 0;
6454 goto yyreturn;
6455
6456/*-----------------------------------.
6457| yyabortlab -- YYABORT comes here. |
6458`-----------------------------------*/
6459yyabortlab:
6460 yyresult = 1;
6461 goto yyreturn;
6462
6463#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006464/*-------------------------------------------------.
6465| yyexhaustedlab -- memory exhaustion comes here. |
6466`-------------------------------------------------*/
6467yyexhaustedlab:
6468 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006469 yyresult = 2;
6470 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006471#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006472
6473yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006474 if (yychar != YYEOF && yychar != YYEMPTY)
6475 yydestruct ("Cleanup: discarding lookahead",
6476 yytoken, &yylval);
6477 while (yyssp != yyss)
6478 {
6479 yydestruct ("Cleanup: popping",
6480 yystos[*yyssp], yyvsp);
Reid Spencerb7046c72007-01-29 05:41:34 +00006481 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006482 }
Reid Spencer319a7302007-01-05 17:20:02 +00006483#ifndef yyoverflow
6484 if (yyss != yyssa)
6485 YYSTACK_FREE (yyss);
6486#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006487 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006488}
Reid Spencer319a7302007-01-05 17:20:02 +00006489
6490
Reid Spencered96d1e2007-02-08 09:08:52 +00006491#line 3492 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006492
6493
6494int yyerror(const char *ErrorMsg) {
6495 std::string where
6496 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006497 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006498 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6499 if (yychar != YYEMPTY && yychar != 0)
6500 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6501 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006502 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006503 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006504 exit(1);
6505}
Reid Spencer319a7302007-01-05 17:20:02 +00006506
Reid Spencer30d0c582007-01-15 00:26:18 +00006507void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006508 std::string where
6509 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006510 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006511 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6512 if (yychar != YYEMPTY && yychar != 0)
6513 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6514 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006515 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6516}
6517
Reid Spencer950bf602007-01-26 08:19:09 +00006518void error(const std::string& ErrorMsg, int LineNo) {
6519 if (LineNo == -1) LineNo = Upgradelineno;
6520 Upgradelineno = LineNo;
6521 yyerror(ErrorMsg.c_str());
6522}
6523
6524