blob: d1895a91b248a7e0bedbf638d047ab33d33ed267 [file] [log] [blame]
Reid Spencerb7046c72007-01-29 05:41:34 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Reid Spencerb7046c72007-01-29 05:41:34 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00005
Reid Spencer319a7302007-01-05 17:20:02 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Reid Spencere7c3c602006-11-30 06:36:44 +000010
Reid Spencer319a7302007-01-05 17:20:02 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
Reid Spencer950bf602007-01-26 08:19:09 +000018 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
Reid Spencer319a7302007-01-05 17:20:02 +000020
Reid Spencerb7046c72007-01-29 05:41:34 +000021/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
Reid Spencer319a7302007-01-05 17:20:02 +000025
Reid Spencerb7046c72007-01-29 05:41:34 +000026/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
Reid Spencer319a7302007-01-05 17:20:02 +000028
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
Reid Spencer950bf602007-01-26 08:19:09 +000037#define YYBISON 1
38
39/* Bison version. */
Reid Spencerb7046c72007-01-29 05:41:34 +000040#define YYBISON_VERSION "2.1"
Reid Spencer950bf602007-01-26 08:19:09 +000041
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
Reid Spencer319a7302007-01-05 17:20:02 +000044
45/* Pure parsers. */
Reid Spencer950bf602007-01-26 08:19:09 +000046#define YYPURE 0
Reid Spencer319a7302007-01-05 17:20:02 +000047
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
Reid Spencer950bf602007-01-26 08:19:09 +000051/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000052#define yyparse Upgradeparse
Reid Spencer319a7302007-01-05 17:20:02 +000053#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000054#define yyerror Upgradeerror
Reid Spencer319a7302007-01-05 17:20:02 +000055#define yylval Upgradelval
56#define yychar Upgradechar
Reid Spencere7c3c602006-11-30 06:36:44 +000057#define yydebug Upgradedebug
58#define yynerrs Upgradenerrs
59
Reid Spencere7c3c602006-11-30 06:36:44 +000060
Reid Spencer319a7302007-01-05 17:20:02 +000061/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
Reid Spencer950bf602007-01-26 08:19:09 +000067 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 BOOL = 264,
74 SBYTE = 265,
75 UBYTE = 266,
76 SHORT = 267,
77 USHORT = 268,
78 INT = 269,
79 UINT = 270,
80 LONG = 271,
81 ULONG = 272,
82 FLOAT = 273,
83 DOUBLE = 274,
84 TYPE = 275,
85 LABEL = 276,
86 VAR_ID = 277,
87 LABELSTR = 278,
88 STRINGCONSTANT = 279,
89 IMPLEMENTATION = 280,
90 ZEROINITIALIZER = 281,
91 TRUETOK = 282,
92 FALSETOK = 283,
93 BEGINTOK = 284,
94 ENDTOK = 285,
95 DECLARE = 286,
96 GLOBAL = 287,
97 CONSTANT = 288,
98 SECTION = 289,
99 VOLATILE = 290,
100 TO = 291,
101 DOTDOTDOT = 292,
102 NULL_TOK = 293,
103 UNDEF = 294,
104 CONST = 295,
105 INTERNAL = 296,
106 LINKONCE = 297,
107 WEAK = 298,
108 APPENDING = 299,
Reid Spencer319a7302007-01-05 17:20:02 +0000109 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
Reid Spencer950bf602007-01-26 08:19:09 +0000112 OPAQUE = 303,
113 NOT = 304,
114 EXTERNAL = 305,
115 TARGET = 306,
116 TRIPLE = 307,
117 ENDIAN = 308,
118 POINTERSIZE = 309,
119 LITTLE = 310,
120 BIG = 311,
121 ALIGN = 312,
Reid Spencerc4d96252007-01-13 00:03:30 +0000122 DEPLIBS = 313,
123 CALL = 314,
124 TAIL = 315,
125 ASM_TOK = 316,
126 MODULE = 317,
127 SIDEEFFECT = 318,
128 CC_TOK = 319,
129 CCC_TOK = 320,
130 CSRETCC_TOK = 321,
131 FASTCC_TOK = 322,
132 COLDCC_TOK = 323,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
135 DATALAYOUT = 326,
136 RET = 327,
137 BR = 328,
138 SWITCH = 329,
139 INVOKE = 330,
Reid Spencer950bf602007-01-26 08:19:09 +0000140 UNREACHABLE = 331,
Reid Spencerc4d96252007-01-13 00:03:30 +0000141 UNWIND = 332,
Reid Spencer950bf602007-01-26 08:19:09 +0000142 EXCEPT = 333,
Reid Spencerc4d96252007-01-13 00:03:30 +0000143 ADD = 334,
144 SUB = 335,
145 MUL = 336,
146 DIV = 337,
147 UDIV = 338,
148 SDIV = 339,
149 FDIV = 340,
150 REM = 341,
151 UREM = 342,
152 SREM = 343,
153 FREM = 344,
154 AND = 345,
155 OR = 346,
156 XOR = 347,
157 SETLE = 348,
158 SETGE = 349,
159 SETLT = 350,
160 SETGT = 351,
161 SETEQ = 352,
162 SETNE = 353,
163 ICMP = 354,
164 FCMP = 355,
Reid Spencer950bf602007-01-26 08:19:09 +0000165 MALLOC = 356,
166 ALLOCA = 357,
167 FREE = 358,
168 LOAD = 359,
169 STORE = 360,
170 GETELEMENTPTR = 361,
171 PHI_TOK = 362,
172 SELECT = 363,
173 SHL = 364,
174 SHR = 365,
175 ASHR = 366,
176 LSHR = 367,
177 VAARG = 368,
178 EXTRACTELEMENT = 369,
179 INSERTELEMENT = 370,
180 SHUFFLEVECTOR = 371,
181 VAARG_old = 372,
182 VANEXT_old = 373,
183 EQ = 374,
184 NE = 375,
185 SLT = 376,
186 SGT = 377,
187 SLE = 378,
188 SGE = 379,
189 ULT = 380,
190 UGT = 381,
191 ULE = 382,
192 UGE = 383,
193 OEQ = 384,
194 ONE = 385,
195 OLT = 386,
196 OGT = 387,
197 OLE = 388,
198 OGE = 389,
199 ORD = 390,
200 UNO = 391,
201 UEQ = 392,
202 UNE = 393,
203 CAST = 394,
204 TRUNC = 395,
205 ZEXT = 396,
206 SEXT = 397,
207 FPTRUNC = 398,
208 FPEXT = 399,
209 FPTOUI = 400,
210 FPTOSI = 401,
211 UITOFP = 402,
212 SITOFP = 403,
213 PTRTOINT = 404,
214 INTTOPTR = 405,
215 BITCAST = 406
Reid Spencer319a7302007-01-05 17:20:02 +0000216 };
217#endif
Reid Spencer950bf602007-01-26 08:19:09 +0000218/* Tokens. */
219#define ESINT64VAL 258
220#define EUINT64VAL 259
221#define SINTVAL 260
222#define UINTVAL 261
223#define FPVAL 262
224#define VOID 263
225#define BOOL 264
226#define SBYTE 265
227#define UBYTE 266
228#define SHORT 267
229#define USHORT 268
230#define INT 269
231#define UINT 270
232#define LONG 271
233#define ULONG 272
234#define FLOAT 273
235#define DOUBLE 274
236#define TYPE 275
237#define LABEL 276
238#define VAR_ID 277
239#define LABELSTR 278
240#define STRINGCONSTANT 279
241#define IMPLEMENTATION 280
242#define ZEROINITIALIZER 281
243#define TRUETOK 282
244#define FALSETOK 283
245#define BEGINTOK 284
246#define ENDTOK 285
247#define DECLARE 286
248#define GLOBAL 287
249#define CONSTANT 288
250#define SECTION 289
251#define VOLATILE 290
252#define TO 291
253#define DOTDOTDOT 292
254#define NULL_TOK 293
255#define UNDEF 294
256#define CONST 295
257#define INTERNAL 296
258#define LINKONCE 297
259#define WEAK 298
260#define APPENDING 299
Reid Spencer319a7302007-01-05 17:20:02 +0000261#define DLLIMPORT 300
262#define DLLEXPORT 301
263#define EXTERN_WEAK 302
Reid Spencer950bf602007-01-26 08:19:09 +0000264#define OPAQUE 303
265#define NOT 304
266#define EXTERNAL 305
267#define TARGET 306
268#define TRIPLE 307
269#define ENDIAN 308
270#define POINTERSIZE 309
271#define LITTLE 310
272#define BIG 311
273#define ALIGN 312
Reid Spencerc4d96252007-01-13 00:03:30 +0000274#define DEPLIBS 313
275#define CALL 314
276#define TAIL 315
277#define ASM_TOK 316
278#define MODULE 317
279#define SIDEEFFECT 318
280#define CC_TOK 319
281#define CCC_TOK 320
282#define CSRETCC_TOK 321
283#define FASTCC_TOK 322
284#define COLDCC_TOK 323
285#define X86_STDCALLCC_TOK 324
286#define X86_FASTCALLCC_TOK 325
287#define DATALAYOUT 326
288#define RET 327
289#define BR 328
290#define SWITCH 329
291#define INVOKE 330
Reid Spencer950bf602007-01-26 08:19:09 +0000292#define UNREACHABLE 331
Reid Spencerc4d96252007-01-13 00:03:30 +0000293#define UNWIND 332
Reid Spencer950bf602007-01-26 08:19:09 +0000294#define EXCEPT 333
Reid Spencerc4d96252007-01-13 00:03:30 +0000295#define ADD 334
296#define SUB 335
297#define MUL 336
298#define DIV 337
299#define UDIV 338
300#define SDIV 339
301#define FDIV 340
302#define REM 341
303#define UREM 342
304#define SREM 343
305#define FREM 344
306#define AND 345
307#define OR 346
308#define XOR 347
309#define SETLE 348
310#define SETGE 349
311#define SETLT 350
312#define SETGT 351
313#define SETEQ 352
314#define SETNE 353
315#define ICMP 354
316#define FCMP 355
Reid Spencer950bf602007-01-26 08:19:09 +0000317#define MALLOC 356
318#define ALLOCA 357
319#define FREE 358
320#define LOAD 359
321#define STORE 360
322#define GETELEMENTPTR 361
323#define PHI_TOK 362
324#define SELECT 363
325#define SHL 364
326#define SHR 365
327#define ASHR 366
328#define LSHR 367
329#define VAARG 368
330#define EXTRACTELEMENT 369
331#define INSERTELEMENT 370
332#define SHUFFLEVECTOR 371
333#define VAARG_old 372
334#define VANEXT_old 373
335#define EQ 374
336#define NE 375
337#define SLT 376
338#define SGT 377
339#define SLE 378
340#define SGE 379
341#define ULT 380
342#define UGT 381
343#define ULE 382
344#define UGE 383
345#define OEQ 384
346#define ONE 385
347#define OLT 386
348#define OGT 387
349#define OLE 388
350#define OGE 389
351#define ORD 390
352#define UNO 391
353#define UEQ 392
354#define UNE 393
355#define CAST 394
356#define TRUNC 395
357#define ZEXT 396
358#define SEXT 397
359#define FPTRUNC 398
360#define FPEXT 399
361#define FPTOUI 400
362#define FPTOSI 401
363#define UITOFP 402
364#define SITOFP 403
365#define PTRTOINT 404
366#define INTTOPTR 405
367#define BITCAST 406
Reid Spencer319a7302007-01-05 17:20:02 +0000368
369
370
371
372/* Copy the first part of user declarations. */
Reid Spencerb7046c72007-01-29 05:41:34 +0000373#line 14 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +0000374
375#include "UpgradeInternals.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000376#include "llvm/CallingConv.h"
377#include "llvm/InlineAsm.h"
378#include "llvm/Instructions.h"
379#include "llvm/Module.h"
380#include "llvm/SymbolTable.h"
381#include "llvm/Support/GetElementPtrTypeIterator.h"
382#include "llvm/ADT/STLExtras.h"
383#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000384#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000385#include <iostream>
Reid Spencer950bf602007-01-26 08:19:09 +0000386#include <list>
387#include <utility>
388
389// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
390// relating to upreferences in the input stream.
391//
392//#define DEBUG_UPREFS 1
393#ifdef DEBUG_UPREFS
394#define UR_OUT(X) std::cerr << X
395#else
396#define UR_OUT(X)
397#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000398
Reid Spencere77e35e2006-12-01 20:26:20 +0000399#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000400#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000401#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000402
Reid Spencer950bf602007-01-26 08:19:09 +0000403int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000404int yyparse();
405
Reid Spencer950bf602007-01-26 08:19:09 +0000406int yyerror(const char*);
407static void warning(const std::string& WarningMsg);
408
409namespace llvm {
410
Reid Spencer950bf602007-01-26 08:19:09 +0000411std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000412static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000413
Reid Spencer71d2ec92006-12-31 06:02:26 +0000414// This bool controls whether attributes are ever added to function declarations
415// definitions and calls.
416static bool AddAttributes = false;
417
Reid Spencer950bf602007-01-26 08:19:09 +0000418static Module *ParserResult;
419static bool ObsoleteVarArgs;
420static bool NewVarArgs;
421static BasicBlock *CurBB;
422static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000423
Reid Spencer950bf602007-01-26 08:19:09 +0000424// This contains info used when building the body of a function. It is
425// destroyed when the function is completed.
426//
427typedef std::vector<Value *> ValueList; // Numbered defs
428
429typedef std::pair<std::string,const Type*> RenameMapKey;
430typedef std::map<RenameMapKey,std::string> RenameMapType;
431
432static void
433ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
434 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
435
436static struct PerModuleInfo {
437 Module *CurrentModule;
438 std::map<const Type *, ValueList> Values; // Module level numbered definitions
439 std::map<const Type *,ValueList> LateResolveValues;
440 std::vector<PATypeHolder> Types;
441 std::map<ValID, PATypeHolder> LateResolveTypes;
442 static Module::Endianness Endian;
443 static Module::PointerSize PointerSize;
444 RenameMapType RenameMap;
445
446 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
447 /// how they were referenced and on which line of the input they came from so
448 /// that we can resolve them later and print error messages as appropriate.
449 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
450
451 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
452 // references to global values. Global values may be referenced before they
453 // are defined, and if so, the temporary object that they represent is held
454 // here. This is used for forward references of GlobalValues.
455 //
456 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
457 GlobalRefsType;
458 GlobalRefsType GlobalRefs;
459
460 void ModuleDone() {
461 // If we could not resolve some functions at function compilation time
462 // (calls to functions before they are defined), resolve them now... Types
463 // are resolved when the constant pool has been completely parsed.
464 //
465 ResolveDefinitions(LateResolveValues);
466
467 // Check to make sure that all global value forward references have been
468 // resolved!
469 //
470 if (!GlobalRefs.empty()) {
471 std::string UndefinedReferences = "Unresolved global references exist:\n";
472
473 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
474 I != E; ++I) {
475 UndefinedReferences += " " + I->first.first->getDescription() + " " +
476 I->first.second.getName() + "\n";
477 }
478 error(UndefinedReferences);
479 return;
480 }
481
482 if (CurrentModule->getDataLayout().empty()) {
483 std::string dataLayout;
484 if (Endian != Module::AnyEndianness)
485 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
486 if (PointerSize != Module::AnyPointerSize) {
487 if (!dataLayout.empty())
488 dataLayout += "-";
489 dataLayout.append(PointerSize == Module::Pointer64 ?
490 "p:64:64" : "p:32:32");
491 }
492 CurrentModule->setDataLayout(dataLayout);
493 }
494
495 Values.clear(); // Clear out function local definitions
496 Types.clear();
497 CurrentModule = 0;
498 }
499
500 // GetForwardRefForGlobal - Check to see if there is a forward reference
501 // for this global. If so, remove it from the GlobalRefs map and return it.
502 // If not, just return null.
503 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
504 // Check to see if there is a forward reference to this global variable...
505 // if there is, eliminate it and patch the reference to use the new def'n.
506 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
507 GlobalValue *Ret = 0;
508 if (I != GlobalRefs.end()) {
509 Ret = I->second;
510 GlobalRefs.erase(I);
511 }
512 return Ret;
513 }
514 void setEndianness(Module::Endianness E) { Endian = E; }
515 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
516} CurModule;
517
518Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
519Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
520
521static struct PerFunctionInfo {
522 Function *CurrentFunction; // Pointer to current function being created
523
524 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
525 std::map<const Type*, ValueList> LateResolveValues;
526 bool isDeclare; // Is this function a forward declararation?
527 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
528
529 /// BBForwardRefs - When we see forward references to basic blocks, keep
530 /// track of them here.
531 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
532 std::vector<BasicBlock*> NumberedBlocks;
533 RenameMapType RenameMap;
Reid Spencerb7046c72007-01-29 05:41:34 +0000534 unsigned LastCC;
Reid Spencer950bf602007-01-26 08:19:09 +0000535 unsigned NextBBNum;
536
537 inline PerFunctionInfo() {
538 CurrentFunction = 0;
539 isDeclare = false;
540 Linkage = GlobalValue::ExternalLinkage;
541 }
542
543 inline void FunctionStart(Function *M) {
544 CurrentFunction = M;
545 NextBBNum = 0;
546 }
547
548 void FunctionDone() {
549 NumberedBlocks.clear();
550
551 // Any forward referenced blocks left?
552 if (!BBForwardRefs.empty()) {
553 error("Undefined reference to label " +
554 BBForwardRefs.begin()->first->getName());
555 return;
556 }
557
558 // Resolve all forward references now.
559 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
560
561 Values.clear(); // Clear out function local definitions
562 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000563 CurrentFunction = 0;
564 isDeclare = false;
565 Linkage = GlobalValue::ExternalLinkage;
566 }
567} CurFun; // Info for the current function...
568
569static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
570
571
572//===----------------------------------------------------------------------===//
573// Code to handle definitions of all the types
574//===----------------------------------------------------------------------===//
575
576static int InsertValue(Value *V,
577 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
578 if (V->hasName()) return -1; // Is this a numbered definition?
579
580 // Yes, insert the value into the value table...
581 ValueList &List = ValueTab[V->getType()];
582 List.push_back(V);
583 return List.size()-1;
584}
585
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000586static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000587 switch (D.Type) {
588 case ValID::NumberVal: // Is it a numbered definition?
589 // Module constants occupy the lowest numbered slots...
590 if ((unsigned)D.Num < CurModule.Types.size()) {
591 return CurModule.Types[(unsigned)D.Num];
592 }
593 break;
594 case ValID::NameVal: // Is it a named definition?
595 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
596 D.destroy(); // Free old strdup'd memory...
597 return N;
598 }
599 break;
600 default:
601 error("Internal parser error: Invalid symbol type reference");
602 return 0;
603 }
604
605 // If we reached here, we referenced either a symbol that we don't know about
606 // or an id number that hasn't been read yet. We may be referencing something
607 // forward, so just create an entry to be resolved later and get to it...
608 //
609 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
610
611
612 if (inFunctionScope()) {
613 if (D.Type == ValID::NameVal) {
614 error("Reference to an undefined type: '" + D.getName() + "'");
615 return 0;
616 } else {
617 error("Reference to an undefined type: #" + itostr(D.Num));
618 return 0;
619 }
620 }
621
622 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
623 if (I != CurModule.LateResolveTypes.end())
624 return I->second;
625
626 Type *Typ = OpaqueType::get();
627 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
628 return Typ;
629 }
630
631// getExistingValue - Look up the value specified by the provided type and
632// the provided ValID. If the value exists and has already been defined, return
633// it. Otherwise return null.
634//
635static Value *getExistingValue(const Type *Ty, const ValID &D) {
636 if (isa<FunctionType>(Ty)) {
637 error("Functions are not values and must be referenced as pointers");
638 }
639
640 switch (D.Type) {
641 case ValID::NumberVal: { // Is it a numbered definition?
642 unsigned Num = (unsigned)D.Num;
643
644 // Module constants occupy the lowest numbered slots...
645 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
646 if (VI != CurModule.Values.end()) {
647 if (Num < VI->second.size())
648 return VI->second[Num];
649 Num -= VI->second.size();
650 }
651
652 // Make sure that our type is within bounds
653 VI = CurFun.Values.find(Ty);
654 if (VI == CurFun.Values.end()) return 0;
655
656 // Check that the number is within bounds...
657 if (VI->second.size() <= Num) return 0;
658
659 return VI->second[Num];
660 }
661
662 case ValID::NameVal: { // Is it a named definition?
663 // Get the name out of the ID
664 std::string Name(D.Name);
665 Value* V = 0;
666 RenameMapKey Key = std::make_pair(Name, Ty);
667 if (inFunctionScope()) {
668 // See if the name was renamed
669 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
670 std::string LookupName;
671 if (I != CurFun.RenameMap.end())
672 LookupName = I->second;
673 else
674 LookupName = Name;
675 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
676 V = SymTab.lookup(Ty, LookupName);
677 }
678 if (!V) {
679 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
680 std::string LookupName;
681 if (I != CurModule.RenameMap.end())
682 LookupName = I->second;
683 else
684 LookupName = Name;
685 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
686 }
687 if (V == 0)
688 return 0;
689
690 D.destroy(); // Free old strdup'd memory...
691 return V;
692 }
693
694 // Check to make sure that "Ty" is an integral type, and that our
695 // value will fit into the specified type...
696 case ValID::ConstSIntVal: // Is it a constant pool reference??
697 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
698 error("Signed integral constant '" + itostr(D.ConstPool64) +
699 "' is invalid for type '" + Ty->getDescription() + "'");
700 }
701 return ConstantInt::get(Ty, D.ConstPool64);
702
703 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
704 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
705 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
706 error("Integral constant '" + utostr(D.UConstPool64) +
707 "' is invalid or out of range");
708 else // This is really a signed reference. Transmogrify.
709 return ConstantInt::get(Ty, D.ConstPool64);
710 } else
711 return ConstantInt::get(Ty, D.UConstPool64);
712
713 case ValID::ConstFPVal: // Is it a floating point const pool reference?
714 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
715 error("FP constant invalid for type");
716 return ConstantFP::get(Ty, D.ConstPoolFP);
717
718 case ValID::ConstNullVal: // Is it a null value?
719 if (!isa<PointerType>(Ty))
720 error("Cannot create a a non pointer null");
721 return ConstantPointerNull::get(cast<PointerType>(Ty));
722
723 case ValID::ConstUndefVal: // Is it an undef value?
724 return UndefValue::get(Ty);
725
726 case ValID::ConstZeroVal: // Is it a zero value?
727 return Constant::getNullValue(Ty);
728
729 case ValID::ConstantVal: // Fully resolved constant?
730 if (D.ConstantValue->getType() != Ty)
731 error("Constant expression type different from required type");
732 return D.ConstantValue;
733
734 case ValID::InlineAsmVal: { // Inline asm expression
735 const PointerType *PTy = dyn_cast<PointerType>(Ty);
736 const FunctionType *FTy =
737 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
738 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
739 error("Invalid type for asm constraint string");
740 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
741 D.IAD->HasSideEffects);
742 D.destroy(); // Free InlineAsmDescriptor.
743 return IA;
744 }
745 default:
746 assert(0 && "Unhandled case");
747 return 0;
748 } // End of switch
749
750 assert(0 && "Unhandled case");
751 return 0;
752}
753
754// getVal - This function is identical to getExistingValue, except that if a
755// value is not already defined, it "improvises" by creating a placeholder var
756// that looks and acts just like the requested variable. When the value is
757// defined later, all uses of the placeholder variable are replaced with the
758// real thing.
759//
760static Value *getVal(const Type *Ty, const ValID &ID) {
761 if (Ty == Type::LabelTy)
762 error("Cannot use a basic block here");
763
764 // See if the value has already been defined.
765 Value *V = getExistingValue(Ty, ID);
766 if (V) return V;
767
768 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
769 error("Invalid use of a composite type");
770
771 // If we reached here, we referenced either a symbol that we don't know about
772 // or an id number that hasn't been read yet. We may be referencing something
773 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000774 V = new Argument(Ty);
775
776 // Remember where this forward reference came from. FIXME, shouldn't we try
777 // to recycle these things??
778 CurModule.PlaceHolderInfo.insert(
779 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
780
781 if (inFunctionScope())
782 InsertValue(V, CurFun.LateResolveValues);
783 else
784 InsertValue(V, CurModule.LateResolveValues);
785 return V;
786}
787
788/// getBBVal - This is used for two purposes:
789/// * If isDefinition is true, a new basic block with the specified ID is being
790/// defined.
791/// * If isDefinition is true, this is a reference to a basic block, which may
792/// or may not be a forward reference.
793///
794static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
795 assert(inFunctionScope() && "Can't get basic block at global scope");
796
797 std::string Name;
798 BasicBlock *BB = 0;
799 switch (ID.Type) {
800 default:
801 error("Illegal label reference " + ID.getName());
802 break;
803 case ValID::NumberVal: // Is it a numbered definition?
804 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
805 CurFun.NumberedBlocks.resize(ID.Num+1);
806 BB = CurFun.NumberedBlocks[ID.Num];
807 break;
808 case ValID::NameVal: // Is it a named definition?
809 Name = ID.Name;
810 if (Value *N = CurFun.CurrentFunction->
811 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
812 if (N->getType() != Type::LabelTy)
813 error("Name '" + Name + "' does not refer to a BasicBlock");
814 BB = cast<BasicBlock>(N);
815 }
816 break;
817 }
818
819 // See if the block has already been defined.
820 if (BB) {
821 // If this is the definition of the block, make sure the existing value was
822 // just a forward reference. If it was a forward reference, there will be
823 // an entry for it in the PlaceHolderInfo map.
824 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
825 // The existing value was a definition, not a forward reference.
826 error("Redefinition of label " + ID.getName());
827
828 ID.destroy(); // Free strdup'd memory.
829 return BB;
830 }
831
832 // Otherwise this block has not been seen before.
833 BB = new BasicBlock("", CurFun.CurrentFunction);
834 if (ID.Type == ValID::NameVal) {
835 BB->setName(ID.Name);
836 } else {
837 CurFun.NumberedBlocks[ID.Num] = BB;
838 }
839
840 // If this is not a definition, keep track of it so we can use it as a forward
841 // reference.
842 if (!isDefinition) {
843 // Remember where this forward reference came from.
844 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
845 } else {
846 // The forward declaration could have been inserted anywhere in the
847 // function: insert it into the correct place now.
848 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
849 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
850 }
851 ID.destroy();
852 return BB;
853}
854
855
856//===----------------------------------------------------------------------===//
857// Code to handle forward references in instructions
858//===----------------------------------------------------------------------===//
859//
860// This code handles the late binding needed with statements that reference
861// values not defined yet... for example, a forward branch, or the PHI node for
862// a loop body.
863//
864// This keeps a table (CurFun.LateResolveValues) of all such forward references
865// and back patchs after we are done.
866//
867
868// ResolveDefinitions - If we could not resolve some defs at parsing
869// time (forward branches, phi functions for loops, etc...) resolve the
870// defs now...
871//
872static void
873ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
874 std::map<const Type*,ValueList> *FutureLateResolvers) {
875 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
876 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
877 E = LateResolvers.end(); LRI != E; ++LRI) {
878 ValueList &List = LRI->second;
879 while (!List.empty()) {
880 Value *V = List.back();
881 List.pop_back();
882
883 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
884 CurModule.PlaceHolderInfo.find(V);
885 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
886
887 ValID &DID = PHI->second.first;
888
889 Value *TheRealValue = getExistingValue(LRI->first, DID);
890 if (TheRealValue) {
891 V->replaceAllUsesWith(TheRealValue);
892 delete V;
893 CurModule.PlaceHolderInfo.erase(PHI);
894 } else if (FutureLateResolvers) {
895 // Functions have their unresolved items forwarded to the module late
896 // resolver table
897 InsertValue(V, *FutureLateResolvers);
898 } else {
899 if (DID.Type == ValID::NameVal) {
900 error("Reference to an invalid definition: '" +DID.getName()+
901 "' of type '" + V->getType()->getDescription() + "'",
902 PHI->second.second);
903 return;
904 } else {
905 error("Reference to an invalid definition: #" +
906 itostr(DID.Num) + " of type '" +
907 V->getType()->getDescription() + "'", PHI->second.second);
908 return;
909 }
910 }
911 }
912 }
913
914 LateResolvers.clear();
915}
916
917// ResolveTypeTo - A brand new type was just declared. This means that (if
918// name is not null) things referencing Name can be resolved. Otherwise, things
919// refering to the number can be resolved. Do this now.
920//
921static void ResolveTypeTo(char *Name, const Type *ToTy) {
922 ValID D;
923 if (Name) D = ValID::create(Name);
924 else D = ValID::create((int)CurModule.Types.size());
925
926 std::map<ValID, PATypeHolder>::iterator I =
927 CurModule.LateResolveTypes.find(D);
928 if (I != CurModule.LateResolveTypes.end()) {
929 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
930 CurModule.LateResolveTypes.erase(I);
931 }
932}
933
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000934/// @brief This just makes any name given to it unique, up to MAX_UINT times.
Reid Spencer950bf602007-01-26 08:19:09 +0000935static std::string makeNameUnique(const std::string& Name) {
936 static unsigned UniqueNameCounter = 1;
937 std::string Result(Name);
938 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
939 return Result;
940}
941
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000942/// This is the implementation portion of TypeHasInteger. It traverses the
943/// type given, avoiding recursive types, and returns true as soon as it finds
944/// an integer type. If no integer type is found, it returns false.
945static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
946 // Handle some easy cases
947 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
948 return false;
949 if (Ty->isInteger())
950 return true;
951 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
952 return STy->getElementType()->isInteger();
953
954 // Avoid type structure recursion
955 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
956 I != E; ++I)
957 if (Ty == *I)
958 return false;
959
960 // Push us on the type stack
961 Stack.push_back(Ty);
962
963 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
964 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
965 return true;
966 FunctionType::param_iterator I = FTy->param_begin();
967 FunctionType::param_iterator E = FTy->param_end();
968 for (; I != E; ++I)
969 if (TypeHasIntegerI(*I, Stack))
970 return true;
971 return false;
972 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
973 StructType::element_iterator I = STy->element_begin();
974 StructType::element_iterator E = STy->element_end();
975 for (; I != E; ++I) {
976 if (TypeHasIntegerI(*I, Stack))
977 return true;
978 }
979 return false;
980 }
981 // There shouldn't be anything else, but its definitely not integer
982 assert(0 && "What type is this?");
983 return false;
984}
985
986/// This is the interface to TypeHasIntegerI. It just provides the type stack,
987/// to avoid recursion, and then calls TypeHasIntegerI.
988static inline bool TypeHasInteger(const Type *Ty) {
989 std::vector<const Type*> TyStack;
990 return TypeHasIntegerI(Ty, TyStack);
991}
992
Reid Spencer950bf602007-01-26 08:19:09 +0000993// setValueName - Set the specified value to the name given. The name may be
994// null potentially, in which case this is a noop. The string passed in is
995// assumed to be a malloc'd string buffer, and is free'd by this function.
996//
997static void setValueName(Value *V, char *NameStr) {
998 if (NameStr) {
999 std::string Name(NameStr); // Copy string
1000 free(NameStr); // Free old string
1001
1002 if (V->getType() == Type::VoidTy) {
1003 error("Can't assign name '" + Name + "' to value with void type");
1004 return;
1005 }
1006
Reid Spencer950bf602007-01-26 08:19:09 +00001007 assert(inFunctionScope() && "Must be in function scope");
1008
1009 // Search the function's symbol table for an existing value of this name
1010 Value* Existing = 0;
1011 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1012 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
1013 for ( ; PI != PE; ++PI) {
1014 SymbolTable::value_const_iterator VI = PI->second.find(Name);
1015 if (VI != PI->second.end()) {
1016 Existing = VI->second;
1017 break;
1018 }
1019 }
1020 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001021 // An existing value of the same name was found. This might have happened
1022 // because of the integer type planes collapsing in LLVM 2.0.
1023 if (Existing->getType() == V->getType() &&
1024 !TypeHasInteger(Existing->getType())) {
1025 // If the type does not contain any integers in them then this can't be
1026 // a type plane collapsing issue. It truly is a redefinition and we
1027 // should error out as the assembly is invalid.
1028 error("Redefinition of value named '" + Name + "' of type '" +
1029 V->getType()->getDescription() + "'");
1030 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001031 }
1032 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1033 // function, regardless of Type. Previously re-use of names was okay as
1034 // long as they were distinct types. With type planes collapsing because
1035 // of the signedness change and because of PR411, this can no longer be
1036 // supported. We must search the entire symbol table for a conflicting
1037 // name and make the name unique. No warning is needed as this can't
1038 // cause a problem.
1039 std::string NewName = makeNameUnique(Name);
1040 // We're changing the name but it will probably be used by other
1041 // instructions as operands later on. Consequently we have to retain
1042 // a mapping of the renaming that we're doing.
1043 RenameMapKey Key = std::make_pair(Name,V->getType());
1044 CurFun.RenameMap[Key] = NewName;
1045 Name = NewName;
1046 }
1047
1048 // Set the name.
1049 V->setName(Name);
1050 }
1051}
1052
1053/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1054/// this is a declaration, otherwise it is a definition.
1055static GlobalVariable *
1056ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1057 bool isConstantGlobal, const Type *Ty,
1058 Constant *Initializer) {
1059 if (isa<FunctionType>(Ty))
1060 error("Cannot declare global vars of function type");
1061
1062 const PointerType *PTy = PointerType::get(Ty);
1063
1064 std::string Name;
1065 if (NameStr) {
1066 Name = NameStr; // Copy string
1067 free(NameStr); // Free old string
1068 }
1069
1070 // See if this global value was forward referenced. If so, recycle the
1071 // object.
1072 ValID ID;
1073 if (!Name.empty()) {
1074 ID = ValID::create((char*)Name.c_str());
1075 } else {
1076 ID = ValID::create((int)CurModule.Values[PTy].size());
1077 }
1078
1079 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1080 // Move the global to the end of the list, from whereever it was
1081 // previously inserted.
1082 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1083 CurModule.CurrentModule->getGlobalList().remove(GV);
1084 CurModule.CurrentModule->getGlobalList().push_back(GV);
1085 GV->setInitializer(Initializer);
1086 GV->setLinkage(Linkage);
1087 GV->setConstant(isConstantGlobal);
1088 InsertValue(GV, CurModule.Values);
1089 return GV;
1090 }
1091
1092 // If this global has a name, check to see if there is already a definition
1093 // of this global in the module and emit warnings if there are conflicts.
1094 if (!Name.empty()) {
1095 // The global has a name. See if there's an existing one of the same name.
1096 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1097 // We found an existing global ov the same name. This isn't allowed
1098 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1099 // can at least compile. This can happen because of type planes
1100 // There is alread a global of the same name which means there is a
1101 // conflict. Let's see what we can do about it.
1102 std::string NewName(makeNameUnique(Name));
1103 if (Linkage == GlobalValue::InternalLinkage) {
1104 // The linkage type is internal so just warn about the rename without
1105 // invoking "scarey language" about linkage failures. GVars with
1106 // InternalLinkage can be renamed at will.
1107 warning("Global variable '" + Name + "' was renamed to '"+
1108 NewName + "'");
1109 } else {
1110 // The linkage of this gval is external so we can't reliably rename
1111 // it because it could potentially create a linking problem.
1112 // However, we can't leave the name conflict in the output either or
1113 // it won't assemble with LLVM 2.0. So, all we can do is rename
1114 // this one to something unique and emit a warning about the problem.
1115 warning("Renaming global variable '" + Name + "' to '" + NewName +
1116 "' may cause linkage errors");
1117 }
1118
1119 // Put the renaming in the global rename map
1120 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1121 CurModule.RenameMap[Key] = NewName;
1122
1123 // Rename it
1124 Name = NewName;
1125 }
1126 }
1127
1128 // Otherwise there is no existing GV to use, create one now.
1129 GlobalVariable *GV =
1130 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1131 CurModule.CurrentModule);
1132 InsertValue(GV, CurModule.Values);
1133 return GV;
1134}
1135
1136// setTypeName - Set the specified type to the name given. The name may be
1137// null potentially, in which case this is a noop. The string passed in is
1138// assumed to be a malloc'd string buffer, and is freed by this function.
1139//
1140// This function returns true if the type has already been defined, but is
1141// allowed to be redefined in the specified context. If the name is a new name
1142// for the type plane, it is inserted and false is returned.
1143static bool setTypeName(const Type *T, char *NameStr) {
1144 assert(!inFunctionScope() && "Can't give types function-local names");
1145 if (NameStr == 0) return false;
1146
1147 std::string Name(NameStr); // Copy string
1148 free(NameStr); // Free old string
1149
1150 // We don't allow assigning names to void type
1151 if (T == Type::VoidTy) {
1152 error("Can't assign name '" + Name + "' to the void type");
1153 return false;
1154 }
1155
1156 // Set the type name, checking for conflicts as we do so.
1157 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1158
1159 if (AlreadyExists) { // Inserting a name that is already defined???
1160 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1161 assert(Existing && "Conflict but no matching type?");
1162
1163 // There is only one case where this is allowed: when we are refining an
1164 // opaque type. In this case, Existing will be an opaque type.
1165 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1166 // We ARE replacing an opaque type!
1167 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1168 return true;
1169 }
1170
1171 // Otherwise, this is an attempt to redefine a type. That's okay if
1172 // the redefinition is identical to the original. This will be so if
1173 // Existing and T point to the same Type object. In this one case we
1174 // allow the equivalent redefinition.
1175 if (Existing == T) return true; // Yes, it's equal.
1176
1177 // Any other kind of (non-equivalent) redefinition is an error.
1178 error("Redefinition of type named '" + Name + "' in the '" +
1179 T->getDescription() + "' type plane");
1180 }
1181
1182 return false;
1183}
1184
1185//===----------------------------------------------------------------------===//
1186// Code for handling upreferences in type names...
1187//
1188
1189// TypeContains - Returns true if Ty directly contains E in it.
1190//
1191static bool TypeContains(const Type *Ty, const Type *E) {
1192 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1193 E) != Ty->subtype_end();
1194}
1195
1196namespace {
1197 struct UpRefRecord {
1198 // NestingLevel - The number of nesting levels that need to be popped before
1199 // this type is resolved.
1200 unsigned NestingLevel;
1201
1202 // LastContainedTy - This is the type at the current binding level for the
1203 // type. Every time we reduce the nesting level, this gets updated.
1204 const Type *LastContainedTy;
1205
1206 // UpRefTy - This is the actual opaque type that the upreference is
1207 // represented with.
1208 OpaqueType *UpRefTy;
1209
1210 UpRefRecord(unsigned NL, OpaqueType *URTy)
1211 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1212 };
1213}
1214
1215// UpRefs - A list of the outstanding upreferences that need to be resolved.
1216static std::vector<UpRefRecord> UpRefs;
1217
1218/// HandleUpRefs - Every time we finish a new layer of types, this function is
1219/// called. It loops through the UpRefs vector, which is a list of the
1220/// currently active types. For each type, if the up reference is contained in
1221/// the newly completed type, we decrement the level count. When the level
1222/// count reaches zero, the upreferenced type is the type that is passed in:
1223/// thus we can complete the cycle.
1224///
1225static PATypeHolder HandleUpRefs(const Type *ty) {
1226 // If Ty isn't abstract, or if there are no up-references in it, then there is
1227 // nothing to resolve here.
1228 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1229
1230 PATypeHolder Ty(ty);
1231 UR_OUT("Type '" << Ty->getDescription() <<
1232 "' newly formed. Resolving upreferences.\n" <<
1233 UpRefs.size() << " upreferences active!\n");
1234
1235 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1236 // to zero), we resolve them all together before we resolve them to Ty. At
1237 // the end of the loop, if there is anything to resolve to Ty, it will be in
1238 // this variable.
1239 OpaqueType *TypeToResolve = 0;
1240
1241 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1242 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1243 << UpRefs[i].second->getDescription() << ") = "
1244 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1245 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1246 // Decrement level of upreference
1247 unsigned Level = --UpRefs[i].NestingLevel;
1248 UpRefs[i].LastContainedTy = Ty;
1249 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1250 if (Level == 0) { // Upreference should be resolved!
1251 if (!TypeToResolve) {
1252 TypeToResolve = UpRefs[i].UpRefTy;
1253 } else {
1254 UR_OUT(" * Resolving upreference for "
1255 << UpRefs[i].second->getDescription() << "\n";
1256 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1257 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1258 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1259 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1260 }
1261 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1262 --i; // Do not skip the next element...
1263 }
1264 }
1265 }
1266
1267 if (TypeToResolve) {
1268 UR_OUT(" * Resolving upreference for "
1269 << UpRefs[i].second->getDescription() << "\n";
1270 std::string OldName = TypeToResolve->getDescription());
1271 TypeToResolve->refineAbstractTypeTo(Ty);
1272 }
1273
1274 return Ty;
1275}
1276
1277static inline Instruction::TermOps
1278getTermOp(TermOps op) {
1279 switch (op) {
1280 default : assert(0 && "Invalid OldTermOp");
1281 case RetOp : return Instruction::Ret;
1282 case BrOp : return Instruction::Br;
1283 case SwitchOp : return Instruction::Switch;
1284 case InvokeOp : return Instruction::Invoke;
1285 case UnwindOp : return Instruction::Unwind;
1286 case UnreachableOp: return Instruction::Unreachable;
1287 }
1288}
1289
1290static inline Instruction::BinaryOps
1291getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1292 switch (op) {
1293 default : assert(0 && "Invalid OldBinaryOps");
1294 case SetEQ :
1295 case SetNE :
1296 case SetLE :
1297 case SetGE :
1298 case SetLT :
1299 case SetGT : assert(0 && "Should use getCompareOp");
1300 case AddOp : return Instruction::Add;
1301 case SubOp : return Instruction::Sub;
1302 case MulOp : return Instruction::Mul;
1303 case DivOp : {
1304 // This is an obsolete instruction so we must upgrade it based on the
1305 // types of its operands.
1306 bool isFP = Ty->isFloatingPoint();
1307 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1308 // If its a packed type we want to use the element type
1309 isFP = PTy->getElementType()->isFloatingPoint();
1310 if (isFP)
1311 return Instruction::FDiv;
1312 else if (Sign == Signed)
1313 return Instruction::SDiv;
1314 return Instruction::UDiv;
1315 }
1316 case UDivOp : return Instruction::UDiv;
1317 case SDivOp : return Instruction::SDiv;
1318 case FDivOp : return Instruction::FDiv;
1319 case RemOp : {
1320 // This is an obsolete instruction so we must upgrade it based on the
1321 // types of its operands.
1322 bool isFP = Ty->isFloatingPoint();
1323 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1324 // If its a packed type we want to use the element type
1325 isFP = PTy->getElementType()->isFloatingPoint();
1326 // Select correct opcode
1327 if (isFP)
1328 return Instruction::FRem;
1329 else if (Sign == Signed)
1330 return Instruction::SRem;
1331 return Instruction::URem;
1332 }
1333 case URemOp : return Instruction::URem;
1334 case SRemOp : return Instruction::SRem;
1335 case FRemOp : return Instruction::FRem;
1336 case AndOp : return Instruction::And;
1337 case OrOp : return Instruction::Or;
1338 case XorOp : return Instruction::Xor;
1339 }
1340}
1341
1342static inline Instruction::OtherOps
1343getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1344 Signedness Sign) {
1345 bool isSigned = Sign == Signed;
1346 bool isFP = Ty->isFloatingPoint();
1347 switch (op) {
1348 default : assert(0 && "Invalid OldSetCC");
1349 case SetEQ :
1350 if (isFP) {
1351 predicate = FCmpInst::FCMP_OEQ;
1352 return Instruction::FCmp;
1353 } else {
1354 predicate = ICmpInst::ICMP_EQ;
1355 return Instruction::ICmp;
1356 }
1357 case SetNE :
1358 if (isFP) {
1359 predicate = FCmpInst::FCMP_UNE;
1360 return Instruction::FCmp;
1361 } else {
1362 predicate = ICmpInst::ICMP_NE;
1363 return Instruction::ICmp;
1364 }
1365 case SetLE :
1366 if (isFP) {
1367 predicate = FCmpInst::FCMP_OLE;
1368 return Instruction::FCmp;
1369 } else {
1370 if (isSigned)
1371 predicate = ICmpInst::ICMP_SLE;
1372 else
1373 predicate = ICmpInst::ICMP_ULE;
1374 return Instruction::ICmp;
1375 }
1376 case SetGE :
1377 if (isFP) {
1378 predicate = FCmpInst::FCMP_OGE;
1379 return Instruction::FCmp;
1380 } else {
1381 if (isSigned)
1382 predicate = ICmpInst::ICMP_SGE;
1383 else
1384 predicate = ICmpInst::ICMP_UGE;
1385 return Instruction::ICmp;
1386 }
1387 case SetLT :
1388 if (isFP) {
1389 predicate = FCmpInst::FCMP_OLT;
1390 return Instruction::FCmp;
1391 } else {
1392 if (isSigned)
1393 predicate = ICmpInst::ICMP_SLT;
1394 else
1395 predicate = ICmpInst::ICMP_ULT;
1396 return Instruction::ICmp;
1397 }
1398 case SetGT :
1399 if (isFP) {
1400 predicate = FCmpInst::FCMP_OGT;
1401 return Instruction::FCmp;
1402 } else {
1403 if (isSigned)
1404 predicate = ICmpInst::ICMP_SGT;
1405 else
1406 predicate = ICmpInst::ICMP_UGT;
1407 return Instruction::ICmp;
1408 }
1409 }
1410}
1411
1412static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1413 switch (op) {
1414 default : assert(0 && "Invalid OldMemoryOps");
1415 case MallocOp : return Instruction::Malloc;
1416 case FreeOp : return Instruction::Free;
1417 case AllocaOp : return Instruction::Alloca;
1418 case LoadOp : return Instruction::Load;
1419 case StoreOp : return Instruction::Store;
1420 case GetElementPtrOp : return Instruction::GetElementPtr;
1421 }
1422}
1423
1424static inline Instruction::OtherOps
1425getOtherOp(OtherOps op, Signedness Sign) {
1426 switch (op) {
1427 default : assert(0 && "Invalid OldOtherOps");
1428 case PHIOp : return Instruction::PHI;
1429 case CallOp : return Instruction::Call;
1430 case ShlOp : return Instruction::Shl;
1431 case ShrOp :
1432 if (Sign == Signed)
1433 return Instruction::AShr;
1434 return Instruction::LShr;
1435 case SelectOp : return Instruction::Select;
1436 case UserOp1 : return Instruction::UserOp1;
1437 case UserOp2 : return Instruction::UserOp2;
1438 case VAArg : return Instruction::VAArg;
1439 case ExtractElementOp : return Instruction::ExtractElement;
1440 case InsertElementOp : return Instruction::InsertElement;
1441 case ShuffleVectorOp : return Instruction::ShuffleVector;
1442 case ICmpOp : return Instruction::ICmp;
1443 case FCmpOp : return Instruction::FCmp;
1444 case LShrOp : return Instruction::LShr;
1445 case AShrOp : return Instruction::AShr;
1446 };
1447}
1448
1449static inline Value*
1450getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1451 Signedness DstSign, bool ForceInstruction = false) {
1452 Instruction::CastOps Opcode;
1453 const Type* SrcTy = Src->getType();
1454 if (op == CastOp) {
1455 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1456 // fp -> ptr cast is no longer supported but we must upgrade this
1457 // by doing a double cast: fp -> int -> ptr
1458 SrcTy = Type::Int64Ty;
1459 Opcode = Instruction::IntToPtr;
1460 if (isa<Constant>(Src)) {
1461 Src = ConstantExpr::getCast(Instruction::FPToUI,
1462 cast<Constant>(Src), SrcTy);
1463 } else {
1464 std::string NewName(makeNameUnique(Src->getName()));
1465 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1466 }
1467 } else if (isa<IntegerType>(DstTy) &&
1468 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1469 // cast type %x to bool was previously defined as setne type %x, null
1470 // The cast semantic is now to truncate, not compare so we must retain
1471 // the original intent by replacing the cast with a setne
1472 Constant* Null = Constant::getNullValue(SrcTy);
1473 Instruction::OtherOps Opcode = Instruction::ICmp;
1474 unsigned short predicate = ICmpInst::ICMP_NE;
1475 if (SrcTy->isFloatingPoint()) {
1476 Opcode = Instruction::FCmp;
1477 predicate = FCmpInst::FCMP_ONE;
1478 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1479 error("Invalid cast to bool");
1480 }
1481 if (isa<Constant>(Src) && !ForceInstruction)
1482 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1483 else
1484 return CmpInst::create(Opcode, predicate, Src, Null);
1485 }
1486 // Determine the opcode to use by calling CastInst::getCastOpcode
1487 Opcode =
1488 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1489
1490 } else switch (op) {
1491 default: assert(0 && "Invalid cast token");
1492 case TruncOp: Opcode = Instruction::Trunc; break;
1493 case ZExtOp: Opcode = Instruction::ZExt; break;
1494 case SExtOp: Opcode = Instruction::SExt; break;
1495 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1496 case FPExtOp: Opcode = Instruction::FPExt; break;
1497 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1498 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1499 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1500 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1501 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1502 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1503 case BitCastOp: Opcode = Instruction::BitCast; break;
1504 }
1505
1506 if (isa<Constant>(Src) && !ForceInstruction)
1507 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1508 return CastInst::create(Opcode, Src, DstTy);
1509}
1510
1511static Instruction *
1512upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1513 std::vector<Value*>& Args) {
1514
1515 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1516 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1517 if (Args.size() != 2)
1518 error("Invalid prototype for " + Name + " prototype");
1519 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1520 } else {
1521 static unsigned upgradeCount = 1;
1522 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1523 std::vector<const Type*> Params;
1524 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1525 if (Args.size() != 1)
1526 error("Invalid prototype for " + Name + " prototype");
1527 Params.push_back(PtrTy);
1528 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1529 const PointerType *PFTy = PointerType::get(FTy);
1530 Value* Func = getVal(PFTy, ID);
1531 std::string InstName("va_upgrade");
1532 InstName += llvm::utostr(upgradeCount++);
1533 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1534 return new CallInst(Func, Args);
1535 } else if (Name == "llvm.va_copy") {
1536 if (Args.size() != 2)
1537 error("Invalid prototype for " + Name + " prototype");
1538 Params.push_back(PtrTy);
1539 Params.push_back(PtrTy);
1540 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1541 const PointerType *PFTy = PointerType::get(FTy);
1542 Value* Func = getVal(PFTy, ID);
1543 std::string InstName0("va_upgrade");
1544 InstName0 += llvm::utostr(upgradeCount++);
1545 std::string InstName1("va_upgrade");
1546 InstName1 += llvm::utostr(upgradeCount++);
1547 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1548 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1549 return new CallInst(Func, Args);
1550 }
1551 }
1552 return 0;
1553}
1554
1555const Type* upgradeGEPIndices(const Type* PTy,
1556 std::vector<ValueInfo> *Indices,
1557 std::vector<Value*> &VIndices,
1558 std::vector<Constant*> *CIndices = 0) {
1559 // Traverse the indices with a gep_type_iterator so we can build the list
1560 // of constant and value indices for use later. Also perform upgrades
1561 VIndices.clear();
1562 if (CIndices) CIndices->clear();
1563 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1564 VIndices.push_back((*Indices)[i].V);
1565 generic_gep_type_iterator<std::vector<Value*>::iterator>
1566 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1567 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1568 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1569 Value *Index = VIndices[i];
1570 if (CIndices && !isa<Constant>(Index))
1571 error("Indices to constant getelementptr must be constants");
1572 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1573 // struct indices to i32 struct indices with ZExt for compatibility.
1574 else if (isa<StructType>(*GTI)) { // Only change struct indices
1575 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1576 if (CUI->getType()->getBitWidth() == 8)
1577 Index =
1578 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1579 } else {
1580 // Make sure that unsigned SequentialType indices are zext'd to
1581 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1582 // all indices for SequentialType elements. We must retain the same
1583 // semantic (zext) for unsigned types.
1584 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001585 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001586 if (CIndices)
1587 Index = ConstantExpr::getCast(Instruction::ZExt,
1588 cast<Constant>(Index), Type::Int64Ty);
1589 else
1590 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencerd7c4f8c2007-01-26 19:59:25 +00001591 makeNameUnique("gep_upgrade"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001592 VIndices[i] = Index;
1593 }
Reid Spencer950bf602007-01-26 08:19:09 +00001594 }
1595 // Add to the CIndices list, if requested.
1596 if (CIndices)
1597 CIndices->push_back(cast<Constant>(Index));
1598 }
1599
1600 const Type *IdxTy =
1601 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1602 if (!IdxTy)
1603 error("Index list invalid for constant getelementptr");
1604 return IdxTy;
1605}
1606
Reid Spencerb7046c72007-01-29 05:41:34 +00001607unsigned upgradeCallingConv(unsigned CC) {
1608 switch (CC) {
1609 case OldCallingConv::C : return CallingConv::C;
1610 case OldCallingConv::CSRet : return CallingConv::C;
1611 case OldCallingConv::Fast : return CallingConv::Fast;
1612 case OldCallingConv::Cold : return CallingConv::Cold;
1613 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1614 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1615 default:
1616 return CC;
1617 }
1618}
1619
Reid Spencer950bf602007-01-26 08:19:09 +00001620Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1621 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001622{
1623 Upgradelineno = 1;
1624 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001625 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001626 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001627 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001628 ObsoleteVarArgs = false;
1629 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001630
Reid Spencer950bf602007-01-26 08:19:09 +00001631 CurModule.CurrentModule = new Module(CurFilename);
1632
1633 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001634 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001635 if (ParserResult)
1636 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001637 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001638 return 0;
1639 }
1640
Reid Spencer950bf602007-01-26 08:19:09 +00001641 // Check to make sure that parsing produced a result
1642 if (!ParserResult) {
1643 std::cerr << "llvm-upgrade: no parse result.\n";
1644 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001645 }
1646
Reid Spencer950bf602007-01-26 08:19:09 +00001647 // Reset ParserResult variable while saving its value for the result.
1648 Module *Result = ParserResult;
1649 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001650
Reid Spencer950bf602007-01-26 08:19:09 +00001651 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001652 {
Reid Spencer950bf602007-01-26 08:19:09 +00001653 Function* F;
1654 if ((F = Result->getNamedFunction("llvm.va_start"))
1655 && F->getFunctionType()->getNumParams() == 0)
1656 ObsoleteVarArgs = true;
1657 if((F = Result->getNamedFunction("llvm.va_copy"))
1658 && F->getFunctionType()->getNumParams() == 1)
1659 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001660 }
Reid Spencer319a7302007-01-05 17:20:02 +00001661
Reid Spencer950bf602007-01-26 08:19:09 +00001662 if (ObsoleteVarArgs && NewVarArgs) {
1663 error("This file is corrupt: it uses both new and old style varargs");
1664 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001665 }
Reid Spencer319a7302007-01-05 17:20:02 +00001666
Reid Spencer950bf602007-01-26 08:19:09 +00001667 if(ObsoleteVarArgs) {
1668 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1669 if (F->arg_size() != 0) {
1670 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001671 return 0;
1672 }
Reid Spencer950bf602007-01-26 08:19:09 +00001673
1674 //foo = va_start()
1675 // ->
1676 //bar = alloca typeof(foo)
1677 //va_start(bar)
1678 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001679
Reid Spencer950bf602007-01-26 08:19:09 +00001680 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1681 const Type* ArgTy = F->getFunctionType()->getReturnType();
1682 const Type* ArgTyPtr = PointerType::get(ArgTy);
1683 Function* NF = cast<Function>(Result->getOrInsertFunction(
1684 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1685
1686 while (!F->use_empty()) {
1687 CallInst* CI = cast<CallInst>(F->use_back());
1688 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1689 new CallInst(NF, bar, "", CI);
1690 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1691 CI->replaceAllUsesWith(foo);
1692 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001693 }
Reid Spencer950bf602007-01-26 08:19:09 +00001694 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001695 }
Reid Spencer950bf602007-01-26 08:19:09 +00001696
1697 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1698 if(F->arg_size() != 1) {
1699 error("Obsolete va_end takes 1 argument");
1700 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001701 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001702
Reid Spencer950bf602007-01-26 08:19:09 +00001703 //vaend foo
1704 // ->
1705 //bar = alloca 1 of typeof(foo)
1706 //vaend bar
1707 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1708 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1709 const Type* ArgTyPtr = PointerType::get(ArgTy);
1710 Function* NF = cast<Function>(Result->getOrInsertFunction(
1711 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001712
Reid Spencer950bf602007-01-26 08:19:09 +00001713 while (!F->use_empty()) {
1714 CallInst* CI = cast<CallInst>(F->use_back());
1715 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1716 new StoreInst(CI->getOperand(1), bar, CI);
1717 new CallInst(NF, bar, "", CI);
1718 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001719 }
Reid Spencer950bf602007-01-26 08:19:09 +00001720 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001721 }
Reid Spencer950bf602007-01-26 08:19:09 +00001722
1723 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1724 if(F->arg_size() != 1) {
1725 error("Obsolete va_copy takes 1 argument");
1726 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001727 }
Reid Spencer950bf602007-01-26 08:19:09 +00001728 //foo = vacopy(bar)
1729 // ->
1730 //a = alloca 1 of typeof(foo)
1731 //b = alloca 1 of typeof(foo)
1732 //store bar -> b
1733 //vacopy(a, b)
1734 //foo = load a
1735
1736 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1737 const Type* ArgTy = F->getFunctionType()->getReturnType();
1738 const Type* ArgTyPtr = PointerType::get(ArgTy);
1739 Function* NF = cast<Function>(Result->getOrInsertFunction(
1740 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001741
Reid Spencer950bf602007-01-26 08:19:09 +00001742 while (!F->use_empty()) {
1743 CallInst* CI = cast<CallInst>(F->use_back());
1744 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1745 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1746 new StoreInst(CI->getOperand(1), b, CI);
1747 new CallInst(NF, a, b, "", CI);
1748 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1749 CI->replaceAllUsesWith(foo);
1750 CI->getParent()->getInstList().erase(CI);
1751 }
1752 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001753 }
1754 }
1755
Reid Spencer52402b02007-01-02 05:45:11 +00001756 return Result;
1757}
1758
Reid Spencer950bf602007-01-26 08:19:09 +00001759} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001760
Reid Spencer950bf602007-01-26 08:19:09 +00001761using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001762
1763
Reid Spencer319a7302007-01-05 17:20:02 +00001764
1765/* Enabling traces. */
1766#ifndef YYDEBUG
1767# define YYDEBUG 0
1768#endif
1769
1770/* Enabling verbose error messages. */
1771#ifdef YYERROR_VERBOSE
1772# undef YYERROR_VERBOSE
1773# define YYERROR_VERBOSE 1
1774#else
1775# define YYERROR_VERBOSE 0
1776#endif
1777
Reid Spencer950bf602007-01-26 08:19:09 +00001778/* Enabling the token table. */
1779#ifndef YYTOKEN_TABLE
1780# define YYTOKEN_TABLE 0
1781#endif
1782
Reid Spencerb7046c72007-01-29 05:41:34 +00001783#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1784#line 1405 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
1785typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00001786 llvm::Module *ModuleVal;
1787 llvm::Function *FunctionVal;
1788 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1789 llvm::BasicBlock *BasicBlockVal;
1790 llvm::TerminatorInst *TermInstVal;
1791 llvm::InstrInfo InstVal;
1792 llvm::ConstInfo ConstVal;
1793 llvm::ValueInfo ValueVal;
1794 llvm::PATypeInfo TypeVal;
1795 llvm::TypeInfo PrimType;
1796 llvm::PHIListInfo PHIList;
1797 std::list<llvm::PATypeInfo> *TypeList;
1798 std::vector<llvm::ValueInfo> *ValueList;
1799 std::vector<llvm::ConstInfo> *ConstVector;
1800
1801
1802 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1803 // Represent the RHS of PHI node
1804 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1805
1806 llvm::GlobalValue::LinkageTypes Linkage;
1807 int64_t SInt64Val;
1808 uint64_t UInt64Val;
1809 int SIntVal;
1810 unsigned UIntVal;
1811 double FPVal;
1812 bool BoolVal;
1813
1814 char *StrVal; // This memory is strdup'd!
1815 llvm::ValID ValIDVal; // strdup'd memory maybe!
1816
1817 llvm::BinaryOps BinaryOpVal;
1818 llvm::TermOps TermOpVal;
1819 llvm::MemoryOps MemOpVal;
1820 llvm::OtherOps OtherOpVal;
1821 llvm::CastOps CastOpVal;
1822 llvm::ICmpInst::Predicate IPred;
1823 llvm::FCmpInst::Predicate FPred;
1824 llvm::Module::Endianness Endianness;
Reid Spencerb7046c72007-01-29 05:41:34 +00001825} YYSTYPE;
1826/* Line 196 of yacc.c. */
1827#line 1828 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001828# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1829# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001830# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001831#endif
1832
Reid Spencer950bf602007-01-26 08:19:09 +00001833
Reid Spencere7c3c602006-11-30 06:36:44 +00001834
Reid Spencer319a7302007-01-05 17:20:02 +00001835/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001836
1837
Reid Spencerb7046c72007-01-29 05:41:34 +00001838/* Line 219 of yacc.c. */
1839#line 1840 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001840
Reid Spencerb7046c72007-01-29 05:41:34 +00001841#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1842# define YYSIZE_T __SIZE_TYPE__
Reid Spencer950bf602007-01-26 08:19:09 +00001843#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001844#if ! defined (YYSIZE_T) && defined (size_t)
1845# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001846#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001847#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1848# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1849# define YYSIZE_T size_t
Reid Spencer950bf602007-01-26 08:19:09 +00001850#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001851#if ! defined (YYSIZE_T)
1852# define YYSIZE_T unsigned int
Reid Spencer950bf602007-01-26 08:19:09 +00001853#endif
1854
1855#ifndef YY_
1856# if YYENABLE_NLS
1857# if ENABLE_NLS
1858# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1859# define YY_(msgid) dgettext ("bison-runtime", msgid)
1860# endif
1861# endif
1862# ifndef YY_
1863# define YY_(msgid) msgid
1864# endif
1865#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001866
Reid Spencerb7046c72007-01-29 05:41:34 +00001867#if ! defined (yyoverflow) || YYERROR_VERBOSE
Reid Spencer319a7302007-01-05 17:20:02 +00001868
1869/* The parser invokes alloca or malloc; define the necessary symbols. */
1870
Reid Spencer950bf602007-01-26 08:19:09 +00001871# ifdef YYSTACK_USE_ALLOCA
1872# if YYSTACK_USE_ALLOCA
1873# ifdef __GNUC__
1874# define YYSTACK_ALLOC __builtin_alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001875# else
Reid Spencer950bf602007-01-26 08:19:09 +00001876# define YYSTACK_ALLOC alloca
Reid Spencerb7046c72007-01-29 05:41:34 +00001877# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00001878# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Reid Spencerb7046c72007-01-29 05:41:34 +00001879# define YYINCLUDED_STDLIB_H
Reid Spencer319a7302007-01-05 17:20:02 +00001880# endif
1881# endif
1882# endif
1883# endif
1884
1885# ifdef YYSTACK_ALLOC
Reid Spencerb7046c72007-01-29 05:41:34 +00001886 /* Pacify GCC's `empty if-body' warning. */
1887# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00001888# ifndef YYSTACK_ALLOC_MAXIMUM
1889 /* The OS might guarantee only one guard page at the bottom of the stack,
1890 and a page size can be as small as 4096 bytes. So we cannot safely
1891 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1892 to allow for a few compiler-allocated temporary stack slots. */
Reid Spencerb7046c72007-01-29 05:41:34 +00001893# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer319a7302007-01-05 17:20:02 +00001894# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001895# else
1896# define YYSTACK_ALLOC YYMALLOC
1897# define YYSTACK_FREE YYFREE
1898# ifndef YYSTACK_ALLOC_MAXIMUM
Reid Spencerb7046c72007-01-29 05:41:34 +00001899# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
Reid Spencer950bf602007-01-26 08:19:09 +00001900# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001901# ifdef __cplusplus
1902extern "C" {
Reid Spencer950bf602007-01-26 08:19:09 +00001903# endif
1904# ifndef YYMALLOC
1905# define YYMALLOC malloc
Reid Spencerb7046c72007-01-29 05:41:34 +00001906# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1907 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001908void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1909# endif
1910# endif
1911# ifndef YYFREE
1912# define YYFREE free
Reid Spencerb7046c72007-01-29 05:41:34 +00001913# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1914 && (defined (__STDC__) || defined (__cplusplus)))
Reid Spencer950bf602007-01-26 08:19:09 +00001915void free (void *); /* INFRINGES ON USER NAME SPACE */
1916# endif
1917# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001918# ifdef __cplusplus
1919}
1920# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001921# endif
Reid Spencerb7046c72007-01-29 05:41:34 +00001922#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00001923
1924
Reid Spencerb7046c72007-01-29 05:41:34 +00001925#if (! defined (yyoverflow) \
1926 && (! defined (__cplusplus) \
1927 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001928
1929/* A type that is properly aligned for any stack member. */
1930union yyalloc
1931{
Reid Spencerb7046c72007-01-29 05:41:34 +00001932 short int yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001933 YYSTYPE yyvs;
1934 };
1935
1936/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00001937# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00001938
1939/* The size of an array large to enough to hold all stacks, each with
1940 N elements. */
1941# define YYSTACK_BYTES(N) \
Reid Spencerb7046c72007-01-29 05:41:34 +00001942 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer950bf602007-01-26 08:19:09 +00001943 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00001944
1945/* Copy COUNT objects from FROM to TO. The source and destination do
1946 not overlap. */
1947# ifndef YYCOPY
Reid Spencerb7046c72007-01-29 05:41:34 +00001948# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00001949# define YYCOPY(To, From, Count) \
1950 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1951# else
1952# define YYCOPY(To, From, Count) \
1953 do \
1954 { \
Reid Spencer950bf602007-01-26 08:19:09 +00001955 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00001956 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00001957 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00001958 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00001959 while (0)
Reid Spencer319a7302007-01-05 17:20:02 +00001960# endif
1961# endif
1962
1963/* Relocate STACK from its old location to the new one. The
1964 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1965 elements in the stack, and YYPTR gives the new location of the
1966 stack. Advance YYPTR to a properly aligned location for the next
1967 stack. */
1968# define YYSTACK_RELOCATE(Stack) \
1969 do \
1970 { \
1971 YYSIZE_T yynewbytes; \
1972 YYCOPY (&yyptr->Stack, Stack, yysize); \
1973 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00001974 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00001975 yyptr += yynewbytes / sizeof (*yyptr); \
1976 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00001977 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00001978
1979#endif
1980
Reid Spencerb7046c72007-01-29 05:41:34 +00001981#if defined (__STDC__) || defined (__cplusplus)
1982 typedef signed char yysigned_char;
1983#else
1984 typedef short int yysigned_char;
1985#endif
1986
1987/* YYFINAL -- State number of the termination state. */
Reid Spencer319a7302007-01-05 17:20:02 +00001988#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00001989/* YYLAST -- Last index in YYTABLE. */
1990#define YYLAST 1712
Reid Spencer319a7302007-01-05 17:20:02 +00001991
Reid Spencerb7046c72007-01-29 05:41:34 +00001992/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00001993#define YYNTOKENS 166
Reid Spencerb7046c72007-01-29 05:41:34 +00001994/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00001995#define YYNNTS 79
Reid Spencerb7046c72007-01-29 05:41:34 +00001996/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00001997#define YYNRULES 308
Reid Spencerb7046c72007-01-29 05:41:34 +00001998/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00001999#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00002000
2001/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2002#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00002003#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00002004
Reid Spencer950bf602007-01-26 08:19:09 +00002005#define YYTRANSLATE(YYX) \
2006 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00002007
2008/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002009static const unsigned char yytranslate[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002010{
2011 0, 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,
Reid Spencer950bf602007-01-26 08:19:09 +00002015 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002016 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002017 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002018 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2019 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002020 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002021 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2022 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002023 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002024 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2025 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2026 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2027 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2028 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2029 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2030 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2031 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2033 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2034 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2035 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2036 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2037 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2038 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2039 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2040 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2041 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2042 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2043 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2044 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2045 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2046 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2047 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2048 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2049 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2050 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002051 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002052};
2053
2054#if YYDEBUG
2055/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2056 YYRHS. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002057static const unsigned short int yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002058{
2059 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2060 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2061 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2062 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2063 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2064 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2065 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2066 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2067 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002068 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002069 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2070 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2071 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2072 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2073 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002074 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2075 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2076 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2077 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2078 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2079 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2080 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2081 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2082 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2083 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2084 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2085 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2086 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2087 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2088 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2089 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002090};
2091
Reid Spencerb7046c72007-01-29 05:41:34 +00002092/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2093static const short int yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002094{
Reid Spencer950bf602007-01-26 08:19:09 +00002095 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002096 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2097 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2098 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2099 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
Reid Spencer950bf602007-01-26 08:19:09 +00002100 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2101 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2102 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2103 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2104 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2105 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2106 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2107 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2108 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2109 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2110 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2111 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2112 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2113 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2114 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2115 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2116 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2117 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002118 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002119 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2120 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2121 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2122 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2123 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2124 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2125 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2126 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2127 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2128 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2129 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2130 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2131 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2132 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2133 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2134 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2135 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2136 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2137 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2138 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2139 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2140 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2141 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2142 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2143 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2144 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2145 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2146 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2147 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2148 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2149 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2150 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2151 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2152 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2153 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2154 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2155 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2156 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2157 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2158 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2159 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2160 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2161 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2162 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2163 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2164 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2165 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2166 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2167 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2168 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2169 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2170 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2171 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2172 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2173 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2174 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2175 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2176 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2177 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2178 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2179 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2180 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2181 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2182 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2183 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2184 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2185 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2186 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2187 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2188 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2189 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2190 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2191 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002192};
2193
2194/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002195static const unsigned short int yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002196{
Reid Spencerb7046c72007-01-29 05:41:34 +00002197 0, 1545, 1545, 1546, 1554, 1555, 1565, 1565, 1565, 1565,
2198 1565, 1565, 1565, 1565, 1565, 1565, 1565, 1569, 1569, 1569,
2199 1573, 1573, 1573, 1573, 1573, 1573, 1577, 1577, 1578, 1578,
2200 1579, 1579, 1580, 1580, 1581, 1581, 1585, 1585, 1586, 1586,
2201 1587, 1587, 1588, 1588, 1589, 1589, 1590, 1590, 1591, 1591,
2202 1592, 1593, 1596, 1596, 1596, 1596, 1600, 1600, 1600, 1600,
2203 1600, 1600, 1600, 1601, 1601, 1601, 1601, 1601, 1601, 1607,
2204 1607, 1607, 1607, 1611, 1611, 1611, 1611, 1615, 1615, 1619,
2205 1619, 1624, 1627, 1632, 1633, 1634, 1635, 1636, 1637, 1638,
2206 1639, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1660,
2207 1661, 1669, 1670, 1678, 1687, 1688, 1695, 1696, 1700, 1704,
2208 1720, 1721, 1728, 1729, 1736, 1744, 1744, 1744, 1744, 1744,
2209 1744, 1744, 1745, 1745, 1745, 1745, 1745, 1750, 1754, 1758,
2210 1763, 1772, 1793, 1799, 1812, 1821, 1825, 1836, 1840, 1853,
2211 1857, 1864, 1865, 1871, 1878, 1890, 1920, 1933, 1956, 1984,
2212 2006, 2017, 2039, 2050, 2059, 2064, 2122, 2129, 2137, 2144,
2213 2151, 2155, 2159, 2168, 2183, 2196, 2205, 2233, 2246, 2255,
2214 2261, 2267, 2276, 2282, 2288, 2299, 2300, 2309, 2310, 2322,
2215 2331, 2332, 2333, 2334, 2335, 2351, 2371, 2373, 2375, 2375,
2216 2382, 2382, 2389, 2389, 2396, 2396, 2404, 2406, 2408, 2413,
2217 2427, 2428, 2432, 2435, 2443, 2447, 2454, 2458, 2462, 2466,
2218 2474, 2474, 2478, 2479, 2483, 2491, 2496, 2504, 2505, 2512,
2219 2519, 2523, 2638, 2638, 2642, 2652, 2652, 2656, 2660, 2662,
2220 2663, 2667, 2667, 2679, 2680, 2685, 2686, 2687, 2688, 2689,
2221 2690, 2691, 2692, 2693, 2714, 2717, 2732, 2733, 2738, 2738,
2222 2746, 2755, 2758, 2767, 2777, 2782, 2791, 2802, 2802, 2805,
2223 2808, 2811, 2815, 2821, 2836, 2842, 2898, 2901, 2907, 2917,
2224 2930, 2959, 2967, 2975, 2979, 2986, 2987, 2991, 2994, 3000,
2225 3017, 3033, 3047, 3059, 3071, 3082, 3091, 3100, 3109, 3116,
2226 3137, 3161, 3167, 3173, 3179, 3195, 3273, 3281, 3282, 3286,
2227 3287, 3291, 3297, 3303, 3309, 3315, 3322, 3334, 3348
Reid Spencer319a7302007-01-05 17:20:02 +00002228};
2229#endif
2230
Reid Spencer950bf602007-01-26 08:19:09 +00002231#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2232/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencerb7046c72007-01-29 05:41:34 +00002233 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer319a7302007-01-05 17:20:02 +00002234static const char *const yytname[] =
2235{
Reid Spencer950bf602007-01-26 08:19:09 +00002236 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2237 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2238 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2239 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2240 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2241 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2242 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2243 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2244 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2245 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2246 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2247 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2248 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2249 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2250 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2251 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2252 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2253 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2254 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2255 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2256 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2257 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2258 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2259 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2260 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2261 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2262 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2263 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2264 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2265 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2266 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2267 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2268 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2269 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2270 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2271 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2272 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2273 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2274 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002275 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002276};
2277#endif
2278
2279# ifdef YYPRINT
2280/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2281 token YYLEX-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002282static const unsigned short int yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002283{
2284 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2285 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2286 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2287 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2288 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2289 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2290 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2291 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2292 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2293 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2294 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2295 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2296 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2297 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2298 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002299 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2300 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002301};
2302# endif
2303
2304/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002305static const unsigned char yyr1[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002306{
Reid Spencer950bf602007-01-26 08:19:09 +00002307 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2308 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2309 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2310 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2311 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2312 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2313 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2314 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2315 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2316 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2317 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2318 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2319 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2320 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2321 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2322 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2323 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2324 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2325 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2326 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2327 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2328 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2329 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2330 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2331 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2332 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2333 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2334 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2335 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2336 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2337 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002338};
2339
2340/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002341static const unsigned char yyr2[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002342{
2343 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2344 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2345 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2346 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2347 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2348 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2349 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2350 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2351 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002352 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002353 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2356 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2357 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002358 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2359 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2360 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2361 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2362 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2363 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2364 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2365 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2366 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2367 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2368 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2369 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2370 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2371 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2372 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2373 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002374};
2375
2376/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2377 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2378 means the default is an error. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002379static const unsigned short int yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002380{
Reid Spencer950bf602007-01-26 08:19:09 +00002381 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2382 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2383 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2384 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2385 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2386 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2387 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2388 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2389 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2390 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2391 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2392 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2393 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2394 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2395 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2396 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2397 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2398 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2399 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2400 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2401 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2402 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2403 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2404 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2405 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2406 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2407 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2408 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2409 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002410 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002411 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2412 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002413 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002414 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2415 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2416 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2417 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2418 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2419 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2420 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2421 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2422 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2423 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2424 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2425 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2426 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2427 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2428 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2429 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2430 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2431 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2432 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2433 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2434 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2435 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2436 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2437 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2438 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2439 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2440 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2441 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002442};
2443
Reid Spencerb7046c72007-01-29 05:41:34 +00002444/* YYDEFGOTO[NTERM-NUM]. */
2445static const short int yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002446{
Reid Spencer950bf602007-01-26 08:19:09 +00002447 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2448 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2449 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2450 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2451 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2452 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2453 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2454 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002455};
2456
2457/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2458 STATE-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002459#define YYPACT_NINF -508
Reid Spencerb7046c72007-01-29 05:41:34 +00002460static const short int yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002461{
Reid Spencer950bf602007-01-26 08:19:09 +00002462 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2463 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2464 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2465 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2466 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2467 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2468 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2469 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2470 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2471 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2472 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2473 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2474 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2475 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2476 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2477 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2478 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2479 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2480 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2481 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2482 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2483 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2484 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2485 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2486 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2487 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2488 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2489 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2490 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2491 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2492 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2493 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2494 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2495 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2496 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2497 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2498 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2499 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2500 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2501 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2502 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2503 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2504 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2505 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2506 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2507 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2508 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2509 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2510 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2511 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2512 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2513 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2514 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2515 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2516 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2517 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2518 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2519 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2520 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2521 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2522 898, 898, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002523};
2524
2525/* YYPGOTO[NTERM-NUM]. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002526static const short int yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002527{
Reid Spencer950bf602007-01-26 08:19:09 +00002528 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2529 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2530 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2531 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2532 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2533 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2534 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2535 -508, -508, 43, -22, -508, -508, 21, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002536};
2537
2538/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2539 positive, shift that token. If negative, reduce the rule which
2540 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002541 If YYTABLE_NINF, syntax error. */
2542#define YYTABLE_NINF -180
Reid Spencerb7046c72007-01-29 05:41:34 +00002543static const short int yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002544{
Reid Spencer950bf602007-01-26 08:19:09 +00002545 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2546 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2547 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2548 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2549 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2550 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2551 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2552 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2553 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2554 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2555 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2556 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2557 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2558 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2559 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2560 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2561 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2562 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2563 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2564 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2565 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2566 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2567 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2568 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2569 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2570 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2571 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2572 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2573 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2574 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2575 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2576 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2577 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2578 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2579 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2580 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2581 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2582 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2583 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2584 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2585 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2586 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2587 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2588 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2589 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2590 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2591 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2592 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2593 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2594 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2595 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2596 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2597 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2598 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2599 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2600 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2601 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2602 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2603 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2604 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2605 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2606 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2607 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2608 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2609 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2610 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2611 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2612 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2613 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2614 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2615 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2616 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2617 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2618 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2619 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2620 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2621 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2622 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2623 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2624 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2625 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2626 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2627 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
Reid Spencerc4d96252007-01-13 00:03:30 +00002628 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002629 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2630 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2631 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2632 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002633 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002634 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2635 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2636 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2637 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2638 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2639 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2640 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2641 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2642 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2643 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2644 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2645 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2646 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2647 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2648 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2649 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2650 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2651 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2652 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2653 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2654 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2655 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2656 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2657 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2658 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2659 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2660 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2661 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2662 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2663 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2664 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2665 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2666 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2667 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2668 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2669 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2670 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2671 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2672 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2673 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2674 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2675 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2676 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2677 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2678 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2679 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2680 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2681 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2682 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2683 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2684 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2685 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2686 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2687 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2688 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2689 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2690 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2691 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2692 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2693 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2694 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2695 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2696 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2697 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2698 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002699 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2700 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002701 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2702 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2703 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2704 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002706 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2707 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2708 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2709 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2710 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2711 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2712 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2713 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2714 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2715 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2716 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002717};
2718
Reid Spencerb7046c72007-01-29 05:41:34 +00002719static const short int yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002720{
Reid Spencer950bf602007-01-26 08:19:09 +00002721 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2722 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2723 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2724 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2725 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2726 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2727 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2728 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2729 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2730 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2731 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2732 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2733 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2734 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2735 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2736 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2737 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2738 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2739 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2740 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2741 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2742 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2743 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2744 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2745 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2746 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2747 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2748 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2749 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2750 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2751 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2752 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2753 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2754 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2755 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2756 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2757 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2758 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2759 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2760 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2761 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2762 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2763 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2764 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2765 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2766 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2767 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2768 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2769 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2770 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2771 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2772 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
Reid Spencerc4d96252007-01-13 00:03:30 +00002773 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
Reid Spencer950bf602007-01-26 08:19:09 +00002774 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2775 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2776 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2777 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2778 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2779 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2780 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2781 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2782 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2783 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2784 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2785 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2786 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2787 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2788 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2789 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2790 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2791 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2792 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2793 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2794 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2795 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2796 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2797 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2798 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2799 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2800 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2801 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2802 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2803 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2804 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2805 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2806 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2807 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2808 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2809 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2810 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2811 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2812 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2813 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2814 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2815 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2816 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2817 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2818 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2819 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2820 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2821 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2822 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2823 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2824 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2825 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2826 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2827 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2828 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2829 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2830 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2831 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2832 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2833 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2834 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2835 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2836 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2837 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2838 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2839 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2840 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2841 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2842 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2843 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2844 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2845 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2846 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2847 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2848 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2849 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2850 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2851 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2852 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2853 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2854 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2855 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2856 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2857 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2858 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2859 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2860 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2861 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2862 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2863 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2864 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2865 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2866 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2867 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2868 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2869 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2870 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2871 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2872 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2873 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2874 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2875 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2876 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2877 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2878 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2879 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2880 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2881 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2882 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2883 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2884 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2885 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2886 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2887 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2888 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2889 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2890 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2891 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2892 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002893};
2894
2895/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2896 symbol of state STATE-NUM. */
Reid Spencerb7046c72007-01-29 05:41:34 +00002897static const unsigned char yystos[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002898{
Reid Spencer950bf602007-01-26 08:19:09 +00002899 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2900 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2901 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2902 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2903 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2904 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2905 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2906 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2907 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2908 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2909 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2910 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2911 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2912 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2913 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2914 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2915 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2916 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2917 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2918 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2919 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2920 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2921 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2922 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2923 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2924 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2925 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2926 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2927 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2928 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2929 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2930 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2931 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2932 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2933 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2934 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2935 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2936 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2937 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2938 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2939 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2940 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2941 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2942 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2943 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2944 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2945 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2946 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2947 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2948 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2949 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2950 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2951 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2952 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2953 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2954 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2955 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2956 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2957 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2958 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2959 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00002960};
Reid Spencere7c3c602006-11-30 06:36:44 +00002961
2962#define yyerrok (yyerrstatus = 0)
2963#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00002964#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00002965#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00002966
Reid Spencere7c3c602006-11-30 06:36:44 +00002967#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00002968#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00002969#define YYERROR goto yyerrorlab
2970
Reid Spencer319a7302007-01-05 17:20:02 +00002971
2972/* Like YYERROR except do call yyerror. This remains here temporarily
2973 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00002974 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00002975
Reid Spencere7c3c602006-11-30 06:36:44 +00002976#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00002977
Reid Spencere7c3c602006-11-30 06:36:44 +00002978#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00002979
2980#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00002981do \
2982 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00002983 { \
2984 yychar = (Token); \
2985 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00002986 yytoken = YYTRANSLATE (yychar); \
Reid Spencerb7046c72007-01-29 05:41:34 +00002987 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00002988 goto yybackup; \
2989 } \
2990 else \
Reid Spencer950bf602007-01-26 08:19:09 +00002991 { \
2992 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00002993 YYERROR; \
2994 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00002995while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00002996
Reid Spencer950bf602007-01-26 08:19:09 +00002997
Reid Spencere7c3c602006-11-30 06:36:44 +00002998#define YYTERROR 1
2999#define YYERRCODE 256
3000
Reid Spencer319a7302007-01-05 17:20:02 +00003001
Reid Spencer950bf602007-01-26 08:19:09 +00003002/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3003 If N is 0, then set CURRENT to the empty location which ends
3004 the previous symbol: RHS[0] (always defined). */
3005
3006#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00003007#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00003008# define YYLLOC_DEFAULT(Current, Rhs, N) \
3009 do \
Reid Spencerb7046c72007-01-29 05:41:34 +00003010 if (N) \
Reid Spencer950bf602007-01-26 08:19:09 +00003011 { \
3012 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3013 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3014 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3015 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3016 } \
3017 else \
3018 { \
3019 (Current).first_line = (Current).last_line = \
3020 YYRHSLOC (Rhs, 0).last_line; \
3021 (Current).first_column = (Current).last_column = \
3022 YYRHSLOC (Rhs, 0).last_column; \
3023 } \
Reid Spencerb7046c72007-01-29 05:41:34 +00003024 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003025#endif
3026
Reid Spencer950bf602007-01-26 08:19:09 +00003027
3028/* YY_LOCATION_PRINT -- Print the location on the stream.
3029 This macro was not mandated originally: define only if we know
3030 we won't break user code: when these are the locations we know. */
3031
3032#ifndef YY_LOCATION_PRINT
3033# if YYLTYPE_IS_TRIVIAL
3034# define YY_LOCATION_PRINT(File, Loc) \
3035 fprintf (File, "%d.%d-%d.%d", \
Reid Spencerb7046c72007-01-29 05:41:34 +00003036 (Loc).first_line, (Loc).first_column, \
3037 (Loc).last_line, (Loc).last_column)
Reid Spencer950bf602007-01-26 08:19:09 +00003038# else
3039# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3040# endif
3041#endif
3042
3043
Reid Spencer319a7302007-01-05 17:20:02 +00003044/* YYLEX -- calling `yylex' with the right arguments. */
3045
Reid Spencer950bf602007-01-26 08:19:09 +00003046#ifdef YYLEX_PARAM
3047# define YYLEX yylex (YYLEX_PARAM)
3048#else
3049# define YYLEX yylex ()
3050#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003051
3052/* Enable debugging if requested. */
3053#if YYDEBUG
3054
3055# ifndef YYFPRINTF
3056# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3057# define YYFPRINTF fprintf
3058# endif
3059
3060# define YYDPRINTF(Args) \
3061do { \
3062 if (yydebug) \
3063 YYFPRINTF Args; \
Reid Spencerb7046c72007-01-29 05:41:34 +00003064} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003065
Reid Spencerb7046c72007-01-29 05:41:34 +00003066# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3067do { \
3068 if (yydebug) \
3069 { \
3070 YYFPRINTF (stderr, "%s ", Title); \
3071 yysymprint (stderr, \
3072 Type, Value); \
3073 YYFPRINTF (stderr, "\n"); \
3074 } \
3075} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003076
3077/*------------------------------------------------------------------.
3078| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3079| TOP (included). |
3080`------------------------------------------------------------------*/
3081
Reid Spencerb7046c72007-01-29 05:41:34 +00003082#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003083static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003084yy_stack_print (short int *bottom, short int *top)
Reid Spencer950bf602007-01-26 08:19:09 +00003085#else
3086static void
3087yy_stack_print (bottom, top)
Reid Spencerb7046c72007-01-29 05:41:34 +00003088 short int *bottom;
3089 short int *top;
Reid Spencer950bf602007-01-26 08:19:09 +00003090#endif
3091{
3092 YYFPRINTF (stderr, "Stack now");
Reid Spencerb7046c72007-01-29 05:41:34 +00003093 for (/* Nothing. */; bottom <= top; ++bottom)
Reid Spencer950bf602007-01-26 08:19:09 +00003094 YYFPRINTF (stderr, " %d", *bottom);
3095 YYFPRINTF (stderr, "\n");
3096}
3097
3098# define YY_STACK_PRINT(Bottom, Top) \
3099do { \
3100 if (yydebug) \
3101 yy_stack_print ((Bottom), (Top)); \
Reid Spencerb7046c72007-01-29 05:41:34 +00003102} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003103
3104
3105/*------------------------------------------------.
3106| Report that the YYRULE is going to be reduced. |
3107`------------------------------------------------*/
3108
Reid Spencerb7046c72007-01-29 05:41:34 +00003109#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003110static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003111yy_reduce_print (int yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003112#else
3113static void
Reid Spencerb7046c72007-01-29 05:41:34 +00003114yy_reduce_print (yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003115 int yyrule;
3116#endif
3117{
3118 int yyi;
3119 unsigned long int yylno = yyrline[yyrule];
Reid Spencerb7046c72007-01-29 05:41:34 +00003120 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3121 yyrule - 1, yylno);
3122 /* Print the symbols being reduced, and their result. */
3123 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3124 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3125 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Reid Spencer950bf602007-01-26 08:19:09 +00003126}
3127
3128# define YY_REDUCE_PRINT(Rule) \
3129do { \
3130 if (yydebug) \
Reid Spencerb7046c72007-01-29 05:41:34 +00003131 yy_reduce_print (Rule); \
3132} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003133
Reid Spencer319a7302007-01-05 17:20:02 +00003134/* Nonzero means print parse trace. It is left uninitialized so that
3135 multiple parsers can coexist. */
3136int yydebug;
3137#else /* !YYDEBUG */
3138# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003139# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3140# define YY_STACK_PRINT(Bottom, Top)
3141# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003142#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003143
Reid Spencer950bf602007-01-26 08:19:09 +00003144
Reid Spencer319a7302007-01-05 17:20:02 +00003145/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003146#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003147# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003148#endif
3149
Reid Spencer319a7302007-01-05 17:20:02 +00003150/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3151 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003152
Reid Spencer319a7302007-01-05 17:20:02 +00003153 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003154 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003155 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003156
3157#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003158# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003159#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003160
Reid Spencere7c3c602006-11-30 06:36:44 +00003161
3162
Reid Spencer319a7302007-01-05 17:20:02 +00003163#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003164
Reid Spencer319a7302007-01-05 17:20:02 +00003165# ifndef yystrlen
Reid Spencerb7046c72007-01-29 05:41:34 +00003166# if defined (__GLIBC__) && defined (_STRING_H)
Reid Spencer319a7302007-01-05 17:20:02 +00003167# define yystrlen strlen
3168# else
3169/* Return the length of YYSTR. */
3170static YYSIZE_T
Reid Spencerb7046c72007-01-29 05:41:34 +00003171# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003172yystrlen (const char *yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003173# else
Reid Spencer319a7302007-01-05 17:20:02 +00003174yystrlen (yystr)
Reid Spencerb7046c72007-01-29 05:41:34 +00003175 const char *yystr;
3176# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003177{
Reid Spencerb7046c72007-01-29 05:41:34 +00003178 const char *yys = yystr;
3179
3180 while (*yys++ != '\0')
Reid Spencer319a7302007-01-05 17:20:02 +00003181 continue;
Reid Spencerb7046c72007-01-29 05:41:34 +00003182
3183 return yys - yystr - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003184}
Reid Spencer319a7302007-01-05 17:20:02 +00003185# endif
3186# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003187
Reid Spencer319a7302007-01-05 17:20:02 +00003188# ifndef yystpcpy
Reid Spencerb7046c72007-01-29 05:41:34 +00003189# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Reid Spencer319a7302007-01-05 17:20:02 +00003190# define yystpcpy stpcpy
3191# else
3192/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3193 YYDEST. */
3194static char *
Reid Spencerb7046c72007-01-29 05:41:34 +00003195# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003196yystpcpy (char *yydest, const char *yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003197# else
Reid Spencer319a7302007-01-05 17:20:02 +00003198yystpcpy (yydest, yysrc)
Reid Spencerb7046c72007-01-29 05:41:34 +00003199 char *yydest;
3200 const char *yysrc;
3201# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003202{
Reid Spencer950bf602007-01-26 08:19:09 +00003203 char *yyd = yydest;
3204 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003205
Reid Spencer319a7302007-01-05 17:20:02 +00003206 while ((*yyd++ = *yys++) != '\0')
3207 continue;
3208
3209 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003210}
Reid Spencer319a7302007-01-05 17:20:02 +00003211# endif
3212# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003213
Reid Spencer950bf602007-01-26 08:19:09 +00003214# ifndef yytnamerr
3215/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3216 quotes and backslashes, so that it's suitable for yyerror. The
3217 heuristic is that double-quoting is unnecessary unless the string
3218 contains an apostrophe, a comma, or backslash (other than
3219 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3220 null, do not copy; instead, return the length of what the result
3221 would have been. */
3222static YYSIZE_T
3223yytnamerr (char *yyres, const char *yystr)
3224{
3225 if (*yystr == '"')
3226 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003227 size_t yyn = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00003228 char const *yyp = yystr;
3229
3230 for (;;)
3231 switch (*++yyp)
3232 {
3233 case '\'':
3234 case ',':
3235 goto do_not_strip_quotes;
3236
3237 case '\\':
3238 if (*++yyp != '\\')
3239 goto do_not_strip_quotes;
3240 /* Fall through. */
3241 default:
3242 if (yyres)
3243 yyres[yyn] = *yyp;
3244 yyn++;
3245 break;
3246
3247 case '"':
3248 if (yyres)
3249 yyres[yyn] = '\0';
3250 return yyn;
3251 }
3252 do_not_strip_quotes: ;
3253 }
3254
3255 if (! yyres)
3256 return yystrlen (yystr);
3257
3258 return yystpcpy (yyres, yystr) - yyres;
3259}
3260# endif
3261
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003262#endif /* YYERROR_VERBOSE */
Reid Spencerb7046c72007-01-29 05:41:34 +00003263
Reid Spencere7c3c602006-11-30 06:36:44 +00003264
3265
Reid Spencerb7046c72007-01-29 05:41:34 +00003266#if YYDEBUG
3267/*--------------------------------.
3268| Print this symbol on YYOUTPUT. |
3269`--------------------------------*/
3270
3271#if defined (__STDC__) || defined (__cplusplus)
3272static void
3273yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
3274#else
3275static void
3276yysymprint (yyoutput, yytype, yyvaluep)
3277 FILE *yyoutput;
3278 int yytype;
3279 YYSTYPE *yyvaluep;
3280#endif
3281{
3282 /* Pacify ``unused variable'' warnings. */
3283 (void) yyvaluep;
3284
3285 if (yytype < YYNTOKENS)
3286 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3287 else
3288 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3289
3290
3291# ifdef YYPRINT
3292 if (yytype < YYNTOKENS)
3293 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3294# endif
3295 switch (yytype)
3296 {
3297 default:
3298 break;
3299 }
3300 YYFPRINTF (yyoutput, ")");
3301}
3302
3303#endif /* ! YYDEBUG */
Reid Spencer319a7302007-01-05 17:20:02 +00003304/*-----------------------------------------------.
3305| Release the memory associated to this symbol. |
3306`-----------------------------------------------*/
3307
Reid Spencerb7046c72007-01-29 05:41:34 +00003308#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003309static void
3310yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003311#else
Reid Spencer950bf602007-01-26 08:19:09 +00003312static void
3313yydestruct (yymsg, yytype, yyvaluep)
3314 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003315 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003316 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003317#endif
3318{
Reid Spencerb7046c72007-01-29 05:41:34 +00003319 /* Pacify ``unused variable'' warnings. */
3320 (void) yyvaluep;
Reid Spencer950bf602007-01-26 08:19:09 +00003321
3322 if (!yymsg)
3323 yymsg = "Deleting";
3324 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003325
3326 switch (yytype)
3327 {
Reid Spencer950bf602007-01-26 08:19:09 +00003328
Reid Spencer319a7302007-01-05 17:20:02 +00003329 default:
Reid Spencerb7046c72007-01-29 05:41:34 +00003330 break;
Reid Spencer319a7302007-01-05 17:20:02 +00003331 }
3332}
3333
3334
Reid Spencer950bf602007-01-26 08:19:09 +00003335/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003336
3337#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003338# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003339int yyparse (void *YYPARSE_PARAM);
Reid Spencerb7046c72007-01-29 05:41:34 +00003340# else
Reid Spencer950bf602007-01-26 08:19:09 +00003341int yyparse ();
Reid Spencerb7046c72007-01-29 05:41:34 +00003342# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003343#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003344#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003345int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003346#else
3347int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003348#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003349#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003350
3351
Reid Spencer950bf602007-01-26 08:19:09 +00003352
3353/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003354int yychar;
3355
Reid Spencer950bf602007-01-26 08:19:09 +00003356/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003357YYSTYPE yylval;
3358
Reid Spencer950bf602007-01-26 08:19:09 +00003359/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003360int yynerrs;
3361
3362
Reid Spencer950bf602007-01-26 08:19:09 +00003363
3364/*----------.
3365| yyparse. |
3366`----------*/
3367
3368#ifdef YYPARSE_PARAM
Reid Spencerb7046c72007-01-29 05:41:34 +00003369# if defined (__STDC__) || defined (__cplusplus)
3370int yyparse (void *YYPARSE_PARAM)
3371# else
3372int yyparse (YYPARSE_PARAM)
3373 void *YYPARSE_PARAM;
3374# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003375#else /* ! YYPARSE_PARAM */
Reid Spencerb7046c72007-01-29 05:41:34 +00003376#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003377int
Reid Spencer950bf602007-01-26 08:19:09 +00003378yyparse (void)
3379#else
3380int
3381yyparse ()
3382
3383#endif
3384#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003385{
3386
Reid Spencer950bf602007-01-26 08:19:09 +00003387 int yystate;
3388 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003389 int yyresult;
3390 /* Number of tokens to shift before error messages enabled. */
3391 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003392 /* Look-ahead token as an internal (translated) token number. */
3393 int yytoken = 0;
Reid Spencer319a7302007-01-05 17:20:02 +00003394
3395 /* Three stacks and their tools:
3396 `yyss': related to states,
3397 `yyvs': related to semantic values,
3398 `yyls': related to locations.
3399
3400 Refer to the stacks thru separate pointers, to allow yyoverflow
3401 to reallocate them elsewhere. */
3402
3403 /* The state stack. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003404 short int yyssa[YYINITDEPTH];
3405 short int *yyss = yyssa;
3406 short int *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003407
3408 /* The semantic value stack. */
3409 YYSTYPE yyvsa[YYINITDEPTH];
3410 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003411 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003412
3413
3414
Reid Spencerb7046c72007-01-29 05:41:34 +00003415#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003416
Reid Spencer319a7302007-01-05 17:20:02 +00003417 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003418
Reid Spencer319a7302007-01-05 17:20:02 +00003419 /* The variables used to return semantic value and location from the
3420 action routines. */
3421 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003422
3423
Reid Spencerb7046c72007-01-29 05:41:34 +00003424 /* When reducing, the number of symbols on the RHS of the reduced
3425 rule. */
3426 int yylen;
Reid Spencere7c3c602006-11-30 06:36:44 +00003427
Reid Spencer319a7302007-01-05 17:20:02 +00003428 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003429
3430 yystate = 0;
3431 yyerrstatus = 0;
3432 yynerrs = 0;
3433 yychar = YYEMPTY; /* Cause a token to be read. */
3434
3435 /* Initialize stack pointers.
3436 Waste one element of value and location stack
3437 so that they stay on the same level as the state stack.
3438 The wasted elements are never initialized. */
3439
Reid Spencer319a7302007-01-05 17:20:02 +00003440 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003441 yyvsp = yyvs;
3442
Reid Spencer319a7302007-01-05 17:20:02 +00003443 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003444
Reid Spencer319a7302007-01-05 17:20:02 +00003445/*------------------------------------------------------------.
3446| yynewstate -- Push a new state, which is found in yystate. |
3447`------------------------------------------------------------*/
3448 yynewstate:
3449 /* In all cases, when you get here, the value and location stacks
Reid Spencerb7046c72007-01-29 05:41:34 +00003450 have just been pushed. so pushing a state here evens the stacks.
3451 */
Reid Spencer319a7302007-01-05 17:20:02 +00003452 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003453
Reid Spencer319a7302007-01-05 17:20:02 +00003454 yysetstate:
3455 *yyssp = yystate;
3456
Reid Spencer950bf602007-01-26 08:19:09 +00003457 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003458 {
3459 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003460 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003461
3462#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003463 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003464 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer319a7302007-01-05 17:20:02 +00003465 these so that the &'s don't force the real ones into
3466 memory. */
3467 YYSTYPE *yyvs1 = yyvs;
Reid Spencerb7046c72007-01-29 05:41:34 +00003468 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003469
Reid Spencer319a7302007-01-05 17:20:02 +00003470
3471 /* Each stack pointer address is followed by the size of the
3472 data in use in that stack, in bytes. This used to be a
3473 conditional around just the two extra args, but that might
3474 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003475 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003476 &yyss1, yysize * sizeof (*yyssp),
3477 &yyvs1, yysize * sizeof (*yyvsp),
3478
3479 &yystacksize);
3480
3481 yyss = yyss1;
3482 yyvs = yyvs1;
3483 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003484#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003485# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003486 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003487# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003488 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003489 if (YYMAXDEPTH <= yystacksize)
3490 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003491 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003492 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003493 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003494
3495 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003496 short int *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003497 union yyalloc *yyptr =
3498 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3499 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003500 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003501 YYSTACK_RELOCATE (yyss);
3502 YYSTACK_RELOCATE (yyvs);
3503
3504# undef YYSTACK_RELOCATE
3505 if (yyss1 != yyssa)
3506 YYSTACK_FREE (yyss1);
3507 }
3508# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003509#endif /* no yyoverflow */
3510
Reid Spencer319a7302007-01-05 17:20:02 +00003511 yyssp = yyss + yysize - 1;
3512 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003513
3514
Reid Spencer319a7302007-01-05 17:20:02 +00003515 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3516 (unsigned long int) yystacksize));
3517
Reid Spencer950bf602007-01-26 08:19:09 +00003518 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003519 YYABORT;
3520 }
3521
Reid Spencer319a7302007-01-05 17:20:02 +00003522 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003523
3524 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003525
3526/*-----------.
3527| yybackup. |
3528`-----------*/
3529yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003530
Reid Spencerb7046c72007-01-29 05:41:34 +00003531/* Do appropriate processing given the current state. */
3532/* Read a look-ahead token if we need one and don't already have one. */
3533/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003534
Reid Spencer950bf602007-01-26 08:19:09 +00003535 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003536
Reid Spencere7c3c602006-11-30 06:36:44 +00003537 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003538 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003539 goto yydefault;
3540
Reid Spencer950bf602007-01-26 08:19:09 +00003541 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003542
Reid Spencer950bf602007-01-26 08:19:09 +00003543 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003544 if (yychar == YYEMPTY)
3545 {
Reid Spencer319a7302007-01-05 17:20:02 +00003546 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003547 yychar = YYLEX;
3548 }
3549
Reid Spencer950bf602007-01-26 08:19:09 +00003550 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003551 {
Reid Spencer950bf602007-01-26 08:19:09 +00003552 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003553 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003554 }
3555 else
3556 {
Reid Spencer950bf602007-01-26 08:19:09 +00003557 yytoken = YYTRANSLATE (yychar);
3558 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003559 }
3560
Reid Spencer950bf602007-01-26 08:19:09 +00003561 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003562 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003563 yyn += yytoken;
3564 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003565 goto yydefault;
3566 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003567 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003568 {
Reid Spencer319a7302007-01-05 17:20:02 +00003569 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003570 goto yyerrlab;
3571 yyn = -yyn;
3572 goto yyreduce;
3573 }
3574
3575 if (yyn == YYFINAL)
3576 YYACCEPT;
3577
Reid Spencerb7046c72007-01-29 05:41:34 +00003578 /* Shift the look-ahead token. */
3579 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3580
3581 /* Discard the token being shifted unless it is eof. */
3582 if (yychar != YYEOF)
3583 yychar = YYEMPTY;
3584
3585 *++yyvsp = yylval;
3586
3587
Reid Spencer319a7302007-01-05 17:20:02 +00003588 /* Count tokens shifted since error; after three, turn off error
3589 status. */
3590 if (yyerrstatus)
3591 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003592
3593 yystate = yyn;
3594 goto yynewstate;
3595
Chris Lattner37e01c52007-01-04 18:46:42 +00003596
Reid Spencer319a7302007-01-05 17:20:02 +00003597/*-----------------------------------------------------------.
3598| yydefault -- do the default action for the current state. |
3599`-----------------------------------------------------------*/
3600yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003601 yyn = yydefact[yystate];
3602 if (yyn == 0)
3603 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003604 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003605
Reid Spencer319a7302007-01-05 17:20:02 +00003606
3607/*-----------------------------.
3608| yyreduce -- Do a reduction. |
3609`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003610yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003611 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003612 yylen = yyr2[yyn];
3613
Reid Spencer319a7302007-01-05 17:20:02 +00003614 /* If YYLEN is nonzero, implement the default value of the action:
3615 `$$ = $1'.
3616
3617 Otherwise, the following line sets YYVAL to garbage.
3618 This behavior is undocumented and Bison
3619 users should not rely upon it. Assigning to YYVAL
3620 unconditionally makes the parser a bit smaller, and it avoids a
3621 GCC warning that YYVAL may be used uninitialized. */
3622 yyval = yyvsp[1-yylen];
3623
3624
Reid Spencer950bf602007-01-26 08:19:09 +00003625 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003626 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003627 {
Reid Spencer950bf602007-01-26 08:19:09 +00003628 case 3:
Reid Spencerb7046c72007-01-29 05:41:34 +00003629#line 1546 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003630 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003631 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003632 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003633 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003634 ;}
3635 break;
3636
3637 case 5:
Reid Spencerb7046c72007-01-29 05:41:34 +00003638#line 1555 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003639 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003640 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003641 error("Value too large for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00003642 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003643 ;}
3644 break;
3645
3646 case 26:
Reid Spencerb7046c72007-01-29 05:41:34 +00003647#line 1577 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003648 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3649 break;
3650
3651 case 27:
Reid Spencerb7046c72007-01-29 05:41:34 +00003652#line 1577 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003653 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3654 break;
3655
3656 case 28:
Reid Spencerb7046c72007-01-29 05:41:34 +00003657#line 1578 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003658 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3659 break;
3660
3661 case 29:
Reid Spencerb7046c72007-01-29 05:41:34 +00003662#line 1578 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003663 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3664 break;
3665
3666 case 30:
Reid Spencerb7046c72007-01-29 05:41:34 +00003667#line 1579 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003668 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3669 break;
3670
3671 case 31:
Reid Spencerb7046c72007-01-29 05:41:34 +00003672#line 1579 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003673 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3674 break;
3675
3676 case 32:
Reid Spencerb7046c72007-01-29 05:41:34 +00003677#line 1580 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003678 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3679 break;
3680
3681 case 33:
Reid Spencerb7046c72007-01-29 05:41:34 +00003682#line 1580 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003683 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3684 break;
3685
3686 case 34:
Reid Spencerb7046c72007-01-29 05:41:34 +00003687#line 1581 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003688 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3689 break;
3690
3691 case 35:
Reid Spencerb7046c72007-01-29 05:41:34 +00003692#line 1581 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003693 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3694 break;
3695
3696 case 36:
Reid Spencerb7046c72007-01-29 05:41:34 +00003697#line 1585 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003698 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3699 break;
3700
3701 case 37:
Reid Spencerb7046c72007-01-29 05:41:34 +00003702#line 1585 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003703 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3704 break;
3705
3706 case 38:
Reid Spencerb7046c72007-01-29 05:41:34 +00003707#line 1586 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003708 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3709 break;
3710
3711 case 39:
Reid Spencerb7046c72007-01-29 05:41:34 +00003712#line 1586 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003713 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3714 break;
3715
3716 case 40:
Reid Spencerb7046c72007-01-29 05:41:34 +00003717#line 1587 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003718 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3719 break;
3720
3721 case 41:
Reid Spencerb7046c72007-01-29 05:41:34 +00003722#line 1587 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003723 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3724 break;
3725
3726 case 42:
Reid Spencerb7046c72007-01-29 05:41:34 +00003727#line 1588 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003728 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3729 break;
3730
3731 case 43:
Reid Spencerb7046c72007-01-29 05:41:34 +00003732#line 1588 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003733 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3734 break;
3735
3736 case 44:
Reid Spencerb7046c72007-01-29 05:41:34 +00003737#line 1589 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003738 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3739 break;
3740
3741 case 45:
Reid Spencerb7046c72007-01-29 05:41:34 +00003742#line 1589 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003743 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3744 break;
3745
3746 case 46:
Reid Spencerb7046c72007-01-29 05:41:34 +00003747#line 1590 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003748 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3749 break;
3750
3751 case 47:
Reid Spencerb7046c72007-01-29 05:41:34 +00003752#line 1590 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003753 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3754 break;
3755
3756 case 48:
Reid Spencerb7046c72007-01-29 05:41:34 +00003757#line 1591 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003758 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3759 break;
3760
3761 case 49:
Reid Spencerb7046c72007-01-29 05:41:34 +00003762#line 1591 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003763 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3764 break;
3765
3766 case 50:
Reid Spencerb7046c72007-01-29 05:41:34 +00003767#line 1592 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003768 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3769 break;
3770
3771 case 51:
Reid Spencerb7046c72007-01-29 05:41:34 +00003772#line 1593 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003773 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3774 break;
3775
3776 case 81:
Reid Spencerb7046c72007-01-29 05:41:34 +00003777#line 1624 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003778 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003779 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003780 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003781 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003782
Reid Spencer319a7302007-01-05 17:20:02 +00003783 case 82:
Reid Spencerb7046c72007-01-29 05:41:34 +00003784#line 1627 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003785 {
Reid Spencer950bf602007-01-26 08:19:09 +00003786 (yyval.StrVal) = 0;
3787 ;}
3788 break;
3789
3790 case 83:
Reid Spencerb7046c72007-01-29 05:41:34 +00003791#line 1632 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003792 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3793 break;
3794
3795 case 84:
Reid Spencerb7046c72007-01-29 05:41:34 +00003796#line 1633 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003797 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3798 break;
3799
3800 case 85:
Reid Spencerb7046c72007-01-29 05:41:34 +00003801#line 1634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003802 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3803 break;
3804
3805 case 86:
Reid Spencerb7046c72007-01-29 05:41:34 +00003806#line 1635 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003807 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3808 break;
3809
3810 case 87:
Reid Spencerb7046c72007-01-29 05:41:34 +00003811#line 1636 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003812 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3813 break;
3814
3815 case 88:
Reid Spencerb7046c72007-01-29 05:41:34 +00003816#line 1637 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003817 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3818 break;
3819
3820 case 89:
Reid Spencerb7046c72007-01-29 05:41:34 +00003821#line 1638 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003822 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003823 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003824
Reid Spencer319a7302007-01-05 17:20:02 +00003825 case 90:
Reid Spencerb7046c72007-01-29 05:41:34 +00003826#line 1639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003827 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3828 break;
3829
3830 case 91:
Reid Spencerb7046c72007-01-29 05:41:34 +00003831#line 1643 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3832 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003833 break;
3834
3835 case 92:
Reid Spencerb7046c72007-01-29 05:41:34 +00003836#line 1644 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3837 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003838 break;
3839
3840 case 93:
Reid Spencerb7046c72007-01-29 05:41:34 +00003841#line 1645 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3842 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::CSRet; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003843 break;
3844
3845 case 94:
Reid Spencerb7046c72007-01-29 05:41:34 +00003846#line 1646 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3847 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::Fast; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003848 break;
3849
3850 case 95:
Reid Spencerb7046c72007-01-29 05:41:34 +00003851#line 1647 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3852 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::Cold; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003853 break;
3854
3855 case 96:
Reid Spencerb7046c72007-01-29 05:41:34 +00003856#line 1648 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3857 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003858 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00003859
Reid Spencer319a7302007-01-05 17:20:02 +00003860 case 97:
Reid Spencerb7046c72007-01-29 05:41:34 +00003861#line 1649 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3862 { CurFun.LastCC = (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003863 break;
Reid Spencer16244f42006-12-01 21:10:07 +00003864
Reid Spencer319a7302007-01-05 17:20:02 +00003865 case 98:
Reid Spencerb7046c72007-01-29 05:41:34 +00003866#line 1650 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003867 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003868 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00003869 error("Calling conv too large");
Reid Spencerb7046c72007-01-29 05:41:34 +00003870 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003871 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003872 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003873
Reid Spencer319a7302007-01-05 17:20:02 +00003874 case 99:
Reid Spencerb7046c72007-01-29 05:41:34 +00003875#line 1660 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003876 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003877 break;
3878
Reid Spencerc4d96252007-01-13 00:03:30 +00003879 case 100:
Reid Spencerb7046c72007-01-29 05:41:34 +00003880#line 1661 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003881 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003882 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003883 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3884 error("Alignment must be a power of two");
3885 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003886 break;
3887
3888 case 101:
Reid Spencerb7046c72007-01-29 05:41:34 +00003889#line 1669 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003890 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003891 break;
3892
3893 case 102:
Reid Spencerb7046c72007-01-29 05:41:34 +00003894#line 1670 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003895 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003896 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003897 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3898 error("Alignment must be a power of two");
3899 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003900 break;
3901
3902 case 103:
Reid Spencerb7046c72007-01-29 05:41:34 +00003903#line 1678 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003904 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003905 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3906 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00003907 error("Invalid character in section name");
Reid Spencerb7046c72007-01-29 05:41:34 +00003908 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003909 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003910 break;
3911
3912 case 104:
Reid Spencerb7046c72007-01-29 05:41:34 +00003913#line 1687 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003914 { (yyval.StrVal) = 0; ;}
3915 break;
3916
3917 case 105:
Reid Spencerb7046c72007-01-29 05:41:34 +00003918#line 1688 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3919 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003920 break;
3921
Reid Spencerc4d96252007-01-13 00:03:30 +00003922 case 106:
Reid Spencerb7046c72007-01-29 05:41:34 +00003923#line 1695 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003924 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003925 break;
3926
Reid Spencer319a7302007-01-05 17:20:02 +00003927 case 107:
Reid Spencerb7046c72007-01-29 05:41:34 +00003928#line 1696 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003929 {;}
3930 break;
3931
3932 case 108:
Reid Spencerb7046c72007-01-29 05:41:34 +00003933#line 1700 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003934 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003935 CurGV->setSection((yyvsp[0].StrVal));
3936 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00003937 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003938 break;
3939
3940 case 109:
Reid Spencerb7046c72007-01-29 05:41:34 +00003941#line 1704 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003942 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003943 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00003944 error("Alignment must be a power of two");
Reid Spencerb7046c72007-01-29 05:41:34 +00003945 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00003946
3947 ;}
3948 break;
3949
3950 case 111:
Reid Spencerb7046c72007-01-29 05:41:34 +00003951#line 1721 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003952 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003953 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00003954 (yyval.TypeVal).S = Signless;
3955 ;}
3956 break;
3957
3958 case 113:
Reid Spencerb7046c72007-01-29 05:41:34 +00003959#line 1729 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003960 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003961 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00003962 (yyval.TypeVal).S = Signless;
3963 ;}
3964 break;
3965
3966 case 114:
Reid Spencerb7046c72007-01-29 05:41:34 +00003967#line 1736 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003968 {
3969 if (!UpRefs.empty())
Reid Spencerb7046c72007-01-29 05:41:34 +00003970 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).T)->getDescription());
3971 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003972 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003973 break;
3974
3975 case 127:
Reid Spencerb7046c72007-01-29 05:41:34 +00003976#line 1750 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003977 {
Reid Spencerb7046c72007-01-29 05:41:34 +00003978 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
3979 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
Reid Spencer950bf602007-01-26 08:19:09 +00003980 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003981 break;
3982
3983 case 128:
Reid Spencerb7046c72007-01-29 05:41:34 +00003984#line 1754 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003985 {
3986 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
3987 (yyval.TypeVal).S = Signless;
3988 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003989 break;
3990
3991 case 129:
Reid Spencerb7046c72007-01-29 05:41:34 +00003992#line 1758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003993 { // Named types are also simple types...
Reid Spencerb7046c72007-01-29 05:41:34 +00003994 const Type* tmp = getType((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00003995 (yyval.TypeVal).T = new PATypeHolder(tmp);
3996 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
3997 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003998 break;
3999
4000 case 130:
Reid Spencerb7046c72007-01-29 05:41:34 +00004001#line 1763 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004002 { // Type UpReference
Reid Spencerb7046c72007-01-29 05:41:34 +00004003 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004004 error("Value out of range");
4005 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencerb7046c72007-01-29 05:41:34 +00004006 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Reid Spencer950bf602007-01-26 08:19:09 +00004007 (yyval.TypeVal).T = new PATypeHolder(OT);
4008 (yyval.TypeVal).S = Signless;
4009 UR_OUT("New Upreference!\n");
4010 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004011 break;
4012
4013 case 131:
Reid Spencerb7046c72007-01-29 05:41:34 +00004014#line 1772 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004015 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004016 std::vector<const Type*> Params;
Reid Spencerb7046c72007-01-29 05:41:34 +00004017 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4018 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004019 Params.push_back(I->T->get());
4020 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004021 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004022 FunctionType::ParamAttrsList ParamAttrs;
4023 if (CurFun.LastCC == OldCallingConv::CSRet) {
4024 ParamAttrs.push_back(FunctionType::NoAttributeSet);
4025 ParamAttrs.push_back(FunctionType::StructRetAttribute);
4026 }
Reid Spencer950bf602007-01-26 08:19:09 +00004027 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4028 if (isVarArg) Params.pop_back();
4029
Reid Spencerb7046c72007-01-29 05:41:34 +00004030 (yyval.TypeVal).T = new PATypeHolder(
4031 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).T->get(),Params,isVarArg, ParamAttrs)));
4032 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
4033 delete (yyvsp[-3].TypeVal).T; // Delete the return type handle
4034 delete (yyvsp[-1].TypeList); // Delete the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00004035 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004036 break;
4037
4038 case 132:
Reid Spencerb7046c72007-01-29 05:41:34 +00004039#line 1793 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004040 { // Sized array type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004041 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).T->get(),
4042 (unsigned)(yyvsp[-3].UInt64Val))));
4043 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4044 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004045 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004046 break;
4047
4048 case 133:
Reid Spencerb7046c72007-01-29 05:41:34 +00004049#line 1799 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004050 { // Packed array type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004051 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).T->get();
4052 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004053 error("Unsigned result not equal to signed result");
4054 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4055 error("Elements of a PackedType must be integer or floating point");
Reid Spencerb7046c72007-01-29 05:41:34 +00004056 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004057 error("PackedType length should be a power of 2");
4058 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
Reid Spencerb7046c72007-01-29 05:41:34 +00004059 (unsigned)(yyvsp[-3].UInt64Val))));
4060 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4061 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004062 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004063 break;
4064
4065 case 134:
Reid Spencerb7046c72007-01-29 05:41:34 +00004066#line 1812 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004067 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004068 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004069 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4070 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer950bf602007-01-26 08:19:09 +00004071 Elements.push_back(I->T->get());
4072 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4073 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004074 delete (yyvsp[-1].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004075 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004076 break;
4077
4078 case 135:
Reid Spencerb7046c72007-01-29 05:41:34 +00004079#line 1821 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004080 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004081 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4082 (yyval.TypeVal).S = Signless;
4083 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004084 break;
4085
4086 case 136:
Reid Spencerb7046c72007-01-29 05:41:34 +00004087#line 1825 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004088 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004089 std::vector<const Type*> Elements;
Reid Spencerb7046c72007-01-29 05:41:34 +00004090 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4091 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004092 Elements.push_back(I->T->get());
4093 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004094 }
Reid Spencer950bf602007-01-26 08:19:09 +00004095 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4096 (yyval.TypeVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004097 delete (yyvsp[-2].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004098 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004099 break;
4100
4101 case 137:
Reid Spencerb7046c72007-01-29 05:41:34 +00004102#line 1836 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004103 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004104 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4105 (yyval.TypeVal).S = Signless;
4106 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004107 break;
4108
4109 case 138:
Reid Spencerb7046c72007-01-29 05:41:34 +00004110#line 1840 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004111 { // Pointer type?
Reid Spencerb7046c72007-01-29 05:41:34 +00004112 if ((yyvsp[-1].TypeVal).T->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004113 error("Cannot form a pointer to a basic block");
Reid Spencerb7046c72007-01-29 05:41:34 +00004114 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).T->get())));
4115 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4116 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004117 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004118 break;
4119
4120 case 139:
Reid Spencerb7046c72007-01-29 05:41:34 +00004121#line 1853 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004122 {
Reid Spencer950bf602007-01-26 08:19:09 +00004123 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004124 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004125 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004126 break;
4127
4128 case 140:
Reid Spencerb7046c72007-01-29 05:41:34 +00004129#line 1857 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004130 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004131 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004132 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004133 break;
4134
4135 case 142:
Reid Spencerb7046c72007-01-29 05:41:34 +00004136#line 1865 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004137 {
Reid Spencer950bf602007-01-26 08:19:09 +00004138 PATypeInfo VoidTI;
4139 VoidTI.T = new PATypeHolder(Type::VoidTy);
4140 VoidTI.S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00004141 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
Reid Spencer950bf602007-01-26 08:19:09 +00004142 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004143 break;
4144
4145 case 143:
Reid Spencerb7046c72007-01-29 05:41:34 +00004146#line 1871 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004147 {
Reid Spencer950bf602007-01-26 08:19:09 +00004148 (yyval.TypeList) = new std::list<PATypeInfo>();
4149 PATypeInfo VoidTI;
4150 VoidTI.T = new PATypeHolder(Type::VoidTy);
4151 VoidTI.S = Signless;
4152 (yyval.TypeList)->push_back(VoidTI);
4153 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004154 break;
4155
4156 case 144:
Reid Spencerb7046c72007-01-29 05:41:34 +00004157#line 1878 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004158 {
Reid Spencer950bf602007-01-26 08:19:09 +00004159 (yyval.TypeList) = new std::list<PATypeInfo>();
4160 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004161 break;
4162
4163 case 145:
Reid Spencerb7046c72007-01-29 05:41:34 +00004164#line 1890 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004165 { // Nonempty unsized arr
Reid Spencerb7046c72007-01-29 05:41:34 +00004166 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004167 if (ATy == 0)
4168 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004169 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004170 const Type *ETy = ATy->getElementType();
4171 int NumElements = ATy->getNumElements();
4172
4173 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004174 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004175 error("Type mismatch: constant sized array initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004176 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004177 itostr(NumElements) + "");
4178
4179 // Verify all elements are correct type!
4180 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004181 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4182 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004183 const Type* ValTy = C->getType();
4184 if (ETy != ValTy)
4185 error("Element #" + utostr(i) + " is not of type '" +
4186 ETy->getDescription() +"' as required!\nIt is of type '"+
4187 ValTy->getDescription() + "'");
4188 Elems.push_back(C);
4189 }
4190 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004191 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4192 delete (yyvsp[-3].TypeVal).T;
4193 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004194 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004195 break;
4196
4197 case 146:
Reid Spencerb7046c72007-01-29 05:41:34 +00004198#line 1920 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004199 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004200 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004201 if (ATy == 0)
4202 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004203 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004204 int NumElements = ATy->getNumElements();
4205 if (NumElements != -1 && NumElements != 0)
4206 error("Type mismatch: constant sized array initialized with 0"
4207 " arguments, but has size of " + itostr(NumElements) +"");
4208 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004209 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4210 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004211 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004212 break;
4213
4214 case 147:
Reid Spencerb7046c72007-01-29 05:41:34 +00004215#line 1933 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004216 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004217 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004218 if (ATy == 0)
4219 error("Cannot make array constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004220 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004221 int NumElements = ATy->getNumElements();
4222 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4223 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4224 error("String arrays require type i8, not '" + ETy->getDescription() +
4225 "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004226 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4227 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004228 error("Can't build string constant of size " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004229 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004230 itostr(NumElements) + "");
4231 std::vector<Constant*> Vals;
Reid Spencerb7046c72007-01-29 05:41:34 +00004232 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004233 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencerb7046c72007-01-29 05:41:34 +00004234 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004235 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerb7046c72007-01-29 05:41:34 +00004236 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4237 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004238 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004239 break;
4240
4241 case 148:
Reid Spencerb7046c72007-01-29 05:41:34 +00004242#line 1956 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004243 { // Nonempty unsized arr
Reid Spencerb7046c72007-01-29 05:41:34 +00004244 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004245 if (PTy == 0)
4246 error("Cannot make packed constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004247 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004248 const Type *ETy = PTy->getElementType();
4249 int NumElements = PTy->getNumElements();
4250 // Verify that we have the correct size...
Reid Spencerb7046c72007-01-29 05:41:34 +00004251 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004252 error("Type mismatch: constant sized packed initialized with " +
Reid Spencerb7046c72007-01-29 05:41:34 +00004253 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004254 itostr(NumElements) + "");
4255 // Verify all elements are correct type!
4256 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00004257 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4258 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004259 const Type* ValTy = C->getType();
4260 if (ETy != ValTy)
4261 error("Element #" + utostr(i) + " is not of type '" +
4262 ETy->getDescription() +"' as required!\nIt is of type '"+
4263 ValTy->getDescription() + "'");
4264 Elems.push_back(C);
4265 }
4266 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
Reid Spencerb7046c72007-01-29 05:41:34 +00004267 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4268 delete (yyvsp[-3].TypeVal).T;
4269 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004270 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004271 break;
4272
4273 case 149:
Reid Spencerb7046c72007-01-29 05:41:34 +00004274#line 1984 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004275 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004276 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004277 if (STy == 0)
4278 error("Cannot make struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004279 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4280 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004281 error("Illegal number of initializers for structure type");
4282
4283 // Check to ensure that constants are compatible with the type initializer!
4284 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004285 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4286 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004287 if (C->getType() != STy->getElementType(i))
4288 error("Expected type '" + STy->getElementType(i)->getDescription() +
4289 "' for element #" + utostr(i) + " of structure initializer");
4290 Fields.push_back(C);
4291 }
4292 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004293 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4294 delete (yyvsp[-3].TypeVal).T;
4295 delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004296 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004297 break;
4298
4299 case 150:
Reid Spencerb7046c72007-01-29 05:41:34 +00004300#line 2006 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004301 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004302 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004303 if (STy == 0)
4304 error("Cannot make struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004305 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004306 if (STy->getNumContainedTypes() != 0)
4307 error("Illegal number of initializers for structure type");
4308 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004309 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4310 delete (yyvsp[-2].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004311 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004312 break;
4313
4314 case 151:
Reid Spencerb7046c72007-01-29 05:41:34 +00004315#line 2017 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004316 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004317 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004318 if (STy == 0)
4319 error("Cannot make packed struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004320 (yyvsp[-5].TypeVal).T->get()->getDescription() + "'");
4321 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004322 error("Illegal number of initializers for packed structure type");
4323
4324 // Check to ensure that constants are compatible with the type initializer!
4325 std::vector<Constant*> Fields;
Reid Spencerb7046c72007-01-29 05:41:34 +00004326 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4327 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004328 if (C->getType() != STy->getElementType(i))
4329 error("Expected type '" + STy->getElementType(i)->getDescription() +
4330 "' for element #" + utostr(i) + " of packed struct initializer");
4331 Fields.push_back(C);
4332 }
4333 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerb7046c72007-01-29 05:41:34 +00004334 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4335 delete (yyvsp[-5].TypeVal).T;
4336 delete (yyvsp[-2].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004337 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004338 break;
4339
4340 case 152:
Reid Spencerb7046c72007-01-29 05:41:34 +00004341#line 2039 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004342 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004343 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004344 if (STy == 0)
4345 error("Cannot make packed struct constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004346 (yyvsp[-4].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004347 if (STy->getNumContainedTypes() != 0)
4348 error("Illegal number of initializers for packed structure type");
4349 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerb7046c72007-01-29 05:41:34 +00004350 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4351 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004352 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004353 break;
4354
4355 case 153:
Reid Spencerb7046c72007-01-29 05:41:34 +00004356#line 2050 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004357 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004358 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004359 if (PTy == 0)
4360 error("Cannot make null pointer constant with type: '" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004361 (yyvsp[-1].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004362 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00004363 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4364 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004365 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004366 break;
4367
4368 case 154:
Reid Spencerb7046c72007-01-29 05:41:34 +00004369#line 2059 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004370 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004371 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).T->get());
4372 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4373 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004374 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004375 break;
4376
4377 case 155:
Reid Spencerb7046c72007-01-29 05:41:34 +00004378#line 2064 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004379 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004380 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004381 if (Ty == 0)
4382 error("Global const reference must be a pointer type, not" +
Reid Spencerb7046c72007-01-29 05:41:34 +00004383 (yyvsp[-1].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004384
4385 // ConstExprs can exist in the body of a function, thus creating
4386 // GlobalValues whenever they refer to a variable. Because we are in
4387 // the context of a function, getExistingValue will search the functions
4388 // symbol table instead of the module symbol table for the global symbol,
4389 // which throws things all off. To get around this, we just tell
4390 // getExistingValue that we are at global scope here.
4391 //
4392 Function *SavedCurFn = CurFun.CurrentFunction;
4393 CurFun.CurrentFunction = 0;
Reid Spencerb7046c72007-01-29 05:41:34 +00004394 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004395 CurFun.CurrentFunction = SavedCurFn;
4396
4397 // If this is an initializer for a constant pointer, which is referencing a
4398 // (currently) undefined variable, create a stub now that shall be replaced
4399 // in the future with the right type of variable.
4400 //
4401 if (V == 0) {
4402 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4403 const PointerType *PT = cast<PointerType>(Ty);
4404
4405 // First check to see if the forward references value is already created!
4406 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencerb7046c72007-01-29 05:41:34 +00004407 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004408
4409 if (I != CurModule.GlobalRefs.end()) {
4410 V = I->second; // Placeholder already exists, use it...
Reid Spencerb7046c72007-01-29 05:41:34 +00004411 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004412 } else {
4413 std::string Name;
Reid Spencerb7046c72007-01-29 05:41:34 +00004414 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004415
4416 // Create the forward referenced global.
4417 GlobalValue *GV;
4418 if (const FunctionType *FTy =
4419 dyn_cast<FunctionType>(PT->getElementType())) {
4420 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4421 CurModule.CurrentModule);
4422 } else {
4423 GV = new GlobalVariable(PT->getElementType(), false,
4424 GlobalValue::ExternalLinkage, 0,
4425 Name, CurModule.CurrentModule);
4426 }
4427
4428 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencerb7046c72007-01-29 05:41:34 +00004429 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004430 V = GV;
4431 }
4432 }
4433 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerb7046c72007-01-29 05:41:34 +00004434 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4435 delete (yyvsp[-1].TypeVal).T; // Free the type handle
Reid Spencer950bf602007-01-26 08:19:09 +00004436 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004437 break;
4438
4439 case 156:
Reid Spencerb7046c72007-01-29 05:41:34 +00004440#line 2122 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004441 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004442 if ((yyvsp[-1].TypeVal).T->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004443 error("Mismatched types for constant expression");
Reid Spencerb7046c72007-01-29 05:41:34 +00004444 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4445 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4446 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004447 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004448 break;
4449
4450 case 157:
Reid Spencerb7046c72007-01-29 05:41:34 +00004451#line 2129 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004452 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004453 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004454 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4455 error("Cannot create a null initialized value of this type");
4456 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00004457 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4458 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004459 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004460 break;
4461
4462 case 158:
Reid Spencerb7046c72007-01-29 05:41:34 +00004463#line 2137 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004464 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004465 const Type *Ty = (yyvsp[-1].PrimType).T;
4466 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004467 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004468 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004469 (yyval.ConstVal).S = Signed;
4470 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004471 break;
4472
4473 case 159:
Reid Spencerb7046c72007-01-29 05:41:34 +00004474#line 2144 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004475 { // integral constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004476 const Type *Ty = (yyvsp[-1].PrimType).T;
4477 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004478 error("Constant value doesn't fit in type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004479 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004480 (yyval.ConstVal).S = Unsigned;
4481 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004482 break;
4483
4484 case 160:
Reid Spencerb7046c72007-01-29 05:41:34 +00004485#line 2151 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004486 { // Boolean constants
4487 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4488 (yyval.ConstVal).S = Unsigned;
4489 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004490 break;
4491
4492 case 161:
Reid Spencerb7046c72007-01-29 05:41:34 +00004493#line 2155 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004494 { // Boolean constants
4495 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4496 (yyval.ConstVal).S = Unsigned;
4497 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004498 break;
4499
4500 case 162:
Reid Spencerb7046c72007-01-29 05:41:34 +00004501#line 2159 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004502 { // Float & Double constants
Reid Spencerb7046c72007-01-29 05:41:34 +00004503 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004504 error("Floating point constant invalid for type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004505 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004506 (yyval.ConstVal).S = Signless;
4507 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004508 break;
4509
4510 case 163:
Reid Spencerb7046c72007-01-29 05:41:34 +00004511#line 2168 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004512 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004513 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4514 const Type* DstTy = (yyvsp[-1].TypeVal).T->get();
4515 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4516 Signedness DstSign = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004517 if (!SrcTy->isFirstClassType())
4518 error("cast constant expression from a non-primitive type: '" +
4519 SrcTy->getDescription() + "'");
4520 if (!DstTy->isFirstClassType())
4521 error("cast constant expression to a non-primitive type: '" +
4522 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00004523 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencer950bf602007-01-26 08:19:09 +00004524 (yyval.ConstVal).S = DstSign;
Reid Spencerb7046c72007-01-29 05:41:34 +00004525 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004526 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004527 break;
4528
4529 case 164:
Reid Spencerb7046c72007-01-29 05:41:34 +00004530#line 2183 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004531 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004532 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004533 if (!isa<PointerType>(Ty))
4534 error("GetElementPtr requires a pointer operand");
4535
4536 std::vector<Value*> VIndices;
4537 std::vector<Constant*> CIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00004538 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004539
Reid Spencerb7046c72007-01-29 05:41:34 +00004540 delete (yyvsp[-1].ValueList);
4541 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004542 (yyval.ConstVal).S = Signless;
4543 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004544 break;
4545
4546 case 165:
Reid Spencerb7046c72007-01-29 05:41:34 +00004547#line 2196 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004548 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004549 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4550 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004551 error("Select condition must be bool type");
Reid Spencerb7046c72007-01-29 05:41:34 +00004552 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004553 error("Select operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004554 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004555 (yyval.ConstVal).S = Unsigned;
4556 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004557 break;
4558
4559 case 166:
Reid Spencerb7046c72007-01-29 05:41:34 +00004560#line 2205 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004561 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004562 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4563 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004564 error("Binary operator types must match");
4565 // First, make sure we're dealing with the right opcode by upgrading from
4566 // obsolete versions.
Reid Spencerb7046c72007-01-29 05:41:34 +00004567 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004568
4569 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4570 // To retain backward compatibility with these early compilers, we emit a
4571 // cast to the appropriate integer type automatically if we are in the
4572 // broken case. See PR424 for more information.
4573 if (!isa<PointerType>(Ty)) {
Reid Spencerb7046c72007-01-29 05:41:34 +00004574 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004575 } else {
4576 const Type *IntPtrTy = 0;
4577 switch (CurModule.CurrentModule->getPointerSize()) {
4578 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4579 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4580 default: error("invalid pointer binary constant expr");
4581 }
4582 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
Reid Spencerb7046c72007-01-29 05:41:34 +00004583 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4584 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
Reid Spencer950bf602007-01-26 08:19:09 +00004585 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4586 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004587 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004588 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004589 break;
4590
4591 case 167:
Reid Spencerb7046c72007-01-29 05:41:34 +00004592#line 2233 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004593 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004594 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4595 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004596 error("Logical operator types must match");
4597 if (!Ty->isInteger()) {
4598 if (!isa<PackedType>(Ty) ||
4599 !cast<PackedType>(Ty)->getElementType()->isInteger())
4600 error("Logical operator requires integer operands");
4601 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004602 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4603 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4604 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004605 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004606 break;
4607
4608 case 168:
Reid Spencerb7046c72007-01-29 05:41:34 +00004609#line 2246 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004610 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004611 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4612 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004613 error("setcc operand types must match");
4614 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00004615 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4616 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004617 (yyval.ConstVal).S = Unsigned;
4618 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004619 break;
4620
4621 case 169:
Reid Spencerb7046c72007-01-29 05:41:34 +00004622#line 2255 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004623 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004624 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004625 error("icmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004626 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004627 (yyval.ConstVal).S = Unsigned;
4628 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004629 break;
4630
4631 case 170:
Reid Spencerb7046c72007-01-29 05:41:34 +00004632#line 2261 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004633 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004634 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004635 error("fcmp operand types must match");
Reid Spencerb7046c72007-01-29 05:41:34 +00004636 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004637 (yyval.ConstVal).S = Unsigned;
4638 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004639 break;
4640
4641 case 171:
Reid Spencerb7046c72007-01-29 05:41:34 +00004642#line 2267 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004643 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004644 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4645 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004646 error("Shift count for shift constant must be unsigned byte");
Reid Spencerb7046c72007-01-29 05:41:34 +00004647 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004648 error("Shift constant expression requires integer operand");
Reid Spencerb7046c72007-01-29 05:41:34 +00004649 (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4650 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004651 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004652 break;
4653
4654 case 172:
Reid Spencerb7046c72007-01-29 05:41:34 +00004655#line 2276 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004656 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004657 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004658 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004659 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4660 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004661 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004662 break;
4663
4664 case 173:
Reid Spencerb7046c72007-01-29 05:41:34 +00004665#line 2282 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004666 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004667 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004668 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004669 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4670 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004671 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004672 break;
4673
4674 case 174:
Reid Spencerb7046c72007-01-29 05:41:34 +00004675#line 2288 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004676 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004677 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004678 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00004679 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4680 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004681 ;}
4682 break;
4683
4684 case 175:
Reid Spencerb7046c72007-01-29 05:41:34 +00004685#line 2299 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4686 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004687 break;
4688
4689 case 176:
Reid Spencerb7046c72007-01-29 05:41:34 +00004690#line 2300 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004691 {
4692 (yyval.ConstVector) = new std::vector<ConstInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00004693 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004694 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004695 break;
4696
4697 case 177:
Reid Spencerb7046c72007-01-29 05:41:34 +00004698#line 2309 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004699 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004700 break;
4701
4702 case 178:
Reid Spencerb7046c72007-01-29 05:41:34 +00004703#line 2310 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004704 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004705 break;
4706
4707 case 179:
Reid Spencerb7046c72007-01-29 05:41:34 +00004708#line 2322 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004709 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004710 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004711 CurModule.ModuleDone();
4712 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004713 break;
4714
4715 case 180:
Reid Spencerb7046c72007-01-29 05:41:34 +00004716#line 2331 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4717 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004718 break;
4719
4720 case 181:
Reid Spencerb7046c72007-01-29 05:41:34 +00004721#line 2332 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4722 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004723 break;
4724
4725 case 182:
Reid Spencerb7046c72007-01-29 05:41:34 +00004726#line 2333 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4727 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004728 break;
4729
4730 case 183:
Reid Spencerb7046c72007-01-29 05:41:34 +00004731#line 2334 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4732 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004733 break;
4734
4735 case 184:
Reid Spencerb7046c72007-01-29 05:41:34 +00004736#line 2335 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004737 {
4738 (yyval.ModuleVal) = CurModule.CurrentModule;
4739 // Emit an error if there are any unresolved types left.
4740 if (!CurModule.LateResolveTypes.empty()) {
4741 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4742 if (DID.Type == ValID::NameVal) {
4743 error("Reference to an undefined type: '"+DID.getName() + "'");
4744 } else {
4745 error("Reference to an undefined type: #" + itostr(DID.Num));
4746 }
4747 }
4748 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004749 break;
4750
4751 case 185:
Reid Spencerb7046c72007-01-29 05:41:34 +00004752#line 2351 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004753 {
Reid Spencer950bf602007-01-26 08:19:09 +00004754 // Eagerly resolve types. This is not an optimization, this is a
4755 // requirement that is due to the fact that we could have this:
4756 //
4757 // %list = type { %list * }
4758 // %list = type { %list * } ; repeated type decl
4759 //
4760 // If types are not resolved eagerly, then the two types will not be
4761 // determined to be the same type!
4762 //
Reid Spencerb7046c72007-01-29 05:41:34 +00004763 const Type* Ty = (yyvsp[0].TypeVal).T->get();
4764 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004765
Reid Spencerb7046c72007-01-29 05:41:34 +00004766 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer950bf602007-01-26 08:19:09 +00004767 // If this is a named type that is not a redefinition, add it to the slot
4768 // table.
4769 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004770 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004771 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004772 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004773 break;
4774
4775 case 186:
Reid Spencerb7046c72007-01-29 05:41:34 +00004776#line 2371 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004777 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004778 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004779 break;
4780
4781 case 187:
Reid Spencerb7046c72007-01-29 05:41:34 +00004782#line 2373 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004783 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004784 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004785 break;
4786
4787 case 188:
Reid Spencerb7046c72007-01-29 05:41:34 +00004788#line 2375 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004789 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004790 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00004791 error("Global value initializer is not a constant");
Reid Spencerb7046c72007-01-29 05:41:34 +00004792 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004793 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004794 break;
4795
4796 case 189:
Reid Spencerb7046c72007-01-29 05:41:34 +00004797#line 2379 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004798 {
Reid Spencer950bf602007-01-26 08:19:09 +00004799 CurGV = 0;
4800 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004801 break;
4802
4803 case 190:
Reid Spencerb7046c72007-01-29 05:41:34 +00004804#line 2382 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004805 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004806 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4807 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4808 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004809 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004810 break;
4811
4812 case 191:
Reid Spencerb7046c72007-01-29 05:41:34 +00004813#line 2386 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004814 {
Reid Spencer950bf602007-01-26 08:19:09 +00004815 CurGV = 0;
4816 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004817 break;
4818
4819 case 192:
Reid Spencerb7046c72007-01-29 05:41:34 +00004820#line 2389 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004821 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004822 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4823 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4824 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004825 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004826 break;
4827
4828 case 193:
Reid Spencerb7046c72007-01-29 05:41:34 +00004829#line 2393 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004830 {
Reid Spencer950bf602007-01-26 08:19:09 +00004831 CurGV = 0;
4832 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004833 break;
4834
4835 case 194:
Reid Spencerb7046c72007-01-29 05:41:34 +00004836#line 2396 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004837 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004838 const Type *Ty = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004839 CurGV =
Reid Spencerb7046c72007-01-29 05:41:34 +00004840 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4841 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004842 ;}
4843 break;
4844
4845 case 195:
Reid Spencerb7046c72007-01-29 05:41:34 +00004846#line 2401 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004847 {
4848 CurGV = 0;
4849 ;}
4850 break;
4851
4852 case 196:
Reid Spencerb7046c72007-01-29 05:41:34 +00004853#line 2404 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004854 {
Reid Spencer950bf602007-01-26 08:19:09 +00004855 ;}
4856 break;
4857
4858 case 197:
Reid Spencerb7046c72007-01-29 05:41:34 +00004859#line 2406 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004860 {
4861 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004862 break;
4863
4864 case 198:
Reid Spencerb7046c72007-01-29 05:41:34 +00004865#line 2408 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004866 {
4867 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004868 break;
4869
4870 case 199:
Reid Spencerb7046c72007-01-29 05:41:34 +00004871#line 2413 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004872 {
Reid Spencer950bf602007-01-26 08:19:09 +00004873 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencerb7046c72007-01-29 05:41:34 +00004874 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4875 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4876 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004877
4878 if (AsmSoFar.empty())
4879 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4880 else
4881 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4882 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004883 break;
4884
4885 case 200:
Reid Spencerb7046c72007-01-29 05:41:34 +00004886#line 2427 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004887 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004888 break;
4889
4890 case 201:
Reid Spencerb7046c72007-01-29 05:41:34 +00004891#line 2428 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004892 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004893 break;
4894
4895 case 202:
Reid Spencerb7046c72007-01-29 05:41:34 +00004896#line 2432 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004897 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004898 CurModule.setEndianness((yyvsp[0].Endianness));
Reid Spencer950bf602007-01-26 08:19:09 +00004899 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004900 break;
4901
4902 case 203:
Reid Spencerb7046c72007-01-29 05:41:34 +00004903#line 2435 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004904 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004905 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00004906 CurModule.setPointerSize(Module::Pointer32);
Reid Spencerb7046c72007-01-29 05:41:34 +00004907 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00004908 CurModule.setPointerSize(Module::Pointer64);
4909 else
Reid Spencerb7046c72007-01-29 05:41:34 +00004910 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004911 ;}
4912 break;
4913
4914 case 204:
Reid Spencerb7046c72007-01-29 05:41:34 +00004915#line 2443 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004916 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004917 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4918 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004919 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004920 break;
4921
4922 case 205:
Reid Spencerb7046c72007-01-29 05:41:34 +00004923#line 2447 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004924 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004925 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4926 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004927 ;}
4928 break;
4929
4930 case 207:
Reid Spencerb7046c72007-01-29 05:41:34 +00004931#line 2458 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004932 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004933 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4934 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004935 ;}
4936 break;
4937
4938 case 208:
Reid Spencerb7046c72007-01-29 05:41:34 +00004939#line 2462 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004940 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004941 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4942 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004943 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004944 break;
4945
4946 case 209:
Reid Spencerb7046c72007-01-29 05:41:34 +00004947#line 2466 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004948 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004949 break;
4950
Reid Spencerc4d96252007-01-13 00:03:30 +00004951 case 213:
Reid Spencerb7046c72007-01-29 05:41:34 +00004952#line 2479 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004953 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004954 break;
4955
Reid Spencer319a7302007-01-05 17:20:02 +00004956 case 214:
Reid Spencerb7046c72007-01-29 05:41:34 +00004957#line 2483 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004958 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004959 if ((yyvsp[-1].TypeVal).T->get() == Type::VoidTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004960 error("void typed arguments are invalid");
Reid Spencerb7046c72007-01-29 05:41:34 +00004961 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004962 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004963 break;
4964
4965 case 215:
Reid Spencerb7046c72007-01-29 05:41:34 +00004966#line 2491 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004967 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004968 (yyval.ArgList) = (yyvsp[-2].ArgList);
4969 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4970 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004971 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004972 break;
4973
4974 case 216:
Reid Spencerb7046c72007-01-29 05:41:34 +00004975#line 2496 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004976 {
4977 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00004978 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4979 delete (yyvsp[0].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004980 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004981 break;
4982
4983 case 217:
Reid Spencerb7046c72007-01-29 05:41:34 +00004984#line 2504 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4985 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004986 break;
4987
4988 case 218:
Reid Spencerb7046c72007-01-29 05:41:34 +00004989#line 2505 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004990 {
Reid Spencerb7046c72007-01-29 05:41:34 +00004991 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer950bf602007-01-26 08:19:09 +00004992 PATypeInfo VoidTI;
4993 VoidTI.T = new PATypeHolder(Type::VoidTy);
4994 VoidTI.S = Signless;
4995 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4996 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004997 break;
4998
4999 case 219:
Reid Spencerb7046c72007-01-29 05:41:34 +00005000#line 2512 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005001 {
5002 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5003 PATypeInfo VoidTI;
5004 VoidTI.T = new PATypeHolder(Type::VoidTy);
5005 VoidTI.S = Signless;
5006 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5007 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005008 break;
5009
5010 case 220:
Reid Spencerb7046c72007-01-29 05:41:34 +00005011#line 2519 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005012 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005013 break;
5014
5015 case 221:
Reid Spencerb7046c72007-01-29 05:41:34 +00005016#line 2523 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005017 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005018 UnEscapeLexed((yyvsp[-5].StrVal));
5019 std::string FunctionName((yyvsp[-5].StrVal));
5020 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer950bf602007-01-26 08:19:09 +00005021
Reid Spencerb7046c72007-01-29 05:41:34 +00005022 const Type* RetTy = (yyvsp[-6].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005023
5024 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5025 error("LLVM functions cannot return aggregate types");
5026
5027 std::vector<const Type*> ParamTypeList;
5028
5029 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5030 // i8*. We check here for those names and override the parameter list
5031 // types to ensure the prototype is correct.
5032 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5033 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5034 } else if (FunctionName == "llvm.va_copy") {
5035 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5036 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencerb7046c72007-01-29 05:41:34 +00005037 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005038 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencerb7046c72007-01-29 05:41:34 +00005039 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005040 const Type *Ty = I->first.T->get();
5041 ParamTypeList.push_back(Ty);
5042 }
5043 }
5044
5045 bool isVarArg =
5046 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5047 if (isVarArg) ParamTypeList.pop_back();
5048
Reid Spencerb7046c72007-01-29 05:41:34 +00005049 // Convert the CSRet calling convention into the corresponding parameter
5050 // attribute.
5051 FunctionType::ParamAttrsList ParamAttrs;
5052 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
5053 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5054 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5055 }
5056
5057 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg,
5058 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005059 const PointerType *PFT = PointerType::get(FT);
Reid Spencerb7046c72007-01-29 05:41:34 +00005060 delete (yyvsp[-6].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005061
5062 ValID ID;
5063 if (!FunctionName.empty()) {
5064 ID = ValID::create((char*)FunctionName.c_str());
5065 } else {
5066 ID = ValID::create((int)CurModule.Values[PFT].size());
5067 }
5068
5069 Function *Fn = 0;
5070 // See if this function was forward referenced. If so, recycle the object.
5071 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5072 // Move the function to the end of the list, from whereever it was
5073 // previously inserted.
5074 Fn = cast<Function>(FWRef);
5075 CurModule.CurrentModule->getFunctionList().remove(Fn);
5076 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5077 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5078 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5079 // If this is the case, either we need to be a forward decl, or it needs
5080 // to be.
5081 if (!CurFun.isDeclare && !Fn->isExternal())
5082 error("Redefinition of function '" + FunctionName + "'");
5083
5084 // Make sure to strip off any argument names so we can't get conflicts.
5085 if (Fn->isExternal())
5086 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5087 AI != AE; ++AI)
5088 AI->setName("");
5089 } else { // Not already defined?
5090 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5091 CurModule.CurrentModule);
5092
5093 InsertValue(Fn, CurModule.Values);
5094 }
5095
5096 CurFun.FunctionStart(Fn);
5097
5098 if (CurFun.isDeclare) {
5099 // If we have declaration, always overwrite linkage. This will allow us
5100 // to correctly handle cases, when pointer to function is passed as
5101 // argument to another function.
5102 Fn->setLinkage(CurFun.Linkage);
5103 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005104 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5105 Fn->setAlignment((yyvsp[0].UIntVal));
5106 if ((yyvsp[-1].StrVal)) {
5107 Fn->setSection((yyvsp[-1].StrVal));
5108 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005109 }
5110
5111 // Add all of the arguments we parsed to the function...
Reid Spencerb7046c72007-01-29 05:41:34 +00005112 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005113 if (isVarArg) { // Nuke the last entry
Reid Spencerb7046c72007-01-29 05:41:34 +00005114 assert((yyvsp[-3].ArgList)->back().first.T->get() == Type::VoidTy &&
5115 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5116 delete (yyvsp[-3].ArgList)->back().first.T;
5117 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005118 }
5119 Function::arg_iterator ArgIt = Fn->arg_begin();
5120 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencerb7046c72007-01-29 05:41:34 +00005121 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I, ++ArgIt) {
Reid Spencer950bf602007-01-26 08:19:09 +00005122 delete I->first.T; // Delete the typeholder...
5123 setValueName(ArgIt, I->second); // Insert arg into symtab...
5124 InsertValue(ArgIt);
5125 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005126 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005127 }
5128 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005129 break;
5130
5131 case 224:
Reid Spencerb7046c72007-01-29 05:41:34 +00005132#line 2642 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005133 {
5134 (yyval.FunctionVal) = CurFun.CurrentFunction;
5135
5136 // Make sure that we keep track of the linkage type even if there was a
5137 // previous "declare".
Reid Spencerb7046c72007-01-29 05:41:34 +00005138 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Reid Spencer950bf602007-01-26 08:19:09 +00005139 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005140 break;
5141
5142 case 227:
Reid Spencerb7046c72007-01-29 05:41:34 +00005143#line 2656 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005144 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005145 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005146 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005147 break;
5148
5149 case 229:
Reid Spencerb7046c72007-01-29 05:41:34 +00005150#line 2662 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005151 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5152 break;
5153
5154 case 230:
Reid Spencerb7046c72007-01-29 05:41:34 +00005155#line 2663 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005156 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5157 break;
5158
5159 case 231:
Reid Spencerb7046c72007-01-29 05:41:34 +00005160#line 2667 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005161 { CurFun.isDeclare = true; ;}
5162 break;
5163
5164 case 232:
Reid Spencerb7046c72007-01-29 05:41:34 +00005165#line 2667 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005166 {
5167 (yyval.FunctionVal) = CurFun.CurrentFunction;
5168 CurFun.FunctionDone();
5169
5170 ;}
5171 break;
5172
5173 case 233:
Reid Spencerb7046c72007-01-29 05:41:34 +00005174#line 2679 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005175 { (yyval.BoolVal) = false; ;}
5176 break;
5177
5178 case 234:
Reid Spencerb7046c72007-01-29 05:41:34 +00005179#line 2680 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005180 { (yyval.BoolVal) = true; ;}
5181 break;
5182
5183 case 235:
Reid Spencerb7046c72007-01-29 05:41:34 +00005184#line 2685 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5185 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005186 break;
5187
5188 case 236:
Reid Spencerb7046c72007-01-29 05:41:34 +00005189#line 2686 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5190 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005191 break;
5192
5193 case 237:
Reid Spencerb7046c72007-01-29 05:41:34 +00005194#line 2687 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5195 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005196 break;
5197
5198 case 238:
Reid Spencerb7046c72007-01-29 05:41:34 +00005199#line 2688 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005200 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005201 break;
5202
Reid Spencerc4d96252007-01-13 00:03:30 +00005203 case 239:
Reid Spencerb7046c72007-01-29 05:41:34 +00005204#line 2689 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005205 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5206 break;
5207
5208 case 240:
Reid Spencerb7046c72007-01-29 05:41:34 +00005209#line 2690 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005210 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005211 break;
5212
Reid Spencerc4d96252007-01-13 00:03:30 +00005213 case 241:
Reid Spencerb7046c72007-01-29 05:41:34 +00005214#line 2691 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005215 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5216 break;
5217
5218 case 242:
Reid Spencerb7046c72007-01-29 05:41:34 +00005219#line 2692 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005220 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5221 break;
5222
5223 case 243:
Reid Spencerb7046c72007-01-29 05:41:34 +00005224#line 2693 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005225 { // Nonempty unsized packed vector
Reid Spencerb7046c72007-01-29 05:41:34 +00005226 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5227 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer950bf602007-01-26 08:19:09 +00005228 PackedType* pt = PackedType::get(ETy, NumElements);
5229 PATypeHolder* PTy = new PATypeHolder(
5230 HandleUpRefs(PackedType::get(ETy, NumElements)));
5231
5232 // Verify all elements are correct type!
5233 std::vector<Constant*> Elems;
Reid Spencerb7046c72007-01-29 05:41:34 +00005234 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5235 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005236 const Type *CTy = C->getType();
5237 if (ETy != CTy)
5238 error("Element #" + utostr(i) + " is not of type '" +
5239 ETy->getDescription() +"' as required!\nIt is of type '" +
5240 CTy->getDescription() + "'");
5241 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005242 }
Reid Spencer950bf602007-01-26 08:19:09 +00005243 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
Reid Spencerb7046c72007-01-29 05:41:34 +00005244 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00005245 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005246 break;
5247
Reid Spencerc4d96252007-01-13 00:03:30 +00005248 case 244:
Reid Spencerb7046c72007-01-29 05:41:34 +00005249#line 2714 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005250 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005251 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00005252 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005253 break;
5254
Reid Spencerc4d96252007-01-13 00:03:30 +00005255 case 245:
Reid Spencerb7046c72007-01-29 05:41:34 +00005256#line 2717 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005257 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005258 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5259 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5260 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5261 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5262 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5263 free((yyvsp[-2].StrVal));
5264 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005265 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005266 break;
5267
Reid Spencerc4d96252007-01-13 00:03:30 +00005268 case 246:
Reid Spencerb7046c72007-01-29 05:41:34 +00005269#line 2732 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5270 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005271 break;
5272
Reid Spencer319a7302007-01-05 17:20:02 +00005273 case 247:
Reid Spencerb7046c72007-01-29 05:41:34 +00005274#line 2733 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5275 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005276 break;
5277
5278 case 250:
Reid Spencerb7046c72007-01-29 05:41:34 +00005279#line 2746 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005280 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005281 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5282 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5283 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5284 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005285 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005286 break;
5287
Reid Spencerc4d96252007-01-13 00:03:30 +00005288 case 251:
Reid Spencerb7046c72007-01-29 05:41:34 +00005289#line 2755 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005290 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005291 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005292 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005293 break;
5294
Reid Spencerc4d96252007-01-13 00:03:30 +00005295 case 252:
Reid Spencerb7046c72007-01-29 05:41:34 +00005296#line 2758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005297 { // Do not allow functions with 0 basic blocks
Reid Spencerb7046c72007-01-29 05:41:34 +00005298 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005299 ;}
5300 break;
5301
5302 case 253:
Reid Spencerb7046c72007-01-29 05:41:34 +00005303#line 2767 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005304 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005305 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5306 InsertValue((yyvsp[0].TermInstVal));
5307 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5308 InsertValue((yyvsp[-2].BasicBlockVal));
5309 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005310 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005311 break;
5312
Reid Spencerc4d96252007-01-13 00:03:30 +00005313 case 254:
Reid Spencerb7046c72007-01-29 05:41:34 +00005314#line 2777 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005315 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005316 if ((yyvsp[0].InstVal).I)
5317 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5318 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005319 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005320 break;
5321
Reid Spencerc4d96252007-01-13 00:03:30 +00005322 case 255:
Reid Spencerb7046c72007-01-29 05:41:34 +00005323#line 2782 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005324 {
5325 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5326 // Make sure to move the basic block to the correct location in the
5327 // function, instead of leaving it inserted wherever it was first
5328 // referenced.
5329 Function::BasicBlockListType &BBL =
5330 CurFun.CurrentFunction->getBasicBlockList();
5331 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5332 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005333 break;
5334
Reid Spencerc4d96252007-01-13 00:03:30 +00005335 case 256:
Reid Spencerb7046c72007-01-29 05:41:34 +00005336#line 2791 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005337 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005338 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005339 // Make sure to move the basic block to the correct location in the
5340 // function, instead of leaving it inserted wherever it was first
5341 // referenced.
5342 Function::BasicBlockListType &BBL =
5343 CurFun.CurrentFunction->getBasicBlockList();
5344 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5345 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005346 break;
5347
Reid Spencerc4d96252007-01-13 00:03:30 +00005348 case 259:
Reid Spencerb7046c72007-01-29 05:41:34 +00005349#line 2805 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005350 { // Return with a result...
Reid Spencerb7046c72007-01-29 05:41:34 +00005351 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005352 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005353 break;
5354
Reid Spencerc4d96252007-01-13 00:03:30 +00005355 case 260:
Reid Spencerb7046c72007-01-29 05:41:34 +00005356#line 2808 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005357 { // Return with no result...
5358 (yyval.TermInstVal) = new ReturnInst();
5359 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005360 break;
5361
Reid Spencerc4d96252007-01-13 00:03:30 +00005362 case 261:
Reid Spencerb7046c72007-01-29 05:41:34 +00005363#line 2811 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005364 { // Unconditional Branch...
Reid Spencerb7046c72007-01-29 05:41:34 +00005365 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005366 (yyval.TermInstVal) = new BranchInst(tmpBB);
5367 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005368 break;
5369
Reid Spencer319a7302007-01-05 17:20:02 +00005370 case 262:
Reid Spencerb7046c72007-01-29 05:41:34 +00005371#line 2815 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005372 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005373 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5374 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5375 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005376 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5377 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005378 break;
5379
5380 case 263:
Reid Spencerb7046c72007-01-29 05:41:34 +00005381#line 2821 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005382 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005383 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5384 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5385 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencer950bf602007-01-26 08:19:09 +00005386 (yyval.TermInstVal) = S;
Reid Spencerb7046c72007-01-29 05:41:34 +00005387 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5388 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005389 for (; I != E; ++I) {
5390 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5391 S->addCase(CI, I->second);
5392 else
5393 error("Switch case is constant, but not a simple integer");
5394 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005395 delete (yyvsp[-1].JumpTable);
Reid Spencer950bf602007-01-26 08:19:09 +00005396 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005397 break;
5398
5399 case 264:
Reid Spencerb7046c72007-01-29 05:41:34 +00005400#line 2836 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005401 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005402 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5403 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005404 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5405 (yyval.TermInstVal) = S;
5406 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005407 break;
5408
Reid Spencerc4d96252007-01-13 00:03:30 +00005409 case 265:
Reid Spencerb7046c72007-01-29 05:41:34 +00005410#line 2843 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005411 {
Reid Spencer950bf602007-01-26 08:19:09 +00005412 const PointerType *PFTy;
5413 const FunctionType *Ty;
5414
Reid Spencerb7046c72007-01-29 05:41:34 +00005415 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005416 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5417 // Pull out the types of all of the arguments...
5418 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005419 if ((yyvsp[-7].ValueList)) {
5420 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005421 I != E; ++I)
5422 ParamTypes.push_back((*I).V->getType());
5423 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005424 FunctionType::ParamAttrsList ParamAttrs;
5425 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
5426 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5427 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5428 }
Reid Spencer950bf602007-01-26 08:19:09 +00005429 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5430 if (isVarArg) ParamTypes.pop_back();
Reid Spencerb7046c72007-01-29 05:41:34 +00005431 Ty = FunctionType::get((yyvsp[-10].TypeVal).T->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005432 PFTy = PointerType::get(Ty);
5433 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005434 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5435 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5436 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005437
5438 // Create the call node...
Reid Spencerb7046c72007-01-29 05:41:34 +00005439 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005440 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5441 } else { // Has arguments?
5442 // Loop through FunctionType's arguments and ensure they are specified
5443 // correctly!
5444 //
5445 FunctionType::param_iterator I = Ty->param_begin();
5446 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00005447 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005448
5449 std::vector<Value*> Args;
5450 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5451 if ((*ArgI).V->getType() != *I)
5452 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5453 (*I)->getDescription() + "'");
5454 Args.push_back((*ArgI).V);
5455 }
5456
5457 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5458 error("Invalid number of parameters detected");
5459
5460 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5461 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005462 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
5463 delete (yyvsp[-10].TypeVal).T;
5464 delete (yyvsp[-7].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005465 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005466 break;
5467
Reid Spencerc4d96252007-01-13 00:03:30 +00005468 case 266:
Reid Spencerb7046c72007-01-29 05:41:34 +00005469#line 2898 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005470 {
Reid Spencer950bf602007-01-26 08:19:09 +00005471 (yyval.TermInstVal) = new UnwindInst();
5472 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005473 break;
5474
Reid Spencerc4d96252007-01-13 00:03:30 +00005475 case 267:
Reid Spencerb7046c72007-01-29 05:41:34 +00005476#line 2901 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005477 {
5478 (yyval.TermInstVal) = new UnreachableInst();
5479 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005480 break;
5481
Reid Spencerc4d96252007-01-13 00:03:30 +00005482 case 268:
Reid Spencerb7046c72007-01-29 05:41:34 +00005483#line 2907 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005484 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005485 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5486 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005487
5488 if (V == 0)
5489 error("May only switch on a constant pool value");
5490
Reid Spencerb7046c72007-01-29 05:41:34 +00005491 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005492 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5493 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005494 break;
5495
Reid Spencerc4d96252007-01-13 00:03:30 +00005496 case 269:
Reid Spencerb7046c72007-01-29 05:41:34 +00005497#line 2917 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005498 {
Reid Spencer950bf602007-01-26 08:19:09 +00005499 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005500 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005501
5502 if (V == 0)
5503 error("May only switch on a constant pool value");
5504
Reid Spencerb7046c72007-01-29 05:41:34 +00005505 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005506 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5507 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005508 break;
5509
Reid Spencerc4d96252007-01-13 00:03:30 +00005510 case 270:
Reid Spencerb7046c72007-01-29 05:41:34 +00005511#line 2930 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005512 {
Reid Spencer950bf602007-01-26 08:19:09 +00005513 bool omit = false;
Reid Spencerb7046c72007-01-29 05:41:34 +00005514 if ((yyvsp[-1].StrVal))
5515 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005516 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005517 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005518 // This is a useless bit cast causing a name redefinition. It is
5519 // a bit cast from a type to the same type of an operand with the
5520 // same name as the name we would give this instruction. Since this
5521 // instruction results in no code generation, it is safe to omit
5522 // the instruction. This situation can occur because of collapsed
5523 // type planes. For example:
5524 // %X = add int %Y, %Z
5525 // %X = cast int %Y to uint
5526 // After upgrade, this looks like:
5527 // %X = add i32 %Y, %Z
5528 // %X = bitcast i32 to i32
5529 // The bitcast is clearly useless so we omit it.
5530 omit = true;
5531 if (omit) {
5532 (yyval.InstVal).I = 0;
5533 (yyval.InstVal).S = Signless;
5534 } else {
Reid Spencerb7046c72007-01-29 05:41:34 +00005535 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5536 InsertValue((yyvsp[0].InstVal).I);
5537 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005538 }
5539 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005540 break;
5541
Reid Spencerc4d96252007-01-13 00:03:30 +00005542 case 271:
Reid Spencerb7046c72007-01-29 05:41:34 +00005543#line 2959 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005544 { // Used for PHI nodes
5545 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerb7046c72007-01-29 05:41:34 +00005546 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5547 Value* tmpVal = getVal((yyvsp[-5].TypeVal).T->get(), (yyvsp[-3].ValIDVal));
5548 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005549 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencerb7046c72007-01-29 05:41:34 +00005550 delete (yyvsp[-5].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005551 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005552 break;
5553
Reid Spencerc4d96252007-01-13 00:03:30 +00005554 case 272:
Reid Spencerb7046c72007-01-29 05:41:34 +00005555#line 2967 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005556 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005557 (yyval.PHIList) = (yyvsp[-6].PHIList);
5558 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5559 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5560 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer950bf602007-01-26 08:19:09 +00005561 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005562 break;
5563
Reid Spencerc4d96252007-01-13 00:03:30 +00005564 case 273:
Reid Spencerb7046c72007-01-29 05:41:34 +00005565#line 2975 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005566 { // Used for call statements, and memory insts...
5567 (yyval.ValueList) = new std::vector<ValueInfo>();
Reid Spencerb7046c72007-01-29 05:41:34 +00005568 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005569 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005570 break;
5571
Reid Spencer950bf602007-01-26 08:19:09 +00005572 case 274:
Reid Spencerb7046c72007-01-29 05:41:34 +00005573#line 2979 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005574 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005575 (yyval.ValueList) = (yyvsp[-2].ValueList);
5576 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005577 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005578 break;
5579
Reid Spencerc4d96252007-01-13 00:03:30 +00005580 case 276:
Reid Spencerb7046c72007-01-29 05:41:34 +00005581#line 2987 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005582 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005583 break;
5584
Reid Spencerc4d96252007-01-13 00:03:30 +00005585 case 277:
Reid Spencerb7046c72007-01-29 05:41:34 +00005586#line 2991 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005587 {
Reid Spencer950bf602007-01-26 08:19:09 +00005588 (yyval.BoolVal) = true;
5589 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005590 break;
5591
Reid Spencer319a7302007-01-05 17:20:02 +00005592 case 278:
Reid Spencerb7046c72007-01-29 05:41:34 +00005593#line 2994 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005594 {
Reid Spencer950bf602007-01-26 08:19:09 +00005595 (yyval.BoolVal) = false;
5596 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005597 break;
5598
5599 case 279:
Reid Spencerb7046c72007-01-29 05:41:34 +00005600#line 3000 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005601 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005602 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005603 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5604 error("Arithmetic operator requires integer, FP, or packed operands");
5605 if (isa<PackedType>(Ty) &&
Reid Spencerb7046c72007-01-29 05:41:34 +00005606 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Reid Spencer950bf602007-01-26 08:19:09 +00005607 error("Remainder not supported on packed types");
5608 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencerb7046c72007-01-29 05:41:34 +00005609 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5610 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5611 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005612 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5613 if ((yyval.InstVal).I == 0)
5614 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005615 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5616 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005617 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005618 break;
5619
5620 case 280:
Reid Spencerb7046c72007-01-29 05:41:34 +00005621#line 3017 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005622 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005623 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005624 if (!Ty->isInteger()) {
5625 if (!isa<PackedType>(Ty) ||
5626 !cast<PackedType>(Ty)->getElementType()->isInteger())
5627 error("Logical operator requires integral operands");
5628 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005629 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5630 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5631 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005632 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5633 if ((yyval.InstVal).I == 0)
5634 error("binary operator returned null");
Reid Spencerb7046c72007-01-29 05:41:34 +00005635 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5636 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005637 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005638 break;
5639
Reid Spencerc4d96252007-01-13 00:03:30 +00005640 case 281:
Reid Spencerb7046c72007-01-29 05:41:34 +00005641#line 3033 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005642 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005643 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005644 if(isa<PackedType>(Ty))
5645 error("PackedTypes currently not supported in setcc instructions");
5646 unsigned short pred;
Reid Spencerb7046c72007-01-29 05:41:34 +00005647 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5648 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5649 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005650 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5651 if ((yyval.InstVal).I == 0)
5652 error("binary operator returned null");
5653 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005654 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005655 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005656 break;
5657
Reid Spencerc4d96252007-01-13 00:03:30 +00005658 case 282:
Reid Spencerb7046c72007-01-29 05:41:34 +00005659#line 3047 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005660 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005661 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005662 if (isa<PackedType>(Ty))
5663 error("PackedTypes currently not supported in icmp instructions");
5664 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5665 error("icmp requires integer or pointer typed operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005666 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5667 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5668 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005669 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005670 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005671 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005672 break;
5673
Reid Spencerc4d96252007-01-13 00:03:30 +00005674 case 283:
Reid Spencerb7046c72007-01-29 05:41:34 +00005675#line 3059 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005676 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005677 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005678 if (isa<PackedType>(Ty))
5679 error("PackedTypes currently not supported in fcmp instructions");
5680 else if (!Ty->isFloatingPoint())
5681 error("fcmp instruction requires floating point operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005682 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5683 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5684 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005685 (yyval.InstVal).S = Unsigned;
Reid Spencerb7046c72007-01-29 05:41:34 +00005686 delete (yyvsp[-3].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005687 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005688 break;
5689
Reid Spencerc4d96252007-01-13 00:03:30 +00005690 case 284:
Reid Spencerb7046c72007-01-29 05:41:34 +00005691#line 3071 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005692 {
Reid Spencer950bf602007-01-26 08:19:09 +00005693 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencerb7046c72007-01-29 05:41:34 +00005694 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005695 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5696 if (Ones == 0)
5697 error("Expected integral type for not instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005698 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
Reid Spencer950bf602007-01-26 08:19:09 +00005699 if ((yyval.InstVal).I == 0)
5700 error("Could not create a xor instruction");
Reid Spencerb7046c72007-01-29 05:41:34 +00005701 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
Reid Spencer950bf602007-01-26 08:19:09 +00005702 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005703 break;
5704
5705 case 285:
Reid Spencerb7046c72007-01-29 05:41:34 +00005706#line 3082 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005707 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005708 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5709 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005710 error("Shift amount must be int8");
Reid Spencerb7046c72007-01-29 05:41:34 +00005711 if (!(yyvsp[-2].ValueVal).V->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005712 error("Shift constant expression requires integer operand");
Reid Spencerb7046c72007-01-29 05:41:34 +00005713 (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5714 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005715 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005716 break;
5717
5718 case 286:
Reid Spencerb7046c72007-01-29 05:41:34 +00005719#line 3091 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005720 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005721 const Type *DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005722 if (!DstTy->isFirstClassType())
5723 error("cast instruction to a non-primitive type: '" +
5724 DstTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00005725 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5726 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5727 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005728 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005729 break;
5730
5731 case 287:
Reid Spencerb7046c72007-01-29 05:41:34 +00005732#line 3100 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005733 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005734 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5735 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005736 error("select condition must be bool");
Reid Spencerb7046c72007-01-29 05:41:34 +00005737 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005738 error("select value types should match");
Reid Spencerb7046c72007-01-29 05:41:34 +00005739 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5740 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005741 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005742 break;
5743
Reid Spencerc4d96252007-01-13 00:03:30 +00005744 case 288:
Reid Spencerb7046c72007-01-29 05:41:34 +00005745#line 3109 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005746 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005747 const Type *Ty = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005748 NewVarArgs = true;
Reid Spencerb7046c72007-01-29 05:41:34 +00005749 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5750 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5751 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005752 ;}
5753 break;
5754
5755 case 289:
Reid Spencerb7046c72007-01-29 05:41:34 +00005756#line 3116 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005757 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005758 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5759 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005760 ObsoleteVarArgs = true;
5761 Function* NF = cast<Function>(CurModule.CurrentModule->
5762 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5763
5764 //b = vaarg a, t ->
5765 //foo = alloca 1 of t
5766 //bar = vacopy a
5767 //store bar -> foo
5768 //b = vaarg foo, t
5769 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5770 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005771 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005772 CurBB->getInstList().push_back(bar);
5773 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5774 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerb7046c72007-01-29 05:41:34 +00005775 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5776 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005777 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005778 break;
5779
Reid Spencerc4d96252007-01-13 00:03:30 +00005780 case 290:
Reid Spencerb7046c72007-01-29 05:41:34 +00005781#line 3137 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005782 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005783 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5784 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005785 ObsoleteVarArgs = true;
5786 Function* NF = cast<Function>(CurModule.CurrentModule->
5787 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5788
5789 //b = vanext a, t ->
5790 //foo = alloca 1 of t
5791 //bar = vacopy a
5792 //store bar -> foo
5793 //tmp = vaarg foo, t
5794 //b = load foo
5795 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5796 CurBB->getInstList().push_back(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005797 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005798 CurBB->getInstList().push_back(bar);
5799 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5800 Instruction* tmp = new VAArgInst(foo, DstTy);
5801 CurBB->getInstList().push_back(tmp);
5802 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerb7046c72007-01-29 05:41:34 +00005803 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5804 delete (yyvsp[0].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005805 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005806 break;
5807
Reid Spencerc4d96252007-01-13 00:03:30 +00005808 case 291:
Reid Spencerb7046c72007-01-29 05:41:34 +00005809#line 3161 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005810 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005811 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005812 error("Invalid extractelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005813 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5814 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005815 ;}
5816 break;
5817
5818 case 292:
Reid Spencerb7046c72007-01-29 05:41:34 +00005819#line 3167 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005820 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005821 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005822 error("Invalid insertelement operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005823 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5824 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005825 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005826 break;
5827
Reid Spencerc4d96252007-01-13 00:03:30 +00005828 case 293:
Reid Spencerb7046c72007-01-29 05:41:34 +00005829#line 3173 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005830 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005831 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005832 error("Invalid shufflevector operands");
Reid Spencerb7046c72007-01-29 05:41:34 +00005833 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5834 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005835 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005836 break;
5837
Reid Spencerc4d96252007-01-13 00:03:30 +00005838 case 294:
Reid Spencerb7046c72007-01-29 05:41:34 +00005839#line 3179 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005840 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005841 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005842 if (!Ty->isFirstClassType())
5843 error("PHI node operands must be of first class type");
5844 PHINode *PHI = new PHINode(Ty);
Reid Spencerb7046c72007-01-29 05:41:34 +00005845 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5846 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5847 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00005848 error("All elements of a PHI node must be of the same type");
Reid Spencerb7046c72007-01-29 05:41:34 +00005849 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5850 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00005851 }
5852 (yyval.InstVal).I = PHI;
Reid Spencerb7046c72007-01-29 05:41:34 +00005853 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5854 delete (yyvsp[0].PHIList).P; // Free the list...
Reid Spencer950bf602007-01-26 08:19:09 +00005855 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005856 break;
5857
5858 case 295:
Reid Spencerb7046c72007-01-29 05:41:34 +00005859#line 3195 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005860 {
Reid Spencer950bf602007-01-26 08:19:09 +00005861
5862 // Handle the short call syntax
5863 const PointerType *PFTy;
5864 const FunctionType *FTy;
Reid Spencerb7046c72007-01-29 05:41:34 +00005865 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005866 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5867 // Pull out the types of all of the arguments...
5868 std::vector<const Type*> ParamTypes;
Reid Spencerb7046c72007-01-29 05:41:34 +00005869 if ((yyvsp[-1].ValueList)) {
5870 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005871 I != E; ++I)
5872 ParamTypes.push_back((*I).V->getType());
5873 }
5874
Reid Spencerb7046c72007-01-29 05:41:34 +00005875 FunctionType::ParamAttrsList ParamAttrs;
5876 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
5877 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5878 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5879 }
Reid Spencer950bf602007-01-26 08:19:09 +00005880 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5881 if (isVarArg) ParamTypes.pop_back();
5882
Reid Spencerb7046c72007-01-29 05:41:34 +00005883 const Type *RetTy = (yyvsp[-4].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005884 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5885 error("Functions cannot return aggregate types");
5886
Reid Spencerb7046c72007-01-29 05:41:34 +00005887 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005888 PFTy = PointerType::get(FTy);
5889 }
5890
5891 // First upgrade any intrinsic calls.
5892 std::vector<Value*> Args;
Reid Spencerb7046c72007-01-29 05:41:34 +00005893 if ((yyvsp[-1].ValueList))
5894 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
5895 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
5896 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00005897
5898 // If we got an upgraded intrinsic
5899 if (Inst) {
5900 (yyval.InstVal).I = Inst;
5901 (yyval.InstVal).S = Signless;
5902 } else {
5903 // Get the function we're calling
Reid Spencerb7046c72007-01-29 05:41:34 +00005904 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005905
5906 // Check the argument values match
Reid Spencerb7046c72007-01-29 05:41:34 +00005907 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005908 // Make sure no arguments is a good thing!
5909 if (FTy->getNumParams() != 0)
5910 error("No arguments passed to a function that expects arguments");
5911 } else { // Has arguments?
5912 // Loop through FunctionType's arguments and ensure they are specified
5913 // correctly!
5914 //
5915 FunctionType::param_iterator I = FTy->param_begin();
5916 FunctionType::param_iterator E = FTy->param_end();
Reid Spencerb7046c72007-01-29 05:41:34 +00005917 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005918
5919 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5920 if ((*ArgI).V->getType() != *I)
5921 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5922 (*I)->getDescription() + "'");
5923
5924 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
5925 error("Invalid number of parameters detected");
5926 }
5927
5928 // Create the call instruction
5929 CallInst *CI = new CallInst(V, Args);
Reid Spencerb7046c72007-01-29 05:41:34 +00005930 CI->setTailCall((yyvsp[-6].BoolVal));
5931 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005932 (yyval.InstVal).I = CI;
Reid Spencerb7046c72007-01-29 05:41:34 +00005933 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005934 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005935 delete (yyvsp[-4].TypeVal).T;
5936 delete (yyvsp[-1].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005937 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005938 break;
5939
Reid Spencerc4d96252007-01-13 00:03:30 +00005940 case 296:
Reid Spencerb7046c72007-01-29 05:41:34 +00005941#line 3273 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005942 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005943 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005944 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005945 break;
5946
Reid Spencer609ca3e2007-01-12 20:10:51 +00005947 case 297:
Reid Spencerb7046c72007-01-29 05:41:34 +00005948#line 3281 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5949 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005950 break;
5951
5952 case 298:
Reid Spencerb7046c72007-01-29 05:41:34 +00005953#line 3282 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005954 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005955 break;
5956
Reid Spencerc4d96252007-01-13 00:03:30 +00005957 case 299:
Reid Spencerb7046c72007-01-29 05:41:34 +00005958#line 3286 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005959 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005960 break;
5961
Reid Spencerc4d96252007-01-13 00:03:30 +00005962 case 300:
Reid Spencerb7046c72007-01-29 05:41:34 +00005963#line 3287 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005964 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005965 break;
5966
Reid Spencerc4d96252007-01-13 00:03:30 +00005967 case 301:
Reid Spencerb7046c72007-01-29 05:41:34 +00005968#line 3291 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005969 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005970 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5971 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5972 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
5973 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005974 ;}
5975 break;
5976
5977 case 302:
Reid Spencerb7046c72007-01-29 05:41:34 +00005978#line 3297 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005979 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005980 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
5981 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5982 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
5983 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005984 ;}
5985 break;
5986
5987 case 303:
Reid Spencerb7046c72007-01-29 05:41:34 +00005988#line 3303 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005989 {
Reid Spencerb7046c72007-01-29 05:41:34 +00005990 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5991 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
5992 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
5993 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005994 ;}
5995 break;
5996
5997 case 304:
Reid Spencerb7046c72007-01-29 05:41:34 +00005998#line 3309 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005999 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006000 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6001 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6002 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6003 delete (yyvsp[-4].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006004 ;}
6005 break;
6006
6007 case 305:
Reid Spencerb7046c72007-01-29 05:41:34 +00006008#line 3315 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006009 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006010 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006011 if (!isa<PointerType>(PTy))
6012 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006013 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006014 (yyval.InstVal).S = Signless;
6015 ;}
6016 break;
6017
6018 case 306:
Reid Spencerb7046c72007-01-29 05:41:34 +00006019#line 3322 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006020 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006021 const Type* Ty = (yyvsp[-1].TypeVal).T->get();
6022 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006023 if (!isa<PointerType>(Ty))
6024 error("Can't load from nonpointer type: " + Ty->getDescription());
6025 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6026 error("Can't load from pointer of non-first-class type: " +
6027 Ty->getDescription());
Reid Spencerb7046c72007-01-29 05:41:34 +00006028 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6029 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
6030 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006031 ;}
6032 break;
6033
6034 case 307:
Reid Spencerb7046c72007-01-29 05:41:34 +00006035#line 3334 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006036 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006037 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00006038 if (!PTy)
6039 error("Can't store to a nonpointer type: " +
Reid Spencerb7046c72007-01-29 05:41:34 +00006040 (yyvsp[-1].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00006041 const Type *ElTy = PTy->getElementType();
Reid Spencerb7046c72007-01-29 05:41:34 +00006042 if (ElTy != (yyvsp[-3].ValueVal).V->getType())
6043 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencer950bf602007-01-26 08:19:09 +00006044 "' into space of type '" + ElTy->getDescription() + "'");
Reid Spencerb7046c72007-01-29 05:41:34 +00006045 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6046 (yyval.InstVal).I = new StoreInst((yyvsp[-3].ValueVal).V, tmpVal, (yyvsp[-5].BoolVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006047 (yyval.InstVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00006048 delete (yyvsp[-1].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006049 ;}
6050 break;
6051
6052 case 308:
Reid Spencerb7046c72007-01-29 05:41:34 +00006053#line 3348 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006054 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006055 const Type* Ty = (yyvsp[-2].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006056 if (!isa<PointerType>(Ty))
6057 error("getelementptr insn requires pointer operand");
6058
6059 std::vector<Value*> VIndices;
Reid Spencerb7046c72007-01-29 05:41:34 +00006060 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006061
Reid Spencerb7046c72007-01-29 05:41:34 +00006062 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006063 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6064 (yyval.InstVal).S = Signless;
Reid Spencerb7046c72007-01-29 05:41:34 +00006065 delete (yyvsp[-2].TypeVal).T;
6066 delete (yyvsp[0].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006067 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006068 break;
6069
6070
Reid Spencer950bf602007-01-26 08:19:09 +00006071 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006072 }
6073
Reid Spencerb7046c72007-01-29 05:41:34 +00006074/* Line 1126 of yacc.c. */
6075#line 6076 "UpgradeParser.tab.c"
6076
6077 yyvsp -= yylen;
6078 yyssp -= yylen;
6079
6080
Reid Spencer950bf602007-01-26 08:19:09 +00006081 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006082
6083 *++yyvsp = yyval;
6084
6085
Reid Spencer319a7302007-01-05 17:20:02 +00006086 /* Now `shift' the result of the reduction. Determine what state
6087 that goes to, based on the state we popped back to and the rule
6088 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006089
6090 yyn = yyr1[yyn];
6091
Reid Spencer319a7302007-01-05 17:20:02 +00006092 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6093 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006094 yystate = yytable[yystate];
6095 else
Reid Spencer319a7302007-01-05 17:20:02 +00006096 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006097
6098 goto yynewstate;
6099
6100
Reid Spencer319a7302007-01-05 17:20:02 +00006101/*------------------------------------.
6102| yyerrlab -- here on detecting error |
6103`------------------------------------*/
6104yyerrlab:
6105 /* If not already recovering from an error, report this error. */
6106 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006107 {
6108 ++yynerrs;
Reid Spencerb7046c72007-01-29 05:41:34 +00006109#if YYERROR_VERBOSE
6110 yyn = yypact[yystate];
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006111
Reid Spencerb7046c72007-01-29 05:41:34 +00006112 if (YYPACT_NINF < yyn && yyn < YYLAST)
6113 {
6114 int yytype = YYTRANSLATE (yychar);
6115 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6116 YYSIZE_T yysize = yysize0;
6117 YYSIZE_T yysize1;
6118 int yysize_overflow = 0;
6119 char *yymsg = 0;
6120# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6121 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6122 int yyx;
6123
6124#if 0
6125 /* This is so xgettext sees the translatable formats that are
6126 constructed on the fly. */
6127 YY_("syntax error, unexpected %s");
6128 YY_("syntax error, unexpected %s, expecting %s");
6129 YY_("syntax error, unexpected %s, expecting %s or %s");
6130 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6131 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006132#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006133 char *yyfmt;
6134 char const *yyf;
6135 static char const yyunexpected[] = "syntax error, unexpected %s";
6136 static char const yyexpecting[] = ", expecting %s";
6137 static char const yyor[] = " or %s";
6138 char yyformat[sizeof yyunexpected
6139 + sizeof yyexpecting - 1
6140 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6141 * (sizeof yyor - 1))];
6142 char const *yyprefix = yyexpecting;
6143
6144 /* Start YYX at -YYN if negative to avoid negative indexes in
6145 YYCHECK. */
6146 int yyxbegin = yyn < 0 ? -yyn : 0;
6147
6148 /* Stay within bounds of both yycheck and yytname. */
6149 int yychecklim = YYLAST - yyn;
6150 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6151 int yycount = 1;
6152
6153 yyarg[0] = yytname[yytype];
6154 yyfmt = yystpcpy (yyformat, yyunexpected);
6155
6156 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6157 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6158 {
6159 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6160 {
6161 yycount = 1;
6162 yysize = yysize0;
6163 yyformat[sizeof yyunexpected - 1] = '\0';
6164 break;
6165 }
6166 yyarg[yycount++] = yytname[yyx];
6167 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6168 yysize_overflow |= yysize1 < yysize;
6169 yysize = yysize1;
6170 yyfmt = yystpcpy (yyfmt, yyprefix);
6171 yyprefix = yyor;
6172 }
6173
6174 yyf = YY_(yyformat);
6175 yysize1 = yysize + yystrlen (yyf);
6176 yysize_overflow |= yysize1 < yysize;
6177 yysize = yysize1;
6178
6179 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6180 yymsg = (char *) YYSTACK_ALLOC (yysize);
6181 if (yymsg)
6182 {
6183 /* Avoid sprintf, as that infringes on the user's name space.
6184 Don't have undefined behavior even if the translation
6185 produced a string with the wrong number of "%s"s. */
6186 char *yyp = yymsg;
6187 int yyi = 0;
6188 while ((*yyp = *yyf))
6189 {
6190 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6191 {
6192 yyp += yytnamerr (yyp, yyarg[yyi++]);
6193 yyf += 2;
6194 }
6195 else
6196 {
6197 yyp++;
6198 yyf++;
6199 }
6200 }
6201 yyerror (yymsg);
6202 YYSTACK_FREE (yymsg);
6203 }
6204 else
6205 {
6206 yyerror (YY_("syntax error"));
6207 goto yyexhaustedlab;
6208 }
6209 }
6210 else
6211#endif /* YYERROR_VERBOSE */
6212 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006213 }
Reid Spencer950bf602007-01-26 08:19:09 +00006214
6215
6216
6217 if (yyerrstatus == 3)
6218 {
6219 /* If just tried and failed to reuse look-ahead token after an
6220 error, discard it. */
6221
6222 if (yychar <= YYEOF)
Reid Spencerb7046c72007-01-29 05:41:34 +00006223 {
Reid Spencer950bf602007-01-26 08:19:09 +00006224 /* Return failure if at end of input. */
6225 if (yychar == YYEOF)
6226 YYABORT;
Reid Spencerb7046c72007-01-29 05:41:34 +00006227 }
Reid Spencer950bf602007-01-26 08:19:09 +00006228 else
6229 {
Reid Spencerb7046c72007-01-29 05:41:34 +00006230 yydestruct ("Error: discarding", yytoken, &yylval);
Reid Spencer950bf602007-01-26 08:19:09 +00006231 yychar = YYEMPTY;
6232 }
6233 }
6234
6235 /* Else will try to reuse look-ahead token after shifting the error
6236 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006237 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006238
Reid Spencer319a7302007-01-05 17:20:02 +00006239
Reid Spencer950bf602007-01-26 08:19:09 +00006240/*---------------------------------------------------.
6241| yyerrorlab -- error raised explicitly by YYERROR. |
6242`---------------------------------------------------*/
6243yyerrorlab:
6244
6245 /* Pacify compilers like GCC when the user code never invokes
6246 YYERROR and the label yyerrorlab therefore never appears in user
6247 code. */
Reid Spencerb7046c72007-01-29 05:41:34 +00006248 if (0)
Reid Spencer950bf602007-01-26 08:19:09 +00006249 goto yyerrorlab;
6250
Reid Spencerb7046c72007-01-29 05:41:34 +00006251yyvsp -= yylen;
6252 yyssp -= yylen;
Reid Spencer950bf602007-01-26 08:19:09 +00006253 yystate = *yyssp;
6254 goto yyerrlab1;
6255
6256
6257/*-------------------------------------------------------------.
6258| yyerrlab1 -- common code for both syntax error and YYERROR. |
6259`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006260yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006261 yyerrstatus = 3; /* Each real token shifted decrements this. */
6262
6263 for (;;)
6264 {
6265 yyn = yypact[yystate];
6266 if (yyn != YYPACT_NINF)
6267 {
6268 yyn += YYTERROR;
6269 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6270 {
6271 yyn = yytable[yyn];
6272 if (0 < yyn)
6273 break;
6274 }
6275 }
6276
6277 /* Pop the current state because it cannot handle the error token. */
6278 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006279 YYABORT;
6280
6281
Reid Spencerb7046c72007-01-29 05:41:34 +00006282 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6283 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006284 yystate = *yyssp;
6285 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006286 }
6287
6288 if (yyn == YYFINAL)
6289 YYACCEPT;
6290
6291 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006292
6293
Reid Spencerb7046c72007-01-29 05:41:34 +00006294 /* Shift the error token. */
Reid Spencer950bf602007-01-26 08:19:09 +00006295 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6296
Reid Spencere7c3c602006-11-30 06:36:44 +00006297 yystate = yyn;
6298 goto yynewstate;
6299
Chris Lattner37e01c52007-01-04 18:46:42 +00006300
Reid Spencer319a7302007-01-05 17:20:02 +00006301/*-------------------------------------.
6302| yyacceptlab -- YYACCEPT comes here. |
6303`-------------------------------------*/
6304yyacceptlab:
6305 yyresult = 0;
6306 goto yyreturn;
6307
6308/*-----------------------------------.
6309| yyabortlab -- YYABORT comes here. |
6310`-----------------------------------*/
6311yyabortlab:
6312 yyresult = 1;
6313 goto yyreturn;
6314
6315#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006316/*-------------------------------------------------.
6317| yyexhaustedlab -- memory exhaustion comes here. |
6318`-------------------------------------------------*/
6319yyexhaustedlab:
6320 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006321 yyresult = 2;
6322 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006323#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006324
6325yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006326 if (yychar != YYEOF && yychar != YYEMPTY)
6327 yydestruct ("Cleanup: discarding lookahead",
6328 yytoken, &yylval);
6329 while (yyssp != yyss)
6330 {
6331 yydestruct ("Cleanup: popping",
6332 yystos[*yyssp], yyvsp);
Reid Spencerb7046c72007-01-29 05:41:34 +00006333 YYPOPSTACK;
Reid Spencer950bf602007-01-26 08:19:09 +00006334 }
Reid Spencer319a7302007-01-05 17:20:02 +00006335#ifndef yyoverflow
6336 if (yyss != yyssa)
6337 YYSTACK_FREE (yyss);
6338#endif
Reid Spencerb7046c72007-01-29 05:41:34 +00006339 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006340}
Reid Spencer319a7302007-01-05 17:20:02 +00006341
6342
Reid Spencerb7046c72007-01-29 05:41:34 +00006343#line 3364 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006344
6345
6346int yyerror(const char *ErrorMsg) {
6347 std::string where
6348 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006349 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6350 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6351 if (yychar != YYEMPTY && yychar != 0)
6352 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6353 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006354 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006355 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006356 exit(1);
6357}
Reid Spencer319a7302007-01-05 17:20:02 +00006358
Reid Spencer30d0c582007-01-15 00:26:18 +00006359void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006360 std::string where
6361 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006362 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6363 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6364 if (yychar != YYEMPTY && yychar != 0)
6365 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6366 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006367 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6368}
6369
Reid Spencer950bf602007-01-26 08:19:09 +00006370void error(const std::string& ErrorMsg, int LineNo) {
6371 if (LineNo == -1) LineNo = Upgradelineno;
6372 Upgradelineno = LineNo;
6373 yyerror(ErrorMsg.c_str());
6374}
6375
6376