blob: acaeade09a3ee34ce95c193522604a5a02acba3b [file] [log] [blame]
Reid Spencer950bf602007-01-26 08:19:09 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Reid Spencer319a7302007-01-05 17:20:02 +00003/* Skeleton parser for Yacc-like parsing with Bison,
Reid Spencer950bf602007-01-26 08:19:09 +00004 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00005
Reid Spencer319a7302007-01-05 17:20:02 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Reid Spencere7c3c602006-11-30 06:36:44 +000010
Reid Spencer319a7302007-01-05 17:20:02 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
Reid Spencer950bf602007-01-26 08:19:09 +000018 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
Reid Spencer319a7302007-01-05 17:20:02 +000020
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
Reid Spencer950bf602007-01-26 08:19:09 +000037#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
Reid Spencer319a7302007-01-05 17:20:02 +000044
45/* Pure parsers. */
Reid Spencer950bf602007-01-26 08:19:09 +000046#define YYPURE 0
Reid Spencer319a7302007-01-05 17:20:02 +000047
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
Reid Spencer950bf602007-01-26 08:19:09 +000051/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000052#define yyparse Upgradeparse
Reid Spencer319a7302007-01-05 17:20:02 +000053#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000054#define yyerror Upgradeerror
Reid Spencer319a7302007-01-05 17:20:02 +000055#define yylval Upgradelval
56#define yychar Upgradechar
Reid Spencere7c3c602006-11-30 06:36:44 +000057#define yydebug Upgradedebug
58#define yynerrs Upgradenerrs
59
Reid Spencere7c3c602006-11-30 06:36:44 +000060
Reid Spencer319a7302007-01-05 17:20:02 +000061/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
Reid Spencer950bf602007-01-26 08:19:09 +000067 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 BOOL = 264,
74 SBYTE = 265,
75 UBYTE = 266,
76 SHORT = 267,
77 USHORT = 268,
78 INT = 269,
79 UINT = 270,
80 LONG = 271,
81 ULONG = 272,
82 FLOAT = 273,
83 DOUBLE = 274,
84 TYPE = 275,
85 LABEL = 276,
86 VAR_ID = 277,
87 LABELSTR = 278,
88 STRINGCONSTANT = 279,
89 IMPLEMENTATION = 280,
90 ZEROINITIALIZER = 281,
91 TRUETOK = 282,
92 FALSETOK = 283,
93 BEGINTOK = 284,
94 ENDTOK = 285,
95 DECLARE = 286,
96 GLOBAL = 287,
97 CONSTANT = 288,
98 SECTION = 289,
99 VOLATILE = 290,
100 TO = 291,
101 DOTDOTDOT = 292,
102 NULL_TOK = 293,
103 UNDEF = 294,
104 CONST = 295,
105 INTERNAL = 296,
106 LINKONCE = 297,
107 WEAK = 298,
108 APPENDING = 299,
Reid Spencer319a7302007-01-05 17:20:02 +0000109 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
Reid Spencer950bf602007-01-26 08:19:09 +0000112 OPAQUE = 303,
113 NOT = 304,
114 EXTERNAL = 305,
115 TARGET = 306,
116 TRIPLE = 307,
117 ENDIAN = 308,
118 POINTERSIZE = 309,
119 LITTLE = 310,
120 BIG = 311,
121 ALIGN = 312,
Reid Spencerc4d96252007-01-13 00:03:30 +0000122 DEPLIBS = 313,
123 CALL = 314,
124 TAIL = 315,
125 ASM_TOK = 316,
126 MODULE = 317,
127 SIDEEFFECT = 318,
128 CC_TOK = 319,
129 CCC_TOK = 320,
130 CSRETCC_TOK = 321,
131 FASTCC_TOK = 322,
132 COLDCC_TOK = 323,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
135 DATALAYOUT = 326,
136 RET = 327,
137 BR = 328,
138 SWITCH = 329,
139 INVOKE = 330,
Reid Spencer950bf602007-01-26 08:19:09 +0000140 UNREACHABLE = 331,
Reid Spencerc4d96252007-01-13 00:03:30 +0000141 UNWIND = 332,
Reid Spencer950bf602007-01-26 08:19:09 +0000142 EXCEPT = 333,
Reid Spencerc4d96252007-01-13 00:03:30 +0000143 ADD = 334,
144 SUB = 335,
145 MUL = 336,
146 DIV = 337,
147 UDIV = 338,
148 SDIV = 339,
149 FDIV = 340,
150 REM = 341,
151 UREM = 342,
152 SREM = 343,
153 FREM = 344,
154 AND = 345,
155 OR = 346,
156 XOR = 347,
157 SETLE = 348,
158 SETGE = 349,
159 SETLT = 350,
160 SETGT = 351,
161 SETEQ = 352,
162 SETNE = 353,
163 ICMP = 354,
164 FCMP = 355,
Reid Spencer950bf602007-01-26 08:19:09 +0000165 MALLOC = 356,
166 ALLOCA = 357,
167 FREE = 358,
168 LOAD = 359,
169 STORE = 360,
170 GETELEMENTPTR = 361,
171 PHI_TOK = 362,
172 SELECT = 363,
173 SHL = 364,
174 SHR = 365,
175 ASHR = 366,
176 LSHR = 367,
177 VAARG = 368,
178 EXTRACTELEMENT = 369,
179 INSERTELEMENT = 370,
180 SHUFFLEVECTOR = 371,
181 VAARG_old = 372,
182 VANEXT_old = 373,
183 EQ = 374,
184 NE = 375,
185 SLT = 376,
186 SGT = 377,
187 SLE = 378,
188 SGE = 379,
189 ULT = 380,
190 UGT = 381,
191 ULE = 382,
192 UGE = 383,
193 OEQ = 384,
194 ONE = 385,
195 OLT = 386,
196 OGT = 387,
197 OLE = 388,
198 OGE = 389,
199 ORD = 390,
200 UNO = 391,
201 UEQ = 392,
202 UNE = 393,
203 CAST = 394,
204 TRUNC = 395,
205 ZEXT = 396,
206 SEXT = 397,
207 FPTRUNC = 398,
208 FPEXT = 399,
209 FPTOUI = 400,
210 FPTOSI = 401,
211 UITOFP = 402,
212 SITOFP = 403,
213 PTRTOINT = 404,
214 INTTOPTR = 405,
215 BITCAST = 406
Reid Spencer319a7302007-01-05 17:20:02 +0000216 };
217#endif
Reid Spencer950bf602007-01-26 08:19:09 +0000218/* Tokens. */
219#define ESINT64VAL 258
220#define EUINT64VAL 259
221#define SINTVAL 260
222#define UINTVAL 261
223#define FPVAL 262
224#define VOID 263
225#define BOOL 264
226#define SBYTE 265
227#define UBYTE 266
228#define SHORT 267
229#define USHORT 268
230#define INT 269
231#define UINT 270
232#define LONG 271
233#define ULONG 272
234#define FLOAT 273
235#define DOUBLE 274
236#define TYPE 275
237#define LABEL 276
238#define VAR_ID 277
239#define LABELSTR 278
240#define STRINGCONSTANT 279
241#define IMPLEMENTATION 280
242#define ZEROINITIALIZER 281
243#define TRUETOK 282
244#define FALSETOK 283
245#define BEGINTOK 284
246#define ENDTOK 285
247#define DECLARE 286
248#define GLOBAL 287
249#define CONSTANT 288
250#define SECTION 289
251#define VOLATILE 290
252#define TO 291
253#define DOTDOTDOT 292
254#define NULL_TOK 293
255#define UNDEF 294
256#define CONST 295
257#define INTERNAL 296
258#define LINKONCE 297
259#define WEAK 298
260#define APPENDING 299
Reid Spencer319a7302007-01-05 17:20:02 +0000261#define DLLIMPORT 300
262#define DLLEXPORT 301
263#define EXTERN_WEAK 302
Reid Spencer950bf602007-01-26 08:19:09 +0000264#define OPAQUE 303
265#define NOT 304
266#define EXTERNAL 305
267#define TARGET 306
268#define TRIPLE 307
269#define ENDIAN 308
270#define POINTERSIZE 309
271#define LITTLE 310
272#define BIG 311
273#define ALIGN 312
Reid Spencerc4d96252007-01-13 00:03:30 +0000274#define DEPLIBS 313
275#define CALL 314
276#define TAIL 315
277#define ASM_TOK 316
278#define MODULE 317
279#define SIDEEFFECT 318
280#define CC_TOK 319
281#define CCC_TOK 320
282#define CSRETCC_TOK 321
283#define FASTCC_TOK 322
284#define COLDCC_TOK 323
285#define X86_STDCALLCC_TOK 324
286#define X86_FASTCALLCC_TOK 325
287#define DATALAYOUT 326
288#define RET 327
289#define BR 328
290#define SWITCH 329
291#define INVOKE 330
Reid Spencer950bf602007-01-26 08:19:09 +0000292#define UNREACHABLE 331
Reid Spencerc4d96252007-01-13 00:03:30 +0000293#define UNWIND 332
Reid Spencer950bf602007-01-26 08:19:09 +0000294#define EXCEPT 333
Reid Spencerc4d96252007-01-13 00:03:30 +0000295#define ADD 334
296#define SUB 335
297#define MUL 336
298#define DIV 337
299#define UDIV 338
300#define SDIV 339
301#define FDIV 340
302#define REM 341
303#define UREM 342
304#define SREM 343
305#define FREM 344
306#define AND 345
307#define OR 346
308#define XOR 347
309#define SETLE 348
310#define SETGE 349
311#define SETLT 350
312#define SETGT 351
313#define SETEQ 352
314#define SETNE 353
315#define ICMP 354
316#define FCMP 355
Reid Spencer950bf602007-01-26 08:19:09 +0000317#define MALLOC 356
318#define ALLOCA 357
319#define FREE 358
320#define LOAD 359
321#define STORE 360
322#define GETELEMENTPTR 361
323#define PHI_TOK 362
324#define SELECT 363
325#define SHL 364
326#define SHR 365
327#define ASHR 366
328#define LSHR 367
329#define VAARG 368
330#define EXTRACTELEMENT 369
331#define INSERTELEMENT 370
332#define SHUFFLEVECTOR 371
333#define VAARG_old 372
334#define VANEXT_old 373
335#define EQ 374
336#define NE 375
337#define SLT 376
338#define SGT 377
339#define SLE 378
340#define SGE 379
341#define ULT 380
342#define UGT 381
343#define ULE 382
344#define UGE 383
345#define OEQ 384
346#define ONE 385
347#define OLT 386
348#define OGT 387
349#define OLE 388
350#define OGE 389
351#define ORD 390
352#define UNO 391
353#define UEQ 392
354#define UNE 393
355#define CAST 394
356#define TRUNC 395
357#define ZEXT 396
358#define SEXT 397
359#define FPTRUNC 398
360#define FPEXT 399
361#define FPTOUI 400
362#define FPTOSI 401
363#define UITOFP 402
364#define SITOFP 403
365#define PTRTOINT 404
366#define INTTOPTR 405
367#define BITCAST 406
Reid Spencer319a7302007-01-05 17:20:02 +0000368
369
370
371
372/* Copy the first part of user declarations. */
Reid Spencer950bf602007-01-26 08:19:09 +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
411
412SignedType *SignedType::SByteTy = 0;
413SignedType *SignedType::SShortTy = 0;
414SignedType *SignedType::SIntTy = 0;
415SignedType *SignedType::SLongTy = 0;
416
417inline bool SignedType::classof(const Type *T) {
418 if (T->getTypeID() != IntegerTyID)
419 return false;
420 return (T == SByteTy || T == SShortTy || T == SIntTy || T == SLongTy );
421}
422
423SignedType::SignedType(const IntegerType* ITy)
424 : IntegerType(ITy->getBitWidth()), base_type(ITy)
425{
426}
427
428const SignedType *SignedType::get(const IntegerType* ITy) {
429 if (ITy == Type::Int8Ty) {
430 if (!SByteTy)
431 SByteTy = new SignedType(IntegerType::get(8));
432 return SByteTy;
433 } else if (ITy == Type::Int16Ty) {
434 if (!SShortTy)
435 SShortTy = new SignedType(IntegerType::get(16));
436 return SShortTy;
437 } else if (ITy == Type::Int32Ty) {
438 if (!SIntTy)
439 SIntTy = new SignedType(IntegerType::get(32));
440 return SIntTy;
441 } else if (ITy == Type::Int64Ty) {
442 if (!SLongTy)
443 SLongTy = new SignedType(IntegerType::get(64));
444 return SLongTy;
445 } else
446 assert(0 && "Invalid integer type for SignedType::get");
447}
448
449static inline Signedness getSign(const Type *&Ty) {
450 if (const SignedType *STy = dyn_cast<SignedType>(Ty)) {
451 Ty = STy->getBaseType();
452 return Signed;
453 } else if (isa<IntegerType>(Ty))
454 return Unsigned;
455 return Signless;
456}
457
458static const Type*
459resolveTypeImpl(const Type* Ty, std::vector<const Type*>& TyStack)
460{
461 // Nothing to resolve if it isn't a derived type
462 if (!Ty->isDerivedType())
463 return Ty;
464
465 // Prevent infinite recursion for recursive types
466 for (std::vector<const Type*>::const_iterator I = TyStack.begin(),
467 E = TyStack.end(); I != E; ++I)
468 if (Ty == *I)
469 return Ty;
470
471 // Okay, haven't seen this derived type yet, push it on the stack.
472 const Type* Result = Ty;
473 TyStack.push_back(Ty);
474
475 // Process the type
476 switch (Ty->getTypeID()) {
477 default: assert(0 && "Invalid derived type");
478 case Type::IntegerTyID:
479 break;
480 case Type::FunctionTyID: {
481 const FunctionType* FTy = cast<FunctionType>(Ty);
482 const Type* RetTy = resolveTypeImpl(FTy->getReturnType(), TyStack);
483 std::vector<const Type*> Types;
484 FunctionType::ParamAttrsList Attrs;
485 Attrs.push_back(FTy->getParamAttrs(0));
486 for (unsigned i = 0; i < FTy->getNumParams(); ++i) {
487 Types.push_back(resolveTypeImpl(FTy->getParamType(i), TyStack));
488 Attrs.push_back(FTy->getParamAttrs(i+1));
489 }
490 Result = FunctionType::get(RetTy, Types, FTy->isVarArg(), Attrs);
491 break;
492 }
493 case Type::StructTyID:
494 case Type::PackedStructTyID: {
495 const StructType *STy = cast<StructType>(Ty);
496 std::vector<const Type*> FieldTypes;
497 for (unsigned i = 0; i < STy->getNumElements(); ++i)
498 FieldTypes.push_back(resolveTypeImpl(STy->getElementType(i), TyStack));
499 Result = StructType::get(FieldTypes, STy->isPacked());
500 break;
501 }
502 case Type::ArrayTyID: {
503 const ArrayType *ATy = cast<ArrayType>(Ty);
504 uint64_t NElems = ATy->getNumElements();
505 const Type *ElemTy = resolveTypeImpl(ATy->getElementType(), TyStack);
506 Result = ArrayType::get(ElemTy, NElems);
507 break;
508 }
509 case Type::PointerTyID: {
510 const PointerType *PTy = cast<PointerType>(Ty);
511 const Type *ElemTy = resolveTypeImpl(PTy->getElementType(), TyStack);
512 Result = PointerType::get(ElemTy);
513 break;
514 }
515 case Type::PackedTyID: {
516 const PackedType *PTy = cast<PackedType>(Ty);
517 unsigned NElems = PTy->getNumElements();
518 const Type *ElemTy = resolveTypeImpl(PTy->getElementType(), TyStack);
519 Result = PackedType::get(ElemTy, NElems);
520 break;
521 }
522 }
523 // Done with it, pop it off.
524 TyStack.pop_back();
525 return Result;
526}
527
528static inline const Type* resolveType(const Type* Ty) {
529 if (!Ty)
530 return 0;
531 if (const SignedType* STy = dyn_cast<SignedType>(Ty))
532 return STy->getBaseType();
533 std::vector<const Type*> TyStack;
534 return resolveTypeImpl(Ty, TyStack);
535}
536
537std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000538static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000539
Reid Spencer71d2ec92006-12-31 06:02:26 +0000540// This bool controls whether attributes are ever added to function declarations
541// definitions and calls.
542static bool AddAttributes = false;
543
Reid Spencer950bf602007-01-26 08:19:09 +0000544static Module *ParserResult;
545static bool ObsoleteVarArgs;
546static bool NewVarArgs;
547static BasicBlock *CurBB;
548static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000549
Reid Spencer950bf602007-01-26 08:19:09 +0000550
551
552// This contains info used when building the body of a function. It is
553// destroyed when the function is completed.
554//
555typedef std::vector<Value *> ValueList; // Numbered defs
556
557typedef std::pair<std::string,const Type*> RenameMapKey;
558typedef std::map<RenameMapKey,std::string> RenameMapType;
559
560static void
561ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
562 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
563
564static struct PerModuleInfo {
565 Module *CurrentModule;
566 std::map<const Type *, ValueList> Values; // Module level numbered definitions
567 std::map<const Type *,ValueList> LateResolveValues;
568 std::vector<PATypeHolder> Types;
569 std::map<ValID, PATypeHolder> LateResolveTypes;
570 static Module::Endianness Endian;
571 static Module::PointerSize PointerSize;
572 RenameMapType RenameMap;
573
574 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
575 /// how they were referenced and on which line of the input they came from so
576 /// that we can resolve them later and print error messages as appropriate.
577 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
578
579 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
580 // references to global values. Global values may be referenced before they
581 // are defined, and if so, the temporary object that they represent is held
582 // here. This is used for forward references of GlobalValues.
583 //
584 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
585 GlobalRefsType;
586 GlobalRefsType GlobalRefs;
587
588 void ModuleDone() {
589 // If we could not resolve some functions at function compilation time
590 // (calls to functions before they are defined), resolve them now... Types
591 // are resolved when the constant pool has been completely parsed.
592 //
593 ResolveDefinitions(LateResolveValues);
594
595 // Check to make sure that all global value forward references have been
596 // resolved!
597 //
598 if (!GlobalRefs.empty()) {
599 std::string UndefinedReferences = "Unresolved global references exist:\n";
600
601 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
602 I != E; ++I) {
603 UndefinedReferences += " " + I->first.first->getDescription() + " " +
604 I->first.second.getName() + "\n";
605 }
606 error(UndefinedReferences);
607 return;
608 }
609
610 if (CurrentModule->getDataLayout().empty()) {
611 std::string dataLayout;
612 if (Endian != Module::AnyEndianness)
613 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
614 if (PointerSize != Module::AnyPointerSize) {
615 if (!dataLayout.empty())
616 dataLayout += "-";
617 dataLayout.append(PointerSize == Module::Pointer64 ?
618 "p:64:64" : "p:32:32");
619 }
620 CurrentModule->setDataLayout(dataLayout);
621 }
622
623 Values.clear(); // Clear out function local definitions
624 Types.clear();
625 CurrentModule = 0;
626 }
627
628 // GetForwardRefForGlobal - Check to see if there is a forward reference
629 // for this global. If so, remove it from the GlobalRefs map and return it.
630 // If not, just return null.
631 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
632 // Check to see if there is a forward reference to this global variable...
633 // if there is, eliminate it and patch the reference to use the new def'n.
634 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
635 GlobalValue *Ret = 0;
636 if (I != GlobalRefs.end()) {
637 Ret = I->second;
638 GlobalRefs.erase(I);
639 }
640 return Ret;
641 }
642 void setEndianness(Module::Endianness E) { Endian = E; }
643 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
644} CurModule;
645
646Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
647Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
648
649static struct PerFunctionInfo {
650 Function *CurrentFunction; // Pointer to current function being created
651
652 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
653 std::map<const Type*, ValueList> LateResolveValues;
654 bool isDeclare; // Is this function a forward declararation?
655 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
656
657 /// BBForwardRefs - When we see forward references to basic blocks, keep
658 /// track of them here.
659 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
660 std::vector<BasicBlock*> NumberedBlocks;
661 RenameMapType RenameMap;
662 std::set<Value*> SignedValues;
663 unsigned NextBBNum;
664
665 inline PerFunctionInfo() {
666 CurrentFunction = 0;
667 isDeclare = false;
668 Linkage = GlobalValue::ExternalLinkage;
669 }
670
671 inline void FunctionStart(Function *M) {
672 CurrentFunction = M;
673 NextBBNum = 0;
674 }
675
676 void FunctionDone() {
677 NumberedBlocks.clear();
678
679 // Any forward referenced blocks left?
680 if (!BBForwardRefs.empty()) {
681 error("Undefined reference to label " +
682 BBForwardRefs.begin()->first->getName());
683 return;
684 }
685
686 // Resolve all forward references now.
687 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
688
689 Values.clear(); // Clear out function local definitions
690 RenameMap.clear();
691 SignedValues.clear();
692 CurrentFunction = 0;
693 isDeclare = false;
694 Linkage = GlobalValue::ExternalLinkage;
695 }
696} CurFun; // Info for the current function...
697
698static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
699
700
701//===----------------------------------------------------------------------===//
702// Code to handle definitions of all the types
703//===----------------------------------------------------------------------===//
704
705static int InsertValue(Value *V,
706 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
707 if (V->hasName()) return -1; // Is this a numbered definition?
708
709 // Yes, insert the value into the value table...
710 ValueList &List = ValueTab[V->getType()];
711 List.push_back(V);
712 return List.size()-1;
713}
714
715static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
716 switch (D.Type) {
717 case ValID::NumberVal: // Is it a numbered definition?
718 // Module constants occupy the lowest numbered slots...
719 if ((unsigned)D.Num < CurModule.Types.size()) {
720 return CurModule.Types[(unsigned)D.Num];
721 }
722 break;
723 case ValID::NameVal: // Is it a named definition?
724 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
725 D.destroy(); // Free old strdup'd memory...
726 return N;
727 }
728 break;
729 default:
730 error("Internal parser error: Invalid symbol type reference");
731 return 0;
732 }
733
734 // If we reached here, we referenced either a symbol that we don't know about
735 // or an id number that hasn't been read yet. We may be referencing something
736 // forward, so just create an entry to be resolved later and get to it...
737 //
738 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
739
740
741 if (inFunctionScope()) {
742 if (D.Type == ValID::NameVal) {
743 error("Reference to an undefined type: '" + D.getName() + "'");
744 return 0;
745 } else {
746 error("Reference to an undefined type: #" + itostr(D.Num));
747 return 0;
748 }
749 }
750
751 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
752 if (I != CurModule.LateResolveTypes.end())
753 return I->second;
754
755 Type *Typ = OpaqueType::get();
756 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
757 return Typ;
758 }
759
760// getExistingValue - Look up the value specified by the provided type and
761// the provided ValID. If the value exists and has already been defined, return
762// it. Otherwise return null.
763//
764static Value *getExistingValue(const Type *Ty, const ValID &D) {
765 if (isa<FunctionType>(Ty)) {
766 error("Functions are not values and must be referenced as pointers");
767 }
768
769 switch (D.Type) {
770 case ValID::NumberVal: { // Is it a numbered definition?
771 unsigned Num = (unsigned)D.Num;
772
773 // Module constants occupy the lowest numbered slots...
774 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
775 if (VI != CurModule.Values.end()) {
776 if (Num < VI->second.size())
777 return VI->second[Num];
778 Num -= VI->second.size();
779 }
780
781 // Make sure that our type is within bounds
782 VI = CurFun.Values.find(Ty);
783 if (VI == CurFun.Values.end()) return 0;
784
785 // Check that the number is within bounds...
786 if (VI->second.size() <= Num) return 0;
787
788 return VI->second[Num];
789 }
790
791 case ValID::NameVal: { // Is it a named definition?
792 // Get the name out of the ID
793 std::string Name(D.Name);
794 Value* V = 0;
795 RenameMapKey Key = std::make_pair(Name, Ty);
796 if (inFunctionScope()) {
797 // See if the name was renamed
798 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
799 std::string LookupName;
800 if (I != CurFun.RenameMap.end())
801 LookupName = I->second;
802 else
803 LookupName = Name;
804 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
805 V = SymTab.lookup(Ty, LookupName);
806 }
807 if (!V) {
808 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
809 std::string LookupName;
810 if (I != CurModule.RenameMap.end())
811 LookupName = I->second;
812 else
813 LookupName = Name;
814 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
815 }
816 if (V == 0)
817 return 0;
818
819 D.destroy(); // Free old strdup'd memory...
820 return V;
821 }
822
823 // Check to make sure that "Ty" is an integral type, and that our
824 // value will fit into the specified type...
825 case ValID::ConstSIntVal: // Is it a constant pool reference??
826 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
827 error("Signed integral constant '" + itostr(D.ConstPool64) +
828 "' is invalid for type '" + Ty->getDescription() + "'");
829 }
830 return ConstantInt::get(Ty, D.ConstPool64);
831
832 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
833 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
834 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
835 error("Integral constant '" + utostr(D.UConstPool64) +
836 "' is invalid or out of range");
837 else // This is really a signed reference. Transmogrify.
838 return ConstantInt::get(Ty, D.ConstPool64);
839 } else
840 return ConstantInt::get(Ty, D.UConstPool64);
841
842 case ValID::ConstFPVal: // Is it a floating point const pool reference?
843 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
844 error("FP constant invalid for type");
845 return ConstantFP::get(Ty, D.ConstPoolFP);
846
847 case ValID::ConstNullVal: // Is it a null value?
848 if (!isa<PointerType>(Ty))
849 error("Cannot create a a non pointer null");
850 return ConstantPointerNull::get(cast<PointerType>(Ty));
851
852 case ValID::ConstUndefVal: // Is it an undef value?
853 return UndefValue::get(Ty);
854
855 case ValID::ConstZeroVal: // Is it a zero value?
856 return Constant::getNullValue(Ty);
857
858 case ValID::ConstantVal: // Fully resolved constant?
859 if (D.ConstantValue->getType() != Ty)
860 error("Constant expression type different from required type");
861 return D.ConstantValue;
862
863 case ValID::InlineAsmVal: { // Inline asm expression
864 const PointerType *PTy = dyn_cast<PointerType>(Ty);
865 const FunctionType *FTy =
866 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
867 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
868 error("Invalid type for asm constraint string");
869 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
870 D.IAD->HasSideEffects);
871 D.destroy(); // Free InlineAsmDescriptor.
872 return IA;
873 }
874 default:
875 assert(0 && "Unhandled case");
876 return 0;
877 } // End of switch
878
879 assert(0 && "Unhandled case");
880 return 0;
881}
882
883// getVal - This function is identical to getExistingValue, except that if a
884// value is not already defined, it "improvises" by creating a placeholder var
885// that looks and acts just like the requested variable. When the value is
886// defined later, all uses of the placeholder variable are replaced with the
887// real thing.
888//
889static Value *getVal(const Type *Ty, const ValID &ID) {
890 if (Ty == Type::LabelTy)
891 error("Cannot use a basic block here");
892
893 // See if the value has already been defined.
894 Value *V = getExistingValue(Ty, ID);
895 if (V) return V;
896
897 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
898 error("Invalid use of a composite type");
899
900 // If we reached here, we referenced either a symbol that we don't know about
901 // or an id number that hasn't been read yet. We may be referencing something
902 // forward, so just create an entry to be resolved later and get to it...
903 assert(!isa<SignedType>(Ty) && "Can't create value with SignedType");
904 V = new Argument(Ty);
905
906 // Remember where this forward reference came from. FIXME, shouldn't we try
907 // to recycle these things??
908 CurModule.PlaceHolderInfo.insert(
909 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
910
911 if (inFunctionScope())
912 InsertValue(V, CurFun.LateResolveValues);
913 else
914 InsertValue(V, CurModule.LateResolveValues);
915 return V;
916}
917
918/// getBBVal - This is used for two purposes:
919/// * If isDefinition is true, a new basic block with the specified ID is being
920/// defined.
921/// * If isDefinition is true, this is a reference to a basic block, which may
922/// or may not be a forward reference.
923///
924static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
925 assert(inFunctionScope() && "Can't get basic block at global scope");
926
927 std::string Name;
928 BasicBlock *BB = 0;
929 switch (ID.Type) {
930 default:
931 error("Illegal label reference " + ID.getName());
932 break;
933 case ValID::NumberVal: // Is it a numbered definition?
934 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
935 CurFun.NumberedBlocks.resize(ID.Num+1);
936 BB = CurFun.NumberedBlocks[ID.Num];
937 break;
938 case ValID::NameVal: // Is it a named definition?
939 Name = ID.Name;
940 if (Value *N = CurFun.CurrentFunction->
941 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
942 if (N->getType() != Type::LabelTy)
943 error("Name '" + Name + "' does not refer to a BasicBlock");
944 BB = cast<BasicBlock>(N);
945 }
946 break;
947 }
948
949 // See if the block has already been defined.
950 if (BB) {
951 // If this is the definition of the block, make sure the existing value was
952 // just a forward reference. If it was a forward reference, there will be
953 // an entry for it in the PlaceHolderInfo map.
954 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
955 // The existing value was a definition, not a forward reference.
956 error("Redefinition of label " + ID.getName());
957
958 ID.destroy(); // Free strdup'd memory.
959 return BB;
960 }
961
962 // Otherwise this block has not been seen before.
963 BB = new BasicBlock("", CurFun.CurrentFunction);
964 if (ID.Type == ValID::NameVal) {
965 BB->setName(ID.Name);
966 } else {
967 CurFun.NumberedBlocks[ID.Num] = BB;
968 }
969
970 // If this is not a definition, keep track of it so we can use it as a forward
971 // reference.
972 if (!isDefinition) {
973 // Remember where this forward reference came from.
974 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
975 } else {
976 // The forward declaration could have been inserted anywhere in the
977 // function: insert it into the correct place now.
978 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
979 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
980 }
981 ID.destroy();
982 return BB;
983}
984
985
986//===----------------------------------------------------------------------===//
987// Code to handle forward references in instructions
988//===----------------------------------------------------------------------===//
989//
990// This code handles the late binding needed with statements that reference
991// values not defined yet... for example, a forward branch, or the PHI node for
992// a loop body.
993//
994// This keeps a table (CurFun.LateResolveValues) of all such forward references
995// and back patchs after we are done.
996//
997
998// ResolveDefinitions - If we could not resolve some defs at parsing
999// time (forward branches, phi functions for loops, etc...) resolve the
1000// defs now...
1001//
1002static void
1003ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
1004 std::map<const Type*,ValueList> *FutureLateResolvers) {
1005 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1006 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
1007 E = LateResolvers.end(); LRI != E; ++LRI) {
1008 ValueList &List = LRI->second;
1009 while (!List.empty()) {
1010 Value *V = List.back();
1011 List.pop_back();
1012
1013 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1014 CurModule.PlaceHolderInfo.find(V);
1015 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
1016
1017 ValID &DID = PHI->second.first;
1018
1019 Value *TheRealValue = getExistingValue(LRI->first, DID);
1020 if (TheRealValue) {
1021 V->replaceAllUsesWith(TheRealValue);
1022 delete V;
1023 CurModule.PlaceHolderInfo.erase(PHI);
1024 } else if (FutureLateResolvers) {
1025 // Functions have their unresolved items forwarded to the module late
1026 // resolver table
1027 InsertValue(V, *FutureLateResolvers);
1028 } else {
1029 if (DID.Type == ValID::NameVal) {
1030 error("Reference to an invalid definition: '" +DID.getName()+
1031 "' of type '" + V->getType()->getDescription() + "'",
1032 PHI->second.second);
1033 return;
1034 } else {
1035 error("Reference to an invalid definition: #" +
1036 itostr(DID.Num) + " of type '" +
1037 V->getType()->getDescription() + "'", PHI->second.second);
1038 return;
1039 }
1040 }
1041 }
1042 }
1043
1044 LateResolvers.clear();
1045}
1046
1047// ResolveTypeTo - A brand new type was just declared. This means that (if
1048// name is not null) things referencing Name can be resolved. Otherwise, things
1049// refering to the number can be resolved. Do this now.
1050//
1051static void ResolveTypeTo(char *Name, const Type *ToTy) {
1052 ValID D;
1053 if (Name) D = ValID::create(Name);
1054 else D = ValID::create((int)CurModule.Types.size());
1055
1056 std::map<ValID, PATypeHolder>::iterator I =
1057 CurModule.LateResolveTypes.find(D);
1058 if (I != CurModule.LateResolveTypes.end()) {
1059 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1060 CurModule.LateResolveTypes.erase(I);
1061 }
1062}
1063
1064static std::string makeNameUnique(const std::string& Name) {
1065 static unsigned UniqueNameCounter = 1;
1066 std::string Result(Name);
1067 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
1068 return Result;
1069}
1070
1071// setValueName - Set the specified value to the name given. The name may be
1072// null potentially, in which case this is a noop. The string passed in is
1073// assumed to be a malloc'd string buffer, and is free'd by this function.
1074//
1075static void setValueName(Value *V, char *NameStr) {
1076 if (NameStr) {
1077 std::string Name(NameStr); // Copy string
1078 free(NameStr); // Free old string
1079
1080 if (V->getType() == Type::VoidTy) {
1081 error("Can't assign name '" + Name + "' to value with void type");
1082 return;
1083 }
1084
1085 assert(!isa<SignedType>(V->getType()) && "Shouldn't have SignedType Value");
1086 assert(inFunctionScope() && "Must be in function scope");
1087
1088 // Search the function's symbol table for an existing value of this name
1089 Value* Existing = 0;
1090 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1091 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
1092 for ( ; PI != PE; ++PI) {
1093 SymbolTable::value_const_iterator VI = PI->second.find(Name);
1094 if (VI != PI->second.end()) {
1095 Existing = VI->second;
1096 break;
1097 }
1098 }
1099 if (Existing) {
1100 if (Existing->getType() == V->getType()) {
1101 // The type of the Existing value and the new one are the same. This
1102 // is probably a type plane collapsing error. If the types involved
1103 // are both integer, just rename it. Otherwise it
1104 // is a redefinition error.
1105 if (!Existing->getType()->isInteger()) {
1106 error("Redefinition of value named '" + Name + "' in the '" +
1107 V->getType()->getDescription() + "' type plane");
1108 return;
1109 }
1110 }
1111 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1112 // function, regardless of Type. Previously re-use of names was okay as
1113 // long as they were distinct types. With type planes collapsing because
1114 // of the signedness change and because of PR411, this can no longer be
1115 // supported. We must search the entire symbol table for a conflicting
1116 // name and make the name unique. No warning is needed as this can't
1117 // cause a problem.
1118 std::string NewName = makeNameUnique(Name);
1119 // We're changing the name but it will probably be used by other
1120 // instructions as operands later on. Consequently we have to retain
1121 // a mapping of the renaming that we're doing.
1122 RenameMapKey Key = std::make_pair(Name,V->getType());
1123 CurFun.RenameMap[Key] = NewName;
1124 Name = NewName;
1125 }
1126
1127 // Set the name.
1128 V->setName(Name);
1129 }
1130}
1131
1132/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1133/// this is a declaration, otherwise it is a definition.
1134static GlobalVariable *
1135ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1136 bool isConstantGlobal, const Type *Ty,
1137 Constant *Initializer) {
1138 if (isa<FunctionType>(Ty))
1139 error("Cannot declare global vars of function type");
1140
1141 const PointerType *PTy = PointerType::get(Ty);
1142
1143 std::string Name;
1144 if (NameStr) {
1145 Name = NameStr; // Copy string
1146 free(NameStr); // Free old string
1147 }
1148
1149 // See if this global value was forward referenced. If so, recycle the
1150 // object.
1151 ValID ID;
1152 if (!Name.empty()) {
1153 ID = ValID::create((char*)Name.c_str());
1154 } else {
1155 ID = ValID::create((int)CurModule.Values[PTy].size());
1156 }
1157
1158 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1159 // Move the global to the end of the list, from whereever it was
1160 // previously inserted.
1161 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1162 CurModule.CurrentModule->getGlobalList().remove(GV);
1163 CurModule.CurrentModule->getGlobalList().push_back(GV);
1164 GV->setInitializer(Initializer);
1165 GV->setLinkage(Linkage);
1166 GV->setConstant(isConstantGlobal);
1167 InsertValue(GV, CurModule.Values);
1168 return GV;
1169 }
1170
1171 // If this global has a name, check to see if there is already a definition
1172 // of this global in the module and emit warnings if there are conflicts.
1173 if (!Name.empty()) {
1174 // The global has a name. See if there's an existing one of the same name.
1175 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1176 // We found an existing global ov the same name. This isn't allowed
1177 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1178 // can at least compile. This can happen because of type planes
1179 // There is alread a global of the same name which means there is a
1180 // conflict. Let's see what we can do about it.
1181 std::string NewName(makeNameUnique(Name));
1182 if (Linkage == GlobalValue::InternalLinkage) {
1183 // The linkage type is internal so just warn about the rename without
1184 // invoking "scarey language" about linkage failures. GVars with
1185 // InternalLinkage can be renamed at will.
1186 warning("Global variable '" + Name + "' was renamed to '"+
1187 NewName + "'");
1188 } else {
1189 // The linkage of this gval is external so we can't reliably rename
1190 // it because it could potentially create a linking problem.
1191 // However, we can't leave the name conflict in the output either or
1192 // it won't assemble with LLVM 2.0. So, all we can do is rename
1193 // this one to something unique and emit a warning about the problem.
1194 warning("Renaming global variable '" + Name + "' to '" + NewName +
1195 "' may cause linkage errors");
1196 }
1197
1198 // Put the renaming in the global rename map
1199 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1200 CurModule.RenameMap[Key] = NewName;
1201
1202 // Rename it
1203 Name = NewName;
1204 }
1205 }
1206
1207 // Otherwise there is no existing GV to use, create one now.
1208 GlobalVariable *GV =
1209 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1210 CurModule.CurrentModule);
1211 InsertValue(GV, CurModule.Values);
1212 return GV;
1213}
1214
1215// setTypeName - Set the specified type to the name given. The name may be
1216// null potentially, in which case this is a noop. The string passed in is
1217// assumed to be a malloc'd string buffer, and is freed by this function.
1218//
1219// This function returns true if the type has already been defined, but is
1220// allowed to be redefined in the specified context. If the name is a new name
1221// for the type plane, it is inserted and false is returned.
1222static bool setTypeName(const Type *T, char *NameStr) {
1223 assert(!inFunctionScope() && "Can't give types function-local names");
1224 if (NameStr == 0) return false;
1225
1226 std::string Name(NameStr); // Copy string
1227 free(NameStr); // Free old string
1228
1229 // We don't allow assigning names to void type
1230 if (T == Type::VoidTy) {
1231 error("Can't assign name '" + Name + "' to the void type");
1232 return false;
1233 }
1234
1235 // Set the type name, checking for conflicts as we do so.
1236 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1237
1238 if (AlreadyExists) { // Inserting a name that is already defined???
1239 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1240 assert(Existing && "Conflict but no matching type?");
1241
1242 // There is only one case where this is allowed: when we are refining an
1243 // opaque type. In this case, Existing will be an opaque type.
1244 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1245 // We ARE replacing an opaque type!
1246 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1247 return true;
1248 }
1249
1250 // Otherwise, this is an attempt to redefine a type. That's okay if
1251 // the redefinition is identical to the original. This will be so if
1252 // Existing and T point to the same Type object. In this one case we
1253 // allow the equivalent redefinition.
1254 if (Existing == T) return true; // Yes, it's equal.
1255
1256 // Any other kind of (non-equivalent) redefinition is an error.
1257 error("Redefinition of type named '" + Name + "' in the '" +
1258 T->getDescription() + "' type plane");
1259 }
1260
1261 return false;
1262}
1263
1264//===----------------------------------------------------------------------===//
1265// Code for handling upreferences in type names...
1266//
1267
1268// TypeContains - Returns true if Ty directly contains E in it.
1269//
1270static bool TypeContains(const Type *Ty, const Type *E) {
1271 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1272 E) != Ty->subtype_end();
1273}
1274
1275namespace {
1276 struct UpRefRecord {
1277 // NestingLevel - The number of nesting levels that need to be popped before
1278 // this type is resolved.
1279 unsigned NestingLevel;
1280
1281 // LastContainedTy - This is the type at the current binding level for the
1282 // type. Every time we reduce the nesting level, this gets updated.
1283 const Type *LastContainedTy;
1284
1285 // UpRefTy - This is the actual opaque type that the upreference is
1286 // represented with.
1287 OpaqueType *UpRefTy;
1288
1289 UpRefRecord(unsigned NL, OpaqueType *URTy)
1290 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1291 };
1292}
1293
1294// UpRefs - A list of the outstanding upreferences that need to be resolved.
1295static std::vector<UpRefRecord> UpRefs;
1296
1297/// HandleUpRefs - Every time we finish a new layer of types, this function is
1298/// called. It loops through the UpRefs vector, which is a list of the
1299/// currently active types. For each type, if the up reference is contained in
1300/// the newly completed type, we decrement the level count. When the level
1301/// count reaches zero, the upreferenced type is the type that is passed in:
1302/// thus we can complete the cycle.
1303///
1304static PATypeHolder HandleUpRefs(const Type *ty) {
1305 // If Ty isn't abstract, or if there are no up-references in it, then there is
1306 // nothing to resolve here.
1307 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1308
1309 PATypeHolder Ty(ty);
1310 UR_OUT("Type '" << Ty->getDescription() <<
1311 "' newly formed. Resolving upreferences.\n" <<
1312 UpRefs.size() << " upreferences active!\n");
1313
1314 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1315 // to zero), we resolve them all together before we resolve them to Ty. At
1316 // the end of the loop, if there is anything to resolve to Ty, it will be in
1317 // this variable.
1318 OpaqueType *TypeToResolve = 0;
1319
1320 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1321 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1322 << UpRefs[i].second->getDescription() << ") = "
1323 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1324 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1325 // Decrement level of upreference
1326 unsigned Level = --UpRefs[i].NestingLevel;
1327 UpRefs[i].LastContainedTy = Ty;
1328 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1329 if (Level == 0) { // Upreference should be resolved!
1330 if (!TypeToResolve) {
1331 TypeToResolve = UpRefs[i].UpRefTy;
1332 } else {
1333 UR_OUT(" * Resolving upreference for "
1334 << UpRefs[i].second->getDescription() << "\n";
1335 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1336 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1337 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1338 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1339 }
1340 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1341 --i; // Do not skip the next element...
1342 }
1343 }
1344 }
1345
1346 if (TypeToResolve) {
1347 UR_OUT(" * Resolving upreference for "
1348 << UpRefs[i].second->getDescription() << "\n";
1349 std::string OldName = TypeToResolve->getDescription());
1350 TypeToResolve->refineAbstractTypeTo(Ty);
1351 }
1352
1353 return Ty;
1354}
1355
1356static inline Instruction::TermOps
1357getTermOp(TermOps op) {
1358 switch (op) {
1359 default : assert(0 && "Invalid OldTermOp");
1360 case RetOp : return Instruction::Ret;
1361 case BrOp : return Instruction::Br;
1362 case SwitchOp : return Instruction::Switch;
1363 case InvokeOp : return Instruction::Invoke;
1364 case UnwindOp : return Instruction::Unwind;
1365 case UnreachableOp: return Instruction::Unreachable;
1366 }
1367}
1368
1369static inline Instruction::BinaryOps
1370getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1371 switch (op) {
1372 default : assert(0 && "Invalid OldBinaryOps");
1373 case SetEQ :
1374 case SetNE :
1375 case SetLE :
1376 case SetGE :
1377 case SetLT :
1378 case SetGT : assert(0 && "Should use getCompareOp");
1379 case AddOp : return Instruction::Add;
1380 case SubOp : return Instruction::Sub;
1381 case MulOp : return Instruction::Mul;
1382 case DivOp : {
1383 // This is an obsolete instruction so we must upgrade it based on the
1384 // types of its operands.
1385 bool isFP = Ty->isFloatingPoint();
1386 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1387 // If its a packed type we want to use the element type
1388 isFP = PTy->getElementType()->isFloatingPoint();
1389 if (isFP)
1390 return Instruction::FDiv;
1391 else if (Sign == Signed)
1392 return Instruction::SDiv;
1393 return Instruction::UDiv;
1394 }
1395 case UDivOp : return Instruction::UDiv;
1396 case SDivOp : return Instruction::SDiv;
1397 case FDivOp : return Instruction::FDiv;
1398 case RemOp : {
1399 // This is an obsolete instruction so we must upgrade it based on the
1400 // types of its operands.
1401 bool isFP = Ty->isFloatingPoint();
1402 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1403 // If its a packed type we want to use the element type
1404 isFP = PTy->getElementType()->isFloatingPoint();
1405 // Select correct opcode
1406 if (isFP)
1407 return Instruction::FRem;
1408 else if (Sign == Signed)
1409 return Instruction::SRem;
1410 return Instruction::URem;
1411 }
1412 case URemOp : return Instruction::URem;
1413 case SRemOp : return Instruction::SRem;
1414 case FRemOp : return Instruction::FRem;
1415 case AndOp : return Instruction::And;
1416 case OrOp : return Instruction::Or;
1417 case XorOp : return Instruction::Xor;
1418 }
1419}
1420
1421static inline Instruction::OtherOps
1422getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1423 Signedness Sign) {
1424 bool isSigned = Sign == Signed;
1425 bool isFP = Ty->isFloatingPoint();
1426 switch (op) {
1427 default : assert(0 && "Invalid OldSetCC");
1428 case SetEQ :
1429 if (isFP) {
1430 predicate = FCmpInst::FCMP_OEQ;
1431 return Instruction::FCmp;
1432 } else {
1433 predicate = ICmpInst::ICMP_EQ;
1434 return Instruction::ICmp;
1435 }
1436 case SetNE :
1437 if (isFP) {
1438 predicate = FCmpInst::FCMP_UNE;
1439 return Instruction::FCmp;
1440 } else {
1441 predicate = ICmpInst::ICMP_NE;
1442 return Instruction::ICmp;
1443 }
1444 case SetLE :
1445 if (isFP) {
1446 predicate = FCmpInst::FCMP_OLE;
1447 return Instruction::FCmp;
1448 } else {
1449 if (isSigned)
1450 predicate = ICmpInst::ICMP_SLE;
1451 else
1452 predicate = ICmpInst::ICMP_ULE;
1453 return Instruction::ICmp;
1454 }
1455 case SetGE :
1456 if (isFP) {
1457 predicate = FCmpInst::FCMP_OGE;
1458 return Instruction::FCmp;
1459 } else {
1460 if (isSigned)
1461 predicate = ICmpInst::ICMP_SGE;
1462 else
1463 predicate = ICmpInst::ICMP_UGE;
1464 return Instruction::ICmp;
1465 }
1466 case SetLT :
1467 if (isFP) {
1468 predicate = FCmpInst::FCMP_OLT;
1469 return Instruction::FCmp;
1470 } else {
1471 if (isSigned)
1472 predicate = ICmpInst::ICMP_SLT;
1473 else
1474 predicate = ICmpInst::ICMP_ULT;
1475 return Instruction::ICmp;
1476 }
1477 case SetGT :
1478 if (isFP) {
1479 predicate = FCmpInst::FCMP_OGT;
1480 return Instruction::FCmp;
1481 } else {
1482 if (isSigned)
1483 predicate = ICmpInst::ICMP_SGT;
1484 else
1485 predicate = ICmpInst::ICMP_UGT;
1486 return Instruction::ICmp;
1487 }
1488 }
1489}
1490
1491static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1492 switch (op) {
1493 default : assert(0 && "Invalid OldMemoryOps");
1494 case MallocOp : return Instruction::Malloc;
1495 case FreeOp : return Instruction::Free;
1496 case AllocaOp : return Instruction::Alloca;
1497 case LoadOp : return Instruction::Load;
1498 case StoreOp : return Instruction::Store;
1499 case GetElementPtrOp : return Instruction::GetElementPtr;
1500 }
1501}
1502
1503static inline Instruction::OtherOps
1504getOtherOp(OtherOps op, Signedness Sign) {
1505 switch (op) {
1506 default : assert(0 && "Invalid OldOtherOps");
1507 case PHIOp : return Instruction::PHI;
1508 case CallOp : return Instruction::Call;
1509 case ShlOp : return Instruction::Shl;
1510 case ShrOp :
1511 if (Sign == Signed)
1512 return Instruction::AShr;
1513 return Instruction::LShr;
1514 case SelectOp : return Instruction::Select;
1515 case UserOp1 : return Instruction::UserOp1;
1516 case UserOp2 : return Instruction::UserOp2;
1517 case VAArg : return Instruction::VAArg;
1518 case ExtractElementOp : return Instruction::ExtractElement;
1519 case InsertElementOp : return Instruction::InsertElement;
1520 case ShuffleVectorOp : return Instruction::ShuffleVector;
1521 case ICmpOp : return Instruction::ICmp;
1522 case FCmpOp : return Instruction::FCmp;
1523 case LShrOp : return Instruction::LShr;
1524 case AShrOp : return Instruction::AShr;
1525 };
1526}
1527
1528static inline Value*
1529getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1530 Signedness DstSign, bool ForceInstruction = false) {
1531 Instruction::CastOps Opcode;
1532 const Type* SrcTy = Src->getType();
1533 if (op == CastOp) {
1534 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1535 // fp -> ptr cast is no longer supported but we must upgrade this
1536 // by doing a double cast: fp -> int -> ptr
1537 SrcTy = Type::Int64Ty;
1538 Opcode = Instruction::IntToPtr;
1539 if (isa<Constant>(Src)) {
1540 Src = ConstantExpr::getCast(Instruction::FPToUI,
1541 cast<Constant>(Src), SrcTy);
1542 } else {
1543 std::string NewName(makeNameUnique(Src->getName()));
1544 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1545 }
1546 } else if (isa<IntegerType>(DstTy) &&
1547 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1548 // cast type %x to bool was previously defined as setne type %x, null
1549 // The cast semantic is now to truncate, not compare so we must retain
1550 // the original intent by replacing the cast with a setne
1551 Constant* Null = Constant::getNullValue(SrcTy);
1552 Instruction::OtherOps Opcode = Instruction::ICmp;
1553 unsigned short predicate = ICmpInst::ICMP_NE;
1554 if (SrcTy->isFloatingPoint()) {
1555 Opcode = Instruction::FCmp;
1556 predicate = FCmpInst::FCMP_ONE;
1557 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1558 error("Invalid cast to bool");
1559 }
1560 if (isa<Constant>(Src) && !ForceInstruction)
1561 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1562 else
1563 return CmpInst::create(Opcode, predicate, Src, Null);
1564 }
1565 // Determine the opcode to use by calling CastInst::getCastOpcode
1566 Opcode =
1567 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1568
1569 } else switch (op) {
1570 default: assert(0 && "Invalid cast token");
1571 case TruncOp: Opcode = Instruction::Trunc; break;
1572 case ZExtOp: Opcode = Instruction::ZExt; break;
1573 case SExtOp: Opcode = Instruction::SExt; break;
1574 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1575 case FPExtOp: Opcode = Instruction::FPExt; break;
1576 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1577 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1578 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1579 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1580 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1581 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1582 case BitCastOp: Opcode = Instruction::BitCast; break;
1583 }
1584
1585 if (isa<Constant>(Src) && !ForceInstruction)
1586 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1587 return CastInst::create(Opcode, Src, DstTy);
1588}
1589
1590static Instruction *
1591upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1592 std::vector<Value*>& Args) {
1593
1594 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1595 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1596 if (Args.size() != 2)
1597 error("Invalid prototype for " + Name + " prototype");
1598 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1599 } else {
1600 static unsigned upgradeCount = 1;
1601 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1602 std::vector<const Type*> Params;
1603 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1604 if (Args.size() != 1)
1605 error("Invalid prototype for " + Name + " prototype");
1606 Params.push_back(PtrTy);
1607 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1608 const PointerType *PFTy = PointerType::get(FTy);
1609 Value* Func = getVal(PFTy, ID);
1610 std::string InstName("va_upgrade");
1611 InstName += llvm::utostr(upgradeCount++);
1612 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1613 return new CallInst(Func, Args);
1614 } else if (Name == "llvm.va_copy") {
1615 if (Args.size() != 2)
1616 error("Invalid prototype for " + Name + " prototype");
1617 Params.push_back(PtrTy);
1618 Params.push_back(PtrTy);
1619 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1620 const PointerType *PFTy = PointerType::get(FTy);
1621 Value* Func = getVal(PFTy, ID);
1622 std::string InstName0("va_upgrade");
1623 InstName0 += llvm::utostr(upgradeCount++);
1624 std::string InstName1("va_upgrade");
1625 InstName1 += llvm::utostr(upgradeCount++);
1626 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1627 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1628 return new CallInst(Func, Args);
1629 }
1630 }
1631 return 0;
1632}
1633
1634const Type* upgradeGEPIndices(const Type* PTy,
1635 std::vector<ValueInfo> *Indices,
1636 std::vector<Value*> &VIndices,
1637 std::vector<Constant*> *CIndices = 0) {
1638 // Traverse the indices with a gep_type_iterator so we can build the list
1639 // of constant and value indices for use later. Also perform upgrades
1640 VIndices.clear();
1641 if (CIndices) CIndices->clear();
1642 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1643 VIndices.push_back((*Indices)[i].V);
1644 generic_gep_type_iterator<std::vector<Value*>::iterator>
1645 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1646 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1647 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1648 Value *Index = VIndices[i];
1649 if (CIndices && !isa<Constant>(Index))
1650 error("Indices to constant getelementptr must be constants");
1651 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1652 // struct indices to i32 struct indices with ZExt for compatibility.
1653 else if (isa<StructType>(*GTI)) { // Only change struct indices
1654 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1655 if (CUI->getType()->getBitWidth() == 8)
1656 Index =
1657 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1658 } else {
1659 // Make sure that unsigned SequentialType indices are zext'd to
1660 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1661 // all indices for SequentialType elements. We must retain the same
1662 // semantic (zext) for unsigned types.
1663 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
1664 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned)
1665 if (CIndices)
1666 Index = ConstantExpr::getCast(Instruction::ZExt,
1667 cast<Constant>(Index), Type::Int64Ty);
1668 else
1669 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1670 "gep_upgrade", CurBB);
1671 }
1672 // Add to the CIndices list, if requested.
1673 if (CIndices)
1674 CIndices->push_back(cast<Constant>(Index));
1675 }
1676
1677 const Type *IdxTy =
1678 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1679 if (!IdxTy)
1680 error("Index list invalid for constant getelementptr");
1681 return IdxTy;
1682}
1683
1684Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1685 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001686{
1687 Upgradelineno = 1;
1688 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001689 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001690 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001691 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001692 ObsoleteVarArgs = false;
1693 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001694
Reid Spencer950bf602007-01-26 08:19:09 +00001695 CurModule.CurrentModule = new Module(CurFilename);
1696
1697 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001698 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001699 if (ParserResult)
1700 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001701 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001702 return 0;
1703 }
1704
Reid Spencer950bf602007-01-26 08:19:09 +00001705 // Check to make sure that parsing produced a result
1706 if (!ParserResult) {
1707 std::cerr << "llvm-upgrade: no parse result.\n";
1708 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001709 }
1710
Reid Spencer950bf602007-01-26 08:19:09 +00001711 // Reset ParserResult variable while saving its value for the result.
1712 Module *Result = ParserResult;
1713 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001714
Reid Spencer950bf602007-01-26 08:19:09 +00001715 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001716 {
Reid Spencer950bf602007-01-26 08:19:09 +00001717 Function* F;
1718 if ((F = Result->getNamedFunction("llvm.va_start"))
1719 && F->getFunctionType()->getNumParams() == 0)
1720 ObsoleteVarArgs = true;
1721 if((F = Result->getNamedFunction("llvm.va_copy"))
1722 && F->getFunctionType()->getNumParams() == 1)
1723 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001724 }
Reid Spencer319a7302007-01-05 17:20:02 +00001725
Reid Spencer950bf602007-01-26 08:19:09 +00001726 if (ObsoleteVarArgs && NewVarArgs) {
1727 error("This file is corrupt: it uses both new and old style varargs");
1728 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001729 }
Reid Spencer319a7302007-01-05 17:20:02 +00001730
Reid Spencer950bf602007-01-26 08:19:09 +00001731 if(ObsoleteVarArgs) {
1732 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1733 if (F->arg_size() != 0) {
1734 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001735 return 0;
1736 }
Reid Spencer950bf602007-01-26 08:19:09 +00001737
1738 //foo = va_start()
1739 // ->
1740 //bar = alloca typeof(foo)
1741 //va_start(bar)
1742 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001743
Reid Spencer950bf602007-01-26 08:19:09 +00001744 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1745 const Type* ArgTy = F->getFunctionType()->getReturnType();
1746 const Type* ArgTyPtr = PointerType::get(ArgTy);
1747 Function* NF = cast<Function>(Result->getOrInsertFunction(
1748 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1749
1750 while (!F->use_empty()) {
1751 CallInst* CI = cast<CallInst>(F->use_back());
1752 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1753 new CallInst(NF, bar, "", CI);
1754 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1755 CI->replaceAllUsesWith(foo);
1756 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001757 }
Reid Spencer950bf602007-01-26 08:19:09 +00001758 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001759 }
Reid Spencer950bf602007-01-26 08:19:09 +00001760
1761 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1762 if(F->arg_size() != 1) {
1763 error("Obsolete va_end takes 1 argument");
1764 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001765 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001766
Reid Spencer950bf602007-01-26 08:19:09 +00001767 //vaend foo
1768 // ->
1769 //bar = alloca 1 of typeof(foo)
1770 //vaend bar
1771 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1772 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1773 const Type* ArgTyPtr = PointerType::get(ArgTy);
1774 Function* NF = cast<Function>(Result->getOrInsertFunction(
1775 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001776
Reid Spencer950bf602007-01-26 08:19:09 +00001777 while (!F->use_empty()) {
1778 CallInst* CI = cast<CallInst>(F->use_back());
1779 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1780 new StoreInst(CI->getOperand(1), bar, CI);
1781 new CallInst(NF, bar, "", CI);
1782 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001783 }
Reid Spencer950bf602007-01-26 08:19:09 +00001784 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001785 }
Reid Spencer950bf602007-01-26 08:19:09 +00001786
1787 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1788 if(F->arg_size() != 1) {
1789 error("Obsolete va_copy takes 1 argument");
1790 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001791 }
Reid Spencer950bf602007-01-26 08:19:09 +00001792 //foo = vacopy(bar)
1793 // ->
1794 //a = alloca 1 of typeof(foo)
1795 //b = alloca 1 of typeof(foo)
1796 //store bar -> b
1797 //vacopy(a, b)
1798 //foo = load a
1799
1800 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1801 const Type* ArgTy = F->getFunctionType()->getReturnType();
1802 const Type* ArgTyPtr = PointerType::get(ArgTy);
1803 Function* NF = cast<Function>(Result->getOrInsertFunction(
1804 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001805
Reid Spencer950bf602007-01-26 08:19:09 +00001806 while (!F->use_empty()) {
1807 CallInst* CI = cast<CallInst>(F->use_back());
1808 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1809 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1810 new StoreInst(CI->getOperand(1), b, CI);
1811 new CallInst(NF, a, b, "", CI);
1812 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1813 CI->replaceAllUsesWith(foo);
1814 CI->getParent()->getInstList().erase(CI);
1815 }
1816 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001817 }
1818 }
1819
Reid Spencer52402b02007-01-02 05:45:11 +00001820 return Result;
1821}
1822
Reid Spencer950bf602007-01-26 08:19:09 +00001823} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001824
Reid Spencer950bf602007-01-26 08:19:09 +00001825using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001826
1827
Reid Spencer319a7302007-01-05 17:20:02 +00001828
1829/* Enabling traces. */
1830#ifndef YYDEBUG
1831# define YYDEBUG 0
1832#endif
1833
1834/* Enabling verbose error messages. */
1835#ifdef YYERROR_VERBOSE
1836# undef YYERROR_VERBOSE
1837# define YYERROR_VERBOSE 1
1838#else
1839# define YYERROR_VERBOSE 0
1840#endif
1841
Reid Spencer950bf602007-01-26 08:19:09 +00001842/* Enabling the token table. */
1843#ifndef YYTOKEN_TABLE
1844# define YYTOKEN_TABLE 0
1845#endif
1846
1847#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1848#line 1469 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
1849typedef union YYSTYPE {
1850 llvm::Module *ModuleVal;
1851 llvm::Function *FunctionVal;
1852 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1853 llvm::BasicBlock *BasicBlockVal;
1854 llvm::TerminatorInst *TermInstVal;
1855 llvm::InstrInfo InstVal;
1856 llvm::ConstInfo ConstVal;
1857 llvm::ValueInfo ValueVal;
1858 llvm::PATypeInfo TypeVal;
1859 llvm::TypeInfo PrimType;
1860 llvm::PHIListInfo PHIList;
1861 std::list<llvm::PATypeInfo> *TypeList;
1862 std::vector<llvm::ValueInfo> *ValueList;
1863 std::vector<llvm::ConstInfo> *ConstVector;
1864
1865
1866 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1867 // Represent the RHS of PHI node
1868 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1869
1870 llvm::GlobalValue::LinkageTypes Linkage;
1871 int64_t SInt64Val;
1872 uint64_t UInt64Val;
1873 int SIntVal;
1874 unsigned UIntVal;
1875 double FPVal;
1876 bool BoolVal;
1877
1878 char *StrVal; // This memory is strdup'd!
1879 llvm::ValID ValIDVal; // strdup'd memory maybe!
1880
1881 llvm::BinaryOps BinaryOpVal;
1882 llvm::TermOps TermOpVal;
1883 llvm::MemoryOps MemOpVal;
1884 llvm::OtherOps OtherOpVal;
1885 llvm::CastOps CastOpVal;
1886 llvm::ICmpInst::Predicate IPred;
1887 llvm::FCmpInst::Predicate FPred;
1888 llvm::Module::Endianness Endianness;
1889} YYSTYPE;
1890/* Line 196 of yacc.c. */
1891#line 1892 "UpgradeParser.tab.c"
1892# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1893# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001894# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001895#endif
1896
Reid Spencer950bf602007-01-26 08:19:09 +00001897
Reid Spencere7c3c602006-11-30 06:36:44 +00001898
Reid Spencer319a7302007-01-05 17:20:02 +00001899/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001900
1901
Reid Spencer950bf602007-01-26 08:19:09 +00001902/* Line 219 of yacc.c. */
1903#line 1904 "UpgradeParser.tab.c"
1904
1905#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1906# define YYSIZE_T __SIZE_TYPE__
1907#endif
1908#if ! defined (YYSIZE_T) && defined (size_t)
1909# define YYSIZE_T size_t
1910#endif
1911#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1912# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1913# define YYSIZE_T size_t
1914#endif
1915#if ! defined (YYSIZE_T)
1916# define YYSIZE_T unsigned int
1917#endif
1918
1919#ifndef YY_
1920# if YYENABLE_NLS
1921# if ENABLE_NLS
1922# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1923# define YY_(msgid) dgettext ("bison-runtime", msgid)
1924# endif
1925# endif
1926# ifndef YY_
1927# define YY_(msgid) msgid
1928# endif
1929#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001930
1931#if ! defined (yyoverflow) || YYERROR_VERBOSE
1932
1933/* The parser invokes alloca or malloc; define the necessary symbols. */
1934
Reid Spencer950bf602007-01-26 08:19:09 +00001935# ifdef YYSTACK_USE_ALLOCA
1936# if YYSTACK_USE_ALLOCA
1937# ifdef __GNUC__
1938# define YYSTACK_ALLOC __builtin_alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001939# else
Reid Spencer950bf602007-01-26 08:19:09 +00001940# define YYSTACK_ALLOC alloca
1941# if defined (__STDC__) || defined (__cplusplus)
1942# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1943# define YYINCLUDED_STDLIB_H
Reid Spencer319a7302007-01-05 17:20:02 +00001944# endif
1945# endif
1946# endif
1947# endif
1948
1949# ifdef YYSTACK_ALLOC
1950 /* Pacify GCC's `empty if-body' warning. */
1951# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00001952# ifndef YYSTACK_ALLOC_MAXIMUM
1953 /* The OS might guarantee only one guard page at the bottom of the stack,
1954 and a page size can be as small as 4096 bytes. So we cannot safely
1955 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1956 to allow for a few compiler-allocated temporary stack slots. */
1957# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Reid Spencer319a7302007-01-05 17:20:02 +00001958# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001959# else
1960# define YYSTACK_ALLOC YYMALLOC
1961# define YYSTACK_FREE YYFREE
1962# ifndef YYSTACK_ALLOC_MAXIMUM
1963# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1964# endif
1965# ifdef __cplusplus
1966extern "C" {
1967# endif
1968# ifndef YYMALLOC
1969# define YYMALLOC malloc
1970# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1971 && (defined (__STDC__) || defined (__cplusplus)))
1972void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1973# endif
1974# endif
1975# ifndef YYFREE
1976# define YYFREE free
1977# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1978 && (defined (__STDC__) || defined (__cplusplus)))
1979void free (void *); /* INFRINGES ON USER NAME SPACE */
1980# endif
1981# endif
1982# ifdef __cplusplus
1983}
1984# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001985# endif
1986#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1987
1988
1989#if (! defined (yyoverflow) \
1990 && (! defined (__cplusplus) \
Reid Spencer950bf602007-01-26 08:19:09 +00001991 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001992
1993/* A type that is properly aligned for any stack member. */
1994union yyalloc
1995{
Reid Spencer950bf602007-01-26 08:19:09 +00001996 short int yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001997 YYSTYPE yyvs;
1998 };
1999
2000/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00002001# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00002002
2003/* The size of an array large to enough to hold all stacks, each with
2004 N elements. */
2005# define YYSTACK_BYTES(N) \
Reid Spencer950bf602007-01-26 08:19:09 +00002006 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
2007 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00002008
2009/* Copy COUNT objects from FROM to TO. The source and destination do
2010 not overlap. */
2011# ifndef YYCOPY
Reid Spencer950bf602007-01-26 08:19:09 +00002012# if defined (__GNUC__) && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00002013# define YYCOPY(To, From, Count) \
2014 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2015# else
2016# define YYCOPY(To, From, Count) \
2017 do \
2018 { \
Reid Spencer950bf602007-01-26 08:19:09 +00002019 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00002020 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00002021 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00002022 } \
2023 while (0)
2024# endif
2025# endif
2026
2027/* Relocate STACK from its old location to the new one. The
2028 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2029 elements in the stack, and YYPTR gives the new location of the
2030 stack. Advance YYPTR to a properly aligned location for the next
2031 stack. */
2032# define YYSTACK_RELOCATE(Stack) \
2033 do \
2034 { \
2035 YYSIZE_T yynewbytes; \
2036 YYCOPY (&yyptr->Stack, Stack, yysize); \
2037 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00002038 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00002039 yyptr += yynewbytes / sizeof (*yyptr); \
2040 } \
2041 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00002042
2043#endif
2044
Reid Spencer319a7302007-01-05 17:20:02 +00002045#if defined (__STDC__) || defined (__cplusplus)
2046 typedef signed char yysigned_char;
Reid Spencere7c3c602006-11-30 06:36:44 +00002047#else
Reid Spencer950bf602007-01-26 08:19:09 +00002048 typedef short int yysigned_char;
Reid Spencere7c3c602006-11-30 06:36:44 +00002049#endif
2050
Reid Spencer319a7302007-01-05 17:20:02 +00002051/* YYFINAL -- State number of the termination state. */
2052#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00002053/* YYLAST -- Last index in YYTABLE. */
2054#define YYLAST 1712
Reid Spencer319a7302007-01-05 17:20:02 +00002055
2056/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002057#define YYNTOKENS 166
Reid Spencer319a7302007-01-05 17:20:02 +00002058/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002059#define YYNNTS 79
Reid Spencer319a7302007-01-05 17:20:02 +00002060/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00002061#define YYNRULES 308
Reid Spencer319a7302007-01-05 17:20:02 +00002062/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00002063#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00002064
2065/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2066#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00002067#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00002068
Reid Spencer950bf602007-01-26 08:19:09 +00002069#define YYTRANSLATE(YYX) \
2070 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00002071
2072/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2073static const unsigned char yytranslate[] =
2074{
2075 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2077 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002079 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002080 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002081 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002082 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002084 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002085 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2086 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002087 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002088 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2089 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2090 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2091 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2092 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2093 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2094 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2095 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2096 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2097 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2098 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2099 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2100 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2101 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2102 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2103 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2104 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2105 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2106 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2107 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2108 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2109 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2110 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2111 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2112 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2113 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2114 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002115 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002116};
2117
2118#if YYDEBUG
2119/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2120 YYRHS. */
Reid Spencer950bf602007-01-26 08:19:09 +00002121static const unsigned short int yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002122{
2123 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2124 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2125 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2126 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2127 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2128 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2129 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2130 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2131 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002132 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002133 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2134 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2135 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2136 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2137 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002138 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2139 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2140 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2141 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2142 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2143 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2144 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2145 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2146 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2147 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2148 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2149 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2150 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2151 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2152 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2153 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002154};
2155
2156/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Reid Spencer950bf602007-01-26 08:19:09 +00002157static const short int yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002158{
Reid Spencer950bf602007-01-26 08:19:09 +00002159 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002160 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2161 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2162 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2163 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
Reid Spencer950bf602007-01-26 08:19:09 +00002164 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2165 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2166 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2167 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2168 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2169 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2170 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2171 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2172 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2173 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2174 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2175 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2176 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2177 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2178 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2179 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2180 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2181 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002182 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002183 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2184 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2185 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2186 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2187 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2188 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2189 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2190 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2191 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2192 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2193 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2194 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2195 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2196 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2197 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2198 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2199 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2200 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2201 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2202 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2203 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2204 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2205 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2206 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2207 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2208 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2209 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2210 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2211 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2212 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2213 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2214 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2215 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2216 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2217 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2218 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2219 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2220 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2221 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2222 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2223 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2224 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2225 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2226 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2227 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2228 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2229 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2230 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2231 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2232 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2233 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2234 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2235 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2236 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2237 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2238 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2239 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2240 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2241 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2242 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2243 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2244 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2245 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2246 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2247 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2248 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2249 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2250 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2251 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2252 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2253 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2254 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2255 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002256};
2257
2258/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencer950bf602007-01-26 08:19:09 +00002259static const unsigned short int yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002260{
Reid Spencer950bf602007-01-26 08:19:09 +00002261 0, 1607, 1607, 1608, 1616, 1617, 1627, 1627, 1627, 1627,
2262 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1631, 1631, 1631,
2263 1635, 1635, 1635, 1635, 1635, 1635, 1639, 1639, 1640, 1640,
2264 1641, 1641, 1642, 1642, 1643, 1643, 1647, 1647, 1648, 1648,
2265 1649, 1649, 1650, 1650, 1651, 1651, 1652, 1652, 1653, 1653,
2266 1654, 1655, 1658, 1658, 1658, 1658, 1662, 1662, 1662, 1662,
2267 1662, 1662, 1662, 1663, 1663, 1663, 1663, 1663, 1663, 1669,
2268 1669, 1669, 1669, 1673, 1673, 1673, 1673, 1677, 1677, 1681,
2269 1681, 1686, 1689, 1694, 1695, 1696, 1697, 1698, 1699, 1700,
2270 1701, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1722,
2271 1723, 1731, 1732, 1740, 1749, 1750, 1757, 1758, 1762, 1766,
2272 1782, 1783, 1790, 1791, 1798, 1806, 1806, 1806, 1806, 1806,
2273 1806, 1806, 1807, 1807, 1807, 1807, 1807, 1812, 1816, 1820,
2274 1825, 1834, 1850, 1856, 1869, 1878, 1882, 1893, 1897, 1910,
2275 1914, 1921, 1922, 1928, 1935, 1947, 1977, 1990, 2013, 2041,
2276 2063, 2074, 2096, 2107, 2116, 2121, 2179, 2186, 2194, 2201,
2277 2208, 2212, 2216, 2225, 2240, 2253, 2262, 2290, 2303, 2312,
2278 2318, 2324, 2333, 2339, 2345, 2356, 2357, 2366, 2367, 2379,
2279 2388, 2389, 2390, 2391, 2392, 2408, 2428, 2430, 2432, 2432,
2280 2439, 2439, 2446, 2446, 2453, 2453, 2461, 2463, 2465, 2470,
2281 2484, 2485, 2489, 2492, 2500, 2504, 2511, 2515, 2519, 2523,
2282 2531, 2531, 2535, 2536, 2540, 2548, 2553, 2561, 2562, 2569,
2283 2576, 2580, 2686, 2686, 2690, 2700, 2700, 2704, 2708, 2710,
2284 2711, 2715, 2715, 2727, 2728, 2733, 2734, 2735, 2736, 2737,
2285 2738, 2739, 2740, 2741, 2762, 2765, 2780, 2781, 2786, 2786,
2286 2794, 2803, 2806, 2815, 2825, 2830, 2839, 2850, 2850, 2853,
2287 2856, 2859, 2863, 2869, 2884, 2890, 2941, 2944, 2950, 2960,
2288 2973, 3002, 3010, 3018, 3022, 3029, 3030, 3034, 3037, 3043,
2289 3060, 3076, 3090, 3102, 3114, 3125, 3134, 3143, 3152, 3159,
2290 3180, 3204, 3210, 3216, 3222, 3238, 3311, 3319, 3320, 3324,
2291 3325, 3329, 3335, 3341, 3347, 3353, 3360, 3372, 3386
Reid Spencer319a7302007-01-05 17:20:02 +00002292};
2293#endif
2294
Reid Spencer950bf602007-01-26 08:19:09 +00002295#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2296/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencer319a7302007-01-05 17:20:02 +00002297 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2298static const char *const yytname[] =
2299{
Reid Spencer950bf602007-01-26 08:19:09 +00002300 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2301 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2302 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2303 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2304 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2305 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2306 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2307 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2308 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2309 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2310 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2311 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2312 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2313 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2314 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2315 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2316 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2317 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2318 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2319 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2320 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2321 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2322 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2323 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2324 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2325 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2326 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2327 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2328 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2329 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2330 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2331 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2332 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2333 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2334 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2335 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2336 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2337 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2338 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002339 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002340};
2341#endif
2342
2343# ifdef YYPRINT
2344/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2345 token YYLEX-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002346static const unsigned short int yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002347{
2348 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2349 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2350 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2351 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2352 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2353 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2354 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2355 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2356 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2357 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2358 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2359 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2360 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2361 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2362 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002363 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2364 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002365};
2366# endif
2367
2368/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2369static const unsigned char yyr1[] =
2370{
Reid Spencer950bf602007-01-26 08:19:09 +00002371 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2372 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2373 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2374 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2375 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2376 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2377 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2378 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2379 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2380 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2381 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2382 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2383 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2384 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2385 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2386 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2387 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2388 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2389 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2390 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2391 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2392 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2393 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2394 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2395 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2396 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2397 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2398 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2399 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2400 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2401 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002402};
2403
2404/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2405static const unsigned char yyr2[] =
2406{
2407 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2415 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002416 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002417 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2420 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2421 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002422 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2423 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2424 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2425 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2426 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2427 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2428 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2429 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2430 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2431 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2432 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2433 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2434 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2435 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2436 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2437 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002438};
2439
2440/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2441 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2442 means the default is an error. */
Reid Spencer950bf602007-01-26 08:19:09 +00002443static const unsigned short int yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002444{
Reid Spencer950bf602007-01-26 08:19:09 +00002445 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2446 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2447 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2448 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2449 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2450 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2451 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2452 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2453 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2454 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2455 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2456 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2457 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2458 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2459 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2460 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2461 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2462 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2463 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2464 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2465 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2466 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2467 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2468 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2469 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2470 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2471 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2472 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2473 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002474 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002475 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2476 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002477 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002478 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2479 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2480 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2481 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2482 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2483 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2484 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2485 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2486 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2487 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2488 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2489 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2490 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2491 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2492 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2493 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2494 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2495 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2496 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2497 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2498 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2499 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2500 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2501 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2502 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2503 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2504 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2505 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002506};
2507
2508/* YYDEFGOTO[NTERM-NUM]. */
Reid Spencer950bf602007-01-26 08:19:09 +00002509static const short int yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002510{
Reid Spencer950bf602007-01-26 08:19:09 +00002511 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2512 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2513 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2514 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2515 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2516 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2517 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2518 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002519};
2520
2521/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2522 STATE-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002523#define YYPACT_NINF -508
2524static const short int yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002525{
Reid Spencer950bf602007-01-26 08:19:09 +00002526 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2527 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2528 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2529 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2530 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2531 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2532 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2533 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2534 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2535 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2536 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2537 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2538 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2539 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2540 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2541 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2542 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2543 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2544 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2545 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2546 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2547 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2548 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2549 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2550 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2551 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2552 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2553 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2554 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2555 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2556 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2557 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2558 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2559 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2560 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2561 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2562 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2563 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2564 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2565 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2566 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2567 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2568 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2569 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2570 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2571 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2572 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2573 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2574 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2575 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2576 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2577 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2578 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2579 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2580 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2581 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2582 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2583 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2584 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2585 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2586 898, 898, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002587};
2588
2589/* YYPGOTO[NTERM-NUM]. */
Reid Spencer950bf602007-01-26 08:19:09 +00002590static const short int yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002591{
Reid Spencer950bf602007-01-26 08:19:09 +00002592 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2593 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2594 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2595 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2596 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2597 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2598 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2599 -508, -508, 43, -22, -508, -508, 21, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002600};
2601
2602/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2603 positive, shift that token. If negative, reduce the rule which
2604 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002605 If YYTABLE_NINF, syntax error. */
2606#define YYTABLE_NINF -180
2607static const short int yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002608{
Reid Spencer950bf602007-01-26 08:19:09 +00002609 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2610 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2611 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2612 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2613 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2614 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2615 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2616 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2617 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2618 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2619 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2620 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2621 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2622 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2623 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2624 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2625 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2626 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2627 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2628 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2629 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2630 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2631 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2632 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2633 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2634 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2635 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2636 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2637 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2638 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2639 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2640 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2641 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2642 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2643 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2644 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2645 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2646 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2647 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2648 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2649 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2650 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2651 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2652 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2653 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2654 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2655 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2656 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2657 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2658 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2659 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2660 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2661 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2662 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2663 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2664 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2665 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2666 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2667 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2668 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2669 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2670 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2671 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2672 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2673 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2674 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2675 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2676 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2677 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2678 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2679 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2680 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2681 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2682 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2683 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2684 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2685 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2686 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2687 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2688 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2689 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2690 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2691 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
Reid Spencerc4d96252007-01-13 00:03:30 +00002692 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002693 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2694 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2695 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2696 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002697 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002698 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2699 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2700 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2701 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2702 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2703 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2704 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2706 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2707 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2708 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2709 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2710 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2711 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2712 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2713 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2714 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2715 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2716 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2717 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2718 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2719 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2720 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2721 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2722 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2723 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2724 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2725 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2726 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2727 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2728 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2729 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2730 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2731 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2732 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2733 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2734 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2735 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2736 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2737 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2738 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2739 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2740 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2741 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2742 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2743 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2744 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2745 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2746 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2747 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2748 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2749 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2750 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2751 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2752 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2753 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2754 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2755 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2756 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2757 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2758 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2759 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2760 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2761 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2762 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002763 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2764 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002765 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2766 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2767 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2768 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002769 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002770 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2771 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2772 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2773 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2774 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2775 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2776 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2777 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2778 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2779 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2780 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002781};
2782
Reid Spencer950bf602007-01-26 08:19:09 +00002783static const short int yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002784{
Reid Spencer950bf602007-01-26 08:19:09 +00002785 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2786 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2787 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2788 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2789 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2790 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2791 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2792 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2793 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2794 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2795 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2796 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2797 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2798 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2799 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2800 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2801 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2802 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2803 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2804 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2805 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2806 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2807 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2808 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2809 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2810 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2811 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2812 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2813 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2814 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2815 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2816 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2817 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2818 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2819 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2820 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2821 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2822 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2823 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2824 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2825 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2826 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2827 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2828 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2829 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2830 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2831 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2832 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2833 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2834 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2835 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2836 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
Reid Spencerc4d96252007-01-13 00:03:30 +00002837 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
Reid Spencer950bf602007-01-26 08:19:09 +00002838 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2839 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2840 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2841 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2842 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2843 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2844 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2845 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2846 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2847 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2848 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2849 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2850 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2851 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2852 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2853 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2854 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2855 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2856 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2857 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2858 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2859 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2860 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2861 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2862 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2863 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2864 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2865 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2866 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2867 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2868 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2869 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2870 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2871 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2872 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2873 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2874 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2875 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2876 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2877 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2878 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2879 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2880 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2881 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2882 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2883 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2884 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2885 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2886 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2887 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2888 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2889 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2890 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2891 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2892 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2893 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2894 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2895 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2896 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2897 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2898 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2899 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2900 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2901 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2902 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2903 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2904 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2905 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2906 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2907 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2908 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2909 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2910 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2911 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2912 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2913 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2914 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2915 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2916 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2917 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2918 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2919 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2920 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2921 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2922 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2923 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2924 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2925 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2926 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2927 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2928 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2929 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2930 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2931 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2932 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2933 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2934 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2935 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2936 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2937 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2938 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2939 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2940 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2941 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2942 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2943 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2944 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2945 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2946 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2947 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2948 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2949 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2950 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2951 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2952 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2953 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2954 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2955 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2956 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002957};
2958
2959/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2960 symbol of state STATE-NUM. */
2961static const unsigned char yystos[] =
2962{
Reid Spencer950bf602007-01-26 08:19:09 +00002963 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2964 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2965 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2966 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2967 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2968 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2969 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2970 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2971 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2972 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2973 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2974 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2975 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2976 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2977 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2978 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2979 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2980 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2981 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2982 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2983 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2984 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2985 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2986 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2987 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2988 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2989 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2990 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2991 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2992 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2993 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2994 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2995 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2996 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2997 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2998 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2999 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
3000 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
3001 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
3002 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
3003 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
3004 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
3005 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
3006 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
3007 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
3008 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
3009 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
3010 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
3011 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
3012 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
3013 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
3014 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
3015 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
3016 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
3017 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3018 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
3019 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
3020 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
3021 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
3022 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
3023 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00003024};
Reid Spencere7c3c602006-11-30 06:36:44 +00003025
3026#define yyerrok (yyerrstatus = 0)
3027#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00003028#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003029#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00003030
Reid Spencere7c3c602006-11-30 06:36:44 +00003031#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00003032#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00003033#define YYERROR goto yyerrorlab
3034
Reid Spencer319a7302007-01-05 17:20:02 +00003035
3036/* Like YYERROR except do call yyerror. This remains here temporarily
3037 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003038 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00003039
Reid Spencere7c3c602006-11-30 06:36:44 +00003040#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00003041
Reid Spencere7c3c602006-11-30 06:36:44 +00003042#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00003043
3044#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003045do \
3046 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00003047 { \
3048 yychar = (Token); \
3049 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00003050 yytoken = YYTRANSLATE (yychar); \
Reid Spencere7c3c602006-11-30 06:36:44 +00003051 YYPOPSTACK; \
3052 goto yybackup; \
3053 } \
3054 else \
Reid Spencer950bf602007-01-26 08:19:09 +00003055 { \
3056 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00003057 YYERROR; \
3058 } \
Reid Spencere7c3c602006-11-30 06:36:44 +00003059while (0)
3060
Reid Spencer950bf602007-01-26 08:19:09 +00003061
Reid Spencere7c3c602006-11-30 06:36:44 +00003062#define YYTERROR 1
3063#define YYERRCODE 256
3064
Reid Spencer319a7302007-01-05 17:20:02 +00003065
Reid Spencer950bf602007-01-26 08:19:09 +00003066/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3067 If N is 0, then set CURRENT to the empty location which ends
3068 the previous symbol: RHS[0] (always defined). */
3069
3070#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00003071#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00003072# define YYLLOC_DEFAULT(Current, Rhs, N) \
3073 do \
3074 if (N) \
3075 { \
3076 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3077 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3078 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3079 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3080 } \
3081 else \
3082 { \
3083 (Current).first_line = (Current).last_line = \
3084 YYRHSLOC (Rhs, 0).last_line; \
3085 (Current).first_column = (Current).last_column = \
3086 YYRHSLOC (Rhs, 0).last_column; \
3087 } \
3088 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003089#endif
3090
Reid Spencer950bf602007-01-26 08:19:09 +00003091
3092/* YY_LOCATION_PRINT -- Print the location on the stream.
3093 This macro was not mandated originally: define only if we know
3094 we won't break user code: when these are the locations we know. */
3095
3096#ifndef YY_LOCATION_PRINT
3097# if YYLTYPE_IS_TRIVIAL
3098# define YY_LOCATION_PRINT(File, Loc) \
3099 fprintf (File, "%d.%d-%d.%d", \
3100 (Loc).first_line, (Loc).first_column, \
3101 (Loc).last_line, (Loc).last_column)
3102# else
3103# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3104# endif
3105#endif
3106
3107
Reid Spencer319a7302007-01-05 17:20:02 +00003108/* YYLEX -- calling `yylex' with the right arguments. */
3109
Reid Spencer950bf602007-01-26 08:19:09 +00003110#ifdef YYLEX_PARAM
3111# define YYLEX yylex (YYLEX_PARAM)
3112#else
3113# define YYLEX yylex ()
3114#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003115
3116/* Enable debugging if requested. */
3117#if YYDEBUG
3118
3119# ifndef YYFPRINTF
3120# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3121# define YYFPRINTF fprintf
3122# endif
3123
3124# define YYDPRINTF(Args) \
3125do { \
3126 if (yydebug) \
3127 YYFPRINTF Args; \
3128} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003129
3130# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3131do { \
3132 if (yydebug) \
3133 { \
3134 YYFPRINTF (stderr, "%s ", Title); \
3135 yysymprint (stderr, \
3136 Type, Value); \
3137 YYFPRINTF (stderr, "\n"); \
3138 } \
Reid Spencer319a7302007-01-05 17:20:02 +00003139} while (0)
Reid Spencer950bf602007-01-26 08:19:09 +00003140
3141/*------------------------------------------------------------------.
3142| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3143| TOP (included). |
3144`------------------------------------------------------------------*/
3145
3146#if defined (__STDC__) || defined (__cplusplus)
3147static void
3148yy_stack_print (short int *bottom, short int *top)
3149#else
3150static void
3151yy_stack_print (bottom, top)
3152 short int *bottom;
3153 short int *top;
3154#endif
3155{
3156 YYFPRINTF (stderr, "Stack now");
3157 for (/* Nothing. */; bottom <= top; ++bottom)
3158 YYFPRINTF (stderr, " %d", *bottom);
3159 YYFPRINTF (stderr, "\n");
3160}
3161
3162# define YY_STACK_PRINT(Bottom, Top) \
3163do { \
3164 if (yydebug) \
3165 yy_stack_print ((Bottom), (Top)); \
3166} while (0)
3167
3168
3169/*------------------------------------------------.
3170| Report that the YYRULE is going to be reduced. |
3171`------------------------------------------------*/
3172
3173#if defined (__STDC__) || defined (__cplusplus)
3174static void
3175yy_reduce_print (int yyrule)
3176#else
3177static void
3178yy_reduce_print (yyrule)
3179 int yyrule;
3180#endif
3181{
3182 int yyi;
3183 unsigned long int yylno = yyrline[yyrule];
3184 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3185 yyrule - 1, yylno);
3186 /* Print the symbols being reduced, and their result. */
3187 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3188 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3189 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3190}
3191
3192# define YY_REDUCE_PRINT(Rule) \
3193do { \
3194 if (yydebug) \
3195 yy_reduce_print (Rule); \
3196} while (0)
3197
Reid Spencer319a7302007-01-05 17:20:02 +00003198/* Nonzero means print parse trace. It is left uninitialized so that
3199 multiple parsers can coexist. */
3200int yydebug;
3201#else /* !YYDEBUG */
3202# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003203# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3204# define YY_STACK_PRINT(Bottom, Top)
3205# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003206#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003207
Reid Spencer950bf602007-01-26 08:19:09 +00003208
Reid Spencer319a7302007-01-05 17:20:02 +00003209/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003210#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003211# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003212#endif
3213
Reid Spencer319a7302007-01-05 17:20:02 +00003214/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3215 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003216
Reid Spencer319a7302007-01-05 17:20:02 +00003217 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003218 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003219 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003220
3221#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003222# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003223#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003224
Reid Spencere7c3c602006-11-30 06:36:44 +00003225
3226
Reid Spencer319a7302007-01-05 17:20:02 +00003227#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003228
Reid Spencer319a7302007-01-05 17:20:02 +00003229# ifndef yystrlen
3230# if defined (__GLIBC__) && defined (_STRING_H)
3231# define yystrlen strlen
3232# else
3233/* Return the length of YYSTR. */
3234static YYSIZE_T
3235# if defined (__STDC__) || defined (__cplusplus)
3236yystrlen (const char *yystr)
3237# else
3238yystrlen (yystr)
3239 const char *yystr;
3240# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003241{
Reid Spencer950bf602007-01-26 08:19:09 +00003242 const char *yys = yystr;
Chris Lattner37e01c52007-01-04 18:46:42 +00003243
Reid Spencer319a7302007-01-05 17:20:02 +00003244 while (*yys++ != '\0')
3245 continue;
3246
3247 return yys - yystr - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003248}
Reid Spencer319a7302007-01-05 17:20:02 +00003249# endif
3250# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003251
Reid Spencer319a7302007-01-05 17:20:02 +00003252# ifndef yystpcpy
3253# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3254# define yystpcpy stpcpy
3255# else
3256/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3257 YYDEST. */
3258static char *
3259# if defined (__STDC__) || defined (__cplusplus)
3260yystpcpy (char *yydest, const char *yysrc)
3261# else
3262yystpcpy (yydest, yysrc)
3263 char *yydest;
3264 const char *yysrc;
3265# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003266{
Reid Spencer950bf602007-01-26 08:19:09 +00003267 char *yyd = yydest;
3268 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003269
Reid Spencer319a7302007-01-05 17:20:02 +00003270 while ((*yyd++ = *yys++) != '\0')
3271 continue;
3272
3273 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003274}
Reid Spencer319a7302007-01-05 17:20:02 +00003275# endif
3276# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003277
Reid Spencer950bf602007-01-26 08:19:09 +00003278# ifndef yytnamerr
3279/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3280 quotes and backslashes, so that it's suitable for yyerror. The
3281 heuristic is that double-quoting is unnecessary unless the string
3282 contains an apostrophe, a comma, or backslash (other than
3283 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3284 null, do not copy; instead, return the length of what the result
3285 would have been. */
3286static YYSIZE_T
3287yytnamerr (char *yyres, const char *yystr)
3288{
3289 if (*yystr == '"')
3290 {
3291 size_t yyn = 0;
3292 char const *yyp = yystr;
3293
3294 for (;;)
3295 switch (*++yyp)
3296 {
3297 case '\'':
3298 case ',':
3299 goto do_not_strip_quotes;
3300
3301 case '\\':
3302 if (*++yyp != '\\')
3303 goto do_not_strip_quotes;
3304 /* Fall through. */
3305 default:
3306 if (yyres)
3307 yyres[yyn] = *yyp;
3308 yyn++;
3309 break;
3310
3311 case '"':
3312 if (yyres)
3313 yyres[yyn] = '\0';
3314 return yyn;
3315 }
3316 do_not_strip_quotes: ;
3317 }
3318
3319 if (! yyres)
3320 return yystrlen (yystr);
3321
3322 return yystpcpy (yyres, yystr) - yyres;
3323}
3324# endif
3325
3326#endif /* YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00003327
Reid Spencere7c3c602006-11-30 06:36:44 +00003328
3329
Reid Spencer319a7302007-01-05 17:20:02 +00003330#if YYDEBUG
Reid Spencer950bf602007-01-26 08:19:09 +00003331/*--------------------------------.
3332| Print this symbol on YYOUTPUT. |
3333`--------------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003334
Reid Spencer319a7302007-01-05 17:20:02 +00003335#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003336static void
3337yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner37e01c52007-01-04 18:46:42 +00003338#else
Reid Spencer950bf602007-01-26 08:19:09 +00003339static void
3340yysymprint (yyoutput, yytype, yyvaluep)
3341 FILE *yyoutput;
Reid Spencer319a7302007-01-05 17:20:02 +00003342 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003343 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003344#endif
3345{
3346 /* Pacify ``unused variable'' warnings. */
Reid Spencer950bf602007-01-26 08:19:09 +00003347 (void) yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003348
3349 if (yytype < YYNTOKENS)
Reid Spencer950bf602007-01-26 08:19:09 +00003350 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
Jeff Cohenac2dca92007-01-21 19:30:52 +00003351 else
Reid Spencer950bf602007-01-26 08:19:09 +00003352 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Jeff Cohenac2dca92007-01-21 19:30:52 +00003353
Reid Spencer950bf602007-01-26 08:19:09 +00003354
3355# ifdef YYPRINT
3356 if (yytype < YYNTOKENS)
3357 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3358# endif
Reid Spencer319a7302007-01-05 17:20:02 +00003359 switch (yytype)
3360 {
3361 default:
3362 break;
3363 }
Reid Spencer950bf602007-01-26 08:19:09 +00003364 YYFPRINTF (yyoutput, ")");
Reid Spencer319a7302007-01-05 17:20:02 +00003365}
3366
Reid Spencer950bf602007-01-26 08:19:09 +00003367#endif /* ! YYDEBUG */
Reid Spencer319a7302007-01-05 17:20:02 +00003368/*-----------------------------------------------.
3369| Release the memory associated to this symbol. |
3370`-----------------------------------------------*/
3371
3372#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003373static void
3374yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003375#else
Reid Spencer950bf602007-01-26 08:19:09 +00003376static void
3377yydestruct (yymsg, yytype, yyvaluep)
3378 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003379 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003380 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003381#endif
3382{
3383 /* Pacify ``unused variable'' warnings. */
Reid Spencer950bf602007-01-26 08:19:09 +00003384 (void) yyvaluep;
3385
3386 if (!yymsg)
3387 yymsg = "Deleting";
3388 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003389
3390 switch (yytype)
3391 {
Reid Spencer950bf602007-01-26 08:19:09 +00003392
Reid Spencer319a7302007-01-05 17:20:02 +00003393 default:
3394 break;
3395 }
3396}
3397
3398
Reid Spencer950bf602007-01-26 08:19:09 +00003399/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003400
3401#ifdef YYPARSE_PARAM
3402# if defined (__STDC__) || defined (__cplusplus)
Reid Spencer950bf602007-01-26 08:19:09 +00003403int yyparse (void *YYPARSE_PARAM);
Reid Spencer319a7302007-01-05 17:20:02 +00003404# else
Reid Spencer950bf602007-01-26 08:19:09 +00003405int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003406# endif
Reid Spencer950bf602007-01-26 08:19:09 +00003407#else /* ! YYPARSE_PARAM */
3408#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003409int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003410#else
3411int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003412#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003413#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003414
3415
Reid Spencer950bf602007-01-26 08:19:09 +00003416
3417/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003418int yychar;
3419
Reid Spencer950bf602007-01-26 08:19:09 +00003420/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003421YYSTYPE yylval;
3422
Reid Spencer950bf602007-01-26 08:19:09 +00003423/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003424int yynerrs;
3425
3426
Reid Spencer950bf602007-01-26 08:19:09 +00003427
3428/*----------.
3429| yyparse. |
3430`----------*/
3431
3432#ifdef YYPARSE_PARAM
3433# if defined (__STDC__) || defined (__cplusplus)
3434int yyparse (void *YYPARSE_PARAM)
3435# else
3436int yyparse (YYPARSE_PARAM)
3437 void *YYPARSE_PARAM;
3438# endif
3439#else /* ! YYPARSE_PARAM */
3440#if defined (__STDC__) || defined (__cplusplus)
Reid Spencer319a7302007-01-05 17:20:02 +00003441int
Reid Spencer950bf602007-01-26 08:19:09 +00003442yyparse (void)
3443#else
3444int
3445yyparse ()
3446
3447#endif
3448#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003449{
3450
Reid Spencer950bf602007-01-26 08:19:09 +00003451 int yystate;
3452 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003453 int yyresult;
3454 /* Number of tokens to shift before error messages enabled. */
3455 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003456 /* Look-ahead token as an internal (translated) token number. */
3457 int yytoken = 0;
Reid Spencer319a7302007-01-05 17:20:02 +00003458
3459 /* Three stacks and their tools:
3460 `yyss': related to states,
3461 `yyvs': related to semantic values,
3462 `yyls': related to locations.
3463
3464 Refer to the stacks thru separate pointers, to allow yyoverflow
3465 to reallocate them elsewhere. */
3466
3467 /* The state stack. */
Reid Spencer950bf602007-01-26 08:19:09 +00003468 short int yyssa[YYINITDEPTH];
3469 short int *yyss = yyssa;
3470 short int *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003471
3472 /* The semantic value stack. */
3473 YYSTYPE yyvsa[YYINITDEPTH];
3474 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003475 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003476
3477
3478
Reid Spencere7c3c602006-11-30 06:36:44 +00003479#define YYPOPSTACK (yyvsp--, yyssp--)
3480
Reid Spencer319a7302007-01-05 17:20:02 +00003481 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003482
Reid Spencer319a7302007-01-05 17:20:02 +00003483 /* The variables used to return semantic value and location from the
3484 action routines. */
3485 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003486
3487
Reid Spencer319a7302007-01-05 17:20:02 +00003488 /* When reducing, the number of symbols on the RHS of the reduced
3489 rule. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003490 int yylen;
3491
Reid Spencer319a7302007-01-05 17:20:02 +00003492 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003493
3494 yystate = 0;
3495 yyerrstatus = 0;
3496 yynerrs = 0;
3497 yychar = YYEMPTY; /* Cause a token to be read. */
3498
3499 /* Initialize stack pointers.
3500 Waste one element of value and location stack
3501 so that they stay on the same level as the state stack.
3502 The wasted elements are never initialized. */
3503
Reid Spencer319a7302007-01-05 17:20:02 +00003504 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003505 yyvsp = yyvs;
3506
Reid Spencer319a7302007-01-05 17:20:02 +00003507 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003508
Reid Spencer319a7302007-01-05 17:20:02 +00003509/*------------------------------------------------------------.
3510| yynewstate -- Push a new state, which is found in yystate. |
3511`------------------------------------------------------------*/
3512 yynewstate:
3513 /* In all cases, when you get here, the value and location stacks
3514 have just been pushed. so pushing a state here evens the stacks.
3515 */
3516 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003517
Reid Spencer319a7302007-01-05 17:20:02 +00003518 yysetstate:
3519 *yyssp = yystate;
3520
Reid Spencer950bf602007-01-26 08:19:09 +00003521 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003522 {
3523 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003524 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003525
3526#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003527 {
3528 /* Give user a chance to reallocate the stack. Use copies of
3529 these so that the &'s don't force the real ones into
3530 memory. */
3531 YYSTYPE *yyvs1 = yyvs;
Reid Spencer950bf602007-01-26 08:19:09 +00003532 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003533
Reid Spencer319a7302007-01-05 17:20:02 +00003534
3535 /* Each stack pointer address is followed by the size of the
3536 data in use in that stack, in bytes. This used to be a
3537 conditional around just the two extra args, but that might
3538 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003539 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003540 &yyss1, yysize * sizeof (*yyssp),
3541 &yyvs1, yysize * sizeof (*yyvsp),
3542
3543 &yystacksize);
3544
3545 yyss = yyss1;
3546 yyvs = yyvs1;
3547 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003548#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003549# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003550 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003551# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003552 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003553 if (YYMAXDEPTH <= yystacksize)
3554 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003555 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003556 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003557 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003558
3559 {
Reid Spencer950bf602007-01-26 08:19:09 +00003560 short int *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003561 union yyalloc *yyptr =
3562 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3563 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003564 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003565 YYSTACK_RELOCATE (yyss);
3566 YYSTACK_RELOCATE (yyvs);
3567
3568# undef YYSTACK_RELOCATE
3569 if (yyss1 != yyssa)
3570 YYSTACK_FREE (yyss1);
3571 }
3572# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003573#endif /* no yyoverflow */
3574
Reid Spencer319a7302007-01-05 17:20:02 +00003575 yyssp = yyss + yysize - 1;
3576 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003577
3578
Reid Spencer319a7302007-01-05 17:20:02 +00003579 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3580 (unsigned long int) yystacksize));
3581
Reid Spencer950bf602007-01-26 08:19:09 +00003582 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003583 YYABORT;
3584 }
3585
Reid Spencer319a7302007-01-05 17:20:02 +00003586 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003587
3588 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003589
3590/*-----------.
3591| yybackup. |
3592`-----------*/
3593yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003594
3595/* Do appropriate processing given the current state. */
Reid Spencer950bf602007-01-26 08:19:09 +00003596/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003597/* yyresume: */
3598
Reid Spencer950bf602007-01-26 08:19:09 +00003599 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003600
3601 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003602 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003603 goto yydefault;
3604
Reid Spencer950bf602007-01-26 08:19:09 +00003605 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003606
Reid Spencer950bf602007-01-26 08:19:09 +00003607 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003608 if (yychar == YYEMPTY)
3609 {
Reid Spencer319a7302007-01-05 17:20:02 +00003610 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003611 yychar = YYLEX;
3612 }
3613
Reid Spencer950bf602007-01-26 08:19:09 +00003614 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003615 {
Reid Spencer950bf602007-01-26 08:19:09 +00003616 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003617 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003618 }
3619 else
3620 {
Reid Spencer950bf602007-01-26 08:19:09 +00003621 yytoken = YYTRANSLATE (yychar);
3622 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003623 }
3624
Reid Spencer950bf602007-01-26 08:19:09 +00003625 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003626 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003627 yyn += yytoken;
3628 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003629 goto yydefault;
3630 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003631 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003632 {
Reid Spencer319a7302007-01-05 17:20:02 +00003633 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003634 goto yyerrlab;
3635 yyn = -yyn;
3636 goto yyreduce;
3637 }
3638
3639 if (yyn == YYFINAL)
3640 YYACCEPT;
3641
Reid Spencer950bf602007-01-26 08:19:09 +00003642 /* Shift the look-ahead token. */
3643 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003644
3645 /* Discard the token being shifted unless it is eof. */
3646 if (yychar != YYEOF)
3647 yychar = YYEMPTY;
3648
3649 *++yyvsp = yylval;
3650
Reid Spencer319a7302007-01-05 17:20:02 +00003651
3652 /* Count tokens shifted since error; after three, turn off error
3653 status. */
3654 if (yyerrstatus)
3655 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003656
3657 yystate = yyn;
3658 goto yynewstate;
3659
Chris Lattner37e01c52007-01-04 18:46:42 +00003660
Reid Spencer319a7302007-01-05 17:20:02 +00003661/*-----------------------------------------------------------.
3662| yydefault -- do the default action for the current state. |
3663`-----------------------------------------------------------*/
3664yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003665 yyn = yydefact[yystate];
3666 if (yyn == 0)
3667 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003668 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003669
Reid Spencer319a7302007-01-05 17:20:02 +00003670
3671/*-----------------------------.
3672| yyreduce -- Do a reduction. |
3673`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003674yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003675 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003676 yylen = yyr2[yyn];
3677
Reid Spencer319a7302007-01-05 17:20:02 +00003678 /* If YYLEN is nonzero, implement the default value of the action:
3679 `$$ = $1'.
3680
3681 Otherwise, the following line sets YYVAL to garbage.
3682 This behavior is undocumented and Bison
3683 users should not rely upon it. Assigning to YYVAL
3684 unconditionally makes the parser a bit smaller, and it avoids a
3685 GCC warning that YYVAL may be used uninitialized. */
3686 yyval = yyvsp[1-yylen];
3687
3688
Reid Spencer950bf602007-01-26 08:19:09 +00003689 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003690 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003691 {
Reid Spencer950bf602007-01-26 08:19:09 +00003692 case 3:
3693#line 1608 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003694 {
Reid Spencer950bf602007-01-26 08:19:09 +00003695 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
3696 error("Value too large for type");
3697 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3698 ;}
3699 break;
3700
3701 case 5:
3702#line 1617 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3703 {
3704 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
3705 error("Value too large for type");
3706 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3707 ;}
3708 break;
3709
3710 case 26:
3711#line 1639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3712 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3713 break;
3714
3715 case 27:
3716#line 1639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3717 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3718 break;
3719
3720 case 28:
3721#line 1640 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3722 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3723 break;
3724
3725 case 29:
3726#line 1640 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3727 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3728 break;
3729
3730 case 30:
3731#line 1641 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3732 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3733 break;
3734
3735 case 31:
3736#line 1641 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3737 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3738 break;
3739
3740 case 32:
3741#line 1642 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3742 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3743 break;
3744
3745 case 33:
3746#line 1642 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3747 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3748 break;
3749
3750 case 34:
3751#line 1643 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3752 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3753 break;
3754
3755 case 35:
3756#line 1643 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3757 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3758 break;
3759
3760 case 36:
3761#line 1647 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3762 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3763 break;
3764
3765 case 37:
3766#line 1647 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3767 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3768 break;
3769
3770 case 38:
3771#line 1648 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3772 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3773 break;
3774
3775 case 39:
3776#line 1648 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3777 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3778 break;
3779
3780 case 40:
3781#line 1649 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3782 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3783 break;
3784
3785 case 41:
3786#line 1649 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3787 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3788 break;
3789
3790 case 42:
3791#line 1650 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3792 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3793 break;
3794
3795 case 43:
3796#line 1650 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3797 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3798 break;
3799
3800 case 44:
3801#line 1651 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3802 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3803 break;
3804
3805 case 45:
3806#line 1651 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3807 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3808 break;
3809
3810 case 46:
3811#line 1652 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3812 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3813 break;
3814
3815 case 47:
3816#line 1652 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3817 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3818 break;
3819
3820 case 48:
3821#line 1653 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3822 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3823 break;
3824
3825 case 49:
3826#line 1653 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3827 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3828 break;
3829
3830 case 50:
3831#line 1654 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3832 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3833 break;
3834
3835 case 51:
3836#line 1655 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3837 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3838 break;
3839
3840 case 81:
3841#line 1686 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3842 {
3843 (yyval.StrVal) = (yyvsp[-1].StrVal);
3844 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003845 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003846
Reid Spencer319a7302007-01-05 17:20:02 +00003847 case 82:
Reid Spencer950bf602007-01-26 08:19:09 +00003848#line 1689 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003849 {
Reid Spencer950bf602007-01-26 08:19:09 +00003850 (yyval.StrVal) = 0;
3851 ;}
3852 break;
3853
3854 case 83:
3855#line 1694 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3856 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3857 break;
3858
3859 case 84:
3860#line 1695 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3861 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3862 break;
3863
3864 case 85:
3865#line 1696 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3866 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3867 break;
3868
3869 case 86:
3870#line 1697 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3871 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3872 break;
3873
3874 case 87:
3875#line 1698 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3876 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3877 break;
3878
3879 case 88:
3880#line 1699 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3881 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3882 break;
3883
3884 case 89:
3885#line 1700 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3886 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003887 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003888
Reid Spencer319a7302007-01-05 17:20:02 +00003889 case 90:
Reid Spencer950bf602007-01-26 08:19:09 +00003890#line 1701 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3891 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3892 break;
3893
3894 case 91:
3895#line 1705 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3896 { (yyval.UIntVal) = CallingConv::C; ;}
3897 break;
3898
3899 case 92:
3900#line 1706 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3901 { (yyval.UIntVal) = CallingConv::C; ;}
3902 break;
3903
3904 case 93:
3905#line 1707 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3906 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3907 break;
3908
3909 case 94:
3910#line 1708 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3911 { (yyval.UIntVal) = CallingConv::Fast; ;}
3912 break;
3913
3914 case 95:
3915#line 1709 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3916 { (yyval.UIntVal) = CallingConv::Cold; ;}
3917 break;
3918
3919 case 96:
3920#line 1710 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3921 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003922 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00003923
Reid Spencer319a7302007-01-05 17:20:02 +00003924 case 97:
Reid Spencer950bf602007-01-26 08:19:09 +00003925#line 1711 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3926 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003927 break;
Reid Spencer16244f42006-12-01 21:10:07 +00003928
Reid Spencer319a7302007-01-05 17:20:02 +00003929 case 98:
Reid Spencer950bf602007-01-26 08:19:09 +00003930#line 1712 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3931 {
3932 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
3933 error("Calling conv too large");
3934 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3935 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003936 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003937
Reid Spencer319a7302007-01-05 17:20:02 +00003938 case 99:
Reid Spencer950bf602007-01-26 08:19:09 +00003939#line 1722 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3940 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003941 break;
3942
Reid Spencerc4d96252007-01-13 00:03:30 +00003943 case 100:
Reid Spencer950bf602007-01-26 08:19:09 +00003944#line 1723 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3945 {
3946 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3947 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3948 error("Alignment must be a power of two");
3949 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003950 break;
3951
3952 case 101:
Reid Spencer950bf602007-01-26 08:19:09 +00003953#line 1731 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3954 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003955 break;
3956
3957 case 102:
Reid Spencer950bf602007-01-26 08:19:09 +00003958#line 1732 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3959 {
3960 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3961 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3962 error("Alignment must be a power of two");
3963 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003964 break;
3965
3966 case 103:
Reid Spencer950bf602007-01-26 08:19:09 +00003967#line 1740 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3968 {
3969 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3970 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
3971 error("Invalid character in section name");
3972 (yyval.StrVal) = (yyvsp[0].StrVal);
3973 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003974 break;
3975
3976 case 104:
Reid Spencer950bf602007-01-26 08:19:09 +00003977#line 1749 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3978 { (yyval.StrVal) = 0; ;}
3979 break;
3980
3981 case 105:
3982#line 1750 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3983 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003984 break;
3985
Reid Spencerc4d96252007-01-13 00:03:30 +00003986 case 106:
Reid Spencer950bf602007-01-26 08:19:09 +00003987#line 1757 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3988 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00003989 break;
3990
Reid Spencer319a7302007-01-05 17:20:02 +00003991 case 107:
Reid Spencer950bf602007-01-26 08:19:09 +00003992#line 1758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
3993 {;}
3994 break;
3995
3996 case 108:
3997#line 1762 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003998 {
Reid Spencer950bf602007-01-26 08:19:09 +00003999 CurGV->setSection((yyvsp[0].StrVal));
4000 free((yyvsp[0].StrVal));
4001 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004002 break;
4003
4004 case 109:
Reid Spencer950bf602007-01-26 08:19:09 +00004005#line 1766 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004006 {
Reid Spencer950bf602007-01-26 08:19:09 +00004007 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
4008 error("Alignment must be a power of two");
4009 CurGV->setAlignment((yyvsp[0].UInt64Val));
4010
4011 ;}
4012 break;
4013
4014 case 111:
4015#line 1783 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4016 {
4017 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
4018 (yyval.TypeVal).S = Signless;
4019 ;}
4020 break;
4021
4022 case 113:
4023#line 1791 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4024 {
4025 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
4026 (yyval.TypeVal).S = Signless;
4027 ;}
4028 break;
4029
4030 case 114:
4031#line 1798 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4032 {
4033 if (!UpRefs.empty())
4034 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).T)->getDescription());
4035 (yyval.TypeVal) = (yyvsp[0].TypeVal);
4036 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004037 break;
4038
4039 case 127:
Reid Spencer950bf602007-01-26 08:19:09 +00004040#line 1812 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004041 {
Reid Spencer950bf602007-01-26 08:19:09 +00004042 (yyval.TypeVal).T = new PATypeHolder((yyvsp[0].PrimType).T);
4043 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
4044 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004045 break;
4046
4047 case 128:
Reid Spencer950bf602007-01-26 08:19:09 +00004048#line 1816 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4049 {
4050 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4051 (yyval.TypeVal).S = Signless;
4052 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004053 break;
4054
4055 case 129:
Reid Spencer950bf602007-01-26 08:19:09 +00004056#line 1820 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4057 { // Named types are also simple types...
4058 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
4059 (yyval.TypeVal).T = new PATypeHolder(tmp);
4060 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4061 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004062 break;
4063
4064 case 130:
Reid Spencer950bf602007-01-26 08:19:09 +00004065#line 1825 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004066 { // Type UpReference
Reid Spencer950bf602007-01-26 08:19:09 +00004067 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
4068 error("Value out of range");
4069 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
4070 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
4071 (yyval.TypeVal).T = new PATypeHolder(OT);
4072 (yyval.TypeVal).S = Signless;
4073 UR_OUT("New Upreference!\n");
4074 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004075 break;
4076
4077 case 131:
Reid Spencer950bf602007-01-26 08:19:09 +00004078#line 1834 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004079 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004080 std::vector<const Type*> Params;
4081 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4082 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
4083 Params.push_back(I->T->get());
4084 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004085 }
Reid Spencer950bf602007-01-26 08:19:09 +00004086 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4087 if (isVarArg) Params.pop_back();
4088
4089 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
4090 FunctionType::get((yyvsp[-3].TypeVal).T->get(),Params,isVarArg)));
4091 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
4092 delete (yyvsp[-3].TypeVal).T; // Delete the return type handle
4093 delete (yyvsp[-1].TypeList); // Delete the argument list
4094 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004095 break;
4096
4097 case 132:
Reid Spencer950bf602007-01-26 08:19:09 +00004098#line 1850 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004099 { // Sized array type?
Reid Spencer950bf602007-01-26 08:19:09 +00004100 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).T->get(),
4101 (unsigned)(yyvsp[-3].UInt64Val))));
4102 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4103 delete (yyvsp[-1].TypeVal).T;
4104 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004105 break;
4106
4107 case 133:
Reid Spencer950bf602007-01-26 08:19:09 +00004108#line 1856 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004109 { // Packed array type?
Reid Spencer950bf602007-01-26 08:19:09 +00004110 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).T->get();
4111 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
4112 error("Unsigned result not equal to signed result");
4113 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4114 error("Elements of a PackedType must be integer or floating point");
4115 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
4116 error("PackedType length should be a power of 2");
4117 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
4118 (unsigned)(yyvsp[-3].UInt64Val))));
4119 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4120 delete (yyvsp[-1].TypeVal).T;
4121 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004122 break;
4123
4124 case 134:
Reid Spencer950bf602007-01-26 08:19:09 +00004125#line 1869 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004126 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004127 std::vector<const Type*> Elements;
4128 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4129 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
4130 Elements.push_back(I->T->get());
4131 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4132 (yyval.TypeVal).S = Signless;
4133 delete (yyvsp[-1].TypeList);
4134 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004135 break;
4136
4137 case 135:
Reid Spencer950bf602007-01-26 08:19:09 +00004138#line 1878 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004139 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004140 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4141 (yyval.TypeVal).S = Signless;
4142 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004143 break;
4144
4145 case 136:
Reid Spencer950bf602007-01-26 08:19:09 +00004146#line 1882 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004147 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004148 std::vector<const Type*> Elements;
4149 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4150 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
4151 Elements.push_back(I->T->get());
4152 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004153 }
Reid Spencer950bf602007-01-26 08:19:09 +00004154 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4155 (yyval.TypeVal).S = Signless;
4156 delete (yyvsp[-2].TypeList);
4157 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004158 break;
4159
4160 case 137:
Reid Spencer950bf602007-01-26 08:19:09 +00004161#line 1893 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004162 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004163 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4164 (yyval.TypeVal).S = Signless;
4165 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004166 break;
4167
4168 case 138:
Reid Spencer950bf602007-01-26 08:19:09 +00004169#line 1897 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004170 { // Pointer type?
Reid Spencer950bf602007-01-26 08:19:09 +00004171 if ((yyvsp[-1].TypeVal).T->get() == Type::LabelTy)
4172 error("Cannot form a pointer to a basic block");
4173 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).T->get())));
4174 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4175 delete (yyvsp[-1].TypeVal).T;
4176 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004177 break;
4178
4179 case 139:
Reid Spencer950bf602007-01-26 08:19:09 +00004180#line 1910 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004181 {
Reid Spencer950bf602007-01-26 08:19:09 +00004182 (yyval.TypeList) = new std::list<PATypeInfo>();
4183 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4184 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004185 break;
4186
4187 case 140:
Reid Spencer950bf602007-01-26 08:19:09 +00004188#line 1914 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004189 {
Reid Spencer950bf602007-01-26 08:19:09 +00004190 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4191 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004192 break;
4193
4194 case 142:
Reid Spencer950bf602007-01-26 08:19:09 +00004195#line 1922 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004196 {
Reid Spencer950bf602007-01-26 08:19:09 +00004197 PATypeInfo VoidTI;
4198 VoidTI.T = new PATypeHolder(Type::VoidTy);
4199 VoidTI.S = Signless;
4200 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4201 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004202 break;
4203
4204 case 143:
Reid Spencer950bf602007-01-26 08:19:09 +00004205#line 1928 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004206 {
Reid Spencer950bf602007-01-26 08:19:09 +00004207 (yyval.TypeList) = new std::list<PATypeInfo>();
4208 PATypeInfo VoidTI;
4209 VoidTI.T = new PATypeHolder(Type::VoidTy);
4210 VoidTI.S = Signless;
4211 (yyval.TypeList)->push_back(VoidTI);
4212 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004213 break;
4214
4215 case 144:
Reid Spencer950bf602007-01-26 08:19:09 +00004216#line 1935 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004217 {
Reid Spencer950bf602007-01-26 08:19:09 +00004218 (yyval.TypeList) = new std::list<PATypeInfo>();
4219 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004220 break;
4221
4222 case 145:
Reid Spencer950bf602007-01-26 08:19:09 +00004223#line 1947 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004224 { // Nonempty unsized arr
Reid Spencer950bf602007-01-26 08:19:09 +00004225 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).T->get());
4226 if (ATy == 0)
4227 error("Cannot make array constant with type: '" +
4228 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4229 const Type *ETy = ATy->getElementType();
4230 int NumElements = ATy->getNumElements();
4231
4232 // Verify that we have the correct size...
4233 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4234 error("Type mismatch: constant sized array initialized with " +
4235 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4236 itostr(NumElements) + "");
4237
4238 // Verify all elements are correct type!
4239 std::vector<Constant*> Elems;
4240 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4241 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4242 const Type* ValTy = C->getType();
4243 if (ETy != ValTy)
4244 error("Element #" + utostr(i) + " is not of type '" +
4245 ETy->getDescription() +"' as required!\nIt is of type '"+
4246 ValTy->getDescription() + "'");
4247 Elems.push_back(C);
4248 }
4249 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4250 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4251 delete (yyvsp[-3].TypeVal).T;
4252 delete (yyvsp[-1].ConstVector);
4253 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004254 break;
4255
4256 case 146:
Reid Spencer950bf602007-01-26 08:19:09 +00004257#line 1977 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004258 {
Reid Spencer950bf602007-01-26 08:19:09 +00004259 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
4260 if (ATy == 0)
4261 error("Cannot make array constant with type: '" +
4262 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4263 int NumElements = ATy->getNumElements();
4264 if (NumElements != -1 && NumElements != 0)
4265 error("Type mismatch: constant sized array initialized with 0"
4266 " arguments, but has size of " + itostr(NumElements) +"");
4267 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4268 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4269 delete (yyvsp[-2].TypeVal).T;
4270 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004271 break;
4272
4273 case 147:
Reid Spencer950bf602007-01-26 08:19:09 +00004274#line 1990 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004275 {
Reid Spencer950bf602007-01-26 08:19:09 +00004276 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).T->get());
4277 if (ATy == 0)
4278 error("Cannot make array constant with type: '" +
4279 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4280 int NumElements = ATy->getNumElements();
4281 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4282 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4283 error("String arrays require type i8, not '" + ETy->getDescription() +
4284 "'");
4285 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4286 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
4287 error("Can't build string constant of size " +
4288 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
4289 itostr(NumElements) + "");
4290 std::vector<Constant*> Vals;
4291 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
4292 Vals.push_back(ConstantInt::get(ETy, *C));
4293 free((yyvsp[0].StrVal));
4294 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4295 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4296 delete (yyvsp[-2].TypeVal).T;
4297 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004298 break;
4299
4300 case 148:
Reid Spencer950bf602007-01-26 08:19:09 +00004301#line 2013 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004302 { // Nonempty unsized arr
Reid Spencer950bf602007-01-26 08:19:09 +00004303 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).T->get());
4304 if (PTy == 0)
4305 error("Cannot make packed constant with type: '" +
4306 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4307 const Type *ETy = PTy->getElementType();
4308 int NumElements = PTy->getNumElements();
4309 // Verify that we have the correct size...
4310 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
4311 error("Type mismatch: constant sized packed initialized with " +
4312 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
4313 itostr(NumElements) + "");
4314 // Verify all elements are correct type!
4315 std::vector<Constant*> Elems;
4316 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4317 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4318 const Type* ValTy = C->getType();
4319 if (ETy != ValTy)
4320 error("Element #" + utostr(i) + " is not of type '" +
4321 ETy->getDescription() +"' as required!\nIt is of type '"+
4322 ValTy->getDescription() + "'");
4323 Elems.push_back(C);
4324 }
4325 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
4326 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4327 delete (yyvsp[-3].TypeVal).T;
4328 delete (yyvsp[-1].ConstVector);
4329 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004330 break;
4331
4332 case 149:
Reid Spencer950bf602007-01-26 08:19:09 +00004333#line 2041 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004334 {
Reid Spencer950bf602007-01-26 08:19:09 +00004335 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).T->get());
4336 if (STy == 0)
4337 error("Cannot make struct constant with type: '" +
4338 (yyvsp[-3].TypeVal).T->get()->getDescription() + "'");
4339 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
4340 error("Illegal number of initializers for structure type");
4341
4342 // Check to ensure that constants are compatible with the type initializer!
4343 std::vector<Constant*> Fields;
4344 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4345 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
4346 if (C->getType() != STy->getElementType(i))
4347 error("Expected type '" + STy->getElementType(i)->getDescription() +
4348 "' for element #" + utostr(i) + " of structure initializer");
4349 Fields.push_back(C);
4350 }
4351 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4352 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4353 delete (yyvsp[-3].TypeVal).T;
4354 delete (yyvsp[-1].ConstVector);
4355 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004356 break;
4357
4358 case 150:
Reid Spencer950bf602007-01-26 08:19:09 +00004359#line 2063 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004360 {
Reid Spencer950bf602007-01-26 08:19:09 +00004361 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).T->get());
4362 if (STy == 0)
4363 error("Cannot make struct constant with type: '" +
4364 (yyvsp[-2].TypeVal).T->get()->getDescription() + "'");
4365 if (STy->getNumContainedTypes() != 0)
4366 error("Illegal number of initializers for structure type");
4367 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4368 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4369 delete (yyvsp[-2].TypeVal).T;
4370 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004371 break;
4372
4373 case 151:
Reid Spencer950bf602007-01-26 08:19:09 +00004374#line 2074 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004375 {
Reid Spencer950bf602007-01-26 08:19:09 +00004376 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).T->get());
4377 if (STy == 0)
4378 error("Cannot make packed struct constant with type: '" +
4379 (yyvsp[-5].TypeVal).T->get()->getDescription() + "'");
4380 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
4381 error("Illegal number of initializers for packed structure type");
4382
4383 // Check to ensure that constants are compatible with the type initializer!
4384 std::vector<Constant*> Fields;
4385 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4386 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
4387 if (C->getType() != STy->getElementType(i))
4388 error("Expected type '" + STy->getElementType(i)->getDescription() +
4389 "' for element #" + utostr(i) + " of packed struct initializer");
4390 Fields.push_back(C);
4391 }
4392 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4393 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4394 delete (yyvsp[-5].TypeVal).T;
4395 delete (yyvsp[-2].ConstVector);
4396 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004397 break;
4398
4399 case 152:
Reid Spencer950bf602007-01-26 08:19:09 +00004400#line 2096 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004401 {
Reid Spencer950bf602007-01-26 08:19:09 +00004402 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).T->get());
4403 if (STy == 0)
4404 error("Cannot make packed struct constant with type: '" +
4405 (yyvsp[-4].TypeVal).T->get()->getDescription() + "'");
4406 if (STy->getNumContainedTypes() != 0)
4407 error("Illegal number of initializers for packed structure type");
4408 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4409 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4410 delete (yyvsp[-4].TypeVal).T;
4411 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004412 break;
4413
4414 case 153:
Reid Spencer950bf602007-01-26 08:19:09 +00004415#line 2107 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004416 {
Reid Spencer950bf602007-01-26 08:19:09 +00004417 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
4418 if (PTy == 0)
4419 error("Cannot make null pointer constant with type: '" +
4420 (yyvsp[-1].TypeVal).T->get()->getDescription() + "'");
4421 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4422 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4423 delete (yyvsp[-1].TypeVal).T;
4424 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004425 break;
4426
4427 case 154:
Reid Spencer950bf602007-01-26 08:19:09 +00004428#line 2116 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004429 {
Reid Spencer950bf602007-01-26 08:19:09 +00004430 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).T->get());
4431 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4432 delete (yyvsp[-1].TypeVal).T;
4433 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004434 break;
4435
4436 case 155:
Reid Spencer950bf602007-01-26 08:19:09 +00004437#line 2121 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004438 {
Reid Spencer950bf602007-01-26 08:19:09 +00004439 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
4440 if (Ty == 0)
4441 error("Global const reference must be a pointer type, not" +
4442 (yyvsp[-1].TypeVal).T->get()->getDescription());
4443
4444 // ConstExprs can exist in the body of a function, thus creating
4445 // GlobalValues whenever they refer to a variable. Because we are in
4446 // the context of a function, getExistingValue will search the functions
4447 // symbol table instead of the module symbol table for the global symbol,
4448 // which throws things all off. To get around this, we just tell
4449 // getExistingValue that we are at global scope here.
4450 //
4451 Function *SavedCurFn = CurFun.CurrentFunction;
4452 CurFun.CurrentFunction = 0;
4453 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
4454 CurFun.CurrentFunction = SavedCurFn;
4455
4456 // If this is an initializer for a constant pointer, which is referencing a
4457 // (currently) undefined variable, create a stub now that shall be replaced
4458 // in the future with the right type of variable.
4459 //
4460 if (V == 0) {
4461 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4462 const PointerType *PT = cast<PointerType>(Ty);
4463
4464 // First check to see if the forward references value is already created!
4465 PerModuleInfo::GlobalRefsType::iterator I =
4466 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
4467
4468 if (I != CurModule.GlobalRefs.end()) {
4469 V = I->second; // Placeholder already exists, use it...
4470 (yyvsp[0].ValIDVal).destroy();
4471 } else {
4472 std::string Name;
4473 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
4474
4475 // Create the forward referenced global.
4476 GlobalValue *GV;
4477 if (const FunctionType *FTy =
4478 dyn_cast<FunctionType>(PT->getElementType())) {
4479 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4480 CurModule.CurrentModule);
4481 } else {
4482 GV = new GlobalVariable(PT->getElementType(), false,
4483 GlobalValue::ExternalLinkage, 0,
4484 Name, CurModule.CurrentModule);
4485 }
4486
4487 // Keep track of the fact that we have a forward ref to recycle it
4488 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
4489 V = GV;
4490 }
4491 }
4492 (yyval.ConstVal).C = cast<GlobalValue>(V);
4493 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4494 delete (yyvsp[-1].TypeVal).T; // Free the type handle
4495 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004496 break;
4497
4498 case 156:
Reid Spencer950bf602007-01-26 08:19:09 +00004499#line 2179 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4500 {
4501 if ((yyvsp[-1].TypeVal).T->get() != (yyvsp[0].ConstVal).C->getType())
4502 error("Mismatched types for constant expression");
4503 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4504 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4505 delete (yyvsp[-1].TypeVal).T;
4506 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004507 break;
4508
4509 case 157:
Reid Spencer950bf602007-01-26 08:19:09 +00004510#line 2186 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4511 {
4512 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
4513 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4514 error("Cannot create a null initialized value of this type");
4515 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4516 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4517 delete (yyvsp[-1].TypeVal).T;
4518 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004519 break;
4520
4521 case 158:
Reid Spencer950bf602007-01-26 08:19:09 +00004522#line 2194 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4523 { // integral constants
4524 const Type *Ty = (yyvsp[-1].PrimType).T;
4525 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
4526 error("Constant value doesn't fit in type");
4527 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
4528 (yyval.ConstVal).S = Signed;
4529 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004530 break;
4531
4532 case 159:
Reid Spencer950bf602007-01-26 08:19:09 +00004533#line 2201 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4534 { // integral constants
4535 const Type *Ty = (yyvsp[-1].PrimType).T;
4536 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
4537 error("Constant value doesn't fit in type");
4538 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
4539 (yyval.ConstVal).S = Unsigned;
4540 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004541 break;
4542
4543 case 160:
Reid Spencer950bf602007-01-26 08:19:09 +00004544#line 2208 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4545 { // Boolean constants
4546 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4547 (yyval.ConstVal).S = Unsigned;
4548 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004549 break;
4550
4551 case 161:
Reid Spencer950bf602007-01-26 08:19:09 +00004552#line 2212 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4553 { // Boolean constants
4554 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4555 (yyval.ConstVal).S = Unsigned;
4556 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004557 break;
4558
4559 case 162:
Reid Spencer950bf602007-01-26 08:19:09 +00004560#line 2216 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4561 { // Float & Double constants
4562 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
4563 error("Floating point constant invalid for type");
4564 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
4565 (yyval.ConstVal).S = Signless;
4566 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004567 break;
4568
4569 case 163:
Reid Spencer950bf602007-01-26 08:19:09 +00004570#line 2225 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004571 {
Reid Spencer950bf602007-01-26 08:19:09 +00004572 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4573 const Type* DstTy = (yyvsp[-1].TypeVal).T->get();
4574 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4575 Signedness DstSign = (yyvsp[-1].TypeVal).S;
4576 if (!SrcTy->isFirstClassType())
4577 error("cast constant expression from a non-primitive type: '" +
4578 SrcTy->getDescription() + "'");
4579 if (!DstTy->isFirstClassType())
4580 error("cast constant expression to a non-primitive type: '" +
4581 DstTy->getDescription() + "'");
4582 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
4583 (yyval.ConstVal).S = DstSign;
4584 delete (yyvsp[-1].TypeVal).T;
4585 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004586 break;
4587
4588 case 164:
Reid Spencer950bf602007-01-26 08:19:09 +00004589#line 2240 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004590 {
Reid Spencer950bf602007-01-26 08:19:09 +00004591 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
4592 if (!isa<PointerType>(Ty))
4593 error("GetElementPtr requires a pointer operand");
4594
4595 std::vector<Value*> VIndices;
4596 std::vector<Constant*> CIndices;
4597 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
4598
4599 delete (yyvsp[-1].ValueList);
4600 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices);
4601 (yyval.ConstVal).S = Signless;
4602 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004603 break;
4604
4605 case 165:
Reid Spencer950bf602007-01-26 08:19:09 +00004606#line 2253 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004607 {
Reid Spencer950bf602007-01-26 08:19:09 +00004608 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4609 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
4610 error("Select condition must be bool type");
4611 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4612 error("Select operand types must match");
4613 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4614 (yyval.ConstVal).S = Unsigned;
4615 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004616 break;
4617
4618 case 166:
Reid Spencer950bf602007-01-26 08:19:09 +00004619#line 2262 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004620 {
Reid Spencer950bf602007-01-26 08:19:09 +00004621 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4622 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4623 error("Binary operator types must match");
4624 // First, make sure we're dealing with the right opcode by upgrading from
4625 // obsolete versions.
4626 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4627
4628 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4629 // To retain backward compatibility with these early compilers, we emit a
4630 // cast to the appropriate integer type automatically if we are in the
4631 // broken case. See PR424 for more information.
4632 if (!isa<PointerType>(Ty)) {
4633 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4634 } else {
4635 const Type *IntPtrTy = 0;
4636 switch (CurModule.CurrentModule->getPointerSize()) {
4637 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4638 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4639 default: error("invalid pointer binary constant expr");
4640 }
4641 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4642 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4643 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4644 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4645 }
4646 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4647 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004648 break;
4649
4650 case 167:
Reid Spencer950bf602007-01-26 08:19:09 +00004651#line 2290 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004652 {
Reid Spencer950bf602007-01-26 08:19:09 +00004653 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4654 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4655 error("Logical operator types must match");
4656 if (!Ty->isInteger()) {
4657 if (!isa<PackedType>(Ty) ||
4658 !cast<PackedType>(Ty)->getElementType()->isInteger())
4659 error("Logical operator requires integer operands");
4660 }
4661 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4662 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4663 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4664 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004665 break;
4666
4667 case 168:
Reid Spencer950bf602007-01-26 08:19:09 +00004668#line 2303 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004669 {
Reid Spencer950bf602007-01-26 08:19:09 +00004670 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4671 if (Ty != (yyvsp[-1].ConstVal).C->getType())
4672 error("setcc operand types must match");
4673 unsigned short pred;
4674 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4675 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4676 (yyval.ConstVal).S = Unsigned;
4677 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004678 break;
4679
4680 case 169:
Reid Spencer950bf602007-01-26 08:19:09 +00004681#line 2312 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004682 {
Reid Spencer950bf602007-01-26 08:19:09 +00004683 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4684 error("icmp operand types must match");
4685 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4686 (yyval.ConstVal).S = Unsigned;
4687 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004688 break;
4689
4690 case 170:
Reid Spencer950bf602007-01-26 08:19:09 +00004691#line 2318 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004692 {
Reid Spencer950bf602007-01-26 08:19:09 +00004693 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
4694 error("fcmp operand types must match");
4695 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4696 (yyval.ConstVal).S = Unsigned;
4697 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004698 break;
4699
4700 case 171:
Reid Spencer950bf602007-01-26 08:19:09 +00004701#line 2324 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004702 {
Reid Spencer950bf602007-01-26 08:19:09 +00004703 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4704 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
4705 error("Shift count for shift constant must be unsigned byte");
4706 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
4707 error("Shift constant expression requires integer operand");
4708 (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4709 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4710 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004711 break;
4712
4713 case 172:
Reid Spencer950bf602007-01-26 08:19:09 +00004714#line 2333 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004715 {
Reid Spencer950bf602007-01-26 08:19:09 +00004716 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4717 error("Invalid extractelement operands");
4718 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4719 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4720 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004721 break;
4722
4723 case 173:
Reid Spencer950bf602007-01-26 08:19:09 +00004724#line 2339 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004725 {
Reid Spencer950bf602007-01-26 08:19:09 +00004726 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4727 error("Invalid insertelement operands");
4728 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4729 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4730 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004731 break;
4732
4733 case 174:
Reid Spencer950bf602007-01-26 08:19:09 +00004734#line 2345 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4735 {
4736 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
4737 error("Invalid shufflevector operands");
4738 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4739 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4740 ;}
4741 break;
4742
4743 case 175:
4744#line 2356 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4745 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
4746 break;
4747
4748 case 176:
4749#line 2357 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4750 {
4751 (yyval.ConstVector) = new std::vector<ConstInfo>();
4752 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4753 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004754 break;
4755
4756 case 177:
Reid Spencer950bf602007-01-26 08:19:09 +00004757#line 2366 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4758 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004759 break;
4760
4761 case 178:
Reid Spencer950bf602007-01-26 08:19:09 +00004762#line 2367 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4763 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004764 break;
4765
4766 case 179:
Reid Spencer950bf602007-01-26 08:19:09 +00004767#line 2379 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004768 {
Reid Spencer950bf602007-01-26 08:19:09 +00004769 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
4770 CurModule.ModuleDone();
4771 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004772 break;
4773
4774 case 180:
Reid Spencer950bf602007-01-26 08:19:09 +00004775#line 2388 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4776 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004777 break;
4778
4779 case 181:
Reid Spencer950bf602007-01-26 08:19:09 +00004780#line 2389 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4781 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004782 break;
4783
4784 case 182:
Reid Spencer950bf602007-01-26 08:19:09 +00004785#line 2390 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4786 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
4787 break;
4788
4789 case 183:
4790#line 2391 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4791 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004792 break;
4793
4794 case 184:
Reid Spencer950bf602007-01-26 08:19:09 +00004795#line 2392 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4796 {
4797 (yyval.ModuleVal) = CurModule.CurrentModule;
4798 // Emit an error if there are any unresolved types left.
4799 if (!CurModule.LateResolveTypes.empty()) {
4800 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4801 if (DID.Type == ValID::NameVal) {
4802 error("Reference to an undefined type: '"+DID.getName() + "'");
4803 } else {
4804 error("Reference to an undefined type: #" + itostr(DID.Num));
4805 }
4806 }
4807 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004808 break;
4809
4810 case 185:
Reid Spencer950bf602007-01-26 08:19:09 +00004811#line 2408 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004812 {
Reid Spencer950bf602007-01-26 08:19:09 +00004813 // Eagerly resolve types. This is not an optimization, this is a
4814 // requirement that is due to the fact that we could have this:
4815 //
4816 // %list = type { %list * }
4817 // %list = type { %list * } ; repeated type decl
4818 //
4819 // If types are not resolved eagerly, then the two types will not be
4820 // determined to be the same type!
4821 //
4822 const Type* Ty = (yyvsp[0].TypeVal).T->get();
4823 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
4824
4825 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
4826 // If this is a named type that is not a redefinition, add it to the slot
4827 // table.
4828 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004829 }
Reid Spencer950bf602007-01-26 08:19:09 +00004830 delete (yyvsp[0].TypeVal).T;
4831 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004832 break;
4833
4834 case 186:
Reid Spencer950bf602007-01-26 08:19:09 +00004835#line 2428 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004836 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004837 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004838 break;
4839
4840 case 187:
Reid Spencer950bf602007-01-26 08:19:09 +00004841#line 2430 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004842 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004843 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004844 break;
4845
4846 case 188:
Reid Spencer950bf602007-01-26 08:19:09 +00004847#line 2432 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004848 {
Reid Spencer950bf602007-01-26 08:19:09 +00004849 if ((yyvsp[0].ConstVal).C == 0)
4850 error("Global value initializer is not a constant");
4851 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C);
4852 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004853 break;
4854
4855 case 189:
Reid Spencer950bf602007-01-26 08:19:09 +00004856#line 2436 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004857 {
Reid Spencer950bf602007-01-26 08:19:09 +00004858 CurGV = 0;
4859 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004860 break;
4861
4862 case 190:
Reid Spencer950bf602007-01-26 08:19:09 +00004863#line 2439 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004864 {
Reid Spencer950bf602007-01-26 08:19:09 +00004865 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4866 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4867 delete (yyvsp[0].TypeVal).T;
4868 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004869 break;
4870
4871 case 191:
Reid Spencer950bf602007-01-26 08:19:09 +00004872#line 2443 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004873 {
Reid Spencer950bf602007-01-26 08:19:09 +00004874 CurGV = 0;
4875 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004876 break;
4877
4878 case 192:
Reid Spencer950bf602007-01-26 08:19:09 +00004879#line 2446 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4880 {
4881 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4882 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4883 delete (yyvsp[0].TypeVal).T;
4884 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004885 break;
4886
4887 case 193:
Reid Spencer950bf602007-01-26 08:19:09 +00004888#line 2450 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004889 {
Reid Spencer950bf602007-01-26 08:19:09 +00004890 CurGV = 0;
4891 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004892 break;
4893
4894 case 194:
Reid Spencer950bf602007-01-26 08:19:09 +00004895#line 2453 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4896 {
4897 const Type *Ty = (yyvsp[0].TypeVal).T->get();
4898 CurGV =
4899 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
4900 delete (yyvsp[0].TypeVal).T;
4901 ;}
4902 break;
4903
4904 case 195:
4905#line 2458 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4906 {
4907 CurGV = 0;
4908 ;}
4909 break;
4910
4911 case 196:
4912#line 2461 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004913 {
Reid Spencer950bf602007-01-26 08:19:09 +00004914 ;}
4915 break;
4916
4917 case 197:
4918#line 2463 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4919 {
4920 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004921 break;
4922
4923 case 198:
Reid Spencer950bf602007-01-26 08:19:09 +00004924#line 2465 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4925 {
4926 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004927 break;
4928
4929 case 199:
Reid Spencer950bf602007-01-26 08:19:09 +00004930#line 2470 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004931 {
Reid Spencer950bf602007-01-26 08:19:09 +00004932 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4933 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4934 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4935 free((yyvsp[0].StrVal));
4936
4937 if (AsmSoFar.empty())
4938 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4939 else
4940 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4941 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004942 break;
4943
4944 case 200:
Reid Spencer950bf602007-01-26 08:19:09 +00004945#line 2484 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4946 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004947 break;
4948
4949 case 201:
Reid Spencer950bf602007-01-26 08:19:09 +00004950#line 2485 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4951 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004952 break;
4953
4954 case 202:
Reid Spencer950bf602007-01-26 08:19:09 +00004955#line 2489 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004956 {
Reid Spencer950bf602007-01-26 08:19:09 +00004957 CurModule.setEndianness((yyvsp[0].Endianness));
4958 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004959 break;
4960
4961 case 203:
Reid Spencer950bf602007-01-26 08:19:09 +00004962#line 2492 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004963 {
Reid Spencer950bf602007-01-26 08:19:09 +00004964 if ((yyvsp[0].UInt64Val) == 32)
4965 CurModule.setPointerSize(Module::Pointer32);
4966 else if ((yyvsp[0].UInt64Val) == 64)
4967 CurModule.setPointerSize(Module::Pointer64);
4968 else
4969 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
4970 ;}
4971 break;
4972
4973 case 204:
4974#line 2500 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4975 {
4976 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4977 free((yyvsp[0].StrVal));
4978 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004979 break;
4980
4981 case 205:
Reid Spencer950bf602007-01-26 08:19:09 +00004982#line 2504 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004983 {
Reid Spencer950bf602007-01-26 08:19:09 +00004984 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4985 free((yyvsp[0].StrVal));
4986 ;}
4987 break;
4988
4989 case 207:
4990#line 2515 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4991 {
4992 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4993 free((yyvsp[0].StrVal));
4994 ;}
4995 break;
4996
4997 case 208:
4998#line 2519 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
4999 {
5000 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5001 free((yyvsp[0].StrVal));
5002 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005003 break;
5004
5005 case 209:
Reid Spencer950bf602007-01-26 08:19:09 +00005006#line 2523 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5007 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005008 break;
5009
Reid Spencerc4d96252007-01-13 00:03:30 +00005010 case 213:
Reid Spencer950bf602007-01-26 08:19:09 +00005011#line 2536 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5012 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005013 break;
5014
Reid Spencer319a7302007-01-05 17:20:02 +00005015 case 214:
Reid Spencer950bf602007-01-26 08:19:09 +00005016#line 2540 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005017 {
Reid Spencer950bf602007-01-26 08:19:09 +00005018 if ((yyvsp[-1].TypeVal).T->get() == Type::VoidTy)
5019 error("void typed arguments are invalid");
5020 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
5021 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005022 break;
5023
5024 case 215:
Reid Spencer950bf602007-01-26 08:19:09 +00005025#line 2548 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005026 {
Reid Spencer950bf602007-01-26 08:19:09 +00005027 (yyval.ArgList) = (yyvsp[-2].ArgList);
5028 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5029 delete (yyvsp[0].ArgVal);
5030 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005031 break;
5032
5033 case 216:
Reid Spencer950bf602007-01-26 08:19:09 +00005034#line 2553 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5035 {
5036 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5037 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5038 delete (yyvsp[0].ArgVal);
5039 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005040 break;
5041
5042 case 217:
Reid Spencer950bf602007-01-26 08:19:09 +00005043#line 2561 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5044 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005045 break;
5046
5047 case 218:
Reid Spencer950bf602007-01-26 08:19:09 +00005048#line 2562 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5049 {
5050 (yyval.ArgList) = (yyvsp[-2].ArgList);
5051 PATypeInfo VoidTI;
5052 VoidTI.T = new PATypeHolder(Type::VoidTy);
5053 VoidTI.S = Signless;
5054 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5055 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005056 break;
5057
5058 case 219:
Reid Spencer950bf602007-01-26 08:19:09 +00005059#line 2569 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5060 {
5061 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5062 PATypeInfo VoidTI;
5063 VoidTI.T = new PATypeHolder(Type::VoidTy);
5064 VoidTI.S = Signless;
5065 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5066 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005067 break;
5068
5069 case 220:
Reid Spencer950bf602007-01-26 08:19:09 +00005070#line 2576 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5071 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005072 break;
5073
5074 case 221:
Reid Spencer950bf602007-01-26 08:19:09 +00005075#line 2580 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005076 {
Reid Spencer950bf602007-01-26 08:19:09 +00005077 UnEscapeLexed((yyvsp[-5].StrVal));
5078 std::string FunctionName((yyvsp[-5].StrVal));
5079 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
5080
5081 const Type* RetTy = (yyvsp[-6].TypeVal).T->get();
5082
5083 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5084 error("LLVM functions cannot return aggregate types");
5085
5086 std::vector<const Type*> ParamTypeList;
5087
5088 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5089 // i8*. We check here for those names and override the parameter list
5090 // types to ensure the prototype is correct.
5091 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5092 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5093 } else if (FunctionName == "llvm.va_copy") {
5094 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5095 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5096 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
5097 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5098 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
5099 const Type *Ty = I->first.T->get();
5100 ParamTypeList.push_back(Ty);
5101 }
5102 }
5103
5104 bool isVarArg =
5105 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5106 if (isVarArg) ParamTypeList.pop_back();
5107
5108 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
5109 const PointerType *PFT = PointerType::get(FT);
5110 delete (yyvsp[-6].TypeVal).T;
5111
5112 ValID ID;
5113 if (!FunctionName.empty()) {
5114 ID = ValID::create((char*)FunctionName.c_str());
5115 } else {
5116 ID = ValID::create((int)CurModule.Values[PFT].size());
5117 }
5118
5119 Function *Fn = 0;
5120 // See if this function was forward referenced. If so, recycle the object.
5121 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5122 // Move the function to the end of the list, from whereever it was
5123 // previously inserted.
5124 Fn = cast<Function>(FWRef);
5125 CurModule.CurrentModule->getFunctionList().remove(Fn);
5126 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5127 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5128 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5129 // If this is the case, either we need to be a forward decl, or it needs
5130 // to be.
5131 if (!CurFun.isDeclare && !Fn->isExternal())
5132 error("Redefinition of function '" + FunctionName + "'");
5133
5134 // Make sure to strip off any argument names so we can't get conflicts.
5135 if (Fn->isExternal())
5136 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5137 AI != AE; ++AI)
5138 AI->setName("");
5139 } else { // Not already defined?
5140 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5141 CurModule.CurrentModule);
5142
5143 InsertValue(Fn, CurModule.Values);
5144 }
5145
5146 CurFun.FunctionStart(Fn);
5147
5148 if (CurFun.isDeclare) {
5149 // If we have declaration, always overwrite linkage. This will allow us
5150 // to correctly handle cases, when pointer to function is passed as
5151 // argument to another function.
5152 Fn->setLinkage(CurFun.Linkage);
5153 }
5154 Fn->setCallingConv((yyvsp[-7].UIntVal));
5155 Fn->setAlignment((yyvsp[0].UIntVal));
5156 if ((yyvsp[-1].StrVal)) {
5157 Fn->setSection((yyvsp[-1].StrVal));
5158 free((yyvsp[-1].StrVal));
5159 }
5160
5161 // Add all of the arguments we parsed to the function...
5162 if ((yyvsp[-3].ArgList)) { // Is null if empty...
5163 if (isVarArg) { // Nuke the last entry
5164 assert((yyvsp[-3].ArgList)->back().first.T->get() == Type::VoidTy &&
5165 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5166 delete (yyvsp[-3].ArgList)->back().first.T;
5167 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
5168 }
5169 Function::arg_iterator ArgIt = Fn->arg_begin();
5170 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
5171 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I, ++ArgIt) {
5172 delete I->first.T; // Delete the typeholder...
5173 setValueName(ArgIt, I->second); // Insert arg into symtab...
5174 InsertValue(ArgIt);
5175 }
5176 delete (yyvsp[-3].ArgList); // We're now done with the argument list
5177 }
5178 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005179 break;
5180
5181 case 224:
Reid Spencer950bf602007-01-26 08:19:09 +00005182#line 2690 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5183 {
5184 (yyval.FunctionVal) = CurFun.CurrentFunction;
5185
5186 // Make sure that we keep track of the linkage type even if there was a
5187 // previous "declare".
5188 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
5189 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005190 break;
5191
5192 case 227:
Reid Spencer950bf602007-01-26 08:19:09 +00005193#line 2704 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5194 {
5195 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5196 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005197 break;
5198
5199 case 229:
Reid Spencer950bf602007-01-26 08:19:09 +00005200#line 2710 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5201 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5202 break;
5203
5204 case 230:
5205#line 2711 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5206 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5207 break;
5208
5209 case 231:
5210#line 2715 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5211 { CurFun.isDeclare = true; ;}
5212 break;
5213
5214 case 232:
5215#line 2715 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5216 {
5217 (yyval.FunctionVal) = CurFun.CurrentFunction;
5218 CurFun.FunctionDone();
5219
5220 ;}
5221 break;
5222
5223 case 233:
5224#line 2727 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5225 { (yyval.BoolVal) = false; ;}
5226 break;
5227
5228 case 234:
5229#line 2728 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5230 { (yyval.BoolVal) = true; ;}
5231 break;
5232
5233 case 235:
5234#line 2733 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5235 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
5236 break;
5237
5238 case 236:
5239#line 2734 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5240 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5241 break;
5242
5243 case 237:
5244#line 2735 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5245 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5246 break;
5247
5248 case 238:
5249#line 2736 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5250 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005251 break;
5252
Reid Spencerc4d96252007-01-13 00:03:30 +00005253 case 239:
Reid Spencer950bf602007-01-26 08:19:09 +00005254#line 2737 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5255 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5256 break;
5257
5258 case 240:
5259#line 2738 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5260 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005261 break;
5262
Reid Spencerc4d96252007-01-13 00:03:30 +00005263 case 241:
Reid Spencer950bf602007-01-26 08:19:09 +00005264#line 2739 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5265 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5266 break;
5267
5268 case 242:
5269#line 2740 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5270 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5271 break;
5272
5273 case 243:
5274#line 2741 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5275 { // Nonempty unsized packed vector
5276 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5277 int NumElements = (yyvsp[-1].ConstVector)->size();
5278 PackedType* pt = PackedType::get(ETy, NumElements);
5279 PATypeHolder* PTy = new PATypeHolder(
5280 HandleUpRefs(PackedType::get(ETy, NumElements)));
5281
5282 // Verify all elements are correct type!
5283 std::vector<Constant*> Elems;
5284 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5285 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
5286 const Type *CTy = C->getType();
5287 if (ETy != CTy)
5288 error("Element #" + utostr(i) + " is not of type '" +
5289 ETy->getDescription() +"' as required!\nIt is of type '" +
5290 CTy->getDescription() + "'");
5291 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005292 }
Reid Spencer950bf602007-01-26 08:19:09 +00005293 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
5294 delete PTy; delete (yyvsp[-1].ConstVector);
5295 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005296 break;
5297
Reid Spencerc4d96252007-01-13 00:03:30 +00005298 case 244:
Reid Spencer950bf602007-01-26 08:19:09 +00005299#line 2762 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005300 {
Reid Spencer950bf602007-01-26 08:19:09 +00005301 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
5302 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005303 break;
5304
Reid Spencerc4d96252007-01-13 00:03:30 +00005305 case 245:
Reid Spencer950bf602007-01-26 08:19:09 +00005306#line 2765 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005307 {
Reid Spencer950bf602007-01-26 08:19:09 +00005308 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5309 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5310 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5311 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5312 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5313 free((yyvsp[-2].StrVal));
5314 free((yyvsp[0].StrVal));
5315 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005316 break;
5317
Reid Spencerc4d96252007-01-13 00:03:30 +00005318 case 246:
Reid Spencer950bf602007-01-26 08:19:09 +00005319#line 2780 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5320 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005321 break;
5322
Reid Spencer319a7302007-01-05 17:20:02 +00005323 case 247:
Reid Spencer950bf602007-01-26 08:19:09 +00005324#line 2781 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5325 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005326 break;
5327
5328 case 250:
Reid Spencer950bf602007-01-26 08:19:09 +00005329#line 2794 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5330 {
5331 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
5332 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
5333 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
5334 delete (yyvsp[-1].TypeVal).T;
5335 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005336 break;
5337
Reid Spencerc4d96252007-01-13 00:03:30 +00005338 case 251:
Reid Spencer950bf602007-01-26 08:19:09 +00005339#line 2803 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005340 {
Reid Spencer950bf602007-01-26 08:19:09 +00005341 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5342 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005343 break;
5344
Reid Spencerc4d96252007-01-13 00:03:30 +00005345 case 252:
Reid Spencer950bf602007-01-26 08:19:09 +00005346#line 2806 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5347 { // Do not allow functions with 0 basic blocks
5348 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5349 ;}
5350 break;
5351
5352 case 253:
5353#line 2815 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005354 {
Reid Spencer950bf602007-01-26 08:19:09 +00005355 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
5356 InsertValue((yyvsp[0].TermInstVal));
5357 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5358 InsertValue((yyvsp[-2].BasicBlockVal));
5359 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5360 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005361 break;
5362
Reid Spencerc4d96252007-01-13 00:03:30 +00005363 case 254:
Reid Spencer950bf602007-01-26 08:19:09 +00005364#line 2825 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5365 {
5366 if ((yyvsp[0].InstVal).I)
5367 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5368 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5369 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005370 break;
5371
Reid Spencerc4d96252007-01-13 00:03:30 +00005372 case 255:
Reid Spencer950bf602007-01-26 08:19:09 +00005373#line 2830 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5374 {
5375 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5376 // Make sure to move the basic block to the correct location in the
5377 // function, instead of leaving it inserted wherever it was first
5378 // referenced.
5379 Function::BasicBlockListType &BBL =
5380 CurFun.CurrentFunction->getBasicBlockList();
5381 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5382 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005383 break;
5384
Reid Spencerc4d96252007-01-13 00:03:30 +00005385 case 256:
Reid Spencer950bf602007-01-26 08:19:09 +00005386#line 2839 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5387 {
5388 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
5389 // Make sure to move the basic block to the correct location in the
5390 // function, instead of leaving it inserted wherever it was first
5391 // referenced.
5392 Function::BasicBlockListType &BBL =
5393 CurFun.CurrentFunction->getBasicBlockList();
5394 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5395 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005396 break;
5397
Reid Spencerc4d96252007-01-13 00:03:30 +00005398 case 259:
Reid Spencer950bf602007-01-26 08:19:09 +00005399#line 2853 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5400 { // Return with a result...
5401 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
5402 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005403 break;
5404
Reid Spencerc4d96252007-01-13 00:03:30 +00005405 case 260:
Reid Spencer950bf602007-01-26 08:19:09 +00005406#line 2856 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5407 { // Return with no result...
5408 (yyval.TermInstVal) = new ReturnInst();
5409 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005410 break;
5411
Reid Spencerc4d96252007-01-13 00:03:30 +00005412 case 261:
Reid Spencer950bf602007-01-26 08:19:09 +00005413#line 2859 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5414 { // Unconditional Branch...
5415 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5416 (yyval.TermInstVal) = new BranchInst(tmpBB);
5417 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005418 break;
5419
Reid Spencer319a7302007-01-05 17:20:02 +00005420 case 262:
Reid Spencer950bf602007-01-26 08:19:09 +00005421#line 2863 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5422 {
5423 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5424 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5425 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5426 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5427 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005428 break;
5429
5430 case 263:
Reid Spencer950bf602007-01-26 08:19:09 +00005431#line 2869 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005432 {
Reid Spencer950bf602007-01-26 08:19:09 +00005433 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5434 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5435 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5436 (yyval.TermInstVal) = S;
5437 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5438 E = (yyvsp[-1].JumpTable)->end();
5439 for (; I != E; ++I) {
5440 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5441 S->addCase(CI, I->second);
5442 else
5443 error("Switch case is constant, but not a simple integer");
5444 }
5445 delete (yyvsp[-1].JumpTable);
5446 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005447 break;
5448
5449 case 264:
Reid Spencer950bf602007-01-26 08:19:09 +00005450#line 2884 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005451 {
Reid Spencer950bf602007-01-26 08:19:09 +00005452 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5453 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
5454 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5455 (yyval.TermInstVal) = S;
5456 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005457 break;
5458
Reid Spencerc4d96252007-01-13 00:03:30 +00005459 case 265:
Reid Spencer950bf602007-01-26 08:19:09 +00005460#line 2891 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005461 {
Reid Spencer950bf602007-01-26 08:19:09 +00005462 const PointerType *PFTy;
5463 const FunctionType *Ty;
5464
5465 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).T->get())) ||
5466 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5467 // Pull out the types of all of the arguments...
5468 std::vector<const Type*> ParamTypes;
5469 if ((yyvsp[-7].ValueList)) {
5470 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
5471 I != E; ++I)
5472 ParamTypes.push_back((*I).V->getType());
5473 }
5474 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5475 if (isVarArg) ParamTypes.pop_back();
5476 Ty = FunctionType::get((yyvsp[-10].TypeVal).T->get(), ParamTypes, isVarArg);
5477 PFTy = PointerType::get(Ty);
5478 }
5479 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5480 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5481 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
5482
5483 // Create the call node...
5484 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
5485 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5486 } else { // Has arguments?
5487 // Loop through FunctionType's arguments and ensure they are specified
5488 // correctly!
5489 //
5490 FunctionType::param_iterator I = Ty->param_begin();
5491 FunctionType::param_iterator E = Ty->param_end();
5492 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
5493
5494 std::vector<Value*> Args;
5495 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5496 if ((*ArgI).V->getType() != *I)
5497 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5498 (*I)->getDescription() + "'");
5499 Args.push_back((*ArgI).V);
5500 }
5501
5502 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5503 error("Invalid number of parameters detected");
5504
5505 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5506 }
5507 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
5508 delete (yyvsp[-10].TypeVal).T;
5509 delete (yyvsp[-7].ValueList);
5510 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005511 break;
5512
Reid Spencerc4d96252007-01-13 00:03:30 +00005513 case 266:
Reid Spencer950bf602007-01-26 08:19:09 +00005514#line 2941 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005515 {
Reid Spencer950bf602007-01-26 08:19:09 +00005516 (yyval.TermInstVal) = new UnwindInst();
5517 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005518 break;
5519
Reid Spencerc4d96252007-01-13 00:03:30 +00005520 case 267:
Reid Spencer950bf602007-01-26 08:19:09 +00005521#line 2944 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5522 {
5523 (yyval.TermInstVal) = new UnreachableInst();
5524 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005525 break;
5526
Reid Spencerc4d96252007-01-13 00:03:30 +00005527 case 268:
Reid Spencer950bf602007-01-26 08:19:09 +00005528#line 2950 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005529 {
Reid Spencer950bf602007-01-26 08:19:09 +00005530 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5531 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5532
5533 if (V == 0)
5534 error("May only switch on a constant pool value");
5535
5536 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5537 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5538 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005539 break;
5540
Reid Spencerc4d96252007-01-13 00:03:30 +00005541 case 269:
Reid Spencer950bf602007-01-26 08:19:09 +00005542#line 2960 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005543 {
Reid Spencer950bf602007-01-26 08:19:09 +00005544 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5545 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
5546
5547 if (V == 0)
5548 error("May only switch on a constant pool value");
5549
5550 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5551 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5552 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005553 break;
5554
Reid Spencerc4d96252007-01-13 00:03:30 +00005555 case 270:
Reid Spencer950bf602007-01-26 08:19:09 +00005556#line 2973 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005557 {
Reid Spencer950bf602007-01-26 08:19:09 +00005558 bool omit = false;
5559 if ((yyvsp[-1].StrVal))
5560 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
5561 if (BCI->getSrcTy() == BCI->getDestTy() &&
5562 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
5563 // This is a useless bit cast causing a name redefinition. It is
5564 // a bit cast from a type to the same type of an operand with the
5565 // same name as the name we would give this instruction. Since this
5566 // instruction results in no code generation, it is safe to omit
5567 // the instruction. This situation can occur because of collapsed
5568 // type planes. For example:
5569 // %X = add int %Y, %Z
5570 // %X = cast int %Y to uint
5571 // After upgrade, this looks like:
5572 // %X = add i32 %Y, %Z
5573 // %X = bitcast i32 to i32
5574 // The bitcast is clearly useless so we omit it.
5575 omit = true;
5576 if (omit) {
5577 (yyval.InstVal).I = 0;
5578 (yyval.InstVal).S = Signless;
5579 } else {
5580 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
5581 InsertValue((yyvsp[0].InstVal).I);
5582 (yyval.InstVal) = (yyvsp[0].InstVal);
5583 }
5584 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005585 break;
5586
Reid Spencerc4d96252007-01-13 00:03:30 +00005587 case 271:
Reid Spencer950bf602007-01-26 08:19:09 +00005588#line 3002 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5589 { // Used for PHI nodes
5590 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5591 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
5592 Value* tmpVal = getVal((yyvsp[-5].TypeVal).T->get(), (yyvsp[-3].ValIDVal));
5593 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5594 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5595 delete (yyvsp[-5].TypeVal).T;
5596 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005597 break;
5598
Reid Spencerc4d96252007-01-13 00:03:30 +00005599 case 272:
Reid Spencer950bf602007-01-26 08:19:09 +00005600#line 3010 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5601 {
5602 (yyval.PHIList) = (yyvsp[-6].PHIList);
5603 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5604 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5605 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5606 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005607 break;
5608
Reid Spencerc4d96252007-01-13 00:03:30 +00005609 case 273:
Reid Spencer950bf602007-01-26 08:19:09 +00005610#line 3018 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5611 { // Used for call statements, and memory insts...
5612 (yyval.ValueList) = new std::vector<ValueInfo>();
5613 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5614 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005615 break;
5616
Reid Spencer950bf602007-01-26 08:19:09 +00005617 case 274:
5618#line 3022 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005619 {
Reid Spencer950bf602007-01-26 08:19:09 +00005620 (yyval.ValueList) = (yyvsp[-2].ValueList);
5621 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
5622 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005623 break;
5624
Reid Spencerc4d96252007-01-13 00:03:30 +00005625 case 276:
Reid Spencer950bf602007-01-26 08:19:09 +00005626#line 3030 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5627 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005628 break;
5629
Reid Spencerc4d96252007-01-13 00:03:30 +00005630 case 277:
Reid Spencer950bf602007-01-26 08:19:09 +00005631#line 3034 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005632 {
Reid Spencer950bf602007-01-26 08:19:09 +00005633 (yyval.BoolVal) = true;
5634 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005635 break;
5636
Reid Spencer319a7302007-01-05 17:20:02 +00005637 case 278:
Reid Spencer950bf602007-01-26 08:19:09 +00005638#line 3037 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005639 {
Reid Spencer950bf602007-01-26 08:19:09 +00005640 (yyval.BoolVal) = false;
5641 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005642 break;
5643
5644 case 279:
Reid Spencer950bf602007-01-26 08:19:09 +00005645#line 3043 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005646 {
Reid Spencer950bf602007-01-26 08:19:09 +00005647 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
5648 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5649 error("Arithmetic operator requires integer, FP, or packed operands");
5650 if (isa<PackedType>(Ty) &&
5651 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
5652 error("Remainder not supported on packed types");
5653 // Upgrade the opcode from obsolete versions before we do anything with it.
5654 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5655 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5656 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
5657 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5658 if ((yyval.InstVal).I == 0)
5659 error("binary operator returned null");
5660 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5661 delete (yyvsp[-3].TypeVal).T;
5662 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005663 break;
5664
5665 case 280:
Reid Spencer950bf602007-01-26 08:19:09 +00005666#line 3060 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005667 {
Reid Spencer950bf602007-01-26 08:19:09 +00005668 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5669 if (!Ty->isInteger()) {
5670 if (!isa<PackedType>(Ty) ||
5671 !cast<PackedType>(Ty)->getElementType()->isInteger())
5672 error("Logical operator requires integral operands");
5673 }
5674 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5675 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5676 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5677 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5678 if ((yyval.InstVal).I == 0)
5679 error("binary operator returned null");
5680 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5681 delete (yyvsp[-3].TypeVal).T;
5682 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005683 break;
5684
Reid Spencerc4d96252007-01-13 00:03:30 +00005685 case 281:
Reid Spencer950bf602007-01-26 08:19:09 +00005686#line 3076 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005687 {
Reid Spencer950bf602007-01-26 08:19:09 +00005688 const Type* Ty = (yyvsp[-3].TypeVal).T->get();
5689 if(isa<PackedType>(Ty))
5690 error("PackedTypes currently not supported in setcc instructions");
5691 unsigned short pred;
5692 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5693 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5694 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5695 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5696 if ((yyval.InstVal).I == 0)
5697 error("binary operator returned null");
5698 (yyval.InstVal).S = Unsigned;
5699 delete (yyvsp[-3].TypeVal).T;
5700 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005701 break;
5702
Reid Spencerc4d96252007-01-13 00:03:30 +00005703 case 282:
Reid Spencer950bf602007-01-26 08:19:09 +00005704#line 3090 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005705 {
Reid Spencer950bf602007-01-26 08:19:09 +00005706 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5707 if (isa<PackedType>(Ty))
5708 error("PackedTypes currently not supported in icmp instructions");
5709 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5710 error("icmp requires integer or pointer typed operands");
5711 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5712 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5713 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
5714 (yyval.InstVal).S = Unsigned;
5715 delete (yyvsp[-3].TypeVal).T;
5716 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005717 break;
5718
Reid Spencerc4d96252007-01-13 00:03:30 +00005719 case 283:
Reid Spencer950bf602007-01-26 08:19:09 +00005720#line 3102 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005721 {
Reid Spencer950bf602007-01-26 08:19:09 +00005722 const Type *Ty = (yyvsp[-3].TypeVal).T->get();
5723 if (isa<PackedType>(Ty))
5724 error("PackedTypes currently not supported in fcmp instructions");
5725 else if (!Ty->isFloatingPoint())
5726 error("fcmp instruction requires floating point operands");
5727 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5728 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5729 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
5730 (yyval.InstVal).S = Unsigned;
5731 delete (yyvsp[-3].TypeVal).T;
5732 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005733 break;
5734
Reid Spencerc4d96252007-01-13 00:03:30 +00005735 case 284:
Reid Spencer950bf602007-01-26 08:19:09 +00005736#line 3114 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005737 {
Reid Spencer950bf602007-01-26 08:19:09 +00005738 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5739 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
5740 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5741 if (Ones == 0)
5742 error("Expected integral type for not instruction");
5743 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
5744 if ((yyval.InstVal).I == 0)
5745 error("Could not create a xor instruction");
5746 (yyval.InstVal).S = (yyvsp[0].ValueVal).S
5747 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005748 break;
5749
5750 case 285:
Reid Spencer950bf602007-01-26 08:19:09 +00005751#line 3125 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005752 {
Reid Spencer950bf602007-01-26 08:19:09 +00005753 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5754 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
5755 error("Shift amount must be int8");
5756 if (!(yyvsp[-2].ValueVal).V->getType()->isInteger())
5757 error("Shift constant expression requires integer operand");
5758 (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5759 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5760 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005761 break;
5762
5763 case 286:
Reid Spencer950bf602007-01-26 08:19:09 +00005764#line 3134 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005765 {
Reid Spencer950bf602007-01-26 08:19:09 +00005766 const Type *DstTy = (yyvsp[0].TypeVal).T->get();
5767 if (!DstTy->isFirstClassType())
5768 error("cast instruction to a non-primitive type: '" +
5769 DstTy->getDescription() + "'");
5770 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5771 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5772 delete (yyvsp[0].TypeVal).T;
5773 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005774 break;
5775
5776 case 287:
Reid Spencer950bf602007-01-26 08:19:09 +00005777#line 3143 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005778 {
Reid Spencer950bf602007-01-26 08:19:09 +00005779 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5780 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
5781 error("select condition must be bool");
5782 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
5783 error("select value types should match");
5784 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5785 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5786 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005787 break;
5788
Reid Spencerc4d96252007-01-13 00:03:30 +00005789 case 288:
Reid Spencer950bf602007-01-26 08:19:09 +00005790#line 3152 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005791 {
Reid Spencer950bf602007-01-26 08:19:09 +00005792 const Type *Ty = (yyvsp[0].TypeVal).T->get();
5793 NewVarArgs = true;
5794 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5795 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5796 delete (yyvsp[0].TypeVal).T;
5797 ;}
5798 break;
5799
5800 case 289:
5801#line 3159 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5802 {
5803 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5804 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
5805 ObsoleteVarArgs = true;
5806 Function* NF = cast<Function>(CurModule.CurrentModule->
5807 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5808
5809 //b = vaarg a, t ->
5810 //foo = alloca 1 of t
5811 //bar = vacopy a
5812 //store bar -> foo
5813 //b = vaarg foo, t
5814 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5815 CurBB->getInstList().push_back(foo);
5816 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5817 CurBB->getInstList().push_back(bar);
5818 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5819 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5820 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5821 delete (yyvsp[0].TypeVal).T;
5822 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005823 break;
5824
Reid Spencerc4d96252007-01-13 00:03:30 +00005825 case 290:
Reid Spencer950bf602007-01-26 08:19:09 +00005826#line 3180 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5827 {
5828 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5829 const Type* DstTy = (yyvsp[0].TypeVal).T->get();
5830 ObsoleteVarArgs = true;
5831 Function* NF = cast<Function>(CurModule.CurrentModule->
5832 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5833
5834 //b = vanext a, t ->
5835 //foo = alloca 1 of t
5836 //bar = vacopy a
5837 //store bar -> foo
5838 //tmp = vaarg foo, t
5839 //b = load foo
5840 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5841 CurBB->getInstList().push_back(foo);
5842 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
5843 CurBB->getInstList().push_back(bar);
5844 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5845 Instruction* tmp = new VAArgInst(foo, DstTy);
5846 CurBB->getInstList().push_back(tmp);
5847 (yyval.InstVal).I = new LoadInst(foo);
5848 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5849 delete (yyvsp[0].TypeVal).T;
5850 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005851 break;
5852
Reid Spencerc4d96252007-01-13 00:03:30 +00005853 case 291:
Reid Spencer950bf602007-01-26 08:19:09 +00005854#line 3204 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5855 {
5856 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5857 error("Invalid extractelement operands");
5858 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5859 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5860 ;}
5861 break;
5862
5863 case 292:
5864#line 3210 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5865 {
5866 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5867 error("Invalid insertelement operands");
5868 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5869 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5870 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005871 break;
5872
Reid Spencerc4d96252007-01-13 00:03:30 +00005873 case 293:
Reid Spencer950bf602007-01-26 08:19:09 +00005874#line 3216 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5875 {
5876 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
5877 error("Invalid shufflevector operands");
5878 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5879 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5880 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005881 break;
5882
Reid Spencerc4d96252007-01-13 00:03:30 +00005883 case 294:
Reid Spencer950bf602007-01-26 08:19:09 +00005884#line 3222 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005885 {
Reid Spencer950bf602007-01-26 08:19:09 +00005886 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
5887 if (!Ty->isFirstClassType())
5888 error("PHI node operands must be of first class type");
5889 PHINode *PHI = new PHINode(Ty);
5890 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5891 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5892 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
5893 error("All elements of a PHI node must be of the same type");
5894 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5895 (yyvsp[0].PHIList).P->pop_front();
5896 }
5897 (yyval.InstVal).I = PHI;
5898 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5899 delete (yyvsp[0].PHIList).P; // Free the list...
5900 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005901 break;
5902
5903 case 295:
Reid Spencer950bf602007-01-26 08:19:09 +00005904#line 3238 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005905 {
Reid Spencer950bf602007-01-26 08:19:09 +00005906
5907 // Handle the short call syntax
5908 const PointerType *PFTy;
5909 const FunctionType *FTy;
5910 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).T->get())) ||
5911 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5912 // Pull out the types of all of the arguments...
5913 std::vector<const Type*> ParamTypes;
5914 if ((yyvsp[-1].ValueList)) {
5915 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
5916 I != E; ++I)
5917 ParamTypes.push_back((*I).V->getType());
5918 }
5919
5920 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5921 if (isVarArg) ParamTypes.pop_back();
5922
5923 const Type *RetTy = (yyvsp[-4].TypeVal).T->get();
5924 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5925 error("Functions cannot return aggregate types");
5926
5927 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
5928 PFTy = PointerType::get(FTy);
5929 }
5930
5931 // First upgrade any intrinsic calls.
5932 std::vector<Value*> Args;
5933 if ((yyvsp[-1].ValueList))
5934 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
5935 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
5936 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
5937
5938 // If we got an upgraded intrinsic
5939 if (Inst) {
5940 (yyval.InstVal).I = Inst;
5941 (yyval.InstVal).S = Signless;
5942 } else {
5943 // Get the function we're calling
5944 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
5945
5946 // Check the argument values match
5947 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
5948 // Make sure no arguments is a good thing!
5949 if (FTy->getNumParams() != 0)
5950 error("No arguments passed to a function that expects arguments");
5951 } else { // Has arguments?
5952 // Loop through FunctionType's arguments and ensure they are specified
5953 // correctly!
5954 //
5955 FunctionType::param_iterator I = FTy->param_begin();
5956 FunctionType::param_iterator E = FTy->param_end();
5957 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
5958
5959 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5960 if ((*ArgI).V->getType() != *I)
5961 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5962 (*I)->getDescription() + "'");
5963
5964 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
5965 error("Invalid number of parameters detected");
5966 }
5967
5968 // Create the call instruction
5969 CallInst *CI = new CallInst(V, Args);
5970 CI->setTailCall((yyvsp[-6].BoolVal));
5971 CI->setCallingConv((yyvsp[-5].UIntVal));
5972 (yyval.InstVal).I = CI;
5973 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
5974 }
5975 delete (yyvsp[-4].TypeVal).T;
5976 delete (yyvsp[-1].ValueList);
5977 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005978 break;
5979
Reid Spencerc4d96252007-01-13 00:03:30 +00005980 case 296:
Reid Spencer950bf602007-01-26 08:19:09 +00005981#line 3311 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005982 {
Reid Spencer950bf602007-01-26 08:19:09 +00005983 (yyval.InstVal) = (yyvsp[0].InstVal);
5984 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005985 break;
5986
Reid Spencer609ca3e2007-01-12 20:10:51 +00005987 case 297:
Reid Spencer950bf602007-01-26 08:19:09 +00005988#line 3319 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5989 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005990 break;
5991
5992 case 298:
Reid Spencer950bf602007-01-26 08:19:09 +00005993#line 3320 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5994 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005995 break;
5996
Reid Spencerc4d96252007-01-13 00:03:30 +00005997 case 299:
Reid Spencer950bf602007-01-26 08:19:09 +00005998#line 3324 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5999 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006000 break;
6001
Reid Spencerc4d96252007-01-13 00:03:30 +00006002 case 300:
Reid Spencer950bf602007-01-26 08:19:09 +00006003#line 3325 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6004 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006005 break;
6006
Reid Spencerc4d96252007-01-13 00:03:30 +00006007 case 301:
Reid Spencer950bf602007-01-26 08:19:09 +00006008#line 3329 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006009 {
Reid Spencer950bf602007-01-26 08:19:09 +00006010 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
6011 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6012 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6013 delete (yyvsp[-1].TypeVal).T;
6014 ;}
6015 break;
6016
6017 case 302:
6018#line 3335 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6019 {
6020 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6021 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6022 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6023 delete (yyvsp[-4].TypeVal).T;
6024 ;}
6025 break;
6026
6027 case 303:
6028#line 3341 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6029 {
6030 const Type *Ty = (yyvsp[-1].TypeVal).T->get();
6031 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6032 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6033 delete (yyvsp[-1].TypeVal).T;
6034 ;}
6035 break;
6036
6037 case 304:
6038#line 3347 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6039 {
6040 const Type *Ty = (yyvsp[-4].TypeVal).T->get();
6041 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
6042 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6043 delete (yyvsp[-4].TypeVal).T;
6044 ;}
6045 break;
6046
6047 case 305:
6048#line 3353 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6049 {
6050 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
6051 if (!isa<PointerType>(PTy))
6052 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
6053 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
6054 (yyval.InstVal).S = Signless;
6055 ;}
6056 break;
6057
6058 case 306:
6059#line 3360 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6060 {
6061 const Type* Ty = (yyvsp[-1].TypeVal).T->get();
6062 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6063 if (!isa<PointerType>(Ty))
6064 error("Can't load from nonpointer type: " + Ty->getDescription());
6065 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6066 error("Can't load from pointer of non-first-class type: " +
6067 Ty->getDescription());
6068 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6069 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
6070 delete (yyvsp[-1].TypeVal).T;
6071 ;}
6072 break;
6073
6074 case 307:
6075#line 3372 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6076 {
6077 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).T->get());
6078 if (!PTy)
6079 error("Can't store to a nonpointer type: " +
6080 (yyvsp[-1].TypeVal).T->get()->getDescription());
6081 const Type *ElTy = PTy->getElementType();
6082 if (ElTy != (yyvsp[-3].ValueVal).V->getType())
6083 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
6084 "' into space of type '" + ElTy->getDescription() + "'");
6085 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6086 (yyval.InstVal).I = new StoreInst((yyvsp[-3].ValueVal).V, tmpVal, (yyvsp[-5].BoolVal));
6087 (yyval.InstVal).S = Signless;
6088 delete (yyvsp[-1].TypeVal).T;
6089 ;}
6090 break;
6091
6092 case 308:
6093#line 3386 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
6094 {
6095 const Type* Ty = (yyvsp[-2].TypeVal).T->get();
6096 if (!isa<PointerType>(Ty))
6097 error("getelementptr insn requires pointer operand");
6098
6099 std::vector<Value*> VIndices;
6100 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
6101
6102 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
6103 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6104 (yyval.InstVal).S = Signless;
6105 delete (yyvsp[-2].TypeVal).T;
6106 delete (yyvsp[0].ValueList);
6107 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006108 break;
6109
6110
Reid Spencer950bf602007-01-26 08:19:09 +00006111 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006112 }
6113
Reid Spencer950bf602007-01-26 08:19:09 +00006114/* Line 1126 of yacc.c. */
6115#line 6116 "UpgradeParser.tab.c"
Reid Spencere7c3c602006-11-30 06:36:44 +00006116
6117 yyvsp -= yylen;
6118 yyssp -= yylen;
6119
Reid Spencer319a7302007-01-05 17:20:02 +00006120
Reid Spencer950bf602007-01-26 08:19:09 +00006121 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006122
6123 *++yyvsp = yyval;
6124
6125
Reid Spencer319a7302007-01-05 17:20:02 +00006126 /* Now `shift' the result of the reduction. Determine what state
6127 that goes to, based on the state we popped back to and the rule
6128 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006129
6130 yyn = yyr1[yyn];
6131
Reid Spencer319a7302007-01-05 17:20:02 +00006132 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6133 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006134 yystate = yytable[yystate];
6135 else
Reid Spencer319a7302007-01-05 17:20:02 +00006136 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006137
6138 goto yynewstate;
6139
6140
Reid Spencer319a7302007-01-05 17:20:02 +00006141/*------------------------------------.
6142| yyerrlab -- here on detecting error |
6143`------------------------------------*/
6144yyerrlab:
6145 /* If not already recovering from an error, report this error. */
6146 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006147 {
6148 ++yynerrs;
Reid Spencer319a7302007-01-05 17:20:02 +00006149#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00006150 yyn = yypact[yystate];
6151
Reid Spencer319a7302007-01-05 17:20:02 +00006152 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencere7c3c602006-11-30 06:36:44 +00006153 {
Reid Spencer319a7302007-01-05 17:20:02 +00006154 int yytype = YYTRANSLATE (yychar);
Reid Spencer950bf602007-01-26 08:19:09 +00006155 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6156 YYSIZE_T yysize = yysize0;
6157 YYSIZE_T yysize1;
6158 int yysize_overflow = 0;
6159 char *yymsg = 0;
6160# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6161 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6162 int yyx;
Reid Spencere7c3c602006-11-30 06:36:44 +00006163
Reid Spencer950bf602007-01-26 08:19:09 +00006164#if 0
6165 /* This is so xgettext sees the translatable formats that are
6166 constructed on the fly. */
6167 YY_("syntax error, unexpected %s");
6168 YY_("syntax error, unexpected %s, expecting %s");
6169 YY_("syntax error, unexpected %s, expecting %s or %s");
6170 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6171 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6172#endif
6173 char *yyfmt;
6174 char const *yyf;
6175 static char const yyunexpected[] = "syntax error, unexpected %s";
6176 static char const yyexpecting[] = ", expecting %s";
6177 static char const yyor[] = " or %s";
6178 char yyformat[sizeof yyunexpected
6179 + sizeof yyexpecting - 1
6180 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6181 * (sizeof yyor - 1))];
6182 char const *yyprefix = yyexpecting;
6183
Reid Spencer319a7302007-01-05 17:20:02 +00006184 /* Start YYX at -YYN if negative to avoid negative indexes in
6185 YYCHECK. */
Reid Spencer950bf602007-01-26 08:19:09 +00006186 int yyxbegin = yyn < 0 ? -yyn : 0;
Jeff Cohenac2dca92007-01-21 19:30:52 +00006187
Reid Spencer950bf602007-01-26 08:19:09 +00006188 /* Stay within bounds of both yycheck and yytname. */
6189 int yychecklim = YYLAST - yyn;
6190 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6191 int yycount = 1;
6192
6193 yyarg[0] = yytname[yytype];
6194 yyfmt = yystpcpy (yyformat, yyunexpected);
6195
6196 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6197 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6198 {
6199 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6200 {
6201 yycount = 1;
6202 yysize = yysize0;
6203 yyformat[sizeof yyunexpected - 1] = '\0';
6204 break;
6205 }
6206 yyarg[yycount++] = yytname[yyx];
6207 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6208 yysize_overflow |= yysize1 < yysize;
6209 yysize = yysize1;
6210 yyfmt = yystpcpy (yyfmt, yyprefix);
6211 yyprefix = yyor;
6212 }
6213
6214 yyf = YY_(yyformat);
6215 yysize1 = yysize + yystrlen (yyf);
6216 yysize_overflow |= yysize1 < yysize;
6217 yysize = yysize1;
6218
6219 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6220 yymsg = (char *) YYSTACK_ALLOC (yysize);
6221 if (yymsg)
6222 {
6223 /* Avoid sprintf, as that infringes on the user's name space.
6224 Don't have undefined behavior even if the translation
6225 produced a string with the wrong number of "%s"s. */
6226 char *yyp = yymsg;
6227 int yyi = 0;
6228 while ((*yyp = *yyf))
Reid Spencere7c3c602006-11-30 06:36:44 +00006229 {
Reid Spencer950bf602007-01-26 08:19:09 +00006230 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6231 {
6232 yyp += yytnamerr (yyp, yyarg[yyi++]);
6233 yyf += 2;
6234 }
6235 else
6236 {
6237 yyp++;
6238 yyf++;
6239 }
Reid Spencere7c3c602006-11-30 06:36:44 +00006240 }
Reid Spencer319a7302007-01-05 17:20:02 +00006241 yyerror (yymsg);
6242 YYSTACK_FREE (yymsg);
Reid Spencere7c3c602006-11-30 06:36:44 +00006243 }
6244 else
Reid Spencer950bf602007-01-26 08:19:09 +00006245 {
6246 yyerror (YY_("syntax error"));
6247 goto yyexhaustedlab;
6248 }
Reid Spencere7c3c602006-11-30 06:36:44 +00006249 }
6250 else
6251#endif /* YYERROR_VERBOSE */
Reid Spencer950bf602007-01-26 08:19:09 +00006252 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006253 }
Reid Spencer950bf602007-01-26 08:19:09 +00006254
6255
6256
6257 if (yyerrstatus == 3)
6258 {
6259 /* If just tried and failed to reuse look-ahead token after an
6260 error, discard it. */
6261
6262 if (yychar <= YYEOF)
6263 {
6264 /* Return failure if at end of input. */
6265 if (yychar == YYEOF)
6266 YYABORT;
6267 }
6268 else
6269 {
6270 yydestruct ("Error: discarding", yytoken, &yylval);
6271 yychar = YYEMPTY;
6272 }
6273 }
6274
6275 /* Else will try to reuse look-ahead token after shifting the error
6276 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006277 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006278
Reid Spencer319a7302007-01-05 17:20:02 +00006279
Reid Spencer950bf602007-01-26 08:19:09 +00006280/*---------------------------------------------------.
6281| yyerrorlab -- error raised explicitly by YYERROR. |
6282`---------------------------------------------------*/
6283yyerrorlab:
6284
6285 /* Pacify compilers like GCC when the user code never invokes
6286 YYERROR and the label yyerrorlab therefore never appears in user
6287 code. */
6288 if (0)
6289 goto yyerrorlab;
6290
6291yyvsp -= yylen;
6292 yyssp -= yylen;
6293 yystate = *yyssp;
6294 goto yyerrlab1;
6295
6296
6297/*-------------------------------------------------------------.
6298| yyerrlab1 -- common code for both syntax error and YYERROR. |
6299`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006300yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006301 yyerrstatus = 3; /* Each real token shifted decrements this. */
6302
6303 for (;;)
6304 {
6305 yyn = yypact[yystate];
6306 if (yyn != YYPACT_NINF)
6307 {
6308 yyn += YYTERROR;
6309 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6310 {
6311 yyn = yytable[yyn];
6312 if (0 < yyn)
6313 break;
6314 }
6315 }
6316
6317 /* Pop the current state because it cannot handle the error token. */
6318 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006319 YYABORT;
6320
6321
Reid Spencer950bf602007-01-26 08:19:09 +00006322 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6323 YYPOPSTACK;
6324 yystate = *yyssp;
6325 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006326 }
6327
6328 if (yyn == YYFINAL)
6329 YYACCEPT;
6330
6331 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006332
6333
Reid Spencer950bf602007-01-26 08:19:09 +00006334 /* Shift the error token. */
6335 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6336
Reid Spencere7c3c602006-11-30 06:36:44 +00006337 yystate = yyn;
6338 goto yynewstate;
6339
Chris Lattner37e01c52007-01-04 18:46:42 +00006340
Reid Spencer319a7302007-01-05 17:20:02 +00006341/*-------------------------------------.
6342| yyacceptlab -- YYACCEPT comes here. |
6343`-------------------------------------*/
6344yyacceptlab:
6345 yyresult = 0;
6346 goto yyreturn;
6347
6348/*-----------------------------------.
6349| yyabortlab -- YYABORT comes here. |
6350`-----------------------------------*/
6351yyabortlab:
6352 yyresult = 1;
6353 goto yyreturn;
6354
6355#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006356/*-------------------------------------------------.
6357| yyexhaustedlab -- memory exhaustion comes here. |
6358`-------------------------------------------------*/
6359yyexhaustedlab:
6360 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006361 yyresult = 2;
6362 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006363#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006364
6365yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006366 if (yychar != YYEOF && yychar != YYEMPTY)
6367 yydestruct ("Cleanup: discarding lookahead",
6368 yytoken, &yylval);
6369 while (yyssp != yyss)
6370 {
6371 yydestruct ("Cleanup: popping",
6372 yystos[*yyssp], yyvsp);
6373 YYPOPSTACK;
6374 }
Reid Spencer319a7302007-01-05 17:20:02 +00006375#ifndef yyoverflow
6376 if (yyss != yyssa)
6377 YYSTACK_FREE (yyss);
6378#endif
6379 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006380}
Reid Spencer319a7302007-01-05 17:20:02 +00006381
6382
Reid Spencer950bf602007-01-26 08:19:09 +00006383#line 3402 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006384
6385
6386int yyerror(const char *ErrorMsg) {
6387 std::string where
6388 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006389 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6390 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6391 if (yychar != YYEMPTY && yychar != 0)
6392 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6393 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006394 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006395 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006396 exit(1);
6397}
Reid Spencer319a7302007-01-05 17:20:02 +00006398
Reid Spencer30d0c582007-01-15 00:26:18 +00006399void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006400 std::string where
6401 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006402 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6403 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6404 if (yychar != YYEMPTY && yychar != 0)
6405 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6406 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006407 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6408}
6409
Reid Spencer950bf602007-01-26 08:19:09 +00006410void error(const std::string& ErrorMsg, int LineNo) {
6411 if (LineNo == -1) LineNo = Upgradelineno;
6412 Upgradelineno = LineNo;
6413 yyerror(ErrorMsg.c_str());
6414}
6415
6416