blob: e289939e2410a4341e9823e4035b01884a34113a [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 Spencer832254e2007-02-02 02:16:23 +0000373#line 14 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +0000374
375#include "UpgradeInternals.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000376#include "llvm/CallingConv.h"
377#include "llvm/InlineAsm.h"
378#include "llvm/Instructions.h"
379#include "llvm/Module.h"
380#include "llvm/SymbolTable.h"
381#include "llvm/Support/GetElementPtrTypeIterator.h"
382#include "llvm/ADT/STLExtras.h"
383#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000384#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000385#include <iostream>
Reid Spencer950bf602007-01-26 08:19:09 +0000386#include <list>
387#include <utility>
388
389// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
390// relating to upreferences in the input stream.
391//
392//#define DEBUG_UPREFS 1
393#ifdef DEBUG_UPREFS
394#define UR_OUT(X) std::cerr << X
395#else
396#define UR_OUT(X)
397#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000398
Reid Spencere77e35e2006-12-01 20:26:20 +0000399#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000400#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000401#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000402
Reid Spencer950bf602007-01-26 08:19:09 +0000403int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000404int yyparse();
405
Reid Spencer950bf602007-01-26 08:19:09 +0000406int yyerror(const char*);
407static void warning(const std::string& WarningMsg);
408
409namespace llvm {
410
Reid Spencer950bf602007-01-26 08:19:09 +0000411std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000412static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000413
Reid Spencer71d2ec92006-12-31 06:02:26 +0000414// This bool controls whether attributes are ever added to function declarations
415// definitions and calls.
416static bool AddAttributes = false;
417
Reid Spencer950bf602007-01-26 08:19:09 +0000418static Module *ParserResult;
419static bool ObsoleteVarArgs;
420static bool NewVarArgs;
421static BasicBlock *CurBB;
422static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000423
Reid Spencer950bf602007-01-26 08:19:09 +0000424// This contains info used when building the body of a function. It is
425// destroyed when the function is completed.
426//
427typedef std::vector<Value *> ValueList; // Numbered defs
428
429typedef std::pair<std::string,const Type*> RenameMapKey;
430typedef std::map<RenameMapKey,std::string> RenameMapType;
431
432static void
433ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
434 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
435
436static struct PerModuleInfo {
437 Module *CurrentModule;
438 std::map<const Type *, ValueList> Values; // Module level numbered definitions
439 std::map<const Type *,ValueList> LateResolveValues;
440 std::vector<PATypeHolder> Types;
441 std::map<ValID, PATypeHolder> LateResolveTypes;
442 static Module::Endianness Endian;
443 static Module::PointerSize PointerSize;
444 RenameMapType RenameMap;
445
446 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
447 /// how they were referenced and on which line of the input they came from so
448 /// that we can resolve them later and print error messages as appropriate.
449 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
450
451 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
452 // references to global values. Global values may be referenced before they
453 // are defined, and if so, the temporary object that they represent is held
454 // here. This is used for forward references of GlobalValues.
455 //
456 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
457 GlobalRefsType;
458 GlobalRefsType GlobalRefs;
459
460 void ModuleDone() {
461 // If we could not resolve some functions at function compilation time
462 // (calls to functions before they are defined), resolve them now... Types
463 // are resolved when the constant pool has been completely parsed.
464 //
465 ResolveDefinitions(LateResolveValues);
466
467 // Check to make sure that all global value forward references have been
468 // resolved!
469 //
470 if (!GlobalRefs.empty()) {
471 std::string UndefinedReferences = "Unresolved global references exist:\n";
472
473 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
474 I != E; ++I) {
475 UndefinedReferences += " " + I->first.first->getDescription() + " " +
476 I->first.second.getName() + "\n";
477 }
478 error(UndefinedReferences);
479 return;
480 }
481
482 if (CurrentModule->getDataLayout().empty()) {
483 std::string dataLayout;
484 if (Endian != Module::AnyEndianness)
485 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
486 if (PointerSize != Module::AnyPointerSize) {
487 if (!dataLayout.empty())
488 dataLayout += "-";
489 dataLayout.append(PointerSize == Module::Pointer64 ?
490 "p:64:64" : "p:32:32");
491 }
492 CurrentModule->setDataLayout(dataLayout);
493 }
494
495 Values.clear(); // Clear out function local definitions
496 Types.clear();
497 CurrentModule = 0;
498 }
499
500 // GetForwardRefForGlobal - Check to see if there is a forward reference
501 // for this global. If so, remove it from the GlobalRefs map and return it.
502 // If not, just return null.
503 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
504 // Check to see if there is a forward reference to this global variable...
505 // if there is, eliminate it and patch the reference to use the new def'n.
506 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
507 GlobalValue *Ret = 0;
508 if (I != GlobalRefs.end()) {
509 Ret = I->second;
510 GlobalRefs.erase(I);
511 }
512 return Ret;
513 }
514 void setEndianness(Module::Endianness E) { Endian = E; }
515 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
516} CurModule;
517
518Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
519Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
520
521static struct PerFunctionInfo {
522 Function *CurrentFunction; // Pointer to current function being created
523
524 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
525 std::map<const Type*, ValueList> LateResolveValues;
526 bool isDeclare; // Is this function a forward declararation?
527 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
528
529 /// BBForwardRefs - When we see forward references to basic blocks, keep
530 /// track of them here.
531 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
532 std::vector<BasicBlock*> NumberedBlocks;
533 RenameMapType RenameMap;
Reid Spencerb7046c72007-01-29 05:41:34 +0000534 unsigned LastCC;
Reid Spencer950bf602007-01-26 08:19:09 +0000535 unsigned NextBBNum;
536
537 inline PerFunctionInfo() {
538 CurrentFunction = 0;
539 isDeclare = false;
540 Linkage = GlobalValue::ExternalLinkage;
541 }
542
543 inline void FunctionStart(Function *M) {
544 CurrentFunction = M;
545 NextBBNum = 0;
546 }
547
548 void FunctionDone() {
549 NumberedBlocks.clear();
550
551 // Any forward referenced blocks left?
552 if (!BBForwardRefs.empty()) {
553 error("Undefined reference to label " +
554 BBForwardRefs.begin()->first->getName());
555 return;
556 }
557
558 // Resolve all forward references now.
559 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
560
561 Values.clear(); // Clear out function local definitions
562 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000563 CurrentFunction = 0;
564 isDeclare = false;
565 Linkage = GlobalValue::ExternalLinkage;
566 }
567} CurFun; // Info for the current function...
568
569static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
570
571
572//===----------------------------------------------------------------------===//
573// Code to handle definitions of all the types
574//===----------------------------------------------------------------------===//
575
576static int InsertValue(Value *V,
577 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
578 if (V->hasName()) return -1; // Is this a numbered definition?
579
580 // Yes, insert the value into the value table...
581 ValueList &List = ValueTab[V->getType()];
582 List.push_back(V);
583 return List.size()-1;
584}
585
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000586static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000587 switch (D.Type) {
588 case ValID::NumberVal: // Is it a numbered definition?
589 // Module constants occupy the lowest numbered slots...
590 if ((unsigned)D.Num < CurModule.Types.size()) {
591 return CurModule.Types[(unsigned)D.Num];
592 }
593 break;
594 case ValID::NameVal: // Is it a named definition?
595 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
596 D.destroy(); // Free old strdup'd memory...
597 return N;
598 }
599 break;
600 default:
601 error("Internal parser error: Invalid symbol type reference");
602 return 0;
603 }
604
605 // If we reached here, we referenced either a symbol that we don't know about
606 // or an id number that hasn't been read yet. We may be referencing something
607 // forward, so just create an entry to be resolved later and get to it...
608 //
609 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
610
611
612 if (inFunctionScope()) {
613 if (D.Type == ValID::NameVal) {
614 error("Reference to an undefined type: '" + D.getName() + "'");
615 return 0;
616 } else {
617 error("Reference to an undefined type: #" + itostr(D.Num));
618 return 0;
619 }
620 }
621
622 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
623 if (I != CurModule.LateResolveTypes.end())
624 return I->second;
625
626 Type *Typ = OpaqueType::get();
627 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
628 return Typ;
629 }
630
631// getExistingValue - Look up the value specified by the provided type and
632// the provided ValID. If the value exists and has already been defined, return
633// it. Otherwise return null.
634//
635static Value *getExistingValue(const Type *Ty, const ValID &D) {
636 if (isa<FunctionType>(Ty)) {
637 error("Functions are not values and must be referenced as pointers");
638 }
639
640 switch (D.Type) {
641 case ValID::NumberVal: { // Is it a numbered definition?
642 unsigned Num = (unsigned)D.Num;
643
644 // Module constants occupy the lowest numbered slots...
645 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
646 if (VI != CurModule.Values.end()) {
647 if (Num < VI->second.size())
648 return VI->second[Num];
649 Num -= VI->second.size();
650 }
651
652 // Make sure that our type is within bounds
653 VI = CurFun.Values.find(Ty);
654 if (VI == CurFun.Values.end()) return 0;
655
656 // Check that the number is within bounds...
657 if (VI->second.size() <= Num) return 0;
658
659 return VI->second[Num];
660 }
661
662 case ValID::NameVal: { // Is it a named definition?
663 // Get the name out of the ID
664 std::string Name(D.Name);
665 Value* V = 0;
666 RenameMapKey Key = std::make_pair(Name, Ty);
667 if (inFunctionScope()) {
668 // See if the name was renamed
669 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
670 std::string LookupName;
671 if (I != CurFun.RenameMap.end())
672 LookupName = I->second;
673 else
674 LookupName = Name;
675 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
676 V = SymTab.lookup(Ty, LookupName);
677 }
678 if (!V) {
679 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
680 std::string LookupName;
681 if (I != CurModule.RenameMap.end())
682 LookupName = I->second;
683 else
684 LookupName = Name;
685 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
686 }
687 if (V == 0)
688 return 0;
689
690 D.destroy(); // Free old strdup'd memory...
691 return V;
692 }
693
694 // Check to make sure that "Ty" is an integral type, and that our
695 // value will fit into the specified type...
696 case ValID::ConstSIntVal: // Is it a constant pool reference??
697 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
698 error("Signed integral constant '" + itostr(D.ConstPool64) +
699 "' is invalid for type '" + Ty->getDescription() + "'");
700 }
701 return ConstantInt::get(Ty, D.ConstPool64);
702
703 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
704 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
705 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
706 error("Integral constant '" + utostr(D.UConstPool64) +
707 "' is invalid or out of range");
708 else // This is really a signed reference. Transmogrify.
709 return ConstantInt::get(Ty, D.ConstPool64);
710 } else
711 return ConstantInt::get(Ty, D.UConstPool64);
712
713 case ValID::ConstFPVal: // Is it a floating point const pool reference?
714 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
715 error("FP constant invalid for type");
716 return ConstantFP::get(Ty, D.ConstPoolFP);
717
718 case ValID::ConstNullVal: // Is it a null value?
719 if (!isa<PointerType>(Ty))
720 error("Cannot create a a non pointer null");
721 return ConstantPointerNull::get(cast<PointerType>(Ty));
722
723 case ValID::ConstUndefVal: // Is it an undef value?
724 return UndefValue::get(Ty);
725
726 case ValID::ConstZeroVal: // Is it a zero value?
727 return Constant::getNullValue(Ty);
728
729 case ValID::ConstantVal: // Fully resolved constant?
730 if (D.ConstantValue->getType() != Ty)
731 error("Constant expression type different from required type");
732 return D.ConstantValue;
733
734 case ValID::InlineAsmVal: { // Inline asm expression
735 const PointerType *PTy = dyn_cast<PointerType>(Ty);
736 const FunctionType *FTy =
737 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
738 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
739 error("Invalid type for asm constraint string");
740 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
741 D.IAD->HasSideEffects);
742 D.destroy(); // Free InlineAsmDescriptor.
743 return IA;
744 }
745 default:
746 assert(0 && "Unhandled case");
747 return 0;
748 } // End of switch
749
750 assert(0 && "Unhandled case");
751 return 0;
752}
753
754// getVal - This function is identical to getExistingValue, except that if a
755// value is not already defined, it "improvises" by creating a placeholder var
756// that looks and acts just like the requested variable. When the value is
757// defined later, all uses of the placeholder variable are replaced with the
758// real thing.
759//
760static Value *getVal(const Type *Ty, const ValID &ID) {
761 if (Ty == Type::LabelTy)
762 error("Cannot use a basic block here");
763
764 // See if the value has already been defined.
765 Value *V = getExistingValue(Ty, ID);
766 if (V) return V;
767
768 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
769 error("Invalid use of a composite type");
770
771 // If we reached here, we referenced either a symbol that we don't know about
772 // or an id number that hasn't been read yet. We may be referencing something
773 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000774 V = new Argument(Ty);
775
776 // Remember where this forward reference came from. FIXME, shouldn't we try
777 // to recycle these things??
778 CurModule.PlaceHolderInfo.insert(
779 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
780
781 if (inFunctionScope())
782 InsertValue(V, CurFun.LateResolveValues);
783 else
784 InsertValue(V, CurModule.LateResolveValues);
785 return V;
786}
787
788/// getBBVal - This is used for two purposes:
789/// * If isDefinition is true, a new basic block with the specified ID is being
790/// defined.
791/// * If isDefinition is true, this is a reference to a basic block, which may
792/// or may not be a forward reference.
793///
794static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
795 assert(inFunctionScope() && "Can't get basic block at global scope");
796
797 std::string Name;
798 BasicBlock *BB = 0;
799 switch (ID.Type) {
800 default:
801 error("Illegal label reference " + ID.getName());
802 break;
803 case ValID::NumberVal: // Is it a numbered definition?
804 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
805 CurFun.NumberedBlocks.resize(ID.Num+1);
806 BB = CurFun.NumberedBlocks[ID.Num];
807 break;
808 case ValID::NameVal: // Is it a named definition?
809 Name = ID.Name;
810 if (Value *N = CurFun.CurrentFunction->
811 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
812 if (N->getType() != Type::LabelTy)
813 error("Name '" + Name + "' does not refer to a BasicBlock");
814 BB = cast<BasicBlock>(N);
815 }
816 break;
817 }
818
819 // See if the block has already been defined.
820 if (BB) {
821 // If this is the definition of the block, make sure the existing value was
822 // just a forward reference. If it was a forward reference, there will be
823 // an entry for it in the PlaceHolderInfo map.
824 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
825 // The existing value was a definition, not a forward reference.
826 error("Redefinition of label " + ID.getName());
827
828 ID.destroy(); // Free strdup'd memory.
829 return BB;
830 }
831
832 // Otherwise this block has not been seen before.
833 BB = new BasicBlock("", CurFun.CurrentFunction);
834 if (ID.Type == ValID::NameVal) {
835 BB->setName(ID.Name);
836 } else {
837 CurFun.NumberedBlocks[ID.Num] = BB;
838 }
839
840 // If this is not a definition, keep track of it so we can use it as a forward
841 // reference.
842 if (!isDefinition) {
843 // Remember where this forward reference came from.
844 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
845 } else {
846 // The forward declaration could have been inserted anywhere in the
847 // function: insert it into the correct place now.
848 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
849 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
850 }
851 ID.destroy();
852 return BB;
853}
854
855
856//===----------------------------------------------------------------------===//
857// Code to handle forward references in instructions
858//===----------------------------------------------------------------------===//
859//
860// This code handles the late binding needed with statements that reference
861// values not defined yet... for example, a forward branch, or the PHI node for
862// a loop body.
863//
864// This keeps a table (CurFun.LateResolveValues) of all such forward references
865// and back patchs after we are done.
866//
867
Reid Spencer7de2e012007-01-29 19:08:46 +0000868/// This function determines if two function types differ only in their use of
869/// the sret parameter attribute in the first argument. If they are identical
870/// in all other respects, it returns true. Otherwise, it returns false.
871bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
872 const FunctionType *F2) {
873 if (F1->getReturnType() != F2->getReturnType() ||
874 F1->getNumParams() != F2->getNumParams() ||
875 F1->getParamAttrs(0) != F2->getParamAttrs(0))
876 return false;
877 unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute);
878 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
879 if (F1->getParamType(i) != F2->getParamType(i) ||
880 unsigned(F1->getParamAttrs(i+1)) & SRetMask !=
881 unsigned(F2->getParamAttrs(i+1)) & SRetMask)
882 return false;
883 }
884 return true;
885}
886
Reid Spencer950bf602007-01-26 08:19:09 +0000887// ResolveDefinitions - If we could not resolve some defs at parsing
888// time (forward branches, phi functions for loops, etc...) resolve the
889// defs now...
890//
891static void
892ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
893 std::map<const Type*,ValueList> *FutureLateResolvers) {
894 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
895 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
896 E = LateResolvers.end(); LRI != E; ++LRI) {
897 ValueList &List = LRI->second;
898 while (!List.empty()) {
899 Value *V = List.back();
900 List.pop_back();
901
902 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
903 CurModule.PlaceHolderInfo.find(V);
904 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
905
906 ValID &DID = PHI->second.first;
907
908 Value *TheRealValue = getExistingValue(LRI->first, DID);
909 if (TheRealValue) {
910 V->replaceAllUsesWith(TheRealValue);
911 delete V;
912 CurModule.PlaceHolderInfo.erase(PHI);
913 } else if (FutureLateResolvers) {
914 // Functions have their unresolved items forwarded to the module late
915 // resolver table
916 InsertValue(V, *FutureLateResolvers);
917 } else {
918 if (DID.Type == ValID::NameVal) {
Reid Spencer7de2e012007-01-29 19:08:46 +0000919 // The upgrade of csretcc to sret param attribute may have caused a
920 // function to not be found because the param attribute changed the
921 // type of the called function. Detect this situation and insert a
922 // cast as necessary.
923 bool fixed = false;
924 if (const PointerType *PTy = dyn_cast<PointerType>(V->getType()))
925 if (const FunctionType *FTy =
926 dyn_cast<FunctionType>(PTy->getElementType()))
927 if (Function *OtherF =
928 CurModule.CurrentModule->getNamedFunction(DID.getName()))
929 if (FuncTysDifferOnlyBySRet(FTy,OtherF->getFunctionType())) {
930 V->replaceAllUsesWith(ConstantExpr::getBitCast(OtherF, PTy));
931 fixed = true;
932 }
933 if (!fixed) {
934 error("Reference to an invalid definition: '" +DID.getName()+
935 "' of type '" + V->getType()->getDescription() + "'",
936 PHI->second.second);
937 return;
938 }
Reid Spencer950bf602007-01-26 08:19:09 +0000939 } else {
940 error("Reference to an invalid definition: #" +
941 itostr(DID.Num) + " of type '" +
942 V->getType()->getDescription() + "'", PHI->second.second);
943 return;
944 }
945 }
946 }
947 }
948
949 LateResolvers.clear();
950}
951
952// ResolveTypeTo - A brand new type was just declared. This means that (if
953// name is not null) things referencing Name can be resolved. Otherwise, things
954// refering to the number can be resolved. Do this now.
955//
956static void ResolveTypeTo(char *Name, const Type *ToTy) {
957 ValID D;
958 if (Name) D = ValID::create(Name);
959 else D = ValID::create((int)CurModule.Types.size());
960
961 std::map<ValID, PATypeHolder>::iterator I =
962 CurModule.LateResolveTypes.find(D);
963 if (I != CurModule.LateResolveTypes.end()) {
964 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
965 CurModule.LateResolveTypes.erase(I);
966 }
967}
968
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000969/// @brief This just makes any name given to it unique, up to MAX_UINT times.
Reid Spencer950bf602007-01-26 08:19:09 +0000970static std::string makeNameUnique(const std::string& Name) {
971 static unsigned UniqueNameCounter = 1;
972 std::string Result(Name);
973 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
974 return Result;
975}
976
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000977/// This is the implementation portion of TypeHasInteger. It traverses the
978/// type given, avoiding recursive types, and returns true as soon as it finds
979/// an integer type. If no integer type is found, it returns false.
980static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
981 // Handle some easy cases
982 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
983 return false;
984 if (Ty->isInteger())
985 return true;
986 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
987 return STy->getElementType()->isInteger();
988
989 // Avoid type structure recursion
990 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
991 I != E; ++I)
992 if (Ty == *I)
993 return false;
994
995 // Push us on the type stack
996 Stack.push_back(Ty);
997
998 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
999 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1000 return true;
1001 FunctionType::param_iterator I = FTy->param_begin();
1002 FunctionType::param_iterator E = FTy->param_end();
1003 for (; I != E; ++I)
1004 if (TypeHasIntegerI(*I, Stack))
1005 return true;
1006 return false;
1007 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1008 StructType::element_iterator I = STy->element_begin();
1009 StructType::element_iterator E = STy->element_end();
1010 for (; I != E; ++I) {
1011 if (TypeHasIntegerI(*I, Stack))
1012 return true;
1013 }
1014 return false;
1015 }
1016 // There shouldn't be anything else, but its definitely not integer
1017 assert(0 && "What type is this?");
1018 return false;
1019}
1020
1021/// This is the interface to TypeHasIntegerI. It just provides the type stack,
1022/// to avoid recursion, and then calls TypeHasIntegerI.
1023static inline bool TypeHasInteger(const Type *Ty) {
1024 std::vector<const Type*> TyStack;
1025 return TypeHasIntegerI(Ty, TyStack);
1026}
1027
Reid Spencer950bf602007-01-26 08:19:09 +00001028// setValueName - Set the specified value to the name given. The name may be
1029// null potentially, in which case this is a noop. The string passed in is
1030// assumed to be a malloc'd string buffer, and is free'd by this function.
1031//
1032static void setValueName(Value *V, char *NameStr) {
1033 if (NameStr) {
1034 std::string Name(NameStr); // Copy string
1035 free(NameStr); // Free old string
1036
1037 if (V->getType() == Type::VoidTy) {
1038 error("Can't assign name '" + Name + "' to value with void type");
1039 return;
1040 }
1041
Reid Spencer950bf602007-01-26 08:19:09 +00001042 assert(inFunctionScope() && "Must be in function scope");
1043
1044 // Search the function's symbol table for an existing value of this name
1045 Value* Existing = 0;
1046 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1047 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
1048 for ( ; PI != PE; ++PI) {
1049 SymbolTable::value_const_iterator VI = PI->second.find(Name);
1050 if (VI != PI->second.end()) {
1051 Existing = VI->second;
1052 break;
1053 }
1054 }
1055 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001056 // An existing value of the same name was found. This might have happened
1057 // because of the integer type planes collapsing in LLVM 2.0.
1058 if (Existing->getType() == V->getType() &&
1059 !TypeHasInteger(Existing->getType())) {
1060 // If the type does not contain any integers in them then this can't be
1061 // a type plane collapsing issue. It truly is a redefinition and we
1062 // should error out as the assembly is invalid.
1063 error("Redefinition of value named '" + Name + "' of type '" +
1064 V->getType()->getDescription() + "'");
1065 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001066 }
1067 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1068 // function, regardless of Type. Previously re-use of names was okay as
1069 // long as they were distinct types. With type planes collapsing because
1070 // of the signedness change and because of PR411, this can no longer be
1071 // supported. We must search the entire symbol table for a conflicting
1072 // name and make the name unique. No warning is needed as this can't
1073 // cause a problem.
1074 std::string NewName = makeNameUnique(Name);
1075 // We're changing the name but it will probably be used by other
1076 // instructions as operands later on. Consequently we have to retain
1077 // a mapping of the renaming that we're doing.
1078 RenameMapKey Key = std::make_pair(Name,V->getType());
1079 CurFun.RenameMap[Key] = NewName;
1080 Name = NewName;
1081 }
1082
1083 // Set the name.
1084 V->setName(Name);
1085 }
1086}
1087
1088/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1089/// this is a declaration, otherwise it is a definition.
1090static GlobalVariable *
1091ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1092 bool isConstantGlobal, const Type *Ty,
1093 Constant *Initializer) {
1094 if (isa<FunctionType>(Ty))
1095 error("Cannot declare global vars of function type");
1096
1097 const PointerType *PTy = PointerType::get(Ty);
1098
1099 std::string Name;
1100 if (NameStr) {
1101 Name = NameStr; // Copy string
1102 free(NameStr); // Free old string
1103 }
1104
1105 // See if this global value was forward referenced. If so, recycle the
1106 // object.
1107 ValID ID;
1108 if (!Name.empty()) {
1109 ID = ValID::create((char*)Name.c_str());
1110 } else {
1111 ID = ValID::create((int)CurModule.Values[PTy].size());
1112 }
1113
1114 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1115 // Move the global to the end of the list, from whereever it was
1116 // previously inserted.
1117 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1118 CurModule.CurrentModule->getGlobalList().remove(GV);
1119 CurModule.CurrentModule->getGlobalList().push_back(GV);
1120 GV->setInitializer(Initializer);
1121 GV->setLinkage(Linkage);
1122 GV->setConstant(isConstantGlobal);
1123 InsertValue(GV, CurModule.Values);
1124 return GV;
1125 }
1126
1127 // If this global has a name, check to see if there is already a definition
1128 // of this global in the module and emit warnings if there are conflicts.
1129 if (!Name.empty()) {
1130 // The global has a name. See if there's an existing one of the same name.
1131 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1132 // We found an existing global ov the same name. This isn't allowed
1133 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1134 // can at least compile. This can happen because of type planes
1135 // There is alread a global of the same name which means there is a
1136 // conflict. Let's see what we can do about it.
1137 std::string NewName(makeNameUnique(Name));
1138 if (Linkage == GlobalValue::InternalLinkage) {
1139 // The linkage type is internal so just warn about the rename without
1140 // invoking "scarey language" about linkage failures. GVars with
1141 // InternalLinkage can be renamed at will.
1142 warning("Global variable '" + Name + "' was renamed to '"+
1143 NewName + "'");
1144 } else {
1145 // The linkage of this gval is external so we can't reliably rename
1146 // it because it could potentially create a linking problem.
1147 // However, we can't leave the name conflict in the output either or
1148 // it won't assemble with LLVM 2.0. So, all we can do is rename
1149 // this one to something unique and emit a warning about the problem.
1150 warning("Renaming global variable '" + Name + "' to '" + NewName +
1151 "' may cause linkage errors");
1152 }
1153
1154 // Put the renaming in the global rename map
1155 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1156 CurModule.RenameMap[Key] = NewName;
1157
1158 // Rename it
1159 Name = NewName;
1160 }
1161 }
1162
1163 // Otherwise there is no existing GV to use, create one now.
1164 GlobalVariable *GV =
1165 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1166 CurModule.CurrentModule);
1167 InsertValue(GV, CurModule.Values);
1168 return GV;
1169}
1170
1171// setTypeName - Set the specified type to the name given. The name may be
1172// null potentially, in which case this is a noop. The string passed in is
1173// assumed to be a malloc'd string buffer, and is freed by this function.
1174//
1175// This function returns true if the type has already been defined, but is
1176// allowed to be redefined in the specified context. If the name is a new name
1177// for the type plane, it is inserted and false is returned.
1178static bool setTypeName(const Type *T, char *NameStr) {
1179 assert(!inFunctionScope() && "Can't give types function-local names");
1180 if (NameStr == 0) return false;
1181
1182 std::string Name(NameStr); // Copy string
1183 free(NameStr); // Free old string
1184
1185 // We don't allow assigning names to void type
1186 if (T == Type::VoidTy) {
1187 error("Can't assign name '" + Name + "' to the void type");
1188 return false;
1189 }
1190
1191 // Set the type name, checking for conflicts as we do so.
1192 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1193
1194 if (AlreadyExists) { // Inserting a name that is already defined???
1195 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1196 assert(Existing && "Conflict but no matching type?");
1197
1198 // There is only one case where this is allowed: when we are refining an
1199 // opaque type. In this case, Existing will be an opaque type.
1200 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1201 // We ARE replacing an opaque type!
1202 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1203 return true;
1204 }
1205
1206 // Otherwise, this is an attempt to redefine a type. That's okay if
1207 // the redefinition is identical to the original. This will be so if
1208 // Existing and T point to the same Type object. In this one case we
1209 // allow the equivalent redefinition.
1210 if (Existing == T) return true; // Yes, it's equal.
1211
1212 // Any other kind of (non-equivalent) redefinition is an error.
1213 error("Redefinition of type named '" + Name + "' in the '" +
1214 T->getDescription() + "' type plane");
1215 }
1216
1217 return false;
1218}
1219
1220//===----------------------------------------------------------------------===//
1221// Code for handling upreferences in type names...
1222//
1223
1224// TypeContains - Returns true if Ty directly contains E in it.
1225//
1226static bool TypeContains(const Type *Ty, const Type *E) {
1227 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1228 E) != Ty->subtype_end();
1229}
1230
1231namespace {
1232 struct UpRefRecord {
1233 // NestingLevel - The number of nesting levels that need to be popped before
1234 // this type is resolved.
1235 unsigned NestingLevel;
1236
1237 // LastContainedTy - This is the type at the current binding level for the
1238 // type. Every time we reduce the nesting level, this gets updated.
1239 const Type *LastContainedTy;
1240
1241 // UpRefTy - This is the actual opaque type that the upreference is
1242 // represented with.
1243 OpaqueType *UpRefTy;
1244
1245 UpRefRecord(unsigned NL, OpaqueType *URTy)
1246 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1247 };
1248}
1249
1250// UpRefs - A list of the outstanding upreferences that need to be resolved.
1251static std::vector<UpRefRecord> UpRefs;
1252
1253/// HandleUpRefs - Every time we finish a new layer of types, this function is
1254/// called. It loops through the UpRefs vector, which is a list of the
1255/// currently active types. For each type, if the up reference is contained in
1256/// the newly completed type, we decrement the level count. When the level
1257/// count reaches zero, the upreferenced type is the type that is passed in:
1258/// thus we can complete the cycle.
1259///
1260static PATypeHolder HandleUpRefs(const Type *ty) {
1261 // If Ty isn't abstract, or if there are no up-references in it, then there is
1262 // nothing to resolve here.
1263 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1264
1265 PATypeHolder Ty(ty);
1266 UR_OUT("Type '" << Ty->getDescription() <<
1267 "' newly formed. Resolving upreferences.\n" <<
1268 UpRefs.size() << " upreferences active!\n");
1269
1270 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1271 // to zero), we resolve them all together before we resolve them to Ty. At
1272 // the end of the loop, if there is anything to resolve to Ty, it will be in
1273 // this variable.
1274 OpaqueType *TypeToResolve = 0;
1275
1276 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1277 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1278 << UpRefs[i].second->getDescription() << ") = "
1279 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1280 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1281 // Decrement level of upreference
1282 unsigned Level = --UpRefs[i].NestingLevel;
1283 UpRefs[i].LastContainedTy = Ty;
1284 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1285 if (Level == 0) { // Upreference should be resolved!
1286 if (!TypeToResolve) {
1287 TypeToResolve = UpRefs[i].UpRefTy;
1288 } else {
1289 UR_OUT(" * Resolving upreference for "
1290 << UpRefs[i].second->getDescription() << "\n";
1291 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1292 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1293 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1294 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1295 }
1296 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1297 --i; // Do not skip the next element...
1298 }
1299 }
1300 }
1301
1302 if (TypeToResolve) {
1303 UR_OUT(" * Resolving upreference for "
1304 << UpRefs[i].second->getDescription() << "\n";
1305 std::string OldName = TypeToResolve->getDescription());
1306 TypeToResolve->refineAbstractTypeTo(Ty);
1307 }
1308
1309 return Ty;
1310}
1311
1312static inline Instruction::TermOps
1313getTermOp(TermOps op) {
1314 switch (op) {
1315 default : assert(0 && "Invalid OldTermOp");
1316 case RetOp : return Instruction::Ret;
1317 case BrOp : return Instruction::Br;
1318 case SwitchOp : return Instruction::Switch;
1319 case InvokeOp : return Instruction::Invoke;
1320 case UnwindOp : return Instruction::Unwind;
1321 case UnreachableOp: return Instruction::Unreachable;
1322 }
1323}
1324
1325static inline Instruction::BinaryOps
1326getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1327 switch (op) {
1328 default : assert(0 && "Invalid OldBinaryOps");
1329 case SetEQ :
1330 case SetNE :
1331 case SetLE :
1332 case SetGE :
1333 case SetLT :
1334 case SetGT : assert(0 && "Should use getCompareOp");
1335 case AddOp : return Instruction::Add;
1336 case SubOp : return Instruction::Sub;
1337 case MulOp : return Instruction::Mul;
1338 case DivOp : {
1339 // This is an obsolete instruction so we must upgrade it based on the
1340 // types of its operands.
1341 bool isFP = Ty->isFloatingPoint();
1342 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1343 // If its a packed type we want to use the element type
1344 isFP = PTy->getElementType()->isFloatingPoint();
1345 if (isFP)
1346 return Instruction::FDiv;
1347 else if (Sign == Signed)
1348 return Instruction::SDiv;
1349 return Instruction::UDiv;
1350 }
1351 case UDivOp : return Instruction::UDiv;
1352 case SDivOp : return Instruction::SDiv;
1353 case FDivOp : return Instruction::FDiv;
1354 case RemOp : {
1355 // This is an obsolete instruction so we must upgrade it based on the
1356 // types of its operands.
1357 bool isFP = Ty->isFloatingPoint();
1358 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1359 // If its a packed type we want to use the element type
1360 isFP = PTy->getElementType()->isFloatingPoint();
1361 // Select correct opcode
1362 if (isFP)
1363 return Instruction::FRem;
1364 else if (Sign == Signed)
1365 return Instruction::SRem;
1366 return Instruction::URem;
1367 }
1368 case URemOp : return Instruction::URem;
1369 case SRemOp : return Instruction::SRem;
1370 case FRemOp : return Instruction::FRem;
Reid Spencer832254e2007-02-02 02:16:23 +00001371 case LShrOp : return Instruction::LShr;
1372 case AShrOp : return Instruction::AShr;
1373 case ShlOp : return Instruction::Shl;
1374 case ShrOp :
1375 if (Sign == Signed)
1376 return Instruction::AShr;
1377 return Instruction::LShr;
Reid Spencer950bf602007-01-26 08:19:09 +00001378 case AndOp : return Instruction::And;
1379 case OrOp : return Instruction::Or;
1380 case XorOp : return Instruction::Xor;
1381 }
1382}
1383
1384static inline Instruction::OtherOps
1385getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1386 Signedness Sign) {
1387 bool isSigned = Sign == Signed;
1388 bool isFP = Ty->isFloatingPoint();
1389 switch (op) {
1390 default : assert(0 && "Invalid OldSetCC");
1391 case SetEQ :
1392 if (isFP) {
1393 predicate = FCmpInst::FCMP_OEQ;
1394 return Instruction::FCmp;
1395 } else {
1396 predicate = ICmpInst::ICMP_EQ;
1397 return Instruction::ICmp;
1398 }
1399 case SetNE :
1400 if (isFP) {
1401 predicate = FCmpInst::FCMP_UNE;
1402 return Instruction::FCmp;
1403 } else {
1404 predicate = ICmpInst::ICMP_NE;
1405 return Instruction::ICmp;
1406 }
1407 case SetLE :
1408 if (isFP) {
1409 predicate = FCmpInst::FCMP_OLE;
1410 return Instruction::FCmp;
1411 } else {
1412 if (isSigned)
1413 predicate = ICmpInst::ICMP_SLE;
1414 else
1415 predicate = ICmpInst::ICMP_ULE;
1416 return Instruction::ICmp;
1417 }
1418 case SetGE :
1419 if (isFP) {
1420 predicate = FCmpInst::FCMP_OGE;
1421 return Instruction::FCmp;
1422 } else {
1423 if (isSigned)
1424 predicate = ICmpInst::ICMP_SGE;
1425 else
1426 predicate = ICmpInst::ICMP_UGE;
1427 return Instruction::ICmp;
1428 }
1429 case SetLT :
1430 if (isFP) {
1431 predicate = FCmpInst::FCMP_OLT;
1432 return Instruction::FCmp;
1433 } else {
1434 if (isSigned)
1435 predicate = ICmpInst::ICMP_SLT;
1436 else
1437 predicate = ICmpInst::ICMP_ULT;
1438 return Instruction::ICmp;
1439 }
1440 case SetGT :
1441 if (isFP) {
1442 predicate = FCmpInst::FCMP_OGT;
1443 return Instruction::FCmp;
1444 } else {
1445 if (isSigned)
1446 predicate = ICmpInst::ICMP_SGT;
1447 else
1448 predicate = ICmpInst::ICMP_UGT;
1449 return Instruction::ICmp;
1450 }
1451 }
1452}
1453
1454static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1455 switch (op) {
1456 default : assert(0 && "Invalid OldMemoryOps");
1457 case MallocOp : return Instruction::Malloc;
1458 case FreeOp : return Instruction::Free;
1459 case AllocaOp : return Instruction::Alloca;
1460 case LoadOp : return Instruction::Load;
1461 case StoreOp : return Instruction::Store;
1462 case GetElementPtrOp : return Instruction::GetElementPtr;
1463 }
1464}
1465
1466static inline Instruction::OtherOps
1467getOtherOp(OtherOps op, Signedness Sign) {
1468 switch (op) {
1469 default : assert(0 && "Invalid OldOtherOps");
1470 case PHIOp : return Instruction::PHI;
1471 case CallOp : return Instruction::Call;
Reid Spencer950bf602007-01-26 08:19:09 +00001472 case SelectOp : return Instruction::Select;
1473 case UserOp1 : return Instruction::UserOp1;
1474 case UserOp2 : return Instruction::UserOp2;
1475 case VAArg : return Instruction::VAArg;
1476 case ExtractElementOp : return Instruction::ExtractElement;
1477 case InsertElementOp : return Instruction::InsertElement;
1478 case ShuffleVectorOp : return Instruction::ShuffleVector;
1479 case ICmpOp : return Instruction::ICmp;
1480 case FCmpOp : return Instruction::FCmp;
Reid Spencer950bf602007-01-26 08:19:09 +00001481 };
1482}
1483
1484static inline Value*
1485getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1486 Signedness DstSign, bool ForceInstruction = false) {
1487 Instruction::CastOps Opcode;
1488 const Type* SrcTy = Src->getType();
1489 if (op == CastOp) {
1490 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1491 // fp -> ptr cast is no longer supported but we must upgrade this
1492 // by doing a double cast: fp -> int -> ptr
1493 SrcTy = Type::Int64Ty;
1494 Opcode = Instruction::IntToPtr;
1495 if (isa<Constant>(Src)) {
1496 Src = ConstantExpr::getCast(Instruction::FPToUI,
1497 cast<Constant>(Src), SrcTy);
1498 } else {
1499 std::string NewName(makeNameUnique(Src->getName()));
1500 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1501 }
1502 } else if (isa<IntegerType>(DstTy) &&
1503 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1504 // cast type %x to bool was previously defined as setne type %x, null
1505 // The cast semantic is now to truncate, not compare so we must retain
1506 // the original intent by replacing the cast with a setne
1507 Constant* Null = Constant::getNullValue(SrcTy);
1508 Instruction::OtherOps Opcode = Instruction::ICmp;
1509 unsigned short predicate = ICmpInst::ICMP_NE;
1510 if (SrcTy->isFloatingPoint()) {
1511 Opcode = Instruction::FCmp;
1512 predicate = FCmpInst::FCMP_ONE;
1513 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1514 error("Invalid cast to bool");
1515 }
1516 if (isa<Constant>(Src) && !ForceInstruction)
1517 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1518 else
1519 return CmpInst::create(Opcode, predicate, Src, Null);
1520 }
1521 // Determine the opcode to use by calling CastInst::getCastOpcode
1522 Opcode =
1523 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1524
1525 } else switch (op) {
1526 default: assert(0 && "Invalid cast token");
1527 case TruncOp: Opcode = Instruction::Trunc; break;
1528 case ZExtOp: Opcode = Instruction::ZExt; break;
1529 case SExtOp: Opcode = Instruction::SExt; break;
1530 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1531 case FPExtOp: Opcode = Instruction::FPExt; break;
1532 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1533 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1534 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1535 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1536 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1537 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1538 case BitCastOp: Opcode = Instruction::BitCast; break;
1539 }
1540
1541 if (isa<Constant>(Src) && !ForceInstruction)
1542 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1543 return CastInst::create(Opcode, Src, DstTy);
1544}
1545
1546static Instruction *
1547upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1548 std::vector<Value*>& Args) {
1549
1550 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1551 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1552 if (Args.size() != 2)
1553 error("Invalid prototype for " + Name + " prototype");
1554 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1555 } else {
Reid Spencer950bf602007-01-26 08:19:09 +00001556 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1557 std::vector<const Type*> Params;
1558 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1559 if (Args.size() != 1)
1560 error("Invalid prototype for " + Name + " prototype");
1561 Params.push_back(PtrTy);
1562 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1563 const PointerType *PFTy = PointerType::get(FTy);
1564 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001565 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
Reid Spencer950bf602007-01-26 08:19:09 +00001566 return new CallInst(Func, Args);
1567 } else if (Name == "llvm.va_copy") {
1568 if (Args.size() != 2)
1569 error("Invalid prototype for " + Name + " prototype");
1570 Params.push_back(PtrTy);
1571 Params.push_back(PtrTy);
1572 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1573 const PointerType *PFTy = PointerType::get(FTy);
1574 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001575 std::string InstName0(makeNameUnique("va0"));
1576 std::string InstName1(makeNameUnique("va1"));
Reid Spencer950bf602007-01-26 08:19:09 +00001577 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1578 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1579 return new CallInst(Func, Args);
1580 }
1581 }
1582 return 0;
1583}
1584
1585const Type* upgradeGEPIndices(const Type* PTy,
1586 std::vector<ValueInfo> *Indices,
1587 std::vector<Value*> &VIndices,
1588 std::vector<Constant*> *CIndices = 0) {
1589 // Traverse the indices with a gep_type_iterator so we can build the list
1590 // of constant and value indices for use later. Also perform upgrades
1591 VIndices.clear();
1592 if (CIndices) CIndices->clear();
1593 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1594 VIndices.push_back((*Indices)[i].V);
1595 generic_gep_type_iterator<std::vector<Value*>::iterator>
1596 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1597 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1598 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1599 Value *Index = VIndices[i];
1600 if (CIndices && !isa<Constant>(Index))
1601 error("Indices to constant getelementptr must be constants");
1602 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1603 // struct indices to i32 struct indices with ZExt for compatibility.
1604 else if (isa<StructType>(*GTI)) { // Only change struct indices
1605 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1606 if (CUI->getType()->getBitWidth() == 8)
1607 Index =
1608 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1609 } else {
1610 // Make sure that unsigned SequentialType indices are zext'd to
1611 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1612 // all indices for SequentialType elements. We must retain the same
1613 // semantic (zext) for unsigned types.
1614 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001615 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001616 if (CIndices)
1617 Index = ConstantExpr::getCast(Instruction::ZExt,
1618 cast<Constant>(Index), Type::Int64Ty);
1619 else
1620 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001621 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001622 VIndices[i] = Index;
1623 }
Reid Spencer950bf602007-01-26 08:19:09 +00001624 }
1625 // Add to the CIndices list, if requested.
1626 if (CIndices)
1627 CIndices->push_back(cast<Constant>(Index));
1628 }
1629
1630 const Type *IdxTy =
1631 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1632 if (!IdxTy)
1633 error("Index list invalid for constant getelementptr");
1634 return IdxTy;
1635}
1636
Reid Spencerb7046c72007-01-29 05:41:34 +00001637unsigned upgradeCallingConv(unsigned CC) {
1638 switch (CC) {
1639 case OldCallingConv::C : return CallingConv::C;
1640 case OldCallingConv::CSRet : return CallingConv::C;
1641 case OldCallingConv::Fast : return CallingConv::Fast;
1642 case OldCallingConv::Cold : return CallingConv::Cold;
1643 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1644 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1645 default:
1646 return CC;
1647 }
1648}
1649
Reid Spencer950bf602007-01-26 08:19:09 +00001650Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1651 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001652{
1653 Upgradelineno = 1;
1654 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001655 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001656 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001657 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001658 ObsoleteVarArgs = false;
1659 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001660
Reid Spencer950bf602007-01-26 08:19:09 +00001661 CurModule.CurrentModule = new Module(CurFilename);
1662
1663 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001664 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001665 if (ParserResult)
1666 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001667 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001668 return 0;
1669 }
1670
Reid Spencer950bf602007-01-26 08:19:09 +00001671 // Check to make sure that parsing produced a result
1672 if (!ParserResult) {
1673 std::cerr << "llvm-upgrade: no parse result.\n";
1674 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001675 }
1676
Reid Spencer950bf602007-01-26 08:19:09 +00001677 // Reset ParserResult variable while saving its value for the result.
1678 Module *Result = ParserResult;
1679 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001680
Reid Spencer950bf602007-01-26 08:19:09 +00001681 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001682 {
Reid Spencer950bf602007-01-26 08:19:09 +00001683 Function* F;
1684 if ((F = Result->getNamedFunction("llvm.va_start"))
1685 && F->getFunctionType()->getNumParams() == 0)
1686 ObsoleteVarArgs = true;
1687 if((F = Result->getNamedFunction("llvm.va_copy"))
1688 && F->getFunctionType()->getNumParams() == 1)
1689 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001690 }
Reid Spencer319a7302007-01-05 17:20:02 +00001691
Reid Spencer950bf602007-01-26 08:19:09 +00001692 if (ObsoleteVarArgs && NewVarArgs) {
1693 error("This file is corrupt: it uses both new and old style varargs");
1694 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001695 }
Reid Spencer319a7302007-01-05 17:20:02 +00001696
Reid Spencer950bf602007-01-26 08:19:09 +00001697 if(ObsoleteVarArgs) {
1698 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1699 if (F->arg_size() != 0) {
1700 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001701 return 0;
1702 }
Reid Spencer950bf602007-01-26 08:19:09 +00001703
1704 //foo = va_start()
1705 // ->
1706 //bar = alloca typeof(foo)
1707 //va_start(bar)
1708 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001709
Reid Spencer950bf602007-01-26 08:19:09 +00001710 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1711 const Type* ArgTy = F->getFunctionType()->getReturnType();
1712 const Type* ArgTyPtr = PointerType::get(ArgTy);
1713 Function* NF = cast<Function>(Result->getOrInsertFunction(
1714 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1715
1716 while (!F->use_empty()) {
1717 CallInst* CI = cast<CallInst>(F->use_back());
1718 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1719 new CallInst(NF, bar, "", CI);
1720 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1721 CI->replaceAllUsesWith(foo);
1722 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001723 }
Reid Spencer950bf602007-01-26 08:19:09 +00001724 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001725 }
Reid Spencer950bf602007-01-26 08:19:09 +00001726
1727 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1728 if(F->arg_size() != 1) {
1729 error("Obsolete va_end takes 1 argument");
1730 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001731 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001732
Reid Spencer950bf602007-01-26 08:19:09 +00001733 //vaend foo
1734 // ->
1735 //bar = alloca 1 of typeof(foo)
1736 //vaend bar
1737 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1738 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1739 const Type* ArgTyPtr = PointerType::get(ArgTy);
1740 Function* NF = cast<Function>(Result->getOrInsertFunction(
1741 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001742
Reid Spencer950bf602007-01-26 08:19:09 +00001743 while (!F->use_empty()) {
1744 CallInst* CI = cast<CallInst>(F->use_back());
1745 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1746 new StoreInst(CI->getOperand(1), bar, CI);
1747 new CallInst(NF, bar, "", CI);
1748 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001749 }
Reid Spencer950bf602007-01-26 08:19:09 +00001750 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001751 }
Reid Spencer950bf602007-01-26 08:19:09 +00001752
1753 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1754 if(F->arg_size() != 1) {
1755 error("Obsolete va_copy takes 1 argument");
1756 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001757 }
Reid Spencer950bf602007-01-26 08:19:09 +00001758 //foo = vacopy(bar)
1759 // ->
1760 //a = alloca 1 of typeof(foo)
1761 //b = alloca 1 of typeof(foo)
1762 //store bar -> b
1763 //vacopy(a, b)
1764 //foo = load a
1765
1766 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1767 const Type* ArgTy = F->getFunctionType()->getReturnType();
1768 const Type* ArgTyPtr = PointerType::get(ArgTy);
1769 Function* NF = cast<Function>(Result->getOrInsertFunction(
1770 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001771
Reid Spencer950bf602007-01-26 08:19:09 +00001772 while (!F->use_empty()) {
1773 CallInst* CI = cast<CallInst>(F->use_back());
1774 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1775 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1776 new StoreInst(CI->getOperand(1), b, CI);
1777 new CallInst(NF, a, b, "", CI);
1778 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1779 CI->replaceAllUsesWith(foo);
1780 CI->getParent()->getInstList().erase(CI);
1781 }
1782 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001783 }
1784 }
1785
Reid Spencer52402b02007-01-02 05:45:11 +00001786 return Result;
1787}
1788
Reid Spencer950bf602007-01-26 08:19:09 +00001789} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001790
Reid Spencer950bf602007-01-26 08:19:09 +00001791using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001792
1793
Reid Spencer319a7302007-01-05 17:20:02 +00001794
1795/* Enabling traces. */
1796#ifndef YYDEBUG
1797# define YYDEBUG 0
1798#endif
1799
1800/* Enabling verbose error messages. */
1801#ifdef YYERROR_VERBOSE
1802# undef YYERROR_VERBOSE
1803# define YYERROR_VERBOSE 1
1804#else
1805# define YYERROR_VERBOSE 0
1806#endif
1807
Reid Spencer950bf602007-01-26 08:19:09 +00001808/* Enabling the token table. */
1809#ifndef YYTOKEN_TABLE
1810# define YYTOKEN_TABLE 0
1811#endif
1812
Reid Spencerb7046c72007-01-29 05:41:34 +00001813#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer832254e2007-02-02 02:16:23 +00001814#line 1435 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00001815typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00001816 llvm::Module *ModuleVal;
1817 llvm::Function *FunctionVal;
1818 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1819 llvm::BasicBlock *BasicBlockVal;
1820 llvm::TerminatorInst *TermInstVal;
1821 llvm::InstrInfo InstVal;
1822 llvm::ConstInfo ConstVal;
1823 llvm::ValueInfo ValueVal;
1824 llvm::PATypeInfo TypeVal;
1825 llvm::TypeInfo PrimType;
1826 llvm::PHIListInfo PHIList;
1827 std::list<llvm::PATypeInfo> *TypeList;
1828 std::vector<llvm::ValueInfo> *ValueList;
1829 std::vector<llvm::ConstInfo> *ConstVector;
1830
1831
1832 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1833 // Represent the RHS of PHI node
1834 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1835
1836 llvm::GlobalValue::LinkageTypes Linkage;
1837 int64_t SInt64Val;
1838 uint64_t UInt64Val;
1839 int SIntVal;
1840 unsigned UIntVal;
1841 double FPVal;
1842 bool BoolVal;
1843
1844 char *StrVal; // This memory is strdup'd!
1845 llvm::ValID ValIDVal; // strdup'd memory maybe!
1846
1847 llvm::BinaryOps BinaryOpVal;
1848 llvm::TermOps TermOpVal;
1849 llvm::MemoryOps MemOpVal;
1850 llvm::OtherOps OtherOpVal;
1851 llvm::CastOps CastOpVal;
1852 llvm::ICmpInst::Predicate IPred;
1853 llvm::FCmpInst::Predicate FPred;
1854 llvm::Module::Endianness Endianness;
Reid Spencerb7046c72007-01-29 05:41:34 +00001855} YYSTYPE;
1856/* Line 196 of yacc.c. */
Reid Spencer832254e2007-02-02 02:16:23 +00001857#line 1858 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001858# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1859# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001860# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001861#endif
1862
Reid Spencer950bf602007-01-26 08:19:09 +00001863
Reid Spencere7c3c602006-11-30 06:36:44 +00001864
Reid Spencer319a7302007-01-05 17:20:02 +00001865/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001866
1867
Reid Spencerb7046c72007-01-29 05:41:34 +00001868/* Line 219 of yacc.c. */
Reid Spencer832254e2007-02-02 02:16:23 +00001869#line 1870 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001870
Reid Spencerb7046c72007-01-29 05:41:34 +00001871#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1872# define YYSIZE_T __SIZE_TYPE__
Reid Spencer950bf602007-01-26 08:19:09 +00001873#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001874#if ! defined (YYSIZE_T) && defined (size_t)
1875# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001876#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001877#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1878# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1879# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001880#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001881#if ! defined (YYSIZE_T)
1882# define YYSIZE_T unsigned int
Reid Spencer950bf602007-01-26 08:19:09 +00001883#endif
1884
1885#ifndef YY_
1886# if YYENABLE_NLS
1887# if ENABLE_NLS
1888# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1889# define YY_(msgid) dgettext ("bison-runtime", msgid)
1890# endif
1891# endif
1892# ifndef YY_
1893# define YY_(msgid) msgid
1894# endif
1895#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001896
Reid Spencerb7046c72007-01-29 05:41:34 +00001897#if ! defined (yyoverflow) || YYERROR_VERBOSE
Reid Spencer319a7302007-01-05 17:20:02 +00001898
1899/* The parser invokes alloca or malloc; define the necessary symbols. */
1900
Reid Spencer950bf602007-01-26 08:19:09 +00001901# ifdef YYSTACK_USE_ALLOCA
1902# if YYSTACK_USE_ALLOCA
1903# ifdef __GNUC__
1904# define YYSTACK_ALLOC __builtin_alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001905# else
Reid Spencer950bf602007-01-26 08:19:09 +00001906# define YYSTACK_ALLOC alloca
Reid Spencerb7046c72007-01-29 05:41:34 +00001907# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00001908# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Reid Spencerb7046c72007-01-29 05:41:34 +00001909# define YYINCLUDED_STDLIB_H
Reid Spencer319a7302007-01-05 17:20:02 +00001910# endif
1911# endif
1912# endif
1913# endif
1914
1915# ifdef YYSTACK_ALLOC
Reid Spencerb7046c72007-01-29 05:41:34 +00001916 /* Pacify GCC's `empty if-body' warning. */
1917# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00001918# ifndef YYSTACK_ALLOC_MAXIMUM
1919 /* The OS might guarantee only one guard page at the bottom of the stack,
1920 and a page size can be as small as 4096 bytes. So we cannot safely
1921 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1922 to allow for a few compiler-allocated temporary stack slots. */
Reid Spencerb7046c72007-01-29 05:41:34 +00001923# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer319a7302007-01-05 17:20:02 +00001924# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001925# else
1926# define YYSTACK_ALLOC YYMALLOC
1927# define YYSTACK_FREE YYFREE
1928# ifndef YYSTACK_ALLOC_MAXIMUM
Reid Spencerb7046c72007-01-29 05:41:34 +00001929# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
Reid Spencer950bf602007-01-26 08:19:09 +00001930# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001931# ifdef __cplusplus
1932extern "C" {
Reid Spencer950bf602007-01-26 08:19:09 +00001933# endif
1934# ifndef YYMALLOC
1935# define YYMALLOC malloc
Reid Spencerb7046c72007-01-29 05:41:34 +00001936# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1937 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001938void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1939# endif
1940# endif
1941# ifndef YYFREE
1942# define YYFREE free
Reid Spencerb7046c72007-01-29 05:41:34 +00001943# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1944 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001945void free (void *); /* INFRINGES ON USER NAME SPACE */
1946# endif
1947# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001948# ifdef __cplusplus
1949}
1950# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001951# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001952#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00001953
1954
Reid Spencerb7046c72007-01-29 05:41:34 +00001955#if (! defined (yyoverflow) \
1956 && (! defined (__cplusplus) \
1957 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001958
1959/* A type that is properly aligned for any stack member. */
1960union yyalloc
1961{
Reid Spencerb7046c72007-01-29 05:41:34 +00001962 short int yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001963 YYSTYPE yyvs;
1964 };
1965
1966/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00001967# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00001968
1969/* The size of an array large to enough to hold all stacks, each with
1970 N elements. */
1971# define YYSTACK_BYTES(N) \
Reid Spencerb7046c72007-01-29 05:41:34 +00001972 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer950bf602007-01-26 08:19:09 +00001973 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00001974
1975/* Copy COUNT objects from FROM to TO. The source and destination do
1976 not overlap. */
1977# ifndef YYCOPY
Reid Spencerb7046c72007-01-29 05:41:34 +00001978# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00001979# define YYCOPY(To, From, Count) \
1980 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1981# else
1982# define YYCOPY(To, From, Count) \
1983 do \
1984 { \
Reid Spencer950bf602007-01-26 08:19:09 +00001985 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00001986 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00001987 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00001988 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00001989 while (0)
Reid Spencer319a7302007-01-05 17:20:02 +00001990# endif
1991# endif
1992
1993/* Relocate STACK from its old location to the new one. The
1994 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1995 elements in the stack, and YYPTR gives the new location of the
1996 stack. Advance YYPTR to a properly aligned location for the next
1997 stack. */
1998# define YYSTACK_RELOCATE(Stack) \
1999 do \
2000 { \
2001 YYSIZE_T yynewbytes; \
2002 YYCOPY (&yyptr->Stack, Stack, yysize); \
2003 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00002004 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00002005 yyptr += yynewbytes / sizeof (*yyptr); \
2006 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00002007 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00002008
2009#endif
2010
Reid Spencerb7046c72007-01-29 05:41:34 +00002011#if defined (__STDC__) || defined (__cplusplus)
2012 typedef signed char yysigned_char;
2013#else
2014 typedef short int yysigned_char;
2015#endif
2016
2017/* YYFINAL -- State number of the termination state. */
Reid Spencer319a7302007-01-05 17:20:02 +00002018#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00002019/* YYLAST -- Last index in YYTABLE. */
Reid Spencer832254e2007-02-02 02:16:23 +00002020#define YYLAST 1736
Reid Spencer319a7302007-01-05 17:20:02 +00002021
Reid Spencerb7046c72007-01-29 05:41:34 +00002022/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002023#define YYNTOKENS 166
Reid Spencerb7046c72007-01-29 05:41:34 +00002024/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002025#define YYNNTS 79
Reid Spencerb7046c72007-01-29 05:41:34 +00002026/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00002027#define YYNRULES 308
Reid Spencerb7046c72007-01-29 05:41:34 +00002028/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00002029#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00002030
2031/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2032#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00002033#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00002034
Reid Spencer950bf602007-01-26 08:19:09 +00002035#define YYTRANSLATE(YYX) \
2036 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00002037
2038/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002039static const unsigned char yytranslate[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002040{
2041 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2042 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2043 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2044 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002045 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002046 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002047 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002050 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002051 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2052 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002053 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2057 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2058 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2059 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2060 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2061 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2062 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2063 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2064 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2065 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2066 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2067 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2068 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2069 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2070 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2071 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2072 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2073 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2074 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2075 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2076 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2077 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2078 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2079 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2080 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002081 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002082};
2083
2084#if YYDEBUG
2085/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2086 YYRHS. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002087static const unsigned short int yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002088{
2089 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2090 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2091 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2092 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2093 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2094 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2095 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2096 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2097 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002098 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002099 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2100 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2101 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2102 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2103 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002104 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2105 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2106 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2107 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2108 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2109 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2110 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2111 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2112 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2113 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2114 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2115 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2116 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2117 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2118 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2119 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002120};
2121
Reid Spencerb7046c72007-01-29 05:41:34 +00002122/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2123static const short int yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002124{
Reid Spencer950bf602007-01-26 08:19:09 +00002125 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002126 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2127 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
Reid Spencer832254e2007-02-02 02:16:23 +00002128 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2129 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
Reid Spencer950bf602007-01-26 08:19:09 +00002130 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2131 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2132 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2133 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2134 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
Reid Spencer832254e2007-02-02 02:16:23 +00002135 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
Reid Spencer950bf602007-01-26 08:19:09 +00002136 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2137 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2138 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2139 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2140 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2141 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2142 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2143 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2144 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2145 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2146 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2147 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002148 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002149 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2150 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2151 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2152 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2153 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2154 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2155 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2156 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2157 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2158 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2159 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2160 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2161 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2162 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2163 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
Reid Spencer832254e2007-02-02 02:16:23 +00002164 36, 191, 156, -1, 110, 155, 196, 242, 156, -1,
2165 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
Reid Spencer950bf602007-01-26 08:19:09 +00002166 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2167 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002168 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
Reid Spencer950bf602007-01-26 08:19:09 +00002169 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2170 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2171 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2172 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2173 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2174 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2175 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2176 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2177 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2178 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2179 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2180 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2181 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2182 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2183 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2184 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2185 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2186 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2187 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2188 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2189 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2190 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2191 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2192 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2193 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2194 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2195 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2196 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2197 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2198 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2199 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2200 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2201 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2202 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2203 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2204 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2205 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2206 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2207 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2208 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002209 103, 172, 191, 228, 153, 228, -1, 104, 173, 191,
Reid Spencer950bf602007-01-26 08:19:09 +00002210 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
Reid Spencer832254e2007-02-02 02:16:23 +00002211 229, -1, 175, 229, 36, 191, -1, 112, 229, 153,
Reid Spencer950bf602007-01-26 08:19:09 +00002212 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2213 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2214 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
Reid Spencer832254e2007-02-02 02:16:23 +00002215 -1, 116, 229, 153, 229, 153, 229, -1, 111, 237,
Reid Spencer950bf602007-01-26 08:19:09 +00002216 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
Reid Spencer832254e2007-02-02 02:16:23 +00002217 -1, 153, 238, -1, -1, 35, -1, -1, 105, 191,
2218 184, -1, 105, 191, 153, 15, 228, 184, -1, 106,
2219 191, 184, -1, 106, 191, 153, 15, 228, 184, -1,
2220 107, 229, -1, 243, 108, 191, 228, -1, 243, 109,
2221 229, 153, 191, 228, -1, 110, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002222};
2223
2224/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002225static const unsigned short int yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002226{
Reid Spencer832254e2007-02-02 02:16:23 +00002227 0, 1575, 1575, 1576, 1584, 1585, 1595, 1595, 1595, 1595,
2228 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1599, 1599, 1599,
2229 1603, 1603, 1603, 1603, 1603, 1603, 1607, 1607, 1608, 1608,
2230 1609, 1609, 1610, 1610, 1611, 1611, 1615, 1615, 1616, 1616,
2231 1617, 1617, 1618, 1618, 1619, 1619, 1620, 1620, 1621, 1621,
2232 1622, 1623, 1626, 1626, 1626, 1626, 1630, 1630, 1630, 1630,
2233 1630, 1630, 1630, 1631, 1631, 1631, 1631, 1631, 1631, 1637,
2234 1637, 1637, 1637, 1641, 1641, 1641, 1641, 1645, 1645, 1649,
2235 1649, 1654, 1657, 1662, 1663, 1664, 1665, 1666, 1667, 1668,
2236 1669, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1690,
2237 1691, 1699, 1700, 1708, 1717, 1718, 1725, 1726, 1730, 1734,
2238 1750, 1751, 1758, 1759, 1766, 1774, 1774, 1774, 1774, 1774,
2239 1774, 1774, 1775, 1775, 1775, 1775, 1775, 1780, 1784, 1788,
2240 1793, 1802, 1823, 1829, 1842, 1851, 1855, 1866, 1870, 1883,
2241 1887, 1894, 1895, 1901, 1908, 1920, 1950, 1963, 1986, 2014,
2242 2036, 2047, 2069, 2080, 2089, 2094, 2152, 2159, 2167, 2174,
2243 2181, 2185, 2189, 2198, 2213, 2226, 2235, 2263, 2276, 2285,
2244 2291, 2297, 2308, 2314, 2320, 2331, 2332, 2341, 2342, 2354,
2245 2363, 2364, 2365, 2366, 2367, 2383, 2403, 2405, 2407, 2407,
2246 2414, 2414, 2421, 2421, 2428, 2428, 2436, 2438, 2440, 2445,
2247 2459, 2460, 2464, 2467, 2475, 2479, 2486, 2490, 2494, 2498,
2248 2506, 2506, 2510, 2511, 2515, 2523, 2528, 2536, 2537, 2544,
2249 2551, 2555, 2670, 2670, 2674, 2684, 2684, 2688, 2692, 2694,
2250 2695, 2699, 2699, 2711, 2712, 2717, 2718, 2719, 2720, 2721,
2251 2722, 2723, 2724, 2725, 2746, 2749, 2764, 2765, 2770, 2770,
2252 2778, 2787, 2790, 2799, 2809, 2814, 2823, 2834, 2834, 2837,
2253 2840, 2843, 2847, 2853, 2868, 2874, 2930, 2933, 2939, 2949,
2254 2962, 2991, 2999, 3007, 3011, 3018, 3019, 3023, 3026, 3032,
2255 3049, 3065, 3079, 3091, 3103, 3114, 3132, 3141, 3150, 3157,
2256 3178, 3202, 3208, 3214, 3220, 3236, 3314, 3322, 3323, 3327,
2257 3328, 3332, 3338, 3344, 3350, 3356, 3363, 3375, 3389
Reid Spencer319a7302007-01-05 17:20:02 +00002258};
2259#endif
2260
Reid Spencer950bf602007-01-26 08:19:09 +00002261#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2262/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencerb7046c72007-01-29 05:41:34 +00002263 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer319a7302007-01-05 17:20:02 +00002264static const char *const yytname[] =
2265{
Reid Spencer950bf602007-01-26 08:19:09 +00002266 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2267 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2268 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2269 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2270 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2271 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2272 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2273 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2274 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2275 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2276 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2277 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2278 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2279 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
Reid Spencer832254e2007-02-02 02:16:23 +00002280 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2281 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2282 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2283 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
Reid Spencer950bf602007-01-26 08:19:09 +00002284 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2285 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2286 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2287 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2288 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2289 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2290 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2291 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2292 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2293 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2294 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2295 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2296 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2297 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2298 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2299 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2300 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2301 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2302 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2303 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2304 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002305 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002306};
2307#endif
2308
2309# ifdef YYPRINT
2310/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2311 token YYLEX-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002312static const unsigned short int yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002313{
2314 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2315 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2316 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2317 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2318 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2319 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2320 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2321 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2322 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2323 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2324 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2325 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2326 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2327 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2328 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002329 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2330 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002331};
2332# endif
2333
2334/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002335static const unsigned char yyr1[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002336{
Reid Spencer950bf602007-01-26 08:19:09 +00002337 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2338 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2339 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2340 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2341 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2342 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2343 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2344 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2345 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2346 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2347 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2348 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2349 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2350 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2351 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2352 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2353 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2354 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2355 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2356 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2357 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2358 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2359 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2360 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2361 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2362 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2363 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2364 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2365 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2366 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2367 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002368};
2369
2370/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002371static const unsigned char yyr2[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002372{
2373 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2374 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2375 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2376 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2377 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2378 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2379 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2381 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002382 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002383 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2384 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2385 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2386 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2387 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002388 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2389 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2390 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2391 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2392 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2393 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2394 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2395 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2396 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2397 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2398 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2399 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2400 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2401 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2402 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2403 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002404};
2405
2406/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2407 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2408 means the default is an error. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002409static const unsigned short int yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002410{
Reid Spencer950bf602007-01-26 08:19:09 +00002411 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2412 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2413 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2414 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2415 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2416 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2417 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2418 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2419 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2420 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2421 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2422 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2423 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2424 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
Reid Spencer832254e2007-02-02 02:16:23 +00002425 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2426 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2427 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002428 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2429 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2430 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2431 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2432 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2433 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2434 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2435 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2436 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2437 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2438 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2439 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002440 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002441 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2442 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002443 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002444 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2445 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2446 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2447 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2448 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2449 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2450 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2451 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2452 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2453 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2454 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2455 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2456 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2457 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2458 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2459 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2460 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2461 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2462 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2463 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2464 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2465 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2466 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2467 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2468 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2469 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2470 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2471 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002472};
2473
Reid Spencerb7046c72007-01-29 05:41:34 +00002474/* YYDEFGOTO[NTERM-NUM]. */
2475static const short int yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002476{
Reid Spencer950bf602007-01-26 08:19:09 +00002477 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2478 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2479 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2480 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2481 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2482 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2483 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2484 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002485};
2486
2487/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2488 STATE-NUM. */
Reid Spencer832254e2007-02-02 02:16:23 +00002489#define YYPACT_NINF -541
Reid Spencerb7046c72007-01-29 05:41:34 +00002490static const short int yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002491{
Reid Spencer832254e2007-02-02 02:16:23 +00002492 -541, 28, 61, 478, -541, -541, -541, -541, -541, -541,
2493 -541, -541, -541, -541, 23, 152, 45, -541, -541, -9,
2494 -541, -541, -20, -51, 76, 69, 12, -541, 97, 149,
2495 172, -541, -541, -541, -541, -541, -541, 1331, -19, -541,
2496 -541, 137, -541, -541, -541, -541, 49, 58, 60, 62,
2497 -541, 72, 149, 1331, 88, 88, 88, 88, -541, -541,
2498 -541, 152, -541, -541, -541, -541, -541, 75, -541, -541,
2499 -541, -541, -541, -541, -541, -541, -541, -541, -541, -541,
2500 -541, 227, 228, 3, 691, -541, 137, 79, -541, -541,
2501 -46, -541, -541, -541, -541, -541, 1585, -541, 212, 136,
2502 233, 214, 216, -541, -541, -541, -541, -541, 1392, 1392,
2503 1392, 1433, -541, -541, 83, 87, 711, -541, -541, -46,
2504 -70, 89, 777, -541, -541, 1392, -541, 183, 1453, 6,
2505 309, 152, -541, -541, -541, -541, -541, -541, -541, -541,
2506 -541, -541, -541, -541, -541, -541, -541, -541, -541, -541,
2507 -541, -541, -541, -541, -541, -541, -541, -541, -541, 59,
2508 142, 1392, 1392, 1392, 1392, 1392, 1392, 1392, 1392, 1392,
2509 1392, 1392, 1392, -541, -541, -541, -541, -541, -541, -541,
2510 -541, -541, -541, -541, -541, -541, 1392, 1392, 1392, 1392,
2511 1392, -541, -541, 152, -541, 86, -541, -541, -541, -541,
2512 -541, -541, -541, -541, -129, -541, -541, -541, 169, 196,
2513 242, 200, 246, 203, 252, 205, 253, 251, 258, 221,
2514 255, 259, 533, -541, 1392, 1392, 99, -63, 1392, -541,
2515 1173, -541, 128, 126, 894, -541, -541, 75, -541, 894,
2516 894, -541, -541, -541, -541, -541, -541, -541, -541, -541,
2517 -541, 894, 1331, -541, -541, -541, -541, -541, -541, -541,
2518 -541, -541, -541, 1392, -541, -541, -541, -541, -541, -541,
2519 -541, -541, -541, -541, -541, -541, -541, -541, -541, -541,
2520 1392, 130, 133, -541, 894, 132, 138, 139, 143, 144,
2521 151, 155, 156, 157, 894, 894, 894, 163, 254, 1331,
2522 1392, 1392, 271, -541, 164, 164, 164, -541, -541, -541,
2523 -541, -541, -541, -541, -541, -541, -541, 59, 142, 173,
2524 174, 175, 176, 177, 1214, 1494, 732, 281, 178, 179,
2525 180, 182, 190, -541, -541, 164, -42, -135, -541, 166,
2526 -46, -541, 137, -541, 193, 191, 1234, -541, -541, -541,
2527 -541, -541, -541, -541, -541, -541, 290, 1433, -541, -541,
2528 -541, -541, 201, -541, 202, 894, 894, 894, 7, -541,
2529 10, -541, 204, 894, 199, 1392, 1392, 1392, 1392, 1392,
2530 1392, 1392, 211, 215, 217, 1392, 1392, 894, 894, 223,
2531 -541, -21, -541, -541, -541, 210, 219, 1433, 1433, 1433,
2532 1433, 1433, -541, -541, 4, 752, -91, -541, -8, -541,
2533 1433, 1433, 1433, 1433, 1433, -541, -541, -541, -541, -541,
2534 -541, 1275, 324, -541, -541, 343, 37, 348, 356, 224,
2535 225, 229, 894, 376, 894, 1392, -541, 230, 894, 232,
2536 -541, -541, 234, 235, -541, -541, 894, 894, 894, -541,
2537 -541, 226, -541, 1392, 362, 385, -541, 164, 1433, 1433,
2538 204, 238, 239, 240, 241, 1433, -541, 243, -17, -5,
2539 -541, -541, 247, 250, 261, 262, 359, -541, -541, -541,
2540 339, 268, -541, 894, 894, 1392, 894, 894, 269, -541,
2541 269, -541, 270, 894, 272, 1392, 1392, 1392, -541, -541,
2542 -541, 1392, 894, -541, -541, -541, 273, 274, 249, 1433,
2543 1433, 1433, 1433, -541, -541, 245, 1433, 1433, 1433, 1433,
2544 1392, 395, -541, 383, 275, 267, 270, 279, -541, -541,
2545 351, -541, -541, 1392, 277, 894, -541, -541, -541, 282,
2546 -541, 1433, 1433, -541, 278, 283, 284, 288, -541, 289,
2547 291, 295, 296, 297, -541, -541, 423, 43, 410, -541,
2548 -541, 298, -541, 300, 305, 1433, -541, 1433, 1433, -541,
2549 -541, -541, -541, -541, 894, -541, 1020, 64, 441, -541,
2550 -541, -541, 307, 311, 314, -541, 312, -541, 1020, 894,
2551 -541, -541, -541, 450, 319, 150, 894, 452, 453, -541,
2552 894, 894, -541, -541
Reid Spencer319a7302007-01-05 17:20:02 +00002553};
2554
2555/* YYPGOTO[NTERM-NUM]. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002556static const short int yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002557{
Reid Spencer832254e2007-02-02 02:16:23 +00002558 -541, -541, -541, 379, 380, 381, 161, 162, 386, 388,
2559 -128, -127, -540, -541, 438, 456, -111, -541, -277, 63,
2560 -541, -297, -541, -47, -541, -37, -541, -53, 40, -541,
2561 -99, 264, -307, 84, -541, -541, -541, -541, -541, -541,
2562 -541, 435, -541, -541, -541, -541, 8, -541, 68, -541,
2563 -541, 427, -541, -541, -541, -541, -541, 487, -541, -541,
2564 -489, -199, 67, -124, -541, 472, -541, -103, -541, -541,
2565 -541, -541, 71, -7, -541, -541, 33, -541, -541
Reid Spencer319a7302007-01-05 17:20:02 +00002566};
2567
2568/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2569 positive, shift that token. If negative, reduce the rule which
2570 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002571 If YYTABLE_NINF, syntax error. */
2572#define YYTABLE_NINF -180
Reid Spencerb7046c72007-01-29 05:41:34 +00002573static const short int yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002574{
Reid Spencer832254e2007-02-02 02:16:23 +00002575 88, 235, 249, 250, 238, 371, 105, 115, 393, 394,
2576 93, 26, 223, 454, 39, 239, 88, 576, 406, 408,
2577 252, 42, 432, 334, 302, 434, 417, 240, 4, 123,
2578 303, 119, 46, 47, 48, 360, 455, 588, 415, 283,
2579 360, 360, 287, 288, 289, 290, 291, 292, 293, 26,
2580 426, 49, 360, 241, 242, 243, 244, 245, 246, 247,
2581 248, -179, 465, 119, 433, 297, 298, 433, 39, 119,
2582 470, 205, 206, 207, 241, 242, 243, 244, 245, 246,
2583 247, 248, 299, 228, 29, 360, 5, 586, 234, 53,
2584 228, 234, 6, 229, 121, 360, 360, 360, 469, 594,
2585 339, 51, 7, 8, 9, 10, 11, 12, 13, -112,
2586 7, 8, 9, 10, 54, 12, 55, 416, 123, 56,
2587 106, 107, 123, 14, 281, 282, 234, 284, 285, 234,
2588 234, 234, 234, 234, 234, 234, -139, 52, -112, 109,
2589 110, 111, 59, 94, 60, 465, -139, 123, 465, 294,
2590 295, 296, 234, 234, 43, 471, 227, 465, 515, 20,
2591 505, 21, 232, 466, 58, 116, 360, 360, 360, 264,
2592 265, 336, 337, 62, 360, 340, 64, 389, 253, 254,
2593 255, 256, 257, 258, 259, 260, 261, 262, 360, 360,
2594 465, 198, 199, 342, 300, 301, 307, 308, 482, -72,
2595 -72, 98, 575, -71, -71, 365, -70, -70, -69, -69,
2596 99, 531, 100, 532, 101, 88, 30, 31, 32, 33,
2597 34, 35, 36, 587, 309, 310, 366, 133, 134, 102,
2598 -113, 113, 114, 360, 122, 360, 197, 201, 202, 360,
2599 203, 224, 236, 367, 230, 225, -76, 360, 360, 360,
2600 -75, 439, 387, 441, 442, 443, -74, -73, -79, 312,
2601 338, 449, 88, 388, 234, -80, 313, 266, 267, 268,
2602 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
2603 279, 346, 347, 368, 360, 360, 370, 360, 360, 373,
2604 386, 374, 375, 340, 360, 390, 376, 377, 460, 461,
2605 462, 463, 464, 360, 378, 409, 362, 363, 379, 380,
2606 381, 472, 473, 474, 475, 476, 385, 391, 364, 241,
2607 242, 243, 244, 245, 246, 247, 248, 418, 397, 398,
2608 399, 400, 401, 410, 411, 412, 360, 413, 234, 440,
2609 234, 234, 234, 444, 445, 414, 421, 422, 234, 450,
2610 419, 372, 468, 424, 427, 428, 438, 435, 454, 506,
2611 507, 382, 383, 384, 446, 458, 513, 481, 447, 483,
2612 448, 536, 537, 538, 459, 360, 453, 484, 486, 485,
2613 489, 501, 487, 493, 342, 495, 503, 496, 497, 504,
2614 360, 509, 510, 511, 512, 520, 521, 360, 234, 554,
2615 516, 360, 360, 517, 514, 543, 548, 555, 433, 559,
2616 544, 545, 546, 547, 518, 519, 502, 549, 550, 551,
2617 552, 523, 530, 533, 557, 535, 541, 542, 556, 249,
2618 250, 565, 429, 430, 431, 558, 560, 567, 562, 566,
2619 437, 568, 563, 564, 574, 569, 578, 570, 234, 249,
2620 250, 571, 572, 573, 451, 452, 580, 579, 234, 234,
2621 234, 581, 589, 590, 234, 593, 582, 591, 583, 584,
2622 592, 596, 597, 600, 601, 186, 187, 188, 395, 96,
2623 396, 57, 189, 553, 190, 479, 333, 104, 112, 478,
2624 27, 45, 598, 508, 539, 0, 234, 0, -82, 488,
2625 20, 490, 21, 0, 0, 494, 492, 0, 0, 6,
2626 -82, -82, 0, 498, 499, 500, 0, 0, 0, -82,
2627 -82, -82, -82, -82, -82, -82, 0, 0, -82, 22,
2628 0, 0, 0, 0, 0, 0, 23, 0, 65, 66,
2629 24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2630 524, 525, 0, 528, 529, 20, 0, 21, 0, 314,
2631 534, 0, 0, 0, 0, 0, 0, 0, 0, 540,
2632 0, 315, 316, 0, 0, 0, 0, 0, 0, 0,
2633 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2634 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2635 0, 0, 561, 0, 0, 0, 0, 0, 0, 0,
2636 0, 0, 135, 136, 137, 138, 139, 140, 141, 142,
2637 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,
2638 153, 154, 155, 156, 157, 158, 317, 318, 0, 0,
2639 0, 585, 0, 319, 0, 320, 0, 321, 322, 323,
2640 0, 0, 0, 0, 0, 0, 595, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002641 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002642 0, 0, 173, 174, 175, 176, 177, 178, 179, 180,
2643 181, 182, 183, 184, 185, 0, 0, 0, 0, 0,
2644 324, 0, 0, 325, 0, 326, 65, 66, 327, 117,
Reid Spencer950bf602007-01-26 08:19:09 +00002645 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
Reid Spencer832254e2007-02-02 02:16:23 +00002646 78, 0, 79, 20, 0, 21, 65, 66, 0, 117,
2647 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2648 78, 0, 79, 20, 0, 21, 0, 65, 66, 80,
2649 117, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2650 217, 218, 0, 79, 20, 0, 21, 65, 66, 80,
2651 117, 208, 209, 210, 211, 212, 213, 214, 215, 216,
2652 217, 218, 0, 79, 20, 0, 21, 0, 0, 0,
2653 80, 0, 65, 66, 0, 117, 68, 69, 70, 71,
2654 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2655 80, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2656 0, 0, 0, 0, 231, 0, 0, 0, 0, 0,
2657 0, 0, 0, 0, 0, 80, 0, 0, 0, 0,
Reid Spencerc4d96252007-01-13 00:03:30 +00002658 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002659 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2660 0, 83, 0, 84, 118, 0, 0, 0, 0, 0,
2661 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2662 0, 83, 0, 84, 226, 0, 0, 0, 0, 0,
2663 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
2664 0, 0, 83, 0, 84, 407, 0, 348, 349, 65,
2665 66, 350, 0, 0, 0, 0, 81, 0, 0, 82,
2666 0, 0, 83, 0, 84, 467, 20, 0, 21, 0,
2667 351, 352, 353, 0, 0, 0, 0, 0, 0, 0,
2668 0, 81, 354, 355, 82, 0, 0, 83, 0, 84,
Reid Spencer319a7302007-01-05 17:20:02 +00002669 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002670 0, 0, 0, 0, 0, 356, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002671 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002672 0, 0, 0, 135, 136, 137, 138, 139, 140, 141,
2673 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2674 152, 153, 154, 155, 156, 157, 158, 317, 318, 0,
2675 0, 0, 0, 0, 319, 0, 320, 0, 321, 322,
2676 323, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2677 0, 0, 0, 348, 349, 0, 0, 350, 0, 0,
2678 0, 0, 0, 173, 174, 175, 176, 177, 178, 179,
2679 180, 181, 182, 183, 184, 185, 351, 352, 353, 0,
2680 0, 0, 0, 0, 357, 0, 0, 0, 354, 355,
Reid Spencer950bf602007-01-26 08:19:09 +00002681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002682 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002683 0, 356, 0, 0, 0, 0, 0, 0, 0, 0,
2684 0, 0, 0, 0, 0, 0, 0, 0, 0, 135,
2685 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2686 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
2687 156, 157, 158, 317, 318, 0, 0, 0, 0, 0,
2688 319, 0, 320, 0, 321, 322, 323, 0, 0, 0,
2689 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2690 0, 0, 0, 0, 0, 0, 0, 0, 0, 173,
2691 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2692 184, 185, 0, 0, 0, 0, 0, 0, 65, 66,
2693 357, 117, 68, 69, 70, 71, 72, 73, 74, 75,
2694 76, 77, 78, 0, 79, 20, 0, 21, 0, 0,
2695 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2696 341, 0, 0, 0, 0, 0, 0, 0, 0, 65,
2697 66, 80, 117, 208, 209, 210, 211, 212, 213, 214,
2698 215, 216, 217, 218, 0, 79, 20, 0, 21, 65,
2699 66, 0, 117, 68, 69, 70, 71, 72, 73, 74,
2700 75, 76, 77, 78, 0, 79, 20, 0, 21, 0,
2701 0, 0, 80, 0, 0, 0, 0, 0, 0, 0,
2702 0, 423, 0, 0, 0, 0, 0, 0, 0, 0,
2703 65, 66, 80, 117, 68, 69, 70, 71, 72, 73,
2704 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2706 0, 0, 477, 0, 0, 0, 0, 0, 0, 0,
2707 0, 0, 0, 80, 0, 0, 0, 81, 0, 0,
2708 82, 0, 0, 83, 0, 84, 65, 66, 0, 67,
Reid Spencer950bf602007-01-26 08:19:09 +00002709 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2710 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002711 0, 0, 0, 0, 0, 0, 0, 0, 81, 0,
2712 0, 82, 0, 402, 83, 0, 84, 0, 0, 80,
2713 0, 0, 0, 0, 0, 0, 0, 0, 81, 0,
2714 0, 82, 0, 0, 83, 0, 84, 65, 66, 0,
2715 117, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2716 77, 78, 0, 79, 20, 0, 21, 0, 0, 0,
2717 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2718 0, 0, 82, 0, 0, 83, 0, 84, 65, 66,
2719 80, 117, 208, 209, 210, 211, 212, 213, 214, 215,
2720 216, 217, 218, 0, 79, 20, 0, 21, 65, 66,
2721 0, 237, 68, 69, 70, 71, 72, 73, 74, 75,
2722 76, 77, 78, 0, 79, 20, 0, 21, 0, 0,
2723 0, 80, 0, 0, 0, 81, 0, 0, 82, 0,
2724 0, 83, 0, 84, 0, 0, 0, 0, 0, 65,
2725 66, 80, 117, 208, 209, 210, 211, 212, 213, 214,
2726 215, 216, 217, 218, 0, 79, 20, 0, 21, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002727 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2728 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002729 0, 0, 80, 0, 0, 0, 81, 0, 0, 82,
2730 0, 0, 83, 0, 84, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002731 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2732 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer832254e2007-02-02 02:16:23 +00002733 0, 0, 0, 0, 0, 0, 0, 81, 0, 0,
2734 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2735 0, 0, 0, 0, 0, 0, 0, 81, 0, 0,
2736 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2737 124, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2738 0, 0, 0, 0, 125, 0, 0, 0, 0, 0,
2739 0, 0, 0, 0, 126, 127, 0, 0, 81, 0,
2740 0, 82, 0, 0, 83, 0, 405, 128, 129, 130,
2741 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
2742 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
2743 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
2744 161, 162, 163, 0, 0, 164, 165, 166, 167, 168,
2745 169, 170, 171, 172, 0, 0, 0, 0, 0, 0,
2746 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2747 0, 0, 0, 0, 173, 174, 175, 176, 177, 178,
2748 179, 180, 181, 182, 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002749};
2750
Reid Spencerb7046c72007-01-29 05:41:34 +00002751static const short int yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002752{
Reid Spencer832254e2007-02-02 02:16:23 +00002753 37, 125, 130, 130, 128, 282, 53, 4, 305, 306,
2754 29, 3, 111, 34, 23, 9, 53, 557, 325, 326,
2755 131, 30, 15, 222, 153, 15, 161, 21, 0, 164,
2756 159, 84, 52, 53, 54, 234, 57, 577, 335, 163,
2757 239, 240, 166, 167, 168, 169, 170, 171, 172, 41,
2758 357, 71, 251, 10, 11, 12, 13, 14, 15, 16,
2759 17, 0, 153, 116, 57, 189, 190, 57, 23, 122,
2760 161, 108, 109, 110, 10, 11, 12, 13, 14, 15,
2761 16, 17, 193, 153, 61, 284, 25, 576, 125, 20,
2762 153, 128, 31, 163, 86, 294, 295, 296, 405, 588,
2763 163, 152, 41, 42, 43, 44, 45, 46, 47, 155,
2764 41, 42, 43, 44, 45, 46, 47, 159, 164, 50,
2765 32, 33, 164, 62, 161, 162, 163, 164, 165, 166,
2766 167, 168, 169, 170, 171, 172, 153, 61, 155, 55,
2767 56, 57, 45, 162, 47, 153, 163, 164, 153, 186,
2768 187, 188, 189, 190, 163, 163, 116, 153, 163, 22,
2769 457, 24, 122, 159, 152, 162, 365, 366, 367, 27,
2770 28, 224, 225, 24, 373, 228, 4, 301, 119, 120,
2771 121, 122, 123, 124, 125, 126, 127, 128, 387, 388,
2772 153, 55, 56, 230, 108, 109, 27, 28, 161, 3,
2773 4, 152, 159, 3, 4, 252, 3, 4, 3, 4,
2774 152, 488, 152, 490, 152, 252, 64, 65, 66, 67,
2775 68, 69, 70, 159, 3, 4, 263, 77, 78, 157,
2776 155, 4, 4, 432, 155, 434, 24, 4, 24, 438,
2777 24, 158, 59, 280, 155, 158, 4, 446, 447, 448,
2778 4, 375, 299, 377, 378, 379, 4, 4, 7, 4,
2779 161, 385, 299, 300, 301, 7, 7, 125, 126, 127,
2780 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
2781 138, 153, 156, 153, 483, 484, 153, 486, 487, 157,
2782 36, 153, 153, 346, 493, 24, 153, 153, 397, 398,
2783 399, 400, 401, 502, 153, 24, 239, 240, 153, 153,
2784 153, 410, 411, 412, 413, 414, 153, 153, 251, 10,
2785 11, 12, 13, 14, 15, 16, 17, 161, 155, 155,
2786 155, 155, 155, 155, 155, 155, 535, 155, 375, 376,
2787 377, 378, 379, 380, 381, 155, 153, 156, 385, 386,
2788 342, 284, 405, 63, 153, 153, 157, 153, 34, 458,
2789 459, 294, 295, 296, 153, 155, 465, 24, 153, 21,
2790 153, 495, 496, 497, 155, 574, 153, 21, 153, 155,
2791 4, 155, 153, 153, 421, 153, 24, 153, 153, 4,
2792 589, 153, 153, 153, 153, 36, 57, 596, 435, 4,
2793 153, 600, 601, 153, 161, 156, 161, 24, 57, 533,
2794 509, 510, 511, 512, 153, 153, 453, 516, 517, 518,
2795 519, 153, 153, 153, 157, 153, 153, 153, 153, 557,
2796 557, 153, 365, 366, 367, 156, 159, 153, 156, 156,
2797 373, 153, 541, 542, 21, 156, 36, 156, 485, 577,
2798 577, 156, 156, 156, 387, 388, 156, 159, 495, 496,
2799 497, 156, 21, 156, 501, 153, 565, 156, 567, 568,
2800 156, 21, 153, 21, 21, 96, 96, 96, 317, 41,
2801 318, 25, 96, 520, 96, 422, 222, 52, 61, 421,
2802 3, 19, 595, 460, 501, -1, 533, -1, 20, 432,
2803 22, 434, 24, -1, -1, 438, 435, -1, -1, 31,
2804 32, 33, -1, 446, 447, 448, -1, -1, -1, 41,
2805 42, 43, 44, 45, 46, 47, -1, -1, 50, 51,
2806 -1, -1, -1, -1, -1, -1, 58, -1, 5, 6,
2807 62, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2808 483, 484, -1, 486, 487, 22, -1, 24, -1, 26,
2809 493, -1, -1, -1, -1, -1, -1, -1, -1, 502,
2810 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
2811 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2812 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2813 -1, -1, 535, -1, -1, -1, -1, -1, -1, -1,
2814 -1, -1, 79, 80, 81, 82, 83, 84, 85, 86,
2815 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
2816 97, 98, 99, 100, 101, 102, 103, 104, -1, -1,
2817 -1, 574, -1, 110, -1, 112, -1, 114, 115, 116,
2818 -1, -1, -1, -1, -1, -1, 589, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002819 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002820 -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
2821 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
2822 157, -1, -1, 160, -1, 162, 5, 6, 165, 8,
Reid Spencer950bf602007-01-26 08:19:09 +00002823 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Reid Spencer832254e2007-02-02 02:16:23 +00002824 19, -1, 21, 22, -1, 24, 5, 6, -1, 8,
2825 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2826 19, -1, 21, 22, -1, 24, -1, 5, 6, 48,
2827 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2828 18, 19, -1, 21, 22, -1, 24, 5, 6, 48,
2829 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2830 18, 19, -1, 21, 22, -1, 24, -1, -1, -1,
2831 48, -1, 5, 6, -1, 8, 9, 10, 11, 12,
2832 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2833 48, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2834 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
2835 -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002836 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002837 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2838 -1, 160, -1, 162, 163, -1, -1, -1, -1, -1,
2839 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2840 -1, 160, -1, 162, 163, -1, -1, -1, -1, -1,
2841 -1, -1, -1, -1, -1, -1, 154, -1, -1, 157,
2842 -1, -1, 160, -1, 162, 163, -1, 3, 4, 5,
2843 6, 7, -1, -1, -1, -1, 154, -1, -1, 157,
2844 -1, -1, 160, -1, 162, 163, 22, -1, 24, -1,
2845 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
2846 -1, 154, 38, 39, 157, -1, -1, 160, -1, 162,
Reid Spencer950bf602007-01-26 08:19:09 +00002847 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002848 -1, -1, -1, -1, -1, 61, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002849 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002850 -1, -1, -1, 79, 80, 81, 82, 83, 84, 85,
2851 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
2852 96, 97, 98, 99, 100, 101, 102, 103, 104, -1,
2853 -1, -1, -1, -1, 110, -1, 112, -1, 114, 115,
2854 116, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2855 -1, -1, -1, 3, 4, -1, -1, 7, -1, -1,
2856 -1, -1, -1, 139, 140, 141, 142, 143, 144, 145,
2857 146, 147, 148, 149, 150, 151, 26, 27, 28, -1,
2858 -1, -1, -1, -1, 160, -1, -1, -1, 38, 39,
Reid Spencer950bf602007-01-26 08:19:09 +00002859 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002860 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002861 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
2862 -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
2863 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2864 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
2865 100, 101, 102, 103, 104, -1, -1, -1, -1, -1,
2866 110, -1, 112, -1, 114, 115, 116, -1, -1, -1,
2867 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2868 -1, -1, -1, -1, -1, -1, -1, -1, -1, 139,
2869 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2870 150, 151, -1, -1, -1, -1, -1, -1, 5, 6,
2871 160, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2872 17, 18, 19, -1, 21, 22, -1, 24, -1, -1,
2873 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2874 37, -1, -1, -1, -1, -1, -1, -1, -1, 5,
2875 6, 48, 8, 9, 10, 11, 12, 13, 14, 15,
2876 16, 17, 18, 19, -1, 21, 22, -1, 24, 5,
2877 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
2878 16, 17, 18, 19, -1, 21, 22, -1, 24, -1,
2879 -1, -1, 48, -1, -1, -1, -1, -1, -1, -1,
2880 -1, 37, -1, -1, -1, -1, -1, -1, -1, -1,
2881 5, 6, 48, 8, 9, 10, 11, 12, 13, 14,
2882 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2883 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2884 -1, -1, 37, -1, -1, -1, -1, -1, -1, -1,
2885 -1, -1, -1, 48, -1, -1, -1, 154, -1, -1,
2886 157, -1, -1, 160, -1, 162, 5, 6, -1, 8,
Reid Spencer950bf602007-01-26 08:19:09 +00002887 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2888 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002889 -1, -1, -1, -1, -1, -1, -1, -1, 154, -1,
2890 -1, 157, -1, 159, 160, -1, 162, -1, -1, 48,
2891 -1, -1, -1, -1, -1, -1, -1, -1, 154, -1,
2892 -1, 157, -1, -1, 160, -1, 162, 5, 6, -1,
2893 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2894 18, 19, -1, 21, 22, -1, 24, -1, -1, -1,
2895 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2896 -1, -1, 157, -1, -1, 160, -1, 162, 5, 6,
2897 48, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2898 17, 18, 19, -1, 21, 22, -1, 24, 5, 6,
2899 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2900 17, 18, 19, -1, 21, 22, -1, 24, -1, -1,
2901 -1, 48, -1, -1, -1, 154, -1, -1, 157, -1,
2902 -1, 160, -1, 162, -1, -1, -1, -1, -1, 5,
2903 6, 48, 8, 9, 10, 11, 12, 13, 14, 15,
2904 16, 17, 18, 19, -1, 21, 22, -1, 24, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002905 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2906 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002907 -1, -1, 48, -1, -1, -1, 154, -1, -1, 157,
2908 -1, -1, 160, -1, 162, -1, -1, -1, -1, -1,
Reid Spencer950bf602007-01-26 08:19:09 +00002909 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2910 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer832254e2007-02-02 02:16:23 +00002911 -1, -1, -1, -1, -1, -1, -1, 154, -1, -1,
2912 157, -1, -1, 160, -1, 162, -1, -1, -1, -1,
2913 -1, -1, -1, -1, -1, -1, -1, 154, -1, -1,
2914 157, -1, -1, 160, -1, 162, -1, -1, -1, -1,
2915 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2916 -1, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2917 -1, -1, -1, -1, 59, 60, -1, -1, 154, -1,
2918 -1, 157, -1, -1, 160, -1, 162, 72, 73, 74,
2919 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2920 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2921 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2922 105, 106, 107, -1, -1, 110, 111, 112, 113, 114,
2923 115, 116, 117, 118, -1, -1, -1, -1, -1, -1,
2924 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2925 -1, -1, -1, -1, 139, 140, 141, 142, 143, 144,
2926 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002927};
2928
2929/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2930 symbol of state STATE-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002931static const unsigned char yystos[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002932{
Reid Spencer950bf602007-01-26 08:19:09 +00002933 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2934 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2935 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2936 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2937 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2938 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2939 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2940 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2941 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2942 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2943 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2944 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2945 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2946 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2947 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2948 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
Reid Spencer832254e2007-02-02 02:16:23 +00002949 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
Reid Spencer950bf602007-01-26 08:19:09 +00002950 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2951 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2952 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2953 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2954 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2955 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2956 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2957 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2958 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2959 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2960 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2961 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2962 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
Reid Spencer832254e2007-02-02 02:16:23 +00002963 108, 109, 153, 159, 205, 206, 204, 27, 28, 3,
2964 4, 168, 4, 7, 26, 38, 39, 103, 104, 110,
2965 112, 114, 115, 116, 157, 160, 162, 165, 169, 170,
Reid Spencer950bf602007-01-26 08:19:09 +00002966 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2967 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2968 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2969 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2970 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2971 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2972 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2973 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2974 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2975 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2976 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2977 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2978 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2979 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2980 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2981 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2982 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2983 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2984 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2985 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2986 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2987 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2988 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2989 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2990 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2991 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2992 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2993 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00002994};
Reid Spencere7c3c602006-11-30 06:36:44 +00002995
2996#define yyerrok (yyerrstatus = 0)
2997#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00002998#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00002999#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00003000
Reid Spencere7c3c602006-11-30 06:36:44 +00003001#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00003002#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00003003#define YYERROR goto yyerrorlab
3004
Reid Spencer319a7302007-01-05 17:20:02 +00003005
3006/* Like YYERROR except do call yyerror. This remains here temporarily
3007 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003008 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00003009
Reid Spencere7c3c602006-11-30 06:36:44 +00003010#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00003011
Reid Spencere7c3c602006-11-30 06:36:44 +00003012#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00003013
3014#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003015do \
3016 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00003017 { \
3018 yychar = (Token); \
3019 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00003020 yytoken = YYTRANSLATE (yychar); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003021 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003022 goto yybackup; \
3023 } \
3024 else \
Reid Spencer950bf602007-01-26 08:19:09 +00003025 { \
3026 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00003027 YYERROR; \
3028 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003029while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003030
Reid Spencer950bf602007-01-26 08:19:09 +00003031
Reid Spencere7c3c602006-11-30 06:36:44 +00003032#define YYTERROR 1
3033#define YYERRCODE 256
3034
Reid Spencer319a7302007-01-05 17:20:02 +00003035
Reid Spencer950bf602007-01-26 08:19:09 +00003036/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3037 If N is 0, then set CURRENT to the empty location which ends
3038 the previous symbol: RHS[0] (always defined). */
3039
3040#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00003041#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00003042# define YYLLOC_DEFAULT(Current, Rhs, N) \
3043 do \
Reid Spencerb7046c72007-01-29 05:41:34 +00003044 if (N) \
Reid Spencer950bf602007-01-26 08:19:09 +00003045 { \
3046 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3047 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3048 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3049 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3050 } \
3051 else \
3052 { \
3053 (Current).first_line = (Current).last_line = \
3054 YYRHSLOC (Rhs, 0).last_line; \
3055 (Current).first_column = (Current).last_column = \
3056 YYRHSLOC (Rhs, 0).last_column; \
3057 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003058 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003059#endif
3060
Reid Spencer950bf602007-01-26 08:19:09 +00003061
3062/* YY_LOCATION_PRINT -- Print the location on the stream.
3063 This macro was not mandated originally: define only if we know
3064 we won't break user code: when these are the locations we know. */
3065
3066#ifndef YY_LOCATION_PRINT
3067# if YYLTYPE_IS_TRIVIAL
3068# define YY_LOCATION_PRINT(File, Loc) \
3069 fprintf (File, "%d.%d-%d.%d", \
Reid Spencerb7046c72007-01-29 05:41:34 +00003070 (Loc).first_line, (Loc).first_column, \
3071 (Loc).last_line, (Loc).last_column)
Reid Spencer950bf602007-01-26 08:19:09 +00003072# else
3073# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3074# endif
3075#endif
3076
3077
Reid Spencer319a7302007-01-05 17:20:02 +00003078/* YYLEX -- calling `yylex' with the right arguments. */
3079
Reid Spencer950bf602007-01-26 08:19:09 +00003080#ifdef YYLEX_PARAM
3081# define YYLEX yylex (YYLEX_PARAM)
3082#else
3083# define YYLEX yylex ()
3084#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003085
3086/* Enable debugging if requested. */
3087#if YYDEBUG
3088
3089# ifndef YYFPRINTF
3090# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3091# define YYFPRINTF fprintf
3092# endif
3093
3094# define YYDPRINTF(Args) \
3095do { \
3096 if (yydebug) \
3097 YYFPRINTF Args; \
Reid Spencerb7046c72007-01-29 05:41:34 +00003098} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003099
Reid Spencerb7046c72007-01-29 05:41:34 +00003100# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3101do { \
3102 if (yydebug) \
3103 { \
3104 YYFPRINTF (stderr, "%s ", Title); \
3105 yysymprint (stderr, \
3106 Type, Value); \
3107 YYFPRINTF (stderr, "\n"); \
3108 } \
3109} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003110
3111/*------------------------------------------------------------------.
3112| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3113| TOP (included). |
3114`------------------------------------------------------------------*/
3115
Reid Spencerb7046c72007-01-29 05:41:34 +00003116#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003117static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003118yy_stack_print (short int *bottom, short int *top)
Reid Spencer950bf602007-01-26 08:19:09 +00003119#else
3120static void
3121yy_stack_print (bottom, top)
Reid Spencerb7046c72007-01-29 05:41:34 +00003122 short int *bottom;
3123 short int *top;
Reid Spencer950bf602007-01-26 08:19:09 +00003124#endif
3125{
3126 YYFPRINTF (stderr, "Stack now");
Reid Spencerb7046c72007-01-29 05:41:34 +00003127 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer950bf602007-01-26 08:19:09 +00003128 YYFPRINTF (stderr, " %d", *bottom);
3129 YYFPRINTF (stderr, "\n");
3130}
3131
3132# define YY_STACK_PRINT(Bottom, Top) \
3133do { \
3134 if (yydebug) \
3135 yy_stack_print ((Bottom), (Top)); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003136} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003137
3138
3139/*------------------------------------------------.
3140| Report that the YYRULE is going to be reduced. |
3141`------------------------------------------------*/
3142
Reid Spencerb7046c72007-01-29 05:41:34 +00003143#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003144static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003145yy_reduce_print (int yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003146#else
3147static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003148yy_reduce_print (yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003149 int yyrule;
3150#endif
3151{
3152 int yyi;
3153 unsigned long int yylno = yyrline[yyrule];
Reid Spencerb7046c72007-01-29 05:41:34 +00003154 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3155 yyrule - 1, yylno);
3156 /* Print the symbols being reduced, and their result. */
3157 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3158 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3159 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer950bf602007-01-26 08:19:09 +00003160}
3161
3162# define YY_REDUCE_PRINT(Rule) \
3163do { \
3164 if (yydebug) \
Reid Spencerb7046c72007-01-29 05:41:34 +00003165 yy_reduce_print (Rule); \
3166} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003167
Reid Spencer319a7302007-01-05 17:20:02 +00003168/* Nonzero means print parse trace. It is left uninitialized so that
3169 multiple parsers can coexist. */
3170int yydebug;
3171#else /* !YYDEBUG */
3172# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003173# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3174# define YY_STACK_PRINT(Bottom, Top)
3175# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003176#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003177
Reid Spencer950bf602007-01-26 08:19:09 +00003178
Reid Spencer319a7302007-01-05 17:20:02 +00003179/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003180#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003181# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003182#endif
3183
Reid Spencer319a7302007-01-05 17:20:02 +00003184/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3185 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003186
Reid Spencer319a7302007-01-05 17:20:02 +00003187 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003188 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003189 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003190
3191#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003192# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003193#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003194
Reid Spencere7c3c602006-11-30 06:36:44 +00003195
3196
Reid Spencer319a7302007-01-05 17:20:02 +00003197#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003198
Reid Spencer319a7302007-01-05 17:20:02 +00003199# ifndef yystrlen
Reid Spencerb7046c72007-01-29 05:41:34 +00003200# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer319a7302007-01-05 17:20:02 +00003201# define yystrlen strlen
3202# else
3203/* Return the length of YYSTR. */
3204static YYSIZE_T
Reid Spencerb7046c72007-01-29 05:41:34 +00003205# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003206yystrlen (const char *yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003207# else
Reid Spencer319a7302007-01-05 17:20:02 +00003208yystrlen (yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003209 const char *yystr;
3210# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003211{
Reid Spencerb7046c72007-01-29 05:41:34 +00003212 const char *yys = yystr;
3213
3214 while (*yys++ != '\0')
Reid Spencer319a7302007-01-05 17:20:02 +00003215 continue;
Reid Spencerb7046c72007-01-29 05:41:34 +00003216
3217 return yys - yystr - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003218}
Reid Spencer319a7302007-01-05 17:20:02 +00003219# endif
3220# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003221
Reid Spencer319a7302007-01-05 17:20:02 +00003222# ifndef yystpcpy
Reid Spencerb7046c72007-01-29 05:41:34 +00003223# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer319a7302007-01-05 17:20:02 +00003224# define yystpcpy stpcpy
3225# else
3226/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3227 YYDEST. */
3228static char *
Reid Spencerb7046c72007-01-29 05:41:34 +00003229# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003230yystpcpy (char *yydest, const char *yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003231# else
Reid Spencer319a7302007-01-05 17:20:02 +00003232yystpcpy (yydest, yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003233 char *yydest;
3234 const char *yysrc;
3235# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003236{
Reid Spencer950bf602007-01-26 08:19:09 +00003237 char *yyd = yydest;
3238 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003239
Reid Spencer319a7302007-01-05 17:20:02 +00003240 while ((*yyd++ = *yys++) != '\0')
3241 continue;
3242
3243 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003244}
Reid Spencer319a7302007-01-05 17:20:02 +00003245# endif
3246# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003247
Reid Spencer950bf602007-01-26 08:19:09 +00003248# ifndef yytnamerr
3249/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3250 quotes and backslashes, so that it's suitable for yyerror. The
3251 heuristic is that double-quoting is unnecessary unless the string
3252 contains an apostrophe, a comma, or backslash (other than
3253 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3254 null, do not copy; instead, return the length of what the result
3255 would have been. */
3256static YYSIZE_T
3257yytnamerr (char *yyres, const char *yystr)
3258{
3259 if (*yystr == '"')
3260 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003261 size_t yyn = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00003262 char const *yyp = yystr;
3263
3264 for (;;)
3265 switch (*++yyp)
3266 {
3267 case '\'':
3268 case ',':
3269 goto do_not_strip_quotes;
3270
3271 case '\\':
3272 if (*++yyp != '\\')
3273 goto do_not_strip_quotes;
3274 /* Fall through. */
3275 default:
3276 if (yyres)
3277 yyres[yyn] = *yyp;
3278 yyn++;
3279 break;
3280
3281 case '"':
3282 if (yyres)
3283 yyres[yyn] = '\0';
3284 return yyn;
3285 }
3286 do_not_strip_quotes: ;
3287 }
3288
3289 if (! yyres)
3290 return yystrlen (yystr);
3291
3292 return yystpcpy (yyres, yystr) - yyres;
3293}
3294# endif
3295
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003296#endif /* YYERROR_VERBOSE */
Reid Spencerb7046c72007-01-29 05:41:34 +00003297
Reid Spencere7c3c602006-11-30 06:36:44 +00003298
3299
Reid Spencerb7046c72007-01-29 05:41:34 +00003300#if YYDEBUG
3301/*--------------------------------.
3302| Print this symbol on YYOUTPUT. |
3303`--------------------------------*/
3304
3305#if defined (__STDC__) || defined (__cplusplus)
3306static void
3307yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
3308#else
3309static void
3310yysymprint (yyoutput, yytype, yyvaluep)
3311 FILE *yyoutput;
3312 int yytype;
3313 YYSTYPE *yyvaluep;
3314#endif
3315{
3316 /* Pacify ``unused variable'' warnings. */
3317 (void) yyvaluep;
3318
3319 if (yytype < YYNTOKENS)
3320 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3321 else
3322 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3323
3324
3325# ifdef YYPRINT
3326 if (yytype < YYNTOKENS)
3327 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3328# endif
3329 switch (yytype)
3330 {
3331 default:
3332 break;
3333 }
3334 YYFPRINTF (yyoutput, ")");
3335}
3336
3337#endif /* ! YYDEBUG */
Reid Spencer319a7302007-01-05 17:20:02 +00003338/*-----------------------------------------------.
3339| Release the memory associated to this symbol. |
3340`-----------------------------------------------*/
3341
Reid Spencerb7046c72007-01-29 05:41:34 +00003342#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003343static void
3344yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003345#else
Reid Spencer950bf602007-01-26 08:19:09 +00003346static void
3347yydestruct (yymsg, yytype, yyvaluep)
3348 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003349 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003350 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003351#endif
3352{
Reid Spencerb7046c72007-01-29 05:41:34 +00003353 /* Pacify ``unused variable'' warnings. */
3354 (void) yyvaluep;
Reid Spencer950bf602007-01-26 08:19:09 +00003355
3356 if (!yymsg)
3357 yymsg = "Deleting";
3358 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003359
3360 switch (yytype)
3361 {
Reid Spencer950bf602007-01-26 08:19:09 +00003362
Reid Spencer319a7302007-01-05 17:20:02 +00003363 default:
Reid Spencerb7046c72007-01-29 05:41:34 +00003364 break;
Reid Spencer319a7302007-01-05 17:20:02 +00003365 }
3366}
3367
3368
Reid Spencer950bf602007-01-26 08:19:09 +00003369/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003370
3371#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003372# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003373int yyparse (void *YYPARSE_PARAM);
Reid Spencerb7046c72007-01-29 05:41:34 +00003374# else
Reid Spencer950bf602007-01-26 08:19:09 +00003375int yyparse ();
Reid Spencerb7046c72007-01-29 05:41:34 +00003376# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003377#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003378#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003379int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003380#else
3381int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003382#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003383#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003384
3385
Reid Spencer950bf602007-01-26 08:19:09 +00003386
3387/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003388int yychar;
3389
Reid Spencer950bf602007-01-26 08:19:09 +00003390/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003391YYSTYPE yylval;
3392
Reid Spencer950bf602007-01-26 08:19:09 +00003393/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003394int yynerrs;
3395
3396
Reid Spencer950bf602007-01-26 08:19:09 +00003397
3398/*----------.
3399| yyparse. |
3400`----------*/
3401
3402#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003403# if defined (__STDC__) || defined (__cplusplus)
3404int yyparse (void *YYPARSE_PARAM)
3405# else
3406int yyparse (YYPARSE_PARAM)
3407 void *YYPARSE_PARAM;
3408# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003409#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003410#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003411int
Reid Spencer950bf602007-01-26 08:19:09 +00003412yyparse (void)
3413#else
3414int
3415yyparse ()
3416
3417#endif
3418#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003419{
3420
Reid Spencer950bf602007-01-26 08:19:09 +00003421 int yystate;
3422 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003423 int yyresult;
3424 /* Number of tokens to shift before error messages enabled. */
3425 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003426 /* Look-ahead token as an internal (translated) token number. */
3427 int yytoken = 0;
Reid Spencer319a7302007-01-05 17:20:02 +00003428
3429 /* Three stacks and their tools:
3430 `yyss': related to states,
3431 `yyvs': related to semantic values,
3432 `yyls': related to locations.
3433
3434 Refer to the stacks thru separate pointers, to allow yyoverflow
3435 to reallocate them elsewhere. */
3436
3437 /* The state stack. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003438 short int yyssa[YYINITDEPTH];
3439 short int *yyss = yyssa;
3440 short int *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003441
3442 /* The semantic value stack. */
3443 YYSTYPE yyvsa[YYINITDEPTH];
3444 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003445 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003446
3447
3448
Reid Spencerb7046c72007-01-29 05:41:34 +00003449#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003450
Reid Spencer319a7302007-01-05 17:20:02 +00003451 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003452
Reid Spencer319a7302007-01-05 17:20:02 +00003453 /* The variables used to return semantic value and location from the
3454 action routines. */
3455 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003456
3457
Reid Spencerb7046c72007-01-29 05:41:34 +00003458 /* When reducing, the number of symbols on the RHS of the reduced
3459 rule. */
3460 int yylen;
Reid Spencere7c3c602006-11-30 06:36:44 +00003461
Reid Spencer319a7302007-01-05 17:20:02 +00003462 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003463
3464 yystate = 0;
3465 yyerrstatus = 0;
3466 yynerrs = 0;
3467 yychar = YYEMPTY; /* Cause a token to be read. */
3468
3469 /* Initialize stack pointers.
3470 Waste one element of value and location stack
3471 so that they stay on the same level as the state stack.
3472 The wasted elements are never initialized. */
3473
Reid Spencer319a7302007-01-05 17:20:02 +00003474 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003475 yyvsp = yyvs;
3476
Reid Spencer319a7302007-01-05 17:20:02 +00003477 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003478
Reid Spencer319a7302007-01-05 17:20:02 +00003479/*------------------------------------------------------------.
3480| yynewstate -- Push a new state, which is found in yystate. |
3481`------------------------------------------------------------*/
3482 yynewstate:
3483 /* In all cases, when you get here, the value and location stacks
Reid Spencerb7046c72007-01-29 05:41:34 +00003484 have just been pushed. so pushing a state here evens the stacks.
3485 */
Reid Spencer319a7302007-01-05 17:20:02 +00003486 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003487
Reid Spencer319a7302007-01-05 17:20:02 +00003488 yysetstate:
3489 *yyssp = yystate;
3490
Reid Spencer950bf602007-01-26 08:19:09 +00003491 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003492 {
3493 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003494 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003495
3496#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003497 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003498 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer319a7302007-01-05 17:20:02 +00003499 these so that the &'s don't force the real ones into
3500 memory. */
3501 YYSTYPE *yyvs1 = yyvs;
Reid Spencerb7046c72007-01-29 05:41:34 +00003502 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003503
Reid Spencer319a7302007-01-05 17:20:02 +00003504
3505 /* Each stack pointer address is followed by the size of the
3506 data in use in that stack, in bytes. This used to be a
3507 conditional around just the two extra args, but that might
3508 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003509 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003510 &yyss1, yysize * sizeof (*yyssp),
3511 &yyvs1, yysize * sizeof (*yyvsp),
3512
3513 &yystacksize);
3514
3515 yyss = yyss1;
3516 yyvs = yyvs1;
3517 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003518#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003519# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003520 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003521# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003522 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003523 if (YYMAXDEPTH <= yystacksize)
3524 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003525 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003526 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003527 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003528
3529 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003530 short int *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003531 union yyalloc *yyptr =
3532 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3533 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003534 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003535 YYSTACK_RELOCATE (yyss);
3536 YYSTACK_RELOCATE (yyvs);
3537
3538# undef YYSTACK_RELOCATE
3539 if (yyss1 != yyssa)
3540 YYSTACK_FREE (yyss1);
3541 }
3542# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003543#endif /* no yyoverflow */
3544
Reid Spencer319a7302007-01-05 17:20:02 +00003545 yyssp = yyss + yysize - 1;
3546 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003547
3548
Reid Spencer319a7302007-01-05 17:20:02 +00003549 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3550 (unsigned long int) yystacksize));
3551
Reid Spencer950bf602007-01-26 08:19:09 +00003552 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003553 YYABORT;
3554 }
3555
Reid Spencer319a7302007-01-05 17:20:02 +00003556 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003557
3558 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003559
3560/*-----------.
3561| yybackup. |
3562`-----------*/
3563yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003564
Reid Spencerb7046c72007-01-29 05:41:34 +00003565/* Do appropriate processing given the current state. */
3566/* Read a look-ahead token if we need one and don't already have one. */
3567/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003568
Reid Spencer950bf602007-01-26 08:19:09 +00003569 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003570
Reid Spencere7c3c602006-11-30 06:36:44 +00003571 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003572 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003573 goto yydefault;
3574
Reid Spencer950bf602007-01-26 08:19:09 +00003575 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003576
Reid Spencer950bf602007-01-26 08:19:09 +00003577 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003578 if (yychar == YYEMPTY)
3579 {
Reid Spencer319a7302007-01-05 17:20:02 +00003580 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003581 yychar = YYLEX;
3582 }
3583
Reid Spencer950bf602007-01-26 08:19:09 +00003584 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003585 {
Reid Spencer950bf602007-01-26 08:19:09 +00003586 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003587 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003588 }
3589 else
3590 {
Reid Spencer950bf602007-01-26 08:19:09 +00003591 yytoken = YYTRANSLATE (yychar);
3592 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003593 }
3594
Reid Spencer950bf602007-01-26 08:19:09 +00003595 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003596 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003597 yyn += yytoken;
3598 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003599 goto yydefault;
3600 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003601 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003602 {
Reid Spencer319a7302007-01-05 17:20:02 +00003603 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003604 goto yyerrlab;
3605 yyn = -yyn;
3606 goto yyreduce;
3607 }
3608
3609 if (yyn == YYFINAL)
3610 YYACCEPT;
3611
Reid Spencerb7046c72007-01-29 05:41:34 +00003612 /* Shift the look-ahead token. */
3613 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3614
3615 /* Discard the token being shifted unless it is eof. */
3616 if (yychar != YYEOF)
3617 yychar = YYEMPTY;
3618
3619 *++yyvsp = yylval;
3620
3621
Reid Spencer319a7302007-01-05 17:20:02 +00003622 /* Count tokens shifted since error; after three, turn off error
3623 status. */
3624 if (yyerrstatus)
3625 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003626
3627 yystate = yyn;
3628 goto yynewstate;
3629
Chris Lattner37e01c52007-01-04 18:46:42 +00003630
Reid Spencer319a7302007-01-05 17:20:02 +00003631/*-----------------------------------------------------------.
3632| yydefault -- do the default action for the current state. |
3633`-----------------------------------------------------------*/
3634yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003635 yyn = yydefact[yystate];
3636 if (yyn == 0)
3637 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003638 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003639
Reid Spencer319a7302007-01-05 17:20:02 +00003640
3641/*-----------------------------.
3642| yyreduce -- Do a reduction. |
3643`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003644yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003645 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003646 yylen = yyr2[yyn];
3647
Reid Spencer319a7302007-01-05 17:20:02 +00003648 /* If YYLEN is nonzero, implement the default value of the action:
3649 `$$ = $1'.
3650
3651 Otherwise, the following line sets YYVAL to garbage.
3652 This behavior is undocumented and Bison
3653 users should not rely upon it. Assigning to YYVAL
3654 unconditionally makes the parser a bit smaller, and it avoids a
3655 GCC warning that YYVAL may be used uninitialized. */
3656 yyval = yyvsp[1-yylen];
3657
3658
Reid Spencer950bf602007-01-26 08:19:09 +00003659 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003660 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003661 {
Reid Spencer950bf602007-01-26 08:19:09 +00003662 case 3:
Reid Spencer832254e2007-02-02 02:16:23 +00003663#line 1576 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003664 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003665 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003666 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003667 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003668 ;}
3669 break;
3670
3671 case 5:
Reid Spencer832254e2007-02-02 02:16:23 +00003672#line 1585 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003673 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003674 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003675 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003676 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003677 ;}
3678 break;
3679
3680 case 26:
Reid Spencer832254e2007-02-02 02:16:23 +00003681#line 1607 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003682 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3683 break;
3684
3685 case 27:
Reid Spencer832254e2007-02-02 02:16:23 +00003686#line 1607 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003687 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3688 break;
3689
3690 case 28:
Reid Spencer832254e2007-02-02 02:16:23 +00003691#line 1608 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003692 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3693 break;
3694
3695 case 29:
Reid Spencer832254e2007-02-02 02:16:23 +00003696#line 1608 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003697 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3698 break;
3699
3700 case 30:
Reid Spencer832254e2007-02-02 02:16:23 +00003701#line 1609 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003702 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3703 break;
3704
3705 case 31:
Reid Spencer832254e2007-02-02 02:16:23 +00003706#line 1609 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003707 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3708 break;
3709
3710 case 32:
Reid Spencer832254e2007-02-02 02:16:23 +00003711#line 1610 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003712 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3713 break;
3714
3715 case 33:
Reid Spencer832254e2007-02-02 02:16:23 +00003716#line 1610 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003717 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3718 break;
3719
3720 case 34:
Reid Spencer832254e2007-02-02 02:16:23 +00003721#line 1611 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003722 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3723 break;
3724
3725 case 35:
Reid Spencer832254e2007-02-02 02:16:23 +00003726#line 1611 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003727 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3728 break;
3729
3730 case 36:
Reid Spencer832254e2007-02-02 02:16:23 +00003731#line 1615 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003732 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3733 break;
3734
3735 case 37:
Reid Spencer832254e2007-02-02 02:16:23 +00003736#line 1615 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003737 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3738 break;
3739
3740 case 38:
Reid Spencer832254e2007-02-02 02:16:23 +00003741#line 1616 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003742 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3743 break;
3744
3745 case 39:
Reid Spencer832254e2007-02-02 02:16:23 +00003746#line 1616 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003747 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3748 break;
3749
3750 case 40:
Reid Spencer832254e2007-02-02 02:16:23 +00003751#line 1617 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003752 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3753 break;
3754
3755 case 41:
Reid Spencer832254e2007-02-02 02:16:23 +00003756#line 1617 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003757 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3758 break;
3759
3760 case 42:
Reid Spencer832254e2007-02-02 02:16:23 +00003761#line 1618 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003762 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3763 break;
3764
3765 case 43:
Reid Spencer832254e2007-02-02 02:16:23 +00003766#line 1618 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003767 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3768 break;
3769
3770 case 44:
Reid Spencer832254e2007-02-02 02:16:23 +00003771#line 1619 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003772 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3773 break;
3774
3775 case 45:
Reid Spencer832254e2007-02-02 02:16:23 +00003776#line 1619 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003777 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3778 break;
3779
3780 case 46:
Reid Spencer832254e2007-02-02 02:16:23 +00003781#line 1620 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003782 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3783 break;
3784
3785 case 47:
Reid Spencer832254e2007-02-02 02:16:23 +00003786#line 1620 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003787 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3788 break;
3789
3790 case 48:
Reid Spencer832254e2007-02-02 02:16:23 +00003791#line 1621 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003792 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3793 break;
3794
3795 case 49:
Reid Spencer832254e2007-02-02 02:16:23 +00003796#line 1621 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003797 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3798 break;
3799
3800 case 50:
Reid Spencer832254e2007-02-02 02:16:23 +00003801#line 1622 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003802 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3803 break;
3804
3805 case 51:
Reid Spencer832254e2007-02-02 02:16:23 +00003806#line 1623 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003807 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3808 break;
3809
3810 case 81:
Reid Spencer832254e2007-02-02 02:16:23 +00003811#line 1654 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003812 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003813 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003814 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003815 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003816
Reid Spencer319a7302007-01-05 17:20:02 +00003817 case 82:
Reid Spencer832254e2007-02-02 02:16:23 +00003818#line 1657 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003819 {
Reid Spencer950bf602007-01-26 08:19:09 +00003820 (yyval.StrVal) = 0;
3821 ;}
3822 break;
3823
3824 case 83:
Reid Spencer832254e2007-02-02 02:16:23 +00003825#line 1662 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003826 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3827 break;
3828
3829 case 84:
Reid Spencer832254e2007-02-02 02:16:23 +00003830#line 1663 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003831 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3832 break;
3833
3834 case 85:
Reid Spencer832254e2007-02-02 02:16:23 +00003835#line 1664 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003836 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3837 break;
3838
3839 case 86:
Reid Spencer832254e2007-02-02 02:16:23 +00003840#line 1665 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003841 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3842 break;
3843
3844 case 87:
Reid Spencer832254e2007-02-02 02:16:23 +00003845#line 1666 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003846 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3847 break;
3848
3849 case 88:
Reid Spencer832254e2007-02-02 02:16:23 +00003850#line 1667 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003851 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3852 break;
3853
3854 case 89:
Reid Spencer832254e2007-02-02 02:16:23 +00003855#line 1668 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003856 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003857 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003858
Reid Spencer319a7302007-01-05 17:20:02 +00003859 case 90:
Reid Spencer832254e2007-02-02 02:16:23 +00003860#line 1669 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003861 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3862 break;
3863
3864 case 91:
Reid Spencer832254e2007-02-02 02:16:23 +00003865#line 1673 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003866 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003867 break;
3868
3869 case 92:
Reid Spencer832254e2007-02-02 02:16:23 +00003870#line 1674 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003871 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003872 break;
3873
3874 case 93:
Reid Spencer832254e2007-02-02 02:16:23 +00003875#line 1675 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003876 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::CSRet; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003877 break;
3878
3879 case 94:
Reid Spencer832254e2007-02-02 02:16:23 +00003880#line 1676 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003881 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::Fast; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003882 break;
3883
3884 case 95:
Reid Spencer832254e2007-02-02 02:16:23 +00003885#line 1677 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003886 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::Cold; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003887 break;
3888
3889 case 96:
Reid Spencer832254e2007-02-02 02:16:23 +00003890#line 1678 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003891 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003892 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00003893
Reid Spencer319a7302007-01-05 17:20:02 +00003894 case 97:
Reid Spencer832254e2007-02-02 02:16:23 +00003895#line 1679 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003896 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003897 break;
Reid Spencer16244f42006-12-01 21:10:07 +00003898
Reid Spencer319a7302007-01-05 17:20:02 +00003899 case 98:
Reid Spencer832254e2007-02-02 02:16:23 +00003900#line 1680 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003901 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003902 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00003903 error("Calling conv too large");
Reid Spencerb7046c72007-01-29 05:41:34 +00003904 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003905 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003906 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003907
Reid Spencer319a7302007-01-05 17:20:02 +00003908 case 99:
Reid Spencer832254e2007-02-02 02:16:23 +00003909#line 1690 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003910 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003911 break;
3912
Reid Spencerc4d96252007-01-13 00:03:30 +00003913 case 100:
Reid Spencer832254e2007-02-02 02:16:23 +00003914#line 1691 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003915 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003916 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003917 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3918 error("Alignment must be a power of two");
3919 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003920 break;
3921
3922 case 101:
Reid Spencer832254e2007-02-02 02:16:23 +00003923#line 1699 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003924 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003925 break;
3926
3927 case 102:
Reid Spencer832254e2007-02-02 02:16:23 +00003928#line 1700 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003929 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003930 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003931 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3932 error("Alignment must be a power of two");
3933 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003934 break;
3935
3936 case 103:
Reid Spencer832254e2007-02-02 02:16:23 +00003937#line 1708 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003938 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003939 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3940 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00003941 error("Invalid character in section name");
Reid Spencerb7046c72007-01-29 05:41:34 +00003942 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003943 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003944 break;
3945
3946 case 104:
Reid Spencer832254e2007-02-02 02:16:23 +00003947#line 1717 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003948 { (yyval.StrVal) = 0; ;}
3949 break;
3950
3951 case 105:
Reid Spencer832254e2007-02-02 02:16:23 +00003952#line 1718 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00003953 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003954 break;
3955
Reid Spencerc4d96252007-01-13 00:03:30 +00003956 case 106:
Reid Spencer832254e2007-02-02 02:16:23 +00003957#line 1725 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003958 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003959 break;
3960
Reid Spencer319a7302007-01-05 17:20:02 +00003961 case 107:
Reid Spencer832254e2007-02-02 02:16:23 +00003962#line 1726 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003963 {;}
3964 break;
3965
3966 case 108:
Reid Spencer832254e2007-02-02 02:16:23 +00003967#line 1730 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003968 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003969 CurGV->setSection((yyvsp[0].StrVal));
3970 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00003971 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003972 break;
3973
3974 case 109:
Reid Spencer832254e2007-02-02 02:16:23 +00003975#line 1734 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003976 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003977 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00003978 error("Alignment must be a power of two");
Reid Spencerb7046c72007-01-29 05:41:34 +00003979 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00003980
3981 ;}
3982 break;
3983
3984 case 111:
Reid Spencer832254e2007-02-02 02:16:23 +00003985#line 1751 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003986 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003987 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00003988 (yyval.TypeVal).S = Signless;
3989 ;}
3990 break;
3991
3992 case 113:
Reid Spencer832254e2007-02-02 02:16:23 +00003993#line 1759 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003994 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003995 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00003996 (yyval.TypeVal).S = Signless;
3997 ;}
3998 break;
3999
4000 case 114:
Reid Spencer832254e2007-02-02 02:16:23 +00004001#line 1766 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004002 {
4003 if (!UpRefs.empty())
Reid Spencerb7046c72007-01-29 05:41:34 +00004004 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).T)->getDescription());
4005 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004006 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004007 break;
4008
4009 case 127:
Reid Spencer832254e2007-02-02 02:16:23 +00004010#line 1780 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004011 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004012 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
4013 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004014 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004015 break;
4016
4017 case 128:
Reid Spencer832254e2007-02-02 02:16:23 +00004018#line 1784 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004019 {
4020 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4021 (yyval.TypeVal).S = Signless;
4022 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004023 break;
4024
4025 case 129:
Reid Spencer832254e2007-02-02 02:16:23 +00004026#line 1788 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004027 { // Named types are also simple types...
Reid Spencerb7046c72007-01-29 05:41:34 +00004028 const Type* tmp = getType((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004029 (yyval.TypeVal).T = new PATypeHolder(tmp);
4030 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4031 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004032 break;
4033
4034 case 130:
Reid Spencer832254e2007-02-02 02:16:23 +00004035#line 1793 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004036 { // Type UpReference
Reid Spencerb7046c72007-01-29 05:41:34 +00004037 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004038 error("Value out of range");
4039 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencerb7046c72007-01-29 05:41:34 +00004040 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Reid Spencer950bf602007-01-26 08:19:09 +00004041 (yyval.TypeVal).T = new PATypeHolder(OT);
4042 (yyval.TypeVal).S = Signless;
4043 UR_OUT("New Upreference!\n");
4044 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004045 break;
4046
4047 case 131:
Reid Spencer832254e2007-02-02 02:16:23 +00004048#line 1802 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004049 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004050 std::vector<const Type*> Params;
Reid Spencerb7046c72007-01-29 05:41:34 +00004051 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4052 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004053 Params.push_back(I->T->get());
4054 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004055 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004056 FunctionType::ParamAttrsList ParamAttrs;
4057 if (CurFun.LastCC == OldCallingConv::CSRet) {
4058 ParamAttrs.push_back(FunctionType::NoAttributeSet);
4059 ParamAttrs.push_back(FunctionType::StructRetAttribute);
4060 }
Reid Spencer950bf602007-01-26 08:19:09 +00004061 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4062 if (isVarArg) Params.pop_back();
4063
Reid Spencerb7046c72007-01-29 05:41:34 +00004064 (yyval.TypeVal).T = new PATypeHolder(
4065 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).T->get(),Params,isVarArg, ParamAttrs)));
4066 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
4067 delete (yyvsp[-3].TypeVal).T; // Delete the return type handle
4068 delete (yyvsp[-1].TypeList); // Delete the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00004069 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004070 break;
4071
4072 case 132:
Reid Spencer832254e2007-02-02 02:16:23 +00004073#line 1823 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004074 { // Sized array type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004075 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).T->get(),
4076 (unsigned)(yyvsp[-3].UInt64Val))));
4077 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4078 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004079 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004080 break;
4081
4082 case 133:
Reid Spencer832254e2007-02-02 02:16:23 +00004083#line 1829 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004084 { // Packed array type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004085 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).T->get();
4086 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004087 error("Unsigned result not equal to signed result");
4088 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4089 error("Elements of a PackedType must be integer or floating point");
Reid Spencerb7046c72007-01-29 05:41:34 +00004090 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004091 error("PackedType length should be a power of 2");
4092 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
Reid Spencerb7046c72007-01-29 05:41:34 +00004093 (unsigned)(yyvsp[-3].UInt64Val))));
4094 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4095 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004096 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004097 break;
4098
4099 case 134:
Reid Spencer832254e2007-02-02 02:16:23 +00004100#line 1842 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004101 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004102 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004103 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4104 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer950bf602007-01-26 08:19:09 +00004105 Elements.push_back(I->T->get());
4106 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4107 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004108 delete (yyvsp[-1].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004109 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004110 break;
4111
4112 case 135:
Reid Spencer832254e2007-02-02 02:16:23 +00004113#line 1851 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004114 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004115 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4116 (yyval.TypeVal).S = Signless;
4117 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004118 break;
4119
4120 case 136:
Reid Spencer832254e2007-02-02 02:16:23 +00004121#line 1855 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004122 { // Packed 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[-2].TypeList)->begin(),
4125 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004126 Elements.push_back(I->T->get());
4127 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004128 }
Reid Spencer950bf602007-01-26 08:19:09 +00004129 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4130 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004131 delete (yyvsp[-2].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004132 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004133 break;
4134
4135 case 137:
Reid Spencer832254e2007-02-02 02:16:23 +00004136#line 1866 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004137 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004138 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4139 (yyval.TypeVal).S = Signless;
4140 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004141 break;
4142
4143 case 138:
Reid Spencer832254e2007-02-02 02:16:23 +00004144#line 1870 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004145 { // Pointer type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004146 if ((yyvsp[-1].TypeVal).T->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004147 error("Cannot form a pointer to a basic block");
Reid Spencerb7046c72007-01-29 05:41:34 +00004148 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).T->get())));
4149 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4150 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004151 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004152 break;
4153
4154 case 139:
Reid Spencer832254e2007-02-02 02:16:23 +00004155#line 1883 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004156 {
Reid Spencer950bf602007-01-26 08:19:09 +00004157 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004158 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004159 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004160 break;
4161
4162 case 140:
Reid Spencer832254e2007-02-02 02:16:23 +00004163#line 1887 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004164 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004165 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004166 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004167 break;
4168
4169 case 142:
Reid Spencer832254e2007-02-02 02:16:23 +00004170#line 1895 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004171 {
Reid Spencer950bf602007-01-26 08:19:09 +00004172 PATypeInfo VoidTI;
4173 VoidTI.T = new PATypeHolder(Type::VoidTy);
4174 VoidTI.S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004175 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
Reid Spencer950bf602007-01-26 08:19:09 +00004176 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004177 break;
4178
4179 case 143:
Reid Spencer832254e2007-02-02 02:16:23 +00004180#line 1901 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004181 {
Reid Spencer950bf602007-01-26 08:19:09 +00004182 (yyval.TypeList) = new std::list<PATypeInfo>();
4183 PATypeInfo VoidTI;
4184 VoidTI.T = new PATypeHolder(Type::VoidTy);
4185 VoidTI.S = Signless;
4186 (yyval.TypeList)->push_back(VoidTI);
4187 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004188 break;
4189
4190 case 144:
Reid Spencer832254e2007-02-02 02:16:23 +00004191#line 1908 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004192 {
Reid Spencer950bf602007-01-26 08:19:09 +00004193 (yyval.TypeList) = new std::list<PATypeInfo>();
4194 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004195 break;
4196
4197 case 145:
Reid Spencer832254e2007-02-02 02:16:23 +00004198#line 1920 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004199 { // Nonempty unsized arr
Reid Spencerb7046c72007-01-29 05:41:34 +00004200 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004201 if (ATy == 0)
4202 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004203 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004204 const Type *ETy = ATy->getElementType();
4205 int NumElements = ATy->getNumElements();
4206
4207 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004208 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004209 error("Type mismatch: constant sized array initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004210 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004211 itostr(NumElements) + "");
4212
4213 // Verify all elements are correct type!
4214 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004215 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4216 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004217 const Type* ValTy = C->getType();
4218 if (ETy != ValTy)
4219 error("Element #" + utostr(i) + " is not of type '" +
4220 ETy->getDescription() +"' as required!\nIt is of type '"+
4221 ValTy->getDescription() + "'");
4222 Elems.push_back(C);
4223 }
4224 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004225 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4226 delete (yyvsp[-3].TypeVal).T;
4227 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004228 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004229 break;
4230
4231 case 146:
Reid Spencer832254e2007-02-02 02:16:23 +00004232#line 1950 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004233 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004234 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004235 if (ATy == 0)
4236 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004237 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004238 int NumElements = ATy->getNumElements();
4239 if (NumElements != -1 && NumElements != 0)
4240 error("Type mismatch: constant sized array initialized with 0"
4241 " arguments, but has size of " + itostr(NumElements) +"");
4242 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004243 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4244 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004245 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004246 break;
4247
4248 case 147:
Reid Spencer832254e2007-02-02 02:16:23 +00004249#line 1963 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004250 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004251 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004252 if (ATy == 0)
4253 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004254 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004255 int NumElements = ATy->getNumElements();
4256 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4257 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4258 error("String arrays require type i8, not '" + ETy->getDescription() +
4259 "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004260 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4261 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004262 error("Can't build string constant of size " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004263 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004264 itostr(NumElements) + "");
4265 std::vector<Constant*> Vals;
Reid Spencerb7046c72007-01-29 05:41:34 +00004266 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004267 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencerb7046c72007-01-29 05:41:34 +00004268 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004269 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerb7046c72007-01-29 05:41:34 +00004270 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4271 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004272 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004273 break;
4274
4275 case 148:
Reid Spencer832254e2007-02-02 02:16:23 +00004276#line 1986 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004277 { // Nonempty unsized arr
Reid Spencerb7046c72007-01-29 05:41:34 +00004278 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004279 if (PTy == 0)
4280 error("Cannot make packed constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004281 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004282 const Type *ETy = PTy->getElementType();
4283 int NumElements = PTy->getNumElements();
4284 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004285 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004286 error("Type mismatch: constant sized packed initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004287 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004288 itostr(NumElements) + "");
4289 // Verify all elements are correct type!
4290 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004291 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4292 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004293 const Type* ValTy = C->getType();
4294 if (ETy != ValTy)
4295 error("Element #" + utostr(i) + " is not of type '" +
4296 ETy->getDescription() +"' as required!\nIt is of type '"+
4297 ValTy->getDescription() + "'");
4298 Elems.push_back(C);
4299 }
4300 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004301 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4302 delete (yyvsp[-3].TypeVal).T;
4303 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004304 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004305 break;
4306
4307 case 149:
Reid Spencer832254e2007-02-02 02:16:23 +00004308#line 2014 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004309 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004310 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004311 if (STy == 0)
4312 error("Cannot make struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004313 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4314 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004315 error("Illegal number of initializers for structure type");
4316
4317 // Check to ensure that constants are compatible with the type initializer!
4318 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004319 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4320 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004321 if (C->getType() != STy->getElementType(i))
4322 error("Expected type '" + STy->getElementType(i)->getDescription() +
4323 "' for element #" + utostr(i) + " of structure initializer");
4324 Fields.push_back(C);
4325 }
4326 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004327 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4328 delete (yyvsp[-3].TypeVal).T;
4329 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004330 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004331 break;
4332
4333 case 150:
Reid Spencer832254e2007-02-02 02:16:23 +00004334#line 2036 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004335 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004336 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004337 if (STy == 0)
4338 error("Cannot make struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004339 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004340 if (STy->getNumContainedTypes() != 0)
4341 error("Illegal number of initializers for structure type");
4342 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004343 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4344 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004345 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004346 break;
4347
4348 case 151:
Reid Spencer832254e2007-02-02 02:16:23 +00004349#line 2047 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004350 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004351 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004352 if (STy == 0)
4353 error("Cannot make packed struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004354 (yyvsp[-5].TypeVal).T->get()->getDescription() + "'");
4355 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004356 error("Illegal number of initializers for packed structure type");
4357
4358 // Check to ensure that constants are compatible with the type initializer!
4359 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004360 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4361 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004362 if (C->getType() != STy->getElementType(i))
4363 error("Expected type '" + STy->getElementType(i)->getDescription() +
4364 "' for element #" + utostr(i) + " of packed struct initializer");
4365 Fields.push_back(C);
4366 }
4367 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004368 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4369 delete (yyvsp[-5].TypeVal).T;
4370 delete (yyvsp[-2].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004371 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004372 break;
4373
4374 case 152:
Reid Spencer832254e2007-02-02 02:16:23 +00004375#line 2069 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004376 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004377 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004378 if (STy == 0)
4379 error("Cannot make packed struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004380 (yyvsp[-4].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004381 if (STy->getNumContainedTypes() != 0)
4382 error("Illegal number of initializers for packed structure type");
4383 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004384 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4385 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004386 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004387 break;
4388
4389 case 153:
Reid Spencer832254e2007-02-02 02:16:23 +00004390#line 2080 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004391 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004392 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004393 if (PTy == 0)
4394 error("Cannot make null pointer constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004395 (yyvsp[-1].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004396 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00004397 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4398 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004399 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004400 break;
4401
4402 case 154:
Reid Spencer832254e2007-02-02 02:16:23 +00004403#line 2089 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004404 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004405 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).T->get());
4406 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4407 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004408 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004409 break;
4410
4411 case 155:
Reid Spencer832254e2007-02-02 02:16:23 +00004412#line 2094 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004413 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004414 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004415 if (Ty == 0)
4416 error("Global const reference must be a pointer type, not" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004417 (yyvsp[-1].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004418
4419 // ConstExprs can exist in the body of a function, thus creating
4420 // GlobalValues whenever they refer to a variable. Because we are in
4421 // the context of a function, getExistingValue will search the functions
4422 // symbol table instead of the module symbol table for the global symbol,
4423 // which throws things all off. To get around this, we just tell
4424 // getExistingValue that we are at global scope here.
4425 //
4426 Function *SavedCurFn = CurFun.CurrentFunction;
4427 CurFun.CurrentFunction = 0;
Reid Spencerb7046c72007-01-29 05:41:34 +00004428 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004429 CurFun.CurrentFunction = SavedCurFn;
4430
4431 // If this is an initializer for a constant pointer, which is referencing a
4432 // (currently) undefined variable, create a stub now that shall be replaced
4433 // in the future with the right type of variable.
4434 //
4435 if (V == 0) {
4436 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4437 const PointerType *PT = cast<PointerType>(Ty);
4438
4439 // First check to see if the forward references value is already created!
4440 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencerb7046c72007-01-29 05:41:34 +00004441 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004442
4443 if (I != CurModule.GlobalRefs.end()) {
4444 V = I->second; // Placeholder already exists, use it...
Reid Spencerb7046c72007-01-29 05:41:34 +00004445 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004446 } else {
4447 std::string Name;
Reid Spencerb7046c72007-01-29 05:41:34 +00004448 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004449
4450 // Create the forward referenced global.
4451 GlobalValue *GV;
4452 if (const FunctionType *FTy =
4453 dyn_cast<FunctionType>(PT->getElementType())) {
4454 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4455 CurModule.CurrentModule);
4456 } else {
4457 GV = new GlobalVariable(PT->getElementType(), false,
4458 GlobalValue::ExternalLinkage, 0,
4459 Name, CurModule.CurrentModule);
4460 }
4461
4462 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencerb7046c72007-01-29 05:41:34 +00004463 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004464 V = GV;
4465 }
4466 }
4467 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerb7046c72007-01-29 05:41:34 +00004468 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4469 delete (yyvsp[-1].TypeVal).T; // Free the type handle
Reid Spencer950bf602007-01-26 08:19:09 +00004470 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004471 break;
4472
4473 case 156:
Reid Spencer832254e2007-02-02 02:16:23 +00004474#line 2152 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004475 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004476 if ((yyvsp[-1].TypeVal).T->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004477 error("Mismatched types for constant expression");
Reid Spencerb7046c72007-01-29 05:41:34 +00004478 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4479 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4480 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004481 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004482 break;
4483
4484 case 157:
Reid Spencer832254e2007-02-02 02:16:23 +00004485#line 2159 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004486 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004487 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004488 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4489 error("Cannot create a null initialized value of this type");
4490 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00004491 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4492 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004493 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004494 break;
4495
4496 case 158:
Reid Spencer832254e2007-02-02 02:16:23 +00004497#line 2167 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004498 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004499 const Type *Ty = (yyvsp[-1].PrimType).T;
4500 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004501 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004502 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004503 (yyval.ConstVal).S = Signed;
4504 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004505 break;
4506
4507 case 159:
Reid Spencer832254e2007-02-02 02:16:23 +00004508#line 2174 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004509 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004510 const Type *Ty = (yyvsp[-1].PrimType).T;
4511 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004512 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004513 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004514 (yyval.ConstVal).S = Unsigned;
4515 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004516 break;
4517
4518 case 160:
Reid Spencer832254e2007-02-02 02:16:23 +00004519#line 2181 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004520 { // Boolean constants
4521 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4522 (yyval.ConstVal).S = Unsigned;
4523 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004524 break;
4525
4526 case 161:
Reid Spencer832254e2007-02-02 02:16:23 +00004527#line 2185 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004528 { // Boolean constants
4529 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4530 (yyval.ConstVal).S = Unsigned;
4531 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004532 break;
4533
4534 case 162:
Reid Spencer832254e2007-02-02 02:16:23 +00004535#line 2189 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004536 { // Float & Double constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004537 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004538 error("Floating point constant invalid for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004539 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004540 (yyval.ConstVal).S = Signless;
4541 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004542 break;
4543
4544 case 163:
Reid Spencer832254e2007-02-02 02:16:23 +00004545#line 2198 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004546 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004547 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4548 const Type* DstTy = (yyvsp[-1].TypeVal).T->get();
4549 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4550 Signedness DstSign = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004551 if (!SrcTy->isFirstClassType())
4552 error("cast constant expression from a non-primitive type: '" +
4553 SrcTy->getDescription() + "'");
4554 if (!DstTy->isFirstClassType())
4555 error("cast constant expression to a non-primitive type: '" +
4556 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004557 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencer950bf602007-01-26 08:19:09 +00004558 (yyval.ConstVal).S = DstSign;
Reid Spencerb7046c72007-01-29 05:41:34 +00004559 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004560 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004561 break;
4562
4563 case 164:
Reid Spencer832254e2007-02-02 02:16:23 +00004564#line 2213 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004565 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004566 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004567 if (!isa<PointerType>(Ty))
4568 error("GetElementPtr requires a pointer operand");
4569
4570 std::vector<Value*> VIndices;
4571 std::vector<Constant*> CIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00004572 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004573
Reid Spencerb7046c72007-01-29 05:41:34 +00004574 delete (yyvsp[-1].ValueList);
4575 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004576 (yyval.ConstVal).S = Signless;
4577 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004578 break;
4579
4580 case 165:
Reid Spencer832254e2007-02-02 02:16:23 +00004581#line 2226 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004582 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004583 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4584 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004585 error("Select condition must be bool type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004586 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004587 error("Select operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004588 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004589 (yyval.ConstVal).S = Unsigned;
4590 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004591 break;
4592
4593 case 166:
Reid Spencer832254e2007-02-02 02:16:23 +00004594#line 2235 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004595 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004596 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4597 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004598 error("Binary operator types must match");
4599 // First, make sure we're dealing with the right opcode by upgrading from
4600 // obsolete versions.
Reid Spencerb7046c72007-01-29 05:41:34 +00004601 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004602
4603 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4604 // To retain backward compatibility with these early compilers, we emit a
4605 // cast to the appropriate integer type automatically if we are in the
4606 // broken case. See PR424 for more information.
4607 if (!isa<PointerType>(Ty)) {
Reid Spencerb7046c72007-01-29 05:41:34 +00004608 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004609 } else {
4610 const Type *IntPtrTy = 0;
4611 switch (CurModule.CurrentModule->getPointerSize()) {
4612 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4613 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4614 default: error("invalid pointer binary constant expr");
4615 }
4616 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
Reid Spencerb7046c72007-01-29 05:41:34 +00004617 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4618 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
Reid Spencer950bf602007-01-26 08:19:09 +00004619 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4620 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004621 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004622 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004623 break;
4624
4625 case 167:
Reid Spencer832254e2007-02-02 02:16:23 +00004626#line 2263 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004627 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004628 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4629 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004630 error("Logical operator types must match");
4631 if (!Ty->isInteger()) {
4632 if (!isa<PackedType>(Ty) ||
4633 !cast<PackedType>(Ty)->getElementType()->isInteger())
4634 error("Logical operator requires integer operands");
4635 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004636 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4637 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4638 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004639 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004640 break;
4641
4642 case 168:
Reid Spencer832254e2007-02-02 02:16:23 +00004643#line 2276 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004644 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004645 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4646 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004647 error("setcc operand types must match");
4648 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00004649 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4650 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004651 (yyval.ConstVal).S = Unsigned;
4652 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004653 break;
4654
4655 case 169:
Reid Spencer832254e2007-02-02 02:16:23 +00004656#line 2285 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004657 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004658 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004659 error("icmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004660 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004661 (yyval.ConstVal).S = Unsigned;
4662 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004663 break;
4664
4665 case 170:
Reid Spencer832254e2007-02-02 02:16:23 +00004666#line 2291 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004667 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004668 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004669 error("fcmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004670 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004671 (yyval.ConstVal).S = Unsigned;
4672 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004673 break;
4674
4675 case 171:
Reid Spencer832254e2007-02-02 02:16:23 +00004676#line 2297 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004677 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004678 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4679 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004680 error("Shift count for shift constant must be unsigned byte");
Reid Spencer832254e2007-02-02 02:16:23 +00004681 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
Reid Spencerb7046c72007-01-29 05:41:34 +00004682 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004683 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00004684 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4685 (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 +00004686 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004687 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004688 break;
4689
4690 case 172:
Reid Spencer832254e2007-02-02 02:16:23 +00004691#line 2308 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004692 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004693 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004694 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004695 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4696 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004697 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004698 break;
4699
4700 case 173:
Reid Spencer832254e2007-02-02 02:16:23 +00004701#line 2314 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004702 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004703 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004704 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004705 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4706 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004707 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004708 break;
4709
4710 case 174:
Reid Spencer832254e2007-02-02 02:16:23 +00004711#line 2320 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004712 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004713 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004714 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004715 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4716 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004717 ;}
4718 break;
4719
4720 case 175:
Reid Spencer832254e2007-02-02 02:16:23 +00004721#line 2331 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004722 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004723 break;
4724
4725 case 176:
Reid Spencer832254e2007-02-02 02:16:23 +00004726#line 2332 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004727 {
4728 (yyval.ConstVector) = new std::vector<ConstInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004729 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004730 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004731 break;
4732
4733 case 177:
Reid Spencer832254e2007-02-02 02:16:23 +00004734#line 2341 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004735 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004736 break;
4737
4738 case 178:
Reid Spencer832254e2007-02-02 02:16:23 +00004739#line 2342 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004740 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004741 break;
4742
4743 case 179:
Reid Spencer832254e2007-02-02 02:16:23 +00004744#line 2354 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004745 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004746 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004747 CurModule.ModuleDone();
4748 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004749 break;
4750
4751 case 180:
Reid Spencer832254e2007-02-02 02:16:23 +00004752#line 2363 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004753 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004754 break;
4755
4756 case 181:
Reid Spencer832254e2007-02-02 02:16:23 +00004757#line 2364 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004758 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004759 break;
4760
4761 case 182:
Reid Spencer832254e2007-02-02 02:16:23 +00004762#line 2365 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004763 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004764 break;
4765
4766 case 183:
Reid Spencer832254e2007-02-02 02:16:23 +00004767#line 2366 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00004768 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004769 break;
4770
4771 case 184:
Reid Spencer832254e2007-02-02 02:16:23 +00004772#line 2367 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004773 {
4774 (yyval.ModuleVal) = CurModule.CurrentModule;
4775 // Emit an error if there are any unresolved types left.
4776 if (!CurModule.LateResolveTypes.empty()) {
4777 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4778 if (DID.Type == ValID::NameVal) {
4779 error("Reference to an undefined type: '"+DID.getName() + "'");
4780 } else {
4781 error("Reference to an undefined type: #" + itostr(DID.Num));
4782 }
4783 }
4784 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004785 break;
4786
4787 case 185:
Reid Spencer832254e2007-02-02 02:16:23 +00004788#line 2383 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004789 {
Reid Spencer950bf602007-01-26 08:19:09 +00004790 // Eagerly resolve types. This is not an optimization, this is a
4791 // requirement that is due to the fact that we could have this:
4792 //
4793 // %list = type { %list * }
4794 // %list = type { %list * } ; repeated type decl
4795 //
4796 // If types are not resolved eagerly, then the two types will not be
4797 // determined to be the same type!
4798 //
Reid Spencerb7046c72007-01-29 05:41:34 +00004799 const Type* Ty = (yyvsp[0].TypeVal).T->get();
4800 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004801
Reid Spencerb7046c72007-01-29 05:41:34 +00004802 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer950bf602007-01-26 08:19:09 +00004803 // If this is a named type that is not a redefinition, add it to the slot
4804 // table.
4805 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004806 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004807 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004808 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004809 break;
4810
4811 case 186:
Reid Spencer832254e2007-02-02 02:16:23 +00004812#line 2403 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004813 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004814 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004815 break;
4816
4817 case 187:
Reid Spencer832254e2007-02-02 02:16:23 +00004818#line 2405 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004819 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004820 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004821 break;
4822
4823 case 188:
Reid Spencer832254e2007-02-02 02:16:23 +00004824#line 2407 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004825 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004826 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00004827 error("Global value initializer is not a constant");
Reid Spencerb7046c72007-01-29 05:41:34 +00004828 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 +00004829 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004830 break;
4831
4832 case 189:
Reid Spencer832254e2007-02-02 02:16:23 +00004833#line 2411 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004834 {
Reid Spencer950bf602007-01-26 08:19:09 +00004835 CurGV = 0;
4836 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004837 break;
4838
4839 case 190:
Reid Spencer832254e2007-02-02 02:16:23 +00004840#line 2414 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004841 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004842 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4843 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4844 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004845 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004846 break;
4847
4848 case 191:
Reid Spencer832254e2007-02-02 02:16:23 +00004849#line 2418 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004850 {
Reid Spencer950bf602007-01-26 08:19:09 +00004851 CurGV = 0;
4852 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004853 break;
4854
4855 case 192:
Reid Spencer832254e2007-02-02 02:16:23 +00004856#line 2421 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004857 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004858 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4859 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4860 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004861 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004862 break;
4863
4864 case 193:
Reid Spencer832254e2007-02-02 02:16:23 +00004865#line 2425 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004866 {
Reid Spencer950bf602007-01-26 08:19:09 +00004867 CurGV = 0;
4868 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004869 break;
4870
4871 case 194:
Reid Spencer832254e2007-02-02 02:16:23 +00004872#line 2428 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004873 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004874 const Type *Ty = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004875 CurGV =
Reid Spencerb7046c72007-01-29 05:41:34 +00004876 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4877 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004878 ;}
4879 break;
4880
4881 case 195:
Reid Spencer832254e2007-02-02 02:16:23 +00004882#line 2433 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004883 {
4884 CurGV = 0;
4885 ;}
4886 break;
4887
4888 case 196:
Reid Spencer832254e2007-02-02 02:16:23 +00004889#line 2436 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004890 {
Reid Spencer950bf602007-01-26 08:19:09 +00004891 ;}
4892 break;
4893
4894 case 197:
Reid Spencer832254e2007-02-02 02:16:23 +00004895#line 2438 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004896 {
4897 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004898 break;
4899
4900 case 198:
Reid Spencer832254e2007-02-02 02:16:23 +00004901#line 2440 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004902 {
4903 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004904 break;
4905
4906 case 199:
Reid Spencer832254e2007-02-02 02:16:23 +00004907#line 2445 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004908 {
Reid Spencer950bf602007-01-26 08:19:09 +00004909 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencerb7046c72007-01-29 05:41:34 +00004910 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4911 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4912 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004913
4914 if (AsmSoFar.empty())
4915 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4916 else
4917 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4918 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004919 break;
4920
4921 case 200:
Reid Spencer832254e2007-02-02 02:16:23 +00004922#line 2459 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004923 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004924 break;
4925
4926 case 201:
Reid Spencer832254e2007-02-02 02:16:23 +00004927#line 2460 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004928 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004929 break;
4930
4931 case 202:
Reid Spencer832254e2007-02-02 02:16:23 +00004932#line 2464 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004933 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004934 CurModule.setEndianness((yyvsp[0].Endianness));
Reid Spencer950bf602007-01-26 08:19:09 +00004935 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004936 break;
4937
4938 case 203:
Reid Spencer832254e2007-02-02 02:16:23 +00004939#line 2467 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004940 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004941 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00004942 CurModule.setPointerSize(Module::Pointer32);
Reid Spencerb7046c72007-01-29 05:41:34 +00004943 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00004944 CurModule.setPointerSize(Module::Pointer64);
4945 else
Reid Spencerb7046c72007-01-29 05:41:34 +00004946 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004947 ;}
4948 break;
4949
4950 case 204:
Reid Spencer832254e2007-02-02 02:16:23 +00004951#line 2475 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004952 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004953 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4954 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004955 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004956 break;
4957
4958 case 205:
Reid Spencer832254e2007-02-02 02:16:23 +00004959#line 2479 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004960 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004961 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4962 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004963 ;}
4964 break;
4965
4966 case 207:
Reid Spencer832254e2007-02-02 02:16:23 +00004967#line 2490 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004968 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004969 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4970 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004971 ;}
4972 break;
4973
4974 case 208:
Reid Spencer832254e2007-02-02 02:16:23 +00004975#line 2494 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004976 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004977 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4978 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004979 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004980 break;
4981
4982 case 209:
Reid Spencer832254e2007-02-02 02:16:23 +00004983#line 2498 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004984 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004985 break;
4986
Reid Spencerc4d96252007-01-13 00:03:30 +00004987 case 213:
Reid Spencer832254e2007-02-02 02:16:23 +00004988#line 2511 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004989 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004990 break;
4991
Reid Spencer319a7302007-01-05 17:20:02 +00004992 case 214:
Reid Spencer832254e2007-02-02 02:16:23 +00004993#line 2515 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004994 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004995 if ((yyvsp[-1].TypeVal).T->get() == Type::VoidTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004996 error("void typed arguments are invalid");
Reid Spencerb7046c72007-01-29 05:41:34 +00004997 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004998 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004999 break;
5000
5001 case 215:
Reid Spencer832254e2007-02-02 02:16:23 +00005002#line 2523 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005003 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005004 (yyval.ArgList) = (yyvsp[-2].ArgList);
5005 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5006 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005007 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005008 break;
5009
5010 case 216:
Reid Spencer832254e2007-02-02 02:16:23 +00005011#line 2528 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005012 {
5013 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005014 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5015 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005016 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005017 break;
5018
5019 case 217:
Reid Spencer832254e2007-02-02 02:16:23 +00005020#line 2536 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005021 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005022 break;
5023
5024 case 218:
Reid Spencer832254e2007-02-02 02:16:23 +00005025#line 2537 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005026 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005027 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer950bf602007-01-26 08:19:09 +00005028 PATypeInfo VoidTI;
5029 VoidTI.T = new PATypeHolder(Type::VoidTy);
5030 VoidTI.S = Signless;
5031 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5032 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005033 break;
5034
5035 case 219:
Reid Spencer832254e2007-02-02 02:16:23 +00005036#line 2544 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005037 {
5038 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5039 PATypeInfo VoidTI;
5040 VoidTI.T = new PATypeHolder(Type::VoidTy);
5041 VoidTI.S = Signless;
5042 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5043 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005044 break;
5045
5046 case 220:
Reid Spencer832254e2007-02-02 02:16:23 +00005047#line 2551 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005048 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005049 break;
5050
5051 case 221:
Reid Spencer832254e2007-02-02 02:16:23 +00005052#line 2555 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005053 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005054 UnEscapeLexed((yyvsp[-5].StrVal));
5055 std::string FunctionName((yyvsp[-5].StrVal));
5056 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer950bf602007-01-26 08:19:09 +00005057
Reid Spencerb7046c72007-01-29 05:41:34 +00005058 const Type* RetTy = (yyvsp[-6].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005059
5060 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5061 error("LLVM functions cannot return aggregate types");
5062
5063 std::vector<const Type*> ParamTypeList;
5064
5065 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5066 // i8*. We check here for those names and override the parameter list
5067 // types to ensure the prototype is correct.
5068 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5069 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5070 } else if (FunctionName == "llvm.va_copy") {
5071 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5072 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencerb7046c72007-01-29 05:41:34 +00005073 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005074 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencerb7046c72007-01-29 05:41:34 +00005075 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005076 const Type *Ty = I->first.T->get();
5077 ParamTypeList.push_back(Ty);
5078 }
5079 }
5080
5081 bool isVarArg =
5082 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5083 if (isVarArg) ParamTypeList.pop_back();
5084
Reid Spencerb7046c72007-01-29 05:41:34 +00005085 // Convert the CSRet calling convention into the corresponding parameter
5086 // attribute.
5087 FunctionType::ParamAttrsList ParamAttrs;
5088 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
5089 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5090 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5091 }
5092
5093 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg,
5094 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005095 const PointerType *PFT = PointerType::get(FT);
Reid Spencerb7046c72007-01-29 05:41:34 +00005096 delete (yyvsp[-6].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005097
5098 ValID ID;
5099 if (!FunctionName.empty()) {
5100 ID = ValID::create((char*)FunctionName.c_str());
5101 } else {
5102 ID = ValID::create((int)CurModule.Values[PFT].size());
5103 }
5104
5105 Function *Fn = 0;
5106 // See if this function was forward referenced. If so, recycle the object.
5107 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5108 // Move the function to the end of the list, from whereever it was
5109 // previously inserted.
5110 Fn = cast<Function>(FWRef);
5111 CurModule.CurrentModule->getFunctionList().remove(Fn);
5112 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5113 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5114 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5115 // If this is the case, either we need to be a forward decl, or it needs
5116 // to be.
Reid Spencer5cbf9852007-01-30 20:08:39 +00005117 if (!CurFun.isDeclare && !Fn->isDeclaration())
Reid Spencer950bf602007-01-26 08:19:09 +00005118 error("Redefinition of function '" + FunctionName + "'");
5119
5120 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer5cbf9852007-01-30 20:08:39 +00005121 if (Fn->isDeclaration())
Reid Spencer950bf602007-01-26 08:19:09 +00005122 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5123 AI != AE; ++AI)
5124 AI->setName("");
5125 } else { // Not already defined?
5126 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5127 CurModule.CurrentModule);
5128
5129 InsertValue(Fn, CurModule.Values);
5130 }
5131
5132 CurFun.FunctionStart(Fn);
5133
5134 if (CurFun.isDeclare) {
5135 // If we have declaration, always overwrite linkage. This will allow us
5136 // to correctly handle cases, when pointer to function is passed as
5137 // argument to another function.
5138 Fn->setLinkage(CurFun.Linkage);
5139 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005140 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5141 Fn->setAlignment((yyvsp[0].UIntVal));
5142 if ((yyvsp[-1].StrVal)) {
5143 Fn->setSection((yyvsp[-1].StrVal));
5144 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005145 }
5146
5147 // Add all of the arguments we parsed to the function...
Reid Spencerb7046c72007-01-29 05:41:34 +00005148 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005149 if (isVarArg) { // Nuke the last entry
Reid Spencerb7046c72007-01-29 05:41:34 +00005150 assert((yyvsp[-3].ArgList)->back().first.T->get() == Type::VoidTy &&
5151 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5152 delete (yyvsp[-3].ArgList)->back().first.T;
5153 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005154 }
5155 Function::arg_iterator ArgIt = Fn->arg_begin();
5156 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencerb7046c72007-01-29 05:41:34 +00005157 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I, ++ArgIt) {
Reid Spencer950bf602007-01-26 08:19:09 +00005158 delete I->first.T; // Delete the typeholder...
5159 setValueName(ArgIt, I->second); // Insert arg into symtab...
5160 InsertValue(ArgIt);
5161 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005162 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005163 }
5164 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005165 break;
5166
5167 case 224:
Reid Spencer832254e2007-02-02 02:16:23 +00005168#line 2674 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005169 {
5170 (yyval.FunctionVal) = CurFun.CurrentFunction;
5171
5172 // Make sure that we keep track of the linkage type even if there was a
5173 // previous "declare".
Reid Spencerb7046c72007-01-29 05:41:34 +00005174 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Reid Spencer950bf602007-01-26 08:19:09 +00005175 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005176 break;
5177
5178 case 227:
Reid Spencer832254e2007-02-02 02:16:23 +00005179#line 2688 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005180 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005181 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005182 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005183 break;
5184
5185 case 229:
Reid Spencer832254e2007-02-02 02:16:23 +00005186#line 2694 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005187 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5188 break;
5189
5190 case 230:
Reid Spencer832254e2007-02-02 02:16:23 +00005191#line 2695 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005192 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5193 break;
5194
5195 case 231:
Reid Spencer832254e2007-02-02 02:16:23 +00005196#line 2699 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005197 { CurFun.isDeclare = true; ;}
5198 break;
5199
5200 case 232:
Reid Spencer832254e2007-02-02 02:16:23 +00005201#line 2699 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005202 {
5203 (yyval.FunctionVal) = CurFun.CurrentFunction;
5204 CurFun.FunctionDone();
5205
5206 ;}
5207 break;
5208
5209 case 233:
Reid Spencer832254e2007-02-02 02:16:23 +00005210#line 2711 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005211 { (yyval.BoolVal) = false; ;}
5212 break;
5213
5214 case 234:
Reid Spencer832254e2007-02-02 02:16:23 +00005215#line 2712 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005216 { (yyval.BoolVal) = true; ;}
5217 break;
5218
5219 case 235:
Reid Spencer832254e2007-02-02 02:16:23 +00005220#line 2717 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005221 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005222 break;
5223
5224 case 236:
Reid Spencer832254e2007-02-02 02:16:23 +00005225#line 2718 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005226 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005227 break;
5228
5229 case 237:
Reid Spencer832254e2007-02-02 02:16:23 +00005230#line 2719 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005231 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005232 break;
5233
5234 case 238:
Reid Spencer832254e2007-02-02 02:16:23 +00005235#line 2720 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005236 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005237 break;
5238
Reid Spencerc4d96252007-01-13 00:03:30 +00005239 case 239:
Reid Spencer832254e2007-02-02 02:16:23 +00005240#line 2721 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005241 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5242 break;
5243
5244 case 240:
Reid Spencer832254e2007-02-02 02:16:23 +00005245#line 2722 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005246 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005247 break;
5248
Reid Spencerc4d96252007-01-13 00:03:30 +00005249 case 241:
Reid Spencer832254e2007-02-02 02:16:23 +00005250#line 2723 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005251 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5252 break;
5253
5254 case 242:
Reid Spencer832254e2007-02-02 02:16:23 +00005255#line 2724 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005256 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5257 break;
5258
5259 case 243:
Reid Spencer832254e2007-02-02 02:16:23 +00005260#line 2725 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005261 { // Nonempty unsized packed vector
Reid Spencerb7046c72007-01-29 05:41:34 +00005262 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5263 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer950bf602007-01-26 08:19:09 +00005264 PackedType* pt = PackedType::get(ETy, NumElements);
5265 PATypeHolder* PTy = new PATypeHolder(
5266 HandleUpRefs(PackedType::get(ETy, NumElements)));
5267
5268 // Verify all elements are correct type!
5269 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00005270 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5271 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005272 const Type *CTy = C->getType();
5273 if (ETy != CTy)
5274 error("Element #" + utostr(i) + " is not of type '" +
5275 ETy->getDescription() +"' as required!\nIt is of type '" +
5276 CTy->getDescription() + "'");
5277 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005278 }
Reid Spencer950bf602007-01-26 08:19:09 +00005279 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
Reid Spencerb7046c72007-01-29 05:41:34 +00005280 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00005281 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005282 break;
5283
Reid Spencerc4d96252007-01-13 00:03:30 +00005284 case 244:
Reid Spencer832254e2007-02-02 02:16:23 +00005285#line 2746 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005286 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005287 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00005288 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005289 break;
5290
Reid Spencerc4d96252007-01-13 00:03:30 +00005291 case 245:
Reid Spencer832254e2007-02-02 02:16:23 +00005292#line 2749 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005293 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005294 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5295 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5296 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5297 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5298 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5299 free((yyvsp[-2].StrVal));
5300 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005301 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005302 break;
5303
Reid Spencerc4d96252007-01-13 00:03:30 +00005304 case 246:
Reid Spencer832254e2007-02-02 02:16:23 +00005305#line 2764 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005306 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005307 break;
5308
Reid Spencer319a7302007-01-05 17:20:02 +00005309 case 247:
Reid Spencer832254e2007-02-02 02:16:23 +00005310#line 2765 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005311 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005312 break;
5313
5314 case 250:
Reid Spencer832254e2007-02-02 02:16:23 +00005315#line 2778 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005316 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005317 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5318 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5319 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5320 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005321 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005322 break;
5323
Reid Spencerc4d96252007-01-13 00:03:30 +00005324 case 251:
Reid Spencer832254e2007-02-02 02:16:23 +00005325#line 2787 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005326 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005327 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005328 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005329 break;
5330
Reid Spencerc4d96252007-01-13 00:03:30 +00005331 case 252:
Reid Spencer832254e2007-02-02 02:16:23 +00005332#line 2790 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005333 { // Do not allow functions with 0 basic blocks
Reid Spencerb7046c72007-01-29 05:41:34 +00005334 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005335 ;}
5336 break;
5337
5338 case 253:
Reid Spencer832254e2007-02-02 02:16:23 +00005339#line 2799 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005340 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005341 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5342 InsertValue((yyvsp[0].TermInstVal));
5343 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5344 InsertValue((yyvsp[-2].BasicBlockVal));
5345 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005346 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005347 break;
5348
Reid Spencerc4d96252007-01-13 00:03:30 +00005349 case 254:
Reid Spencer832254e2007-02-02 02:16:23 +00005350#line 2809 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005351 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005352 if ((yyvsp[0].InstVal).I)
5353 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5354 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005355 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005356 break;
5357
Reid Spencerc4d96252007-01-13 00:03:30 +00005358 case 255:
Reid Spencer832254e2007-02-02 02:16:23 +00005359#line 2814 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005360 {
5361 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5362 // Make sure to move the basic block to the correct location in the
5363 // function, instead of leaving it inserted wherever it was first
5364 // referenced.
5365 Function::BasicBlockListType &BBL =
5366 CurFun.CurrentFunction->getBasicBlockList();
5367 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5368 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005369 break;
5370
Reid Spencerc4d96252007-01-13 00:03:30 +00005371 case 256:
Reid Spencer832254e2007-02-02 02:16:23 +00005372#line 2823 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005373 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005374 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005375 // Make sure to move the basic block to the correct location in the
5376 // function, instead of leaving it inserted wherever it was first
5377 // referenced.
5378 Function::BasicBlockListType &BBL =
5379 CurFun.CurrentFunction->getBasicBlockList();
5380 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5381 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005382 break;
5383
Reid Spencerc4d96252007-01-13 00:03:30 +00005384 case 259:
Reid Spencer832254e2007-02-02 02:16:23 +00005385#line 2837 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005386 { // Return with a result...
Reid Spencerb7046c72007-01-29 05:41:34 +00005387 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005388 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005389 break;
5390
Reid Spencerc4d96252007-01-13 00:03:30 +00005391 case 260:
Reid Spencer832254e2007-02-02 02:16:23 +00005392#line 2840 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005393 { // Return with no result...
5394 (yyval.TermInstVal) = new ReturnInst();
5395 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005396 break;
5397
Reid Spencerc4d96252007-01-13 00:03:30 +00005398 case 261:
Reid Spencer832254e2007-02-02 02:16:23 +00005399#line 2843 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005400 { // Unconditional Branch...
Reid Spencerb7046c72007-01-29 05:41:34 +00005401 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005402 (yyval.TermInstVal) = new BranchInst(tmpBB);
5403 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005404 break;
5405
Reid Spencer319a7302007-01-05 17:20:02 +00005406 case 262:
Reid Spencer832254e2007-02-02 02:16:23 +00005407#line 2847 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005408 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005409 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5410 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5411 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005412 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5413 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005414 break;
5415
5416 case 263:
Reid Spencer832254e2007-02-02 02:16:23 +00005417#line 2853 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005418 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005419 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5420 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5421 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencer950bf602007-01-26 08:19:09 +00005422 (yyval.TermInstVal) = S;
Reid Spencerb7046c72007-01-29 05:41:34 +00005423 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5424 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005425 for (; I != E; ++I) {
5426 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5427 S->addCase(CI, I->second);
5428 else
5429 error("Switch case is constant, but not a simple integer");
5430 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005431 delete (yyvsp[-1].JumpTable);
Reid Spencer950bf602007-01-26 08:19:09 +00005432 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005433 break;
5434
5435 case 264:
Reid Spencer832254e2007-02-02 02:16:23 +00005436#line 2868 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005437 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005438 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5439 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005440 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5441 (yyval.TermInstVal) = S;
5442 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005443 break;
5444
Reid Spencerc4d96252007-01-13 00:03:30 +00005445 case 265:
Reid Spencer832254e2007-02-02 02:16:23 +00005446#line 2875 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005447 {
Reid Spencer950bf602007-01-26 08:19:09 +00005448 const PointerType *PFTy;
5449 const FunctionType *Ty;
5450
Reid Spencerb7046c72007-01-29 05:41:34 +00005451 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005452 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5453 // Pull out the types of all of the arguments...
5454 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005455 if ((yyvsp[-7].ValueList)) {
5456 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005457 I != E; ++I)
5458 ParamTypes.push_back((*I).V->getType());
5459 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005460 FunctionType::ParamAttrsList ParamAttrs;
5461 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
5462 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5463 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5464 }
Reid Spencer950bf602007-01-26 08:19:09 +00005465 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5466 if (isVarArg) ParamTypes.pop_back();
Reid Spencerb7046c72007-01-29 05:41:34 +00005467 Ty = FunctionType::get((yyvsp[-10].TypeVal).T->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005468 PFTy = PointerType::get(Ty);
5469 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005470 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5471 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5472 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005473
5474 // Create the call node...
Reid Spencerb7046c72007-01-29 05:41:34 +00005475 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005476 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5477 } else { // Has arguments?
5478 // Loop through FunctionType's arguments and ensure they are specified
5479 // correctly!
5480 //
5481 FunctionType::param_iterator I = Ty->param_begin();
5482 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00005483 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005484
5485 std::vector<Value*> Args;
5486 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5487 if ((*ArgI).V->getType() != *I)
5488 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5489 (*I)->getDescription() + "'");
5490 Args.push_back((*ArgI).V);
5491 }
5492
5493 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5494 error("Invalid number of parameters detected");
5495
5496 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5497 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005498 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
5499 delete (yyvsp[-10].TypeVal).T;
5500 delete (yyvsp[-7].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005501 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005502 break;
5503
Reid Spencerc4d96252007-01-13 00:03:30 +00005504 case 266:
Reid Spencer832254e2007-02-02 02:16:23 +00005505#line 2930 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005506 {
Reid Spencer950bf602007-01-26 08:19:09 +00005507 (yyval.TermInstVal) = new UnwindInst();
5508 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005509 break;
5510
Reid Spencerc4d96252007-01-13 00:03:30 +00005511 case 267:
Reid Spencer832254e2007-02-02 02:16:23 +00005512#line 2933 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005513 {
5514 (yyval.TermInstVal) = new UnreachableInst();
5515 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005516 break;
5517
Reid Spencerc4d96252007-01-13 00:03:30 +00005518 case 268:
Reid Spencer832254e2007-02-02 02:16:23 +00005519#line 2939 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005520 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005521 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5522 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005523
5524 if (V == 0)
5525 error("May only switch on a constant pool value");
5526
Reid Spencerb7046c72007-01-29 05:41:34 +00005527 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005528 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5529 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005530 break;
5531
Reid Spencerc4d96252007-01-13 00:03:30 +00005532 case 269:
Reid Spencer832254e2007-02-02 02:16:23 +00005533#line 2949 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005534 {
Reid Spencer950bf602007-01-26 08:19:09 +00005535 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005536 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005537
5538 if (V == 0)
5539 error("May only switch on a constant pool value");
5540
Reid Spencerb7046c72007-01-29 05:41:34 +00005541 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005542 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5543 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005544 break;
5545
Reid Spencerc4d96252007-01-13 00:03:30 +00005546 case 270:
Reid Spencer832254e2007-02-02 02:16:23 +00005547#line 2962 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005548 {
Reid Spencer950bf602007-01-26 08:19:09 +00005549 bool omit = false;
Reid Spencerb7046c72007-01-29 05:41:34 +00005550 if ((yyvsp[-1].StrVal))
5551 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005552 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005553 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005554 // This is a useless bit cast causing a name redefinition. It is
5555 // a bit cast from a type to the same type of an operand with the
5556 // same name as the name we would give this instruction. Since this
5557 // instruction results in no code generation, it is safe to omit
5558 // the instruction. This situation can occur because of collapsed
5559 // type planes. For example:
5560 // %X = add int %Y, %Z
5561 // %X = cast int %Y to uint
5562 // After upgrade, this looks like:
5563 // %X = add i32 %Y, %Z
5564 // %X = bitcast i32 to i32
5565 // The bitcast is clearly useless so we omit it.
5566 omit = true;
5567 if (omit) {
5568 (yyval.InstVal).I = 0;
5569 (yyval.InstVal).S = Signless;
5570 } else {
Reid Spencerb7046c72007-01-29 05:41:34 +00005571 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5572 InsertValue((yyvsp[0].InstVal).I);
5573 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005574 }
5575 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005576 break;
5577
Reid Spencerc4d96252007-01-13 00:03:30 +00005578 case 271:
Reid Spencer832254e2007-02-02 02:16:23 +00005579#line 2991 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005580 { // Used for PHI nodes
5581 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005582 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5583 Value* tmpVal = getVal((yyvsp[-5].TypeVal).T->get(), (yyvsp[-3].ValIDVal));
5584 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005585 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencerb7046c72007-01-29 05:41:34 +00005586 delete (yyvsp[-5].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005587 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005588 break;
5589
Reid Spencerc4d96252007-01-13 00:03:30 +00005590 case 272:
Reid Spencer832254e2007-02-02 02:16:23 +00005591#line 2999 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005592 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005593 (yyval.PHIList) = (yyvsp[-6].PHIList);
5594 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5595 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5596 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer950bf602007-01-26 08:19:09 +00005597 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005598 break;
5599
Reid Spencerc4d96252007-01-13 00:03:30 +00005600 case 273:
Reid Spencer832254e2007-02-02 02:16:23 +00005601#line 3007 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005602 { // Used for call statements, and memory insts...
5603 (yyval.ValueList) = new std::vector<ValueInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00005604 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005605 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005606 break;
5607
Reid Spencer950bf602007-01-26 08:19:09 +00005608 case 274:
Reid Spencer832254e2007-02-02 02:16:23 +00005609#line 3011 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005610 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005611 (yyval.ValueList) = (yyvsp[-2].ValueList);
5612 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005613 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005614 break;
5615
Reid Spencerc4d96252007-01-13 00:03:30 +00005616 case 276:
Reid Spencer832254e2007-02-02 02:16:23 +00005617#line 3019 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005618 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005619 break;
5620
Reid Spencerc4d96252007-01-13 00:03:30 +00005621 case 277:
Reid Spencer832254e2007-02-02 02:16:23 +00005622#line 3023 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005623 {
Reid Spencer950bf602007-01-26 08:19:09 +00005624 (yyval.BoolVal) = true;
5625 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005626 break;
5627
Reid Spencer319a7302007-01-05 17:20:02 +00005628 case 278:
Reid Spencer832254e2007-02-02 02:16:23 +00005629#line 3026 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005630 {
Reid Spencer950bf602007-01-26 08:19:09 +00005631 (yyval.BoolVal) = false;
5632 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005633 break;
5634
5635 case 279:
Reid Spencer832254e2007-02-02 02:16:23 +00005636#line 3032 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005637 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005638 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005639 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5640 error("Arithmetic operator requires integer, FP, or packed operands");
5641 if (isa<PackedType>(Ty) &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005642 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Reid Spencer950bf602007-01-26 08:19:09 +00005643 error("Remainder not supported on packed types");
5644 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencerb7046c72007-01-29 05:41:34 +00005645 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5646 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5647 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005648 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5649 if ((yyval.InstVal).I == 0)
5650 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005651 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5652 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005653 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005654 break;
5655
5656 case 280:
Reid Spencer832254e2007-02-02 02:16:23 +00005657#line 3049 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005658 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005659 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005660 if (!Ty->isInteger()) {
5661 if (!isa<PackedType>(Ty) ||
5662 !cast<PackedType>(Ty)->getElementType()->isInteger())
5663 error("Logical operator requires integral operands");
5664 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005665 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5666 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5667 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005668 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5669 if ((yyval.InstVal).I == 0)
5670 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005671 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5672 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005673 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005674 break;
5675
Reid Spencerc4d96252007-01-13 00:03:30 +00005676 case 281:
Reid Spencer832254e2007-02-02 02:16:23 +00005677#line 3065 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005678 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005679 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005680 if(isa<PackedType>(Ty))
5681 error("PackedTypes currently not supported in setcc instructions");
5682 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00005683 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5684 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5685 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005686 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5687 if ((yyval.InstVal).I == 0)
5688 error("binary operator returned null");
5689 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005690 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005691 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005692 break;
5693
Reid Spencerc4d96252007-01-13 00:03:30 +00005694 case 282:
Reid Spencer832254e2007-02-02 02:16:23 +00005695#line 3079 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005696 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005697 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005698 if (isa<PackedType>(Ty))
5699 error("PackedTypes currently not supported in icmp instructions");
5700 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5701 error("icmp requires integer or pointer typed operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005702 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5703 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5704 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005705 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005706 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005707 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005708 break;
5709
Reid Spencerc4d96252007-01-13 00:03:30 +00005710 case 283:
Reid Spencer832254e2007-02-02 02:16:23 +00005711#line 3091 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005712 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005713 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005714 if (isa<PackedType>(Ty))
5715 error("PackedTypes currently not supported in fcmp instructions");
5716 else if (!Ty->isFloatingPoint())
5717 error("fcmp instruction requires floating point operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005718 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5719 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5720 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005721 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005722 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005723 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005724 break;
5725
Reid Spencerc4d96252007-01-13 00:03:30 +00005726 case 284:
Reid Spencer832254e2007-02-02 02:16:23 +00005727#line 3103 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005728 {
Reid Spencer950bf602007-01-26 08:19:09 +00005729 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencerb7046c72007-01-29 05:41:34 +00005730 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005731 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5732 if (Ones == 0)
5733 error("Expected integral type for not instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005734 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
Reid Spencer950bf602007-01-26 08:19:09 +00005735 if ((yyval.InstVal).I == 0)
5736 error("Could not create a xor instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005737 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
Reid Spencer950bf602007-01-26 08:19:09 +00005738 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005739 break;
5740
5741 case 285:
Reid Spencer832254e2007-02-02 02:16:23 +00005742#line 3114 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005743 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005744 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5745 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005746 error("Shift amount must be int8");
Reid Spencer832254e2007-02-02 02:16:23 +00005747 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
5748 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005749 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00005750 Value* ShiftAmt = 0;
5751 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
5752 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
5753 ShiftAmt = ConstantExpr::getZExt(C, Ty);
5754 else
5755 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
5756 else
5757 ShiftAmt = (yyvsp[0].ValueVal).V;
5758 (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 +00005759 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005760 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005761 break;
5762
5763 case 286:
Reid Spencer832254e2007-02-02 02:16:23 +00005764#line 3132 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005765 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005766 const Type *DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005767 if (!DstTy->isFirstClassType())
5768 error("cast instruction to a non-primitive type: '" +
5769 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00005770 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5771 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5772 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005773 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005774 break;
5775
5776 case 287:
Reid Spencer832254e2007-02-02 02:16:23 +00005777#line 3141 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005778 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005779 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5780 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005781 error("select condition must be bool");
Reid Spencerb7046c72007-01-29 05:41:34 +00005782 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005783 error("select value types should match");
Reid Spencerb7046c72007-01-29 05:41:34 +00005784 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5785 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005786 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005787 break;
5788
Reid Spencerc4d96252007-01-13 00:03:30 +00005789 case 288:
Reid Spencer832254e2007-02-02 02:16:23 +00005790#line 3150 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005791 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005792 const Type *Ty = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005793 NewVarArgs = true;
Reid Spencerb7046c72007-01-29 05:41:34 +00005794 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5795 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5796 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005797 ;}
5798 break;
5799
5800 case 289:
Reid Spencer832254e2007-02-02 02:16:23 +00005801#line 3157 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005802 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005803 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5804 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005805 ObsoleteVarArgs = true;
5806 Function* NF = cast<Function>(CurModule.CurrentModule->
5807 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5808
5809 //b = vaarg a, t ->
5810 //foo = alloca 1 of t
5811 //bar = vacopy a
5812 //store bar -> foo
5813 //b = vaarg foo, t
5814 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5815 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005816 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005817 CurBB->getInstList().push_back(bar);
5818 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5819 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00005820 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5821 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005822 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005823 break;
5824
Reid Spencerc4d96252007-01-13 00:03:30 +00005825 case 290:
Reid Spencer832254e2007-02-02 02:16:23 +00005826#line 3178 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005827 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005828 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5829 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005830 ObsoleteVarArgs = true;
5831 Function* NF = cast<Function>(CurModule.CurrentModule->
5832 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5833
5834 //b = vanext a, t ->
5835 //foo = alloca 1 of t
5836 //bar = vacopy a
5837 //store bar -> foo
5838 //tmp = vaarg foo, t
5839 //b = load foo
5840 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5841 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005842 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005843 CurBB->getInstList().push_back(bar);
5844 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5845 Instruction* tmp = new VAArgInst(foo, DstTy);
5846 CurBB->getInstList().push_back(tmp);
5847 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005848 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5849 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005850 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005851 break;
5852
Reid Spencerc4d96252007-01-13 00:03:30 +00005853 case 291:
Reid Spencer832254e2007-02-02 02:16:23 +00005854#line 3202 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005855 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005856 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005857 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005858 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5859 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005860 ;}
5861 break;
5862
5863 case 292:
Reid Spencer832254e2007-02-02 02:16:23 +00005864#line 3208 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005865 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005866 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005867 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005868 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5869 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005870 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005871 break;
5872
Reid Spencerc4d96252007-01-13 00:03:30 +00005873 case 293:
Reid Spencer832254e2007-02-02 02:16:23 +00005874#line 3214 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005875 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005876 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005877 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005878 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5879 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005880 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005881 break;
5882
Reid Spencerc4d96252007-01-13 00:03:30 +00005883 case 294:
Reid Spencer832254e2007-02-02 02:16:23 +00005884#line 3220 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005885 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005886 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005887 if (!Ty->isFirstClassType())
5888 error("PHI node operands must be of first class type");
5889 PHINode *PHI = new PHINode(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00005890 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5891 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5892 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00005893 error("All elements of a PHI node must be of the same type");
Reid Spencerb7046c72007-01-29 05:41:34 +00005894 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5895 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00005896 }
5897 (yyval.InstVal).I = PHI;
Reid Spencerb7046c72007-01-29 05:41:34 +00005898 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5899 delete (yyvsp[0].PHIList).P; // Free the list...
Reid Spencer950bf602007-01-26 08:19:09 +00005900 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005901 break;
5902
5903 case 295:
Reid Spencer832254e2007-02-02 02:16:23 +00005904#line 3236 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005905 {
Reid Spencer950bf602007-01-26 08:19:09 +00005906
5907 // Handle the short call syntax
5908 const PointerType *PFTy;
5909 const FunctionType *FTy;
Reid Spencerb7046c72007-01-29 05:41:34 +00005910 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005911 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5912 // Pull out the types of all of the arguments...
5913 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005914 if ((yyvsp[-1].ValueList)) {
5915 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005916 I != E; ++I)
5917 ParamTypes.push_back((*I).V->getType());
5918 }
5919
Reid Spencerb7046c72007-01-29 05:41:34 +00005920 FunctionType::ParamAttrsList ParamAttrs;
5921 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
5922 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5923 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5924 }
Reid Spencer950bf602007-01-26 08:19:09 +00005925 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5926 if (isVarArg) ParamTypes.pop_back();
5927
Reid Spencerb7046c72007-01-29 05:41:34 +00005928 const Type *RetTy = (yyvsp[-4].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005929 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5930 error("Functions cannot return aggregate types");
5931
Reid Spencerb7046c72007-01-29 05:41:34 +00005932 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005933 PFTy = PointerType::get(FTy);
5934 }
5935
5936 // First upgrade any intrinsic calls.
5937 std::vector<Value*> Args;
Reid Spencerb7046c72007-01-29 05:41:34 +00005938 if ((yyvsp[-1].ValueList))
5939 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
5940 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
5941 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00005942
5943 // If we got an upgraded intrinsic
5944 if (Inst) {
5945 (yyval.InstVal).I = Inst;
5946 (yyval.InstVal).S = Signless;
5947 } else {
5948 // Get the function we're calling
Reid Spencerb7046c72007-01-29 05:41:34 +00005949 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005950
5951 // Check the argument values match
Reid Spencerb7046c72007-01-29 05:41:34 +00005952 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005953 // Make sure no arguments is a good thing!
5954 if (FTy->getNumParams() != 0)
5955 error("No arguments passed to a function that expects arguments");
5956 } else { // Has arguments?
5957 // Loop through FunctionType's arguments and ensure they are specified
5958 // correctly!
5959 //
5960 FunctionType::param_iterator I = FTy->param_begin();
5961 FunctionType::param_iterator E = FTy->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00005962 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005963
5964 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5965 if ((*ArgI).V->getType() != *I)
5966 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5967 (*I)->getDescription() + "'");
5968
5969 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
5970 error("Invalid number of parameters detected");
5971 }
5972
5973 // Create the call instruction
5974 CallInst *CI = new CallInst(V, Args);
Reid Spencerb7046c72007-01-29 05:41:34 +00005975 CI->setTailCall((yyvsp[-6].BoolVal));
5976 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005977 (yyval.InstVal).I = CI;
Reid Spencerb7046c72007-01-29 05:41:34 +00005978 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005979 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005980 delete (yyvsp[-4].TypeVal).T;
5981 delete (yyvsp[-1].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005982 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005983 break;
5984
Reid Spencerc4d96252007-01-13 00:03:30 +00005985 case 296:
Reid Spencer832254e2007-02-02 02:16:23 +00005986#line 3314 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005987 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005988 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005989 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005990 break;
5991
Reid Spencer609ca3e2007-01-12 20:10:51 +00005992 case 297:
Reid Spencer832254e2007-02-02 02:16:23 +00005993#line 3322 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerb7046c72007-01-29 05:41:34 +00005994 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005995 break;
5996
5997 case 298:
Reid Spencer832254e2007-02-02 02:16:23 +00005998#line 3323 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005999 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006000 break;
6001
Reid Spencerc4d96252007-01-13 00:03:30 +00006002 case 299:
Reid Spencer832254e2007-02-02 02:16:23 +00006003#line 3327 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006004 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006005 break;
6006
Reid Spencerc4d96252007-01-13 00:03:30 +00006007 case 300:
Reid Spencer832254e2007-02-02 02:16:23 +00006008#line 3328 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006009 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006010 break;
6011
Reid Spencerc4d96252007-01-13 00:03:30 +00006012 case 301:
Reid Spencer832254e2007-02-02 02:16:23 +00006013#line 3332 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006014 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006015 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
6016 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6017 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6018 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006019 ;}
6020 break;
6021
6022 case 302:
Reid Spencer832254e2007-02-02 02:16:23 +00006023#line 3338 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006024 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006025 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6026 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6027 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6028 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006029 ;}
6030 break;
6031
6032 case 303:
Reid Spencer832254e2007-02-02 02:16:23 +00006033#line 3344 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006034 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006035 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
6036 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6037 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6038 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006039 ;}
6040 break;
6041
6042 case 304:
Reid Spencer832254e2007-02-02 02:16:23 +00006043#line 3350 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006044 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006045 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6046 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6047 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6048 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006049 ;}
6050 break;
6051
6052 case 305:
Reid Spencer832254e2007-02-02 02:16:23 +00006053#line 3356 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006054 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006055 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006056 if (!isa<PointerType>(PTy))
6057 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006058 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006059 (yyval.InstVal).S = Signless;
6060 ;}
6061 break;
6062
6063 case 306:
Reid Spencer832254e2007-02-02 02:16:23 +00006064#line 3363 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006065 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006066 const Type* Ty = (yyvsp[-1].TypeVal).T->get();
6067 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006068 if (!isa<PointerType>(Ty))
6069 error("Can't load from nonpointer type: " + Ty->getDescription());
6070 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6071 error("Can't load from pointer of non-first-class type: " +
6072 Ty->getDescription());
Reid Spencerb7046c72007-01-29 05:41:34 +00006073 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6074 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
6075 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006076 ;}
6077 break;
6078
6079 case 307:
Reid Spencer832254e2007-02-02 02:16:23 +00006080#line 3375 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006081 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006082 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00006083 if (!PTy)
6084 error("Can't store to a nonpointer type: " +
Reid Spencerb7046c72007-01-29 05:41:34 +00006085 (yyvsp[-1].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00006086 const Type *ElTy = PTy->getElementType();
Reid Spencerb7046c72007-01-29 05:41:34 +00006087 if (ElTy != (yyvsp[-3].ValueVal).V->getType())
6088 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencer950bf602007-01-26 08:19:09 +00006089 "' into space of type '" + ElTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006090 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6091 (yyval.InstVal).I = new StoreInst((yyvsp[-3].ValueVal).V, tmpVal, (yyvsp[-5].BoolVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006092 (yyval.InstVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00006093 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006094 ;}
6095 break;
6096
6097 case 308:
Reid Spencer832254e2007-02-02 02:16:23 +00006098#line 3389 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006099 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006100 const Type* Ty = (yyvsp[-2].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006101 if (!isa<PointerType>(Ty))
6102 error("getelementptr insn requires pointer operand");
6103
6104 std::vector<Value*> VIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00006105 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006106
Reid Spencerb7046c72007-01-29 05:41:34 +00006107 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006108 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6109 (yyval.InstVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00006110 delete (yyvsp[-2].TypeVal).T;
6111 delete (yyvsp[0].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006112 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006113 break;
6114
6115
Reid Spencer950bf602007-01-26 08:19:09 +00006116 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006117 }
6118
Reid Spencerb7046c72007-01-29 05:41:34 +00006119/* Line 1126 of yacc.c. */
Reid Spencer832254e2007-02-02 02:16:23 +00006120#line 6121 "UpgradeParser.tab.c"
Reid Spencerb7046c72007-01-29 05:41:34 +00006121
6122 yyvsp -= yylen;
6123 yyssp -= yylen;
6124
6125
Reid Spencer950bf602007-01-26 08:19:09 +00006126 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006127
6128 *++yyvsp = yyval;
6129
6130
Reid Spencer319a7302007-01-05 17:20:02 +00006131 /* Now `shift' the result of the reduction. Determine what state
6132 that goes to, based on the state we popped back to and the rule
6133 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006134
6135 yyn = yyr1[yyn];
6136
Reid Spencer319a7302007-01-05 17:20:02 +00006137 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6138 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006139 yystate = yytable[yystate];
6140 else
Reid Spencer319a7302007-01-05 17:20:02 +00006141 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006142
6143 goto yynewstate;
6144
6145
Reid Spencer319a7302007-01-05 17:20:02 +00006146/*------------------------------------.
6147| yyerrlab -- here on detecting error |
6148`------------------------------------*/
6149yyerrlab:
6150 /* If not already recovering from an error, report this error. */
6151 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006152 {
6153 ++yynerrs;
Reid Spencerb7046c72007-01-29 05:41:34 +00006154#if YYERROR_VERBOSE
6155 yyn = yypact[yystate];
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006156
Reid Spencerb7046c72007-01-29 05:41:34 +00006157 if (YYPACT_NINF < yyn && yyn < YYLAST)
6158 {
6159 int yytype = YYTRANSLATE (yychar);
6160 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6161 YYSIZE_T yysize = yysize0;
6162 YYSIZE_T yysize1;
6163 int yysize_overflow = 0;
6164 char *yymsg = 0;
6165# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6166 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6167 int yyx;
6168
6169#if 0
6170 /* This is so xgettext sees the translatable formats that are
6171 constructed on the fly. */
6172 YY_("syntax error, unexpected %s");
6173 YY_("syntax error, unexpected %s, expecting %s");
6174 YY_("syntax error, unexpected %s, expecting %s or %s");
6175 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6176 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006177#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006178 char *yyfmt;
6179 char const *yyf;
6180 static char const yyunexpected[] = "syntax error, unexpected %s";
6181 static char const yyexpecting[] = ", expecting %s";
6182 static char const yyor[] = " or %s";
6183 char yyformat[sizeof yyunexpected
6184 + sizeof yyexpecting - 1
6185 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6186 * (sizeof yyor - 1))];
6187 char const *yyprefix = yyexpecting;
6188
6189 /* Start YYX at -YYN if negative to avoid negative indexes in
6190 YYCHECK. */
6191 int yyxbegin = yyn < 0 ? -yyn : 0;
6192
6193 /* Stay within bounds of both yycheck and yytname. */
6194 int yychecklim = YYLAST - yyn;
6195 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6196 int yycount = 1;
6197
6198 yyarg[0] = yytname[yytype];
6199 yyfmt = yystpcpy (yyformat, yyunexpected);
6200
6201 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6202 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6203 {
6204 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6205 {
6206 yycount = 1;
6207 yysize = yysize0;
6208 yyformat[sizeof yyunexpected - 1] = '\0';
6209 break;
6210 }
6211 yyarg[yycount++] = yytname[yyx];
6212 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6213 yysize_overflow |= yysize1 < yysize;
6214 yysize = yysize1;
6215 yyfmt = yystpcpy (yyfmt, yyprefix);
6216 yyprefix = yyor;
6217 }
6218
6219 yyf = YY_(yyformat);
6220 yysize1 = yysize + yystrlen (yyf);
6221 yysize_overflow |= yysize1 < yysize;
6222 yysize = yysize1;
6223
6224 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6225 yymsg = (char *) YYSTACK_ALLOC (yysize);
6226 if (yymsg)
6227 {
6228 /* Avoid sprintf, as that infringes on the user's name space.
6229 Don't have undefined behavior even if the translation
6230 produced a string with the wrong number of "%s"s. */
6231 char *yyp = yymsg;
6232 int yyi = 0;
6233 while ((*yyp = *yyf))
6234 {
6235 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6236 {
6237 yyp += yytnamerr (yyp, yyarg[yyi++]);
6238 yyf += 2;
6239 }
6240 else
6241 {
6242 yyp++;
6243 yyf++;
6244 }
6245 }
6246 yyerror (yymsg);
6247 YYSTACK_FREE (yymsg);
6248 }
6249 else
6250 {
6251 yyerror (YY_("syntax error"));
6252 goto yyexhaustedlab;
6253 }
6254 }
6255 else
6256#endif /* YYERROR_VERBOSE */
6257 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006258 }
Reid Spencer950bf602007-01-26 08:19:09 +00006259
6260
6261
6262 if (yyerrstatus == 3)
6263 {
6264 /* If just tried and failed to reuse look-ahead token after an
6265 error, discard it. */
6266
6267 if (yychar <= YYEOF)
Reid Spencerb7046c72007-01-29 05:41:34 +00006268 {
Reid Spencer950bf602007-01-26 08:19:09 +00006269 /* Return failure if at end of input. */
6270 if (yychar == YYEOF)
6271 YYABORT;
Reid Spencerb7046c72007-01-29 05:41:34 +00006272 }
Reid Spencer950bf602007-01-26 08:19:09 +00006273 else
6274 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006275 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer950bf602007-01-26 08:19:09 +00006276 yychar = YYEMPTY;
6277 }
6278 }
6279
6280 /* Else will try to reuse look-ahead token after shifting the error
6281 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006282 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006283
Reid Spencer319a7302007-01-05 17:20:02 +00006284
Reid Spencer950bf602007-01-26 08:19:09 +00006285/*---------------------------------------------------.
6286| yyerrorlab -- error raised explicitly by YYERROR. |
6287`---------------------------------------------------*/
6288yyerrorlab:
6289
6290 /* Pacify compilers like GCC when the user code never invokes
6291 YYERROR and the label yyerrorlab therefore never appears in user
6292 code. */
Reid Spencerb7046c72007-01-29 05:41:34 +00006293 if (0)
Reid Spencer950bf602007-01-26 08:19:09 +00006294 goto yyerrorlab;
6295
Reid Spencerb7046c72007-01-29 05:41:34 +00006296yyvsp -= yylen;
6297 yyssp -= yylen;
Reid Spencer950bf602007-01-26 08:19:09 +00006298 yystate = *yyssp;
6299 goto yyerrlab1;
6300
6301
6302/*-------------------------------------------------------------.
6303| yyerrlab1 -- common code for both syntax error and YYERROR. |
6304`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006305yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006306 yyerrstatus = 3; /* Each real token shifted decrements this. */
6307
6308 for (;;)
6309 {
6310 yyn = yypact[yystate];
6311 if (yyn != YYPACT_NINF)
6312 {
6313 yyn += YYTERROR;
6314 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6315 {
6316 yyn = yytable[yyn];
6317 if (0 < yyn)
6318 break;
6319 }
6320 }
6321
6322 /* Pop the current state because it cannot handle the error token. */
6323 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006324 YYABORT;
6325
6326
Reid Spencerb7046c72007-01-29 05:41:34 +00006327 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6328 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006329 yystate = *yyssp;
6330 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006331 }
6332
6333 if (yyn == YYFINAL)
6334 YYACCEPT;
6335
6336 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006337
6338
Reid Spencerb7046c72007-01-29 05:41:34 +00006339 /* Shift the error token. */
Reid Spencer950bf602007-01-26 08:19:09 +00006340 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6341
Reid Spencere7c3c602006-11-30 06:36:44 +00006342 yystate = yyn;
6343 goto yynewstate;
6344
Chris Lattner37e01c52007-01-04 18:46:42 +00006345
Reid Spencer319a7302007-01-05 17:20:02 +00006346/*-------------------------------------.
6347| yyacceptlab -- YYACCEPT comes here. |
6348`-------------------------------------*/
6349yyacceptlab:
6350 yyresult = 0;
6351 goto yyreturn;
6352
6353/*-----------------------------------.
6354| yyabortlab -- YYABORT comes here. |
6355`-----------------------------------*/
6356yyabortlab:
6357 yyresult = 1;
6358 goto yyreturn;
6359
6360#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006361/*-------------------------------------------------.
6362| yyexhaustedlab -- memory exhaustion comes here. |
6363`-------------------------------------------------*/
6364yyexhaustedlab:
6365 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006366 yyresult = 2;
6367 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006368#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006369
6370yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006371 if (yychar != YYEOF && yychar != YYEMPTY)
6372 yydestruct ("Cleanup: discarding lookahead",
6373 yytoken, &yylval);
6374 while (yyssp != yyss)
6375 {
6376 yydestruct ("Cleanup: popping",
6377 yystos[*yyssp], yyvsp);
Reid Spencerb7046c72007-01-29 05:41:34 +00006378 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006379 }
Reid Spencer319a7302007-01-05 17:20:02 +00006380#ifndef yyoverflow
6381 if (yyss != yyssa)
6382 YYSTACK_FREE (yyss);
6383#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006384 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006385}
Reid Spencer319a7302007-01-05 17:20:02 +00006386
6387
Reid Spencer832254e2007-02-02 02:16:23 +00006388#line 3405 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006389
6390
6391int yyerror(const char *ErrorMsg) {
6392 std::string where
6393 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006394 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6395 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6396 if (yychar != YYEMPTY && yychar != 0)
6397 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6398 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006399 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006400 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006401 exit(1);
6402}
Reid Spencer319a7302007-01-05 17:20:02 +00006403
Reid Spencer30d0c582007-01-15 00:26:18 +00006404void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006405 std::string where
6406 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006407 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6408 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6409 if (yychar != YYEMPTY && yychar != 0)
6410 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6411 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006412 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6413}
6414
Reid Spencer950bf602007-01-26 08:19:09 +00006415void error(const std::string& ErrorMsg, int LineNo) {
6416 if (LineNo == -1) LineNo = Upgradelineno;
6417 Upgradelineno = LineNo;
6418 yyerror(ErrorMsg.c_str());
6419}
6420
6421