blob: a04facb61434b38dc4cc968bca7a5f6eb790f988 [file] [log] [blame]
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00005
Reid Spencer3fae7ba2007-03-14 23:13:06 +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 Spencer3fae7ba2007-03-14 23:13:06 +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
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
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. */
37#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000052#define yyparse Upgradeparse
Reid Spencer3fae7ba2007-03-14 23:13:06 +000053#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000054#define yyerror Upgradeerror
Reid Spencer3fae7ba2007-03-14 23:13:06 +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 Spencer3fae7ba2007-03-14 23:13:06 +000060
61/* 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 {
67 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,
109 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
112 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,
122 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,
140 UNREACHABLE = 331,
141 UNWIND = 332,
142 EXCEPT = 333,
143 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 SHL = 348,
158 SHR = 349,
159 ASHR = 350,
160 LSHR = 351,
161 SETLE = 352,
162 SETGE = 353,
163 SETLT = 354,
164 SETGT = 355,
165 SETEQ = 356,
166 SETNE = 357,
167 ICMP = 358,
168 FCMP = 359,
169 MALLOC = 360,
170 ALLOCA = 361,
171 FREE = 362,
172 LOAD = 363,
173 STORE = 364,
174 GETELEMENTPTR = 365,
175 PHI_TOK = 366,
176 SELECT = 367,
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
216 };
217#endif
218/* 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
261#define DLLIMPORT 300
262#define DLLEXPORT 301
263#define EXTERN_WEAK 302
264#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
274#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
292#define UNREACHABLE 331
293#define UNWIND 332
294#define EXCEPT 333
295#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 SHL 348
310#define SHR 349
311#define ASHR 350
312#define LSHR 351
313#define SETLE 352
314#define SETGE 353
315#define SETLT 354
316#define SETGT 355
317#define SETEQ 356
318#define SETNE 357
319#define ICMP 358
320#define FCMP 359
321#define MALLOC 360
322#define ALLOCA 361
323#define FREE 362
324#define LOAD 363
325#define STORE 364
326#define GETELEMENTPTR 365
327#define PHI_TOK 366
328#define SELECT 367
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
368
369
370
371
372/* Copy the first part of user declarations. */
373#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"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000380#include "llvm/ValueSymbolTable.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000381#include "llvm/Support/GetElementPtrTypeIterator.h"
382#include "llvm/ADT/STLExtras.h"
383#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000384#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000385#include <iostream>
Chris Lattner8adde282007-02-11 21:40:10 +0000386#include <map>
Reid Spencer950bf602007-01-26 08:19:09 +0000387#include <list>
388#include <utility>
389
390// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
391// relating to upreferences in the input stream.
392//
393//#define DEBUG_UPREFS 1
394#ifdef DEBUG_UPREFS
395#define UR_OUT(X) std::cerr << X
396#else
397#define UR_OUT(X)
398#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000399
Reid Spencere77e35e2006-12-01 20:26:20 +0000400#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000401#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000402#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000403
Reid Spencer950bf602007-01-26 08:19:09 +0000404int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000405int yyparse();
406
Reid Spencer950bf602007-01-26 08:19:09 +0000407int yyerror(const char*);
408static void warning(const std::string& WarningMsg);
409
410namespace llvm {
411
Reid Spencer950bf602007-01-26 08:19:09 +0000412std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000413static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000414
Reid Spencer71d2ec92006-12-31 06:02:26 +0000415// This bool controls whether attributes are ever added to function declarations
416// definitions and calls.
417static bool AddAttributes = false;
418
Reid Spencer950bf602007-01-26 08:19:09 +0000419static Module *ParserResult;
420static bool ObsoleteVarArgs;
421static bool NewVarArgs;
422static BasicBlock *CurBB;
423static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000424
Reid Spencer950bf602007-01-26 08:19:09 +0000425// This contains info used when building the body of a function. It is
426// destroyed when the function is completed.
427//
428typedef std::vector<Value *> ValueList; // Numbered defs
429
Reid Spencer5eb77c72007-03-15 03:26:42 +0000430typedef std::pair<std::string,const Type*> RenameMapKey;
Reid Spencer950bf602007-01-26 08:19:09 +0000431typedef std::map<RenameMapKey,std::string> RenameMapType;
432
433static void
434ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
435 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
436
437static struct PerModuleInfo {
438 Module *CurrentModule;
439 std::map<const Type *, ValueList> Values; // Module level numbered definitions
440 std::map<const Type *,ValueList> LateResolveValues;
441 std::vector<PATypeHolder> Types;
442 std::map<ValID, PATypeHolder> LateResolveTypes;
443 static Module::Endianness Endian;
444 static Module::PointerSize PointerSize;
445 RenameMapType RenameMap;
446
447 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
448 /// how they were referenced and on which line of the input they came from so
449 /// that we can resolve them later and print error messages as appropriate.
450 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
451
452 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
453 // references to global values. Global values may be referenced before they
454 // are defined, and if so, the temporary object that they represent is held
455 // here. This is used for forward references of GlobalValues.
456 //
457 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
458 GlobalRefsType;
459 GlobalRefsType GlobalRefs;
460
461 void ModuleDone() {
462 // If we could not resolve some functions at function compilation time
463 // (calls to functions before they are defined), resolve them now... Types
464 // are resolved when the constant pool has been completely parsed.
465 //
466 ResolveDefinitions(LateResolveValues);
467
468 // Check to make sure that all global value forward references have been
469 // resolved!
470 //
471 if (!GlobalRefs.empty()) {
472 std::string UndefinedReferences = "Unresolved global references exist:\n";
473
474 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
475 I != E; ++I) {
476 UndefinedReferences += " " + I->first.first->getDescription() + " " +
477 I->first.second.getName() + "\n";
478 }
479 error(UndefinedReferences);
480 return;
481 }
482
483 if (CurrentModule->getDataLayout().empty()) {
484 std::string dataLayout;
485 if (Endian != Module::AnyEndianness)
486 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
487 if (PointerSize != Module::AnyPointerSize) {
488 if (!dataLayout.empty())
489 dataLayout += "-";
490 dataLayout.append(PointerSize == Module::Pointer64 ?
491 "p:64:64" : "p:32:32");
492 }
493 CurrentModule->setDataLayout(dataLayout);
494 }
495
496 Values.clear(); // Clear out function local definitions
497 Types.clear();
498 CurrentModule = 0;
499 }
500
501 // GetForwardRefForGlobal - Check to see if there is a forward reference
502 // for this global. If so, remove it from the GlobalRefs map and return it.
503 // If not, just return null.
504 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
505 // Check to see if there is a forward reference to this global variable...
506 // if there is, eliminate it and patch the reference to use the new def'n.
507 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
508 GlobalValue *Ret = 0;
509 if (I != GlobalRefs.end()) {
510 Ret = I->second;
511 GlobalRefs.erase(I);
512 }
513 return Ret;
514 }
515 void setEndianness(Module::Endianness E) { Endian = E; }
516 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
517} CurModule;
518
519Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
520Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
521
522static struct PerFunctionInfo {
523 Function *CurrentFunction; // Pointer to current function being created
524
525 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
526 std::map<const Type*, ValueList> LateResolveValues;
527 bool isDeclare; // Is this function a forward declararation?
528 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
529
530 /// BBForwardRefs - When we see forward references to basic blocks, keep
531 /// track of them here.
532 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
533 std::vector<BasicBlock*> NumberedBlocks;
534 RenameMapType RenameMap;
Reid Spencer950bf602007-01-26 08:19:09 +0000535 unsigned NextBBNum;
536
537 inline PerFunctionInfo() {
538 CurrentFunction = 0;
539 isDeclare = false;
540 Linkage = GlobalValue::ExternalLinkage;
541 }
542
543 inline void FunctionStart(Function *M) {
544 CurrentFunction = M;
545 NextBBNum = 0;
546 }
547
548 void FunctionDone() {
549 NumberedBlocks.clear();
550
551 // Any forward referenced blocks left?
552 if (!BBForwardRefs.empty()) {
553 error("Undefined reference to label " +
554 BBForwardRefs.begin()->first->getName());
555 return;
556 }
557
558 // Resolve all forward references now.
559 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
560
561 Values.clear(); // Clear out function local definitions
562 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000563 CurrentFunction = 0;
564 isDeclare = false;
565 Linkage = GlobalValue::ExternalLinkage;
566 }
567} CurFun; // Info for the current function...
568
569static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
570
571
572//===----------------------------------------------------------------------===//
573// Code to handle definitions of all the types
574//===----------------------------------------------------------------------===//
575
576static int InsertValue(Value *V,
577 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
578 if (V->hasName()) return -1; // Is this a numbered definition?
579
580 // Yes, insert the value into the value table...
581 ValueList &List = ValueTab[V->getType()];
582 List.push_back(V);
583 return List.size()-1;
584}
585
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000586static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000587 switch (D.Type) {
588 case ValID::NumberVal: // Is it a numbered definition?
589 // Module constants occupy the lowest numbered slots...
590 if ((unsigned)D.Num < CurModule.Types.size()) {
591 return CurModule.Types[(unsigned)D.Num];
592 }
593 break;
594 case ValID::NameVal: // Is it a named definition?
595 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
596 D.destroy(); // Free old strdup'd memory...
597 return N;
598 }
599 break;
600 default:
601 error("Internal parser error: Invalid symbol type reference");
602 return 0;
603 }
604
605 // If we reached here, we referenced either a symbol that we don't know about
606 // or an id number that hasn't been read yet. We may be referencing something
607 // forward, so just create an entry to be resolved later and get to it...
608 //
609 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
610
611
612 if (inFunctionScope()) {
613 if (D.Type == ValID::NameVal) {
614 error("Reference to an undefined type: '" + D.getName() + "'");
615 return 0;
616 } else {
617 error("Reference to an undefined type: #" + itostr(D.Num));
618 return 0;
619 }
620 }
621
622 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
623 if (I != CurModule.LateResolveTypes.end())
624 return I->second;
625
626 Type *Typ = OpaqueType::get();
627 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
628 return Typ;
629 }
630
Reid Spencered96d1e2007-02-08 09:08:52 +0000631/// This function determines if two function types differ only in their use of
632/// the sret parameter attribute in the first argument. If they are identical
633/// in all other respects, it returns true. Otherwise, it returns false.
634bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
635 const FunctionType *F2) {
636 if (F1->getReturnType() != F2->getReturnType() ||
637 F1->getNumParams() != F2->getNumParams() ||
638 F1->getParamAttrs(0) != F2->getParamAttrs(0))
639 return false;
640 unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute);
641 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
642 if (F1->getParamType(i) != F2->getParamType(i) ||
643 unsigned(F1->getParamAttrs(i+1)) & SRetMask !=
644 unsigned(F2->getParamAttrs(i+1)) & SRetMask)
645 return false;
646 }
647 return true;
648}
649
650// The upgrade of csretcc to sret param attribute may have caused a function
651// to not be found because the param attribute changed the type of the called
652// function. This helper function, used in getExistingValue, detects that
Reid Spencer5eb77c72007-03-15 03:26:42 +0000653// situation and returns V if it occurs and 0 otherwise.
Reid Spencered96d1e2007-02-08 09:08:52 +0000654static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
655 // Handle degenerate cases
656 if (!V)
657 return 0;
658 if (V->getType() == Ty)
659 return V;
660
661 Value* Result = 0;
662 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
663 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
664 if (PF1 && PF2) {
Reid Spencer5eb77c72007-03-15 03:26:42 +0000665 const FunctionType *FT1 =
666 dyn_cast<FunctionType>(PF1->getElementType());
667 const FunctionType *FT2 =
668 dyn_cast<FunctionType>(PF2->getElementType());
Reid Spencered96d1e2007-02-08 09:08:52 +0000669 if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2))
670 if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute))
671 Result = V;
672 else if (Constant *C = dyn_cast<Constant>(V))
673 Result = ConstantExpr::getBitCast(C, PF1);
674 else
675 Result = new BitCastInst(V, PF1, "upgrd.cast", CurBB);
676 }
677 return Result;
678}
679
Reid Spencer950bf602007-01-26 08:19:09 +0000680// getExistingValue - Look up the value specified by the provided type and
681// the provided ValID. If the value exists and has already been defined, return
682// it. Otherwise return null.
683//
684static Value *getExistingValue(const Type *Ty, const ValID &D) {
685 if (isa<FunctionType>(Ty)) {
686 error("Functions are not values and must be referenced as pointers");
687 }
688
689 switch (D.Type) {
690 case ValID::NumberVal: { // Is it a numbered definition?
691 unsigned Num = (unsigned)D.Num;
692
693 // Module constants occupy the lowest numbered slots...
694 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
695 if (VI != CurModule.Values.end()) {
696 if (Num < VI->second.size())
697 return VI->second[Num];
698 Num -= VI->second.size();
699 }
700
701 // Make sure that our type is within bounds
702 VI = CurFun.Values.find(Ty);
703 if (VI == CurFun.Values.end()) return 0;
704
705 // Check that the number is within bounds...
706 if (VI->second.size() <= Num) return 0;
707
708 return VI->second[Num];
709 }
710
711 case ValID::NameVal: { // Is it a named definition?
712 // Get the name out of the ID
713 std::string Name(D.Name);
714 Value* V = 0;
Reid Spencer5eb77c72007-03-15 03:26:42 +0000715 RenameMapKey Key = std::make_pair(Name, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +0000716 if (inFunctionScope()) {
717 // See if the name was renamed
718 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
719 std::string LookupName;
720 if (I != CurFun.RenameMap.end())
721 LookupName = I->second;
722 else
723 LookupName = Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000724 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
725 V = SymTab.lookup(LookupName);
Reid Spencered96d1e2007-02-08 09:08:52 +0000726 V = handleSRetFuncTypeMerge(V, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +0000727 }
728 if (!V) {
729 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
730 std::string LookupName;
731 if (I != CurModule.RenameMap.end())
732 LookupName = I->second;
733 else
734 LookupName = Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000735 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
Reid Spencered96d1e2007-02-08 09:08:52 +0000736 V = handleSRetFuncTypeMerge(V, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +0000737 }
Reid Spenceref9b9a72007-02-05 20:47:22 +0000738 if (!V)
Reid Spencer950bf602007-01-26 08:19:09 +0000739 return 0;
740
741 D.destroy(); // Free old strdup'd memory...
742 return V;
743 }
744
745 // Check to make sure that "Ty" is an integral type, and that our
746 // value will fit into the specified type...
747 case ValID::ConstSIntVal: // Is it a constant pool reference??
748 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
749 error("Signed integral constant '" + itostr(D.ConstPool64) +
750 "' is invalid for type '" + Ty->getDescription() + "'");
751 }
752 return ConstantInt::get(Ty, D.ConstPool64);
753
754 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
755 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
756 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
757 error("Integral constant '" + utostr(D.UConstPool64) +
758 "' is invalid or out of range");
759 else // This is really a signed reference. Transmogrify.
760 return ConstantInt::get(Ty, D.ConstPool64);
761 } else
762 return ConstantInt::get(Ty, D.UConstPool64);
763
764 case ValID::ConstFPVal: // Is it a floating point const pool reference?
765 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
766 error("FP constant invalid for type");
767 return ConstantFP::get(Ty, D.ConstPoolFP);
768
769 case ValID::ConstNullVal: // Is it a null value?
770 if (!isa<PointerType>(Ty))
771 error("Cannot create a a non pointer null");
772 return ConstantPointerNull::get(cast<PointerType>(Ty));
773
774 case ValID::ConstUndefVal: // Is it an undef value?
775 return UndefValue::get(Ty);
776
777 case ValID::ConstZeroVal: // Is it a zero value?
778 return Constant::getNullValue(Ty);
779
780 case ValID::ConstantVal: // Fully resolved constant?
781 if (D.ConstantValue->getType() != Ty)
782 error("Constant expression type different from required type");
783 return D.ConstantValue;
784
785 case ValID::InlineAsmVal: { // Inline asm expression
786 const PointerType *PTy = dyn_cast<PointerType>(Ty);
787 const FunctionType *FTy =
788 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
789 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
790 error("Invalid type for asm constraint string");
791 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
792 D.IAD->HasSideEffects);
793 D.destroy(); // Free InlineAsmDescriptor.
794 return IA;
795 }
796 default:
797 assert(0 && "Unhandled case");
798 return 0;
799 } // End of switch
800
801 assert(0 && "Unhandled case");
802 return 0;
803}
804
805// getVal - This function is identical to getExistingValue, except that if a
806// value is not already defined, it "improvises" by creating a placeholder var
807// that looks and acts just like the requested variable. When the value is
808// defined later, all uses of the placeholder variable are replaced with the
809// real thing.
810//
811static Value *getVal(const Type *Ty, const ValID &ID) {
812 if (Ty == Type::LabelTy)
813 error("Cannot use a basic block here");
814
815 // See if the value has already been defined.
816 Value *V = getExistingValue(Ty, ID);
817 if (V) return V;
818
819 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
820 error("Invalid use of a composite type");
821
822 // If we reached here, we referenced either a symbol that we don't know about
823 // or an id number that hasn't been read yet. We may be referencing something
824 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000825 V = new Argument(Ty);
826
827 // Remember where this forward reference came from. FIXME, shouldn't we try
828 // to recycle these things??
829 CurModule.PlaceHolderInfo.insert(
Reid Spenceref9b9a72007-02-05 20:47:22 +0000830 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
Reid Spencer950bf602007-01-26 08:19:09 +0000831
832 if (inFunctionScope())
833 InsertValue(V, CurFun.LateResolveValues);
834 else
835 InsertValue(V, CurModule.LateResolveValues);
836 return V;
837}
838
Reid Spencered96d1e2007-02-08 09:08:52 +0000839/// @brief This just makes any name given to it unique, up to MAX_UINT times.
840static std::string makeNameUnique(const std::string& Name) {
841 static unsigned UniqueNameCounter = 1;
842 std::string Result(Name);
843 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
844 return Result;
845}
846
Reid Spencer950bf602007-01-26 08:19:09 +0000847/// getBBVal - This is used for two purposes:
848/// * If isDefinition is true, a new basic block with the specified ID is being
849/// defined.
850/// * If isDefinition is true, this is a reference to a basic block, which may
851/// or may not be a forward reference.
852///
853static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
854 assert(inFunctionScope() && "Can't get basic block at global scope");
855
856 std::string Name;
857 BasicBlock *BB = 0;
858 switch (ID.Type) {
859 default:
860 error("Illegal label reference " + ID.getName());
861 break;
862 case ValID::NumberVal: // Is it a numbered definition?
863 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
864 CurFun.NumberedBlocks.resize(ID.Num+1);
865 BB = CurFun.NumberedBlocks[ID.Num];
866 break;
867 case ValID::NameVal: // Is it a named definition?
868 Name = ID.Name;
869 if (Value *N = CurFun.CurrentFunction->
Reid Spenceref9b9a72007-02-05 20:47:22 +0000870 getValueSymbolTable().lookup(Name)) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000871 if (N->getType() != Type::LabelTy) {
872 // Register names didn't use to conflict with basic block names
873 // because of type planes. Now they all have to be unique. So, we just
874 // rename the register and treat this name as if no basic block
875 // had been found.
Reid Spencer5eb77c72007-03-15 03:26:42 +0000876 RenameMapKey Key = std::make_pair(N->getName(),N->getType());
Reid Spencered96d1e2007-02-08 09:08:52 +0000877 N->setName(makeNameUnique(N->getName()));
878 CurModule.RenameMap[Key] = N->getName();
879 BB = 0;
880 } else {
881 BB = cast<BasicBlock>(N);
882 }
Reid Spencer950bf602007-01-26 08:19:09 +0000883 }
884 break;
885 }
886
887 // See if the block has already been defined.
888 if (BB) {
889 // If this is the definition of the block, make sure the existing value was
890 // just a forward reference. If it was a forward reference, there will be
891 // an entry for it in the PlaceHolderInfo map.
892 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
893 // The existing value was a definition, not a forward reference.
894 error("Redefinition of label " + ID.getName());
895
896 ID.destroy(); // Free strdup'd memory.
897 return BB;
898 }
899
900 // Otherwise this block has not been seen before.
901 BB = new BasicBlock("", CurFun.CurrentFunction);
902 if (ID.Type == ValID::NameVal) {
903 BB->setName(ID.Name);
904 } else {
905 CurFun.NumberedBlocks[ID.Num] = BB;
906 }
907
908 // If this is not a definition, keep track of it so we can use it as a forward
909 // reference.
910 if (!isDefinition) {
911 // Remember where this forward reference came from.
912 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
913 } else {
914 // The forward declaration could have been inserted anywhere in the
915 // function: insert it into the correct place now.
916 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
917 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
918 }
919 ID.destroy();
920 return BB;
921}
922
923
924//===----------------------------------------------------------------------===//
925// Code to handle forward references in instructions
926//===----------------------------------------------------------------------===//
927//
928// This code handles the late binding needed with statements that reference
929// values not defined yet... for example, a forward branch, or the PHI node for
930// a loop body.
931//
932// This keeps a table (CurFun.LateResolveValues) of all such forward references
933// and back patchs after we are done.
934//
935
936// ResolveDefinitions - If we could not resolve some defs at parsing
937// time (forward branches, phi functions for loops, etc...) resolve the
938// defs now...
939//
940static void
941ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
942 std::map<const Type*,ValueList> *FutureLateResolvers) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000943
Reid Spencer950bf602007-01-26 08:19:09 +0000944 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
945 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
946 E = LateResolvers.end(); LRI != E; ++LRI) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000947 const Type* Ty = LRI->first;
Reid Spencer950bf602007-01-26 08:19:09 +0000948 ValueList &List = LRI->second;
949 while (!List.empty()) {
950 Value *V = List.back();
951 List.pop_back();
952
953 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
954 CurModule.PlaceHolderInfo.find(V);
955 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
956
957 ValID &DID = PHI->second.first;
958
Reid Spencered96d1e2007-02-08 09:08:52 +0000959 Value *TheRealValue = getExistingValue(Ty, DID);
Reid Spencer950bf602007-01-26 08:19:09 +0000960 if (TheRealValue) {
961 V->replaceAllUsesWith(TheRealValue);
962 delete V;
963 CurModule.PlaceHolderInfo.erase(PHI);
964 } else if (FutureLateResolvers) {
965 // Functions have their unresolved items forwarded to the module late
966 // resolver table
967 InsertValue(V, *FutureLateResolvers);
968 } else {
969 if (DID.Type == ValID::NameVal) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000970 error("Reference to an invalid definition: '" + DID.getName() +
971 "' of type '" + V->getType()->getDescription() + "'",
972 PHI->second.second);
Reid Spencer7de2e012007-01-29 19:08:46 +0000973 return;
Reid Spencer950bf602007-01-26 08:19:09 +0000974 } else {
975 error("Reference to an invalid definition: #" +
976 itostr(DID.Num) + " of type '" +
977 V->getType()->getDescription() + "'", PHI->second.second);
978 return;
979 }
980 }
981 }
982 }
983
984 LateResolvers.clear();
985}
986
987// ResolveTypeTo - A brand new type was just declared. This means that (if
988// name is not null) things referencing Name can be resolved. Otherwise, things
989// refering to the number can be resolved. Do this now.
990//
Reid Spencer5eb77c72007-03-15 03:26:42 +0000991static void ResolveTypeTo(char *Name, const Type *ToTy) {
Reid Spencer950bf602007-01-26 08:19:09 +0000992 ValID D;
Reid Spencer5eb77c72007-03-15 03:26:42 +0000993 if (Name) D = ValID::create(Name);
994 else D = ValID::create((int)CurModule.Types.size());
Reid Spencer950bf602007-01-26 08:19:09 +0000995
996 std::map<ValID, PATypeHolder>::iterator I =
997 CurModule.LateResolveTypes.find(D);
998 if (I != CurModule.LateResolveTypes.end()) {
999 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1000 CurModule.LateResolveTypes.erase(I);
1001 }
1002}
1003
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001004/// This is the implementation portion of TypeHasInteger. It traverses the
1005/// type given, avoiding recursive types, and returns true as soon as it finds
1006/// an integer type. If no integer type is found, it returns false.
1007static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
1008 // Handle some easy cases
1009 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
1010 return false;
1011 if (Ty->isInteger())
1012 return true;
1013 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
1014 return STy->getElementType()->isInteger();
1015
1016 // Avoid type structure recursion
1017 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
1018 I != E; ++I)
1019 if (Ty == *I)
1020 return false;
1021
1022 // Push us on the type stack
1023 Stack.push_back(Ty);
1024
1025 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1026 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1027 return true;
1028 FunctionType::param_iterator I = FTy->param_begin();
1029 FunctionType::param_iterator E = FTy->param_end();
1030 for (; I != E; ++I)
1031 if (TypeHasIntegerI(*I, Stack))
1032 return true;
1033 return false;
1034 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1035 StructType::element_iterator I = STy->element_begin();
1036 StructType::element_iterator E = STy->element_end();
1037 for (; I != E; ++I) {
1038 if (TypeHasIntegerI(*I, Stack))
1039 return true;
1040 }
1041 return false;
1042 }
1043 // There shouldn't be anything else, but its definitely not integer
1044 assert(0 && "What type is this?");
1045 return false;
1046}
1047
1048/// This is the interface to TypeHasIntegerI. It just provides the type stack,
1049/// to avoid recursion, and then calls TypeHasIntegerI.
1050static inline bool TypeHasInteger(const Type *Ty) {
1051 std::vector<const Type*> TyStack;
1052 return TypeHasIntegerI(Ty, TyStack);
1053}
1054
Reid Spencer950bf602007-01-26 08:19:09 +00001055// setValueName - Set the specified value to the name given. The name may be
1056// null potentially, in which case this is a noop. The string passed in is
1057// assumed to be a malloc'd string buffer, and is free'd by this function.
1058//
Reid Spencer5eb77c72007-03-15 03:26:42 +00001059static void setValueName(Value *V, char *NameStr) {
Reid Spencer950bf602007-01-26 08:19:09 +00001060 if (NameStr) {
1061 std::string Name(NameStr); // Copy string
1062 free(NameStr); // Free old string
1063
Reid Spencer5eb77c72007-03-15 03:26:42 +00001064 if (V->getType() == Type::VoidTy) {
Reid Spencer950bf602007-01-26 08:19:09 +00001065 error("Can't assign name '" + Name + "' to value with void type");
1066 return;
1067 }
1068
Reid Spencer950bf602007-01-26 08:19:09 +00001069 assert(inFunctionScope() && "Must be in function scope");
1070
1071 // Search the function's symbol table for an existing value of this name
Reid Spenceref9b9a72007-02-05 20:47:22 +00001072 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1073 Value* Existing = ST.lookup(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001074 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001075 // An existing value of the same name was found. This might have happened
1076 // because of the integer type planes collapsing in LLVM 2.0.
Reid Spencer5eb77c72007-03-15 03:26:42 +00001077 if (Existing->getType() == V->getType() &&
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001078 !TypeHasInteger(Existing->getType())) {
1079 // If the type does not contain any integers in them then this can't be
1080 // a type plane collapsing issue. It truly is a redefinition and we
1081 // should error out as the assembly is invalid.
1082 error("Redefinition of value named '" + Name + "' of type '" +
Reid Spencer5eb77c72007-03-15 03:26:42 +00001083 V->getType()->getDescription() + "'");
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001084 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001085 }
1086 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1087 // function, regardless of Type. Previously re-use of names was okay as
1088 // long as they were distinct types. With type planes collapsing because
1089 // of the signedness change and because of PR411, this can no longer be
1090 // supported. We must search the entire symbol table for a conflicting
1091 // name and make the name unique. No warning is needed as this can't
1092 // cause a problem.
1093 std::string NewName = makeNameUnique(Name);
1094 // We're changing the name but it will probably be used by other
1095 // instructions as operands later on. Consequently we have to retain
1096 // a mapping of the renaming that we're doing.
Reid Spencer5eb77c72007-03-15 03:26:42 +00001097 RenameMapKey Key = std::make_pair(Name,V->getType());
Reid Spencer950bf602007-01-26 08:19:09 +00001098 CurFun.RenameMap[Key] = NewName;
1099 Name = NewName;
1100 }
1101
1102 // Set the name.
Reid Spencer5eb77c72007-03-15 03:26:42 +00001103 V->setName(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001104 }
1105}
1106
1107/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1108/// this is a declaration, otherwise it is a definition.
1109static GlobalVariable *
1110ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1111 bool isConstantGlobal, const Type *Ty,
Reid Spencer5eb77c72007-03-15 03:26:42 +00001112 Constant *Initializer) {
Reid Spencer950bf602007-01-26 08:19:09 +00001113 if (isa<FunctionType>(Ty))
1114 error("Cannot declare global vars of function type");
1115
1116 const PointerType *PTy = PointerType::get(Ty);
1117
1118 std::string Name;
1119 if (NameStr) {
1120 Name = NameStr; // Copy string
1121 free(NameStr); // Free old string
1122 }
1123
1124 // See if this global value was forward referenced. If so, recycle the
1125 // object.
1126 ValID ID;
1127 if (!Name.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00001128 ID = ValID::create((char*)Name.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00001129 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00001130 ID = ValID::create((int)CurModule.Values[PTy].size());
Reid Spencer950bf602007-01-26 08:19:09 +00001131 }
1132
1133 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1134 // Move the global to the end of the list, from whereever it was
1135 // previously inserted.
1136 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1137 CurModule.CurrentModule->getGlobalList().remove(GV);
1138 CurModule.CurrentModule->getGlobalList().push_back(GV);
1139 GV->setInitializer(Initializer);
1140 GV->setLinkage(Linkage);
1141 GV->setConstant(isConstantGlobal);
1142 InsertValue(GV, CurModule.Values);
1143 return GV;
1144 }
1145
1146 // If this global has a name, check to see if there is already a definition
1147 // of this global in the module and emit warnings if there are conflicts.
1148 if (!Name.empty()) {
1149 // The global has a name. See if there's an existing one of the same name.
1150 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1151 // We found an existing global ov the same name. This isn't allowed
1152 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1153 // can at least compile. This can happen because of type planes
1154 // There is alread a global of the same name which means there is a
1155 // conflict. Let's see what we can do about it.
1156 std::string NewName(makeNameUnique(Name));
1157 if (Linkage == GlobalValue::InternalLinkage) {
1158 // The linkage type is internal so just warn about the rename without
1159 // invoking "scarey language" about linkage failures. GVars with
1160 // InternalLinkage can be renamed at will.
1161 warning("Global variable '" + Name + "' was renamed to '"+
1162 NewName + "'");
1163 } else {
1164 // The linkage of this gval is external so we can't reliably rename
1165 // it because it could potentially create a linking problem.
1166 // However, we can't leave the name conflict in the output either or
1167 // it won't assemble with LLVM 2.0. So, all we can do is rename
1168 // this one to something unique and emit a warning about the problem.
1169 warning("Renaming global variable '" + Name + "' to '" + NewName +
1170 "' may cause linkage errors");
1171 }
1172
1173 // Put the renaming in the global rename map
Reid Spencer5eb77c72007-03-15 03:26:42 +00001174 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00001175 CurModule.RenameMap[Key] = NewName;
1176
1177 // Rename it
1178 Name = NewName;
1179 }
1180 }
1181
1182 // Otherwise there is no existing GV to use, create one now.
1183 GlobalVariable *GV =
1184 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1185 CurModule.CurrentModule);
1186 InsertValue(GV, CurModule.Values);
1187 return GV;
1188}
1189
1190// setTypeName - Set the specified type to the name given. The name may be
1191// null potentially, in which case this is a noop. The string passed in is
1192// assumed to be a malloc'd string buffer, and is freed by this function.
1193//
1194// This function returns true if the type has already been defined, but is
1195// allowed to be redefined in the specified context. If the name is a new name
1196// for the type plane, it is inserted and false is returned.
1197static bool setTypeName(const Type *T, char *NameStr) {
1198 assert(!inFunctionScope() && "Can't give types function-local names");
1199 if (NameStr == 0) return false;
1200
1201 std::string Name(NameStr); // Copy string
1202 free(NameStr); // Free old string
1203
1204 // We don't allow assigning names to void type
1205 if (T == Type::VoidTy) {
1206 error("Can't assign name '" + Name + "' to the void type");
1207 return false;
1208 }
1209
1210 // Set the type name, checking for conflicts as we do so.
1211 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1212
1213 if (AlreadyExists) { // Inserting a name that is already defined???
1214 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1215 assert(Existing && "Conflict but no matching type?");
1216
1217 // There is only one case where this is allowed: when we are refining an
1218 // opaque type. In this case, Existing will be an opaque type.
1219 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1220 // We ARE replacing an opaque type!
1221 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1222 return true;
1223 }
1224
1225 // Otherwise, this is an attempt to redefine a type. That's okay if
1226 // the redefinition is identical to the original. This will be so if
1227 // Existing and T point to the same Type object. In this one case we
1228 // allow the equivalent redefinition.
1229 if (Existing == T) return true; // Yes, it's equal.
1230
1231 // Any other kind of (non-equivalent) redefinition is an error.
1232 error("Redefinition of type named '" + Name + "' in the '" +
1233 T->getDescription() + "' type plane");
1234 }
1235
1236 return false;
1237}
1238
1239//===----------------------------------------------------------------------===//
1240// Code for handling upreferences in type names...
1241//
1242
1243// TypeContains - Returns true if Ty directly contains E in it.
1244//
1245static bool TypeContains(const Type *Ty, const Type *E) {
1246 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1247 E) != Ty->subtype_end();
1248}
1249
1250namespace {
1251 struct UpRefRecord {
1252 // NestingLevel - The number of nesting levels that need to be popped before
1253 // this type is resolved.
1254 unsigned NestingLevel;
1255
1256 // LastContainedTy - This is the type at the current binding level for the
1257 // type. Every time we reduce the nesting level, this gets updated.
1258 const Type *LastContainedTy;
1259
1260 // UpRefTy - This is the actual opaque type that the upreference is
1261 // represented with.
1262 OpaqueType *UpRefTy;
1263
1264 UpRefRecord(unsigned NL, OpaqueType *URTy)
1265 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1266 };
1267}
1268
1269// UpRefs - A list of the outstanding upreferences that need to be resolved.
1270static std::vector<UpRefRecord> UpRefs;
1271
1272/// HandleUpRefs - Every time we finish a new layer of types, this function is
1273/// called. It loops through the UpRefs vector, which is a list of the
1274/// currently active types. For each type, if the up reference is contained in
1275/// the newly completed type, we decrement the level count. When the level
1276/// count reaches zero, the upreferenced type is the type that is passed in:
1277/// thus we can complete the cycle.
1278///
1279static PATypeHolder HandleUpRefs(const Type *ty) {
1280 // If Ty isn't abstract, or if there are no up-references in it, then there is
1281 // nothing to resolve here.
1282 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1283
1284 PATypeHolder Ty(ty);
1285 UR_OUT("Type '" << Ty->getDescription() <<
1286 "' newly formed. Resolving upreferences.\n" <<
1287 UpRefs.size() << " upreferences active!\n");
1288
1289 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1290 // to zero), we resolve them all together before we resolve them to Ty. At
1291 // the end of the loop, if there is anything to resolve to Ty, it will be in
1292 // this variable.
1293 OpaqueType *TypeToResolve = 0;
1294
1295 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1296 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1297 << UpRefs[i].second->getDescription() << ") = "
1298 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1299 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1300 // Decrement level of upreference
1301 unsigned Level = --UpRefs[i].NestingLevel;
1302 UpRefs[i].LastContainedTy = Ty;
1303 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1304 if (Level == 0) { // Upreference should be resolved!
1305 if (!TypeToResolve) {
1306 TypeToResolve = UpRefs[i].UpRefTy;
1307 } else {
1308 UR_OUT(" * Resolving upreference for "
1309 << UpRefs[i].second->getDescription() << "\n";
1310 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1311 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1312 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1313 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1314 }
1315 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1316 --i; // Do not skip the next element...
1317 }
1318 }
1319 }
1320
1321 if (TypeToResolve) {
1322 UR_OUT(" * Resolving upreference for "
1323 << UpRefs[i].second->getDescription() << "\n";
1324 std::string OldName = TypeToResolve->getDescription());
1325 TypeToResolve->refineAbstractTypeTo(Ty);
1326 }
1327
1328 return Ty;
1329}
1330
1331static inline Instruction::TermOps
1332getTermOp(TermOps op) {
1333 switch (op) {
1334 default : assert(0 && "Invalid OldTermOp");
1335 case RetOp : return Instruction::Ret;
1336 case BrOp : return Instruction::Br;
1337 case SwitchOp : return Instruction::Switch;
1338 case InvokeOp : return Instruction::Invoke;
1339 case UnwindOp : return Instruction::Unwind;
1340 case UnreachableOp: return Instruction::Unreachable;
1341 }
1342}
1343
1344static inline Instruction::BinaryOps
1345getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1346 switch (op) {
1347 default : assert(0 && "Invalid OldBinaryOps");
1348 case SetEQ :
1349 case SetNE :
1350 case SetLE :
1351 case SetGE :
1352 case SetLT :
1353 case SetGT : assert(0 && "Should use getCompareOp");
1354 case AddOp : return Instruction::Add;
1355 case SubOp : return Instruction::Sub;
1356 case MulOp : return Instruction::Mul;
1357 case DivOp : {
1358 // This is an obsolete instruction so we must upgrade it based on the
1359 // types of its operands.
1360 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001361 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001362 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001363 isFP = PTy->getElementType()->isFloatingPoint();
1364 if (isFP)
1365 return Instruction::FDiv;
1366 else if (Sign == Signed)
1367 return Instruction::SDiv;
1368 return Instruction::UDiv;
1369 }
1370 case UDivOp : return Instruction::UDiv;
1371 case SDivOp : return Instruction::SDiv;
1372 case FDivOp : return Instruction::FDiv;
1373 case RemOp : {
1374 // This is an obsolete instruction so we must upgrade it based on the
1375 // types of its operands.
1376 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001377 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001378 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001379 isFP = PTy->getElementType()->isFloatingPoint();
1380 // Select correct opcode
1381 if (isFP)
1382 return Instruction::FRem;
1383 else if (Sign == Signed)
1384 return Instruction::SRem;
1385 return Instruction::URem;
1386 }
1387 case URemOp : return Instruction::URem;
1388 case SRemOp : return Instruction::SRem;
1389 case FRemOp : return Instruction::FRem;
Reid Spencer832254e2007-02-02 02:16:23 +00001390 case LShrOp : return Instruction::LShr;
1391 case AShrOp : return Instruction::AShr;
1392 case ShlOp : return Instruction::Shl;
1393 case ShrOp :
1394 if (Sign == Signed)
1395 return Instruction::AShr;
1396 return Instruction::LShr;
Reid Spencer950bf602007-01-26 08:19:09 +00001397 case AndOp : return Instruction::And;
1398 case OrOp : return Instruction::Or;
1399 case XorOp : return Instruction::Xor;
1400 }
1401}
1402
1403static inline Instruction::OtherOps
1404getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1405 Signedness Sign) {
1406 bool isSigned = Sign == Signed;
1407 bool isFP = Ty->isFloatingPoint();
1408 switch (op) {
1409 default : assert(0 && "Invalid OldSetCC");
1410 case SetEQ :
1411 if (isFP) {
1412 predicate = FCmpInst::FCMP_OEQ;
1413 return Instruction::FCmp;
1414 } else {
1415 predicate = ICmpInst::ICMP_EQ;
1416 return Instruction::ICmp;
1417 }
1418 case SetNE :
1419 if (isFP) {
1420 predicate = FCmpInst::FCMP_UNE;
1421 return Instruction::FCmp;
1422 } else {
1423 predicate = ICmpInst::ICMP_NE;
1424 return Instruction::ICmp;
1425 }
1426 case SetLE :
1427 if (isFP) {
1428 predicate = FCmpInst::FCMP_OLE;
1429 return Instruction::FCmp;
1430 } else {
1431 if (isSigned)
1432 predicate = ICmpInst::ICMP_SLE;
1433 else
1434 predicate = ICmpInst::ICMP_ULE;
1435 return Instruction::ICmp;
1436 }
1437 case SetGE :
1438 if (isFP) {
1439 predicate = FCmpInst::FCMP_OGE;
1440 return Instruction::FCmp;
1441 } else {
1442 if (isSigned)
1443 predicate = ICmpInst::ICMP_SGE;
1444 else
1445 predicate = ICmpInst::ICMP_UGE;
1446 return Instruction::ICmp;
1447 }
1448 case SetLT :
1449 if (isFP) {
1450 predicate = FCmpInst::FCMP_OLT;
1451 return Instruction::FCmp;
1452 } else {
1453 if (isSigned)
1454 predicate = ICmpInst::ICMP_SLT;
1455 else
1456 predicate = ICmpInst::ICMP_ULT;
1457 return Instruction::ICmp;
1458 }
1459 case SetGT :
1460 if (isFP) {
1461 predicate = FCmpInst::FCMP_OGT;
1462 return Instruction::FCmp;
1463 } else {
1464 if (isSigned)
1465 predicate = ICmpInst::ICMP_SGT;
1466 else
1467 predicate = ICmpInst::ICMP_UGT;
1468 return Instruction::ICmp;
1469 }
1470 }
1471}
1472
1473static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1474 switch (op) {
1475 default : assert(0 && "Invalid OldMemoryOps");
1476 case MallocOp : return Instruction::Malloc;
1477 case FreeOp : return Instruction::Free;
1478 case AllocaOp : return Instruction::Alloca;
1479 case LoadOp : return Instruction::Load;
1480 case StoreOp : return Instruction::Store;
1481 case GetElementPtrOp : return Instruction::GetElementPtr;
1482 }
1483}
1484
1485static inline Instruction::OtherOps
1486getOtherOp(OtherOps op, Signedness Sign) {
1487 switch (op) {
1488 default : assert(0 && "Invalid OldOtherOps");
1489 case PHIOp : return Instruction::PHI;
1490 case CallOp : return Instruction::Call;
Reid Spencer950bf602007-01-26 08:19:09 +00001491 case SelectOp : return Instruction::Select;
1492 case UserOp1 : return Instruction::UserOp1;
1493 case UserOp2 : return Instruction::UserOp2;
1494 case VAArg : return Instruction::VAArg;
1495 case ExtractElementOp : return Instruction::ExtractElement;
1496 case InsertElementOp : return Instruction::InsertElement;
1497 case ShuffleVectorOp : return Instruction::ShuffleVector;
1498 case ICmpOp : return Instruction::ICmp;
1499 case FCmpOp : return Instruction::FCmp;
Reid Spencer950bf602007-01-26 08:19:09 +00001500 };
1501}
1502
1503static inline Value*
1504getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1505 Signedness DstSign, bool ForceInstruction = false) {
1506 Instruction::CastOps Opcode;
1507 const Type* SrcTy = Src->getType();
1508 if (op == CastOp) {
1509 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1510 // fp -> ptr cast is no longer supported but we must upgrade this
1511 // by doing a double cast: fp -> int -> ptr
1512 SrcTy = Type::Int64Ty;
1513 Opcode = Instruction::IntToPtr;
1514 if (isa<Constant>(Src)) {
1515 Src = ConstantExpr::getCast(Instruction::FPToUI,
1516 cast<Constant>(Src), SrcTy);
1517 } else {
1518 std::string NewName(makeNameUnique(Src->getName()));
1519 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1520 }
1521 } else if (isa<IntegerType>(DstTy) &&
1522 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1523 // cast type %x to bool was previously defined as setne type %x, null
1524 // The cast semantic is now to truncate, not compare so we must retain
1525 // the original intent by replacing the cast with a setne
1526 Constant* Null = Constant::getNullValue(SrcTy);
1527 Instruction::OtherOps Opcode = Instruction::ICmp;
1528 unsigned short predicate = ICmpInst::ICMP_NE;
1529 if (SrcTy->isFloatingPoint()) {
1530 Opcode = Instruction::FCmp;
1531 predicate = FCmpInst::FCMP_ONE;
1532 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1533 error("Invalid cast to bool");
1534 }
1535 if (isa<Constant>(Src) && !ForceInstruction)
1536 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1537 else
1538 return CmpInst::create(Opcode, predicate, Src, Null);
1539 }
1540 // Determine the opcode to use by calling CastInst::getCastOpcode
1541 Opcode =
1542 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1543
1544 } else switch (op) {
1545 default: assert(0 && "Invalid cast token");
1546 case TruncOp: Opcode = Instruction::Trunc; break;
1547 case ZExtOp: Opcode = Instruction::ZExt; break;
1548 case SExtOp: Opcode = Instruction::SExt; break;
1549 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1550 case FPExtOp: Opcode = Instruction::FPExt; break;
1551 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1552 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1553 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1554 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1555 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1556 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1557 case BitCastOp: Opcode = Instruction::BitCast; break;
1558 }
1559
1560 if (isa<Constant>(Src) && !ForceInstruction)
1561 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1562 return CastInst::create(Opcode, Src, DstTy);
1563}
1564
1565static Instruction *
1566upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1567 std::vector<Value*>& Args) {
1568
1569 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1570 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1571 if (Args.size() != 2)
1572 error("Invalid prototype for " + Name + " prototype");
1573 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1574 } else {
Reid Spencer950bf602007-01-26 08:19:09 +00001575 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1576 std::vector<const Type*> Params;
1577 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1578 if (Args.size() != 1)
1579 error("Invalid prototype for " + Name + " prototype");
1580 Params.push_back(PtrTy);
1581 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1582 const PointerType *PFTy = PointerType::get(FTy);
1583 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001584 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
Chris Lattnercf3d0612007-02-13 06:04:17 +00001585 return new CallInst(Func, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00001586 } else if (Name == "llvm.va_copy") {
1587 if (Args.size() != 2)
1588 error("Invalid prototype for " + Name + " prototype");
1589 Params.push_back(PtrTy);
1590 Params.push_back(PtrTy);
1591 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1592 const PointerType *PFTy = PointerType::get(FTy);
1593 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001594 std::string InstName0(makeNameUnique("va0"));
1595 std::string InstName1(makeNameUnique("va1"));
Reid Spencer950bf602007-01-26 08:19:09 +00001596 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1597 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
Chris Lattnercf3d0612007-02-13 06:04:17 +00001598 return new CallInst(Func, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00001599 }
1600 }
1601 return 0;
1602}
1603
1604const Type* upgradeGEPIndices(const Type* PTy,
1605 std::vector<ValueInfo> *Indices,
1606 std::vector<Value*> &VIndices,
1607 std::vector<Constant*> *CIndices = 0) {
1608 // Traverse the indices with a gep_type_iterator so we can build the list
1609 // of constant and value indices for use later. Also perform upgrades
1610 VIndices.clear();
1611 if (CIndices) CIndices->clear();
1612 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1613 VIndices.push_back((*Indices)[i].V);
1614 generic_gep_type_iterator<std::vector<Value*>::iterator>
1615 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1616 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1617 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1618 Value *Index = VIndices[i];
1619 if (CIndices && !isa<Constant>(Index))
1620 error("Indices to constant getelementptr must be constants");
1621 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1622 // struct indices to i32 struct indices with ZExt for compatibility.
1623 else if (isa<StructType>(*GTI)) { // Only change struct indices
1624 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1625 if (CUI->getType()->getBitWidth() == 8)
1626 Index =
1627 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1628 } else {
1629 // Make sure that unsigned SequentialType indices are zext'd to
1630 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1631 // all indices for SequentialType elements. We must retain the same
1632 // semantic (zext) for unsigned types.
1633 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001634 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001635 if (CIndices)
1636 Index = ConstantExpr::getCast(Instruction::ZExt,
1637 cast<Constant>(Index), Type::Int64Ty);
1638 else
1639 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001640 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001641 VIndices[i] = Index;
1642 }
Reid Spencer950bf602007-01-26 08:19:09 +00001643 }
1644 // Add to the CIndices list, if requested.
1645 if (CIndices)
1646 CIndices->push_back(cast<Constant>(Index));
1647 }
1648
1649 const Type *IdxTy =
Chris Lattner1bc3fa62007-02-12 22:58:38 +00001650 GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true);
Reid Spencer950bf602007-01-26 08:19:09 +00001651 if (!IdxTy)
1652 error("Index list invalid for constant getelementptr");
1653 return IdxTy;
1654}
1655
Reid Spencerb7046c72007-01-29 05:41:34 +00001656unsigned upgradeCallingConv(unsigned CC) {
1657 switch (CC) {
1658 case OldCallingConv::C : return CallingConv::C;
1659 case OldCallingConv::CSRet : return CallingConv::C;
1660 case OldCallingConv::Fast : return CallingConv::Fast;
1661 case OldCallingConv::Cold : return CallingConv::Cold;
1662 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1663 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1664 default:
1665 return CC;
1666 }
1667}
1668
Reid Spencer950bf602007-01-26 08:19:09 +00001669Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1670 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001671{
1672 Upgradelineno = 1;
1673 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001674 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001675 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001676 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001677 ObsoleteVarArgs = false;
1678 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001679
Reid Spencer950bf602007-01-26 08:19:09 +00001680 CurModule.CurrentModule = new Module(CurFilename);
1681
1682 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001683 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001684 if (ParserResult)
1685 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001686 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001687 return 0;
1688 }
1689
Reid Spencer950bf602007-01-26 08:19:09 +00001690 // Check to make sure that parsing produced a result
1691 if (!ParserResult) {
1692 std::cerr << "llvm-upgrade: no parse result.\n";
1693 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001694 }
1695
Reid Spencer950bf602007-01-26 08:19:09 +00001696 // Reset ParserResult variable while saving its value for the result.
1697 Module *Result = ParserResult;
1698 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001699
Reid Spencer950bf602007-01-26 08:19:09 +00001700 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001701 {
Reid Spencer950bf602007-01-26 08:19:09 +00001702 Function* F;
Reid Spencer688b0492007-02-05 21:19:13 +00001703 if ((F = Result->getFunction("llvm.va_start"))
Reid Spencer950bf602007-01-26 08:19:09 +00001704 && F->getFunctionType()->getNumParams() == 0)
1705 ObsoleteVarArgs = true;
Reid Spencer688b0492007-02-05 21:19:13 +00001706 if((F = Result->getFunction("llvm.va_copy"))
Reid Spencer950bf602007-01-26 08:19:09 +00001707 && F->getFunctionType()->getNumParams() == 1)
1708 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001709 }
Reid Spencer319a7302007-01-05 17:20:02 +00001710
Reid Spencer950bf602007-01-26 08:19:09 +00001711 if (ObsoleteVarArgs && NewVarArgs) {
1712 error("This file is corrupt: it uses both new and old style varargs");
1713 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001714 }
Reid Spencer319a7302007-01-05 17:20:02 +00001715
Reid Spencer950bf602007-01-26 08:19:09 +00001716 if(ObsoleteVarArgs) {
Reid Spencer688b0492007-02-05 21:19:13 +00001717 if(Function* F = Result->getFunction("llvm.va_start")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001718 if (F->arg_size() != 0) {
1719 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001720 return 0;
1721 }
Reid Spencer950bf602007-01-26 08:19:09 +00001722
1723 //foo = va_start()
1724 // ->
1725 //bar = alloca typeof(foo)
1726 //va_start(bar)
1727 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001728
Reid Spencer950bf602007-01-26 08:19:09 +00001729 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1730 const Type* ArgTy = F->getFunctionType()->getReturnType();
1731 const Type* ArgTyPtr = PointerType::get(ArgTy);
1732 Function* NF = cast<Function>(Result->getOrInsertFunction(
1733 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1734
1735 while (!F->use_empty()) {
1736 CallInst* CI = cast<CallInst>(F->use_back());
1737 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1738 new CallInst(NF, bar, "", CI);
1739 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1740 CI->replaceAllUsesWith(foo);
1741 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001742 }
Reid Spencer950bf602007-01-26 08:19:09 +00001743 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001744 }
Reid Spencer950bf602007-01-26 08:19:09 +00001745
Reid Spencer688b0492007-02-05 21:19:13 +00001746 if(Function* F = Result->getFunction("llvm.va_end")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001747 if(F->arg_size() != 1) {
1748 error("Obsolete va_end takes 1 argument");
1749 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001750 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001751
Reid Spencer950bf602007-01-26 08:19:09 +00001752 //vaend foo
1753 // ->
1754 //bar = alloca 1 of typeof(foo)
1755 //vaend bar
1756 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1757 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1758 const Type* ArgTyPtr = PointerType::get(ArgTy);
1759 Function* NF = cast<Function>(Result->getOrInsertFunction(
1760 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001761
Reid Spencer950bf602007-01-26 08:19:09 +00001762 while (!F->use_empty()) {
1763 CallInst* CI = cast<CallInst>(F->use_back());
1764 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1765 new StoreInst(CI->getOperand(1), bar, CI);
1766 new CallInst(NF, bar, "", CI);
1767 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001768 }
Reid Spencer950bf602007-01-26 08:19:09 +00001769 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001770 }
Reid Spencer950bf602007-01-26 08:19:09 +00001771
Reid Spencer688b0492007-02-05 21:19:13 +00001772 if(Function* F = Result->getFunction("llvm.va_copy")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001773 if(F->arg_size() != 1) {
1774 error("Obsolete va_copy takes 1 argument");
1775 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001776 }
Reid Spencer950bf602007-01-26 08:19:09 +00001777 //foo = vacopy(bar)
1778 // ->
1779 //a = alloca 1 of typeof(foo)
1780 //b = alloca 1 of typeof(foo)
1781 //store bar -> b
1782 //vacopy(a, b)
1783 //foo = load a
1784
1785 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1786 const Type* ArgTy = F->getFunctionType()->getReturnType();
1787 const Type* ArgTyPtr = PointerType::get(ArgTy);
1788 Function* NF = cast<Function>(Result->getOrInsertFunction(
1789 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001790
Reid Spencer950bf602007-01-26 08:19:09 +00001791 while (!F->use_empty()) {
1792 CallInst* CI = cast<CallInst>(F->use_back());
1793 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1794 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1795 new StoreInst(CI->getOperand(1), b, CI);
1796 new CallInst(NF, a, b, "", CI);
1797 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1798 CI->replaceAllUsesWith(foo);
1799 CI->getParent()->getInstList().erase(CI);
1800 }
1801 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001802 }
1803 }
1804
Reid Spencer52402b02007-01-02 05:45:11 +00001805 return Result;
1806}
1807
Reid Spencer950bf602007-01-26 08:19:09 +00001808} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001809
Reid Spencer950bf602007-01-26 08:19:09 +00001810using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001811
1812
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001813
1814/* Enabling traces. */
1815#ifndef YYDEBUG
1816# define YYDEBUG 0
1817#endif
1818
1819/* Enabling verbose error messages. */
1820#ifdef YYERROR_VERBOSE
1821# undef YYERROR_VERBOSE
1822# define YYERROR_VERBOSE 1
1823#else
1824# define YYERROR_VERBOSE 0
1825#endif
1826
1827/* Enabling the token table. */
1828#ifndef YYTOKEN_TABLE
1829# define YYTOKEN_TABLE 0
1830#endif
1831
1832#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer5eb77c72007-03-15 03:26:42 +00001833#line 1454 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001834typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00001835 llvm::Module *ModuleVal;
1836 llvm::Function *FunctionVal;
1837 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1838 llvm::BasicBlock *BasicBlockVal;
1839 llvm::TerminatorInst *TermInstVal;
1840 llvm::InstrInfo InstVal;
1841 llvm::ConstInfo ConstVal;
1842 llvm::ValueInfo ValueVal;
1843 llvm::PATypeInfo TypeVal;
1844 llvm::TypeInfo PrimType;
1845 llvm::PHIListInfo PHIList;
1846 std::list<llvm::PATypeInfo> *TypeList;
1847 std::vector<llvm::ValueInfo> *ValueList;
1848 std::vector<llvm::ConstInfo> *ConstVector;
1849
1850
1851 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1852 // Represent the RHS of PHI node
1853 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1854
1855 llvm::GlobalValue::LinkageTypes Linkage;
1856 int64_t SInt64Val;
1857 uint64_t UInt64Val;
1858 int SIntVal;
1859 unsigned UIntVal;
1860 double FPVal;
1861 bool BoolVal;
1862
1863 char *StrVal; // This memory is strdup'd!
1864 llvm::ValID ValIDVal; // strdup'd memory maybe!
1865
1866 llvm::BinaryOps BinaryOpVal;
1867 llvm::TermOps TermOpVal;
1868 llvm::MemoryOps MemOpVal;
1869 llvm::OtherOps OtherOpVal;
1870 llvm::CastOps CastOpVal;
1871 llvm::ICmpInst::Predicate IPred;
1872 llvm::FCmpInst::Predicate FPred;
1873 llvm::Module::Endianness Endianness;
Chris Lattnercf3d0612007-02-13 06:04:17 +00001874} YYSTYPE;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001875/* Line 196 of yacc.c. */
Reid Spencer5eb77c72007-03-15 03:26:42 +00001876#line 1877 "UpgradeParser.tab.c"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001877# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1878# define YYSTYPE_IS_DECLARED 1
1879# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001880#endif
1881
Reid Spencer950bf602007-01-26 08:19:09 +00001882
Reid Spencere7c3c602006-11-30 06:36:44 +00001883
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001884/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001885
1886
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001887/* Line 219 of yacc.c. */
Reid Spencer5eb77c72007-03-15 03:26:42 +00001888#line 1889 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001889
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001890#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1891# define YYSIZE_T __SIZE_TYPE__
1892#endif
1893#if ! defined (YYSIZE_T) && defined (size_t)
1894# define YYSIZE_T size_t
1895#endif
1896#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1897# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1898# define YYSIZE_T size_t
1899#endif
1900#if ! defined (YYSIZE_T)
1901# define YYSIZE_T unsigned int
1902#endif
Chris Lattnercf3d0612007-02-13 06:04:17 +00001903
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001904#ifndef YY_
1905# if YYENABLE_NLS
1906# if ENABLE_NLS
1907# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1908# define YY_(msgid) dgettext ("bison-runtime", msgid)
1909# endif
1910# endif
1911# ifndef YY_
1912# define YY_(msgid) msgid
1913# endif
1914#endif
1915
1916#if ! defined (yyoverflow) || YYERROR_VERBOSE
1917
1918/* The parser invokes alloca or malloc; define the necessary symbols. */
1919
1920# ifdef YYSTACK_USE_ALLOCA
1921# if YYSTACK_USE_ALLOCA
1922# ifdef __GNUC__
1923# define YYSTACK_ALLOC __builtin_alloca
1924# else
1925# define YYSTACK_ALLOC alloca
1926# if defined (__STDC__) || defined (__cplusplus)
1927# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1928# define YYINCLUDED_STDLIB_H
1929# endif
1930# endif
1931# endif
1932# endif
1933
1934# ifdef YYSTACK_ALLOC
1935 /* Pacify GCC's `empty if-body' warning. */
1936# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1937# ifndef YYSTACK_ALLOC_MAXIMUM
1938 /* The OS might guarantee only one guard page at the bottom of the stack,
1939 and a page size can be as small as 4096 bytes. So we cannot safely
1940 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1941 to allow for a few compiler-allocated temporary stack slots. */
1942# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1943# endif
1944# else
1945# define YYSTACK_ALLOC YYMALLOC
1946# define YYSTACK_FREE YYFREE
1947# ifndef YYSTACK_ALLOC_MAXIMUM
1948# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1949# endif
1950# ifdef __cplusplus
1951extern "C" {
1952# endif
1953# ifndef YYMALLOC
1954# define YYMALLOC malloc
1955# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1956 && (defined (__STDC__) || defined (__cplusplus)))
1957void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1958# endif
1959# endif
1960# ifndef YYFREE
1961# define YYFREE free
1962# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1963 && (defined (__STDC__) || defined (__cplusplus)))
1964void free (void *); /* INFRINGES ON USER NAME SPACE */
1965# endif
1966# endif
1967# ifdef __cplusplus
1968}
1969# endif
1970# endif
1971#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1972
1973
1974#if (! defined (yyoverflow) \
1975 && (! defined (__cplusplus) \
1976 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1977
1978/* A type that is properly aligned for any stack member. */
1979union yyalloc
1980{
1981 short int yyss;
1982 YYSTYPE yyvs;
1983 };
1984
1985/* The size of the maximum gap between one aligned stack and the next. */
1986# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1987
1988/* The size of an array large to enough to hold all stacks, each with
1989 N elements. */
1990# define YYSTACK_BYTES(N) \
1991 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1992 + YYSTACK_GAP_MAXIMUM)
1993
1994/* Copy COUNT objects from FROM to TO. The source and destination do
1995 not overlap. */
1996# ifndef YYCOPY
1997# if defined (__GNUC__) && 1 < __GNUC__
1998# define YYCOPY(To, From, Count) \
1999 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2000# else
2001# define YYCOPY(To, From, Count) \
2002 do \
2003 { \
2004 YYSIZE_T yyi; \
2005 for (yyi = 0; yyi < (Count); yyi++) \
2006 (To)[yyi] = (From)[yyi]; \
2007 } \
2008 while (0)
2009# endif
2010# endif
2011
2012/* Relocate STACK from its old location to the new one. The
2013 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2014 elements in the stack, and YYPTR gives the new location of the
2015 stack. Advance YYPTR to a properly aligned location for the next
2016 stack. */
2017# define YYSTACK_RELOCATE(Stack) \
2018 do \
2019 { \
2020 YYSIZE_T yynewbytes; \
2021 YYCOPY (&yyptr->Stack, Stack, yysize); \
2022 Stack = &yyptr->Stack; \
2023 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2024 yyptr += yynewbytes / sizeof (*yyptr); \
2025 } \
2026 while (0)
Chris Lattnercf3d0612007-02-13 06:04:17 +00002027
Reid Spencere7c3c602006-11-30 06:36:44 +00002028#endif
2029
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002030#if defined (__STDC__) || defined (__cplusplus)
2031 typedef signed char yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002032#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002033 typedef short int yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002034#endif
2035
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002036/* YYFINAL -- State number of the termination state. */
2037#define YYFINAL 4
2038/* YYLAST -- Last index in YYTABLE. */
2039#define YYLAST 1762
2040
2041/* YYNTOKENS -- Number of terminals. */
2042#define YYNTOKENS 166
2043/* YYNNTS -- Number of nonterminals. */
2044#define YYNNTS 80
2045/* YYNRULES -- Number of rules. */
2046#define YYNRULES 309
2047/* YYNRULES -- Number of states. */
2048#define YYNSTATES 605
2049
2050/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2051#define YYUNDEFTOK 2
2052#define YYMAXUTOK 406
2053
2054#define YYTRANSLATE(YYX) \
2055 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2056
2057/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2058static const unsigned char yytranslate[] =
2059{
2060 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2061 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2062 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2063 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2064 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2065 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2066 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2067 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2069 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2071 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2072 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2073 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2074 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2075 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2077 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2079 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2080 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2081 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2082 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2084 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2085 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2086 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2087 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2088 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2089 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2090 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2091 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2092 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2093 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2094 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2095 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2096 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2097 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2098 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2099 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2100 145, 146, 147, 148, 149, 150, 151
2101};
2102
2103#if YYDEBUG
2104/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2105 YYRHS. */
2106static const unsigned short int yyprhs[] =
2107{
2108 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2109 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2110 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2111 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2112 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2113 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2114 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2115 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2116 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2117 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2118 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2119 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2120 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2121 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2122 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2123 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2124 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2125 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2126 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2127 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2128 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2129 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2130 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2131 650, 652, 653, 654, 660, 661, 663, 665, 667, 669,
2132 671, 673, 675, 677, 679, 683, 685, 691, 693, 695,
2133 697, 699, 702, 705, 708, 712, 715, 716, 718, 720,
2134 722, 725, 728, 732, 742, 752, 761, 775, 777, 779,
2135 786, 792, 795, 802, 810, 812, 816, 818, 819, 822,
2136 824, 830, 836, 842, 849, 856, 859, 864, 869, 876,
2137 881, 886, 891, 896, 903, 910, 913, 921, 923, 926,
2138 927, 929, 930, 934, 941, 945, 952, 955, 960, 967
2139};
2140
2141/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2142static const short int yyrhs[] =
2143{
2144 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2145 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2146 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2147 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2148 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2149 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2150 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2151 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2152 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2153 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2154 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2155 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2156 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2157 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2158 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2159 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2160 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2161 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2162 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2163 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2164 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2165 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2166 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2167 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2168 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2169 -1, 19, -1, 21, -1, 192, -1, 48, -1, 228,
2170 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2171 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2172 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2173 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2174 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2175 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2176 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2177 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2178 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2179 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2180 191, 39, -1, 191, 228, -1, 191, 197, -1, 191,
2181 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2182 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2183 36, 191, 156, -1, 110, 155, 196, 243, 156, -1,
2184 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2185 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2186 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2187 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2188 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2189 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2190 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2191 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2192 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2193 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2194 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2195 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2196 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2197 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2198 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2199 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2200 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2201 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2202 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2203 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2204 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2205 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2206 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2207 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2208 30, -1, 163, -1, 231, 220, -1, -1, 45, -1,
2209 47, -1, -1, -1, 31, 224, 222, 225, 217, -1,
2210 -1, 63, -1, 3, -1, 4, -1, 7, -1, 27,
2211 -1, 28, -1, 38, -1, 39, -1, 26, -1, 160,
2212 198, 161, -1, 197, -1, 61, 226, 24, 153, 24,
2213 -1, 167, -1, 212, -1, 228, -1, 227, -1, 191,
2214 229, -1, 231, 232, -1, 219, 232, -1, 233, 180,
2215 235, -1, 233, 237, -1, -1, 23, -1, 77, -1,
2216 78, -1, 72, 230, -1, 72, 8, -1, 73, 21,
2217 229, -1, 73, 9, 229, 153, 21, 229, 153, 21,
2218 229, -1, 74, 178, 229, 153, 21, 229, 157, 236,
2219 159, -1, 74, 178, 229, 153, 21, 229, 157, 159,
2220 -1, 75, 182, 189, 229, 155, 240, 156, 36, 21,
2221 229, 234, 21, 229, -1, 234, -1, 76, -1, 236,
2222 178, 227, 153, 21, 229, -1, 178, 227, 153, 21,
2223 229, -1, 180, 242, -1, 191, 157, 229, 153, 229,
2224 159, -1, 238, 153, 157, 229, 153, 229, 159, -1,
2225 230, -1, 239, 153, 230, -1, 239, -1, -1, 60,
2226 59, -1, 59, -1, 169, 191, 229, 153, 229, -1,
2227 170, 191, 229, 153, 229, -1, 171, 191, 229, 153,
2228 229, -1, 103, 172, 191, 229, 153, 229, -1, 104,
2229 173, 191, 229, 153, 229, -1, 49, 230, -1, 174,
2230 230, 153, 230, -1, 175, 230, 36, 191, -1, 112,
2231 230, 153, 230, 153, 230, -1, 113, 230, 153, 191,
2232 -1, 117, 230, 153, 191, -1, 118, 230, 153, 191,
2233 -1, 114, 230, 153, 230, -1, 115, 230, 153, 230,
2234 153, 230, -1, 116, 230, 153, 230, 153, 230, -1,
2235 111, 238, -1, 241, 182, 189, 229, 155, 240, 156,
2236 -1, 245, -1, 153, 239, -1, -1, 35, -1, -1,
2237 105, 191, 184, -1, 105, 191, 153, 15, 229, 184,
2238 -1, 106, 191, 184, -1, 106, 191, 153, 15, 229,
2239 184, -1, 107, 230, -1, 244, 108, 191, 229, -1,
2240 244, 109, 230, 153, 191, 229, -1, 110, 191, 229,
2241 243, -1
2242};
2243
2244/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2245static const unsigned short int yyrline[] =
2246{
Reid Spencer5eb77c72007-03-15 03:26:42 +00002247 0, 1594, 1594, 1595, 1603, 1604, 1614, 1614, 1614, 1614,
2248 1614, 1614, 1614, 1614, 1614, 1614, 1614, 1618, 1618, 1618,
2249 1622, 1622, 1622, 1622, 1622, 1622, 1626, 1626, 1627, 1627,
2250 1628, 1628, 1629, 1629, 1630, 1630, 1634, 1634, 1635, 1635,
2251 1636, 1636, 1637, 1637, 1638, 1638, 1639, 1639, 1640, 1640,
2252 1641, 1642, 1645, 1645, 1645, 1645, 1649, 1649, 1649, 1649,
2253 1649, 1649, 1649, 1650, 1650, 1650, 1650, 1650, 1650, 1656,
2254 1656, 1656, 1656, 1660, 1660, 1660, 1660, 1664, 1664, 1668,
2255 1668, 1673, 1676, 1681, 1682, 1683, 1684, 1685, 1686, 1687,
2256 1688, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1709,
2257 1710, 1718, 1719, 1727, 1736, 1737, 1744, 1745, 1749, 1753,
2258 1769, 1770, 1777, 1778, 1785, 1793, 1793, 1793, 1793, 1793,
2259 1793, 1793, 1794, 1794, 1794, 1794, 1794, 1799, 1803, 1807,
2260 1812, 1821, 1838, 1844, 1857, 1866, 1870, 1881, 1885, 1898,
2261 1902, 1909, 1910, 1916, 1923, 1935, 1965, 1978, 2001, 2029,
2262 2051, 2062, 2084, 2095, 2104, 2109, 2167, 2174, 2182, 2189,
2263 2196, 2200, 2204, 2213, 2228, 2241, 2250, 2278, 2291, 2300,
2264 2306, 2312, 2323, 2329, 2335, 2346, 2347, 2356, 2357, 2369,
2265 2378, 2379, 2380, 2381, 2382, 2398, 2418, 2420, 2422, 2422,
2266 2429, 2429, 2436, 2436, 2443, 2443, 2451, 2453, 2455, 2460,
2267 2474, 2475, 2479, 2482, 2490, 2494, 2501, 2505, 2509, 2513,
2268 2521, 2521, 2525, 2526, 2530, 2538, 2543, 2551, 2552, 2559,
2269 2566, 2570, 2746, 2746, 2750, 2760, 2760, 2764, 2769, 2770,
2270 2771, 2775, 2776, 2775, 2788, 2789, 2794, 2795, 2796, 2797,
2271 2798, 2799, 2800, 2801, 2802, 2823, 2826, 2841, 2842, 2847,
2272 2847, 2855, 2864, 2867, 2876, 2886, 2891, 2900, 2911, 2911,
2273 2914, 2917, 2920, 2924, 2930, 2945, 2951, 3007, 3010, 3016,
2274 3026, 3039, 3068, 3076, 3084, 3088, 3095, 3096, 3100, 3103,
2275 3109, 3126, 3142, 3156, 3168, 3180, 3191, 3209, 3218, 3227,
2276 3234, 3255, 3279, 3285, 3291, 3297, 3313, 3391, 3399, 3400,
2277 3404, 3405, 3409, 3415, 3421, 3427, 3433, 3440, 3452, 3477
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002278};
2279#endif
2280
2281#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2282/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2283 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2284static const char *const yytname[] =
2285{
2286 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2287 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2288 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2289 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2290 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2291 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2292 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2293 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2294 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2295 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2296 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2297 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2298 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2299 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2300 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2301 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2302 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2303 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2304 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2305 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2306 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2307 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2308 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2309 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2310 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2311 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2312 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2313 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2314 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2315 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2316 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2317 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2318 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2319 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2320 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5", "@6",
2321 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2322 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2323 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2324 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2325 "OptVolatile", "MemoryInst", 0
2326};
2327#endif
2328
2329# ifdef YYPRINT
2330/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2331 token YYLEX-NUM. */
2332static const unsigned short int yytoknum[] =
2333{
2334 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2335 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2336 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2337 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2338 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2339 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2340 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2341 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2342 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2343 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2344 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2345 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2346 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2347 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2348 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2349 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2350 60, 62, 123, 125, 42, 99
2351};
2352# endif
2353
2354/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2355static const unsigned char yyr1[] =
2356{
2357 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2358 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2359 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2360 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2361 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2362 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2363 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2364 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2365 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2366 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2367 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2368 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2369 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2370 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2371 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2372 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2373 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2374 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2375 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2376 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2377 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2378 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2379 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2380 222, 224, 225, 223, 226, 226, 227, 227, 227, 227,
2381 227, 227, 227, 227, 227, 227, 227, 228, 228, 229,
2382 229, 230, 231, 231, 232, 233, 233, 233, 234, 234,
2383 235, 235, 235, 235, 235, 235, 235, 235, 235, 236,
2384 236, 237, 238, 238, 239, 239, 240, 240, 241, 241,
2385 242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
2386 242, 242, 242, 242, 242, 242, 242, 242, 243, 243,
2387 244, 244, 245, 245, 245, 245, 245, 245, 245, 245
2388};
2389
2390/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2391static const unsigned char yyr2[] =
2392{
2393 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2398 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2399 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2400 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2401 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2402 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2403 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2406 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2407 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2408 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2409 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2410 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2411 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2412 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2413 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2414 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2415 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2416 1, 0, 0, 5, 0, 1, 1, 1, 1, 1,
2417 1, 1, 1, 1, 3, 1, 5, 1, 1, 1,
2418 1, 2, 2, 2, 3, 2, 0, 1, 1, 1,
2419 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
2420 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
2421 5, 5, 5, 6, 6, 2, 4, 4, 6, 4,
2422 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
2423 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
2424};
2425
2426/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2427 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2428 means the default is an error. */
2429static const unsigned short int yydefact[] =
2430{
2431 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2432 86, 87, 88, 89, 0, 91, 256, 180, 181, 256,
2433 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2434 0, 92, 93, 94, 95, 96, 97, 0, 0, 257,
2435 253, 82, 225, 226, 227, 252, 0, 0, 0, 0,
2436 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2437 230, 232, 199, 182, 98, 2, 3, 111, 115, 116,
2438 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2439 128, 0, 0, 0, 0, 247, 0, 0, 110, 127,
2440 114, 248, 129, 222, 223, 224, 301, 255, 0, 0,
2441 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2442 0, 0, 91, 130, 0, 0, 0, 113, 135, 139,
2443 0, 0, 144, 138, 300, 0, 279, 0, 0, 0,
2444 0, 91, 268, 258, 259, 6, 7, 8, 9, 10,
2445 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2446 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2448 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2449 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2450 0, 267, 254, 91, 271, 0, 297, 204, 201, 200,
2451 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2452 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2453 0, 0, 0, 188, 233, 0, 0, 0, 0, 0,
2454 134, 220, 143, 141, 0, 0, 285, 278, 261, 260,
2455 0, 0, 72, 76, 71, 75, 70, 74, 69, 73,
2456 77, 78, 0, 0, 26, 27, 28, 29, 30, 31,
2457 32, 33, 34, 35, 0, 50, 51, 46, 47, 48,
2458 49, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2459 45, 0, 101, 101, 306, 0, 0, 295, 0, 0,
2460 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2461 0, 0, 0, 0, 206, 106, 106, 106, 160, 161,
2462 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2463 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2464 0, 0, 0, 0, 156, 155, 106, 112, 112, 137,
2465 0, 140, 219, 213, 216, 217, 0, 0, 131, 236,
2466 237, 238, 243, 239, 240, 241, 242, 234, 0, 245,
2467 250, 249, 251, 0, 262, 0, 0, 0, 0, 0,
2468 302, 0, 304, 299, 0, 0, 0, 0, 0, 0,
2469 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2470 0, 207, 0, 193, 195, 191, 0, 0, 0, 0,
2471 0, 0, 0, 146, 176, 0, 0, 0, 150, 0,
2472 147, 0, 0, 0, 0, 0, 189, 132, 133, 136,
2473 212, 214, 0, 104, 142, 235, 0, 0, 0, 0,
2474 0, 0, 0, 0, 0, 0, 0, 309, 0, 0,
2475 0, 289, 292, 0, 0, 290, 291, 0, 0, 0,
2476 286, 287, 0, 307, 0, 0, 0, 108, 106, 0,
2477 0, 299, 0, 0, 0, 0, 0, 145, 135, 114,
2478 0, 148, 149, 0, 0, 0, 0, 0, 218, 215,
2479 105, 99, 0, 244, 0, 0, 277, 0, 0, 101,
2480 102, 101, 274, 298, 0, 0, 0, 0, 0, 280,
2481 281, 282, 277, 0, 103, 109, 107, 0, 0, 0,
2482 0, 0, 0, 0, 175, 152, 0, 0, 0, 0,
2483 0, 0, 0, 221, 0, 0, 0, 276, 0, 283,
2484 284, 0, 303, 305, 0, 0, 0, 288, 293, 294,
2485 0, 308, 0, 0, 164, 0, 0, 0, 0, 151,
2486 0, 0, 0, 0, 0, 100, 246, 0, 0, 0,
2487 275, 272, 0, 296, 0, 0, 0, 172, 0, 0,
2488 166, 167, 168, 171, 163, 0, 265, 0, 0, 0,
2489 273, 169, 170, 0, 0, 0, 263, 0, 264, 0,
2490 0, 165, 173, 174, 0, 0, 0, 0, 0, 0,
2491 270, 0, 0, 269, 266
2492};
2493
2494/* YYDEFGOTO[NTERM-NUM]. */
2495static const short int yydefgoto[] =
2496{
2497 -1, 85, 312, 329, 330, 331, 264, 281, 332, 333,
2498 219, 220, 252, 221, 25, 15, 37, 523, 370, 457,
2499 481, 393, 458, 86, 87, 222, 89, 90, 120, 234,
2500 404, 359, 405, 108, 1, 2, 3, 336, 307, 305,
2501 306, 63, 200, 50, 103, 204, 91, 421, 344, 345,
2502 346, 38, 95, 16, 44, 17, 61, 18, 28, 112,
2503 426, 360, 92, 362, 492, 19, 40, 41, 191, 192,
2504 578, 97, 287, 527, 528, 193, 194, 437, 195, 196
2505};
2506
2507/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2508 STATE-NUM. */
2509#define YYPACT_NINF -555
2510static const short int yypact[] =
2511{
2512 -555, 136, 58, 247, -555, -555, -555, -555, -555, -555,
2513 -555, -555, -555, -555, 96, 181, 141, -555, -555, -9,
2514 -555, -555, 16, 7, 114, 65, 39, -555, 50, 188,
2515 210, -555, -555, -555, -555, -555, -555, 1357, -19, -555,
2516 -555, 134, -555, -555, -555, -555, 68, 69, 70, 73,
2517 -555, 60, 188, 1357, 4, 4, 4, 4, -555, -555,
2518 -555, -555, -555, -555, -555, -555, -555, 63, -555, -555,
2519 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2520 -555, 222, 224, 1, 171, -555, 134, 84, -555, -555,
2521 -103, -555, -555, -555, -555, -555, 1611, -555, 216, 66,
2522 238, 219, 233, -555, -555, -555, -555, -555, 1418, 1418,
2523 1418, 1459, 181, -555, 100, 101, 737, -555, -555, -103,
2524 -112, 105, 803, -555, -555, 1418, -555, 202, 1479, 13,
2525 221, 181, -555, -555, -555, -555, -555, -555, -555, -555,
2526 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2527 -555, -555, -555, -555, -555, -555, -555, -555, -555, 77,
2528 377, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418,
2529 1418, 1418, 1418, -555, -555, -555, -555, -555, -555, -555,
2530 -555, -555, -555, -555, -555, -555, 1418, 1418, 1418, 1418,
2531 1418, -555, -555, 181, -555, 33, -555, -555, -555, -555,
2532 -555, -555, -555, -555, -15, -555, -555, -555, 36, 158,
2533 262, 164, 264, 167, 266, 169, 268, 269, 270, 204,
2534 271, 274, 579, -555, -555, 1418, 1418, 121, -67, 1418,
2535 -555, 1199, -555, 120, 127, 920, -555, -555, 63, -555,
2536 920, 920, -555, -555, -555, -555, -555, -555, -555, -555,
2537 -555, -555, 920, 1357, -555, -555, -555, -555, -555, -555,
2538 -555, -555, -555, -555, 1418, -555, -555, -555, -555, -555,
2539 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2540 -555, 1418, 142, 143, -555, 920, 147, 153, 154, 155,
2541 157, 165, 166, 168, 170, 920, 920, 920, 173, 275,
2542 1357, 1418, 1418, 293, -555, 174, 174, 174, -555, -555,
2543 -555, -555, -555, -555, -555, -555, -555, -555, 77, 377,
2544 175, 177, 180, 182, 183, 1240, 1520, 757, 296, 192,
2545 193, 199, 203, 207, -555, -555, 174, -45, -71, -555,
2546 161, -103, -555, 134, -555, 176, 209, 1260, -555, -555,
2547 -555, -555, -555, -555, -555, -555, -555, 261, 1459, -555,
2548 -555, -555, -555, 206, -555, 213, 920, 920, 920, -2,
2549 -555, 0, -555, 215, 920, 179, 1418, 1418, 1418, 1418,
2550 1418, 1418, 1418, 217, 218, 223, 1418, 1418, 920, 920,
2551 226, -555, -17, -555, -555, -555, 214, 220, 1459, 1459,
2552 1459, 1459, 1459, -555, -555, -13, 778, -94, -555, -40,
2553 -555, 1459, 1459, 1459, 1459, 1459, -555, -555, -555, -555,
2554 -555, -555, 1301, 346, -555, -555, 357, -69, 361, 362,
2555 229, 234, 235, 920, 382, 920, 1418, -555, 236, 920,
2556 237, -555, -555, 239, 240, -555, -555, 920, 920, 920,
2557 -555, -555, 241, -555, 1418, 367, 390, -555, 174, 1459,
2558 1459, 215, 242, 245, 248, 249, 1459, -555, 254, -16,
2559 -8, -555, -555, 250, 253, 263, 272, 364, -555, -555,
2560 -555, 366, 273, -555, 920, 920, 1418, 920, 920, 276,
2561 -555, 276, -555, 279, 920, 280, 1418, 1418, 1418, -555,
2562 -555, -555, 1418, 920, -555, -555, -555, 281, 282, 283,
2563 1459, 1459, 1459, 1459, -555, -555, 284, 1459, 1459, 1459,
2564 1459, 1418, 423, -555, 416, 288, 285, 279, 290, -555,
2565 -555, 391, -555, -555, 1418, 294, 920, -555, -555, -555,
2566 291, -555, 1459, 1459, -555, 299, 298, 302, 303, -555,
2567 301, 306, 307, 308, 310, -555, -555, 437, 15, 432,
2568 -555, -555, 312, -555, 316, 319, 1459, -555, 1459, 1459,
2569 -555, -555, -555, -555, -555, 920, -555, 1046, 64, 460,
2570 -555, -555, -555, 326, 329, 331, -555, 335, -555, 1046,
2571 920, -555, -555, -555, 468, 337, 132, 920, 470, 472,
2572 -555, 920, 920, -555, -555
2573};
2574
2575/* YYPGOTO[NTERM-NUM]. */
2576static const short int yypgoto[] =
2577{
2578 -555, -555, -555, 398, 399, 400, 198, 200, 402, 403,
2579 -128, -127, -525, -555, 476, 493, -111, -555, -276, 97,
2580 -555, -298, -555, -47, -555, -37, -555, -60, -62, -555,
2581 -99, 300, -308, 61, -555, -555, -555, -555, -555, -555,
2582 -555, 469, -555, -555, -555, -555, 8, -555, 102, -555,
2583 -555, 411, -555, -555, -555, -555, -555, 523, -555, -555,
2584 -555, -554, -11, 112, -124, -555, 508, -555, -68, -555,
2585 -555, -555, -555, 93, 28, -555, -555, 71, -555, -555
2586};
2587
2588/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2589 positive, shift that token. If negative, reduce the rule which
2590 number is the opposite. If zero, do what YYDEFACT says.
2591 If YYTABLE_NINF, syntax error. */
2592#define YYTABLE_NINF -180
2593static const short int yytable[] =
2594{
2595 88, 236, 250, 251, 239, 115, 105, 372, 394, 395,
2596 93, 26, 223, 433, 39, 435, 88, 455, 407, 409,
2597 253, 42, 240, 587, 119, 242, 243, 244, 245, 246,
2598 247, 248, 249, 577, 241, 595, 106, 107, 416, 284,
2599 456, 229, 288, 289, 290, 291, 292, 293, 294, 26,
2600 427, 230, -112, 589, 228, 434, 119, 434, -179, 466,
2601 233, 123, 119, 308, 309, 298, 299, 471, 46, 47,
2602 48, 205, 206, 207, 242, 243, 244, 245, 246, 247,
2603 248, 249, 300, 5, 466, 53, 229, 49, 235, 6,
2604 418, 235, 483, 123, 121, 59, 340, 60, 470, 7,
2605 8, 9, 10, 11, 12, 13, 7, 8, 9, 10,
2606 54, 12, 55, 466, 417, 56, 109, 110, 111, 123,
2607 14, 198, 199, 472, 282, 283, 235, 285, 286, 235,
2608 235, 235, 235, 235, 235, 235, 4, -139, 303, -112,
2609 466, 301, 302, 94, 304, 466, 467, -139, 123, 295,
2610 296, 297, 235, 235, 43, 516, 20, 29, 21, 51,
2611 506, -72, -72, 116, 39, 337, 338, -71, -71, 341,
2612 -70, -70, -69, -69, 576, 52, 65, 66, 390, 117,
2613 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2614 78, 58, 79, 20, 343, 21, 254, 255, 256, 257,
2615 258, 259, 260, 261, 262, 263, 366, 310, 311, 133,
2616 134, 335, 62, 532, 64, 533, 88, 102, -113, 80,
2617 98, 99, 100, 588, 361, 101, 113, 367, 114, 361,
2618 361, 242, 243, 244, 245, 246, 247, 248, 249, 122,
2619 197, 361, 201, 202, 368, 30, 31, 32, 33, 34,
2620 35, 36, 440, 388, 442, 443, 444, 203, 225, 226,
2621 231, 237, 450, 88, 389, 235, -76, -82, -75, 20,
2622 -74, 21, -73, 347, 361, 313, -79, -80, 6, -82,
2623 -82, 314, 339, 348, 361, 361, 361, 341, -82, -82,
2624 -82, -82, -82, -82, -82, 369, 371, -82, 22, 461,
2625 462, 463, 464, 465, 374, 23, 375, 376, 377, 24,
2626 378, 387, 473, 474, 475, 476, 477, 391, 379, 380,
2627 410, 381, 419, 382, 425, 81, 386, 392, 82, 422,
2628 398, 83, 399, 84, 118, 400, 439, 401, 402, 235,
2629 441, 235, 235, 235, 445, 446, 469, 411, 412, 235,
2630 451, 420, 363, 364, 413, 361, 361, 361, 414, 428,
2631 507, 508, 415, 361, 365, 423, 429, 514, 436, 459,
2632 447, 448, 537, 538, 539, 460, 449, 361, 361, 454,
2633 455, 482, 484, 485, 486, 343, 490, 487, 488, 494,
2634 496, 504, 497, 498, 505, 510, 502, 373, 511, 235,
2635 521, 512, 513, 517, 265, 266, 518, 383, 384, 385,
2636 560, 545, 546, 547, 548, 515, 519, 503, 550, 551,
2637 552, 553, 361, 522, 361, 520, 524, 555, 361, 531,
2638 250, 251, 534, 536, 542, 543, 361, 361, 361, 544,
2639 556, 557, 558, 564, 565, 549, 559, 563, 434, 235,
2640 250, 251, 566, 561, 567, 568, 569, 570, 575, 235,
2641 235, 235, 571, 572, 573, 235, 574, 583, 579, 584,
2642 585, 580, 581, 361, 361, 582, 361, 361, 430, 431,
2643 432, 590, 591, 361, 554, 592, 438, 593, 594, 597,
2644 598, 601, 361, 602, 186, 187, 188, 235, 189, 190,
2645 452, 453, 267, 268, 269, 270, 271, 272, 273, 274,
2646 275, 276, 277, 278, 279, 280, 396, 96, 57, 397,
2647 480, 104, 334, 224, 479, 361, 27, 45, 599, 493,
2648 540, 0, 509, 0, 0, 0, 0, 0, 0, 0,
2649 0, 0, 0, 0, 0, 489, 0, 491, 0, 0,
2650 0, 495, 0, 0, 0, 0, 0, 0, 0, 499,
2651 500, 501, 0, 0, 361, 0, 0, 0, 0, 0,
2652 0, 0, 0, 0, 0, 0, 0, 0, 0, 361,
2653 0, 0, 0, 0, 65, 66, 361, 0, 0, 0,
2654 361, 361, 0, 0, 0, 0, 525, 526, 0, 529,
2655 530, 20, 0, 21, 0, 315, 535, 0, 0, 0,
2656 0, 0, 0, 0, 0, 541, 0, 316, 317, 0,
2657 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2658 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2659 0, 0, 0, 0, 0, 0, 0, 0, 562, 0,
2660 0, 0, 0, 0, 0, 0, 0, 0, 135, 136,
2661 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
2662 147, 148, 149, 150, 151, 152, 153, 154, 155, 156,
2663 157, 158, 318, 319, 0, 0, 0, 586, 0, 320,
2664 0, 321, 0, 322, 323, 324, 0, 0, 0, 0,
2665 0, 0, 596, 0, 0, 0, 0, 0, 0, 600,
2666 0, 0, 0, 603, 604, 0, 0, 0, 173, 174,
2667 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
2668 185, 0, 0, 0, 0, 0, 325, 0, 0, 326,
2669 0, 327, 65, 66, 328, 117, 68, 69, 70, 71,
2670 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2671 0, 21, 65, 66, 0, 117, 208, 209, 210, 211,
2672 212, 213, 214, 215, 216, 217, 218, 0, 79, 20,
2673 0, 21, 0, 65, 66, 80, 117, 208, 209, 210,
2674 211, 212, 213, 214, 215, 216, 217, 218, 0, 79,
2675 20, 0, 21, 0, 0, 80, 0, 0, 65, 66,
2676 0, 117, 68, 69, 70, 71, 72, 73, 74, 75,
2677 76, 77, 78, 0, 79, 20, 80, 21, 0, 0,
2678 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2679 232, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2680 0, 80, 0, 0, 0, 0, 0, 0, 0, 0,
2681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2682 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2683 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2684 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2685 227, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2686 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2687 408, 0, 0, 349, 350, 65, 66, 351, 0, 0,
2688 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2689 84, 468, 20, 0, 21, 0, 352, 353, 354, 0,
2690 0, 0, 0, 0, 0, 0, 0, 81, 355, 356,
2691 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2692 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2693 0, 357, 0, 0, 0, 0, 0, 0, 0, 0,
2694 0, 0, 0, 0, 0, 0, 0, 0, 0, 135,
2695 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2696 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
2697 156, 157, 158, 318, 319, 0, 0, 0, 0, 0,
2698 320, 0, 321, 0, 322, 323, 324, 0, 0, 0,
2699 0, 0, 0, 0, 0, 0, 0, 0, 0, 349,
2700 350, 0, 0, 351, 0, 0, 0, 0, 0, 173,
2701 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2702 184, 185, 352, 353, 354, 0, 0, 0, 0, 0,
2703 358, 0, 0, 0, 355, 356, 0, 0, 0, 0,
2704 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2705 0, 0, 0, 0, 0, 0, 0, 357, 0, 0,
2706 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2707 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2708 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2709 150, 151, 152, 153, 154, 155, 156, 157, 158, 318,
2710 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
2711 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
2712 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2713 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2714 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2715 0, 0, 0, 0, 65, 66, 358, 117, 68, 69,
2716 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2717 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2718 0, 0, 0, 0, 0, 0, 342, 0, 0, 0,
2719 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2720 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2721 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2722 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2723 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2724 0, 0, 0, 0, 0, 0, 0, 424, 0, 0,
2725 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2726 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2727 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2728 0, 0, 0, 0, 0, 0, 0, 0, 478, 0,
2729 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2730 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2731 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2732 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2733 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2734 0, 0, 0, 0, 81, 0, 0, 82, 0, 403,
2735 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2736 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2737 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2738 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2739 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2740 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2741 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2742 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2743 79, 20, 0, 21, 65, 66, 0, 238, 68, 69,
2744 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2745 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2746 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2747 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2748 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2749 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2750 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2751 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2752 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2753 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2754 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2755 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2756 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2757 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2758 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2759 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
2760 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2761 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2762 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2763 83, 0, 406, 128, 129, 130, 131, 132, 133, 134,
2764 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2765 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2766 155, 156, 157, 158, 159, 160, 161, 162, 163, 0,
2767 0, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2768 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2769 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2770 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2771 183, 184, 185
2772};
2773
2774static const short int yycheck[] =
2775{
2776 37, 125, 130, 130, 128, 4, 53, 283, 306, 307,
2777 29, 3, 111, 15, 23, 15, 53, 34, 326, 327,
2778 131, 30, 9, 577, 84, 10, 11, 12, 13, 14,
2779 15, 16, 17, 558, 21, 589, 32, 33, 336, 163,
2780 57, 153, 166, 167, 168, 169, 170, 171, 172, 41,
2781 358, 163, 155, 578, 116, 57, 116, 57, 0, 153,
2782 122, 164, 122, 27, 28, 189, 190, 161, 52, 53,
2783 54, 108, 109, 110, 10, 11, 12, 13, 14, 15,
2784 16, 17, 193, 25, 153, 20, 153, 71, 125, 31,
2785 161, 128, 161, 164, 86, 45, 163, 47, 406, 41,
2786 42, 43, 44, 45, 46, 47, 41, 42, 43, 44,
2787 45, 46, 47, 153, 159, 50, 55, 56, 57, 164,
2788 62, 55, 56, 163, 161, 162, 163, 164, 165, 166,
2789 167, 168, 169, 170, 171, 172, 0, 153, 153, 155,
2790 153, 108, 109, 162, 159, 153, 159, 163, 164, 186,
2791 187, 188, 189, 190, 163, 163, 22, 61, 24, 152,
2792 458, 3, 4, 162, 23, 225, 226, 3, 4, 229,
2793 3, 4, 3, 4, 159, 61, 5, 6, 302, 8,
2794 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2795 19, 152, 21, 22, 231, 24, 119, 120, 121, 122,
2796 123, 124, 125, 126, 127, 128, 253, 3, 4, 77,
2797 78, 222, 24, 489, 4, 491, 253, 157, 155, 48,
2798 152, 152, 152, 159, 235, 152, 4, 264, 4, 240,
2799 241, 10, 11, 12, 13, 14, 15, 16, 17, 155,
2800 24, 252, 4, 24, 281, 64, 65, 66, 67, 68,
2801 69, 70, 376, 300, 378, 379, 380, 24, 158, 158,
2802 155, 59, 386, 300, 301, 302, 4, 20, 4, 22,
2803 4, 24, 4, 153, 285, 4, 7, 7, 31, 32,
2804 33, 7, 161, 156, 295, 296, 297, 347, 41, 42,
2805 43, 44, 45, 46, 47, 153, 153, 50, 51, 398,
2806 399, 400, 401, 402, 157, 58, 153, 153, 153, 62,
2807 153, 36, 411, 412, 413, 414, 415, 24, 153, 153,
2808 24, 153, 161, 153, 63, 154, 153, 153, 157, 153,
2809 155, 160, 155, 162, 163, 155, 157, 155, 155, 376,
2810 377, 378, 379, 380, 381, 382, 406, 155, 155, 386,
2811 387, 343, 240, 241, 155, 366, 367, 368, 155, 153,
2812 459, 460, 155, 374, 252, 156, 153, 466, 153, 155,
2813 153, 153, 496, 497, 498, 155, 153, 388, 389, 153,
2814 34, 24, 21, 21, 155, 422, 4, 153, 153, 153,
2815 153, 24, 153, 153, 4, 153, 155, 285, 153, 436,
2816 36, 153, 153, 153, 27, 28, 153, 295, 296, 297,
2817 534, 510, 511, 512, 513, 161, 153, 454, 517, 518,
2818 519, 520, 433, 57, 435, 153, 153, 4, 439, 153,
2819 558, 558, 153, 153, 153, 153, 447, 448, 449, 156,
2820 24, 153, 157, 542, 543, 161, 156, 156, 57, 486,
2821 578, 578, 153, 159, 156, 153, 153, 156, 21, 496,
2822 497, 498, 156, 156, 156, 502, 156, 566, 36, 568,
2823 569, 159, 156, 484, 485, 156, 487, 488, 366, 367,
2824 368, 21, 156, 494, 521, 156, 374, 156, 153, 21,
2825 153, 21, 503, 21, 96, 96, 96, 534, 96, 96,
2826 388, 389, 125, 126, 127, 128, 129, 130, 131, 132,
2827 133, 134, 135, 136, 137, 138, 318, 41, 25, 319,
2828 423, 52, 222, 112, 422, 536, 3, 19, 596, 436,
2829 502, -1, 461, -1, -1, -1, -1, -1, -1, -1,
2830 -1, -1, -1, -1, -1, 433, -1, 435, -1, -1,
2831 -1, 439, -1, -1, -1, -1, -1, -1, -1, 447,
2832 448, 449, -1, -1, 575, -1, -1, -1, -1, -1,
2833 -1, -1, -1, -1, -1, -1, -1, -1, -1, 590,
2834 -1, -1, -1, -1, 5, 6, 597, -1, -1, -1,
2835 601, 602, -1, -1, -1, -1, 484, 485, -1, 487,
2836 488, 22, -1, 24, -1, 26, 494, -1, -1, -1,
2837 -1, -1, -1, -1, -1, 503, -1, 38, 39, -1,
2838 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2839 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2840 -1, -1, -1, -1, -1, -1, -1, -1, 536, -1,
2841 -1, -1, -1, -1, -1, -1, -1, -1, 79, 80,
2842 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2843 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
2844 101, 102, 103, 104, -1, -1, -1, 575, -1, 110,
2845 -1, 112, -1, 114, 115, 116, -1, -1, -1, -1,
2846 -1, -1, 590, -1, -1, -1, -1, -1, -1, 597,
2847 -1, -1, -1, 601, 602, -1, -1, -1, 139, 140,
2848 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
2849 151, -1, -1, -1, -1, -1, 157, -1, -1, 160,
2850 -1, 162, 5, 6, 165, 8, 9, 10, 11, 12,
2851 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2852 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
2853 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2854 -1, 24, -1, 5, 6, 48, 8, 9, 10, 11,
2855 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2856 22, -1, 24, -1, -1, 48, -1, -1, 5, 6,
2857 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2858 17, 18, 19, -1, 21, 22, 48, 24, -1, -1,
2859 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2860 37, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2861 -1, 48, -1, -1, -1, -1, -1, -1, -1, -1,
2862 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2863 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2864 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2865 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2866 163, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2867 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2868 163, -1, -1, 3, 4, 5, 6, 7, -1, -1,
2869 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2870 162, 163, 22, -1, 24, -1, 26, 27, 28, -1,
2871 -1, -1, -1, -1, -1, -1, -1, 154, 38, 39,
2872 157, -1, -1, 160, -1, 162, -1, -1, -1, -1,
2873 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2874 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
2875 -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
2876 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2877 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
2878 100, 101, 102, 103, 104, -1, -1, -1, -1, -1,
2879 110, -1, 112, -1, 114, 115, 116, -1, -1, -1,
2880 -1, -1, -1, -1, -1, -1, -1, -1, -1, 3,
2881 4, -1, -1, 7, -1, -1, -1, -1, -1, 139,
2882 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2883 150, 151, 26, 27, 28, -1, -1, -1, -1, -1,
2884 160, -1, -1, -1, 38, 39, -1, -1, -1, -1,
2885 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2886 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
2887 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2888 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2889 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2890 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2891 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
2892 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2893 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2894 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2895 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2896 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2897 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2898 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2899 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2900 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2901 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2902 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2903 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2904 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2905 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2906 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2907 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2908 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2909 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2910 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2911 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2912 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2913 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2914 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2915 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2916 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2917 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2918 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2919 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2920 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2921 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2922 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2923 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2924 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2925 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2926 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2927 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2928 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2929 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2930 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2931 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2932 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2933 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2934 162, -1, -1, -1, -1, -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, -1, -1,
2937 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2938 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2939 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2940 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2941 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2942 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2943 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2944 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2945 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2946 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2947 99, 100, 101, 102, 103, 104, 105, 106, 107, -1,
2948 -1, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2949 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2950 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2951 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2952 149, 150, 151
2953};
2954
2955/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2956 symbol of state STATE-NUM. */
2957static const unsigned char yystos[] =
2958{
2959 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2960 44, 45, 46, 47, 62, 181, 219, 221, 223, 231,
2961 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2962 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2963 232, 233, 30, 163, 220, 232, 52, 53, 54, 71,
2964 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2965 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2966 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2967 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2968 193, 212, 228, 29, 162, 218, 180, 237, 152, 152,
2969 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2970 199, 199, 225, 4, 4, 4, 162, 8, 163, 193,
2971 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2972 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2973 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2974 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2975 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
2976 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2977 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2978 175, 234, 235, 241, 242, 244, 245, 24, 55, 56,
2979 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2980 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2981 177, 179, 191, 196, 217, 158, 158, 163, 194, 153,
2982 163, 155, 37, 194, 195, 191, 230, 59, 8, 230,
2983 9, 21, 10, 11, 12, 13, 14, 15, 16, 17,
2984 176, 177, 178, 182, 119, 120, 121, 122, 123, 124,
2985 125, 126, 127, 128, 172, 27, 28, 125, 126, 127,
2986 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
2987 138, 173, 191, 191, 230, 191, 191, 238, 230, 230,
2988 230, 230, 230, 230, 230, 191, 191, 191, 230, 230,
2989 182, 108, 109, 153, 159, 205, 206, 204, 27, 28,
2990 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
2991 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
2992 170, 171, 174, 175, 197, 228, 203, 193, 193, 161,
2993 163, 193, 37, 191, 214, 215, 216, 153, 156, 3,
2994 4, 7, 26, 27, 28, 38, 39, 61, 160, 197,
2995 227, 228, 229, 229, 229, 229, 189, 191, 191, 153,
2996 184, 153, 184, 229, 157, 153, 153, 153, 153, 153,
2997 153, 153, 153, 229, 229, 229, 153, 36, 189, 191,
2998 230, 24, 153, 187, 187, 187, 172, 173, 155, 155,
2999 155, 155, 155, 159, 196, 198, 162, 198, 163, 198,
3000 24, 155, 155, 155, 155, 155, 187, 159, 161, 161,
3001 212, 213, 153, 156, 37, 63, 226, 198, 153, 153,
3002 229, 229, 229, 15, 57, 15, 153, 243, 229, 157,
3003 230, 191, 230, 230, 230, 191, 191, 153, 153, 153,
3004 230, 191, 229, 229, 153, 34, 57, 185, 188, 155,
3005 155, 196, 196, 196, 196, 196, 153, 159, 163, 193,
3006 198, 161, 163, 196, 196, 196, 196, 196, 37, 214,
3007 185, 186, 24, 161, 21, 21, 155, 153, 153, 229,
3008 4, 229, 230, 239, 153, 229, 153, 153, 153, 229,
3009 229, 229, 155, 191, 24, 4, 187, 196, 196, 243,
3010 153, 153, 153, 153, 196, 161, 163, 153, 153, 153,
3011 153, 36, 57, 183, 153, 229, 229, 239, 240, 229,
3012 229, 153, 184, 184, 153, 229, 153, 230, 230, 230,
3013 240, 229, 153, 153, 156, 196, 196, 196, 196, 161,
3014 196, 196, 196, 196, 191, 4, 24, 153, 157, 156,
3015 230, 159, 229, 156, 196, 196, 153, 156, 153, 153,
3016 156, 156, 156, 156, 156, 21, 159, 178, 236, 36,
3017 159, 156, 156, 196, 196, 196, 229, 227, 159, 178,
3018 21, 156, 156, 156, 153, 227, 229, 21, 153, 234,
3019 229, 21, 21, 229, 229
3020};
Reid Spencere7c3c602006-11-30 06:36:44 +00003021
3022#define yyerrok (yyerrstatus = 0)
3023#define yyclearin (yychar = YYEMPTY)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003024#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003025#define YYEOF 0
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003026
Reid Spencere7c3c602006-11-30 06:36:44 +00003027#define YYACCEPT goto yyacceptlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003028#define YYABORT goto yyabortlab
3029#define YYERROR goto yyerrorlab
3030
3031
3032/* Like YYERROR except do call yyerror. This remains here temporarily
3033 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003034 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003035
Reid Spencere7c3c602006-11-30 06:36:44 +00003036#define YYFAIL goto yyerrlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003037
Reid Spencere7c3c602006-11-30 06:36:44 +00003038#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003039
3040#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003041do \
3042 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003043 { \
3044 yychar = (Token); \
3045 yylval = (Value); \
3046 yytoken = YYTRANSLATE (yychar); \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003047 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003048 goto yybackup; \
3049 } \
3050 else \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003051 { \
3052 yyerror (YY_("syntax error: cannot back up")); \
3053 YYERROR; \
3054 } \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003055while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003056
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003057
Reid Spencere7c3c602006-11-30 06:36:44 +00003058#define YYTERROR 1
3059#define YYERRCODE 256
3060
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003061
3062/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3063 If N is 0, then set CURRENT to the empty location which ends
3064 the previous symbol: RHS[0] (always defined). */
3065
3066#define YYRHSLOC(Rhs, K) ((Rhs)[K])
3067#ifndef YYLLOC_DEFAULT
3068# define YYLLOC_DEFAULT(Current, Rhs, N) \
3069 do \
3070 if (N) \
3071 { \
3072 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3073 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3074 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3075 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3076 } \
3077 else \
3078 { \
3079 (Current).first_line = (Current).last_line = \
3080 YYRHSLOC (Rhs, 0).last_line; \
3081 (Current).first_column = (Current).last_column = \
3082 YYRHSLOC (Rhs, 0).last_column; \
3083 } \
3084 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003085#endif
3086
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003087
3088/* YY_LOCATION_PRINT -- Print the location on the stream.
3089 This macro was not mandated originally: define only if we know
3090 we won't break user code: when these are the locations we know. */
3091
3092#ifndef YY_LOCATION_PRINT
3093# if YYLTYPE_IS_TRIVIAL
3094# define YY_LOCATION_PRINT(File, Loc) \
3095 fprintf (File, "%d.%d-%d.%d", \
3096 (Loc).first_line, (Loc).first_column, \
3097 (Loc).last_line, (Loc).last_column)
3098# else
3099# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3100# endif
3101#endif
3102
3103
3104/* YYLEX -- calling `yylex' with the right arguments. */
3105
Reid Spencer950bf602007-01-26 08:19:09 +00003106#ifdef YYLEX_PARAM
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003107# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer950bf602007-01-26 08:19:09 +00003108#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003109# define YYLEX yylex ()
Chris Lattner4227bdb2007-02-19 07:34:02 +00003110#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003111
3112/* Enable debugging if requested. */
3113#if YYDEBUG
3114
3115# ifndef YYFPRINTF
3116# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3117# define YYFPRINTF fprintf
3118# endif
3119
3120# define YYDPRINTF(Args) \
3121do { \
3122 if (yydebug) \
3123 YYFPRINTF Args; \
3124} while (0)
3125
3126# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3127do { \
3128 if (yydebug) \
3129 { \
3130 YYFPRINTF (stderr, "%s ", Title); \
3131 yysymprint (stderr, \
3132 Type, Value); \
3133 YYFPRINTF (stderr, "\n"); \
3134 } \
3135} while (0)
3136
3137/*------------------------------------------------------------------.
3138| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3139| TOP (included). |
3140`------------------------------------------------------------------*/
3141
3142#if defined (__STDC__) || defined (__cplusplus)
3143static void
3144yy_stack_print (short int *bottom, short int *top)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003145#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003146static void
3147yy_stack_print (bottom, top)
3148 short int *bottom;
3149 short int *top;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003150#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003151{
3152 YYFPRINTF (stderr, "Stack now");
3153 for (/* Nothing. */; bottom <= top; ++bottom)
3154 YYFPRINTF (stderr, " %d", *bottom);
3155 YYFPRINTF (stderr, "\n");
3156}
3157
3158# define YY_STACK_PRINT(Bottom, Top) \
3159do { \
3160 if (yydebug) \
3161 yy_stack_print ((Bottom), (Top)); \
3162} while (0)
3163
3164
3165/*------------------------------------------------.
3166| Report that the YYRULE is going to be reduced. |
3167`------------------------------------------------*/
3168
3169#if defined (__STDC__) || defined (__cplusplus)
3170static void
3171yy_reduce_print (int yyrule)
3172#else
3173static void
3174yy_reduce_print (yyrule)
3175 int yyrule;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003176#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003177{
3178 int yyi;
3179 unsigned long int yylno = yyrline[yyrule];
3180 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3181 yyrule - 1, yylno);
3182 /* Print the symbols being reduced, and their result. */
3183 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3184 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3185 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3186}
Reid Spencer9d6565a2007-02-15 02:26:10 +00003187
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003188# define YY_REDUCE_PRINT(Rule) \
3189do { \
3190 if (yydebug) \
3191 yy_reduce_print (Rule); \
3192} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00003193
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003194/* Nonzero means print parse trace. It is left uninitialized so that
3195 multiple parsers can coexist. */
3196int yydebug;
3197#else /* !YYDEBUG */
3198# define YYDPRINTF(Args)
3199# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3200# define YY_STACK_PRINT(Bottom, Top)
3201# define YY_REDUCE_PRINT(Rule)
3202#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00003203
Reid Spencer9d6565a2007-02-15 02:26:10 +00003204
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003205/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003206#ifndef YYINITDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003207# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003208#endif
3209
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003210/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3211 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003212
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003213 Do not make this value too large; the results are undefined if
3214 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3215 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003216
3217#ifndef YYMAXDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003218# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003219#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003220
Reid Spencere7c3c602006-11-30 06:36:44 +00003221
3222
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003223#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003224
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003225# ifndef yystrlen
3226# if defined (__GLIBC__) && defined (_STRING_H)
3227# define yystrlen strlen
3228# else
3229/* Return the length of YYSTR. */
3230static YYSIZE_T
3231# if defined (__STDC__) || defined (__cplusplus)
3232yystrlen (const char *yystr)
3233# else
3234yystrlen (yystr)
3235 const char *yystr;
3236# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003237{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003238 const char *yys = yystr;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003239
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003240 while (*yys++ != '\0')
3241 continue;
3242
3243 return yys - yystr - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003244}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003245# endif
3246# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003247
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003248# ifndef yystpcpy
3249# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3250# define yystpcpy stpcpy
3251# else
3252/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3253 YYDEST. */
3254static char *
3255# if defined (__STDC__) || defined (__cplusplus)
3256yystpcpy (char *yydest, const char *yysrc)
3257# else
3258yystpcpy (yydest, yysrc)
3259 char *yydest;
3260 const char *yysrc;
3261# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003262{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003263 char *yyd = yydest;
3264 const char *yys = yysrc;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003265
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003266 while ((*yyd++ = *yys++) != '\0')
3267 continue;
3268
3269 return yyd - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003270}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003271# endif
3272# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003273
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003274# ifndef yytnamerr
3275/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3276 quotes and backslashes, so that it's suitable for yyerror. The
3277 heuristic is that double-quoting is unnecessary unless the string
3278 contains an apostrophe, a comma, or backslash (other than
3279 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3280 null, do not copy; instead, return the length of what the result
3281 would have been. */
3282static YYSIZE_T
3283yytnamerr (char *yyres, const char *yystr)
3284{
3285 if (*yystr == '"')
3286 {
3287 size_t yyn = 0;
3288 char const *yyp = yystr;
3289
3290 for (;;)
3291 switch (*++yyp)
3292 {
3293 case '\'':
3294 case ',':
3295 goto do_not_strip_quotes;
3296
3297 case '\\':
3298 if (*++yyp != '\\')
3299 goto do_not_strip_quotes;
3300 /* Fall through. */
3301 default:
3302 if (yyres)
3303 yyres[yyn] = *yyp;
3304 yyn++;
3305 break;
3306
3307 case '"':
3308 if (yyres)
3309 yyres[yyn] = '\0';
3310 return yyn;
3311 }
3312 do_not_strip_quotes: ;
3313 }
3314
3315 if (! yyres)
3316 return yystrlen (yystr);
3317
3318 return yystpcpy (yyres, yystr) - yyres;
3319}
3320# endif
3321
3322#endif /* YYERROR_VERBOSE */
3323
Reid Spencer9d6565a2007-02-15 02:26:10 +00003324
3325
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003326#if YYDEBUG
3327/*--------------------------------.
3328| Print this symbol on YYOUTPUT. |
3329`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00003330
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003331#if defined (__STDC__) || defined (__cplusplus)
3332static void
3333yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003334#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003335static void
3336yysymprint (yyoutput, yytype, yyvaluep)
3337 FILE *yyoutput;
3338 int yytype;
3339 YYSTYPE *yyvaluep;
3340#endif
3341{
3342 /* Pacify ``unused variable'' warnings. */
3343 (void) yyvaluep;
3344
3345 if (yytype < YYNTOKENS)
3346 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3347 else
3348 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3349
3350
3351# ifdef YYPRINT
3352 if (yytype < YYNTOKENS)
3353 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3354# endif
3355 switch (yytype)
3356 {
3357 default:
3358 break;
3359 }
3360 YYFPRINTF (yyoutput, ")");
3361}
3362
3363#endif /* ! YYDEBUG */
3364/*-----------------------------------------------.
3365| Release the memory associated to this symbol. |
3366`-----------------------------------------------*/
3367
3368#if defined (__STDC__) || defined (__cplusplus)
3369static void
3370yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3371#else
3372static void
3373yydestruct (yymsg, yytype, yyvaluep)
3374 const char *yymsg;
3375 int yytype;
3376 YYSTYPE *yyvaluep;
3377#endif
3378{
3379 /* Pacify ``unused variable'' warnings. */
3380 (void) yyvaluep;
3381
3382 if (!yymsg)
3383 yymsg = "Deleting";
3384 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3385
3386 switch (yytype)
3387 {
3388
3389 default:
3390 break;
3391 }
3392}
3393
3394
3395/* Prevent warnings from -Wmissing-prototypes. */
3396
3397#ifdef YYPARSE_PARAM
3398# if defined (__STDC__) || defined (__cplusplus)
3399int yyparse (void *YYPARSE_PARAM);
3400# else
3401int yyparse ();
3402# endif
3403#else /* ! YYPARSE_PARAM */
3404#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003405int yyparse (void);
Chris Lattner4227bdb2007-02-19 07:34:02 +00003406#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003407int yyparse ();
3408#endif
3409#endif /* ! YYPARSE_PARAM */
3410
3411
3412
3413/* The look-ahead symbol. */
3414int yychar;
3415
3416/* The semantic value of the look-ahead symbol. */
3417YYSTYPE yylval;
3418
3419/* Number of syntax errors so far. */
3420int yynerrs;
3421
3422
3423
3424/*----------.
3425| yyparse. |
3426`----------*/
3427
3428#ifdef YYPARSE_PARAM
3429# if defined (__STDC__) || defined (__cplusplus)
3430int yyparse (void *YYPARSE_PARAM)
3431# else
3432int yyparse (YYPARSE_PARAM)
3433 void *YYPARSE_PARAM;
3434# endif
3435#else /* ! YYPARSE_PARAM */
3436#if defined (__STDC__) || defined (__cplusplus)
3437int
3438yyparse (void)
3439#else
3440int
3441yyparse ()
3442
3443#endif
3444#endif
3445{
3446
3447 int yystate;
3448 int yyn;
3449 int yyresult;
3450 /* Number of tokens to shift before error messages enabled. */
3451 int yyerrstatus;
3452 /* Look-ahead token as an internal (translated) token number. */
3453 int yytoken = 0;
3454
3455 /* Three stacks and their tools:
3456 `yyss': related to states,
3457 `yyvs': related to semantic values,
3458 `yyls': related to locations.
3459
3460 Refer to the stacks thru separate pointers, to allow yyoverflow
3461 to reallocate them elsewhere. */
3462
3463 /* The state stack. */
3464 short int yyssa[YYINITDEPTH];
3465 short int *yyss = yyssa;
3466 short int *yyssp;
3467
3468 /* The semantic value stack. */
3469 YYSTYPE yyvsa[YYINITDEPTH];
3470 YYSTYPE *yyvs = yyvsa;
3471 YYSTYPE *yyvsp;
3472
3473
3474
Chris Lattnercf3d0612007-02-13 06:04:17 +00003475#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003476
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003477 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003478
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003479 /* The variables used to return semantic value and location from the
3480 action routines. */
3481 YYSTYPE yyval;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003482
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003483
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003484 /* When reducing, the number of symbols on the RHS of the reduced
3485 rule. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003486 int yylen;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003487
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003488 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003489
Reid Spencere7c3c602006-11-30 06:36:44 +00003490 yystate = 0;
3491 yyerrstatus = 0;
3492 yynerrs = 0;
3493 yychar = YYEMPTY; /* Cause a token to be read. */
3494
3495 /* Initialize stack pointers.
3496 Waste one element of value and location stack
3497 so that they stay on the same level as the state stack.
3498 The wasted elements are never initialized. */
3499
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003500 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003501 yyvsp = yyvs;
3502
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003503 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003504
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003505/*------------------------------------------------------------.
3506| yynewstate -- Push a new state, which is found in yystate. |
3507`------------------------------------------------------------*/
3508 yynewstate:
3509 /* In all cases, when you get here, the value and location stacks
3510 have just been pushed. so pushing a state here evens the stacks.
3511 */
3512 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003513
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003514 yysetstate:
3515 *yyssp = yystate;
3516
3517 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003518 {
3519 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003520 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003521
3522#ifdef yyoverflow
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003523 {
3524 /* Give user a chance to reallocate the stack. Use copies of
3525 these so that the &'s don't force the real ones into
3526 memory. */
3527 YYSTYPE *yyvs1 = yyvs;
3528 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003529
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003530
3531 /* Each stack pointer address is followed by the size of the
3532 data in use in that stack, in bytes. This used to be a
3533 conditional around just the two extra args, but that might
3534 be undefined if yyoverflow is a macro. */
3535 yyoverflow (YY_("memory exhausted"),
3536 &yyss1, yysize * sizeof (*yyssp),
3537 &yyvs1, yysize * sizeof (*yyvsp),
3538
3539 &yystacksize);
3540
3541 yyss = yyss1;
3542 yyvs = yyvs1;
3543 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003544#else /* no yyoverflow */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003545# ifndef YYSTACK_RELOCATE
3546 goto yyexhaustedlab;
3547# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003548 /* Extend the stack our own way. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003549 if (YYMAXDEPTH <= yystacksize)
3550 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003551 yystacksize *= 2;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003552 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003553 yystacksize = YYMAXDEPTH;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003554
3555 {
3556 short int *yyss1 = yyss;
3557 union yyalloc *yyptr =
3558 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3559 if (! yyptr)
3560 goto yyexhaustedlab;
3561 YYSTACK_RELOCATE (yyss);
3562 YYSTACK_RELOCATE (yyvs);
3563
3564# undef YYSTACK_RELOCATE
3565 if (yyss1 != yyssa)
3566 YYSTACK_FREE (yyss1);
3567 }
3568# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003569#endif /* no yyoverflow */
3570
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003571 yyssp = yyss + yysize - 1;
3572 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003573
3574
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003575 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3576 (unsigned long int) yystacksize));
3577
3578 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003579 YYABORT;
3580 }
3581
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003582 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003583
3584 goto yybackup;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003585
3586/*-----------.
3587| yybackup. |
3588`-----------*/
3589yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003590
Chris Lattnercf3d0612007-02-13 06:04:17 +00003591/* Do appropriate processing given the current state. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003592/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003593/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003594
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003595 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003596
Reid Spencere7c3c602006-11-30 06:36:44 +00003597 yyn = yypact[yystate];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003598 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003599 goto yydefault;
3600
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003601 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003602
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003603 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003604 if (yychar == YYEMPTY)
3605 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003606 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003607 yychar = YYLEX;
3608 }
3609
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003610 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003611 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003612 yychar = yytoken = YYEOF;
3613 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003614 }
3615 else
3616 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003617 yytoken = YYTRANSLATE (yychar);
3618 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003619 }
3620
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003621 /* If the proper action on seeing token YYTOKEN is to reduce or to
3622 detect an error, take that action. */
3623 yyn += yytoken;
3624 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003625 goto yydefault;
3626 yyn = yytable[yyn];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003627 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003628 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003629 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003630 goto yyerrlab;
3631 yyn = -yyn;
3632 goto yyreduce;
3633 }
3634
3635 if (yyn == YYFINAL)
3636 YYACCEPT;
3637
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003638 /* Shift the look-ahead token. */
3639 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencerb7046c72007-01-29 05:41:34 +00003640
Chris Lattnercf3d0612007-02-13 06:04:17 +00003641 /* Discard the token being shifted unless it is eof. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003642 if (yychar != YYEOF)
3643 yychar = YYEMPTY;
3644
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003645 *++yyvsp = yylval;
3646
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003647
3648 /* Count tokens shifted since error; after three, turn off error
3649 status. */
3650 if (yyerrstatus)
3651 yyerrstatus--;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003652
3653 yystate = yyn;
Reid Spencere7c3c602006-11-30 06:36:44 +00003654 goto yynewstate;
3655
Chris Lattner4227bdb2007-02-19 07:34:02 +00003656
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003657/*-----------------------------------------------------------.
3658| yydefault -- do the default action for the current state. |
3659`-----------------------------------------------------------*/
3660yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003661 yyn = yydefact[yystate];
3662 if (yyn == 0)
3663 goto yyerrlab;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003664 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003665
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003666
3667/*-----------------------------.
3668| yyreduce -- Do a reduction. |
3669`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003670yyreduce:
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003671 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003672 yylen = yyr2[yyn];
3673
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003674 /* If YYLEN is nonzero, implement the default value of the action:
3675 `$$ = $1'.
3676
3677 Otherwise, the following line sets YYVAL to garbage.
3678 This behavior is undocumented and Bison
3679 users should not rely upon it. Assigning to YYVAL
3680 unconditionally makes the parser a bit smaller, and it avoids a
3681 GCC warning that YYVAL may be used uninitialized. */
3682 yyval = yyvsp[1-yylen];
3683
3684
3685 YY_REDUCE_PRINT (yyn);
3686 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003687 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003688 case 3:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003689#line 1595 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003690 {
3691 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003692 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003693 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3694 ;}
3695 break;
3696
3697 case 5:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003698#line 1604 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003699 {
3700 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003701 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003702 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3703 ;}
3704 break;
3705
3706 case 26:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003707#line 1626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003708 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3709 break;
3710
3711 case 27:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003712#line 1626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003713 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3714 break;
3715
3716 case 28:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003717#line 1627 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003718 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3719 break;
3720
3721 case 29:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003722#line 1627 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003723 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3724 break;
3725
3726 case 30:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003727#line 1628 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003728 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3729 break;
3730
3731 case 31:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003732#line 1628 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003733 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3734 break;
3735
3736 case 32:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003737#line 1629 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003738 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3739 break;
3740
3741 case 33:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003742#line 1629 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003743 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3744 break;
3745
3746 case 34:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003747#line 1630 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003748 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3749 break;
3750
3751 case 35:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003752#line 1630 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003753 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3754 break;
3755
3756 case 36:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003757#line 1634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003758 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3759 break;
3760
3761 case 37:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003762#line 1634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003763 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3764 break;
3765
3766 case 38:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003767#line 1635 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003768 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3769 break;
3770
3771 case 39:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003772#line 1635 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003773 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3774 break;
3775
3776 case 40:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003777#line 1636 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003778 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3779 break;
3780
3781 case 41:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003782#line 1636 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003783 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3784 break;
3785
3786 case 42:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003787#line 1637 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003788 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3789 break;
3790
3791 case 43:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003792#line 1637 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003793 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3794 break;
3795
3796 case 44:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003797#line 1638 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003798 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3799 break;
3800
3801 case 45:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003802#line 1638 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003803 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3804 break;
3805
3806 case 46:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003807#line 1639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003808 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3809 break;
3810
3811 case 47:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003812#line 1639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003813 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3814 break;
3815
3816 case 48:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003817#line 1640 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003818 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3819 break;
3820
3821 case 49:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003822#line 1640 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003823 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3824 break;
3825
3826 case 50:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003827#line 1641 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003828 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3829 break;
3830
3831 case 51:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003832#line 1642 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003833 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3834 break;
3835
3836 case 81:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003837#line 1673 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003838 {
3839 (yyval.StrVal) = (yyvsp[-1].StrVal);
3840 ;}
3841 break;
3842
3843 case 82:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003844#line 1676 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003845 {
3846 (yyval.StrVal) = 0;
3847 ;}
3848 break;
3849
3850 case 83:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003851#line 1681 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003852 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3853 break;
3854
3855 case 84:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003856#line 1682 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003857 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3858 break;
3859
3860 case 85:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003861#line 1683 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003862 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3863 break;
3864
3865 case 86:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003866#line 1684 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003867 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3868 break;
3869
3870 case 87:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003871#line 1685 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003872 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3873 break;
3874
3875 case 88:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003876#line 1686 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003877 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3878 break;
3879
3880 case 89:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003881#line 1687 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003882 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3883 break;
3884
3885 case 90:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003886#line 1688 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003887 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3888 break;
3889
3890 case 91:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003891#line 1692 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003892 { (yyval.UIntVal) = OldCallingConv::C; ;}
3893 break;
3894
3895 case 92:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003896#line 1693 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003897 { (yyval.UIntVal) = OldCallingConv::C; ;}
3898 break;
3899
3900 case 93:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003901#line 1694 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003902 { (yyval.UIntVal) = OldCallingConv::CSRet; ;}
3903 break;
3904
3905 case 94:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003906#line 1695 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003907 { (yyval.UIntVal) = OldCallingConv::Fast; ;}
3908 break;
3909
3910 case 95:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003911#line 1696 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003912 { (yyval.UIntVal) = OldCallingConv::Cold; ;}
3913 break;
3914
3915 case 96:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003916#line 1697 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003917 { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
3918 break;
3919
3920 case 97:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003921#line 1698 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003922 { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
3923 break;
3924
3925 case 98:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003926#line 1699 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003927 {
3928 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00003929 error("Calling conv too large");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003930 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3931 ;}
3932 break;
3933
3934 case 99:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003935#line 1709 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003936 { (yyval.UIntVal) = 0; ;}
3937 break;
3938
3939 case 100:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003940#line 1710 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003941 {
3942 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3943 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00003944 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003945 ;}
3946 break;
3947
3948 case 101:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003949#line 1718 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003950 { (yyval.UIntVal) = 0; ;}
3951 break;
3952
3953 case 102:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003954#line 1719 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003955 {
3956 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3957 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00003958 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003959 ;}
3960 break;
3961
3962 case 103:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003963#line 1727 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003964 {
3965 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3966 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00003967 error("Invalid character in section name");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003968 (yyval.StrVal) = (yyvsp[0].StrVal);
3969 ;}
3970 break;
3971
3972 case 104:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003973#line 1736 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003974 { (yyval.StrVal) = 0; ;}
3975 break;
3976
3977 case 105:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003978#line 1737 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003979 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3980 break;
3981
3982 case 106:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003983#line 1744 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003984 {;}
3985 break;
3986
3987 case 107:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003988#line 1745 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003989 {;}
3990 break;
3991
3992 case 108:
Reid Spencer5eb77c72007-03-15 03:26:42 +00003993#line 1749 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003994 {
3995 CurGV->setSection((yyvsp[0].StrVal));
3996 free((yyvsp[0].StrVal));
3997 ;}
3998 break;
3999
4000 case 109:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004001#line 1753 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004002 {
4003 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004004 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004005 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004006
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004007 ;}
4008 break;
4009
4010 case 111:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004011#line 1770 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004012 {
4013 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
4014 (yyval.TypeVal).S = Signless;
4015 ;}
4016 break;
4017
4018 case 113:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004019#line 1778 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004020 {
4021 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
4022 (yyval.TypeVal).S = Signless;
4023 ;}
4024 break;
4025
4026 case 114:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004027#line 1785 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004028 {
Reid Spencer950bf602007-01-26 08:19:09 +00004029 if (!UpRefs.empty())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004030 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription());
4031 (yyval.TypeVal) = (yyvsp[0].TypeVal);
4032 ;}
4033 break;
4034
4035 case 127:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004036#line 1799 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004037 {
4038 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
4039 (yyval.TypeVal).S = (yyvsp[0].PrimType).S;
4040 ;}
4041 break;
4042
4043 case 128:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004044#line 1803 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004045 {
4046 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
4047 (yyval.TypeVal).S = Signless;
4048 ;}
4049 break;
4050
4051 case 129:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004052#line 1807 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004053 { // Named types are also simple types...
4054 const Type* tmp = getType((yyvsp[0].ValIDVal));
4055 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
Reid Spencer5eb77c72007-03-15 03:26:42 +00004056 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004057 ;}
4058 break;
4059
4060 case 130:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004061#line 1812 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004062 { // Type UpReference
4063 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004064 error("Value out of range");
4065 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004066 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
4067 (yyval.TypeVal).PAT = new PATypeHolder(OT);
4068 (yyval.TypeVal).S = Signless;
Reid Spencer950bf602007-01-26 08:19:09 +00004069 UR_OUT("New Upreference!\n");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004070 ;}
4071 break;
4072
4073 case 131:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004074#line 1821 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004075 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004076 std::vector<const Type*> Params;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004077 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4078 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004079 Params.push_back(I->PAT->get());
Reid Spencer52402b02007-01-02 05:45:11 +00004080 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004081 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00004082 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4083 if (isVarArg) Params.pop_back();
4084
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004085 (yyval.TypeVal).PAT = new PATypeHolder(
4086 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg,
Reid Spencered96d1e2007-02-08 09:08:52 +00004087 ParamAttrs)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004088 (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S;
4089 delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle
4090 delete (yyvsp[-1].TypeList); // Delete the argument list
4091 ;}
4092 break;
4093
4094 case 132:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004095#line 1838 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004096 { // Sized array type?
4097 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(),
4098 (unsigned)(yyvsp[-3].UInt64Val))));
4099 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4100 delete (yyvsp[-1].TypeVal).PAT;
4101 ;}
4102 break;
4103
4104 case 133:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004105#line 1844 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004106 { // Vector type?
4107 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get();
4108 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004109 error("Unsigned result not equal to signed result");
4110 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
Reid Spencer9d6565a2007-02-15 02:26:10 +00004111 error("Elements of a VectorType must be integer or floating point");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004112 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer9d6565a2007-02-15 02:26:10 +00004113 error("VectorType length should be a power of 2");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004114 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4115 (unsigned)(yyvsp[-3].UInt64Val))));
4116 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4117 delete (yyvsp[-1].TypeVal).PAT;
4118 ;}
4119 break;
4120
4121 case 134:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004122#line 1857 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004123 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004124 std::vector<const Type*> Elements;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004125 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4126 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencered96d1e2007-02-08 09:08:52 +00004127 Elements.push_back(I->PAT->get());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004128 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4129 (yyval.TypeVal).S = Signless;
4130 delete (yyvsp[-1].TypeList);
4131 ;}
4132 break;
4133
4134 case 135:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004135#line 1866 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004136 { // Empty structure type?
4137 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4138 (yyval.TypeVal).S = Signless;
4139 ;}
4140 break;
4141
4142 case 136:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004143#line 1870 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004144 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004145 std::vector<const Type*> Elements;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004146 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4147 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004148 Elements.push_back(I->PAT->get());
4149 delete I->PAT;
Reid Spencer52402b02007-01-02 05:45:11 +00004150 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004151 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4152 (yyval.TypeVal).S = Signless;
4153 delete (yyvsp[-2].TypeList);
4154 ;}
4155 break;
4156
4157 case 137:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004158#line 1881 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004159 { // Empty packed structure type?
4160 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4161 (yyval.TypeVal).S = Signless;
4162 ;}
4163 break;
4164
4165 case 138:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004166#line 1885 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004167 { // Pointer type?
4168 if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004169 error("Cannot form a pointer to a basic block");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004170 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get())));
4171 (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S;
4172 delete (yyvsp[-1].TypeVal).PAT;
4173 ;}
4174 break;
4175
4176 case 139:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004177#line 1898 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004178 {
4179 (yyval.TypeList) = new std::list<PATypeInfo>();
4180 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4181 ;}
4182 break;
4183
4184 case 140:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004185#line 1902 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004186 {
4187 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4188 ;}
4189 break;
4190
4191 case 142:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004192#line 1910 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004193 {
Reid Spencer950bf602007-01-26 08:19:09 +00004194 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004195 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencer950bf602007-01-26 08:19:09 +00004196 VoidTI.S = Signless;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004197 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4198 ;}
4199 break;
4200
4201 case 143:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004202#line 1916 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004203 {
4204 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencer950bf602007-01-26 08:19:09 +00004205 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004206 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencer950bf602007-01-26 08:19:09 +00004207 VoidTI.S = Signless;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004208 (yyval.TypeList)->push_back(VoidTI);
4209 ;}
4210 break;
4211
4212 case 144:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004213#line 1923 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004214 {
4215 (yyval.TypeList) = new std::list<PATypeInfo>();
4216 ;}
4217 break;
4218
4219 case 145:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004220#line 1935 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004221 { // Nonempty unsized arr
4222 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004223 if (ATy == 0)
4224 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004225 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004226 const Type *ETy = ATy->getElementType();
4227 int NumElements = ATy->getNumElements();
4228
4229 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004230 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004231 error("Type mismatch: constant sized array initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004232 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004233 itostr(NumElements) + "");
4234
4235 // Verify all elements are correct type!
4236 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004237 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4238 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004239 const Type* ValTy = C->getType();
4240 if (ETy != ValTy)
4241 error("Element #" + utostr(i) + " is not of type '" +
4242 ETy->getDescription() +"' as required!\nIt is of type '"+
4243 ValTy->getDescription() + "'");
4244 Elems.push_back(C);
4245 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004246 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4247 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4248 delete (yyvsp[-3].TypeVal).PAT;
4249 delete (yyvsp[-1].ConstVector);
4250 ;}
4251 break;
4252
4253 case 146:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004254#line 1965 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004255 {
4256 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004257 if (ATy == 0)
4258 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004259 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004260 int NumElements = ATy->getNumElements();
4261 if (NumElements != -1 && NumElements != 0)
4262 error("Type mismatch: constant sized array initialized with 0"
4263 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004264 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4265 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4266 delete (yyvsp[-2].TypeVal).PAT;
4267 ;}
4268 break;
4269
4270 case 147:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004271#line 1978 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004272 {
4273 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004274 if (ATy == 0)
4275 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004276 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004277 int NumElements = ATy->getNumElements();
4278 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4279 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4280 error("String arrays require type i8, not '" + ETy->getDescription() +
4281 "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004282 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4283 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004284 error("Can't build string constant of size " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004285 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004286 itostr(NumElements) + "");
4287 std::vector<Constant*> Vals;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004288 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004289 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004290 free((yyvsp[0].StrVal));
4291 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4292 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4293 delete (yyvsp[-2].TypeVal).PAT;
4294 ;}
4295 break;
4296
4297 case 148:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004298#line 2001 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004299 { // Nonempty unsized arr
4300 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004301 if (PTy == 0)
4302 error("Cannot make packed constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004303 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004304 const Type *ETy = PTy->getElementType();
4305 int NumElements = PTy->getNumElements();
4306 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004307 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004308 error("Type mismatch: constant sized packed initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004309 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004310 itostr(NumElements) + "");
4311 // Verify all elements are correct type!
4312 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004313 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4314 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004315 const Type* ValTy = C->getType();
4316 if (ETy != ValTy)
4317 error("Element #" + utostr(i) + " is not of type '" +
4318 ETy->getDescription() +"' as required!\nIt is of type '"+
4319 ValTy->getDescription() + "'");
4320 Elems.push_back(C);
4321 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004322 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
4323 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4324 delete (yyvsp[-3].TypeVal).PAT;
4325 delete (yyvsp[-1].ConstVector);
4326 ;}
4327 break;
4328
4329 case 149:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004330#line 2029 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004331 {
4332 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004333 if (STy == 0)
4334 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004335 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
4336 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004337 error("Illegal number of initializers for structure type");
4338
4339 // Check to ensure that constants are compatible with the type initializer!
4340 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004341 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4342 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004343 if (C->getType() != STy->getElementType(i))
4344 error("Expected type '" + STy->getElementType(i)->getDescription() +
4345 "' for element #" + utostr(i) + " of structure initializer");
4346 Fields.push_back(C);
4347 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004348 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4349 (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S;
4350 delete (yyvsp[-3].TypeVal).PAT;
4351 delete (yyvsp[-1].ConstVector);
4352 ;}
4353 break;
4354
4355 case 150:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004356#line 2051 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004357 {
4358 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004359 if (STy == 0)
4360 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004361 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004362 if (STy->getNumContainedTypes() != 0)
4363 error("Illegal number of initializers for structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004364 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4365 (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S;
4366 delete (yyvsp[-2].TypeVal).PAT;
4367 ;}
4368 break;
4369
4370 case 151:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004371#line 2062 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004372 {
4373 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004374 if (STy == 0)
4375 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004376 (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'");
4377 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004378 error("Illegal number of initializers for packed structure type");
4379
4380 // Check to ensure that constants are compatible with the type initializer!
4381 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004382 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4383 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004384 if (C->getType() != STy->getElementType(i))
4385 error("Expected type '" + STy->getElementType(i)->getDescription() +
4386 "' for element #" + utostr(i) + " of packed struct initializer");
4387 Fields.push_back(C);
4388 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004389 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4390 (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S;
4391 delete (yyvsp[-5].TypeVal).PAT;
4392 delete (yyvsp[-2].ConstVector);
4393 ;}
4394 break;
4395
4396 case 152:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004397#line 2084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004398 {
4399 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004400 if (STy == 0)
4401 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004402 (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004403 if (STy->getNumContainedTypes() != 0)
4404 error("Illegal number of initializers for packed structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004405 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4406 (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S;
4407 delete (yyvsp[-4].TypeVal).PAT;
4408 ;}
4409 break;
4410
4411 case 153:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004412#line 2095 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004413 {
4414 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004415 if (PTy == 0)
4416 error("Cannot make null pointer constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004417 (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'");
4418 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4419 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4420 delete (yyvsp[-1].TypeVal).PAT;
4421 ;}
4422 break;
4423
4424 case 154:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004425#line 2104 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004426 {
4427 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get());
4428 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4429 delete (yyvsp[-1].TypeVal).PAT;
4430 ;}
4431 break;
4432
4433 case 155:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004434#line 2109 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004435 {
4436 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004437 if (Ty == 0)
4438 error("Global const reference must be a pointer type, not" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004439 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004440
4441 // ConstExprs can exist in the body of a function, thus creating
4442 // GlobalValues whenever they refer to a variable. Because we are in
4443 // the context of a function, getExistingValue will search the functions
4444 // symbol table instead of the module symbol table for the global symbol,
4445 // which throws things all off. To get around this, we just tell
4446 // getExistingValue that we are at global scope here.
4447 //
4448 Function *SavedCurFn = CurFun.CurrentFunction;
4449 CurFun.CurrentFunction = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004450 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004451 CurFun.CurrentFunction = SavedCurFn;
4452
4453 // If this is an initializer for a constant pointer, which is referencing a
4454 // (currently) undefined variable, create a stub now that shall be replaced
4455 // in the future with the right type of variable.
4456 //
4457 if (V == 0) {
4458 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4459 const PointerType *PT = cast<PointerType>(Ty);
4460
4461 // First check to see if the forward references value is already created!
4462 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004463 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004464
4465 if (I != CurModule.GlobalRefs.end()) {
4466 V = I->second; // Placeholder already exists, use it...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004467 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004468 } else {
4469 std::string Name;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004470 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004471
4472 // Create the forward referenced global.
4473 GlobalValue *GV;
4474 if (const FunctionType *FTy =
4475 dyn_cast<FunctionType>(PT->getElementType())) {
4476 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4477 CurModule.CurrentModule);
4478 } else {
4479 GV = new GlobalVariable(PT->getElementType(), false,
4480 GlobalValue::ExternalLinkage, 0,
4481 Name, CurModule.CurrentModule);
4482 }
4483
4484 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004485 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004486 V = GV;
4487 }
4488 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004489 (yyval.ConstVal).C = cast<GlobalValue>(V);
4490 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4491 delete (yyvsp[-1].TypeVal).PAT; // Free the type handle
4492 ;}
4493 break;
4494
4495 case 156:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004496#line 2167 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004497 {
4498 if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004499 error("Mismatched types for constant expression");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004500 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4501 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4502 delete (yyvsp[-1].TypeVal).PAT;
4503 ;}
4504 break;
4505
4506 case 157:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004507#line 2174 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004508 {
4509 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004510 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4511 error("Cannot create a null initialized value of this type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004512 (yyval.ConstVal).C = Constant::getNullValue(Ty);
4513 (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S;
4514 delete (yyvsp[-1].TypeVal).PAT;
4515 ;}
4516 break;
4517
4518 case 158:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004519#line 2182 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004520 { // integral constants
4521 const Type *Ty = (yyvsp[-1].PrimType).T;
4522 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004523 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004524 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
4525 (yyval.ConstVal).S = Signed;
4526 ;}
4527 break;
4528
4529 case 159:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004530#line 2189 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004531 { // integral constants
4532 const Type *Ty = (yyvsp[-1].PrimType).T;
4533 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004534 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004535 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
4536 (yyval.ConstVal).S = Unsigned;
4537 ;}
4538 break;
4539
4540 case 160:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004541#line 2196 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004542 { // Boolean constants
4543 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4544 (yyval.ConstVal).S = Unsigned;
4545 ;}
4546 break;
4547
4548 case 161:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004549#line 2200 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004550 { // Boolean constants
4551 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4552 (yyval.ConstVal).S = Unsigned;
4553 ;}
4554 break;
4555
4556 case 162:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004557#line 2204 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004558 { // Float & Double constants
4559 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004560 error("Floating point constant invalid for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004561 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
4562 (yyval.ConstVal).S = Signless;
4563 ;}
4564 break;
4565
4566 case 163:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004567#line 2213 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004568 {
4569 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4570 const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get();
4571 Signedness SrcSign = (yyvsp[-3].ConstVal).S;
4572 Signedness DstSign = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004573 if (!SrcTy->isFirstClassType())
4574 error("cast constant expression from a non-primitive type: '" +
4575 SrcTy->getDescription() + "'");
4576 if (!DstTy->isFirstClassType())
4577 error("cast constant expression to a non-primitive type: '" +
4578 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004579 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
4580 (yyval.ConstVal).S = DstSign;
4581 delete (yyvsp[-1].TypeVal).PAT;
4582 ;}
4583 break;
4584
4585 case 164:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004586#line 2228 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004587 {
4588 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004589 if (!isa<PointerType>(Ty))
4590 error("GetElementPtr requires a pointer operand");
4591
4592 std::vector<Value*> VIndices;
4593 std::vector<Constant*> CIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004594 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004595
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004596 delete (yyvsp[-1].ValueList);
4597 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, &CIndices[0], CIndices.size());
4598 (yyval.ConstVal).S = Signless;
4599 ;}
4600 break;
4601
4602 case 165:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004603#line 2241 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004604 {
4605 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4606 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004607 error("Select condition must be bool type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004608 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004609 error("Select operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004610 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4611 (yyval.ConstVal).S = Unsigned;
4612 ;}
4613 break;
4614
4615 case 166:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004616#line 2250 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004617 {
4618 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4619 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004620 error("Binary operator types must match");
4621 // First, make sure we're dealing with the right opcode by upgrading from
4622 // obsolete versions.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004623 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004624
4625 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4626 // To retain backward compatibility with these early compilers, we emit a
4627 // cast to the appropriate integer type automatically if we are in the
4628 // broken case. See PR424 for more information.
4629 if (!isa<PointerType>(Ty)) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004630 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004631 } else {
4632 const Type *IntPtrTy = 0;
4633 switch (CurModule.CurrentModule->getPointerSize()) {
4634 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4635 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4636 default: error("invalid pointer binary constant expr");
4637 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004638 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4639 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4640 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4641 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004642 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004643 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4644 ;}
4645 break;
4646
4647 case 167:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004648#line 2278 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004649 {
4650 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4651 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004652 error("Logical operator types must match");
4653 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00004654 if (!isa<VectorType>(Ty) ||
4655 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004656 error("Logical operator requires integer operands");
4657 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004658 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4659 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4660 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4661 ;}
4662 break;
4663
4664 case 168:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004665#line 2291 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004666 {
4667 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4668 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004669 error("setcc operand types must match");
4670 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004671 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4672 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4673 (yyval.ConstVal).S = Unsigned;
4674 ;}
4675 break;
4676
4677 case 169:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004678#line 2300 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004679 {
4680 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004681 error("icmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004682 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4683 (yyval.ConstVal).S = Unsigned;
4684 ;}
4685 break;
4686
4687 case 170:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004688#line 2306 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004689 {
4690 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004691 error("fcmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004692 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4693 (yyval.ConstVal).S = Unsigned;
4694 ;}
4695 break;
4696
4697 case 171:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004698#line 2312 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004699 {
4700 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4701 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004702 error("Shift count for shift constant must be unsigned byte");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004703 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4704 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004705 error("Shift constant expression requires integer operand");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004706 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4707 (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, ShiftAmt);
4708 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4709 ;}
4710 break;
4711
4712 case 172:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004713#line 2323 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004714 {
4715 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004716 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004717 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4718 (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S;
4719 ;}
4720 break;
4721
4722 case 173:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004723#line 2329 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004724 {
4725 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004726 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004727 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4728 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4729 ;}
4730 break;
4731
4732 case 174:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004733#line 2335 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004734 {
4735 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004736 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004737 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
4738 (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S;
4739 ;}
4740 break;
4741
4742 case 175:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004743#line 2346 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004744 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
4745 break;
4746
4747 case 176:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004748#line 2347 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004749 {
4750 (yyval.ConstVector) = new std::vector<ConstInfo>();
4751 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4752 ;}
4753 break;
4754
4755 case 177:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004756#line 2356 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004757 { (yyval.BoolVal) = false; ;}
4758 break;
4759
4760 case 178:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004761#line 2357 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004762 { (yyval.BoolVal) = true; ;}
4763 break;
4764
4765 case 179:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004766#line 2369 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004767 {
4768 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004769 CurModule.ModuleDone();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004770 ;}
4771 break;
4772
4773 case 180:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004774#line 2378 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004775 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
4776 break;
4777
4778 case 181:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004779#line 2379 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004780 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
4781 break;
4782
4783 case 182:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004784#line 2380 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004785 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
4786 break;
4787
4788 case 183:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004789#line 2381 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004790 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
4791 break;
4792
4793 case 184:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004794#line 2382 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004795 {
4796 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer950bf602007-01-26 08:19:09 +00004797 // Emit an error if there are any unresolved types left.
4798 if (!CurModule.LateResolveTypes.empty()) {
4799 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4800 if (DID.Type == ValID::NameVal) {
4801 error("Reference to an undefined type: '"+DID.getName() + "'");
4802 } else {
4803 error("Reference to an undefined type: #" + itostr(DID.Num));
4804 }
4805 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004806 ;}
4807 break;
4808
4809 case 185:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004810#line 2398 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004811 {
Reid Spencer950bf602007-01-26 08:19:09 +00004812 // Eagerly resolve types. This is not an optimization, this is a
4813 // requirement that is due to the fact that we could have this:
4814 //
4815 // %list = type { %list * }
4816 // %list = type { %list * } ; repeated type decl
4817 //
4818 // If types are not resolved eagerly, then the two types will not be
4819 // determined to be the same type!
4820 //
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004821 const Type* Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer5eb77c72007-03-15 03:26:42 +00004822 ResolveTypeTo((yyvsp[-2].StrVal), Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004823
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004824 if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer950bf602007-01-26 08:19:09 +00004825 // If this is a named type that is not a redefinition, add it to the slot
4826 // table.
4827 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004828 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004829 delete (yyvsp[0].TypeVal).PAT;
4830 ;}
4831 break;
4832
4833 case 186:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004834#line 2418 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004835 { // Function prototypes can be in const pool
4836 ;}
4837 break;
4838
4839 case 187:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004840#line 2420 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004841 { // Asm blocks can be in the const pool
4842 ;}
4843 break;
4844
4845 case 188:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004846#line 2422 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004847 {
4848 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00004849 error("Global value initializer is not a constant");
Reid Spencer5eb77c72007-03-15 03:26:42 +00004850 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004851 ;}
4852 break;
4853
4854 case 189:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004855#line 2426 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004856 {
Reid Spencer950bf602007-01-26 08:19:09 +00004857 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004858 ;}
4859 break;
4860
4861 case 190:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004862#line 2429 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004863 {
4864 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer5eb77c72007-03-15 03:26:42 +00004865 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004866 delete (yyvsp[0].TypeVal).PAT;
4867 ;}
4868 break;
4869
4870 case 191:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004871#line 2433 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004872 {
Reid Spencer950bf602007-01-26 08:19:09 +00004873 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004874 ;}
4875 break;
4876
4877 case 192:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004878#line 2436 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004879 {
4880 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer5eb77c72007-03-15 03:26:42 +00004881 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004882 delete (yyvsp[0].TypeVal).PAT;
4883 ;}
4884 break;
4885
4886 case 193:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004887#line 2440 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004888 {
Reid Spencer950bf602007-01-26 08:19:09 +00004889 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004890 ;}
4891 break;
4892
4893 case 194:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004894#line 2443 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004895 {
4896 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004897 CurGV =
Reid Spencer5eb77c72007-03-15 03:26:42 +00004898 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004899 delete (yyvsp[0].TypeVal).PAT;
4900 ;}
4901 break;
4902
4903 case 195:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004904#line 2448 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004905 {
Reid Spencer950bf602007-01-26 08:19:09 +00004906 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004907 ;}
4908 break;
4909
4910 case 196:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004911#line 2451 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004912 {
4913 ;}
4914 break;
4915
4916 case 197:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004917#line 2453 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004918 {
4919 ;}
4920 break;
4921
4922 case 198:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004923#line 2455 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004924 {
4925 ;}
4926 break;
4927
4928 case 199:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004929#line 2460 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004930 {
Reid Spencer950bf602007-01-26 08:19:09 +00004931 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004932 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4933 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4934 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004935
4936 if (AsmSoFar.empty())
4937 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4938 else
4939 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004940 ;}
4941 break;
4942
4943 case 200:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004944#line 2474 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004945 { (yyval.Endianness) = Module::BigEndian; ;}
4946 break;
4947
4948 case 201:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004949#line 2475 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004950 { (yyval.Endianness) = Module::LittleEndian; ;}
4951 break;
4952
4953 case 202:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004954#line 2479 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004955 {
4956 CurModule.setEndianness((yyvsp[0].Endianness));
4957 ;}
4958 break;
4959
4960 case 203:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004961#line 2482 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004962 {
4963 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00004964 CurModule.setPointerSize(Module::Pointer32);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004965 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00004966 CurModule.setPointerSize(Module::Pointer64);
4967 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004968 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
4969 ;}
4970 break;
Reid Spencer9d6565a2007-02-15 02:26:10 +00004971
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004972 case 204:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004973#line 2490 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004974 {
4975 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4976 free((yyvsp[0].StrVal));
4977 ;}
4978 break;
4979
4980 case 205:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004981#line 2494 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004982 {
4983 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4984 free((yyvsp[0].StrVal));
4985 ;}
4986 break;
4987
4988 case 207:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004989#line 2505 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004990 {
4991 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4992 free((yyvsp[0].StrVal));
4993 ;}
4994 break;
4995
4996 case 208:
Reid Spencer5eb77c72007-03-15 03:26:42 +00004997#line 2509 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004998 {
4999 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5000 free((yyvsp[0].StrVal));
5001 ;}
5002 break;
5003
5004 case 209:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005005#line 2513 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005006 { ;}
5007 break;
5008
5009 case 213:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005010#line 2526 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005011 { (yyval.StrVal) = 0; ;}
5012 break;
5013
5014 case 214:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005015#line 2530 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005016 {
5017 if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy)
5018 error("void typed arguments are invalid");
5019 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
5020 ;}
5021 break;
5022
5023 case 215:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005024#line 2538 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005025 {
5026 (yyval.ArgList) = (yyvsp[-2].ArgList);
5027 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5028 delete (yyvsp[0].ArgVal);
5029 ;}
5030 break;
5031
5032 case 216:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005033#line 2543 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005034 {
5035 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5036 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5037 delete (yyvsp[0].ArgVal);
5038 ;}
5039 break;
5040
5041 case 217:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005042#line 2551 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005043 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
5044 break;
5045
5046 case 218:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005047#line 2552 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005048 {
5049 (yyval.ArgList) = (yyvsp[-2].ArgList);
5050 PATypeInfo VoidTI;
5051 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
5052 VoidTI.S = Signless;
5053 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5054 ;}
5055 break;
5056
5057 case 219:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005058#line 2559 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005059 {
5060 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5061 PATypeInfo VoidTI;
5062 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
5063 VoidTI.S = Signless;
5064 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5065 ;}
5066 break;
5067
5068 case 220:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005069#line 2566 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005070 { (yyval.ArgList) = 0; ;}
5071 break;
5072
5073 case 221:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005074#line 2570 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005075 {
5076 UnEscapeLexed((yyvsp[-5].StrVal));
5077 std::string FunctionName((yyvsp[-5].StrVal));
5078 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
5079
5080 const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005081
5082 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5083 error("LLVM functions cannot return aggregate types");
5084
Reid Spenceref9b9a72007-02-05 20:47:22 +00005085 std::vector<const Type*> ParamTyList;
Reid Spencer950bf602007-01-26 08:19:09 +00005086
5087 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5088 // i8*. We check here for those names and override the parameter list
5089 // types to ensure the prototype is correct.
5090 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005091 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00005092 } else if (FunctionName == "llvm.va_copy") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005093 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5094 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005095 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005096 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005097 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005098 const Type *Ty = I->first.PAT->get();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005099 ParamTyList.push_back(Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00005100 }
5101 }
5102
Reid Spenceref9b9a72007-02-05 20:47:22 +00005103 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5104 if (isVarArg)
5105 ParamTyList.pop_back();
Reid Spencer950bf602007-01-26 08:19:09 +00005106
Reid Spencerb7046c72007-01-29 05:41:34 +00005107 // Convert the CSRet calling convention into the corresponding parameter
5108 // attribute.
5109 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005110 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00005111 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5112 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5113 }
5114
Reid Spenceref9b9a72007-02-05 20:47:22 +00005115 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
Reid Spencerb7046c72007-01-29 05:41:34 +00005116 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005117 const PointerType *PFT = PointerType::get(FT);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005118 delete (yyvsp[-6].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005119
5120 ValID ID;
5121 if (!FunctionName.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005122 ID = ValID::create((char*)FunctionName.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00005123 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005124 ID = ValID::create((int)CurModule.Values[PFT].size());
Reid Spencer950bf602007-01-26 08:19:09 +00005125 }
5126
5127 Function *Fn = 0;
Reid Spencered96d1e2007-02-08 09:08:52 +00005128 Module* M = CurModule.CurrentModule;
5129
Reid Spencer950bf602007-01-26 08:19:09 +00005130 // See if this function was forward referenced. If so, recycle the object.
5131 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5132 // Move the function to the end of the list, from whereever it was
5133 // previously inserted.
5134 Fn = cast<Function>(FWRef);
Reid Spencered96d1e2007-02-08 09:08:52 +00005135 M->getFunctionList().remove(Fn);
5136 M->getFunctionList().push_back(Fn);
5137 } else if (!FunctionName.empty()) {
5138 GlobalValue *Conflict = M->getFunction(FunctionName);
5139 if (!Conflict)
5140 Conflict = M->getNamedGlobal(FunctionName);
5141 if (Conflict && PFT == Conflict->getType()) {
5142 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5143 // We have two function definitions that conflict, same type, same
5144 // name. We should really check to make sure that this is the result
5145 // of integer type planes collapsing and generate an error if it is
5146 // not, but we'll just rename on the assumption that it is. However,
5147 // let's do it intelligently and rename the internal linkage one
5148 // if there is one.
5149 std::string NewName(makeNameUnique(FunctionName));
5150 if (Conflict->hasInternalLinkage()) {
5151 Conflict->setName(NewName);
Reid Spencer5eb77c72007-03-15 03:26:42 +00005152 RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
Reid Spencered96d1e2007-02-08 09:08:52 +00005153 CurModule.RenameMap[Key] = NewName;
5154 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5155 InsertValue(Fn, CurModule.Values);
5156 } else {
5157 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5158 InsertValue(Fn, CurModule.Values);
Reid Spencer5eb77c72007-03-15 03:26:42 +00005159 RenameMapKey Key = std::make_pair(FunctionName,PFT);
Reid Spencered96d1e2007-02-08 09:08:52 +00005160 CurModule.RenameMap[Key] = NewName;
5161 }
5162 } else {
5163 // If they are not both definitions, then just use the function we
5164 // found since the types are the same.
5165 Fn = cast<Function>(Conflict);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005166
Reid Spencered96d1e2007-02-08 09:08:52 +00005167 // Make sure to strip off any argument names so we can't get
5168 // conflicts.
5169 if (Fn->isDeclaration())
5170 for (Function::arg_iterator AI = Fn->arg_begin(),
5171 AE = Fn->arg_end(); AI != AE; ++AI)
5172 AI->setName("");
5173 }
5174 } else if (Conflict) {
5175 // We have two globals with the same name and different types.
5176 // Previously, this was permitted because the symbol table had
5177 // "type planes" and names only needed to be distinct within a
5178 // type plane. After PR411 was fixed, this is no loner the case.
5179 // To resolve this we must rename one of the two.
5180 if (Conflict->hasInternalLinkage()) {
5181 // We can safely renamed the Conflict.
5182 Conflict->setName(makeNameUnique(Conflict->getName()));
Reid Spencer5eb77c72007-03-15 03:26:42 +00005183 RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
Reid Spencered96d1e2007-02-08 09:08:52 +00005184 CurModule.RenameMap[Key] = Conflict->getName();
5185 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5186 InsertValue(Fn, CurModule.Values);
5187 } else if (CurFun.Linkage == GlobalValue::InternalLinkage) {
5188 // We can safely rename the function we're defining
5189 std::string NewName = makeNameUnique(FunctionName);
5190 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5191 InsertValue(Fn, CurModule.Values);
Reid Spencer5eb77c72007-03-15 03:26:42 +00005192 RenameMapKey Key = std::make_pair(FunctionName,PFT);
Reid Spencered96d1e2007-02-08 09:08:52 +00005193 CurModule.RenameMap[Key] = NewName;
5194 } else {
5195 // We can't quietly rename either of these things, but we must
5196 // rename one of them. Generate a warning about the renaming and
5197 // elect to rename the thing we're now defining.
5198 std::string NewName = makeNameUnique(FunctionName);
5199 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5200 "' may cause linkage errors");
5201 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5202 InsertValue(Fn, CurModule.Values);
Reid Spencer5eb77c72007-03-15 03:26:42 +00005203 RenameMapKey Key = std::make_pair(FunctionName,PFT);
Reid Spencered96d1e2007-02-08 09:08:52 +00005204 CurModule.RenameMap[Key] = NewName;
5205 }
Reid Spenceref9b9a72007-02-05 20:47:22 +00005206 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005207 // There's no conflict, just define the function
5208 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5209 InsertValue(Fn, CurModule.Values);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005210 }
Reid Spencer950bf602007-01-26 08:19:09 +00005211 }
5212
5213 CurFun.FunctionStart(Fn);
5214
5215 if (CurFun.isDeclare) {
5216 // If we have declaration, always overwrite linkage. This will allow us
5217 // to correctly handle cases, when pointer to function is passed as
5218 // argument to another function.
5219 Fn->setLinkage(CurFun.Linkage);
5220 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005221 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5222 Fn->setAlignment((yyvsp[0].UIntVal));
5223 if ((yyvsp[-1].StrVal)) {
5224 Fn->setSection((yyvsp[-1].StrVal));
5225 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005226 }
5227
5228 // Add all of the arguments we parsed to the function...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005229 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005230 if (isVarArg) { // Nuke the last entry
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005231 assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5232 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5233 delete (yyvsp[-3].ArgList)->back().first.PAT;
5234 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005235 }
5236 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005237 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005238 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
5239 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005240 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005241 delete I->first.PAT; // Delete the typeholder...
Reid Spencer5eb77c72007-03-15 03:26:42 +00005242 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer950bf602007-01-26 08:19:09 +00005243 InsertValue(ArgIt);
5244 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005245 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005246 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005247 ;}
5248 break;
5249
5250 case 224:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005251#line 2750 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005252 {
5253 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005254
5255 // Make sure that we keep track of the linkage type even if there was a
5256 // previous "declare".
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005257 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
5258 ;}
5259 break;
5260
5261 case 227:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005262#line 2764 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005263 {
5264 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5265 ;}
5266 break;
5267
5268 case 228:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005269#line 2769 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005270 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5271 break;
5272
5273 case 229:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005274#line 2770 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005275 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
5276 break;
5277
5278 case 230:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005279#line 2771 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005280 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
5281 break;
5282
5283 case 231:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005284#line 2775 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005285 { CurFun.isDeclare = true; ;}
5286 break;
5287
5288 case 232:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005289#line 2776 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005290 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5291 break;
5292
5293 case 233:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005294#line 2776 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005295 {
5296 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005297 CurFun.FunctionDone();
5298
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005299 ;}
5300 break;
5301
5302 case 234:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005303#line 2788 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005304 { (yyval.BoolVal) = false; ;}
5305 break;
5306
5307 case 235:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005308#line 2789 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005309 { (yyval.BoolVal) = true; ;}
5310 break;
5311
5312 case 236:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005313#line 2794 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005314 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
5315 break;
5316
5317 case 237:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005318#line 2795 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005319 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5320 break;
5321
5322 case 238:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005323#line 2796 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005324 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5325 break;
5326
5327 case 239:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005328#line 2797 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5329 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005330 break;
5331
5332 case 240:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005333#line 2798 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5334 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005335 break;
5336
5337 case 241:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005338#line 2799 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005339 { (yyval.ValIDVal) = ValID::createNull(); ;}
5340 break;
5341
5342 case 242:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005343#line 2800 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005344 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5345 break;
5346
5347 case 243:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005348#line 2801 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005349 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5350 break;
5351
5352 case 244:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005353#line 2802 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005354 { // Nonempty unsized packed vector
5355 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5356 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005357 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer950bf602007-01-26 08:19:09 +00005358 PATypeHolder* PTy = new PATypeHolder(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005359 HandleUpRefs(VectorType::get(ETy, NumElements)));
Reid Spencer950bf602007-01-26 08:19:09 +00005360
5361 // Verify all elements are correct type!
5362 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005363 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5364 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005365 const Type *CTy = C->getType();
5366 if (ETy != CTy)
5367 error("Element #" + utostr(i) + " is not of type '" +
5368 ETy->getDescription() +"' as required!\nIt is of type '" +
5369 CTy->getDescription() + "'");
5370 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005371 }
Reid Spencer5eb77c72007-03-15 03:26:42 +00005372 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005373 delete PTy; delete (yyvsp[-1].ConstVector);
5374 ;}
5375 break;
5376
5377 case 245:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005378#line 2823 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005379 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005380 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005381 ;}
5382 break;
5383
5384 case 246:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005385#line 2826 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005386 {
5387 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5388 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5389 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5390 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5391 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5392 free((yyvsp[-2].StrVal));
5393 free((yyvsp[0].StrVal));
5394 ;}
5395 break;
5396
5397 case 247:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005398#line 2841 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5399 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005400 break;
5401
5402 case 248:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005403#line 2842 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5404 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005405 break;
5406
5407 case 251:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005408#line 2855 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005409 {
5410 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005411 (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencer5eb77c72007-03-15 03:26:42 +00005412 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005413 delete (yyvsp[-1].TypeVal).PAT;
5414 ;}
5415 break;
5416
5417 case 252:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005418#line 2864 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005419 {
5420 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5421 ;}
5422 break;
5423
5424 case 253:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005425#line 2867 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005426 { // Do not allow functions with 0 basic blocks
5427 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5428 ;}
5429 break;
5430
5431 case 254:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005432#line 2876 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005433 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005434 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005435 InsertValue((yyvsp[0].TermInstVal));
5436 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5437 InsertValue((yyvsp[-2].BasicBlockVal));
5438 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5439 ;}
5440 break;
5441
5442 case 255:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005443#line 2886 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005444 {
5445 if ((yyvsp[0].InstVal).I)
5446 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5447 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5448 ;}
5449 break;
5450
5451 case 256:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005452#line 2891 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005453 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005454 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005455 // Make sure to move the basic block to the correct location in the
5456 // function, instead of leaving it inserted wherever it was first
5457 // referenced.
5458 Function::BasicBlockListType &BBL =
5459 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005460 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5461 ;}
5462 break;
5463
5464 case 257:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005465#line 2900 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005466 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005467 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005468 // Make sure to move the basic block to the correct location in the
5469 // function, instead of leaving it inserted wherever it was first
5470 // referenced.
5471 Function::BasicBlockListType &BBL =
5472 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005473 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5474 ;}
5475 break;
5476
5477 case 260:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005478#line 2914 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005479 { // Return with a result...
5480 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V);
5481 ;}
5482 break;
5483
5484 case 261:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005485#line 2917 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005486 { // Return with no result...
5487 (yyval.TermInstVal) = new ReturnInst();
5488 ;}
5489 break;
5490
5491 case 262:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005492#line 2920 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005493 { // Unconditional Branch...
5494 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5495 (yyval.TermInstVal) = new BranchInst(tmpBB);
5496 ;}
5497 break;
5498
5499 case 263:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005500#line 2924 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005501 {
5502 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5503 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5504 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5505 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5506 ;}
5507 break;
5508
5509 case 264:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005510#line 2930 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005511 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005512 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
5513 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5514 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5515 (yyval.TermInstVal) = S;
5516 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5517 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005518 for (; I != E; ++I) {
5519 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5520 S->addCase(CI, I->second);
5521 else
5522 error("Switch case is constant, but not a simple integer");
5523 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005524 delete (yyvsp[-1].JumpTable);
5525 ;}
5526 break;
5527
5528 case 265:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005529#line 2945 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005530 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005531 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
5532 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005533 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005534 (yyval.TermInstVal) = S;
5535 ;}
5536 break;
5537
5538 case 266:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005539#line 2952 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005540 {
Reid Spencer950bf602007-01-26 08:19:09 +00005541 const PointerType *PFTy;
5542 const FunctionType *Ty;
5543
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005544 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005545 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5546 // Pull out the types of all of the arguments...
5547 std::vector<const Type*> ParamTypes;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005548 if ((yyvsp[-7].ValueList)) {
5549 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005550 I != E; ++I)
5551 ParamTypes.push_back((*I).V->getType());
5552 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005553 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005554 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00005555 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5556 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5557 }
Reid Spencer950bf602007-01-26 08:19:09 +00005558 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5559 if (isVarArg) ParamTypes.pop_back();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005560 Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005561 PFTy = PointerType::get(Ty);
5562 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005563 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5564 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5565 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005566
5567 // Create the call node...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005568 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
5569 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, 0, 0);
Reid Spencer950bf602007-01-26 08:19:09 +00005570 } else { // Has arguments?
5571 // Loop through FunctionType's arguments and ensure they are specified
5572 // correctly!
5573 //
5574 FunctionType::param_iterator I = Ty->param_begin();
5575 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005576 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005577
5578 std::vector<Value*> Args;
5579 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5580 if ((*ArgI).V->getType() != *I)
5581 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5582 (*I)->getDescription() + "'");
5583 Args.push_back((*ArgI).V);
5584 }
5585
5586 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5587 error("Invalid number of parameters detected");
5588
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005589 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00005590 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005591 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
5592 delete (yyvsp[-10].TypeVal).PAT;
5593 delete (yyvsp[-7].ValueList);
5594 ;}
5595 break;
5596
5597 case 267:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005598#line 3007 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005599 {
5600 (yyval.TermInstVal) = new UnwindInst();
5601 ;}
5602 break;
5603
5604 case 268:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005605#line 3010 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005606 {
5607 (yyval.TermInstVal) = new UnreachableInst();
5608 ;}
5609 break;
5610
5611 case 269:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005612#line 3016 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005613 {
5614 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005615 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005616
5617 if (V == 0)
5618 error("May only switch on a constant pool value");
5619
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005620 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5621 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5622 ;}
5623 break;
5624
5625 case 270:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005626#line 3026 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005627 {
5628 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005629 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005630
5631 if (V == 0)
5632 error("May only switch on a constant pool value");
5633
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005634 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5635 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5636 ;}
5637 break;
5638
5639 case 271:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005640#line 3039 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005641 {
Reid Spencer950bf602007-01-26 08:19:09 +00005642 bool omit = false;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005643 if ((yyvsp[-1].StrVal))
5644 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005645 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005646 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005647 // This is a useless bit cast causing a name redefinition. It is
5648 // a bit cast from a type to the same type of an operand with the
5649 // same name as the name we would give this instruction. Since this
5650 // instruction results in no code generation, it is safe to omit
5651 // the instruction. This situation can occur because of collapsed
5652 // type planes. For example:
5653 // %X = add int %Y, %Z
5654 // %X = cast int %Y to uint
5655 // After upgrade, this looks like:
5656 // %X = add i32 %Y, %Z
5657 // %X = bitcast i32 to i32
5658 // The bitcast is clearly useless so we omit it.
5659 omit = true;
5660 if (omit) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005661 (yyval.InstVal).I = 0;
5662 (yyval.InstVal).S = Signless;
Reid Spencer950bf602007-01-26 08:19:09 +00005663 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005664 setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005665 InsertValue((yyvsp[0].InstVal).I);
5666 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005667 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005668 ;}
5669 break;
5670
5671 case 272:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005672#line 3068 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005673 { // Used for PHI nodes
5674 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
5675 (yyval.PHIList).S = (yyvsp[-5].TypeVal).S;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005676 Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal));
5677 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5678 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5679 delete (yyvsp[-5].TypeVal).PAT;
5680 ;}
5681 break;
5682
5683 case 273:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005684#line 3076 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005685 {
5686 (yyval.PHIList) = (yyvsp[-6].PHIList);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005687 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
5688 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5689 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5690 ;}
5691 break;
5692
5693 case 274:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005694#line 3084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005695 { // Used for call statements, and memory insts...
5696 (yyval.ValueList) = new std::vector<ValueInfo>();
5697 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5698 ;}
5699 break;
5700
5701 case 275:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005702#line 3088 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005703 {
5704 (yyval.ValueList) = (yyvsp[-2].ValueList);
5705 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
5706 ;}
5707 break;
5708
5709 case 277:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005710#line 3096 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005711 { (yyval.ValueList) = 0; ;}
5712 break;
5713
5714 case 278:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005715#line 3100 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005716 {
5717 (yyval.BoolVal) = true;
5718 ;}
5719 break;
5720
5721 case 279:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005722#line 3103 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005723 {
5724 (yyval.BoolVal) = false;
5725 ;}
5726 break;
5727
5728 case 280:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005729#line 3109 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005730 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005731 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005732 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
Reid Spencer950bf602007-01-26 08:19:09 +00005733 error("Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer9d6565a2007-02-15 02:26:10 +00005734 if (isa<VectorType>(Ty) &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005735 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Chris Lattner4227bdb2007-02-19 07:34:02 +00005736 error("Remainder not supported on vector types");
Reid Spencer950bf602007-01-26 08:19:09 +00005737 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005738 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5739 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5740 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
5741 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5742 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005743 error("binary operator returned null");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005744 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5745 delete (yyvsp[-3].TypeVal).PAT;
5746 ;}
5747 break;
5748
5749 case 281:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005750#line 3126 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005751 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005752 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005753 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00005754 if (!isa<VectorType>(Ty) ||
5755 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005756 error("Logical operator requires integral operands");
5757 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005758 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
5759 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5760 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5761 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5762 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005763 error("binary operator returned null");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005764 (yyval.InstVal).S = (yyvsp[-3].TypeVal).S;
5765 delete (yyvsp[-3].TypeVal).PAT;
5766 ;}
5767 break;
5768
5769 case 282:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005770#line 3142 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005771 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005772 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005773 if(isa<VectorType>(Ty))
5774 error("VectorTypes currently not supported in setcc instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00005775 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005776 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
5777 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5778 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5779 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5780 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005781 error("binary operator returned null");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005782 (yyval.InstVal).S = Unsigned;
5783 delete (yyvsp[-3].TypeVal).PAT;
5784 ;}
5785 break;
5786
5787 case 283:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005788#line 3156 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005789 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005790 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005791 if (isa<VectorType>(Ty))
5792 error("VectorTypes currently not supported in icmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00005793 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5794 error("icmp requires integer or pointer typed operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005795 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5796 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5797 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
5798 (yyval.InstVal).S = Unsigned;
5799 delete (yyvsp[-3].TypeVal).PAT;
5800 ;}
5801 break;
5802
5803 case 284:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005804#line 3168 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005805 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005806 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005807 if (isa<VectorType>(Ty))
5808 error("VectorTypes currently not supported in fcmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00005809 else if (!Ty->isFloatingPoint())
5810 error("fcmp instruction requires floating point operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005811 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
5812 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
5813 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
5814 (yyval.InstVal).S = Unsigned;
5815 delete (yyvsp[-3].TypeVal).PAT;
5816 ;}
5817 break;
5818
5819 case 285:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005820#line 3180 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005821 {
Reid Spencer950bf602007-01-26 08:19:09 +00005822 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005823 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005824 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5825 if (Ones == 0)
5826 error("Expected integral type for not instruction");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005827 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
5828 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005829 error("Could not create a xor instruction");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005830 (yyval.InstVal).S = (yyvsp[0].ValueVal).S;
5831 ;}
5832 break;
5833
5834 case 286:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005835#line 3191 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005836 {
5837 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
5838 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005839 error("Shift amount must be int8");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005840 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
Reid Spencer832254e2007-02-02 02:16:23 +00005841 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005842 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00005843 Value* ShiftAmt = 0;
5844 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005845 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
Reid Spencer832254e2007-02-02 02:16:23 +00005846 ShiftAmt = ConstantExpr::getZExt(C, Ty);
5847 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005848 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
Reid Spencer832254e2007-02-02 02:16:23 +00005849 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005850 ShiftAmt = (yyvsp[0].ValueVal).V;
5851 (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[-3].BinaryOpVal), Ty, (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, ShiftAmt);
5852 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5853 ;}
5854 break;
5855
5856 case 287:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005857#line 3209 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005858 {
5859 const Type *DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005860 if (!DstTy->isFirstClassType())
5861 error("cast instruction to a non-primitive type: '" +
5862 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005863 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
5864 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5865 delete (yyvsp[0].TypeVal).PAT;
5866 ;}
5867 break;
5868
5869 case 288:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005870#line 3218 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005871 {
5872 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
5873 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005874 error("select condition must be bool");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005875 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005876 error("select value types should match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005877 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5878 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5879 ;}
5880 break;
5881
5882 case 289:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005883#line 3227 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005884 {
5885 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005886 NewVarArgs = true;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005887 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
5888 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5889 delete (yyvsp[0].TypeVal).PAT;
5890 ;}
5891 break;
5892
5893 case 290:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005894#line 3234 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005895 {
5896 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5897 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005898 ObsoleteVarArgs = true;
5899 Function* NF = cast<Function>(CurModule.CurrentModule->
5900 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5901
5902 //b = vaarg a, t ->
5903 //foo = alloca 1 of t
5904 //bar = vacopy a
5905 //store bar -> foo
5906 //b = vaarg foo, t
5907 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5908 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005909 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005910 CurBB->getInstList().push_back(bar);
5911 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005912 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
5913 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5914 delete (yyvsp[0].TypeVal).PAT;
5915 ;}
5916 break;
5917
5918 case 291:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005919#line 3255 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005920 {
5921 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
5922 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005923 ObsoleteVarArgs = true;
5924 Function* NF = cast<Function>(CurModule.CurrentModule->
5925 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5926
5927 //b = vanext a, t ->
5928 //foo = alloca 1 of t
5929 //bar = vacopy a
5930 //store bar -> foo
5931 //tmp = vaarg foo, t
5932 //b = load foo
5933 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5934 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005935 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005936 CurBB->getInstList().push_back(bar);
5937 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5938 Instruction* tmp = new VAArgInst(foo, DstTy);
5939 CurBB->getInstList().push_back(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005940 (yyval.InstVal).I = new LoadInst(foo);
5941 (yyval.InstVal).S = (yyvsp[0].TypeVal).S;
5942 delete (yyvsp[0].TypeVal).PAT;
5943 ;}
5944 break;
5945
5946 case 292:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005947#line 3279 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005948 {
5949 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005950 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005951 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5952 (yyval.InstVal).S = (yyvsp[-2].ValueVal).S;
5953 ;}
5954 break;
5955
5956 case 293:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005957#line 3285 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005958 {
5959 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005960 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005961 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5962 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5963 ;}
5964 break;
5965
5966 case 294:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005967#line 3291 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005968 {
5969 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005970 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005971 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
5972 (yyval.InstVal).S = (yyvsp[-4].ValueVal).S;
5973 ;}
5974 break;
5975
5976 case 295:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005977#line 3297 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005978 {
5979 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005980 if (!Ty->isFirstClassType())
5981 error("PHI node operands must be of first class type");
5982 PHINode *PHI = new PHINode(Ty);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005983 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
5984 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
5985 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00005986 error("All elements of a PHI node must be of the same type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005987 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
5988 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00005989 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005990 (yyval.InstVal).I = PHI;
5991 (yyval.InstVal).S = (yyvsp[0].PHIList).S;
5992 delete (yyvsp[0].PHIList).P; // Free the list...
5993 ;}
5994 break;
Reid Spencer950bf602007-01-26 08:19:09 +00005995
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005996 case 296:
Reid Spencer5eb77c72007-03-15 03:26:42 +00005997#line 3313 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005998 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005999
Reid Spencer950bf602007-01-26 08:19:09 +00006000 // Handle the short call syntax
6001 const PointerType *PFTy;
6002 const FunctionType *FTy;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006003 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006004 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6005 // Pull out the types of all of the arguments...
6006 std::vector<const Type*> ParamTypes;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006007 if ((yyvsp[-1].ValueList)) {
6008 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006009 I != E; ++I)
6010 ParamTypes.push_back((*I).V->getType());
6011 }
6012
Reid Spencerb7046c72007-01-29 05:41:34 +00006013 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006014 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00006015 ParamAttrs.push_back(FunctionType::NoAttributeSet);
6016 ParamAttrs.push_back(FunctionType::StructRetAttribute);
6017 }
Reid Spencer950bf602007-01-26 08:19:09 +00006018 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6019 if (isVarArg) ParamTypes.pop_back();
6020
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006021 const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006022 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6023 error("Functions cannot return aggregate types");
6024
Reid Spencerb7046c72007-01-29 05:41:34 +00006025 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00006026 PFTy = PointerType::get(FTy);
6027 }
6028
6029 // First upgrade any intrinsic calls.
6030 std::vector<Value*> Args;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006031 if ((yyvsp[-1].ValueList))
6032 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
6033 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
6034 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006035
6036 // If we got an upgraded intrinsic
6037 if (Inst) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006038 (yyval.InstVal).I = Inst;
6039 (yyval.InstVal).S = Signless;
Reid Spencer950bf602007-01-26 08:19:09 +00006040 } else {
6041 // Get the function we're calling
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006042 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006043
6044 // Check the argument values match
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006045 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006046 // Make sure no arguments is a good thing!
6047 if (FTy->getNumParams() != 0)
6048 error("No arguments passed to a function that expects arguments");
6049 } else { // Has arguments?
6050 // Loop through FunctionType's arguments and ensure they are specified
6051 // correctly!
6052 //
6053 FunctionType::param_iterator I = FTy->param_begin();
6054 FunctionType::param_iterator E = FTy->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006055 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006056
6057 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6058 if ((*ArgI).V->getType() != *I)
6059 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6060 (*I)->getDescription() + "'");
6061
6062 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6063 error("Invalid number of parameters detected");
6064 }
6065
6066 // Create the call instruction
Chris Lattnercf3d0612007-02-13 06:04:17 +00006067 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006068 CI->setTailCall((yyvsp[-6].BoolVal));
6069 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
6070 (yyval.InstVal).I = CI;
6071 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006072 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006073 delete (yyvsp[-4].TypeVal).PAT;
6074 delete (yyvsp[-1].ValueList);
6075 ;}
6076 break;
6077
6078 case 297:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006079#line 3391 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006080 {
6081 (yyval.InstVal) = (yyvsp[0].InstVal);
6082 ;}
6083 break;
6084
6085 case 298:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006086#line 3399 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006087 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
6088 break;
6089
6090 case 299:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006091#line 3400 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006092 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6093 break;
6094
6095 case 300:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006096#line 3404 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006097 { (yyval.BoolVal) = true; ;}
6098 break;
6099
6100 case 301:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006101#line 3405 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006102 { (yyval.BoolVal) = false; ;}
6103 break;
6104
6105 case 302:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006106#line 3409 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006107 {
6108 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
6109 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6110 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6111 delete (yyvsp[-1].TypeVal).PAT;
6112 ;}
6113 break;
6114
6115 case 303:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006116#line 3415 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006117 {
6118 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
6119 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006120 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6121 delete (yyvsp[-4].TypeVal).PAT;
6122 ;}
6123 break;
6124
6125 case 304:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006126#line 3421 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006127 {
6128 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
6129 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
6130 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6131 delete (yyvsp[-1].TypeVal).PAT;
6132 ;}
6133 break;
6134
6135 case 305:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006136#line 3427 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006137 {
6138 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
6139 (yyval.InstVal).S = (yyvsp[-4].TypeVal).S;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006140 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6141 delete (yyvsp[-4].TypeVal).PAT;
6142 ;}
6143 break;
6144
6145 case 306:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006146#line 3433 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006147 {
6148 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006149 if (!isa<PointerType>(PTy))
6150 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006151 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
6152 (yyval.InstVal).S = Signless;
6153 ;}
6154 break;
6155
6156 case 307:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006157#line 3440 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006158 {
6159 const Type* Ty = (yyvsp[-1].TypeVal).PAT->get();
6160 (yyval.InstVal).S = (yyvsp[-1].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006161 if (!isa<PointerType>(Ty))
6162 error("Can't load from nonpointer type: " + Ty->getDescription());
6163 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6164 error("Can't load from pointer of non-first-class type: " +
6165 Ty->getDescription());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006166 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6167 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
6168 delete (yyvsp[-1].TypeVal).PAT;
6169 ;}
6170 break;
6171
6172 case 308:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006173#line 3452 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006174 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006175 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencered96d1e2007-02-08 09:08:52 +00006176 if (!PTy)
6177 error("Can't store to a nonpointer type: " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006178 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencered96d1e2007-02-08 09:08:52 +00006179 const Type *ElTy = PTy->getElementType();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006180 Value *StoreVal = (yyvsp[-3].ValueVal).V;
6181 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6182 if (ElTy != (yyvsp[-3].ValueVal).V->getType()) {
6183 StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy);
Reid Spencered96d1e2007-02-08 09:08:52 +00006184 if (!StoreVal)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006185 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencered96d1e2007-02-08 09:08:52 +00006186 "' into space of type '" + ElTy->getDescription() + "'");
6187 else {
6188 PTy = PointerType::get(StoreVal->getType());
6189 if (Constant *C = dyn_cast<Constant>(tmpVal))
6190 tmpVal = ConstantExpr::getBitCast(C, PTy);
6191 else
6192 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6193 }
6194 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006195 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal));
6196 (yyval.InstVal).S = Signless;
6197 delete (yyvsp[-1].TypeVal).PAT;
6198 ;}
6199 break;
6200
6201 case 309:
Reid Spencer5eb77c72007-03-15 03:26:42 +00006202#line 3477 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006203 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006204 const Type* Ty = (yyvsp[-2].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006205 if (!isa<PointerType>(Ty))
6206 error("getelementptr insn requires pointer operand");
6207
6208 std::vector<Value*> VIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006209 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006210
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006211 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
6212 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size());
6213 (yyval.InstVal).S = Signless;
6214 delete (yyvsp[-2].TypeVal).PAT;
6215 delete (yyvsp[0].ValueList);
6216 ;}
6217 break;
6218
6219
6220 default: break;
6221 }
6222
6223/* Line 1126 of yacc.c. */
Reid Spencer5eb77c72007-03-15 03:26:42 +00006224#line 6225 "UpgradeParser.tab.c"
Chris Lattnercf3d0612007-02-13 06:04:17 +00006225
6226 yyvsp -= yylen;
6227 yyssp -= yylen;
Reid Spencerb7046c72007-01-29 05:41:34 +00006228
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006229
6230 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006231
6232 *++yyvsp = yyval;
6233
6234
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006235 /* Now `shift' the result of the reduction. Determine what state
6236 that goes to, based on the state we popped back to and the rule
6237 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006238
6239 yyn = yyr1[yyn];
6240
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006241 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6242 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006243 yystate = yytable[yystate];
6244 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006245 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006246
6247 goto yynewstate;
6248
6249
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006250/*------------------------------------.
6251| yyerrlab -- here on detecting error |
6252`------------------------------------*/
6253yyerrlab:
6254 /* If not already recovering from an error, report this error. */
6255 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006256 {
6257 ++yynerrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006258#if YYERROR_VERBOSE
Chris Lattnercf3d0612007-02-13 06:04:17 +00006259 yyn = yypact[yystate];
6260
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006261 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006262 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006263 int yytype = YYTRANSLATE (yychar);
6264 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6265 YYSIZE_T yysize = yysize0;
6266 YYSIZE_T yysize1;
6267 int yysize_overflow = 0;
6268 char *yymsg = 0;
6269# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6270 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6271 int yyx;
Chris Lattnercf3d0612007-02-13 06:04:17 +00006272
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006273#if 0
6274 /* This is so xgettext sees the translatable formats that are
6275 constructed on the fly. */
6276 YY_("syntax error, unexpected %s");
6277 YY_("syntax error, unexpected %s, expecting %s");
6278 YY_("syntax error, unexpected %s, expecting %s or %s");
6279 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6280 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6281#endif
6282 char *yyfmt;
6283 char const *yyf;
6284 static char const yyunexpected[] = "syntax error, unexpected %s";
6285 static char const yyexpecting[] = ", expecting %s";
6286 static char const yyor[] = " or %s";
6287 char yyformat[sizeof yyunexpected
6288 + sizeof yyexpecting - 1
6289 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6290 * (sizeof yyor - 1))];
6291 char const *yyprefix = yyexpecting;
6292
6293 /* Start YYX at -YYN if negative to avoid negative indexes in
6294 YYCHECK. */
6295 int yyxbegin = yyn < 0 ? -yyn : 0;
6296
6297 /* Stay within bounds of both yycheck and yytname. */
6298 int yychecklim = YYLAST - yyn;
6299 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6300 int yycount = 1;
6301
6302 yyarg[0] = yytname[yytype];
6303 yyfmt = yystpcpy (yyformat, yyunexpected);
6304
6305 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6306 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6307 {
6308 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6309 {
6310 yycount = 1;
6311 yysize = yysize0;
6312 yyformat[sizeof yyunexpected - 1] = '\0';
6313 break;
6314 }
6315 yyarg[yycount++] = yytname[yyx];
6316 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6317 yysize_overflow |= yysize1 < yysize;
6318 yysize = yysize1;
6319 yyfmt = yystpcpy (yyfmt, yyprefix);
6320 yyprefix = yyor;
6321 }
6322
6323 yyf = YY_(yyformat);
6324 yysize1 = yysize + yystrlen (yyf);
6325 yysize_overflow |= yysize1 < yysize;
6326 yysize = yysize1;
6327
6328 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6329 yymsg = (char *) YYSTACK_ALLOC (yysize);
6330 if (yymsg)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006331 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006332 /* Avoid sprintf, as that infringes on the user's name space.
6333 Don't have undefined behavior even if the translation
6334 produced a string with the wrong number of "%s"s. */
6335 char *yyp = yymsg;
6336 int yyi = 0;
6337 while ((*yyp = *yyf))
Chris Lattnercf3d0612007-02-13 06:04:17 +00006338 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006339 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6340 {
6341 yyp += yytnamerr (yyp, yyarg[yyi++]);
6342 yyf += 2;
6343 }
6344 else
6345 {
6346 yyp++;
6347 yyf++;
6348 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006349 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006350 yyerror (yymsg);
6351 YYSTACK_FREE (yymsg);
Chris Lattnercf3d0612007-02-13 06:04:17 +00006352 }
6353 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006354 {
6355 yyerror (YY_("syntax error"));
6356 goto yyexhaustedlab;
6357 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006358 }
6359 else
6360#endif /* YYERROR_VERBOSE */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006361 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006362 }
Reid Spencer950bf602007-01-26 08:19:09 +00006363
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006364
Reid Spencer950bf602007-01-26 08:19:09 +00006365
6366 if (yyerrstatus == 3)
6367 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006368 /* If just tried and failed to reuse look-ahead token after an
6369 error, discard it. */
Reid Spencer950bf602007-01-26 08:19:09 +00006370
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006371 if (yychar <= YYEOF)
6372 {
6373 /* Return failure if at end of input. */
6374 if (yychar == YYEOF)
6375 YYABORT;
6376 }
6377 else
6378 {
6379 yydestruct ("Error: discarding", yytoken, &yylval);
6380 yychar = YYEMPTY;
6381 }
6382 }
6383
6384 /* Else will try to reuse look-ahead token after shifting the error
6385 token. */
6386 goto yyerrlab1;
6387
6388
6389/*---------------------------------------------------.
6390| yyerrorlab -- error raised explicitly by YYERROR. |
6391`---------------------------------------------------*/
6392yyerrorlab:
6393
6394 /* Pacify compilers like GCC when the user code never invokes
6395 YYERROR and the label yyerrorlab therefore never appears in user
6396 code. */
6397 if (0)
6398 goto yyerrorlab;
6399
6400yyvsp -= yylen;
6401 yyssp -= yylen;
6402 yystate = *yyssp;
6403 goto yyerrlab1;
6404
6405
6406/*-------------------------------------------------------------.
6407| yyerrlab1 -- common code for both syntax error and YYERROR. |
6408`-------------------------------------------------------------*/
6409yyerrlab1:
6410 yyerrstatus = 3; /* Each real token shifted decrements this. */
6411
6412 for (;;)
6413 {
6414 yyn = yypact[yystate];
6415 if (yyn != YYPACT_NINF)
6416 {
6417 yyn += YYTERROR;
6418 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6419 {
6420 yyn = yytable[yyn];
6421 if (0 < yyn)
6422 break;
6423 }
6424 }
6425
6426 /* Pop the current state because it cannot handle the error token. */
6427 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006428 YYABORT;
6429
6430
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006431 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6432 YYPOPSTACK;
6433 yystate = *yyssp;
6434 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006435 }
6436
6437 if (yyn == YYFINAL)
6438 YYACCEPT;
6439
6440 *++yyvsp = yylval;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006441
6442
6443 /* Shift the error token. */
6444 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer950bf602007-01-26 08:19:09 +00006445
Reid Spencere7c3c602006-11-30 06:36:44 +00006446 yystate = yyn;
6447 goto yynewstate;
6448
Chris Lattner4227bdb2007-02-19 07:34:02 +00006449
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006450/*-------------------------------------.
6451| yyacceptlab -- YYACCEPT comes here. |
6452`-------------------------------------*/
6453yyacceptlab:
6454 yyresult = 0;
6455 goto yyreturn;
6456
6457/*-----------------------------------.
6458| yyabortlab -- YYABORT comes here. |
6459`-----------------------------------*/
6460yyabortlab:
6461 yyresult = 1;
6462 goto yyreturn;
6463
6464#ifndef yyoverflow
6465/*-------------------------------------------------.
6466| yyexhaustedlab -- memory exhaustion comes here. |
6467`-------------------------------------------------*/
6468yyexhaustedlab:
6469 yyerror (YY_("memory exhausted"));
6470 yyresult = 2;
6471 /* Fall through. */
Chris Lattner4227bdb2007-02-19 07:34:02 +00006472#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006473
6474yyreturn:
6475 if (yychar != YYEOF && yychar != YYEMPTY)
6476 yydestruct ("Cleanup: discarding lookahead",
6477 yytoken, &yylval);
6478 while (yyssp != yyss)
6479 {
6480 yydestruct ("Cleanup: popping",
6481 yystos[*yyssp], yyvsp);
6482 YYPOPSTACK;
Chris Lattner4227bdb2007-02-19 07:34:02 +00006483 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006484#ifndef yyoverflow
6485 if (yyss != yyssa)
6486 YYSTACK_FREE (yyss);
6487#endif
6488 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006489}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006490
6491
Reid Spencer5eb77c72007-03-15 03:26:42 +00006492#line 3493 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006493
6494
6495int yyerror(const char *ErrorMsg) {
6496 std::string where
6497 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006498 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006499 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6500 if (yychar != YYEMPTY && yychar != 0)
6501 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6502 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006503 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006504 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006505 exit(1);
6506}
Reid Spencer319a7302007-01-05 17:20:02 +00006507
Reid Spencer30d0c582007-01-15 00:26:18 +00006508void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006509 std::string where
6510 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006511 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006512 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6513 if (yychar != YYEMPTY && yychar != 0)
6514 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6515 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006516 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6517}
6518
Reid Spencer950bf602007-01-26 08:19:09 +00006519void error(const std::string& ErrorMsg, int LineNo) {
6520 if (LineNo == -1) LineNo = Upgradelineno;
6521 Upgradelineno = LineNo;
6522 yyerror(ErrorMsg.c_str());
6523}
6524
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006525