blob: 24eb84e6712f18e1c8d7fe8697bb565408c9635d [file] [log] [blame]
Reid Spencer950bf602007-01-26 08:19:09 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Reid Spencer319a7302007-01-05 17:20:02 +00003/* Skeleton parser for Yacc-like parsing with Bison,
Reid Spencer950bf602007-01-26 08:19:09 +00004 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00005
Reid Spencer319a7302007-01-05 17:20:02 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Reid Spencere7c3c602006-11-30 06:36:44 +000010
Reid Spencer319a7302007-01-05 17:20:02 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
Reid Spencer950bf602007-01-26 08:19:09 +000018 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
Reid Spencer319a7302007-01-05 17:20:02 +000020
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
Reid Spencer950bf602007-01-26 08:19:09 +000037#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
Reid Spencer319a7302007-01-05 17:20:02 +000044
45/* Pure parsers. */
Reid Spencer950bf602007-01-26 08:19:09 +000046#define YYPURE 0
Reid Spencer319a7302007-01-05 17:20:02 +000047
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
Reid Spencer950bf602007-01-26 08:19:09 +000051/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000052#define yyparse Upgradeparse
Reid Spencer319a7302007-01-05 17:20:02 +000053#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000054#define yyerror Upgradeerror
Reid Spencer319a7302007-01-05 17:20:02 +000055#define yylval Upgradelval
56#define yychar Upgradechar
Reid Spencere7c3c602006-11-30 06:36:44 +000057#define yydebug Upgradedebug
58#define yynerrs Upgradenerrs
59
Reid Spencere7c3c602006-11-30 06:36:44 +000060
Reid Spencer319a7302007-01-05 17:20:02 +000061/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
Reid Spencer950bf602007-01-26 08:19:09 +000067 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 BOOL = 264,
74 SBYTE = 265,
75 UBYTE = 266,
76 SHORT = 267,
77 USHORT = 268,
78 INT = 269,
79 UINT = 270,
80 LONG = 271,
81 ULONG = 272,
82 FLOAT = 273,
83 DOUBLE = 274,
84 TYPE = 275,
85 LABEL = 276,
86 VAR_ID = 277,
87 LABELSTR = 278,
88 STRINGCONSTANT = 279,
89 IMPLEMENTATION = 280,
90 ZEROINITIALIZER = 281,
91 TRUETOK = 282,
92 FALSETOK = 283,
93 BEGINTOK = 284,
94 ENDTOK = 285,
95 DECLARE = 286,
96 GLOBAL = 287,
97 CONSTANT = 288,
98 SECTION = 289,
99 VOLATILE = 290,
100 TO = 291,
101 DOTDOTDOT = 292,
102 NULL_TOK = 293,
103 UNDEF = 294,
104 CONST = 295,
105 INTERNAL = 296,
106 LINKONCE = 297,
107 WEAK = 298,
108 APPENDING = 299,
Reid Spencer319a7302007-01-05 17:20:02 +0000109 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
Reid Spencer950bf602007-01-26 08:19:09 +0000112 OPAQUE = 303,
113 NOT = 304,
114 EXTERNAL = 305,
115 TARGET = 306,
116 TRIPLE = 307,
117 ENDIAN = 308,
118 POINTERSIZE = 309,
119 LITTLE = 310,
120 BIG = 311,
121 ALIGN = 312,
Reid Spencerc4d96252007-01-13 00:03:30 +0000122 DEPLIBS = 313,
123 CALL = 314,
124 TAIL = 315,
125 ASM_TOK = 316,
126 MODULE = 317,
127 SIDEEFFECT = 318,
128 CC_TOK = 319,
129 CCC_TOK = 320,
130 CSRETCC_TOK = 321,
131 FASTCC_TOK = 322,
132 COLDCC_TOK = 323,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
135 DATALAYOUT = 326,
136 RET = 327,
137 BR = 328,
138 SWITCH = 329,
139 INVOKE = 330,
Reid Spencer950bf602007-01-26 08:19:09 +0000140 UNREACHABLE = 331,
Reid Spencerc4d96252007-01-13 00:03:30 +0000141 UNWIND = 332,
Reid Spencer950bf602007-01-26 08:19:09 +0000142 EXCEPT = 333,
Reid Spencerc4d96252007-01-13 00:03:30 +0000143 ADD = 334,
144 SUB = 335,
145 MUL = 336,
146 DIV = 337,
147 UDIV = 338,
148 SDIV = 339,
149 FDIV = 340,
150 REM = 341,
151 UREM = 342,
152 SREM = 343,
153 FREM = 344,
154 AND = 345,
155 OR = 346,
156 XOR = 347,
157 SETLE = 348,
158 SETGE = 349,
159 SETLT = 350,
160 SETGT = 351,
161 SETEQ = 352,
162 SETNE = 353,
163 ICMP = 354,
164 FCMP = 355,
Reid Spencer950bf602007-01-26 08:19:09 +0000165 MALLOC = 356,
166 ALLOCA = 357,
167 FREE = 358,
168 LOAD = 359,
169 STORE = 360,
170 GETELEMENTPTR = 361,
171 PHI_TOK = 362,
172 SELECT = 363,
173 SHL = 364,
174 SHR = 365,
175 ASHR = 366,
176 LSHR = 367,
177 VAARG = 368,
178 EXTRACTELEMENT = 369,
179 INSERTELEMENT = 370,
180 SHUFFLEVECTOR = 371,
181 VAARG_old = 372,
182 VANEXT_old = 373,
183 EQ = 374,
184 NE = 375,
185 SLT = 376,
186 SGT = 377,
187 SLE = 378,
188 SGE = 379,
189 ULT = 380,
190 UGT = 381,
191 ULE = 382,
192 UGE = 383,
193 OEQ = 384,
194 ONE = 385,
195 OLT = 386,
196 OGT = 387,
197 OLE = 388,
198 OGE = 389,
199 ORD = 390,
200 UNO = 391,
201 UEQ = 392,
202 UNE = 393,
203 CAST = 394,
204 TRUNC = 395,
205 ZEXT = 396,
206 SEXT = 397,
207 FPTRUNC = 398,
208 FPEXT = 399,
209 FPTOUI = 400,
210 FPTOSI = 401,
211 UITOFP = 402,
212 SITOFP = 403,
213 PTRTOINT = 404,
214 INTTOPTR = 405,
215 BITCAST = 406
Reid Spencer319a7302007-01-05 17:20:02 +0000216 };
217#endif
Reid Spencer950bf602007-01-26 08:19:09 +0000218/* Tokens. */
219#define ESINT64VAL 258
220#define EUINT64VAL 259
221#define SINTVAL 260
222#define UINTVAL 261
223#define FPVAL 262
224#define VOID 263
225#define BOOL 264
226#define SBYTE 265
227#define UBYTE 266
228#define SHORT 267
229#define USHORT 268
230#define INT 269
231#define UINT 270
232#define LONG 271
233#define ULONG 272
234#define FLOAT 273
235#define DOUBLE 274
236#define TYPE 275
237#define LABEL 276
238#define VAR_ID 277
239#define LABELSTR 278
240#define STRINGCONSTANT 279
241#define IMPLEMENTATION 280
242#define ZEROINITIALIZER 281
243#define TRUETOK 282
244#define FALSETOK 283
245#define BEGINTOK 284
246#define ENDTOK 285
247#define DECLARE 286
248#define GLOBAL 287
249#define CONSTANT 288
250#define SECTION 289
251#define VOLATILE 290
252#define TO 291
253#define DOTDOTDOT 292
254#define NULL_TOK 293
255#define UNDEF 294
256#define CONST 295
257#define INTERNAL 296
258#define LINKONCE 297
259#define WEAK 298
260#define APPENDING 299
Reid Spencer319a7302007-01-05 17:20:02 +0000261#define DLLIMPORT 300
262#define DLLEXPORT 301
263#define EXTERN_WEAK 302
Reid Spencer950bf602007-01-26 08:19:09 +0000264#define OPAQUE 303
265#define NOT 304
266#define EXTERNAL 305
267#define TARGET 306
268#define TRIPLE 307
269#define ENDIAN 308
270#define POINTERSIZE 309
271#define LITTLE 310
272#define BIG 311
273#define ALIGN 312
Reid Spencerc4d96252007-01-13 00:03:30 +0000274#define DEPLIBS 313
275#define CALL 314
276#define TAIL 315
277#define ASM_TOK 316
278#define MODULE 317
279#define SIDEEFFECT 318
280#define CC_TOK 319
281#define CCC_TOK 320
282#define CSRETCC_TOK 321
283#define FASTCC_TOK 322
284#define COLDCC_TOK 323
285#define X86_STDCALLCC_TOK 324
286#define X86_FASTCALLCC_TOK 325
287#define DATALAYOUT 326
288#define RET 327
289#define BR 328
290#define SWITCH 329
291#define INVOKE 330
Reid Spencer950bf602007-01-26 08:19:09 +0000292#define UNREACHABLE 331
Reid Spencerc4d96252007-01-13 00:03:30 +0000293#define UNWIND 332
Reid Spencer950bf602007-01-26 08:19:09 +0000294#define EXCEPT 333
Reid Spencerc4d96252007-01-13 00:03:30 +0000295#define ADD 334
296#define SUB 335
297#define MUL 336
298#define DIV 337
299#define UDIV 338
300#define SDIV 339
301#define FDIV 340
302#define REM 341
303#define UREM 342
304#define SREM 343
305#define FREM 344
306#define AND 345
307#define OR 346
308#define XOR 347
309#define SETLE 348
310#define SETGE 349
311#define SETLT 350
312#define SETGT 351
313#define SETEQ 352
314#define SETNE 353
315#define ICMP 354
316#define FCMP 355
Reid Spencer950bf602007-01-26 08:19:09 +0000317#define MALLOC 356
318#define ALLOCA 357
319#define FREE 358
320#define LOAD 359
321#define STORE 360
322#define GETELEMENTPTR 361
323#define PHI_TOK 362
324#define SELECT 363
325#define SHL 364
326#define SHR 365
327#define ASHR 366
328#define LSHR 367
329#define VAARG 368
330#define EXTRACTELEMENT 369
331#define INSERTELEMENT 370
332#define SHUFFLEVECTOR 371
333#define VAARG_old 372
334#define VANEXT_old 373
335#define EQ 374
336#define NE 375
337#define SLT 376
338#define SGT 377
339#define SLE 378
340#define SGE 379
341#define ULT 380
342#define UGT 381
343#define ULE 382
344#define UGE 383
345#define OEQ 384
346#define ONE 385
347#define OLT 386
348#define OGT 387
349#define OLE 388
350#define OGE 389
351#define ORD 390
352#define UNO 391
353#define UEQ 392
354#define UNE 393
355#define CAST 394
356#define TRUNC 395
357#define ZEXT 396
358#define SEXT 397
359#define FPTRUNC 398
360#define FPEXT 399
361#define FPTOUI 400
362#define FPTOSI 401
363#define UITOFP 402
364#define SITOFP 403
365#define PTRTOINT 404
366#define INTTOPTR 405
367#define BITCAST 406
Reid Spencer319a7302007-01-05 17:20:02 +0000368
369
370
371
372/* Copy the first part of user declarations. */
Reid Spencer38f682b2007-01-26 20:31:18 +0000373#line 14 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +0000374
375#include "UpgradeInternals.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000376#include "llvm/CallingConv.h"
377#include "llvm/InlineAsm.h"
378#include "llvm/Instructions.h"
379#include "llvm/Module.h"
380#include "llvm/SymbolTable.h"
381#include "llvm/Support/GetElementPtrTypeIterator.h"
382#include "llvm/ADT/STLExtras.h"
383#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000384#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000385#include <iostream>
Reid Spencer950bf602007-01-26 08:19:09 +0000386#include <list>
387#include <utility>
388
389// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
390// relating to upreferences in the input stream.
391//
392//#define DEBUG_UPREFS 1
393#ifdef DEBUG_UPREFS
394#define UR_OUT(X) std::cerr << X
395#else
396#define UR_OUT(X)
397#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000398
Reid Spencere77e35e2006-12-01 20:26:20 +0000399#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000400#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000401#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000402
Reid Spencer950bf602007-01-26 08:19:09 +0000403int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000404int yyparse();
405
Reid Spencer950bf602007-01-26 08:19:09 +0000406int yyerror(const char*);
407static void warning(const std::string& WarningMsg);
408
409namespace llvm {
410
Reid Spencer950bf602007-01-26 08:19:09 +0000411std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000412static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000413
Reid Spencer71d2ec92006-12-31 06:02:26 +0000414// This bool controls whether attributes are ever added to function declarations
415// definitions and calls.
416static bool AddAttributes = false;
417
Reid Spencer950bf602007-01-26 08:19:09 +0000418static Module *ParserResult;
419static bool ObsoleteVarArgs;
420static bool NewVarArgs;
421static BasicBlock *CurBB;
422static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000423
Reid Spencer950bf602007-01-26 08:19:09 +0000424// This contains info used when building the body of a function. It is
425// destroyed when the function is completed.
426//
427typedef std::vector<Value *> ValueList; // Numbered defs
428
429typedef std::pair<std::string,const Type*> RenameMapKey;
430typedef std::map<RenameMapKey,std::string> RenameMapType;
431
432static void
433ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
434 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
435
436static struct PerModuleInfo {
437 Module *CurrentModule;
438 std::map<const Type *, ValueList> Values; // Module level numbered definitions
439 std::map<const Type *,ValueList> LateResolveValues;
440 std::vector<PATypeHolder> Types;
441 std::map<ValID, PATypeHolder> LateResolveTypes;
442 static Module::Endianness Endian;
443 static Module::PointerSize PointerSize;
444 RenameMapType RenameMap;
445
446 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
447 /// how they were referenced and on which line of the input they came from so
448 /// that we can resolve them later and print error messages as appropriate.
449 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
450
451 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
452 // references to global values. Global values may be referenced before they
453 // are defined, and if so, the temporary object that they represent is held
454 // here. This is used for forward references of GlobalValues.
455 //
456 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
457 GlobalRefsType;
458 GlobalRefsType GlobalRefs;
459
460 void ModuleDone() {
461 // If we could not resolve some functions at function compilation time
462 // (calls to functions before they are defined), resolve them now... Types
463 // are resolved when the constant pool has been completely parsed.
464 //
465 ResolveDefinitions(LateResolveValues);
466
467 // Check to make sure that all global value forward references have been
468 // resolved!
469 //
470 if (!GlobalRefs.empty()) {
471 std::string UndefinedReferences = "Unresolved global references exist:\n";
472
473 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
474 I != E; ++I) {
475 UndefinedReferences += " " + I->first.first->getDescription() + " " +
476 I->first.second.getName() + "\n";
477 }
478 error(UndefinedReferences);
479 return;
480 }
481
482 if (CurrentModule->getDataLayout().empty()) {
483 std::string dataLayout;
484 if (Endian != Module::AnyEndianness)
485 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
486 if (PointerSize != Module::AnyPointerSize) {
487 if (!dataLayout.empty())
488 dataLayout += "-";
489 dataLayout.append(PointerSize == Module::Pointer64 ?
490 "p:64:64" : "p:32:32");
491 }
492 CurrentModule->setDataLayout(dataLayout);
493 }
494
495 Values.clear(); // Clear out function local definitions
496 Types.clear();
497 CurrentModule = 0;
498 }
499
500 // GetForwardRefForGlobal - Check to see if there is a forward reference
501 // for this global. If so, remove it from the GlobalRefs map and return it.
502 // If not, just return null.
503 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
504 // Check to see if there is a forward reference to this global variable...
505 // if there is, eliminate it and patch the reference to use the new def'n.
506 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
507 GlobalValue *Ret = 0;
508 if (I != GlobalRefs.end()) {
509 Ret = I->second;
510 GlobalRefs.erase(I);
511 }
512 return Ret;
513 }
514 void setEndianness(Module::Endianness E) { Endian = E; }
515 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
516} CurModule;
517
518Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
519Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
520
521static struct PerFunctionInfo {
522 Function *CurrentFunction; // Pointer to current function being created
523
524 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
525 std::map<const Type*, ValueList> LateResolveValues;
526 bool isDeclare; // Is this function a forward declararation?
527 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
528
529 /// BBForwardRefs - When we see forward references to basic blocks, keep
530 /// track of them here.
531 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
532 std::vector<BasicBlock*> NumberedBlocks;
533 RenameMapType RenameMap;
Reid Spencer950bf602007-01-26 08:19:09 +0000534 unsigned NextBBNum;
535
536 inline PerFunctionInfo() {
537 CurrentFunction = 0;
538 isDeclare = false;
539 Linkage = GlobalValue::ExternalLinkage;
540 }
541
542 inline void FunctionStart(Function *M) {
543 CurrentFunction = M;
544 NextBBNum = 0;
545 }
546
547 void FunctionDone() {
548 NumberedBlocks.clear();
549
550 // Any forward referenced blocks left?
551 if (!BBForwardRefs.empty()) {
552 error("Undefined reference to label " +
553 BBForwardRefs.begin()->first->getName());
554 return;
555 }
556
557 // Resolve all forward references now.
558 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
559
560 Values.clear(); // Clear out function local definitions
561 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000562 CurrentFunction = 0;
563 isDeclare = false;
564 Linkage = GlobalValue::ExternalLinkage;
565 }
566} CurFun; // Info for the current function...
567
568static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
569
570
571//===----------------------------------------------------------------------===//
572// Code to handle definitions of all the types
573//===----------------------------------------------------------------------===//
574
575static int InsertValue(Value *V,
576 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
577 if (V->hasName()) return -1; // Is this a numbered definition?
578
579 // Yes, insert the value into the value table...
580 ValueList &List = ValueTab[V->getType()];
581 List.push_back(V);
582 return List.size()-1;
583}
584
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000585static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000586 switch (D.Type) {
587 case ValID::NumberVal: // Is it a numbered definition?
588 // Module constants occupy the lowest numbered slots...
589 if ((unsigned)D.Num < CurModule.Types.size()) {
590 return CurModule.Types[(unsigned)D.Num];
591 }
592 break;
593 case ValID::NameVal: // Is it a named definition?
594 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
595 D.destroy(); // Free old strdup'd memory...
596 return N;
597 }
598 break;
599 default:
600 error("Internal parser error: Invalid symbol type reference");
601 return 0;
602 }
603
604 // If we reached here, we referenced either a symbol that we don't know about
605 // or an id number that hasn't been read yet. We may be referencing something
606 // forward, so just create an entry to be resolved later and get to it...
607 //
608 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
609
610
611 if (inFunctionScope()) {
612 if (D.Type == ValID::NameVal) {
613 error("Reference to an undefined type: '" + D.getName() + "'");
614 return 0;
615 } else {
616 error("Reference to an undefined type: #" + itostr(D.Num));
617 return 0;
618 }
619 }
620
621 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
622 if (I != CurModule.LateResolveTypes.end())
623 return I->second;
624
625 Type *Typ = OpaqueType::get();
626 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
627 return Typ;
628 }
629
630// getExistingValue - Look up the value specified by the provided type and
631// the provided ValID. If the value exists and has already been defined, return
632// it. Otherwise return null.
633//
634static Value *getExistingValue(const Type *Ty, const ValID &D) {
635 if (isa<FunctionType>(Ty)) {
636 error("Functions are not values and must be referenced as pointers");
637 }
638
639 switch (D.Type) {
640 case ValID::NumberVal: { // Is it a numbered definition?
641 unsigned Num = (unsigned)D.Num;
642
643 // Module constants occupy the lowest numbered slots...
644 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
645 if (VI != CurModule.Values.end()) {
646 if (Num < VI->second.size())
647 return VI->second[Num];
648 Num -= VI->second.size();
649 }
650
651 // Make sure that our type is within bounds
652 VI = CurFun.Values.find(Ty);
653 if (VI == CurFun.Values.end()) return 0;
654
655 // Check that the number is within bounds...
656 if (VI->second.size() <= Num) return 0;
657
658 return VI->second[Num];
659 }
660
661 case ValID::NameVal: { // Is it a named definition?
662 // Get the name out of the ID
663 std::string Name(D.Name);
664 Value* V = 0;
665 RenameMapKey Key = std::make_pair(Name, Ty);
666 if (inFunctionScope()) {
667 // See if the name was renamed
668 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
669 std::string LookupName;
670 if (I != CurFun.RenameMap.end())
671 LookupName = I->second;
672 else
673 LookupName = Name;
674 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
675 V = SymTab.lookup(Ty, LookupName);
676 }
677 if (!V) {
678 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
679 std::string LookupName;
680 if (I != CurModule.RenameMap.end())
681 LookupName = I->second;
682 else
683 LookupName = Name;
684 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
685 }
686 if (V == 0)
687 return 0;
688
689 D.destroy(); // Free old strdup'd memory...
690 return V;
691 }
692
693 // Check to make sure that "Ty" is an integral type, and that our
694 // value will fit into the specified type...
695 case ValID::ConstSIntVal: // Is it a constant pool reference??
696 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
697 error("Signed integral constant '" + itostr(D.ConstPool64) +
698 "' is invalid for type '" + Ty->getDescription() + "'");
699 }
700 return ConstantInt::get(Ty, D.ConstPool64);
701
702 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
703 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
704 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
705 error("Integral constant '" + utostr(D.UConstPool64) +
706 "' is invalid or out of range");
707 else // This is really a signed reference. Transmogrify.
708 return ConstantInt::get(Ty, D.ConstPool64);
709 } else
710 return ConstantInt::get(Ty, D.UConstPool64);
711
712 case ValID::ConstFPVal: // Is it a floating point const pool reference?
713 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
714 error("FP constant invalid for type");
715 return ConstantFP::get(Ty, D.ConstPoolFP);
716
717 case ValID::ConstNullVal: // Is it a null value?
718 if (!isa<PointerType>(Ty))
719 error("Cannot create a a non pointer null");
720 return ConstantPointerNull::get(cast<PointerType>(Ty));
721
722 case ValID::ConstUndefVal: // Is it an undef value?
723 return UndefValue::get(Ty);
724
725 case ValID::ConstZeroVal: // Is it a zero value?
726 return Constant::getNullValue(Ty);
727
728 case ValID::ConstantVal: // Fully resolved constant?
729 if (D.ConstantValue->getType() != Ty)
730 error("Constant expression type different from required type");
731 return D.ConstantValue;
732
733 case ValID::InlineAsmVal: { // Inline asm expression
734 const PointerType *PTy = dyn_cast<PointerType>(Ty);
735 const FunctionType *FTy =
736 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
737 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
738 error("Invalid type for asm constraint string");
739 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
740 D.IAD->HasSideEffects);
741 D.destroy(); // Free InlineAsmDescriptor.
742 return IA;
743 }
744 default:
745 assert(0 && "Unhandled case");
746 return 0;
747 } // End of switch
748
749 assert(0 && "Unhandled case");
750 return 0;
751}
752
753// getVal - This function is identical to getExistingValue, except that if a
754// value is not already defined, it "improvises" by creating a placeholder var
755// that looks and acts just like the requested variable. When the value is
756// defined later, all uses of the placeholder variable are replaced with the
757// real thing.
758//
759static Value *getVal(const Type *Ty, const ValID &ID) {
760 if (Ty == Type::LabelTy)
761 error("Cannot use a basic block here");
762
763 // See if the value has already been defined.
764 Value *V = getExistingValue(Ty, ID);
765 if (V) return V;
766
767 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
768 error("Invalid use of a composite type");
769
770 // If we reached here, we referenced either a symbol that we don't know about
771 // or an id number that hasn't been read yet. We may be referencing something
772 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000773 V = new Argument(Ty);
774
775 // Remember where this forward reference came from. FIXME, shouldn't we try
776 // to recycle these things??
777 CurModule.PlaceHolderInfo.insert(
778 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
779
780 if (inFunctionScope())
781 InsertValue(V, CurFun.LateResolveValues);
782 else
783 InsertValue(V, CurModule.LateResolveValues);
784 return V;
785}
786
787/// getBBVal - This is used for two purposes:
788/// * If isDefinition is true, a new basic block with the specified ID is being
789/// defined.
790/// * If isDefinition is true, this is a reference to a basic block, which may
791/// or may not be a forward reference.
792///
793static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
794 assert(inFunctionScope() && "Can't get basic block at global scope");
795
796 std::string Name;
797 BasicBlock *BB = 0;
798 switch (ID.Type) {
799 default:
800 error("Illegal label reference " + ID.getName());
801 break;
802 case ValID::NumberVal: // Is it a numbered definition?
803 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
804 CurFun.NumberedBlocks.resize(ID.Num+1);
805 BB = CurFun.NumberedBlocks[ID.Num];
806 break;
807 case ValID::NameVal: // Is it a named definition?
808 Name = ID.Name;
809 if (Value *N = CurFun.CurrentFunction->
810 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
811 if (N->getType() != Type::LabelTy)
812 error("Name '" + Name + "' does not refer to a BasicBlock");
813 BB = cast<BasicBlock>(N);
814 }
815 break;
816 }
817
818 // See if the block has already been defined.
819 if (BB) {
820 // If this is the definition of the block, make sure the existing value was
821 // just a forward reference. If it was a forward reference, there will be
822 // an entry for it in the PlaceHolderInfo map.
823 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
824 // The existing value was a definition, not a forward reference.
825 error("Redefinition of label " + ID.getName());
826
827 ID.destroy(); // Free strdup'd memory.
828 return BB;
829 }
830
831 // Otherwise this block has not been seen before.
832 BB = new BasicBlock("", CurFun.CurrentFunction);
833 if (ID.Type == ValID::NameVal) {
834 BB->setName(ID.Name);
835 } else {
836 CurFun.NumberedBlocks[ID.Num] = BB;
837 }
838
839 // If this is not a definition, keep track of it so we can use it as a forward
840 // reference.
841 if (!isDefinition) {
842 // Remember where this forward reference came from.
843 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
844 } else {
845 // The forward declaration could have been inserted anywhere in the
846 // function: insert it into the correct place now.
847 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
848 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
849 }
850 ID.destroy();
851 return BB;
852}
853
854
855//===----------------------------------------------------------------------===//
856// Code to handle forward references in instructions
857//===----------------------------------------------------------------------===//
858//
859// This code handles the late binding needed with statements that reference
860// values not defined yet... for example, a forward branch, or the PHI node for
861// a loop body.
862//
863// This keeps a table (CurFun.LateResolveValues) of all such forward references
864// and back patchs after we are done.
865//
866
867// ResolveDefinitions - If we could not resolve some defs at parsing
868// time (forward branches, phi functions for loops, etc...) resolve the
869// defs now...
870//
871static void
872ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
873 std::map<const Type*,ValueList> *FutureLateResolvers) {
874 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
875 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
876 E = LateResolvers.end(); LRI != E; ++LRI) {
877 ValueList &List = LRI->second;
878 while (!List.empty()) {
879 Value *V = List.back();
880 List.pop_back();
881
882 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
883 CurModule.PlaceHolderInfo.find(V);
884 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
885
886 ValID &DID = PHI->second.first;
887
888 Value *TheRealValue = getExistingValue(LRI->first, DID);
889 if (TheRealValue) {
890 V->replaceAllUsesWith(TheRealValue);
891 delete V;
892 CurModule.PlaceHolderInfo.erase(PHI);
893 } else if (FutureLateResolvers) {
894 // Functions have their unresolved items forwarded to the module late
895 // resolver table
896 InsertValue(V, *FutureLateResolvers);
897 } else {
898 if (DID.Type == ValID::NameVal) {
899 error("Reference to an invalid definition: '" +DID.getName()+
900 "' of type '" + V->getType()->getDescription() + "'",
901 PHI->second.second);
902 return;
903 } else {
904 error("Reference to an invalid definition: #" +
905 itostr(DID.Num) + " of type '" +
906 V->getType()->getDescription() + "'", PHI->second.second);
907 return;
908 }
909 }
910 }
911 }
912
913 LateResolvers.clear();
914}
915
916// ResolveTypeTo - A brand new type was just declared. This means that (if
917// name is not null) things referencing Name can be resolved. Otherwise, things
918// refering to the number can be resolved. Do this now.
919//
920static void ResolveTypeTo(char *Name, const Type *ToTy) {
921 ValID D;
922 if (Name) D = ValID::create(Name);
923 else D = ValID::create((int)CurModule.Types.size());
924
925 std::map<ValID, PATypeHolder>::iterator I =
926 CurModule.LateResolveTypes.find(D);
927 if (I != CurModule.LateResolveTypes.end()) {
928 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
929 CurModule.LateResolveTypes.erase(I);
930 }
931}
932
Reid Spencer3c0f6cf2007-01-28 00:52:05 +0000933/// @brief This just makes any name given to it unique, up to MAX_UINT times.
Reid Spencer950bf602007-01-26 08:19:09 +0000934static std::string makeNameUnique(const std::string& Name) {
935 static unsigned UniqueNameCounter = 1;
936 std::string Result(Name);
937 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
938 return Result;
939}
940
Reid Spencer3c0f6cf2007-01-28 00:52:05 +0000941/// This is the implementation portion of TypeHasInteger. It traverses the
942/// type given, avoiding recursive types, and returns true as soon as it finds
943/// an integer type. If no integer type is found, it returns false.
944static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
945 // Handle some easy cases
946 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
947 return false;
948 if (Ty->isInteger())
949 return true;
950 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
951 return STy->getElementType()->isInteger();
952
953 // Avoid type structure recursion
954 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
955 I != E; ++I)
956 if (Ty == *I)
957 return false;
958
959 // Push us on the type stack
960 Stack.push_back(Ty);
961
962 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
963 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
964 return true;
965 FunctionType::param_iterator I = FTy->param_begin();
966 FunctionType::param_iterator E = FTy->param_end();
967 for (; I != E; ++I)
968 if (TypeHasIntegerI(*I, Stack))
969 return true;
970 return false;
971 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
972 StructType::element_iterator I = STy->element_begin();
973 StructType::element_iterator E = STy->element_end();
974 for (; I != E; ++I) {
975 if (TypeHasIntegerI(*I, Stack))
976 return true;
977 }
978 return false;
979 }
980 // There shouldn't be anything else, but its definitely not integer
981 assert(0 && "What type is this?");
982 return false;
983}
984
985/// This is the interface to TypeHasIntegerI. It just provides the type stack,
986/// to avoid recursion, and then calls TypeHasIntegerI.
987static inline bool TypeHasInteger(const Type *Ty) {
988 std::vector<const Type*> TyStack;
989 return TypeHasIntegerI(Ty, TyStack);
990}
991
Reid Spencer950bf602007-01-26 08:19:09 +0000992// setValueName - Set the specified value to the name given. The name may be
993// null potentially, in which case this is a noop. The string passed in is
994// assumed to be a malloc'd string buffer, and is free'd by this function.
995//
996static void setValueName(Value *V, char *NameStr) {
997 if (NameStr) {
998 std::string Name(NameStr); // Copy string
999 free(NameStr); // Free old string
1000
1001 if (V->getType() == Type::VoidTy) {
1002 error("Can't assign name '" + Name + "' to value with void type");
1003 return;
1004 }
1005
Reid Spencer950bf602007-01-26 08:19:09 +00001006 assert(inFunctionScope() && "Must be in function scope");
1007
1008 // Search the function's symbol table for an existing value of this name
1009 Value* Existing = 0;
1010 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1011 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
1012 for ( ; PI != PE; ++PI) {
1013 SymbolTable::value_const_iterator VI = PI->second.find(Name);
1014 if (VI != PI->second.end()) {
1015 Existing = VI->second;
1016 break;
1017 }
1018 }
1019 if (Existing) {
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00001020 // An existing value of the same name was found. This might have happened
1021 // because of the integer type planes collapsing in LLVM 2.0.
1022 if (Existing->getType() == V->getType() &&
1023 !TypeHasInteger(Existing->getType())) {
1024 // If the type does not contain any integers in them then this can't be
1025 // a type plane collapsing issue. It truly is a redefinition and we
1026 // should error out as the assembly is invalid.
1027 error("Redefinition of value named '" + Name + "' of type '" +
1028 V->getType()->getDescription() + "'");
1029 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001030 }
1031 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1032 // function, regardless of Type. Previously re-use of names was okay as
1033 // long as they were distinct types. With type planes collapsing because
1034 // of the signedness change and because of PR411, this can no longer be
1035 // supported. We must search the entire symbol table for a conflicting
1036 // name and make the name unique. No warning is needed as this can't
1037 // cause a problem.
1038 std::string NewName = makeNameUnique(Name);
1039 // We're changing the name but it will probably be used by other
1040 // instructions as operands later on. Consequently we have to retain
1041 // a mapping of the renaming that we're doing.
1042 RenameMapKey Key = std::make_pair(Name,V->getType());
1043 CurFun.RenameMap[Key] = NewName;
1044 Name = NewName;
1045 }
1046
1047 // Set the name.
1048 V->setName(Name);
1049 }
1050}
1051
1052/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1053/// this is a declaration, otherwise it is a definition.
1054static GlobalVariable *
1055ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1056 bool isConstantGlobal, const Type *Ty,
1057 Constant *Initializer) {
1058 if (isa<FunctionType>(Ty))
1059 error("Cannot declare global vars of function type");
1060
1061 const PointerType *PTy = PointerType::get(Ty);
1062
1063 std::string Name;
1064 if (NameStr) {
1065 Name = NameStr; // Copy string
1066 free(NameStr); // Free old string
1067 }
1068
1069 // See if this global value was forward referenced. If so, recycle the
1070 // object.
1071 ValID ID;
1072 if (!Name.empty()) {
1073 ID = ValID::create((char*)Name.c_str());
1074 } else {
1075 ID = ValID::create((int)CurModule.Values[PTy].size());
1076 }
1077
1078 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1079 // Move the global to the end of the list, from whereever it was
1080 // previously inserted.
1081 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1082 CurModule.CurrentModule->getGlobalList().remove(GV);
1083 CurModule.CurrentModule->getGlobalList().push_back(GV);
1084 GV->setInitializer(Initializer);
1085 GV->setLinkage(Linkage);
1086 GV->setConstant(isConstantGlobal);
1087 InsertValue(GV, CurModule.Values);
1088 return GV;
1089 }
1090
1091 // If this global has a name, check to see if there is already a definition
1092 // of this global in the module and emit warnings if there are conflicts.
1093 if (!Name.empty()) {
1094 // The global has a name. See if there's an existing one of the same name.
1095 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1096 // We found an existing global ov the same name. This isn't allowed
1097 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1098 // can at least compile. This can happen because of type planes
1099 // There is alread a global of the same name which means there is a
1100 // conflict. Let's see what we can do about it.
1101 std::string NewName(makeNameUnique(Name));
1102 if (Linkage == GlobalValue::InternalLinkage) {
1103 // The linkage type is internal so just warn about the rename without
1104 // invoking "scarey language" about linkage failures. GVars with
1105 // InternalLinkage can be renamed at will.
1106 warning("Global variable '" + Name + "' was renamed to '"+
1107 NewName + "'");
1108 } else {
1109 // The linkage of this gval is external so we can't reliably rename
1110 // it because it could potentially create a linking problem.
1111 // However, we can't leave the name conflict in the output either or
1112 // it won't assemble with LLVM 2.0. So, all we can do is rename
1113 // this one to something unique and emit a warning about the problem.
1114 warning("Renaming global variable '" + Name + "' to '" + NewName +
1115 "' may cause linkage errors");
1116 }
1117
1118 // Put the renaming in the global rename map
1119 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1120 CurModule.RenameMap[Key] = NewName;
1121
1122 // Rename it
1123 Name = NewName;
1124 }
1125 }
1126
1127 // Otherwise there is no existing GV to use, create one now.
1128 GlobalVariable *GV =
1129 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1130 CurModule.CurrentModule);
1131 InsertValue(GV, CurModule.Values);
1132 return GV;
1133}
1134
1135// setTypeName - Set the specified type to the name given. The name may be
1136// null potentially, in which case this is a noop. The string passed in is
1137// assumed to be a malloc'd string buffer, and is freed by this function.
1138//
1139// This function returns true if the type has already been defined, but is
1140// allowed to be redefined in the specified context. If the name is a new name
1141// for the type plane, it is inserted and false is returned.
1142static bool setTypeName(const Type *T, char *NameStr) {
1143 assert(!inFunctionScope() && "Can't give types function-local names");
1144 if (NameStr == 0) return false;
1145
1146 std::string Name(NameStr); // Copy string
1147 free(NameStr); // Free old string
1148
1149 // We don't allow assigning names to void type
1150 if (T == Type::VoidTy) {
1151 error("Can't assign name '" + Name + "' to the void type");
1152 return false;
1153 }
1154
1155 // Set the type name, checking for conflicts as we do so.
1156 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1157
1158 if (AlreadyExists) { // Inserting a name that is already defined???
1159 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1160 assert(Existing && "Conflict but no matching type?");
1161
1162 // There is only one case where this is allowed: when we are refining an
1163 // opaque type. In this case, Existing will be an opaque type.
1164 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1165 // We ARE replacing an opaque type!
1166 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1167 return true;
1168 }
1169
1170 // Otherwise, this is an attempt to redefine a type. That's okay if
1171 // the redefinition is identical to the original. This will be so if
1172 // Existing and T point to the same Type object. In this one case we
1173 // allow the equivalent redefinition.
1174 if (Existing == T) return true; // Yes, it's equal.
1175
1176 // Any other kind of (non-equivalent) redefinition is an error.
1177 error("Redefinition of type named '" + Name + "' in the '" +
1178 T->getDescription() + "' type plane");
1179 }
1180
1181 return false;
1182}
1183
1184//===----------------------------------------------------------------------===//
1185// Code for handling upreferences in type names...
1186//
1187
1188// TypeContains - Returns true if Ty directly contains E in it.
1189//
1190static bool TypeContains(const Type *Ty, const Type *E) {
1191 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1192 E) != Ty->subtype_end();
1193}
1194
1195namespace {
1196 struct UpRefRecord {
1197 // NestingLevel - The number of nesting levels that need to be popped before
1198 // this type is resolved.
1199 unsigned NestingLevel;
1200
1201 // LastContainedTy - This is the type at the current binding level for the
1202 // type. Every time we reduce the nesting level, this gets updated.
1203 const Type *LastContainedTy;
1204
1205 // UpRefTy - This is the actual opaque type that the upreference is
1206 // represented with.
1207 OpaqueType *UpRefTy;
1208
1209 UpRefRecord(unsigned NL, OpaqueType *URTy)
1210 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1211 };
1212}
1213
1214// UpRefs - A list of the outstanding upreferences that need to be resolved.
1215static std::vector<UpRefRecord> UpRefs;
1216
1217/// HandleUpRefs - Every time we finish a new layer of types, this function is
1218/// called. It loops through the UpRefs vector, which is a list of the
1219/// currently active types. For each type, if the up reference is contained in
1220/// the newly completed type, we decrement the level count. When the level
1221/// count reaches zero, the upreferenced type is the type that is passed in:
1222/// thus we can complete the cycle.
1223///
1224static PATypeHolder HandleUpRefs(const Type *ty) {
1225 // If Ty isn't abstract, or if there are no up-references in it, then there is
1226 // nothing to resolve here.
1227 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1228
1229 PATypeHolder Ty(ty);
1230 UR_OUT("Type '" << Ty->getDescription() <<
1231 "' newly formed. Resolving upreferences.\n" <<
1232 UpRefs.size() << " upreferences active!\n");
1233
1234 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1235 // to zero), we resolve them all together before we resolve them to Ty. At
1236 // the end of the loop, if there is anything to resolve to Ty, it will be in
1237 // this variable.
1238 OpaqueType *TypeToResolve = 0;
1239
1240 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1241 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1242 << UpRefs[i].second->getDescription() << ") = "
1243 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1244 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1245 // Decrement level of upreference
1246 unsigned Level = --UpRefs[i].NestingLevel;
1247 UpRefs[i].LastContainedTy = Ty;
1248 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1249 if (Level == 0) { // Upreference should be resolved!
1250 if (!TypeToResolve) {
1251 TypeToResolve = UpRefs[i].UpRefTy;
1252 } else {
1253 UR_OUT(" * Resolving upreference for "
1254 << UpRefs[i].second->getDescription() << "\n";
1255 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1256 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1257 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1258 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1259 }
1260 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1261 --i; // Do not skip the next element...
1262 }
1263 }
1264 }
1265
1266 if (TypeToResolve) {
1267 UR_OUT(" * Resolving upreference for "
1268 << UpRefs[i].second->getDescription() << "\n";
1269 std::string OldName = TypeToResolve->getDescription());
1270 TypeToResolve->refineAbstractTypeTo(Ty);
1271 }
1272
1273 return Ty;
1274}
1275
1276static inline Instruction::TermOps
1277getTermOp(TermOps op) {
1278 switch (op) {
1279 default : assert(0 && "Invalid OldTermOp");
1280 case RetOp : return Instruction::Ret;
1281 case BrOp : return Instruction::Br;
1282 case SwitchOp : return Instruction::Switch;
1283 case InvokeOp : return Instruction::Invoke;
1284 case UnwindOp : return Instruction::Unwind;
1285 case UnreachableOp: return Instruction::Unreachable;
1286 }
1287}
1288
1289static inline Instruction::BinaryOps
1290getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1291 switch (op) {
1292 default : assert(0 && "Invalid OldBinaryOps");
1293 case SetEQ :
1294 case SetNE :
1295 case SetLE :
1296 case SetGE :
1297 case SetLT :
1298 case SetGT : assert(0 && "Should use getCompareOp");
1299 case AddOp : return Instruction::Add;
1300 case SubOp : return Instruction::Sub;
1301 case MulOp : return Instruction::Mul;
1302 case DivOp : {
1303 // This is an obsolete instruction so we must upgrade it based on the
1304 // types of its operands.
1305 bool isFP = Ty->isFloatingPoint();
1306 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1307 // If its a packed type we want to use the element type
1308 isFP = PTy->getElementType()->isFloatingPoint();
1309 if (isFP)
1310 return Instruction::FDiv;
1311 else if (Sign == Signed)
1312 return Instruction::SDiv;
1313 return Instruction::UDiv;
1314 }
1315 case UDivOp : return Instruction::UDiv;
1316 case SDivOp : return Instruction::SDiv;
1317 case FDivOp : return Instruction::FDiv;
1318 case RemOp : {
1319 // This is an obsolete instruction so we must upgrade it based on the
1320 // types of its operands.
1321 bool isFP = Ty->isFloatingPoint();
1322 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1323 // If its a packed type we want to use the element type
1324 isFP = PTy->getElementType()->isFloatingPoint();
1325 // Select correct opcode
1326 if (isFP)
1327 return Instruction::FRem;
1328 else if (Sign == Signed)
1329 return Instruction::SRem;
1330 return Instruction::URem;
1331 }
1332 case URemOp : return Instruction::URem;
1333 case SRemOp : return Instruction::SRem;
1334 case FRemOp : return Instruction::FRem;
1335 case AndOp : return Instruction::And;
1336 case OrOp : return Instruction::Or;
1337 case XorOp : return Instruction::Xor;
1338 }
1339}
1340
1341static inline Instruction::OtherOps
1342getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1343 Signedness Sign) {
1344 bool isSigned = Sign == Signed;
1345 bool isFP = Ty->isFloatingPoint();
1346 switch (op) {
1347 default : assert(0 && "Invalid OldSetCC");
1348 case SetEQ :
1349 if (isFP) {
1350 predicate = FCmpInst::FCMP_OEQ;
1351 return Instruction::FCmp;
1352 } else {
1353 predicate = ICmpInst::ICMP_EQ;
1354 return Instruction::ICmp;
1355 }
1356 case SetNE :
1357 if (isFP) {
1358 predicate = FCmpInst::FCMP_UNE;
1359 return Instruction::FCmp;
1360 } else {
1361 predicate = ICmpInst::ICMP_NE;
1362 return Instruction::ICmp;
1363 }
1364 case SetLE :
1365 if (isFP) {
1366 predicate = FCmpInst::FCMP_OLE;
1367 return Instruction::FCmp;
1368 } else {
1369 if (isSigned)
1370 predicate = ICmpInst::ICMP_SLE;
1371 else
1372 predicate = ICmpInst::ICMP_ULE;
1373 return Instruction::ICmp;
1374 }
1375 case SetGE :
1376 if (isFP) {
1377 predicate = FCmpInst::FCMP_OGE;
1378 return Instruction::FCmp;
1379 } else {
1380 if (isSigned)
1381 predicate = ICmpInst::ICMP_SGE;
1382 else
1383 predicate = ICmpInst::ICMP_UGE;
1384 return Instruction::ICmp;
1385 }
1386 case SetLT :
1387 if (isFP) {
1388 predicate = FCmpInst::FCMP_OLT;
1389 return Instruction::FCmp;
1390 } else {
1391 if (isSigned)
1392 predicate = ICmpInst::ICMP_SLT;
1393 else
1394 predicate = ICmpInst::ICMP_ULT;
1395 return Instruction::ICmp;
1396 }
1397 case SetGT :
1398 if (isFP) {
1399 predicate = FCmpInst::FCMP_OGT;
1400 return Instruction::FCmp;
1401 } else {
1402 if (isSigned)
1403 predicate = ICmpInst::ICMP_SGT;
1404 else
1405 predicate = ICmpInst::ICMP_UGT;
1406 return Instruction::ICmp;
1407 }
1408 }
1409}
1410
1411static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1412 switch (op) {
1413 default : assert(0 && "Invalid OldMemoryOps");
1414 case MallocOp : return Instruction::Malloc;
1415 case FreeOp : return Instruction::Free;
1416 case AllocaOp : return Instruction::Alloca;
1417 case LoadOp : return Instruction::Load;
1418 case StoreOp : return Instruction::Store;
1419 case GetElementPtrOp : return Instruction::GetElementPtr;
1420 }
1421}
1422
1423static inline Instruction::OtherOps
1424getOtherOp(OtherOps op, Signedness Sign) {
1425 switch (op) {
1426 default : assert(0 && "Invalid OldOtherOps");
1427 case PHIOp : return Instruction::PHI;
1428 case CallOp : return Instruction::Call;
1429 case ShlOp : return Instruction::Shl;
1430 case ShrOp :
1431 if (Sign == Signed)
1432 return Instruction::AShr;
1433 return Instruction::LShr;
1434 case SelectOp : return Instruction::Select;
1435 case UserOp1 : return Instruction::UserOp1;
1436 case UserOp2 : return Instruction::UserOp2;
1437 case VAArg : return Instruction::VAArg;
1438 case ExtractElementOp : return Instruction::ExtractElement;
1439 case InsertElementOp : return Instruction::InsertElement;
1440 case ShuffleVectorOp : return Instruction::ShuffleVector;
1441 case ICmpOp : return Instruction::ICmp;
1442 case FCmpOp : return Instruction::FCmp;
1443 case LShrOp : return Instruction::LShr;
1444 case AShrOp : return Instruction::AShr;
1445 };
1446}
1447
1448static inline Value*
1449getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1450 Signedness DstSign, bool ForceInstruction = false) {
1451 Instruction::CastOps Opcode;
1452 const Type* SrcTy = Src->getType();
1453 if (op == CastOp) {
1454 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1455 // fp -> ptr cast is no longer supported but we must upgrade this
1456 // by doing a double cast: fp -> int -> ptr
1457 SrcTy = Type::Int64Ty;
1458 Opcode = Instruction::IntToPtr;
1459 if (isa<Constant>(Src)) {
1460 Src = ConstantExpr::getCast(Instruction::FPToUI,
1461 cast<Constant>(Src), SrcTy);
1462 } else {
1463 std::string NewName(makeNameUnique(Src->getName()));
1464 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1465 }
1466 } else if (isa<IntegerType>(DstTy) &&
1467 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1468 // cast type %x to bool was previously defined as setne type %x, null
1469 // The cast semantic is now to truncate, not compare so we must retain
1470 // the original intent by replacing the cast with a setne
1471 Constant* Null = Constant::getNullValue(SrcTy);
1472 Instruction::OtherOps Opcode = Instruction::ICmp;
1473 unsigned short predicate = ICmpInst::ICMP_NE;
1474 if (SrcTy->isFloatingPoint()) {
1475 Opcode = Instruction::FCmp;
1476 predicate = FCmpInst::FCMP_ONE;
1477 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1478 error("Invalid cast to bool");
1479 }
1480 if (isa<Constant>(Src) && !ForceInstruction)
1481 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1482 else
1483 return CmpInst::create(Opcode, predicate, Src, Null);
1484 }
1485 // Determine the opcode to use by calling CastInst::getCastOpcode
1486 Opcode =
1487 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1488
1489 } else switch (op) {
1490 default: assert(0 && "Invalid cast token");
1491 case TruncOp: Opcode = Instruction::Trunc; break;
1492 case ZExtOp: Opcode = Instruction::ZExt; break;
1493 case SExtOp: Opcode = Instruction::SExt; break;
1494 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1495 case FPExtOp: Opcode = Instruction::FPExt; break;
1496 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1497 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1498 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1499 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1500 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1501 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1502 case BitCastOp: Opcode = Instruction::BitCast; break;
1503 }
1504
1505 if (isa<Constant>(Src) && !ForceInstruction)
1506 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1507 return CastInst::create(Opcode, Src, DstTy);
1508}
1509
1510static Instruction *
1511upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1512 std::vector<Value*>& Args) {
1513
1514 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1515 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1516 if (Args.size() != 2)
1517 error("Invalid prototype for " + Name + " prototype");
1518 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1519 } else {
1520 static unsigned upgradeCount = 1;
1521 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1522 std::vector<const Type*> Params;
1523 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1524 if (Args.size() != 1)
1525 error("Invalid prototype for " + Name + " prototype");
1526 Params.push_back(PtrTy);
1527 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1528 const PointerType *PFTy = PointerType::get(FTy);
1529 Value* Func = getVal(PFTy, ID);
1530 std::string InstName("va_upgrade");
1531 InstName += llvm::utostr(upgradeCount++);
1532 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1533 return new CallInst(Func, Args);
1534 } else if (Name == "llvm.va_copy") {
1535 if (Args.size() != 2)
1536 error("Invalid prototype for " + Name + " prototype");
1537 Params.push_back(PtrTy);
1538 Params.push_back(PtrTy);
1539 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1540 const PointerType *PFTy = PointerType::get(FTy);
1541 Value* Func = getVal(PFTy, ID);
1542 std::string InstName0("va_upgrade");
1543 InstName0 += llvm::utostr(upgradeCount++);
1544 std::string InstName1("va_upgrade");
1545 InstName1 += llvm::utostr(upgradeCount++);
1546 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1547 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1548 return new CallInst(Func, Args);
1549 }
1550 }
1551 return 0;
1552}
1553
1554const Type* upgradeGEPIndices(const Type* PTy,
1555 std::vector<ValueInfo> *Indices,
1556 std::vector<Value*> &VIndices,
1557 std::vector<Constant*> *CIndices = 0) {
1558 // Traverse the indices with a gep_type_iterator so we can build the list
1559 // of constant and value indices for use later. Also perform upgrades
1560 VIndices.clear();
1561 if (CIndices) CIndices->clear();
1562 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1563 VIndices.push_back((*Indices)[i].V);
1564 generic_gep_type_iterator<std::vector<Value*>::iterator>
1565 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1566 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1567 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1568 Value *Index = VIndices[i];
1569 if (CIndices && !isa<Constant>(Index))
1570 error("Indices to constant getelementptr must be constants");
1571 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1572 // struct indices to i32 struct indices with ZExt for compatibility.
1573 else if (isa<StructType>(*GTI)) { // Only change struct indices
1574 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1575 if (CUI->getType()->getBitWidth() == 8)
1576 Index =
1577 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1578 } else {
1579 // Make sure that unsigned SequentialType indices are zext'd to
1580 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1581 // all indices for SequentialType elements. We must retain the same
1582 // semantic (zext) for unsigned types.
1583 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001584 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001585 if (CIndices)
1586 Index = ConstantExpr::getCast(Instruction::ZExt,
1587 cast<Constant>(Index), Type::Int64Ty);
1588 else
1589 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencerd7c4f8c2007-01-26 19:59:25 +00001590 makeNameUnique("gep_upgrade"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001591 VIndices[i] = Index;
1592 }
Reid Spencer950bf602007-01-26 08:19:09 +00001593 }
1594 // Add to the CIndices list, if requested.
1595 if (CIndices)
1596 CIndices->push_back(cast<Constant>(Index));
1597 }
1598
1599 const Type *IdxTy =
1600 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1601 if (!IdxTy)
1602 error("Index list invalid for constant getelementptr");
1603 return IdxTy;
1604}
1605
1606Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1607 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001608{
1609 Upgradelineno = 1;
1610 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001611 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001612 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001613 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001614 ObsoleteVarArgs = false;
1615 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001616
Reid Spencer950bf602007-01-26 08:19:09 +00001617 CurModule.CurrentModule = new Module(CurFilename);
1618
1619 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001620 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001621 if (ParserResult)
1622 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001623 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001624 return 0;
1625 }
1626
Reid Spencer950bf602007-01-26 08:19:09 +00001627 // Check to make sure that parsing produced a result
1628 if (!ParserResult) {
1629 std::cerr << "llvm-upgrade: no parse result.\n";
1630 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001631 }
1632
Reid Spencer950bf602007-01-26 08:19:09 +00001633 // Reset ParserResult variable while saving its value for the result.
1634 Module *Result = ParserResult;
1635 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001636
Reid Spencer950bf602007-01-26 08:19:09 +00001637 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001638 {
Reid Spencer950bf602007-01-26 08:19:09 +00001639 Function* F;
1640 if ((F = Result->getNamedFunction("llvm.va_start"))
1641 && F->getFunctionType()->getNumParams() == 0)
1642 ObsoleteVarArgs = true;
1643 if((F = Result->getNamedFunction("llvm.va_copy"))
1644 && F->getFunctionType()->getNumParams() == 1)
1645 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001646 }
Reid Spencer319a7302007-01-05 17:20:02 +00001647
Reid Spencer950bf602007-01-26 08:19:09 +00001648 if (ObsoleteVarArgs && NewVarArgs) {
1649 error("This file is corrupt: it uses both new and old style varargs");
1650 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001651 }
Reid Spencer319a7302007-01-05 17:20:02 +00001652
Reid Spencer950bf602007-01-26 08:19:09 +00001653 if(ObsoleteVarArgs) {
1654 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1655 if (F->arg_size() != 0) {
1656 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001657 return 0;
1658 }
Reid Spencer950bf602007-01-26 08:19:09 +00001659
1660 //foo = va_start()
1661 // ->
1662 //bar = alloca typeof(foo)
1663 //va_start(bar)
1664 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001665
Reid Spencer950bf602007-01-26 08:19:09 +00001666 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1667 const Type* ArgTy = F->getFunctionType()->getReturnType();
1668 const Type* ArgTyPtr = PointerType::get(ArgTy);
1669 Function* NF = cast<Function>(Result->getOrInsertFunction(
1670 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1671
1672 while (!F->use_empty()) {
1673 CallInst* CI = cast<CallInst>(F->use_back());
1674 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1675 new CallInst(NF, bar, "", CI);
1676 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1677 CI->replaceAllUsesWith(foo);
1678 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001679 }
Reid Spencer950bf602007-01-26 08:19:09 +00001680 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001681 }
Reid Spencer950bf602007-01-26 08:19:09 +00001682
1683 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1684 if(F->arg_size() != 1) {
1685 error("Obsolete va_end takes 1 argument");
1686 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001687 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001688
Reid Spencer950bf602007-01-26 08:19:09 +00001689 //vaend foo
1690 // ->
1691 //bar = alloca 1 of typeof(foo)
1692 //vaend bar
1693 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1694 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1695 const Type* ArgTyPtr = PointerType::get(ArgTy);
1696 Function* NF = cast<Function>(Result->getOrInsertFunction(
1697 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001698
Reid Spencer950bf602007-01-26 08:19:09 +00001699 while (!F->use_empty()) {
1700 CallInst* CI = cast<CallInst>(F->use_back());
1701 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1702 new StoreInst(CI->getOperand(1), bar, CI);
1703 new CallInst(NF, bar, "", CI);
1704 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001705 }
Reid Spencer950bf602007-01-26 08:19:09 +00001706 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001707 }
Reid Spencer950bf602007-01-26 08:19:09 +00001708
1709 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1710 if(F->arg_size() != 1) {
1711 error("Obsolete va_copy takes 1 argument");
1712 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001713 }
Reid Spencer950bf602007-01-26 08:19:09 +00001714 //foo = vacopy(bar)
1715 // ->
1716 //a = alloca 1 of typeof(foo)
1717 //b = alloca 1 of typeof(foo)
1718 //store bar -> b
1719 //vacopy(a, b)
1720 //foo = load a
1721
1722 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1723 const Type* ArgTy = F->getFunctionType()->getReturnType();
1724 const Type* ArgTyPtr = PointerType::get(ArgTy);
1725 Function* NF = cast<Function>(Result->getOrInsertFunction(
1726 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001727
Reid Spencer950bf602007-01-26 08:19:09 +00001728 while (!F->use_empty()) {
1729 CallInst* CI = cast<CallInst>(F->use_back());
1730 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1731 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1732 new StoreInst(CI->getOperand(1), b, CI);
1733 new CallInst(NF, a, b, "", CI);
1734 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1735 CI->replaceAllUsesWith(foo);
1736 CI->getParent()->getInstList().erase(CI);
1737 }
1738 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001739 }
1740 }
1741
Reid Spencer52402b02007-01-02 05:45:11 +00001742 return Result;
1743}
1744
Reid Spencer950bf602007-01-26 08:19:09 +00001745} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001746
Reid Spencer950bf602007-01-26 08:19:09 +00001747using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001748
1749
Reid Spencer319a7302007-01-05 17:20:02 +00001750
1751/* Enabling traces. */
1752#ifndef YYDEBUG
1753# define YYDEBUG 0
1754#endif
1755
1756/* Enabling verbose error messages. */
1757#ifdef YYERROR_VERBOSE
1758# undef YYERROR_VERBOSE
1759# define YYERROR_VERBOSE 1
1760#else
1761# define YYERROR_VERBOSE 0
1762#endif
1763
Reid Spencer950bf602007-01-26 08:19:09 +00001764/* Enabling the token table. */
1765#ifndef YYTOKEN_TABLE
1766# define YYTOKEN_TABLE 0
1767#endif
1768
1769#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00001770#line 1391 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00001771typedef union YYSTYPE {
1772 llvm::Module *ModuleVal;
1773 llvm::Function *FunctionVal;
1774 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1775 llvm::BasicBlock *BasicBlockVal;
1776 llvm::TerminatorInst *TermInstVal;
1777 llvm::InstrInfo InstVal;
1778 llvm::ConstInfo ConstVal;
1779 llvm::ValueInfo ValueVal;
1780 llvm::PATypeInfo TypeVal;
1781 llvm::TypeInfo PrimType;
1782 llvm::PHIListInfo PHIList;
1783 std::list<llvm::PATypeInfo> *TypeList;
1784 std::vector<llvm::ValueInfo> *ValueList;
1785 std::vector<llvm::ConstInfo> *ConstVector;
1786
1787
1788 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1789 // Represent the RHS of PHI node
1790 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1791
1792 llvm::GlobalValue::LinkageTypes Linkage;
1793 int64_t SInt64Val;
1794 uint64_t UInt64Val;
1795 int SIntVal;
1796 unsigned UIntVal;
1797 double FPVal;
1798 bool BoolVal;
1799
1800 char *StrVal; // This memory is strdup'd!
1801 llvm::ValID ValIDVal; // strdup'd memory maybe!
1802
1803 llvm::BinaryOps BinaryOpVal;
1804 llvm::TermOps TermOpVal;
1805 llvm::MemoryOps MemOpVal;
1806 llvm::OtherOps OtherOpVal;
1807 llvm::CastOps CastOpVal;
1808 llvm::ICmpInst::Predicate IPred;
1809 llvm::FCmpInst::Predicate FPred;
1810 llvm::Module::Endianness Endianness;
1811} YYSTYPE;
1812/* Line 196 of yacc.c. */
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00001813#line 1814 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001814# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1815# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001816# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001817#endif
1818
Reid Spencer950bf602007-01-26 08:19:09 +00001819
Reid Spencere7c3c602006-11-30 06:36:44 +00001820
Reid Spencer319a7302007-01-05 17:20:02 +00001821/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001822
1823
Reid Spencer950bf602007-01-26 08:19:09 +00001824/* Line 219 of yacc.c. */
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00001825#line 1826 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001826
1827#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1828# define YYSIZE_T __SIZE_TYPE__
1829#endif
1830#if ! defined (YYSIZE_T) && defined (size_t)
1831# define YYSIZE_T size_t
1832#endif
1833#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1834# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1835# define YYSIZE_T size_t
1836#endif
1837#if ! defined (YYSIZE_T)
1838# define YYSIZE_T unsigned int
1839#endif
1840
1841#ifndef YY_
1842# if YYENABLE_NLS
1843# if ENABLE_NLS
1844# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1845# define YY_(msgid) dgettext ("bison-runtime", msgid)
1846# endif
1847# endif
1848# ifndef YY_
1849# define YY_(msgid) msgid
1850# endif
1851#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001852
1853#if ! defined (yyoverflow) || YYERROR_VERBOSE
1854
1855/* The parser invokes alloca or malloc; define the necessary symbols. */
1856
Reid Spencer950bf602007-01-26 08:19:09 +00001857# ifdef YYSTACK_USE_ALLOCA
1858# if YYSTACK_USE_ALLOCA
1859# ifdef __GNUC__
1860# define YYSTACK_ALLOC __builtin_alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001861# else
Reid Spencer950bf602007-01-26 08:19:09 +00001862# define YYSTACK_ALLOC alloca
1863# if defined (__STDC__) || defined (__cplusplus)
1864# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1865# define YYINCLUDED_STDLIB_H
Reid Spencer319a7302007-01-05 17:20:02 +00001866# endif
1867# endif
1868# endif
1869# endif
1870
1871# ifdef YYSTACK_ALLOC
1872 /* Pacify GCC's `empty if-body' warning. */
1873# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00001874# ifndef YYSTACK_ALLOC_MAXIMUM
1875 /* The OS might guarantee only one guard page at the bottom of the stack,
1876 and a page size can be as small as 4096 bytes. So we cannot safely
1877 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1878 to allow for a few compiler-allocated temporary stack slots. */
1879# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer319a7302007-01-05 17:20:02 +00001880# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001881# else
1882# define YYSTACK_ALLOC YYMALLOC
1883# define YYSTACK_FREE YYFREE
1884# ifndef YYSTACK_ALLOC_MAXIMUM
1885# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1886# endif
1887# ifdef __cplusplus
1888extern "C" {
1889# endif
1890# ifndef YYMALLOC
1891# define YYMALLOC malloc
1892# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1893 && (defined (__STDC__) || defined (__cplusplus)))
1894void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1895# endif
1896# endif
1897# ifndef YYFREE
1898# define YYFREE free
1899# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1900 && (defined (__STDC__) || defined (__cplusplus)))
1901void free (void *); /* INFRINGES ON USER NAME SPACE */
1902# endif
1903# endif
1904# ifdef __cplusplus
1905}
1906# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001907# endif
1908#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1909
1910
1911#if (! defined (yyoverflow) \
1912 && (! defined (__cplusplus) \
Reid Spencer950bf602007-01-26 08:19:09 +00001913 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001914
1915/* A type that is properly aligned for any stack member. */
1916union yyalloc
1917{
Reid Spencer950bf602007-01-26 08:19:09 +00001918 short int yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001919 YYSTYPE yyvs;
1920 };
1921
1922/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00001923# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00001924
1925/* The size of an array large to enough to hold all stacks, each with
1926 N elements. */
1927# define YYSTACK_BYTES(N) \
Reid Spencer950bf602007-01-26 08:19:09 +00001928 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1929 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00001930
1931/* Copy COUNT objects from FROM to TO. The source and destination do
1932 not overlap. */
1933# ifndef YYCOPY
Reid Spencer950bf602007-01-26 08:19:09 +00001934# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00001935# define YYCOPY(To, From, Count) \
1936 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1937# else
1938# define YYCOPY(To, From, Count) \
1939 do \
1940 { \
Reid Spencer950bf602007-01-26 08:19:09 +00001941 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00001942 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00001943 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00001944 } \
1945 while (0)
1946# endif
1947# endif
1948
1949/* Relocate STACK from its old location to the new one. The
1950 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1951 elements in the stack, and YYPTR gives the new location of the
1952 stack. Advance YYPTR to a properly aligned location for the next
1953 stack. */
1954# define YYSTACK_RELOCATE(Stack) \
1955 do \
1956 { \
1957 YYSIZE_T yynewbytes; \
1958 YYCOPY (&yyptr->Stack, Stack, yysize); \
1959 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00001960 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00001961 yyptr += yynewbytes / sizeof (*yyptr); \
1962 } \
1963 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00001964
1965#endif
1966
Reid Spencer319a7302007-01-05 17:20:02 +00001967#if defined (__STDC__) || defined (__cplusplus)
1968 typedef signed char yysigned_char;
Reid Spencere7c3c602006-11-30 06:36:44 +00001969#else
Reid Spencer950bf602007-01-26 08:19:09 +00001970 typedef short int yysigned_char;
Reid Spencere7c3c602006-11-30 06:36:44 +00001971#endif
1972
Reid Spencer319a7302007-01-05 17:20:02 +00001973/* YYFINAL -- State number of the termination state. */
1974#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00001975/* YYLAST -- Last index in YYTABLE. */
1976#define YYLAST 1712
Reid Spencer319a7302007-01-05 17:20:02 +00001977
1978/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00001979#define YYNTOKENS 166
Reid Spencer319a7302007-01-05 17:20:02 +00001980/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00001981#define YYNNTS 79
Reid Spencer319a7302007-01-05 17:20:02 +00001982/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00001983#define YYNRULES 308
Reid Spencer319a7302007-01-05 17:20:02 +00001984/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00001985#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00001986
1987/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1988#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00001989#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00001990
Reid Spencer950bf602007-01-26 08:19:09 +00001991#define YYTRANSLATE(YYX) \
1992 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00001993
1994/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1995static const unsigned char yytranslate[] =
1996{
1997 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1998 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1999 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2000 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002001 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002002 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002003 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002004 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2005 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002006 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002007 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2008 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002009 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002010 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2011 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2012 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2013 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2014 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2015 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2016 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2017 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2018 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2019 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2020 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2021 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2022 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2023 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2024 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2025 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2026 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2027 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2028 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2029 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2030 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2031 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2032 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2033 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2034 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2035 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2036 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002037 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002038};
2039
2040#if YYDEBUG
2041/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2042 YYRHS. */
Reid Spencer950bf602007-01-26 08:19:09 +00002043static const unsigned short int yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002044{
2045 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2046 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2047 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2048 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2049 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2050 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2051 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2052 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2053 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002054 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002055 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2056 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2057 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2058 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2059 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002060 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2061 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2062 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2063 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2064 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2065 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2066 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2067 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2068 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2069 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2070 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2071 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2072 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2073 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2074 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2075 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002076};
2077
2078/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Reid Spencer950bf602007-01-26 08:19:09 +00002079static const short int yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002080{
Reid Spencer950bf602007-01-26 08:19:09 +00002081 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002082 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2083 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2084 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2085 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
Reid Spencer950bf602007-01-26 08:19:09 +00002086 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2087 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2088 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2089 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2090 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2091 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2092 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2093 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2094 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2095 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2096 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2097 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2098 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2099 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2100 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2101 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2102 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2103 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002104 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002105 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2106 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2107 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2108 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2109 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2110 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2111 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2112 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2113 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2114 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2115 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2116 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2117 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2118 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2119 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2120 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2121 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2122 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2123 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2124 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2125 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2126 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2127 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2128 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2129 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2130 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2131 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2132 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2133 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2134 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2135 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2136 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2137 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2138 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2139 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2140 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2141 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2142 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2143 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2144 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2145 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2146 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2147 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2148 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2149 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2150 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2151 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2152 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2153 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2154 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2155 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2156 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2157 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2158 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2159 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2160 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2161 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2162 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2163 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2164 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2165 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2166 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2167 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2168 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2169 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2170 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2171 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2172 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2173 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2174 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2175 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2176 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2177 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002178};
2179
2180/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencer950bf602007-01-26 08:19:09 +00002181static const unsigned short int yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002182{
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00002183 0, 1531, 1531, 1532, 1540, 1541, 1551, 1551, 1551, 1551,
2184 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1555, 1555, 1555,
2185 1559, 1559, 1559, 1559, 1559, 1559, 1563, 1563, 1564, 1564,
2186 1565, 1565, 1566, 1566, 1567, 1567, 1571, 1571, 1572, 1572,
2187 1573, 1573, 1574, 1574, 1575, 1575, 1576, 1576, 1577, 1577,
2188 1578, 1579, 1582, 1582, 1582, 1582, 1586, 1586, 1586, 1586,
2189 1586, 1586, 1586, 1587, 1587, 1587, 1587, 1587, 1587, 1593,
2190 1593, 1593, 1593, 1597, 1597, 1597, 1597, 1601, 1601, 1605,
2191 1605, 1610, 1613, 1618, 1619, 1620, 1621, 1622, 1623, 1624,
2192 1625, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1646,
2193 1647, 1655, 1656, 1664, 1673, 1674, 1681, 1682, 1686, 1690,
2194 1706, 1707, 1714, 1715, 1722, 1730, 1730, 1730, 1730, 1730,
2195 1730, 1730, 1731, 1731, 1731, 1731, 1731, 1736, 1740, 1744,
2196 1749, 1758, 1774, 1780, 1793, 1802, 1806, 1817, 1821, 1834,
2197 1838, 1845, 1846, 1852, 1859, 1871, 1901, 1914, 1937, 1965,
2198 1987, 1998, 2020, 2031, 2040, 2045, 2103, 2110, 2118, 2125,
2199 2132, 2136, 2140, 2149, 2164, 2177, 2186, 2214, 2227, 2236,
2200 2242, 2248, 2257, 2263, 2269, 2280, 2281, 2290, 2291, 2303,
2201 2312, 2313, 2314, 2315, 2316, 2332, 2352, 2354, 2356, 2356,
2202 2363, 2363, 2370, 2370, 2377, 2377, 2385, 2387, 2389, 2394,
2203 2408, 2409, 2413, 2416, 2424, 2428, 2435, 2439, 2443, 2447,
2204 2455, 2455, 2459, 2460, 2464, 2472, 2477, 2485, 2486, 2493,
2205 2500, 2504, 2610, 2610, 2614, 2624, 2624, 2628, 2632, 2634,
2206 2635, 2639, 2639, 2651, 2652, 2657, 2658, 2659, 2660, 2661,
2207 2662, 2663, 2664, 2665, 2686, 2689, 2704, 2705, 2710, 2710,
2208 2718, 2727, 2730, 2739, 2749, 2754, 2763, 2774, 2774, 2777,
2209 2780, 2783, 2787, 2793, 2808, 2814, 2865, 2868, 2874, 2884,
2210 2897, 2926, 2934, 2942, 2946, 2953, 2954, 2958, 2961, 2967,
2211 2984, 3000, 3014, 3026, 3038, 3049, 3058, 3067, 3076, 3083,
2212 3104, 3128, 3134, 3140, 3146, 3162, 3235, 3243, 3244, 3248,
2213 3249, 3253, 3259, 3265, 3271, 3277, 3284, 3296, 3310
Reid Spencer319a7302007-01-05 17:20:02 +00002214};
2215#endif
2216
Reid Spencer950bf602007-01-26 08:19:09 +00002217#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2218/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencer319a7302007-01-05 17:20:02 +00002219 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2220static const char *const yytname[] =
2221{
Reid Spencer950bf602007-01-26 08:19:09 +00002222 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2223 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2224 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2225 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2226 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2227 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2228 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2229 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2230 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2231 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2232 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2233 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2234 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2235 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2236 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2237 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2238 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2239 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2240 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2241 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2242 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2243 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2244 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2245 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2246 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2247 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2248 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2249 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2250 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2251 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2252 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2253 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2254 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2255 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2256 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2257 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2258 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2259 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2260 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002261 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002262};
2263#endif
2264
2265# ifdef YYPRINT
2266/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2267 token YYLEX-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002268static const unsigned short int yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002269{
2270 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2271 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2272 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2273 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2274 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2275 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2276 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2277 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2278 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2279 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2280 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2281 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2282 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2283 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2284 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002285 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2286 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002287};
2288# endif
2289
2290/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2291static const unsigned char yyr1[] =
2292{
Reid Spencer950bf602007-01-26 08:19:09 +00002293 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2294 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2295 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2296 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2297 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2298 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2299 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2300 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2301 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2302 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2303 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2304 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2305 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2306 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2307 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2308 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2309 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2310 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2311 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2312 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2313 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2314 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2315 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2316 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2317 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2318 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2319 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2320 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2321 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2322 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2323 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002324};
2325
2326/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2327static const unsigned char yyr2[] =
2328{
2329 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2330 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2331 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2332 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2333 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2334 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2335 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2336 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2337 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002338 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002339 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2340 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2341 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2342 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2343 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002344 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2345 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2346 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2347 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2348 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2349 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2350 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2351 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2352 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2353 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2354 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2355 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2356 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2357 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2358 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2359 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002360};
2361
2362/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2363 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2364 means the default is an error. */
Reid Spencer950bf602007-01-26 08:19:09 +00002365static const unsigned short int yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002366{
Reid Spencer950bf602007-01-26 08:19:09 +00002367 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2368 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2369 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2370 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2371 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2372 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2373 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2374 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2375 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2376 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2377 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2378 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2379 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2380 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2381 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2382 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2383 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2384 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2385 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2386 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2387 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2388 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2389 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2390 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2391 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2392 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2393 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2394 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2395 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002396 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002397 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2398 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002399 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002400 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2401 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2402 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2403 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2404 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2405 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2406 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2407 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2408 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2409 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2410 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2411 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2412 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2413 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2414 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2415 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2416 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2417 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2418 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2419 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2420 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2421 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2422 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2423 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2424 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2425 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2426 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2427 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002428};
2429
2430/* YYDEFGOTO[NTERM-NUM]. */
Reid Spencer950bf602007-01-26 08:19:09 +00002431static const short int yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002432{
Reid Spencer950bf602007-01-26 08:19:09 +00002433 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2434 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2435 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2436 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2437 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2438 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2439 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2440 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002441};
2442
2443/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2444 STATE-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002445#define YYPACT_NINF -508
2446static const short int yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002447{
Reid Spencer950bf602007-01-26 08:19:09 +00002448 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2449 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2450 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2451 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2452 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2453 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2454 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2455 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2456 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2457 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2458 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2459 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2460 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2461 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2462 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2463 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2464 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2465 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2466 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2467 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2468 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2469 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2470 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2471 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2472 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2473 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2474 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2475 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2476 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2477 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2478 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2479 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2480 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2481 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2482 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2483 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2484 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2485 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2486 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2487 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2488 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2489 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2490 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2491 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2492 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2493 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2494 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2495 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2496 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2497 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2498 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2499 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2500 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2501 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2502 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2503 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2504 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2505 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2506 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2507 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2508 898, 898, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002509};
2510
2511/* YYPGOTO[NTERM-NUM]. */
Reid Spencer950bf602007-01-26 08:19:09 +00002512static const short int yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002513{
Reid Spencer950bf602007-01-26 08:19:09 +00002514 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2515 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2516 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2517 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2518 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2519 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2520 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2521 -508, -508, 43, -22, -508, -508, 21, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002522};
2523
2524/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2525 positive, shift that token. If negative, reduce the rule which
2526 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002527 If YYTABLE_NINF, syntax error. */
2528#define YYTABLE_NINF -180
2529static const short int yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002530{
Reid Spencer950bf602007-01-26 08:19:09 +00002531 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2532 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2533 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2534 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2535 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2536 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2537 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2538 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2539 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2540 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2541 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2542 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2543 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2544 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2545 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2546 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2547 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2548 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2549 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2550 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2551 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2552 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2553 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2554 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2555 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2556 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2557 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2558 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2559 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2560 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2561 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2562 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2563 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2564 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2565 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2566 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2567 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2568 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2569 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2570 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2571 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2572 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2573 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2574 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2575 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2576 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2577 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2578 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2579 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2580 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2581 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2582 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2583 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2584 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2585 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2586 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2587 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2588 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2589 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2590 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2591 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2592 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2593 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2594 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2595 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2596 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2597 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2598 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2599 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2600 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2601 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2602 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2603 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2604 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2605 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2606 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2607 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2608 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2609 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2610 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2611 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2612 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2613 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
Reid Spencerc4d96252007-01-13 00:03:30 +00002614 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002615 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2616 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2617 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2618 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002619 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002620 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2621 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2622 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2623 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2624 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2625 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2626 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2627 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2628 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2629 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2630 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2631 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2632 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2633 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2634 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2635 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2636 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2637 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2638 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2639 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2640 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2641 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2642 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2643 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2644 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2645 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2646 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2647 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2648 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2649 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2650 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2651 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2652 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2653 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2654 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2655 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2656 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2657 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2658 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2659 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2660 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2661 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2662 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2663 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2664 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2665 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2666 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2667 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2668 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2669 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2670 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2671 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2672 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2673 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2674 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2675 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2676 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2677 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2678 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2679 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2680 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2682 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2683 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2684 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002685 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2686 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002687 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2688 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2689 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2690 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002691 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002692 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2693 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2694 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2695 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2696 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2697 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2698 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2699 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2700 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2701 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2702 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002703};
2704
Reid Spencer950bf602007-01-26 08:19:09 +00002705static const short int yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002706{
Reid Spencer950bf602007-01-26 08:19:09 +00002707 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2708 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2709 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2710 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2711 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2712 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2713 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2714 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2715 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2716 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2717 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2718 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2719 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2720 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2721 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2722 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2723 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2724 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2725 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2726 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2727 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2728 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2729 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2730 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2731 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2732 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2733 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2734 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2735 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2736 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2737 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2738 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2739 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2740 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2741 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2742 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2743 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2744 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2745 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2746 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2747 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2748 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2749 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2750 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2751 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2752 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2753 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2754 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2755 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2756 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2757 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2758 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
Reid Spencerc4d96252007-01-13 00:03:30 +00002759 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
Reid Spencer950bf602007-01-26 08:19:09 +00002760 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2761 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2762 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2763 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2764 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2765 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2766 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2767 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2768 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2769 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2770 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2771 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2772 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2773 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2774 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2775 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2776 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2777 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2778 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2779 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2780 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2781 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2782 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2783 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2784 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2785 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2786 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2787 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2788 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2789 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2790 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2791 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2792 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2793 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2794 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2795 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2796 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2797 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2798 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2799 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2800 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2801 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2802 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2803 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2804 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2805 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2806 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2807 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2808 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2809 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2810 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2811 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2812 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2813 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2814 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2815 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2816 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2817 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2818 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2819 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2820 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2821 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2822 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2823 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2824 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2825 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2826 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2827 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2828 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2829 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2830 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2831 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2832 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2833 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2834 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2835 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2836 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2837 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2838 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2839 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2840 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2841 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2842 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2843 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2844 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2845 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2846 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2847 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2848 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2849 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2850 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2851 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2852 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2853 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2854 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2855 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2856 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2857 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2858 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2859 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2860 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2861 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2862 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2863 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2864 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2865 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2866 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2867 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2868 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2869 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2870 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2871 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2872 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2873 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2874 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2875 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2876 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2877 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2878 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002879};
2880
2881/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2882 symbol of state STATE-NUM. */
2883static const unsigned char yystos[] =
2884{
Reid Spencer950bf602007-01-26 08:19:09 +00002885 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2886 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2887 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2888 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2889 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2890 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2891 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2892 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2893 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2894 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2895 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2896 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2897 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2898 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2899 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2900 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2901 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2902 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2903 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2904 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2905 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2906 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2907 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2908 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2909 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2910 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2911 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2912 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2913 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2914 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2915 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2916 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2917 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2918 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2919 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2920 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2921 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2922 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2923 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2924 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2925 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2926 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2927 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2928 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2929 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2930 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2931 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2932 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2933 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2934 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2935 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2936 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2937 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2938 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2939 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2940 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2941 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2942 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2943 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2944 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2945 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00002946};
Reid Spencere7c3c602006-11-30 06:36:44 +00002947
2948#define yyerrok (yyerrstatus = 0)
2949#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00002950#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00002951#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00002952
Reid Spencere7c3c602006-11-30 06:36:44 +00002953#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00002954#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00002955#define YYERROR goto yyerrorlab
2956
Reid Spencer319a7302007-01-05 17:20:02 +00002957
2958/* Like YYERROR except do call yyerror. This remains here temporarily
2959 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00002960 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00002961
Reid Spencere7c3c602006-11-30 06:36:44 +00002962#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00002963
Reid Spencere7c3c602006-11-30 06:36:44 +00002964#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00002965
2966#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00002967do \
2968 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00002969 { \
2970 yychar = (Token); \
2971 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00002972 yytoken = YYTRANSLATE (yychar); \
Reid Spencere7c3c602006-11-30 06:36:44 +00002973 YYPOPSTACK; \
2974 goto yybackup; \
2975 } \
2976 else \
Reid Spencer950bf602007-01-26 08:19:09 +00002977 { \
2978 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00002979 YYERROR; \
2980 } \
Reid Spencere7c3c602006-11-30 06:36:44 +00002981while (0)
2982
Reid Spencer950bf602007-01-26 08:19:09 +00002983
Reid Spencere7c3c602006-11-30 06:36:44 +00002984#define YYTERROR 1
2985#define YYERRCODE 256
2986
Reid Spencer319a7302007-01-05 17:20:02 +00002987
Reid Spencer950bf602007-01-26 08:19:09 +00002988/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2989 If N is 0, then set CURRENT to the empty location which ends
2990 the previous symbol: RHS[0] (always defined). */
2991
2992#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00002993#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00002994# define YYLLOC_DEFAULT(Current, Rhs, N) \
2995 do \
2996 if (N) \
2997 { \
2998 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2999 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3000 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3001 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3002 } \
3003 else \
3004 { \
3005 (Current).first_line = (Current).last_line = \
3006 YYRHSLOC (Rhs, 0).last_line; \
3007 (Current).first_column = (Current).last_column = \
3008 YYRHSLOC (Rhs, 0).last_column; \
3009 } \
3010 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003011#endif
3012
Reid Spencer950bf602007-01-26 08:19:09 +00003013
3014/* YY_LOCATION_PRINT -- Print the location on the stream.
3015 This macro was not mandated originally: define only if we know
3016 we won't break user code: when these are the locations we know. */
3017
3018#ifndef YY_LOCATION_PRINT
3019# if YYLTYPE_IS_TRIVIAL
3020# define YY_LOCATION_PRINT(File, Loc) \
3021 fprintf (File, "%d.%d-%d.%d", \
3022 (Loc).first_line, (Loc).first_column, \
3023 (Loc).last_line, (Loc).last_column)
3024# else
3025# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3026# endif
3027#endif
3028
3029
Reid Spencer319a7302007-01-05 17:20:02 +00003030/* YYLEX -- calling `yylex' with the right arguments. */
3031
Reid Spencer950bf602007-01-26 08:19:09 +00003032#ifdef YYLEX_PARAM
3033# define YYLEX yylex (YYLEX_PARAM)
3034#else
3035# define YYLEX yylex ()
3036#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003037
3038/* Enable debugging if requested. */
3039#if YYDEBUG
3040
3041# ifndef YYFPRINTF
3042# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3043# define YYFPRINTF fprintf
3044# endif
3045
3046# define YYDPRINTF(Args) \
3047do { \
3048 if (yydebug) \
3049 YYFPRINTF Args; \
3050} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003051
3052# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3053do { \
3054 if (yydebug) \
3055 { \
3056 YYFPRINTF (stderr, "%s ", Title); \
3057 yysymprint (stderr, \
3058 Type, Value); \
3059 YYFPRINTF (stderr, "\n"); \
3060 } \
Reid Spencer319a7302007-01-05 17:20:02 +00003061} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003062
3063/*------------------------------------------------------------------.
3064| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3065| TOP (included). |
3066`------------------------------------------------------------------*/
3067
3068#if defined (__STDC__) || defined (__cplusplus)
3069static void
3070yy_stack_print (short int *bottom, short int *top)
3071#else
3072static void
3073yy_stack_print (bottom, top)
3074 short int *bottom;
3075 short int *top;
3076#endif
3077{
3078 YYFPRINTF (stderr, "Stack now");
3079 for (/* Nothing. */; bottom <= top; ++bottom)
3080 YYFPRINTF (stderr, " %d", *bottom);
3081 YYFPRINTF (stderr, "\n");
3082}
3083
3084# define YY_STACK_PRINT(Bottom, Top) \
3085do { \
3086 if (yydebug) \
3087 yy_stack_print ((Bottom), (Top)); \
3088} while (0)
3089
3090
3091/*------------------------------------------------.
3092| Report that the YYRULE is going to be reduced. |
3093`------------------------------------------------*/
3094
3095#if defined (__STDC__) || defined (__cplusplus)
3096static void
3097yy_reduce_print (int yyrule)
3098#else
3099static void
3100yy_reduce_print (yyrule)
3101 int yyrule;
3102#endif
3103{
3104 int yyi;
3105 unsigned long int yylno = yyrline[yyrule];
3106 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3107 yyrule - 1, yylno);
3108 /* Print the symbols being reduced, and their result. */
3109 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3110 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3111 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3112}
3113
3114# define YY_REDUCE_PRINT(Rule) \
3115do { \
3116 if (yydebug) \
3117 yy_reduce_print (Rule); \
3118} while (0)
3119
Reid Spencer319a7302007-01-05 17:20:02 +00003120/* Nonzero means print parse trace. It is left uninitialized so that
3121 multiple parsers can coexist. */
3122int yydebug;
3123#else /* !YYDEBUG */
3124# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003125# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3126# define YY_STACK_PRINT(Bottom, Top)
3127# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003128#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003129
Reid Spencer950bf602007-01-26 08:19:09 +00003130
Reid Spencer319a7302007-01-05 17:20:02 +00003131/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003132#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003133# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003134#endif
3135
Reid Spencer319a7302007-01-05 17:20:02 +00003136/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3137 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003138
Reid Spencer319a7302007-01-05 17:20:02 +00003139 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003140 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003141 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003142
3143#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003144# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003145#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003146
Reid Spencere7c3c602006-11-30 06:36:44 +00003147
3148
Reid Spencer319a7302007-01-05 17:20:02 +00003149#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003150
Reid Spencer319a7302007-01-05 17:20:02 +00003151# ifndef yystrlen
3152# if defined (__GLIBC__) && defined (_STRING_H)
3153# define yystrlen strlen
3154# else
3155/* Return the length of YYSTR. */
3156static YYSIZE_T
3157# if defined (__STDC__) || defined (__cplusplus)
3158yystrlen (const char *yystr)
3159# else
3160yystrlen (yystr)
3161 const char *yystr;
3162# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003163{
Reid Spencer950bf602007-01-26 08:19:09 +00003164 const char *yys = yystr;
Chris Lattner37e01c52007-01-04 18:46:42 +00003165
Reid Spencer319a7302007-01-05 17:20:02 +00003166 while (*yys++ != '\0')
3167 continue;
3168
3169 return yys - yystr - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003170}
Reid Spencer319a7302007-01-05 17:20:02 +00003171# endif
3172# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003173
Reid Spencer319a7302007-01-05 17:20:02 +00003174# ifndef yystpcpy
3175# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3176# define yystpcpy stpcpy
3177# else
3178/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3179 YYDEST. */
3180static char *
3181# if defined (__STDC__) || defined (__cplusplus)
3182yystpcpy (char *yydest, const char *yysrc)
3183# else
3184yystpcpy (yydest, yysrc)
3185 char *yydest;
3186 const char *yysrc;
3187# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003188{
Reid Spencer950bf602007-01-26 08:19:09 +00003189 char *yyd = yydest;
3190 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003191
Reid Spencer319a7302007-01-05 17:20:02 +00003192 while ((*yyd++ = *yys++) != '\0')
3193 continue;
3194
3195 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003196}
Reid Spencer319a7302007-01-05 17:20:02 +00003197# endif
3198# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003199
Reid Spencer950bf602007-01-26 08:19:09 +00003200# ifndef yytnamerr
3201/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3202 quotes and backslashes, so that it's suitable for yyerror. The
3203 heuristic is that double-quoting is unnecessary unless the string
3204 contains an apostrophe, a comma, or backslash (other than
3205 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3206 null, do not copy; instead, return the length of what the result
3207 would have been. */
3208static YYSIZE_T
3209yytnamerr (char *yyres, const char *yystr)
3210{
3211 if (*yystr == '"')
3212 {
3213 size_t yyn = 0;
3214 char const *yyp = yystr;
3215
3216 for (;;)
3217 switch (*++yyp)
3218 {
3219 case '\'':
3220 case ',':
3221 goto do_not_strip_quotes;
3222
3223 case '\\':
3224 if (*++yyp != '\\')
3225 goto do_not_strip_quotes;
3226 /* Fall through. */
3227 default:
3228 if (yyres)
3229 yyres[yyn] = *yyp;
3230 yyn++;
3231 break;
3232
3233 case '"':
3234 if (yyres)
3235 yyres[yyn] = '\0';
3236 return yyn;
3237 }
3238 do_not_strip_quotes: ;
3239 }
3240
3241 if (! yyres)
3242 return yystrlen (yystr);
3243
3244 return yystpcpy (yyres, yystr) - yyres;
3245}
3246# endif
3247
3248#endif /* YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00003249
Reid Spencere7c3c602006-11-30 06:36:44 +00003250
3251
Reid Spencer319a7302007-01-05 17:20:02 +00003252#if YYDEBUG
Reid Spencer950bf602007-01-26 08:19:09 +00003253/*--------------------------------.
3254| Print this symbol on YYOUTPUT. |
3255`--------------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003256
Reid Spencer319a7302007-01-05 17:20:02 +00003257#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003258static void
3259yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner37e01c52007-01-04 18:46:42 +00003260#else
Reid Spencer950bf602007-01-26 08:19:09 +00003261static void
3262yysymprint (yyoutput, yytype, yyvaluep)
3263 FILE *yyoutput;
Reid Spencer319a7302007-01-05 17:20:02 +00003264 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003265 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003266#endif
3267{
3268 /* Pacify ``unused variable'' warnings. */
Reid Spencer950bf602007-01-26 08:19:09 +00003269 (void) yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003270
3271 if (yytype < YYNTOKENS)
Reid Spencer950bf602007-01-26 08:19:09 +00003272 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
Jeff Cohenac2dca92007-01-21 19:30:52 +00003273 else
Reid Spencer950bf602007-01-26 08:19:09 +00003274 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Jeff Cohenac2dca92007-01-21 19:30:52 +00003275
Reid Spencer950bf602007-01-26 08:19:09 +00003276
3277# ifdef YYPRINT
3278 if (yytype < YYNTOKENS)
3279 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3280# endif
Reid Spencer319a7302007-01-05 17:20:02 +00003281 switch (yytype)
3282 {
3283 default:
3284 break;
3285 }
Reid Spencer950bf602007-01-26 08:19:09 +00003286 YYFPRINTF (yyoutput, ")");
Reid Spencer319a7302007-01-05 17:20:02 +00003287}
3288
Reid Spencer950bf602007-01-26 08:19:09 +00003289#endif /* ! YYDEBUG */
Reid Spencer319a7302007-01-05 17:20:02 +00003290/*-----------------------------------------------.
3291| Release the memory associated to this symbol. |
3292`-----------------------------------------------*/
3293
3294#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003295static void
3296yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003297#else
Reid Spencer950bf602007-01-26 08:19:09 +00003298static void
3299yydestruct (yymsg, yytype, yyvaluep)
3300 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003301 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003302 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003303#endif
3304{
3305 /* Pacify ``unused variable'' warnings. */
Reid Spencer950bf602007-01-26 08:19:09 +00003306 (void) yyvaluep;
3307
3308 if (!yymsg)
3309 yymsg = "Deleting";
3310 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003311
3312 switch (yytype)
3313 {
Reid Spencer950bf602007-01-26 08:19:09 +00003314
Reid Spencer319a7302007-01-05 17:20:02 +00003315 default:
3316 break;
3317 }
3318}
3319
3320
Reid Spencer950bf602007-01-26 08:19:09 +00003321/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003322
3323#ifdef YYPARSE_PARAM
3324# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003325int yyparse (void *YYPARSE_PARAM);
Reid Spencer319a7302007-01-05 17:20:02 +00003326# else
Reid Spencer950bf602007-01-26 08:19:09 +00003327int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003328# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003329#else /* ! YYPARSE_PARAM */
3330#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003331int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003332#else
3333int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003334#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003335#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003336
3337
Reid Spencer950bf602007-01-26 08:19:09 +00003338
3339/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003340int yychar;
3341
Reid Spencer950bf602007-01-26 08:19:09 +00003342/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003343YYSTYPE yylval;
3344
Reid Spencer950bf602007-01-26 08:19:09 +00003345/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003346int yynerrs;
3347
3348
Reid Spencer950bf602007-01-26 08:19:09 +00003349
3350/*----------.
3351| yyparse. |
3352`----------*/
3353
3354#ifdef YYPARSE_PARAM
3355# if defined (__STDC__) || defined (__cplusplus)
3356int yyparse (void *YYPARSE_PARAM)
3357# else
3358int yyparse (YYPARSE_PARAM)
3359 void *YYPARSE_PARAM;
3360# endif
3361#else /* ! YYPARSE_PARAM */
3362#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003363int
Reid Spencer950bf602007-01-26 08:19:09 +00003364yyparse (void)
3365#else
3366int
3367yyparse ()
3368
3369#endif
3370#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003371{
3372
Reid Spencer950bf602007-01-26 08:19:09 +00003373 int yystate;
3374 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003375 int yyresult;
3376 /* Number of tokens to shift before error messages enabled. */
3377 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003378 /* Look-ahead token as an internal (translated) token number. */
3379 int yytoken = 0;
Reid Spencer319a7302007-01-05 17:20:02 +00003380
3381 /* Three stacks and their tools:
3382 `yyss': related to states,
3383 `yyvs': related to semantic values,
3384 `yyls': related to locations.
3385
3386 Refer to the stacks thru separate pointers, to allow yyoverflow
3387 to reallocate them elsewhere. */
3388
3389 /* The state stack. */
Reid Spencer950bf602007-01-26 08:19:09 +00003390 short int yyssa[YYINITDEPTH];
3391 short int *yyss = yyssa;
3392 short int *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003393
3394 /* The semantic value stack. */
3395 YYSTYPE yyvsa[YYINITDEPTH];
3396 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003397 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003398
3399
3400
Reid Spencere7c3c602006-11-30 06:36:44 +00003401#define YYPOPSTACK (yyvsp--, yyssp--)
3402
Reid Spencer319a7302007-01-05 17:20:02 +00003403 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003404
Reid Spencer319a7302007-01-05 17:20:02 +00003405 /* The variables used to return semantic value and location from the
3406 action routines. */
3407 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003408
3409
Reid Spencer319a7302007-01-05 17:20:02 +00003410 /* When reducing, the number of symbols on the RHS of the reduced
3411 rule. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003412 int yylen;
3413
Reid Spencer319a7302007-01-05 17:20:02 +00003414 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003415
3416 yystate = 0;
3417 yyerrstatus = 0;
3418 yynerrs = 0;
3419 yychar = YYEMPTY; /* Cause a token to be read. */
3420
3421 /* Initialize stack pointers.
3422 Waste one element of value and location stack
3423 so that they stay on the same level as the state stack.
3424 The wasted elements are never initialized. */
3425
Reid Spencer319a7302007-01-05 17:20:02 +00003426 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003427 yyvsp = yyvs;
3428
Reid Spencer319a7302007-01-05 17:20:02 +00003429 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003430
Reid Spencer319a7302007-01-05 17:20:02 +00003431/*------------------------------------------------------------.
3432| yynewstate -- Push a new state, which is found in yystate. |
3433`------------------------------------------------------------*/
3434 yynewstate:
3435 /* In all cases, when you get here, the value and location stacks
3436 have just been pushed. so pushing a state here evens the stacks.
3437 */
3438 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003439
Reid Spencer319a7302007-01-05 17:20:02 +00003440 yysetstate:
3441 *yyssp = yystate;
3442
Reid Spencer950bf602007-01-26 08:19:09 +00003443 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003444 {
3445 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003446 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003447
3448#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003449 {
3450 /* Give user a chance to reallocate the stack. Use copies of
3451 these so that the &'s don't force the real ones into
3452 memory. */
3453 YYSTYPE *yyvs1 = yyvs;
Reid Spencer950bf602007-01-26 08:19:09 +00003454 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003455
Reid Spencer319a7302007-01-05 17:20:02 +00003456
3457 /* Each stack pointer address is followed by the size of the
3458 data in use in that stack, in bytes. This used to be a
3459 conditional around just the two extra args, but that might
3460 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003461 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003462 &yyss1, yysize * sizeof (*yyssp),
3463 &yyvs1, yysize * sizeof (*yyvsp),
3464
3465 &yystacksize);
3466
3467 yyss = yyss1;
3468 yyvs = yyvs1;
3469 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003470#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003471# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003472 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003473# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003474 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003475 if (YYMAXDEPTH <= yystacksize)
3476 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003477 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003478 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003479 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003480
3481 {
Reid Spencer950bf602007-01-26 08:19:09 +00003482 short int *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003483 union yyalloc *yyptr =
3484 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3485 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003486 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003487 YYSTACK_RELOCATE (yyss);
3488 YYSTACK_RELOCATE (yyvs);
3489
3490# undef YYSTACK_RELOCATE
3491 if (yyss1 != yyssa)
3492 YYSTACK_FREE (yyss1);
3493 }
3494# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003495#endif /* no yyoverflow */
3496
Reid Spencer319a7302007-01-05 17:20:02 +00003497 yyssp = yyss + yysize - 1;
3498 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003499
3500
Reid Spencer319a7302007-01-05 17:20:02 +00003501 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3502 (unsigned long int) yystacksize));
3503
Reid Spencer950bf602007-01-26 08:19:09 +00003504 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003505 YYABORT;
3506 }
3507
Reid Spencer319a7302007-01-05 17:20:02 +00003508 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003509
3510 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003511
3512/*-----------.
3513| yybackup. |
3514`-----------*/
3515yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003516
3517/* Do appropriate processing given the current state. */
Reid Spencer950bf602007-01-26 08:19:09 +00003518/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003519/* yyresume: */
3520
Reid Spencer950bf602007-01-26 08:19:09 +00003521 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003522
3523 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003524 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003525 goto yydefault;
3526
Reid Spencer950bf602007-01-26 08:19:09 +00003527 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003528
Reid Spencer950bf602007-01-26 08:19:09 +00003529 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003530 if (yychar == YYEMPTY)
3531 {
Reid Spencer319a7302007-01-05 17:20:02 +00003532 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003533 yychar = YYLEX;
3534 }
3535
Reid Spencer950bf602007-01-26 08:19:09 +00003536 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003537 {
Reid Spencer950bf602007-01-26 08:19:09 +00003538 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003539 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003540 }
3541 else
3542 {
Reid Spencer950bf602007-01-26 08:19:09 +00003543 yytoken = YYTRANSLATE (yychar);
3544 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003545 }
3546
Reid Spencer950bf602007-01-26 08:19:09 +00003547 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003548 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003549 yyn += yytoken;
3550 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003551 goto yydefault;
3552 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003553 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003554 {
Reid Spencer319a7302007-01-05 17:20:02 +00003555 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003556 goto yyerrlab;
3557 yyn = -yyn;
3558 goto yyreduce;
3559 }
3560
3561 if (yyn == YYFINAL)
3562 YYACCEPT;
3563
Reid Spencer950bf602007-01-26 08:19:09 +00003564 /* Shift the look-ahead token. */
3565 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003566
3567 /* Discard the token being shifted unless it is eof. */
3568 if (yychar != YYEOF)
3569 yychar = YYEMPTY;
3570
3571 *++yyvsp = yylval;
3572
Reid Spencer319a7302007-01-05 17:20:02 +00003573
3574 /* Count tokens shifted since error; after three, turn off error
3575 status. */
3576 if (yyerrstatus)
3577 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003578
3579 yystate = yyn;
3580 goto yynewstate;
3581
Chris Lattner37e01c52007-01-04 18:46:42 +00003582
Reid Spencer319a7302007-01-05 17:20:02 +00003583/*-----------------------------------------------------------.
3584| yydefault -- do the default action for the current state. |
3585`-----------------------------------------------------------*/
3586yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003587 yyn = yydefact[yystate];
3588 if (yyn == 0)
3589 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003590 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003591
Reid Spencer319a7302007-01-05 17:20:02 +00003592
3593/*-----------------------------.
3594| yyreduce -- Do a reduction. |
3595`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003596yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003597 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003598 yylen = yyr2[yyn];
3599
Reid Spencer319a7302007-01-05 17:20:02 +00003600 /* If YYLEN is nonzero, implement the default value of the action:
3601 `$$ = $1'.
3602
3603 Otherwise, the following line sets YYVAL to garbage.
3604 This behavior is undocumented and Bison
3605 users should not rely upon it. Assigning to YYVAL
3606 unconditionally makes the parser a bit smaller, and it avoids a
3607 GCC warning that YYVAL may be used uninitialized. */
3608 yyval = yyvsp[1-yylen];
3609
3610
Reid Spencer950bf602007-01-26 08:19:09 +00003611 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003612 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003613 {
Reid Spencer950bf602007-01-26 08:19:09 +00003614 case 3:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003615#line 1532 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003616 {
Reid Spencer950bf602007-01-26 08:19:09 +00003617 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
3618 error("Value too large for type");
3619 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3620 ;}
3621 break;
3622
3623 case 5:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003624#line 1541 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003625 {
3626 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
3627 error("Value too large for type");
3628 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3629 ;}
3630 break;
3631
3632 case 26:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003633#line 1563 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003634 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3635 break;
3636
3637 case 27:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003638#line 1563 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003639 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3640 break;
3641
3642 case 28:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003643#line 1564 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003644 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3645 break;
3646
3647 case 29:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003648#line 1564 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003649 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3650 break;
3651
3652 case 30:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003653#line 1565 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003654 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3655 break;
3656
3657 case 31:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003658#line 1565 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003659 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3660 break;
3661
3662 case 32:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003663#line 1566 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003664 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3665 break;
3666
3667 case 33:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003668#line 1566 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003669 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3670 break;
3671
3672 case 34:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003673#line 1567 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003674 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3675 break;
3676
3677 case 35:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003678#line 1567 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003679 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3680 break;
3681
3682 case 36:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003683#line 1571 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003684 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3685 break;
3686
3687 case 37:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003688#line 1571 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003689 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3690 break;
3691
3692 case 38:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003693#line 1572 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003694 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3695 break;
3696
3697 case 39:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003698#line 1572 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003699 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3700 break;
3701
3702 case 40:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003703#line 1573 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003704 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3705 break;
3706
3707 case 41:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003708#line 1573 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003709 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3710 break;
3711
3712 case 42:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003713#line 1574 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003714 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3715 break;
3716
3717 case 43:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003718#line 1574 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003719 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3720 break;
3721
3722 case 44:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003723#line 1575 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003724 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3725 break;
3726
3727 case 45:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003728#line 1575 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003729 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3730 break;
3731
3732 case 46:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003733#line 1576 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003734 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3735 break;
3736
3737 case 47:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003738#line 1576 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003739 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3740 break;
3741
3742 case 48:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003743#line 1577 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003744 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3745 break;
3746
3747 case 49:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003748#line 1577 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003749 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3750 break;
3751
3752 case 50:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003753#line 1578 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003754 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3755 break;
3756
3757 case 51:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003758#line 1579 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003759 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3760 break;
3761
3762 case 81:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003763#line 1610 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003764 {
3765 (yyval.StrVal) = (yyvsp[-1].StrVal);
3766 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003767 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003768
Reid Spencer319a7302007-01-05 17:20:02 +00003769 case 82:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003770#line 1613 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003771 {
Reid Spencer950bf602007-01-26 08:19:09 +00003772 (yyval.StrVal) = 0;
3773 ;}
3774 break;
3775
3776 case 83:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003777#line 1618 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003778 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3779 break;
3780
3781 case 84:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003782#line 1619 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003783 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3784 break;
3785
3786 case 85:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003787#line 1620 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003788 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3789 break;
3790
3791 case 86:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003792#line 1621 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003793 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3794 break;
3795
3796 case 87:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003797#line 1622 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003798 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3799 break;
3800
3801 case 88:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003802#line 1623 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003803 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3804 break;
3805
3806 case 89:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003807#line 1624 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003808 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003809 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003810
Reid Spencer319a7302007-01-05 17:20:02 +00003811 case 90:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003812#line 1625 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003813 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3814 break;
3815
3816 case 91:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003817#line 1629 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003818 { (yyval.UIntVal) = CallingConv::C; ;}
3819 break;
3820
3821 case 92:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003822#line 1630 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003823 { (yyval.UIntVal) = CallingConv::C; ;}
3824 break;
3825
3826 case 93:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003827#line 1631 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003828 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3829 break;
3830
3831 case 94:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003832#line 1632 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003833 { (yyval.UIntVal) = CallingConv::Fast; ;}
3834 break;
3835
3836 case 95:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003837#line 1633 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003838 { (yyval.UIntVal) = CallingConv::Cold; ;}
3839 break;
3840
3841 case 96:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003842#line 1634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003843 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003844 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00003845
Reid Spencer319a7302007-01-05 17:20:02 +00003846 case 97:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003847#line 1635 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003848 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003849 break;
Reid Spencer16244f42006-12-01 21:10:07 +00003850
Reid Spencer319a7302007-01-05 17:20:02 +00003851 case 98:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003852#line 1636 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003853 {
3854 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
3855 error("Calling conv too large");
3856 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3857 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003858 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003859
Reid Spencer319a7302007-01-05 17:20:02 +00003860 case 99:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003861#line 1646 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003862 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003863 break;
3864
Reid Spencerc4d96252007-01-13 00:03:30 +00003865 case 100:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003866#line 1647 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003867 {
3868 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3869 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3870 error("Alignment must be a power of two");
3871 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003872 break;
3873
3874 case 101:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003875#line 1655 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003876 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003877 break;
3878
3879 case 102:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003880#line 1656 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003881 {
3882 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3883 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3884 error("Alignment must be a power of two");
3885 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003886 break;
3887
3888 case 103:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003889#line 1664 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003890 {
3891 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3892 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
3893 error("Invalid character in section name");
3894 (yyval.StrVal) = (yyvsp[0].StrVal);
3895 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003896 break;
3897
3898 case 104:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003899#line 1673 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003900 { (yyval.StrVal) = 0; ;}
3901 break;
3902
3903 case 105:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003904#line 1674 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003905 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003906 break;
3907
Reid Spencerc4d96252007-01-13 00:03:30 +00003908 case 106:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003909#line 1681 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003910 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003911 break;
3912
Reid Spencer319a7302007-01-05 17:20:02 +00003913 case 107:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003914#line 1682 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003915 {;}
3916 break;
3917
3918 case 108:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003919#line 1686 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003920 {
Reid Spencer950bf602007-01-26 08:19:09 +00003921 CurGV->setSection((yyvsp[0].StrVal));
3922 free((yyvsp[0].StrVal));
3923 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003924 break;
3925
3926 case 109:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003927#line 1690 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003928 {
Reid Spencer950bf602007-01-26 08:19:09 +00003929 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
3930 error("Alignment must be a power of two");
3931 CurGV->setAlignment((yyvsp[0].UInt64Val));
3932
3933 ;}
3934 break;
3935
3936 case 111:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003937#line 1707 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003938 {
3939 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3940 (yyval.TypeVal).S = Signless;
3941 ;}
3942 break;
3943
3944 case 113:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003945#line 1715 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003946 {
3947 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3948 (yyval.TypeVal).S = Signless;
3949 ;}
3950 break;
3951
3952 case 114:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003953#line 1722 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003954 {
3955 if (!UpRefs.empty())
3956 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).T)->getDescription());
3957 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3958 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003959 break;
3960
3961 case 127:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003962#line 1736 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003963 {
Reid Spencer950bf602007-01-26 08:19:09 +00003964 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3965 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
3966 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003967 break;
3968
3969 case 128:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003970#line 1740 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003971 {
3972 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
3973 (yyval.TypeVal).S = Signless;
3974 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003975 break;
3976
3977 case 129:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003978#line 1744 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003979 { // Named types are also simple types...
Reid Spencerd7c4f8c2007-01-26 19:59:25 +00003980 const Type* tmp = getType((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00003981 (yyval.TypeVal).T = new PATypeHolder(tmp);
3982 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
3983 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003984 break;
3985
3986 case 130:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00003987#line 1749 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003988 { // Type UpReference
Reid Spencer950bf602007-01-26 08:19:09 +00003989 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
3990 error("Value out of range");
3991 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
3992 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3993 (yyval.TypeVal).T = new PATypeHolder(OT);
3994 (yyval.TypeVal).S = Signless;
3995 UR_OUT("New Upreference!\n");
3996 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003997 break;
3998
3999 case 131:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004000#line 1758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004001 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004002 std::vector<const Type*> Params;
4003 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4004 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
4005 Params.push_back(I->T->get());
4006 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004007 }
Reid Spencer950bf602007-01-26 08:19:09 +00004008 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4009 if (isVarArg) Params.pop_back();
4010
4011 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
4012 FunctionType::get((yyvsp[-3].TypeVal).T->get(),Params,isVarArg)));
4013 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
4014 delete (yyvsp[-3].TypeVal).T; // Delete the return type handle
4015 delete (yyvsp[-1].TypeList); // Delete the argument list
4016 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004017 break;
4018
4019 case 132:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004020#line 1774 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004021 { // Sized array type?
Reid Spencer950bf602007-01-26 08:19:09 +00004022 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).T->get(),
4023 (unsigned)(yyvsp[-3].UInt64Val))));
4024 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4025 delete (yyvsp[-1].TypeVal).T;
4026 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004027 break;
4028
4029 case 133:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004030#line 1780 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004031 { // Packed array type?
Reid Spencer950bf602007-01-26 08:19:09 +00004032 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).T->get();
4033 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
4034 error("Unsigned result not equal to signed result");
4035 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4036 error("Elements of a PackedType must be integer or floating point");
4037 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
4038 error("PackedType length should be a power of 2");
4039 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
4040 (unsigned)(yyvsp[-3].UInt64Val))));
4041 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4042 delete (yyvsp[-1].TypeVal).T;
4043 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004044 break;
4045
4046 case 134:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004047#line 1793 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004048 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004049 std::vector<const Type*> Elements;
4050 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4051 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
4052 Elements.push_back(I->T->get());
4053 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4054 (yyval.TypeVal).S = Signless;
4055 delete (yyvsp[-1].TypeList);
4056 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004057 break;
4058
4059 case 135:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004060#line 1802 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004061 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004062 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4063 (yyval.TypeVal).S = Signless;
4064 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004065 break;
4066
4067 case 136:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004068#line 1806 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004069 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004070 std::vector<const Type*> Elements;
4071 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4072 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
4073 Elements.push_back(I->T->get());
4074 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004075 }
Reid Spencer950bf602007-01-26 08:19:09 +00004076 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4077 (yyval.TypeVal).S = Signless;
4078 delete (yyvsp[-2].TypeList);
4079 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004080 break;
4081
4082 case 137:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004083#line 1817 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004084 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004085 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4086 (yyval.TypeVal).S = Signless;
4087 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004088 break;
4089
4090 case 138:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004091#line 1821 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004092 { // Pointer type?
Reid Spencer950bf602007-01-26 08:19:09 +00004093 if ((yyvsp[-1].TypeVal).T->get() == Type::LabelTy)
4094 error("Cannot form a pointer to a basic block");
4095 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).T->get())));
4096 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4097 delete (yyvsp[-1].TypeVal).T;
4098 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004099 break;
4100
4101 case 139:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004102#line 1834 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004103 {
Reid Spencer950bf602007-01-26 08:19:09 +00004104 (yyval.TypeList) = new std::list<PATypeInfo>();
4105 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4106 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004107 break;
4108
4109 case 140:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004110#line 1838 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004111 {
Reid Spencer950bf602007-01-26 08:19:09 +00004112 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4113 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004114 break;
4115
4116 case 142:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004117#line 1846 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004118 {
Reid Spencer950bf602007-01-26 08:19:09 +00004119 PATypeInfo VoidTI;
4120 VoidTI.T = new PATypeHolder(Type::VoidTy);
4121 VoidTI.S = Signless;
4122 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4123 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004124 break;
4125
4126 case 143:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004127#line 1852 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004128 {
Reid Spencer950bf602007-01-26 08:19:09 +00004129 (yyval.TypeList) = new std::list<PATypeInfo>();
4130 PATypeInfo VoidTI;
4131 VoidTI.T = new PATypeHolder(Type::VoidTy);
4132 VoidTI.S = Signless;
4133 (yyval.TypeList)->push_back(VoidTI);
4134 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004135 break;
4136
4137 case 144:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004138#line 1859 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004139 {
Reid Spencer950bf602007-01-26 08:19:09 +00004140 (yyval.TypeList) = new std::list<PATypeInfo>();
4141 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004142 break;
4143
4144 case 145:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004145#line 1871 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004146 { // Nonempty unsized arr
Reid Spencer950bf602007-01-26 08:19:09 +00004147 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).T->get());
4148 if (ATy == 0)
4149 error("Cannot make array constant with type: '" +
4150 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4151 const Type *ETy = ATy->getElementType();
4152 int NumElements = ATy->getNumElements();
4153
4154 // Verify that we have the correct size...
4155 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4156 error("Type mismatch: constant sized array initialized with " +
4157 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4158 itostr(NumElements) + "");
4159
4160 // Verify all elements are correct type!
4161 std::vector<Constant*> Elems;
4162 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4163 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4164 const Type* ValTy = C->getType();
4165 if (ETy != ValTy)
4166 error("Element #" + utostr(i) + " is not of type '" +
4167 ETy->getDescription() +"' as required!\nIt is of type '"+
4168 ValTy->getDescription() + "'");
4169 Elems.push_back(C);
4170 }
4171 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4172 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4173 delete (yyvsp[-3].TypeVal).T;
4174 delete (yyvsp[-1].ConstVector);
4175 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004176 break;
4177
4178 case 146:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004179#line 1901 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004180 {
Reid Spencer950bf602007-01-26 08:19:09 +00004181 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
4182 if (ATy == 0)
4183 error("Cannot make array constant with type: '" +
4184 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4185 int NumElements = ATy->getNumElements();
4186 if (NumElements != -1 && NumElements != 0)
4187 error("Type mismatch: constant sized array initialized with 0"
4188 " arguments, but has size of " + itostr(NumElements) +"");
4189 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4190 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4191 delete (yyvsp[-2].TypeVal).T;
4192 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004193 break;
4194
4195 case 147:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004196#line 1914 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004197 {
Reid Spencer950bf602007-01-26 08:19:09 +00004198 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
4199 if (ATy == 0)
4200 error("Cannot make array constant with type: '" +
4201 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4202 int NumElements = ATy->getNumElements();
4203 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4204 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4205 error("String arrays require type i8, not '" + ETy->getDescription() +
4206 "'");
4207 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4208 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
4209 error("Can't build string constant of size " +
4210 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
4211 itostr(NumElements) + "");
4212 std::vector<Constant*> Vals;
4213 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
4214 Vals.push_back(ConstantInt::get(ETy, *C));
4215 free((yyvsp[0].StrVal));
4216 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4217 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4218 delete (yyvsp[-2].TypeVal).T;
4219 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004220 break;
4221
4222 case 148:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004223#line 1937 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004224 { // Nonempty unsized arr
Reid Spencer950bf602007-01-26 08:19:09 +00004225 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).T->get());
4226 if (PTy == 0)
4227 error("Cannot make packed constant with type: '" +
4228 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4229 const Type *ETy = PTy->getElementType();
4230 int NumElements = PTy->getNumElements();
4231 // Verify that we have the correct size...
4232 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4233 error("Type mismatch: constant sized packed initialized with " +
4234 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4235 itostr(NumElements) + "");
4236 // Verify all elements are correct type!
4237 std::vector<Constant*> Elems;
4238 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4239 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4240 const Type* ValTy = C->getType();
4241 if (ETy != ValTy)
4242 error("Element #" + utostr(i) + " is not of type '" +
4243 ETy->getDescription() +"' as required!\nIt is of type '"+
4244 ValTy->getDescription() + "'");
4245 Elems.push_back(C);
4246 }
4247 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
4248 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4249 delete (yyvsp[-3].TypeVal).T;
4250 delete (yyvsp[-1].ConstVector);
4251 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004252 break;
4253
4254 case 149:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004255#line 1965 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004256 {
Reid Spencer950bf602007-01-26 08:19:09 +00004257 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).T->get());
4258 if (STy == 0)
4259 error("Cannot make struct constant with type: '" +
4260 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4261 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
4262 error("Illegal number of initializers for structure type");
4263
4264 // Check to ensure that constants are compatible with the type initializer!
4265 std::vector<Constant*> Fields;
4266 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4267 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4268 if (C->getType() != STy->getElementType(i))
4269 error("Expected type '" + STy->getElementType(i)->getDescription() +
4270 "' for element #" + utostr(i) + " of structure initializer");
4271 Fields.push_back(C);
4272 }
4273 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4274 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4275 delete (yyvsp[-3].TypeVal).T;
4276 delete (yyvsp[-1].ConstVector);
4277 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004278 break;
4279
4280 case 150:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004281#line 1987 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004282 {
Reid Spencer950bf602007-01-26 08:19:09 +00004283 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).T->get());
4284 if (STy == 0)
4285 error("Cannot make struct constant with type: '" +
4286 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4287 if (STy->getNumContainedTypes() != 0)
4288 error("Illegal number of initializers for structure type");
4289 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4290 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4291 delete (yyvsp[-2].TypeVal).T;
4292 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004293 break;
4294
4295 case 151:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004296#line 1998 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004297 {
Reid Spencer950bf602007-01-26 08:19:09 +00004298 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).T->get());
4299 if (STy == 0)
4300 error("Cannot make packed struct constant with type: '" +
4301 (yyvsp[-5].TypeVal).T->get()->getDescription() + "'");
4302 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
4303 error("Illegal number of initializers for packed structure type");
4304
4305 // Check to ensure that constants are compatible with the type initializer!
4306 std::vector<Constant*> Fields;
4307 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4308 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
4309 if (C->getType() != STy->getElementType(i))
4310 error("Expected type '" + STy->getElementType(i)->getDescription() +
4311 "' for element #" + utostr(i) + " of packed struct initializer");
4312 Fields.push_back(C);
4313 }
4314 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4315 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4316 delete (yyvsp[-5].TypeVal).T;
4317 delete (yyvsp[-2].ConstVector);
4318 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004319 break;
4320
4321 case 152:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004322#line 2020 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004323 {
Reid Spencer950bf602007-01-26 08:19:09 +00004324 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).T->get());
4325 if (STy == 0)
4326 error("Cannot make packed struct constant with type: '" +
4327 (yyvsp[-4].TypeVal).T->get()->getDescription() + "'");
4328 if (STy->getNumContainedTypes() != 0)
4329 error("Illegal number of initializers for packed structure type");
4330 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4331 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4332 delete (yyvsp[-4].TypeVal).T;
4333 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004334 break;
4335
4336 case 153:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004337#line 2031 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004338 {
Reid Spencer950bf602007-01-26 08:19:09 +00004339 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
4340 if (PTy == 0)
4341 error("Cannot make null pointer constant with type: '" +
4342 (yyvsp[-1].TypeVal).T->get()->getDescription() + "'");
4343 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4344 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4345 delete (yyvsp[-1].TypeVal).T;
4346 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004347 break;
4348
4349 case 154:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004350#line 2040 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004351 {
Reid Spencer950bf602007-01-26 08:19:09 +00004352 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).T->get());
4353 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4354 delete (yyvsp[-1].TypeVal).T;
4355 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004356 break;
4357
4358 case 155:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004359#line 2045 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004360 {
Reid Spencer950bf602007-01-26 08:19:09 +00004361 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
4362 if (Ty == 0)
4363 error("Global const reference must be a pointer type, not" +
4364 (yyvsp[-1].TypeVal).T->get()->getDescription());
4365
4366 // ConstExprs can exist in the body of a function, thus creating
4367 // GlobalValues whenever they refer to a variable. Because we are in
4368 // the context of a function, getExistingValue will search the functions
4369 // symbol table instead of the module symbol table for the global symbol,
4370 // which throws things all off. To get around this, we just tell
4371 // getExistingValue that we are at global scope here.
4372 //
4373 Function *SavedCurFn = CurFun.CurrentFunction;
4374 CurFun.CurrentFunction = 0;
4375 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
4376 CurFun.CurrentFunction = SavedCurFn;
4377
4378 // If this is an initializer for a constant pointer, which is referencing a
4379 // (currently) undefined variable, create a stub now that shall be replaced
4380 // in the future with the right type of variable.
4381 //
4382 if (V == 0) {
4383 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4384 const PointerType *PT = cast<PointerType>(Ty);
4385
4386 // First check to see if the forward references value is already created!
4387 PerModuleInfo::GlobalRefsType::iterator I =
4388 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
4389
4390 if (I != CurModule.GlobalRefs.end()) {
4391 V = I->second; // Placeholder already exists, use it...
4392 (yyvsp[0].ValIDVal).destroy();
4393 } else {
4394 std::string Name;
4395 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
4396
4397 // Create the forward referenced global.
4398 GlobalValue *GV;
4399 if (const FunctionType *FTy =
4400 dyn_cast<FunctionType>(PT->getElementType())) {
4401 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4402 CurModule.CurrentModule);
4403 } else {
4404 GV = new GlobalVariable(PT->getElementType(), false,
4405 GlobalValue::ExternalLinkage, 0,
4406 Name, CurModule.CurrentModule);
4407 }
4408
4409 // Keep track of the fact that we have a forward ref to recycle it
4410 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
4411 V = GV;
4412 }
4413 }
4414 (yyval.ConstVal).C = cast<GlobalValue>(V);
4415 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4416 delete (yyvsp[-1].TypeVal).T; // Free the type handle
4417 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004418 break;
4419
4420 case 156:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004421#line 2103 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004422 {
4423 if ((yyvsp[-1].TypeVal).T->get() != (yyvsp[0].ConstVal).C->getType())
4424 error("Mismatched types for constant expression");
4425 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4426 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4427 delete (yyvsp[-1].TypeVal).T;
4428 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004429 break;
4430
4431 case 157:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004432#line 2110 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004433 {
4434 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
4435 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4436 error("Cannot create a null initialized value of this type");
4437 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4438 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4439 delete (yyvsp[-1].TypeVal).T;
4440 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004441 break;
4442
4443 case 158:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004444#line 2118 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004445 { // integral constants
4446 const Type *Ty = (yyvsp[-1].PrimType).T;
4447 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
4448 error("Constant value doesn't fit in type");
4449 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
4450 (yyval.ConstVal).S = Signed;
4451 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004452 break;
4453
4454 case 159:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004455#line 2125 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004456 { // integral constants
4457 const Type *Ty = (yyvsp[-1].PrimType).T;
4458 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
4459 error("Constant value doesn't fit in type");
4460 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
4461 (yyval.ConstVal).S = Unsigned;
4462 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004463 break;
4464
4465 case 160:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004466#line 2132 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004467 { // Boolean constants
4468 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4469 (yyval.ConstVal).S = Unsigned;
4470 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004471 break;
4472
4473 case 161:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004474#line 2136 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004475 { // Boolean constants
4476 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4477 (yyval.ConstVal).S = Unsigned;
4478 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004479 break;
4480
4481 case 162:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004482#line 2140 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004483 { // Float & Double constants
4484 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
4485 error("Floating point constant invalid for type");
4486 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
4487 (yyval.ConstVal).S = Signless;
4488 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004489 break;
4490
4491 case 163:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004492#line 2149 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004493 {
Reid Spencer950bf602007-01-26 08:19:09 +00004494 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4495 const Type* DstTy = (yyvsp[-1].TypeVal).T->get();
4496 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4497 Signedness DstSign = (yyvsp[-1].TypeVal).S;
4498 if (!SrcTy->isFirstClassType())
4499 error("cast constant expression from a non-primitive type: '" +
4500 SrcTy->getDescription() + "'");
4501 if (!DstTy->isFirstClassType())
4502 error("cast constant expression to a non-primitive type: '" +
4503 DstTy->getDescription() + "'");
4504 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
4505 (yyval.ConstVal).S = DstSign;
4506 delete (yyvsp[-1].TypeVal).T;
4507 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004508 break;
4509
4510 case 164:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004511#line 2164 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004512 {
Reid Spencer950bf602007-01-26 08:19:09 +00004513 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
4514 if (!isa<PointerType>(Ty))
4515 error("GetElementPtr requires a pointer operand");
4516
4517 std::vector<Value*> VIndices;
4518 std::vector<Constant*> CIndices;
4519 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
4520
4521 delete (yyvsp[-1].ValueList);
4522 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
4523 (yyval.ConstVal).S = Signless;
4524 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004525 break;
4526
4527 case 165:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004528#line 2177 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004529 {
Reid Spencer950bf602007-01-26 08:19:09 +00004530 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4531 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
4532 error("Select condition must be bool type");
4533 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4534 error("Select operand types must match");
4535 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4536 (yyval.ConstVal).S = Unsigned;
4537 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004538 break;
4539
4540 case 166:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004541#line 2186 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004542 {
Reid Spencer950bf602007-01-26 08:19:09 +00004543 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4544 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4545 error("Binary operator types must match");
4546 // First, make sure we're dealing with the right opcode by upgrading from
4547 // obsolete versions.
4548 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4549
4550 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4551 // To retain backward compatibility with these early compilers, we emit a
4552 // cast to the appropriate integer type automatically if we are in the
4553 // broken case. See PR424 for more information.
4554 if (!isa<PointerType>(Ty)) {
4555 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4556 } else {
4557 const Type *IntPtrTy = 0;
4558 switch (CurModule.CurrentModule->getPointerSize()) {
4559 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4560 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4561 default: error("invalid pointer binary constant expr");
4562 }
4563 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4564 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4565 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4566 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4567 }
4568 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4569 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004570 break;
4571
4572 case 167:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004573#line 2214 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004574 {
Reid Spencer950bf602007-01-26 08:19:09 +00004575 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4576 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4577 error("Logical operator types must match");
4578 if (!Ty->isInteger()) {
4579 if (!isa<PackedType>(Ty) ||
4580 !cast<PackedType>(Ty)->getElementType()->isInteger())
4581 error("Logical operator requires integer operands");
4582 }
4583 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4584 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4585 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4586 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004587 break;
4588
4589 case 168:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004590#line 2227 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004591 {
Reid Spencer950bf602007-01-26 08:19:09 +00004592 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4593 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4594 error("setcc operand types must match");
4595 unsigned short pred;
4596 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4597 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4598 (yyval.ConstVal).S = Unsigned;
4599 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004600 break;
4601
4602 case 169:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004603#line 2236 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004604 {
Reid Spencer950bf602007-01-26 08:19:09 +00004605 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4606 error("icmp operand types must match");
4607 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4608 (yyval.ConstVal).S = Unsigned;
4609 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004610 break;
4611
4612 case 170:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004613#line 2242 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004614 {
Reid Spencer950bf602007-01-26 08:19:09 +00004615 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4616 error("fcmp operand types must match");
4617 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4618 (yyval.ConstVal).S = Unsigned;
4619 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004620 break;
4621
4622 case 171:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004623#line 2248 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004624 {
Reid Spencer950bf602007-01-26 08:19:09 +00004625 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4626 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
4627 error("Shift count for shift constant must be unsigned byte");
4628 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
4629 error("Shift constant expression requires integer operand");
4630 (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4631 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4632 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004633 break;
4634
4635 case 172:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004636#line 2257 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004637 {
Reid Spencer950bf602007-01-26 08:19:09 +00004638 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4639 error("Invalid extractelement operands");
4640 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4641 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4642 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004643 break;
4644
4645 case 173:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004646#line 2263 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004647 {
Reid Spencer950bf602007-01-26 08:19:09 +00004648 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4649 error("Invalid insertelement operands");
4650 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4651 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4652 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004653 break;
4654
4655 case 174:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004656#line 2269 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004657 {
4658 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4659 error("Invalid shufflevector operands");
4660 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4661 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4662 ;}
4663 break;
4664
4665 case 175:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004666#line 2280 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004667 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
4668 break;
4669
4670 case 176:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004671#line 2281 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004672 {
4673 (yyval.ConstVector) = new std::vector<ConstInfo>();
4674 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4675 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004676 break;
4677
4678 case 177:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004679#line 2290 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004680 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004681 break;
4682
4683 case 178:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004684#line 2291 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004685 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004686 break;
4687
4688 case 179:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004689#line 2303 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004690 {
Reid Spencer950bf602007-01-26 08:19:09 +00004691 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
4692 CurModule.ModuleDone();
4693 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004694 break;
4695
4696 case 180:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004697#line 2312 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004698 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004699 break;
4700
4701 case 181:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004702#line 2313 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004703 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004704 break;
4705
4706 case 182:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004707#line 2314 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004708 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
4709 break;
4710
4711 case 183:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004712#line 2315 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004713 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004714 break;
4715
4716 case 184:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004717#line 2316 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004718 {
4719 (yyval.ModuleVal) = CurModule.CurrentModule;
4720 // Emit an error if there are any unresolved types left.
4721 if (!CurModule.LateResolveTypes.empty()) {
4722 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4723 if (DID.Type == ValID::NameVal) {
4724 error("Reference to an undefined type: '"+DID.getName() + "'");
4725 } else {
4726 error("Reference to an undefined type: #" + itostr(DID.Num));
4727 }
4728 }
4729 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004730 break;
4731
4732 case 185:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004733#line 2332 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004734 {
Reid Spencer950bf602007-01-26 08:19:09 +00004735 // Eagerly resolve types. This is not an optimization, this is a
4736 // requirement that is due to the fact that we could have this:
4737 //
4738 // %list = type { %list * }
4739 // %list = type { %list * } ; repeated type decl
4740 //
4741 // If types are not resolved eagerly, then the two types will not be
4742 // determined to be the same type!
4743 //
4744 const Type* Ty = (yyvsp[0].TypeVal).T->get();
4745 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
4746
4747 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
4748 // If this is a named type that is not a redefinition, add it to the slot
4749 // table.
4750 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004751 }
Reid Spencer950bf602007-01-26 08:19:09 +00004752 delete (yyvsp[0].TypeVal).T;
4753 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004754 break;
4755
4756 case 186:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004757#line 2352 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004758 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004759 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004760 break;
4761
4762 case 187:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004763#line 2354 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004764 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004765 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004766 break;
4767
4768 case 188:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004769#line 2356 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004770 {
Reid Spencer950bf602007-01-26 08:19:09 +00004771 if ((yyvsp[0].ConstVal).C == 0)
4772 error("Global value initializer is not a constant");
4773 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C);
4774 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004775 break;
4776
4777 case 189:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004778#line 2360 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004779 {
Reid Spencer950bf602007-01-26 08:19:09 +00004780 CurGV = 0;
4781 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004782 break;
4783
4784 case 190:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004785#line 2363 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004786 {
Reid Spencer950bf602007-01-26 08:19:09 +00004787 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4788 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4789 delete (yyvsp[0].TypeVal).T;
4790 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004791 break;
4792
4793 case 191:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004794#line 2367 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004795 {
Reid Spencer950bf602007-01-26 08:19:09 +00004796 CurGV = 0;
4797 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004798 break;
4799
4800 case 192:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004801#line 2370 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004802 {
4803 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4804 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4805 delete (yyvsp[0].TypeVal).T;
4806 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004807 break;
4808
4809 case 193:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004810#line 2374 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004811 {
Reid Spencer950bf602007-01-26 08:19:09 +00004812 CurGV = 0;
4813 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004814 break;
4815
4816 case 194:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004817#line 2377 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004818 {
4819 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4820 CurGV =
4821 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4822 delete (yyvsp[0].TypeVal).T;
4823 ;}
4824 break;
4825
4826 case 195:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004827#line 2382 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004828 {
4829 CurGV = 0;
4830 ;}
4831 break;
4832
4833 case 196:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004834#line 2385 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004835 {
Reid Spencer950bf602007-01-26 08:19:09 +00004836 ;}
4837 break;
4838
4839 case 197:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004840#line 2387 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004841 {
4842 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004843 break;
4844
4845 case 198:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004846#line 2389 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004847 {
4848 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004849 break;
4850
4851 case 199:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004852#line 2394 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004853 {
Reid Spencer950bf602007-01-26 08:19:09 +00004854 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4855 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4856 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4857 free((yyvsp[0].StrVal));
4858
4859 if (AsmSoFar.empty())
4860 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4861 else
4862 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4863 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004864 break;
4865
4866 case 200:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004867#line 2408 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004868 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004869 break;
4870
4871 case 201:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004872#line 2409 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004873 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004874 break;
4875
4876 case 202:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004877#line 2413 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004878 {
Reid Spencer950bf602007-01-26 08:19:09 +00004879 CurModule.setEndianness((yyvsp[0].Endianness));
4880 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004881 break;
4882
4883 case 203:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004884#line 2416 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004885 {
Reid Spencer950bf602007-01-26 08:19:09 +00004886 if ((yyvsp[0].UInt64Val) == 32)
4887 CurModule.setPointerSize(Module::Pointer32);
4888 else if ((yyvsp[0].UInt64Val) == 64)
4889 CurModule.setPointerSize(Module::Pointer64);
4890 else
4891 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
4892 ;}
4893 break;
4894
4895 case 204:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004896#line 2424 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004897 {
4898 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4899 free((yyvsp[0].StrVal));
4900 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004901 break;
4902
4903 case 205:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004904#line 2428 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004905 {
Reid Spencer950bf602007-01-26 08:19:09 +00004906 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4907 free((yyvsp[0].StrVal));
4908 ;}
4909 break;
4910
4911 case 207:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004912#line 2439 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004913 {
4914 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4915 free((yyvsp[0].StrVal));
4916 ;}
4917 break;
4918
4919 case 208:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004920#line 2443 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004921 {
4922 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4923 free((yyvsp[0].StrVal));
4924 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004925 break;
4926
4927 case 209:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004928#line 2447 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004929 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004930 break;
4931
Reid Spencerc4d96252007-01-13 00:03:30 +00004932 case 213:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004933#line 2460 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004934 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004935 break;
4936
Reid Spencer319a7302007-01-05 17:20:02 +00004937 case 214:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004938#line 2464 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004939 {
Reid Spencer950bf602007-01-26 08:19:09 +00004940 if ((yyvsp[-1].TypeVal).T->get() == Type::VoidTy)
4941 error("void typed arguments are invalid");
4942 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
4943 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004944 break;
4945
4946 case 215:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004947#line 2472 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004948 {
Reid Spencer950bf602007-01-26 08:19:09 +00004949 (yyval.ArgList) = (yyvsp[-2].ArgList);
4950 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4951 delete (yyvsp[0].ArgVal);
4952 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004953 break;
4954
4955 case 216:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004956#line 2477 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004957 {
4958 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
4959 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4960 delete (yyvsp[0].ArgVal);
4961 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004962 break;
4963
4964 case 217:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004965#line 2485 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004966 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004967 break;
4968
4969 case 218:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004970#line 2486 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004971 {
4972 (yyval.ArgList) = (yyvsp[-2].ArgList);
4973 PATypeInfo VoidTI;
4974 VoidTI.T = new PATypeHolder(Type::VoidTy);
4975 VoidTI.S = Signless;
4976 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4977 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004978 break;
4979
4980 case 219:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004981#line 2493 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004982 {
4983 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
4984 PATypeInfo VoidTI;
4985 VoidTI.T = new PATypeHolder(Type::VoidTy);
4986 VoidTI.S = Signless;
4987 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4988 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004989 break;
4990
4991 case 220:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004992#line 2500 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004993 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004994 break;
4995
4996 case 221:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00004997#line 2504 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004998 {
Reid Spencer950bf602007-01-26 08:19:09 +00004999 UnEscapeLexed((yyvsp[-5].StrVal));
5000 std::string FunctionName((yyvsp[-5].StrVal));
5001 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
5002
5003 const Type* RetTy = (yyvsp[-6].TypeVal).T->get();
5004
5005 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5006 error("LLVM functions cannot return aggregate types");
5007
5008 std::vector<const Type*> ParamTypeList;
5009
5010 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5011 // i8*. We check here for those names and override the parameter list
5012 // types to ensure the prototype is correct.
5013 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5014 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5015 } else if (FunctionName == "llvm.va_copy") {
5016 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5017 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5018 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
5019 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5020 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
5021 const Type *Ty = I->first.T->get();
5022 ParamTypeList.push_back(Ty);
5023 }
5024 }
5025
5026 bool isVarArg =
5027 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5028 if (isVarArg) ParamTypeList.pop_back();
5029
5030 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
5031 const PointerType *PFT = PointerType::get(FT);
5032 delete (yyvsp[-6].TypeVal).T;
5033
5034 ValID ID;
5035 if (!FunctionName.empty()) {
5036 ID = ValID::create((char*)FunctionName.c_str());
5037 } else {
5038 ID = ValID::create((int)CurModule.Values[PFT].size());
5039 }
5040
5041 Function *Fn = 0;
5042 // See if this function was forward referenced. If so, recycle the object.
5043 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5044 // Move the function to the end of the list, from whereever it was
5045 // previously inserted.
5046 Fn = cast<Function>(FWRef);
5047 CurModule.CurrentModule->getFunctionList().remove(Fn);
5048 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5049 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5050 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5051 // If this is the case, either we need to be a forward decl, or it needs
5052 // to be.
5053 if (!CurFun.isDeclare && !Fn->isExternal())
5054 error("Redefinition of function '" + FunctionName + "'");
5055
5056 // Make sure to strip off any argument names so we can't get conflicts.
5057 if (Fn->isExternal())
5058 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5059 AI != AE; ++AI)
5060 AI->setName("");
5061 } else { // Not already defined?
5062 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5063 CurModule.CurrentModule);
5064
5065 InsertValue(Fn, CurModule.Values);
5066 }
5067
5068 CurFun.FunctionStart(Fn);
5069
5070 if (CurFun.isDeclare) {
5071 // If we have declaration, always overwrite linkage. This will allow us
5072 // to correctly handle cases, when pointer to function is passed as
5073 // argument to another function.
5074 Fn->setLinkage(CurFun.Linkage);
5075 }
5076 Fn->setCallingConv((yyvsp[-7].UIntVal));
5077 Fn->setAlignment((yyvsp[0].UIntVal));
5078 if ((yyvsp[-1].StrVal)) {
5079 Fn->setSection((yyvsp[-1].StrVal));
5080 free((yyvsp[-1].StrVal));
5081 }
5082
5083 // Add all of the arguments we parsed to the function...
5084 if ((yyvsp[-3].ArgList)) { // Is null if empty...
5085 if (isVarArg) { // Nuke the last entry
5086 assert((yyvsp[-3].ArgList)->back().first.T->get() == Type::VoidTy &&
5087 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5088 delete (yyvsp[-3].ArgList)->back().first.T;
5089 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
5090 }
5091 Function::arg_iterator ArgIt = Fn->arg_begin();
5092 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5093 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I, ++ArgIt) {
5094 delete I->first.T; // Delete the typeholder...
5095 setValueName(ArgIt, I->second); // Insert arg into symtab...
5096 InsertValue(ArgIt);
5097 }
5098 delete (yyvsp[-3].ArgList); // We're now done with the argument list
5099 }
5100 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005101 break;
5102
5103 case 224:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005104#line 2614 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005105 {
5106 (yyval.FunctionVal) = CurFun.CurrentFunction;
5107
5108 // Make sure that we keep track of the linkage type even if there was a
5109 // previous "declare".
5110 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
5111 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005112 break;
5113
5114 case 227:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005115#line 2628 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005116 {
5117 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5118 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005119 break;
5120
5121 case 229:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005122#line 2634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005123 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5124 break;
5125
5126 case 230:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005127#line 2635 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005128 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5129 break;
5130
5131 case 231:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005132#line 2639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005133 { CurFun.isDeclare = true; ;}
5134 break;
5135
5136 case 232:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005137#line 2639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005138 {
5139 (yyval.FunctionVal) = CurFun.CurrentFunction;
5140 CurFun.FunctionDone();
5141
5142 ;}
5143 break;
5144
5145 case 233:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005146#line 2651 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005147 { (yyval.BoolVal) = false; ;}
5148 break;
5149
5150 case 234:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005151#line 2652 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005152 { (yyval.BoolVal) = true; ;}
5153 break;
5154
5155 case 235:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005156#line 2657 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005157 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
5158 break;
5159
5160 case 236:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005161#line 2658 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005162 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5163 break;
5164
5165 case 237:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005166#line 2659 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005167 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5168 break;
5169
5170 case 238:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005171#line 2660 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005172 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005173 break;
5174
Reid Spencerc4d96252007-01-13 00:03:30 +00005175 case 239:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005176#line 2661 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005177 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5178 break;
5179
5180 case 240:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005181#line 2662 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005182 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005183 break;
5184
Reid Spencerc4d96252007-01-13 00:03:30 +00005185 case 241:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005186#line 2663 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005187 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5188 break;
5189
5190 case 242:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005191#line 2664 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005192 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5193 break;
5194
5195 case 243:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005196#line 2665 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005197 { // Nonempty unsized packed vector
5198 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5199 int NumElements = (yyvsp[-1].ConstVector)->size();
5200 PackedType* pt = PackedType::get(ETy, NumElements);
5201 PATypeHolder* PTy = new PATypeHolder(
5202 HandleUpRefs(PackedType::get(ETy, NumElements)));
5203
5204 // Verify all elements are correct type!
5205 std::vector<Constant*> Elems;
5206 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5207 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
5208 const Type *CTy = C->getType();
5209 if (ETy != CTy)
5210 error("Element #" + utostr(i) + " is not of type '" +
5211 ETy->getDescription() +"' as required!\nIt is of type '" +
5212 CTy->getDescription() + "'");
5213 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005214 }
Reid Spencer950bf602007-01-26 08:19:09 +00005215 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
5216 delete PTy; delete (yyvsp[-1].ConstVector);
5217 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005218 break;
5219
Reid Spencerc4d96252007-01-13 00:03:30 +00005220 case 244:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005221#line 2686 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005222 {
Reid Spencer950bf602007-01-26 08:19:09 +00005223 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
5224 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005225 break;
5226
Reid Spencerc4d96252007-01-13 00:03:30 +00005227 case 245:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005228#line 2689 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005229 {
Reid Spencer950bf602007-01-26 08:19:09 +00005230 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5231 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5232 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5233 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5234 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5235 free((yyvsp[-2].StrVal));
5236 free((yyvsp[0].StrVal));
5237 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005238 break;
5239
Reid Spencerc4d96252007-01-13 00:03:30 +00005240 case 246:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005241#line 2704 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005242 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005243 break;
5244
Reid Spencer319a7302007-01-05 17:20:02 +00005245 case 247:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005246#line 2705 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005247 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005248 break;
5249
5250 case 250:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005251#line 2718 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005252 {
5253 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5254 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5255 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5256 delete (yyvsp[-1].TypeVal).T;
5257 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005258 break;
5259
Reid Spencerc4d96252007-01-13 00:03:30 +00005260 case 251:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005261#line 2727 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005262 {
Reid Spencer950bf602007-01-26 08:19:09 +00005263 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5264 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005265 break;
5266
Reid Spencerc4d96252007-01-13 00:03:30 +00005267 case 252:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005268#line 2730 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005269 { // Do not allow functions with 0 basic blocks
5270 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5271 ;}
5272 break;
5273
5274 case 253:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005275#line 2739 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005276 {
Reid Spencer950bf602007-01-26 08:19:09 +00005277 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5278 InsertValue((yyvsp[0].TermInstVal));
5279 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5280 InsertValue((yyvsp[-2].BasicBlockVal));
5281 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5282 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005283 break;
5284
Reid Spencerc4d96252007-01-13 00:03:30 +00005285 case 254:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005286#line 2749 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005287 {
5288 if ((yyvsp[0].InstVal).I)
5289 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5290 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5291 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005292 break;
5293
Reid Spencerc4d96252007-01-13 00:03:30 +00005294 case 255:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005295#line 2754 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005296 {
5297 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5298 // Make sure to move the basic block to the correct location in the
5299 // function, instead of leaving it inserted wherever it was first
5300 // referenced.
5301 Function::BasicBlockListType &BBL =
5302 CurFun.CurrentFunction->getBasicBlockList();
5303 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5304 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005305 break;
5306
Reid Spencerc4d96252007-01-13 00:03:30 +00005307 case 256:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005308#line 2763 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005309 {
5310 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
5311 // Make sure to move the basic block to the correct location in the
5312 // function, instead of leaving it inserted wherever it was first
5313 // referenced.
5314 Function::BasicBlockListType &BBL =
5315 CurFun.CurrentFunction->getBasicBlockList();
5316 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5317 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005318 break;
5319
Reid Spencerc4d96252007-01-13 00:03:30 +00005320 case 259:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005321#line 2777 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005322 { // Return with a result...
5323 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
5324 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005325 break;
5326
Reid Spencerc4d96252007-01-13 00:03:30 +00005327 case 260:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005328#line 2780 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005329 { // Return with no result...
5330 (yyval.TermInstVal) = new ReturnInst();
5331 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005332 break;
5333
Reid Spencerc4d96252007-01-13 00:03:30 +00005334 case 261:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005335#line 2783 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005336 { // Unconditional Branch...
5337 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5338 (yyval.TermInstVal) = new BranchInst(tmpBB);
5339 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005340 break;
5341
Reid Spencer319a7302007-01-05 17:20:02 +00005342 case 262:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005343#line 2787 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005344 {
5345 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5346 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5347 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5348 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5349 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005350 break;
5351
5352 case 263:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005353#line 2793 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005354 {
Reid Spencer950bf602007-01-26 08:19:09 +00005355 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5356 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5357 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5358 (yyval.TermInstVal) = S;
5359 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5360 E = (yyvsp[-1].JumpTable)->end();
5361 for (; I != E; ++I) {
5362 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5363 S->addCase(CI, I->second);
5364 else
5365 error("Switch case is constant, but not a simple integer");
5366 }
5367 delete (yyvsp[-1].JumpTable);
5368 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005369 break;
5370
5371 case 264:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005372#line 2808 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005373 {
Reid Spencer950bf602007-01-26 08:19:09 +00005374 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5375 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
5376 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5377 (yyval.TermInstVal) = S;
5378 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005379 break;
5380
Reid Spencerc4d96252007-01-13 00:03:30 +00005381 case 265:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005382#line 2815 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005383 {
Reid Spencer950bf602007-01-26 08:19:09 +00005384 const PointerType *PFTy;
5385 const FunctionType *Ty;
5386
5387 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).T->get())) ||
5388 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5389 // Pull out the types of all of the arguments...
5390 std::vector<const Type*> ParamTypes;
5391 if ((yyvsp[-7].ValueList)) {
5392 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
5393 I != E; ++I)
5394 ParamTypes.push_back((*I).V->getType());
5395 }
5396 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5397 if (isVarArg) ParamTypes.pop_back();
5398 Ty = FunctionType::get((yyvsp[-10].TypeVal).T->get(), ParamTypes, isVarArg);
5399 PFTy = PointerType::get(Ty);
5400 }
5401 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5402 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5403 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
5404
5405 // Create the call node...
5406 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
5407 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5408 } else { // Has arguments?
5409 // Loop through FunctionType's arguments and ensure they are specified
5410 // correctly!
5411 //
5412 FunctionType::param_iterator I = Ty->param_begin();
5413 FunctionType::param_iterator E = Ty->param_end();
5414 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
5415
5416 std::vector<Value*> Args;
5417 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5418 if ((*ArgI).V->getType() != *I)
5419 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5420 (*I)->getDescription() + "'");
5421 Args.push_back((*ArgI).V);
5422 }
5423
5424 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5425 error("Invalid number of parameters detected");
5426
5427 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5428 }
5429 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
5430 delete (yyvsp[-10].TypeVal).T;
5431 delete (yyvsp[-7].ValueList);
5432 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005433 break;
5434
Reid Spencerc4d96252007-01-13 00:03:30 +00005435 case 266:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005436#line 2865 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005437 {
Reid Spencer950bf602007-01-26 08:19:09 +00005438 (yyval.TermInstVal) = new UnwindInst();
5439 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005440 break;
5441
Reid Spencerc4d96252007-01-13 00:03:30 +00005442 case 267:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005443#line 2868 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005444 {
5445 (yyval.TermInstVal) = new UnreachableInst();
5446 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005447 break;
5448
Reid Spencerc4d96252007-01-13 00:03:30 +00005449 case 268:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005450#line 2874 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005451 {
Reid Spencer950bf602007-01-26 08:19:09 +00005452 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5453 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5454
5455 if (V == 0)
5456 error("May only switch on a constant pool value");
5457
5458 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5459 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5460 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005461 break;
5462
Reid Spencerc4d96252007-01-13 00:03:30 +00005463 case 269:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005464#line 2884 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005465 {
Reid Spencer950bf602007-01-26 08:19:09 +00005466 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5467 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5468
5469 if (V == 0)
5470 error("May only switch on a constant pool value");
5471
5472 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5473 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5474 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005475 break;
5476
Reid Spencerc4d96252007-01-13 00:03:30 +00005477 case 270:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005478#line 2897 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005479 {
Reid Spencer950bf602007-01-26 08:19:09 +00005480 bool omit = false;
5481 if ((yyvsp[-1].StrVal))
5482 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
5483 if (BCI->getSrcTy() == BCI->getDestTy() &&
5484 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
5485 // This is a useless bit cast causing a name redefinition. It is
5486 // a bit cast from a type to the same type of an operand with the
5487 // same name as the name we would give this instruction. Since this
5488 // instruction results in no code generation, it is safe to omit
5489 // the instruction. This situation can occur because of collapsed
5490 // type planes. For example:
5491 // %X = add int %Y, %Z
5492 // %X = cast int %Y to uint
5493 // After upgrade, this looks like:
5494 // %X = add i32 %Y, %Z
5495 // %X = bitcast i32 to i32
5496 // The bitcast is clearly useless so we omit it.
5497 omit = true;
5498 if (omit) {
5499 (yyval.InstVal).I = 0;
5500 (yyval.InstVal).S = Signless;
5501 } else {
5502 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5503 InsertValue((yyvsp[0].InstVal).I);
5504 (yyval.InstVal) = (yyvsp[0].InstVal);
5505 }
5506 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005507 break;
5508
Reid Spencerc4d96252007-01-13 00:03:30 +00005509 case 271:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005510#line 2926 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005511 { // Used for PHI nodes
5512 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5513 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5514 Value* tmpVal = getVal((yyvsp[-5].TypeVal).T->get(), (yyvsp[-3].ValIDVal));
5515 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5516 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5517 delete (yyvsp[-5].TypeVal).T;
5518 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005519 break;
5520
Reid Spencerc4d96252007-01-13 00:03:30 +00005521 case 272:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005522#line 2934 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005523 {
5524 (yyval.PHIList) = (yyvsp[-6].PHIList);
5525 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5526 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5527 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5528 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005529 break;
5530
Reid Spencerc4d96252007-01-13 00:03:30 +00005531 case 273:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005532#line 2942 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005533 { // Used for call statements, and memory insts...
5534 (yyval.ValueList) = new std::vector<ValueInfo>();
5535 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5536 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005537 break;
5538
Reid Spencer950bf602007-01-26 08:19:09 +00005539 case 274:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005540#line 2946 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005541 {
Reid Spencer950bf602007-01-26 08:19:09 +00005542 (yyval.ValueList) = (yyvsp[-2].ValueList);
5543 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
5544 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005545 break;
5546
Reid Spencerc4d96252007-01-13 00:03:30 +00005547 case 276:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005548#line 2954 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005549 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005550 break;
5551
Reid Spencerc4d96252007-01-13 00:03:30 +00005552 case 277:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005553#line 2958 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005554 {
Reid Spencer950bf602007-01-26 08:19:09 +00005555 (yyval.BoolVal) = true;
5556 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005557 break;
5558
Reid Spencer319a7302007-01-05 17:20:02 +00005559 case 278:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005560#line 2961 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005561 {
Reid Spencer950bf602007-01-26 08:19:09 +00005562 (yyval.BoolVal) = false;
5563 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005564 break;
5565
5566 case 279:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005567#line 2967 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005568 {
Reid Spencer950bf602007-01-26 08:19:09 +00005569 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
5570 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5571 error("Arithmetic operator requires integer, FP, or packed operands");
5572 if (isa<PackedType>(Ty) &&
5573 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
5574 error("Remainder not supported on packed types");
5575 // Upgrade the opcode from obsolete versions before we do anything with it.
5576 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5577 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5578 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
5579 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5580 if ((yyval.InstVal).I == 0)
5581 error("binary operator returned null");
5582 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5583 delete (yyvsp[-3].TypeVal).T;
5584 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005585 break;
5586
5587 case 280:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005588#line 2984 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005589 {
Reid Spencer950bf602007-01-26 08:19:09 +00005590 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5591 if (!Ty->isInteger()) {
5592 if (!isa<PackedType>(Ty) ||
5593 !cast<PackedType>(Ty)->getElementType()->isInteger())
5594 error("Logical operator requires integral operands");
5595 }
5596 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5597 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5598 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5599 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5600 if ((yyval.InstVal).I == 0)
5601 error("binary operator returned null");
5602 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5603 delete (yyvsp[-3].TypeVal).T;
5604 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005605 break;
5606
Reid Spencerc4d96252007-01-13 00:03:30 +00005607 case 281:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005608#line 3000 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005609 {
Reid Spencer950bf602007-01-26 08:19:09 +00005610 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
5611 if(isa<PackedType>(Ty))
5612 error("PackedTypes currently not supported in setcc instructions");
5613 unsigned short pred;
5614 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5615 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5616 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5617 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5618 if ((yyval.InstVal).I == 0)
5619 error("binary operator returned null");
5620 (yyval.InstVal).S = Unsigned;
5621 delete (yyvsp[-3].TypeVal).T;
5622 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005623 break;
5624
Reid Spencerc4d96252007-01-13 00:03:30 +00005625 case 282:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005626#line 3014 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005627 {
Reid Spencer950bf602007-01-26 08:19:09 +00005628 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5629 if (isa<PackedType>(Ty))
5630 error("PackedTypes currently not supported in icmp instructions");
5631 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5632 error("icmp requires integer or pointer typed operands");
5633 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5634 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5635 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
5636 (yyval.InstVal).S = Unsigned;
5637 delete (yyvsp[-3].TypeVal).T;
5638 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005639 break;
5640
Reid Spencerc4d96252007-01-13 00:03:30 +00005641 case 283:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005642#line 3026 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005643 {
Reid Spencer950bf602007-01-26 08:19:09 +00005644 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5645 if (isa<PackedType>(Ty))
5646 error("PackedTypes currently not supported in fcmp instructions");
5647 else if (!Ty->isFloatingPoint())
5648 error("fcmp instruction requires floating point operands");
5649 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5650 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5651 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
5652 (yyval.InstVal).S = Unsigned;
5653 delete (yyvsp[-3].TypeVal).T;
5654 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005655 break;
5656
Reid Spencerc4d96252007-01-13 00:03:30 +00005657 case 284:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005658#line 3038 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005659 {
Reid Spencer950bf602007-01-26 08:19:09 +00005660 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5661 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
5662 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5663 if (Ones == 0)
5664 error("Expected integral type for not instruction");
5665 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
5666 if ((yyval.InstVal).I == 0)
5667 error("Could not create a xor instruction");
5668 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
5669 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005670 break;
5671
5672 case 285:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005673#line 3049 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005674 {
Reid Spencer950bf602007-01-26 08:19:09 +00005675 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5676 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
5677 error("Shift amount must be int8");
5678 if (!(yyvsp[-2].ValueVal).V->getType()->isInteger())
5679 error("Shift constant expression requires integer operand");
5680 (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5681 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5682 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005683 break;
5684
5685 case 286:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005686#line 3058 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005687 {
Reid Spencer950bf602007-01-26 08:19:09 +00005688 const Type *DstTy = (yyvsp[0].TypeVal).T->get();
5689 if (!DstTy->isFirstClassType())
5690 error("cast instruction to a non-primitive type: '" +
5691 DstTy->getDescription() + "'");
5692 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5693 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5694 delete (yyvsp[0].TypeVal).T;
5695 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005696 break;
5697
5698 case 287:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005699#line 3067 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005700 {
Reid Spencer950bf602007-01-26 08:19:09 +00005701 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5702 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
5703 error("select condition must be bool");
5704 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
5705 error("select value types should match");
5706 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5707 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5708 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005709 break;
5710
Reid Spencerc4d96252007-01-13 00:03:30 +00005711 case 288:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005712#line 3076 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005713 {
Reid Spencer950bf602007-01-26 08:19:09 +00005714 const Type *Ty = (yyvsp[0].TypeVal).T->get();
5715 NewVarArgs = true;
5716 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5717 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5718 delete (yyvsp[0].TypeVal).T;
5719 ;}
5720 break;
5721
5722 case 289:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005723#line 3083 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005724 {
5725 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5726 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
5727 ObsoleteVarArgs = true;
5728 Function* NF = cast<Function>(CurModule.CurrentModule->
5729 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5730
5731 //b = vaarg a, t ->
5732 //foo = alloca 1 of t
5733 //bar = vacopy a
5734 //store bar -> foo
5735 //b = vaarg foo, t
5736 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5737 CurBB->getInstList().push_back(foo);
5738 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5739 CurBB->getInstList().push_back(bar);
5740 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5741 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5742 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5743 delete (yyvsp[0].TypeVal).T;
5744 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005745 break;
5746
Reid Spencerc4d96252007-01-13 00:03:30 +00005747 case 290:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005748#line 3104 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005749 {
5750 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5751 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
5752 ObsoleteVarArgs = true;
5753 Function* NF = cast<Function>(CurModule.CurrentModule->
5754 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5755
5756 //b = vanext a, t ->
5757 //foo = alloca 1 of t
5758 //bar = vacopy a
5759 //store bar -> foo
5760 //tmp = vaarg foo, t
5761 //b = load foo
5762 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5763 CurBB->getInstList().push_back(foo);
5764 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5765 CurBB->getInstList().push_back(bar);
5766 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5767 Instruction* tmp = new VAArgInst(foo, DstTy);
5768 CurBB->getInstList().push_back(tmp);
5769 (yyval.InstVal).I = new LoadInst(foo);
5770 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5771 delete (yyvsp[0].TypeVal).T;
5772 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005773 break;
5774
Reid Spencerc4d96252007-01-13 00:03:30 +00005775 case 291:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005776#line 3128 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005777 {
5778 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5779 error("Invalid extractelement operands");
5780 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5781 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5782 ;}
5783 break;
5784
5785 case 292:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005786#line 3134 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005787 {
5788 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5789 error("Invalid insertelement operands");
5790 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5791 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5792 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005793 break;
5794
Reid Spencerc4d96252007-01-13 00:03:30 +00005795 case 293:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005796#line 3140 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005797 {
5798 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5799 error("Invalid shufflevector operands");
5800 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5801 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5802 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005803 break;
5804
Reid Spencerc4d96252007-01-13 00:03:30 +00005805 case 294:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005806#line 3146 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005807 {
Reid Spencer950bf602007-01-26 08:19:09 +00005808 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
5809 if (!Ty->isFirstClassType())
5810 error("PHI node operands must be of first class type");
5811 PHINode *PHI = new PHINode(Ty);
5812 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5813 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5814 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
5815 error("All elements of a PHI node must be of the same type");
5816 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5817 (yyvsp[0].PHIList).P->pop_front();
5818 }
5819 (yyval.InstVal).I = PHI;
5820 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5821 delete (yyvsp[0].PHIList).P; // Free the list...
5822 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005823 break;
5824
5825 case 295:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005826#line 3162 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005827 {
Reid Spencer950bf602007-01-26 08:19:09 +00005828
5829 // Handle the short call syntax
5830 const PointerType *PFTy;
5831 const FunctionType *FTy;
5832 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).T->get())) ||
5833 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5834 // Pull out the types of all of the arguments...
5835 std::vector<const Type*> ParamTypes;
5836 if ((yyvsp[-1].ValueList)) {
5837 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
5838 I != E; ++I)
5839 ParamTypes.push_back((*I).V->getType());
5840 }
5841
5842 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5843 if (isVarArg) ParamTypes.pop_back();
5844
5845 const Type *RetTy = (yyvsp[-4].TypeVal).T->get();
5846 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5847 error("Functions cannot return aggregate types");
5848
5849 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
5850 PFTy = PointerType::get(FTy);
5851 }
5852
5853 // First upgrade any intrinsic calls.
5854 std::vector<Value*> Args;
5855 if ((yyvsp[-1].ValueList))
5856 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
5857 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
5858 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
5859
5860 // If we got an upgraded intrinsic
5861 if (Inst) {
5862 (yyval.InstVal).I = Inst;
5863 (yyval.InstVal).S = Signless;
5864 } else {
5865 // Get the function we're calling
5866 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
5867
5868 // Check the argument values match
5869 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
5870 // Make sure no arguments is a good thing!
5871 if (FTy->getNumParams() != 0)
5872 error("No arguments passed to a function that expects arguments");
5873 } else { // Has arguments?
5874 // Loop through FunctionType's arguments and ensure they are specified
5875 // correctly!
5876 //
5877 FunctionType::param_iterator I = FTy->param_begin();
5878 FunctionType::param_iterator E = FTy->param_end();
5879 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
5880
5881 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5882 if ((*ArgI).V->getType() != *I)
5883 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5884 (*I)->getDescription() + "'");
5885
5886 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
5887 error("Invalid number of parameters detected");
5888 }
5889
5890 // Create the call instruction
5891 CallInst *CI = new CallInst(V, Args);
5892 CI->setTailCall((yyvsp[-6].BoolVal));
5893 CI->setCallingConv((yyvsp[-5].UIntVal));
5894 (yyval.InstVal).I = CI;
5895 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5896 }
5897 delete (yyvsp[-4].TypeVal).T;
5898 delete (yyvsp[-1].ValueList);
5899 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005900 break;
5901
Reid Spencerc4d96252007-01-13 00:03:30 +00005902 case 296:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005903#line 3235 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005904 {
Reid Spencer950bf602007-01-26 08:19:09 +00005905 (yyval.InstVal) = (yyvsp[0].InstVal);
5906 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005907 break;
5908
Reid Spencer609ca3e2007-01-12 20:10:51 +00005909 case 297:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005910#line 3243 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005911 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005912 break;
5913
5914 case 298:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005915#line 3244 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005916 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005917 break;
5918
Reid Spencerc4d96252007-01-13 00:03:30 +00005919 case 299:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005920#line 3248 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005921 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005922 break;
5923
Reid Spencerc4d96252007-01-13 00:03:30 +00005924 case 300:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005925#line 3249 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005926 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005927 break;
5928
Reid Spencerc4d96252007-01-13 00:03:30 +00005929 case 301:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005930#line 3253 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005931 {
Reid Spencer950bf602007-01-26 08:19:09 +00005932 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5933 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5934 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
5935 delete (yyvsp[-1].TypeVal).T;
5936 ;}
5937 break;
5938
5939 case 302:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005940#line 3259 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005941 {
5942 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
5943 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5944 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
5945 delete (yyvsp[-4].TypeVal).T;
5946 ;}
5947 break;
5948
5949 case 303:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005950#line 3265 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005951 {
5952 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5953 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5954 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
5955 delete (yyvsp[-1].TypeVal).T;
5956 ;}
5957 break;
5958
5959 case 304:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005960#line 3271 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005961 {
5962 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
5963 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5964 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
5965 delete (yyvsp[-4].TypeVal).T;
5966 ;}
5967 break;
5968
5969 case 305:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005970#line 3277 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005971 {
5972 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
5973 if (!isa<PointerType>(PTy))
5974 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
5975 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
5976 (yyval.InstVal).S = Signless;
5977 ;}
5978 break;
5979
5980 case 306:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005981#line 3284 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005982 {
5983 const Type* Ty = (yyvsp[-1].TypeVal).T->get();
5984 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5985 if (!isa<PointerType>(Ty))
5986 error("Can't load from nonpointer type: " + Ty->getDescription());
5987 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
5988 error("Can't load from pointer of non-first-class type: " +
5989 Ty->getDescription());
5990 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
5991 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5992 delete (yyvsp[-1].TypeVal).T;
5993 ;}
5994 break;
5995
5996 case 307:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00005997#line 3296 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005998 {
5999 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
6000 if (!PTy)
6001 error("Can't store to a nonpointer type: " +
6002 (yyvsp[-1].TypeVal).T->get()->getDescription());
6003 const Type *ElTy = PTy->getElementType();
6004 if (ElTy != (yyvsp[-3].ValueVal).V->getType())
6005 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
6006 "' into space of type '" + ElTy->getDescription() + "'");
6007 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6008 (yyval.InstVal).I = new StoreInst((yyvsp[-3].ValueVal).V, tmpVal, (yyvsp[-5].BoolVal));
6009 (yyval.InstVal).S = Signless;
6010 delete (yyvsp[-1].TypeVal).T;
6011 ;}
6012 break;
6013
6014 case 308:
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00006015#line 3310 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006016 {
6017 const Type* Ty = (yyvsp[-2].TypeVal).T->get();
6018 if (!isa<PointerType>(Ty))
6019 error("getelementptr insn requires pointer operand");
6020
6021 std::vector<Value*> VIndices;
6022 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
6023
6024 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
6025 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6026 (yyval.InstVal).S = Signless;
6027 delete (yyvsp[-2].TypeVal).T;
6028 delete (yyvsp[0].ValueList);
6029 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006030 break;
6031
6032
Reid Spencer950bf602007-01-26 08:19:09 +00006033 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006034 }
6035
Reid Spencer950bf602007-01-26 08:19:09 +00006036/* Line 1126 of yacc.c. */
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00006037#line 6038 "UpgradeParser.tab.c"
Reid Spencere7c3c602006-11-30 06:36:44 +00006038
6039 yyvsp -= yylen;
6040 yyssp -= yylen;
6041
Reid Spencer319a7302007-01-05 17:20:02 +00006042
Reid Spencer950bf602007-01-26 08:19:09 +00006043 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006044
6045 *++yyvsp = yyval;
6046
6047
Reid Spencer319a7302007-01-05 17:20:02 +00006048 /* Now `shift' the result of the reduction. Determine what state
6049 that goes to, based on the state we popped back to and the rule
6050 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006051
6052 yyn = yyr1[yyn];
6053
Reid Spencer319a7302007-01-05 17:20:02 +00006054 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6055 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006056 yystate = yytable[yystate];
6057 else
Reid Spencer319a7302007-01-05 17:20:02 +00006058 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006059
6060 goto yynewstate;
6061
6062
Reid Spencer319a7302007-01-05 17:20:02 +00006063/*------------------------------------.
6064| yyerrlab -- here on detecting error |
6065`------------------------------------*/
6066yyerrlab:
6067 /* If not already recovering from an error, report this error. */
6068 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006069 {
6070 ++yynerrs;
Reid Spencer319a7302007-01-05 17:20:02 +00006071#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00006072 yyn = yypact[yystate];
6073
Reid Spencer319a7302007-01-05 17:20:02 +00006074 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencere7c3c602006-11-30 06:36:44 +00006075 {
Reid Spencer319a7302007-01-05 17:20:02 +00006076 int yytype = YYTRANSLATE (yychar);
Reid Spencer950bf602007-01-26 08:19:09 +00006077 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6078 YYSIZE_T yysize = yysize0;
6079 YYSIZE_T yysize1;
6080 int yysize_overflow = 0;
6081 char *yymsg = 0;
6082# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6083 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6084 int yyx;
Reid Spencere7c3c602006-11-30 06:36:44 +00006085
Reid Spencer950bf602007-01-26 08:19:09 +00006086#if 0
6087 /* This is so xgettext sees the translatable formats that are
6088 constructed on the fly. */
6089 YY_("syntax error, unexpected %s");
6090 YY_("syntax error, unexpected %s, expecting %s");
6091 YY_("syntax error, unexpected %s, expecting %s or %s");
6092 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6093 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6094#endif
6095 char *yyfmt;
6096 char const *yyf;
6097 static char const yyunexpected[] = "syntax error, unexpected %s";
6098 static char const yyexpecting[] = ", expecting %s";
6099 static char const yyor[] = " or %s";
6100 char yyformat[sizeof yyunexpected
6101 + sizeof yyexpecting - 1
6102 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6103 * (sizeof yyor - 1))];
6104 char const *yyprefix = yyexpecting;
6105
Reid Spencer319a7302007-01-05 17:20:02 +00006106 /* Start YYX at -YYN if negative to avoid negative indexes in
6107 YYCHECK. */
Reid Spencer950bf602007-01-26 08:19:09 +00006108 int yyxbegin = yyn < 0 ? -yyn : 0;
Jeff Cohenac2dca92007-01-21 19:30:52 +00006109
Reid Spencer950bf602007-01-26 08:19:09 +00006110 /* Stay within bounds of both yycheck and yytname. */
6111 int yychecklim = YYLAST - yyn;
6112 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6113 int yycount = 1;
6114
6115 yyarg[0] = yytname[yytype];
6116 yyfmt = yystpcpy (yyformat, yyunexpected);
6117
6118 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6119 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6120 {
6121 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6122 {
6123 yycount = 1;
6124 yysize = yysize0;
6125 yyformat[sizeof yyunexpected - 1] = '\0';
6126 break;
6127 }
6128 yyarg[yycount++] = yytname[yyx];
6129 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6130 yysize_overflow |= yysize1 < yysize;
6131 yysize = yysize1;
6132 yyfmt = yystpcpy (yyfmt, yyprefix);
6133 yyprefix = yyor;
6134 }
6135
6136 yyf = YY_(yyformat);
6137 yysize1 = yysize + yystrlen (yyf);
6138 yysize_overflow |= yysize1 < yysize;
6139 yysize = yysize1;
6140
6141 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6142 yymsg = (char *) YYSTACK_ALLOC (yysize);
6143 if (yymsg)
6144 {
6145 /* Avoid sprintf, as that infringes on the user's name space.
6146 Don't have undefined behavior even if the translation
6147 produced a string with the wrong number of "%s"s. */
6148 char *yyp = yymsg;
6149 int yyi = 0;
6150 while ((*yyp = *yyf))
Reid Spencere7c3c602006-11-30 06:36:44 +00006151 {
Reid Spencer950bf602007-01-26 08:19:09 +00006152 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6153 {
6154 yyp += yytnamerr (yyp, yyarg[yyi++]);
6155 yyf += 2;
6156 }
6157 else
6158 {
6159 yyp++;
6160 yyf++;
6161 }
Reid Spencere7c3c602006-11-30 06:36:44 +00006162 }
Reid Spencer319a7302007-01-05 17:20:02 +00006163 yyerror (yymsg);
6164 YYSTACK_FREE (yymsg);
Reid Spencere7c3c602006-11-30 06:36:44 +00006165 }
6166 else
Reid Spencer950bf602007-01-26 08:19:09 +00006167 {
6168 yyerror (YY_("syntax error"));
6169 goto yyexhaustedlab;
6170 }
Reid Spencere7c3c602006-11-30 06:36:44 +00006171 }
6172 else
6173#endif /* YYERROR_VERBOSE */
Reid Spencer950bf602007-01-26 08:19:09 +00006174 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006175 }
Reid Spencer950bf602007-01-26 08:19:09 +00006176
6177
6178
6179 if (yyerrstatus == 3)
6180 {
6181 /* If just tried and failed to reuse look-ahead token after an
6182 error, discard it. */
6183
6184 if (yychar <= YYEOF)
6185 {
6186 /* Return failure if at end of input. */
6187 if (yychar == YYEOF)
6188 YYABORT;
6189 }
6190 else
6191 {
6192 yydestruct ("Error: discarding", yytoken, &yylval);
6193 yychar = YYEMPTY;
6194 }
6195 }
6196
6197 /* Else will try to reuse look-ahead token after shifting the error
6198 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006199 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006200
Reid Spencer319a7302007-01-05 17:20:02 +00006201
Reid Spencer950bf602007-01-26 08:19:09 +00006202/*---------------------------------------------------.
6203| yyerrorlab -- error raised explicitly by YYERROR. |
6204`---------------------------------------------------*/
6205yyerrorlab:
6206
6207 /* Pacify compilers like GCC when the user code never invokes
6208 YYERROR and the label yyerrorlab therefore never appears in user
6209 code. */
6210 if (0)
6211 goto yyerrorlab;
6212
6213yyvsp -= yylen;
6214 yyssp -= yylen;
6215 yystate = *yyssp;
6216 goto yyerrlab1;
6217
6218
6219/*-------------------------------------------------------------.
6220| yyerrlab1 -- common code for both syntax error and YYERROR. |
6221`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006222yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006223 yyerrstatus = 3; /* Each real token shifted decrements this. */
6224
6225 for (;;)
6226 {
6227 yyn = yypact[yystate];
6228 if (yyn != YYPACT_NINF)
6229 {
6230 yyn += YYTERROR;
6231 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6232 {
6233 yyn = yytable[yyn];
6234 if (0 < yyn)
6235 break;
6236 }
6237 }
6238
6239 /* Pop the current state because it cannot handle the error token. */
6240 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006241 YYABORT;
6242
6243
Reid Spencer950bf602007-01-26 08:19:09 +00006244 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6245 YYPOPSTACK;
6246 yystate = *yyssp;
6247 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006248 }
6249
6250 if (yyn == YYFINAL)
6251 YYACCEPT;
6252
6253 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006254
6255
Reid Spencer950bf602007-01-26 08:19:09 +00006256 /* Shift the error token. */
6257 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6258
Reid Spencere7c3c602006-11-30 06:36:44 +00006259 yystate = yyn;
6260 goto yynewstate;
6261
Chris Lattner37e01c52007-01-04 18:46:42 +00006262
Reid Spencer319a7302007-01-05 17:20:02 +00006263/*-------------------------------------.
6264| yyacceptlab -- YYACCEPT comes here. |
6265`-------------------------------------*/
6266yyacceptlab:
6267 yyresult = 0;
6268 goto yyreturn;
6269
6270/*-----------------------------------.
6271| yyabortlab -- YYABORT comes here. |
6272`-----------------------------------*/
6273yyabortlab:
6274 yyresult = 1;
6275 goto yyreturn;
6276
6277#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006278/*-------------------------------------------------.
6279| yyexhaustedlab -- memory exhaustion comes here. |
6280`-------------------------------------------------*/
6281yyexhaustedlab:
6282 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006283 yyresult = 2;
6284 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006285#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006286
6287yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006288 if (yychar != YYEOF && yychar != YYEMPTY)
6289 yydestruct ("Cleanup: discarding lookahead",
6290 yytoken, &yylval);
6291 while (yyssp != yyss)
6292 {
6293 yydestruct ("Cleanup: popping",
6294 yystos[*yyssp], yyvsp);
6295 YYPOPSTACK;
6296 }
Reid Spencer319a7302007-01-05 17:20:02 +00006297#ifndef yyoverflow
6298 if (yyss != yyssa)
6299 YYSTACK_FREE (yyss);
6300#endif
6301 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006302}
Reid Spencer319a7302007-01-05 17:20:02 +00006303
6304
Reid Spencer3c0f6cf2007-01-28 00:52:05 +00006305#line 3326 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006306
6307
6308int yyerror(const char *ErrorMsg) {
6309 std::string where
6310 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006311 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6312 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6313 if (yychar != YYEMPTY && yychar != 0)
6314 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6315 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006316 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006317 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006318 exit(1);
6319}
Reid Spencer319a7302007-01-05 17:20:02 +00006320
Reid Spencer30d0c582007-01-15 00:26:18 +00006321void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006322 std::string where
6323 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006324 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6325 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6326 if (yychar != YYEMPTY && yychar != 0)
6327 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6328 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006329 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6330}
6331
Reid Spencer950bf602007-01-26 08:19:09 +00006332void error(const std::string& ErrorMsg, int LineNo) {
6333 if (LineNo == -1) LineNo = Upgradelineno;
6334 Upgradelineno = LineNo;
6335 yyerror(ErrorMsg.c_str());
6336}
6337
6338