blob: a5d5f043e65a4ece74f990738850bbc39cc4a253 [file] [log] [blame]
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00007
Reid Spencer319a7302007-01-05 17:20:02 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
Reid Spencere7c3c602006-11-30 06:36:44 +000012
Reid Spencer319a7302007-01-05 17:20:02 +000013 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
Reid Spencer950bf602007-01-26 08:19:09 +000020 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
Reid Spencer319a7302007-01-05 17:20:02 +000022
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +000023/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
Reid Spencer319a7302007-01-05 17:20:02 +000032
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +000033 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
Reid Spencer319a7302007-01-05 17:20:02 +000038
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
Reid Spencer950bf602007-01-26 08:19:09 +000047#define YYBISON 1
48
49/* Bison version. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +000050#define YYBISON_VERSION "2.3"
Reid Spencer950bf602007-01-26 08:19:09 +000051
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
Reid Spencer319a7302007-01-05 17:20:02 +000054
55/* Pure parsers. */
Reid Spencer950bf602007-01-26 08:19:09 +000056#define YYPURE 0
Reid Spencer319a7302007-01-05 17:20:02 +000057
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
Reid Spencer950bf602007-01-26 08:19:09 +000061/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000062#define yyparse Upgradeparse
Reid Spencer319a7302007-01-05 17:20:02 +000063#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000064#define yyerror Upgradeerror
Reid Spencer319a7302007-01-05 17:20:02 +000065#define yylval Upgradelval
66#define yychar Upgradechar
Reid Spencere7c3c602006-11-30 06:36:44 +000067#define yydebug Upgradedebug
68#define yynerrs Upgradenerrs
69
Reid Spencere7c3c602006-11-30 06:36:44 +000070
Reid Spencer319a7302007-01-05 17:20:02 +000071/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
Reid Spencer950bf602007-01-26 08:19:09 +000077 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 SINTVAL = 260,
80 UINTVAL = 261,
81 FPVAL = 262,
82 VOID = 263,
83 BOOL = 264,
84 SBYTE = 265,
85 UBYTE = 266,
86 SHORT = 267,
87 USHORT = 268,
88 INT = 269,
89 UINT = 270,
90 LONG = 271,
91 ULONG = 272,
92 FLOAT = 273,
93 DOUBLE = 274,
94 TYPE = 275,
95 LABEL = 276,
96 VAR_ID = 277,
97 LABELSTR = 278,
98 STRINGCONSTANT = 279,
99 IMPLEMENTATION = 280,
100 ZEROINITIALIZER = 281,
101 TRUETOK = 282,
102 FALSETOK = 283,
103 BEGINTOK = 284,
104 ENDTOK = 285,
105 DECLARE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 VOLATILE = 290,
110 TO = 291,
111 DOTDOTDOT = 292,
112 NULL_TOK = 293,
113 UNDEF = 294,
114 CONST = 295,
115 INTERNAL = 296,
116 LINKONCE = 297,
117 WEAK = 298,
118 APPENDING = 299,
Reid Spencer319a7302007-01-05 17:20:02 +0000119 DLLIMPORT = 300,
120 DLLEXPORT = 301,
121 EXTERN_WEAK = 302,
Reid Spencer950bf602007-01-26 08:19:09 +0000122 OPAQUE = 303,
123 NOT = 304,
124 EXTERNAL = 305,
125 TARGET = 306,
126 TRIPLE = 307,
127 ENDIAN = 308,
128 POINTERSIZE = 309,
129 LITTLE = 310,
130 BIG = 311,
131 ALIGN = 312,
Reid Spencerc4d96252007-01-13 00:03:30 +0000132 DEPLIBS = 313,
133 CALL = 314,
134 TAIL = 315,
135 ASM_TOK = 316,
136 MODULE = 317,
137 SIDEEFFECT = 318,
138 CC_TOK = 319,
139 CCC_TOK = 320,
140 CSRETCC_TOK = 321,
141 FASTCC_TOK = 322,
142 COLDCC_TOK = 323,
143 X86_STDCALLCC_TOK = 324,
144 X86_FASTCALLCC_TOK = 325,
145 DATALAYOUT = 326,
146 RET = 327,
147 BR = 328,
148 SWITCH = 329,
149 INVOKE = 330,
Reid Spencer950bf602007-01-26 08:19:09 +0000150 UNREACHABLE = 331,
Reid Spencerc4d96252007-01-13 00:03:30 +0000151 UNWIND = 332,
Reid Spencer950bf602007-01-26 08:19:09 +0000152 EXCEPT = 333,
Reid Spencerc4d96252007-01-13 00:03:30 +0000153 ADD = 334,
154 SUB = 335,
155 MUL = 336,
156 DIV = 337,
157 UDIV = 338,
158 SDIV = 339,
159 FDIV = 340,
160 REM = 341,
161 UREM = 342,
162 SREM = 343,
163 FREM = 344,
164 AND = 345,
165 OR = 346,
166 XOR = 347,
167 SETLE = 348,
168 SETGE = 349,
169 SETLT = 350,
170 SETGT = 351,
171 SETEQ = 352,
172 SETNE = 353,
173 ICMP = 354,
174 FCMP = 355,
Reid Spencer950bf602007-01-26 08:19:09 +0000175 MALLOC = 356,
176 ALLOCA = 357,
177 FREE = 358,
178 LOAD = 359,
179 STORE = 360,
180 GETELEMENTPTR = 361,
181 PHI_TOK = 362,
182 SELECT = 363,
183 SHL = 364,
184 SHR = 365,
185 ASHR = 366,
186 LSHR = 367,
187 VAARG = 368,
188 EXTRACTELEMENT = 369,
189 INSERTELEMENT = 370,
190 SHUFFLEVECTOR = 371,
191 VAARG_old = 372,
192 VANEXT_old = 373,
193 EQ = 374,
194 NE = 375,
195 SLT = 376,
196 SGT = 377,
197 SLE = 378,
198 SGE = 379,
199 ULT = 380,
200 UGT = 381,
201 ULE = 382,
202 UGE = 383,
203 OEQ = 384,
204 ONE = 385,
205 OLT = 386,
206 OGT = 387,
207 OLE = 388,
208 OGE = 389,
209 ORD = 390,
210 UNO = 391,
211 UEQ = 392,
212 UNE = 393,
213 CAST = 394,
214 TRUNC = 395,
215 ZEXT = 396,
216 SEXT = 397,
217 FPTRUNC = 398,
218 FPEXT = 399,
219 FPTOUI = 400,
220 FPTOSI = 401,
221 UITOFP = 402,
222 SITOFP = 403,
223 PTRTOINT = 404,
224 INTTOPTR = 405,
225 BITCAST = 406
Reid Spencer319a7302007-01-05 17:20:02 +0000226 };
227#endif
Reid Spencer950bf602007-01-26 08:19:09 +0000228/* Tokens. */
229#define ESINT64VAL 258
230#define EUINT64VAL 259
231#define SINTVAL 260
232#define UINTVAL 261
233#define FPVAL 262
234#define VOID 263
235#define BOOL 264
236#define SBYTE 265
237#define UBYTE 266
238#define SHORT 267
239#define USHORT 268
240#define INT 269
241#define UINT 270
242#define LONG 271
243#define ULONG 272
244#define FLOAT 273
245#define DOUBLE 274
246#define TYPE 275
247#define LABEL 276
248#define VAR_ID 277
249#define LABELSTR 278
250#define STRINGCONSTANT 279
251#define IMPLEMENTATION 280
252#define ZEROINITIALIZER 281
253#define TRUETOK 282
254#define FALSETOK 283
255#define BEGINTOK 284
256#define ENDTOK 285
257#define DECLARE 286
258#define GLOBAL 287
259#define CONSTANT 288
260#define SECTION 289
261#define VOLATILE 290
262#define TO 291
263#define DOTDOTDOT 292
264#define NULL_TOK 293
265#define UNDEF 294
266#define CONST 295
267#define INTERNAL 296
268#define LINKONCE 297
269#define WEAK 298
270#define APPENDING 299
Reid Spencer319a7302007-01-05 17:20:02 +0000271#define DLLIMPORT 300
272#define DLLEXPORT 301
273#define EXTERN_WEAK 302
Reid Spencer950bf602007-01-26 08:19:09 +0000274#define OPAQUE 303
275#define NOT 304
276#define EXTERNAL 305
277#define TARGET 306
278#define TRIPLE 307
279#define ENDIAN 308
280#define POINTERSIZE 309
281#define LITTLE 310
282#define BIG 311
283#define ALIGN 312
Reid Spencerc4d96252007-01-13 00:03:30 +0000284#define DEPLIBS 313
285#define CALL 314
286#define TAIL 315
287#define ASM_TOK 316
288#define MODULE 317
289#define SIDEEFFECT 318
290#define CC_TOK 319
291#define CCC_TOK 320
292#define CSRETCC_TOK 321
293#define FASTCC_TOK 322
294#define COLDCC_TOK 323
295#define X86_STDCALLCC_TOK 324
296#define X86_FASTCALLCC_TOK 325
297#define DATALAYOUT 326
298#define RET 327
299#define BR 328
300#define SWITCH 329
301#define INVOKE 330
Reid Spencer950bf602007-01-26 08:19:09 +0000302#define UNREACHABLE 331
Reid Spencerc4d96252007-01-13 00:03:30 +0000303#define UNWIND 332
Reid Spencer950bf602007-01-26 08:19:09 +0000304#define EXCEPT 333
Reid Spencerc4d96252007-01-13 00:03:30 +0000305#define ADD 334
306#define SUB 335
307#define MUL 336
308#define DIV 337
309#define UDIV 338
310#define SDIV 339
311#define FDIV 340
312#define REM 341
313#define UREM 342
314#define SREM 343
315#define FREM 344
316#define AND 345
317#define OR 346
318#define XOR 347
319#define SETLE 348
320#define SETGE 349
321#define SETLT 350
322#define SETGT 351
323#define SETEQ 352
324#define SETNE 353
325#define ICMP 354
326#define FCMP 355
Reid Spencer950bf602007-01-26 08:19:09 +0000327#define MALLOC 356
328#define ALLOCA 357
329#define FREE 358
330#define LOAD 359
331#define STORE 360
332#define GETELEMENTPTR 361
333#define PHI_TOK 362
334#define SELECT 363
335#define SHL 364
336#define SHR 365
337#define ASHR 366
338#define LSHR 367
339#define VAARG 368
340#define EXTRACTELEMENT 369
341#define INSERTELEMENT 370
342#define SHUFFLEVECTOR 371
343#define VAARG_old 372
344#define VANEXT_old 373
345#define EQ 374
346#define NE 375
347#define SLT 376
348#define SGT 377
349#define SLE 378
350#define SGE 379
351#define ULT 380
352#define UGT 381
353#define ULE 382
354#define UGE 383
355#define OEQ 384
356#define ONE 385
357#define OLT 386
358#define OGT 387
359#define OLE 388
360#define OGE 389
361#define ORD 390
362#define UNO 391
363#define UEQ 392
364#define UNE 393
365#define CAST 394
366#define TRUNC 395
367#define ZEXT 396
368#define SEXT 397
369#define FPTRUNC 398
370#define FPEXT 399
371#define FPTOUI 400
372#define FPTOSI 401
373#define UITOFP 402
374#define SITOFP 403
375#define PTRTOINT 404
376#define INTTOPTR 405
377#define BITCAST 406
Reid Spencer319a7302007-01-05 17:20:02 +0000378
379
380
381
382/* Copy the first part of user declarations. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +0000383#line 14 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +0000384
385#include "UpgradeInternals.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000386#include "llvm/CallingConv.h"
387#include "llvm/InlineAsm.h"
388#include "llvm/Instructions.h"
389#include "llvm/Module.h"
390#include "llvm/SymbolTable.h"
391#include "llvm/Support/GetElementPtrTypeIterator.h"
392#include "llvm/ADT/STLExtras.h"
393#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000394#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000395#include <iostream>
Reid Spencer950bf602007-01-26 08:19:09 +0000396#include <list>
397#include <utility>
398
399// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
400// relating to upreferences in the input stream.
401//
402//#define DEBUG_UPREFS 1
403#ifdef DEBUG_UPREFS
404#define UR_OUT(X) std::cerr << X
405#else
406#define UR_OUT(X)
407#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000408
Reid Spencere77e35e2006-12-01 20:26:20 +0000409#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000410#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000411#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000412
Reid Spencer950bf602007-01-26 08:19:09 +0000413int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000414int yyparse();
415
Reid Spencer950bf602007-01-26 08:19:09 +0000416int yyerror(const char*);
417static void warning(const std::string& WarningMsg);
418
419namespace llvm {
420
Reid Spencer950bf602007-01-26 08:19:09 +0000421std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000422static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000423
Reid Spencer71d2ec92006-12-31 06:02:26 +0000424// This bool controls whether attributes are ever added to function declarations
425// definitions and calls.
426static bool AddAttributes = false;
427
Reid Spencer950bf602007-01-26 08:19:09 +0000428static Module *ParserResult;
429static bool ObsoleteVarArgs;
430static bool NewVarArgs;
431static BasicBlock *CurBB;
432static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000433
Reid Spencer950bf602007-01-26 08:19:09 +0000434// This contains info used when building the body of a function. It is
435// destroyed when the function is completed.
436//
437typedef std::vector<Value *> ValueList; // Numbered defs
438
439typedef std::pair<std::string,const Type*> RenameMapKey;
440typedef std::map<RenameMapKey,std::string> RenameMapType;
441
442static void
443ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
444 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
445
446static struct PerModuleInfo {
447 Module *CurrentModule;
448 std::map<const Type *, ValueList> Values; // Module level numbered definitions
449 std::map<const Type *,ValueList> LateResolveValues;
450 std::vector<PATypeHolder> Types;
451 std::map<ValID, PATypeHolder> LateResolveTypes;
452 static Module::Endianness Endian;
453 static Module::PointerSize PointerSize;
454 RenameMapType RenameMap;
455
456 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
457 /// how they were referenced and on which line of the input they came from so
458 /// that we can resolve them later and print error messages as appropriate.
459 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
460
461 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
462 // references to global values. Global values may be referenced before they
463 // are defined, and if so, the temporary object that they represent is held
464 // here. This is used for forward references of GlobalValues.
465 //
466 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
467 GlobalRefsType;
468 GlobalRefsType GlobalRefs;
469
470 void ModuleDone() {
471 // If we could not resolve some functions at function compilation time
472 // (calls to functions before they are defined), resolve them now... Types
473 // are resolved when the constant pool has been completely parsed.
474 //
475 ResolveDefinitions(LateResolveValues);
476
477 // Check to make sure that all global value forward references have been
478 // resolved!
479 //
480 if (!GlobalRefs.empty()) {
481 std::string UndefinedReferences = "Unresolved global references exist:\n";
482
483 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
484 I != E; ++I) {
485 UndefinedReferences += " " + I->first.first->getDescription() + " " +
486 I->first.second.getName() + "\n";
487 }
488 error(UndefinedReferences);
489 return;
490 }
491
492 if (CurrentModule->getDataLayout().empty()) {
493 std::string dataLayout;
494 if (Endian != Module::AnyEndianness)
495 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
496 if (PointerSize != Module::AnyPointerSize) {
497 if (!dataLayout.empty())
498 dataLayout += "-";
499 dataLayout.append(PointerSize == Module::Pointer64 ?
500 "p:64:64" : "p:32:32");
501 }
502 CurrentModule->setDataLayout(dataLayout);
503 }
504
505 Values.clear(); // Clear out function local definitions
506 Types.clear();
507 CurrentModule = 0;
508 }
509
510 // GetForwardRefForGlobal - Check to see if there is a forward reference
511 // for this global. If so, remove it from the GlobalRefs map and return it.
512 // If not, just return null.
513 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
514 // Check to see if there is a forward reference to this global variable...
515 // if there is, eliminate it and patch the reference to use the new def'n.
516 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
517 GlobalValue *Ret = 0;
518 if (I != GlobalRefs.end()) {
519 Ret = I->second;
520 GlobalRefs.erase(I);
521 }
522 return Ret;
523 }
524 void setEndianness(Module::Endianness E) { Endian = E; }
525 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
526} CurModule;
527
528Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
529Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
530
531static struct PerFunctionInfo {
532 Function *CurrentFunction; // Pointer to current function being created
533
534 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
535 std::map<const Type*, ValueList> LateResolveValues;
536 bool isDeclare; // Is this function a forward declararation?
537 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
538
539 /// BBForwardRefs - When we see forward references to basic blocks, keep
540 /// track of them here.
541 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
542 std::vector<BasicBlock*> NumberedBlocks;
543 RenameMapType RenameMap;
Reid Spencer950bf602007-01-26 08:19:09 +0000544 unsigned NextBBNum;
545
546 inline PerFunctionInfo() {
547 CurrentFunction = 0;
548 isDeclare = false;
549 Linkage = GlobalValue::ExternalLinkage;
550 }
551
552 inline void FunctionStart(Function *M) {
553 CurrentFunction = M;
554 NextBBNum = 0;
555 }
556
557 void FunctionDone() {
558 NumberedBlocks.clear();
559
560 // Any forward referenced blocks left?
561 if (!BBForwardRefs.empty()) {
562 error("Undefined reference to label " +
563 BBForwardRefs.begin()->first->getName());
564 return;
565 }
566
567 // Resolve all forward references now.
568 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
569
570 Values.clear(); // Clear out function local definitions
571 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000572 CurrentFunction = 0;
573 isDeclare = false;
574 Linkage = GlobalValue::ExternalLinkage;
575 }
576} CurFun; // Info for the current function...
577
578static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
579
580
581//===----------------------------------------------------------------------===//
582// Code to handle definitions of all the types
583//===----------------------------------------------------------------------===//
584
585static int InsertValue(Value *V,
586 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
587 if (V->hasName()) return -1; // Is this a numbered definition?
588
589 // Yes, insert the value into the value table...
590 ValueList &List = ValueTab[V->getType()];
591 List.push_back(V);
592 return List.size()-1;
593}
594
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000595static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000596 switch (D.Type) {
597 case ValID::NumberVal: // Is it a numbered definition?
598 // Module constants occupy the lowest numbered slots...
599 if ((unsigned)D.Num < CurModule.Types.size()) {
600 return CurModule.Types[(unsigned)D.Num];
601 }
602 break;
603 case ValID::NameVal: // Is it a named definition?
604 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
605 D.destroy(); // Free old strdup'd memory...
606 return N;
607 }
608 break;
609 default:
610 error("Internal parser error: Invalid symbol type reference");
611 return 0;
612 }
613
614 // If we reached here, we referenced either a symbol that we don't know about
615 // or an id number that hasn't been read yet. We may be referencing something
616 // forward, so just create an entry to be resolved later and get to it...
617 //
618 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
619
620
621 if (inFunctionScope()) {
622 if (D.Type == ValID::NameVal) {
623 error("Reference to an undefined type: '" + D.getName() + "'");
624 return 0;
625 } else {
626 error("Reference to an undefined type: #" + itostr(D.Num));
627 return 0;
628 }
629 }
630
631 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
632 if (I != CurModule.LateResolveTypes.end())
633 return I->second;
634
635 Type *Typ = OpaqueType::get();
636 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
637 return Typ;
638 }
639
640// getExistingValue - Look up the value specified by the provided type and
641// the provided ValID. If the value exists and has already been defined, return
642// it. Otherwise return null.
643//
644static Value *getExistingValue(const Type *Ty, const ValID &D) {
645 if (isa<FunctionType>(Ty)) {
646 error("Functions are not values and must be referenced as pointers");
647 }
648
649 switch (D.Type) {
650 case ValID::NumberVal: { // Is it a numbered definition?
651 unsigned Num = (unsigned)D.Num;
652
653 // Module constants occupy the lowest numbered slots...
654 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
655 if (VI != CurModule.Values.end()) {
656 if (Num < VI->second.size())
657 return VI->second[Num];
658 Num -= VI->second.size();
659 }
660
661 // Make sure that our type is within bounds
662 VI = CurFun.Values.find(Ty);
663 if (VI == CurFun.Values.end()) return 0;
664
665 // Check that the number is within bounds...
666 if (VI->second.size() <= Num) return 0;
667
668 return VI->second[Num];
669 }
670
671 case ValID::NameVal: { // Is it a named definition?
672 // Get the name out of the ID
673 std::string Name(D.Name);
674 Value* V = 0;
675 RenameMapKey Key = std::make_pair(Name, Ty);
676 if (inFunctionScope()) {
677 // See if the name was renamed
678 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
679 std::string LookupName;
680 if (I != CurFun.RenameMap.end())
681 LookupName = I->second;
682 else
683 LookupName = Name;
684 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
685 V = SymTab.lookup(Ty, LookupName);
686 }
687 if (!V) {
688 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
689 std::string LookupName;
690 if (I != CurModule.RenameMap.end())
691 LookupName = I->second;
692 else
693 LookupName = Name;
694 V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
695 }
696 if (V == 0)
697 return 0;
698
699 D.destroy(); // Free old strdup'd memory...
700 return V;
701 }
702
703 // Check to make sure that "Ty" is an integral type, and that our
704 // value will fit into the specified type...
705 case ValID::ConstSIntVal: // Is it a constant pool reference??
706 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
707 error("Signed integral constant '" + itostr(D.ConstPool64) +
708 "' is invalid for type '" + Ty->getDescription() + "'");
709 }
710 return ConstantInt::get(Ty, D.ConstPool64);
711
712 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
713 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
714 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
715 error("Integral constant '" + utostr(D.UConstPool64) +
716 "' is invalid or out of range");
717 else // This is really a signed reference. Transmogrify.
718 return ConstantInt::get(Ty, D.ConstPool64);
719 } else
720 return ConstantInt::get(Ty, D.UConstPool64);
721
722 case ValID::ConstFPVal: // Is it a floating point const pool reference?
723 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
724 error("FP constant invalid for type");
725 return ConstantFP::get(Ty, D.ConstPoolFP);
726
727 case ValID::ConstNullVal: // Is it a null value?
728 if (!isa<PointerType>(Ty))
729 error("Cannot create a a non pointer null");
730 return ConstantPointerNull::get(cast<PointerType>(Ty));
731
732 case ValID::ConstUndefVal: // Is it an undef value?
733 return UndefValue::get(Ty);
734
735 case ValID::ConstZeroVal: // Is it a zero value?
736 return Constant::getNullValue(Ty);
737
738 case ValID::ConstantVal: // Fully resolved constant?
739 if (D.ConstantValue->getType() != Ty)
740 error("Constant expression type different from required type");
741 return D.ConstantValue;
742
743 case ValID::InlineAsmVal: { // Inline asm expression
744 const PointerType *PTy = dyn_cast<PointerType>(Ty);
745 const FunctionType *FTy =
746 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
747 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
748 error("Invalid type for asm constraint string");
749 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
750 D.IAD->HasSideEffects);
751 D.destroy(); // Free InlineAsmDescriptor.
752 return IA;
753 }
754 default:
755 assert(0 && "Unhandled case");
756 return 0;
757 } // End of switch
758
759 assert(0 && "Unhandled case");
760 return 0;
761}
762
763// getVal - This function is identical to getExistingValue, except that if a
764// value is not already defined, it "improvises" by creating a placeholder var
765// that looks and acts just like the requested variable. When the value is
766// defined later, all uses of the placeholder variable are replaced with the
767// real thing.
768//
769static Value *getVal(const Type *Ty, const ValID &ID) {
770 if (Ty == Type::LabelTy)
771 error("Cannot use a basic block here");
772
773 // See if the value has already been defined.
774 Value *V = getExistingValue(Ty, ID);
775 if (V) return V;
776
777 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
778 error("Invalid use of a composite type");
779
780 // If we reached here, we referenced either a symbol that we don't know about
781 // or an id number that hasn't been read yet. We may be referencing something
782 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000783 V = new Argument(Ty);
784
785 // Remember where this forward reference came from. FIXME, shouldn't we try
786 // to recycle these things??
787 CurModule.PlaceHolderInfo.insert(
788 std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
789
790 if (inFunctionScope())
791 InsertValue(V, CurFun.LateResolveValues);
792 else
793 InsertValue(V, CurModule.LateResolveValues);
794 return V;
795}
796
797/// getBBVal - This is used for two purposes:
798/// * If isDefinition is true, a new basic block with the specified ID is being
799/// defined.
800/// * If isDefinition is true, this is a reference to a basic block, which may
801/// or may not be a forward reference.
802///
803static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
804 assert(inFunctionScope() && "Can't get basic block at global scope");
805
806 std::string Name;
807 BasicBlock *BB = 0;
808 switch (ID.Type) {
809 default:
810 error("Illegal label reference " + ID.getName());
811 break;
812 case ValID::NumberVal: // Is it a numbered definition?
813 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
814 CurFun.NumberedBlocks.resize(ID.Num+1);
815 BB = CurFun.NumberedBlocks[ID.Num];
816 break;
817 case ValID::NameVal: // Is it a named definition?
818 Name = ID.Name;
819 if (Value *N = CurFun.CurrentFunction->
820 getValueSymbolTable().lookup(Type::LabelTy, Name)) {
821 if (N->getType() != Type::LabelTy)
822 error("Name '" + Name + "' does not refer to a BasicBlock");
823 BB = cast<BasicBlock>(N);
824 }
825 break;
826 }
827
828 // See if the block has already been defined.
829 if (BB) {
830 // If this is the definition of the block, make sure the existing value was
831 // just a forward reference. If it was a forward reference, there will be
832 // an entry for it in the PlaceHolderInfo map.
833 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
834 // The existing value was a definition, not a forward reference.
835 error("Redefinition of label " + ID.getName());
836
837 ID.destroy(); // Free strdup'd memory.
838 return BB;
839 }
840
841 // Otherwise this block has not been seen before.
842 BB = new BasicBlock("", CurFun.CurrentFunction);
843 if (ID.Type == ValID::NameVal) {
844 BB->setName(ID.Name);
845 } else {
846 CurFun.NumberedBlocks[ID.Num] = BB;
847 }
848
849 // If this is not a definition, keep track of it so we can use it as a forward
850 // reference.
851 if (!isDefinition) {
852 // Remember where this forward reference came from.
853 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
854 } else {
855 // The forward declaration could have been inserted anywhere in the
856 // function: insert it into the correct place now.
857 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
858 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
859 }
860 ID.destroy();
861 return BB;
862}
863
864
865//===----------------------------------------------------------------------===//
866// Code to handle forward references in instructions
867//===----------------------------------------------------------------------===//
868//
869// This code handles the late binding needed with statements that reference
870// values not defined yet... for example, a forward branch, or the PHI node for
871// a loop body.
872//
873// This keeps a table (CurFun.LateResolveValues) of all such forward references
874// and back patchs after we are done.
875//
876
877// ResolveDefinitions - If we could not resolve some defs at parsing
878// time (forward branches, phi functions for loops, etc...) resolve the
879// defs now...
880//
881static void
882ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
883 std::map<const Type*,ValueList> *FutureLateResolvers) {
884 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
885 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
886 E = LateResolvers.end(); LRI != E; ++LRI) {
887 ValueList &List = LRI->second;
888 while (!List.empty()) {
889 Value *V = List.back();
890 List.pop_back();
891
892 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
893 CurModule.PlaceHolderInfo.find(V);
894 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
895
896 ValID &DID = PHI->second.first;
897
898 Value *TheRealValue = getExistingValue(LRI->first, DID);
899 if (TheRealValue) {
900 V->replaceAllUsesWith(TheRealValue);
901 delete V;
902 CurModule.PlaceHolderInfo.erase(PHI);
903 } else if (FutureLateResolvers) {
904 // Functions have their unresolved items forwarded to the module late
905 // resolver table
906 InsertValue(V, *FutureLateResolvers);
907 } else {
908 if (DID.Type == ValID::NameVal) {
909 error("Reference to an invalid definition: '" +DID.getName()+
910 "' of type '" + V->getType()->getDescription() + "'",
911 PHI->second.second);
912 return;
913 } else {
914 error("Reference to an invalid definition: #" +
915 itostr(DID.Num) + " of type '" +
916 V->getType()->getDescription() + "'", PHI->second.second);
917 return;
918 }
919 }
920 }
921 }
922
923 LateResolvers.clear();
924}
925
926// ResolveTypeTo - A brand new type was just declared. This means that (if
927// name is not null) things referencing Name can be resolved. Otherwise, things
928// refering to the number can be resolved. Do this now.
929//
930static void ResolveTypeTo(char *Name, const Type *ToTy) {
931 ValID D;
932 if (Name) D = ValID::create(Name);
933 else D = ValID::create((int)CurModule.Types.size());
934
935 std::map<ValID, PATypeHolder>::iterator I =
936 CurModule.LateResolveTypes.find(D);
937 if (I != CurModule.LateResolveTypes.end()) {
938 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
939 CurModule.LateResolveTypes.erase(I);
940 }
941}
942
943static std::string makeNameUnique(const std::string& Name) {
944 static unsigned UniqueNameCounter = 1;
945 std::string Result(Name);
946 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
947 return Result;
948}
949
950// setValueName - Set the specified value to the name given. The name may be
951// null potentially, in which case this is a noop. The string passed in is
952// assumed to be a malloc'd string buffer, and is free'd by this function.
953//
954static void setValueName(Value *V, char *NameStr) {
955 if (NameStr) {
956 std::string Name(NameStr); // Copy string
957 free(NameStr); // Free old string
958
959 if (V->getType() == Type::VoidTy) {
960 error("Can't assign name '" + Name + "' to value with void type");
961 return;
962 }
963
Reid Spencer950bf602007-01-26 08:19:09 +0000964 assert(inFunctionScope() && "Must be in function scope");
965
966 // Search the function's symbol table for an existing value of this name
967 Value* Existing = 0;
968 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
969 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
970 for ( ; PI != PE; ++PI) {
971 SymbolTable::value_const_iterator VI = PI->second.find(Name);
972 if (VI != PI->second.end()) {
973 Existing = VI->second;
974 break;
975 }
976 }
977 if (Existing) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +0000978 if (Existing->getType() == V->getType()) {
979 // The type of the Existing value and the new one are the same. This
980 // is probably a type plane collapsing error. If the types involved
981 // are both integer, just rename it. Otherwise it
982 // is a redefinition error.
983 if (!Existing->getType()->isInteger()) {
984 error("Redefinition of value named '" + Name + "' in the '" +
985 V->getType()->getDescription() + "' type plane");
986 return;
987 }
Reid Spencer950bf602007-01-26 08:19:09 +0000988 }
989 // In LLVM 2.0 we don't allow names to be re-used for any values in a
990 // function, regardless of Type. Previously re-use of names was okay as
991 // long as they were distinct types. With type planes collapsing because
992 // of the signedness change and because of PR411, this can no longer be
993 // supported. We must search the entire symbol table for a conflicting
994 // name and make the name unique. No warning is needed as this can't
995 // cause a problem.
996 std::string NewName = makeNameUnique(Name);
997 // We're changing the name but it will probably be used by other
998 // instructions as operands later on. Consequently we have to retain
999 // a mapping of the renaming that we're doing.
1000 RenameMapKey Key = std::make_pair(Name,V->getType());
1001 CurFun.RenameMap[Key] = NewName;
1002 Name = NewName;
1003 }
1004
1005 // Set the name.
1006 V->setName(Name);
1007 }
1008}
1009
1010/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1011/// this is a declaration, otherwise it is a definition.
1012static GlobalVariable *
1013ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1014 bool isConstantGlobal, const Type *Ty,
1015 Constant *Initializer) {
1016 if (isa<FunctionType>(Ty))
1017 error("Cannot declare global vars of function type");
1018
1019 const PointerType *PTy = PointerType::get(Ty);
1020
1021 std::string Name;
1022 if (NameStr) {
1023 Name = NameStr; // Copy string
1024 free(NameStr); // Free old string
1025 }
1026
1027 // See if this global value was forward referenced. If so, recycle the
1028 // object.
1029 ValID ID;
1030 if (!Name.empty()) {
1031 ID = ValID::create((char*)Name.c_str());
1032 } else {
1033 ID = ValID::create((int)CurModule.Values[PTy].size());
1034 }
1035
1036 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1037 // Move the global to the end of the list, from whereever it was
1038 // previously inserted.
1039 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1040 CurModule.CurrentModule->getGlobalList().remove(GV);
1041 CurModule.CurrentModule->getGlobalList().push_back(GV);
1042 GV->setInitializer(Initializer);
1043 GV->setLinkage(Linkage);
1044 GV->setConstant(isConstantGlobal);
1045 InsertValue(GV, CurModule.Values);
1046 return GV;
1047 }
1048
1049 // If this global has a name, check to see if there is already a definition
1050 // of this global in the module and emit warnings if there are conflicts.
1051 if (!Name.empty()) {
1052 // The global has a name. See if there's an existing one of the same name.
1053 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1054 // We found an existing global ov the same name. This isn't allowed
1055 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1056 // can at least compile. This can happen because of type planes
1057 // There is alread a global of the same name which means there is a
1058 // conflict. Let's see what we can do about it.
1059 std::string NewName(makeNameUnique(Name));
1060 if (Linkage == GlobalValue::InternalLinkage) {
1061 // The linkage type is internal so just warn about the rename without
1062 // invoking "scarey language" about linkage failures. GVars with
1063 // InternalLinkage can be renamed at will.
1064 warning("Global variable '" + Name + "' was renamed to '"+
1065 NewName + "'");
1066 } else {
1067 // The linkage of this gval is external so we can't reliably rename
1068 // it because it could potentially create a linking problem.
1069 // However, we can't leave the name conflict in the output either or
1070 // it won't assemble with LLVM 2.0. So, all we can do is rename
1071 // this one to something unique and emit a warning about the problem.
1072 warning("Renaming global variable '" + Name + "' to '" + NewName +
1073 "' may cause linkage errors");
1074 }
1075
1076 // Put the renaming in the global rename map
1077 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1078 CurModule.RenameMap[Key] = NewName;
1079
1080 // Rename it
1081 Name = NewName;
1082 }
1083 }
1084
1085 // Otherwise there is no existing GV to use, create one now.
1086 GlobalVariable *GV =
1087 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1088 CurModule.CurrentModule);
1089 InsertValue(GV, CurModule.Values);
1090 return GV;
1091}
1092
1093// setTypeName - Set the specified type to the name given. The name may be
1094// null potentially, in which case this is a noop. The string passed in is
1095// assumed to be a malloc'd string buffer, and is freed by this function.
1096//
1097// This function returns true if the type has already been defined, but is
1098// allowed to be redefined in the specified context. If the name is a new name
1099// for the type plane, it is inserted and false is returned.
1100static bool setTypeName(const Type *T, char *NameStr) {
1101 assert(!inFunctionScope() && "Can't give types function-local names");
1102 if (NameStr == 0) return false;
1103
1104 std::string Name(NameStr); // Copy string
1105 free(NameStr); // Free old string
1106
1107 // We don't allow assigning names to void type
1108 if (T == Type::VoidTy) {
1109 error("Can't assign name '" + Name + "' to the void type");
1110 return false;
1111 }
1112
1113 // Set the type name, checking for conflicts as we do so.
1114 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1115
1116 if (AlreadyExists) { // Inserting a name that is already defined???
1117 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1118 assert(Existing && "Conflict but no matching type?");
1119
1120 // There is only one case where this is allowed: when we are refining an
1121 // opaque type. In this case, Existing will be an opaque type.
1122 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1123 // We ARE replacing an opaque type!
1124 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1125 return true;
1126 }
1127
1128 // Otherwise, this is an attempt to redefine a type. That's okay if
1129 // the redefinition is identical to the original. This will be so if
1130 // Existing and T point to the same Type object. In this one case we
1131 // allow the equivalent redefinition.
1132 if (Existing == T) return true; // Yes, it's equal.
1133
1134 // Any other kind of (non-equivalent) redefinition is an error.
1135 error("Redefinition of type named '" + Name + "' in the '" +
1136 T->getDescription() + "' type plane");
1137 }
1138
1139 return false;
1140}
1141
1142//===----------------------------------------------------------------------===//
1143// Code for handling upreferences in type names...
1144//
1145
1146// TypeContains - Returns true if Ty directly contains E in it.
1147//
1148static bool TypeContains(const Type *Ty, const Type *E) {
1149 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1150 E) != Ty->subtype_end();
1151}
1152
1153namespace {
1154 struct UpRefRecord {
1155 // NestingLevel - The number of nesting levels that need to be popped before
1156 // this type is resolved.
1157 unsigned NestingLevel;
1158
1159 // LastContainedTy - This is the type at the current binding level for the
1160 // type. Every time we reduce the nesting level, this gets updated.
1161 const Type *LastContainedTy;
1162
1163 // UpRefTy - This is the actual opaque type that the upreference is
1164 // represented with.
1165 OpaqueType *UpRefTy;
1166
1167 UpRefRecord(unsigned NL, OpaqueType *URTy)
1168 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1169 };
1170}
1171
1172// UpRefs - A list of the outstanding upreferences that need to be resolved.
1173static std::vector<UpRefRecord> UpRefs;
1174
1175/// HandleUpRefs - Every time we finish a new layer of types, this function is
1176/// called. It loops through the UpRefs vector, which is a list of the
1177/// currently active types. For each type, if the up reference is contained in
1178/// the newly completed type, we decrement the level count. When the level
1179/// count reaches zero, the upreferenced type is the type that is passed in:
1180/// thus we can complete the cycle.
1181///
1182static PATypeHolder HandleUpRefs(const Type *ty) {
1183 // If Ty isn't abstract, or if there are no up-references in it, then there is
1184 // nothing to resolve here.
1185 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1186
1187 PATypeHolder Ty(ty);
1188 UR_OUT("Type '" << Ty->getDescription() <<
1189 "' newly formed. Resolving upreferences.\n" <<
1190 UpRefs.size() << " upreferences active!\n");
1191
1192 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1193 // to zero), we resolve them all together before we resolve them to Ty. At
1194 // the end of the loop, if there is anything to resolve to Ty, it will be in
1195 // this variable.
1196 OpaqueType *TypeToResolve = 0;
1197
1198 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1199 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1200 << UpRefs[i].second->getDescription() << ") = "
1201 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1202 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1203 // Decrement level of upreference
1204 unsigned Level = --UpRefs[i].NestingLevel;
1205 UpRefs[i].LastContainedTy = Ty;
1206 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1207 if (Level == 0) { // Upreference should be resolved!
1208 if (!TypeToResolve) {
1209 TypeToResolve = UpRefs[i].UpRefTy;
1210 } else {
1211 UR_OUT(" * Resolving upreference for "
1212 << UpRefs[i].second->getDescription() << "\n";
1213 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1214 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1215 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1216 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1217 }
1218 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1219 --i; // Do not skip the next element...
1220 }
1221 }
1222 }
1223
1224 if (TypeToResolve) {
1225 UR_OUT(" * Resolving upreference for "
1226 << UpRefs[i].second->getDescription() << "\n";
1227 std::string OldName = TypeToResolve->getDescription());
1228 TypeToResolve->refineAbstractTypeTo(Ty);
1229 }
1230
1231 return Ty;
1232}
1233
1234static inline Instruction::TermOps
1235getTermOp(TermOps op) {
1236 switch (op) {
1237 default : assert(0 && "Invalid OldTermOp");
1238 case RetOp : return Instruction::Ret;
1239 case BrOp : return Instruction::Br;
1240 case SwitchOp : return Instruction::Switch;
1241 case InvokeOp : return Instruction::Invoke;
1242 case UnwindOp : return Instruction::Unwind;
1243 case UnreachableOp: return Instruction::Unreachable;
1244 }
1245}
1246
1247static inline Instruction::BinaryOps
1248getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1249 switch (op) {
1250 default : assert(0 && "Invalid OldBinaryOps");
1251 case SetEQ :
1252 case SetNE :
1253 case SetLE :
1254 case SetGE :
1255 case SetLT :
1256 case SetGT : assert(0 && "Should use getCompareOp");
1257 case AddOp : return Instruction::Add;
1258 case SubOp : return Instruction::Sub;
1259 case MulOp : return Instruction::Mul;
1260 case DivOp : {
1261 // This is an obsolete instruction so we must upgrade it based on the
1262 // types of its operands.
1263 bool isFP = Ty->isFloatingPoint();
1264 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1265 // If its a packed type we want to use the element type
1266 isFP = PTy->getElementType()->isFloatingPoint();
1267 if (isFP)
1268 return Instruction::FDiv;
1269 else if (Sign == Signed)
1270 return Instruction::SDiv;
1271 return Instruction::UDiv;
1272 }
1273 case UDivOp : return Instruction::UDiv;
1274 case SDivOp : return Instruction::SDiv;
1275 case FDivOp : return Instruction::FDiv;
1276 case RemOp : {
1277 // This is an obsolete instruction so we must upgrade it based on the
1278 // types of its operands.
1279 bool isFP = Ty->isFloatingPoint();
1280 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1281 // If its a packed type we want to use the element type
1282 isFP = PTy->getElementType()->isFloatingPoint();
1283 // Select correct opcode
1284 if (isFP)
1285 return Instruction::FRem;
1286 else if (Sign == Signed)
1287 return Instruction::SRem;
1288 return Instruction::URem;
1289 }
1290 case URemOp : return Instruction::URem;
1291 case SRemOp : return Instruction::SRem;
1292 case FRemOp : return Instruction::FRem;
1293 case AndOp : return Instruction::And;
1294 case OrOp : return Instruction::Or;
1295 case XorOp : return Instruction::Xor;
1296 }
1297}
1298
1299static inline Instruction::OtherOps
1300getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1301 Signedness Sign) {
1302 bool isSigned = Sign == Signed;
1303 bool isFP = Ty->isFloatingPoint();
1304 switch (op) {
1305 default : assert(0 && "Invalid OldSetCC");
1306 case SetEQ :
1307 if (isFP) {
1308 predicate = FCmpInst::FCMP_OEQ;
1309 return Instruction::FCmp;
1310 } else {
1311 predicate = ICmpInst::ICMP_EQ;
1312 return Instruction::ICmp;
1313 }
1314 case SetNE :
1315 if (isFP) {
1316 predicate = FCmpInst::FCMP_UNE;
1317 return Instruction::FCmp;
1318 } else {
1319 predicate = ICmpInst::ICMP_NE;
1320 return Instruction::ICmp;
1321 }
1322 case SetLE :
1323 if (isFP) {
1324 predicate = FCmpInst::FCMP_OLE;
1325 return Instruction::FCmp;
1326 } else {
1327 if (isSigned)
1328 predicate = ICmpInst::ICMP_SLE;
1329 else
1330 predicate = ICmpInst::ICMP_ULE;
1331 return Instruction::ICmp;
1332 }
1333 case SetGE :
1334 if (isFP) {
1335 predicate = FCmpInst::FCMP_OGE;
1336 return Instruction::FCmp;
1337 } else {
1338 if (isSigned)
1339 predicate = ICmpInst::ICMP_SGE;
1340 else
1341 predicate = ICmpInst::ICMP_UGE;
1342 return Instruction::ICmp;
1343 }
1344 case SetLT :
1345 if (isFP) {
1346 predicate = FCmpInst::FCMP_OLT;
1347 return Instruction::FCmp;
1348 } else {
1349 if (isSigned)
1350 predicate = ICmpInst::ICMP_SLT;
1351 else
1352 predicate = ICmpInst::ICMP_ULT;
1353 return Instruction::ICmp;
1354 }
1355 case SetGT :
1356 if (isFP) {
1357 predicate = FCmpInst::FCMP_OGT;
1358 return Instruction::FCmp;
1359 } else {
1360 if (isSigned)
1361 predicate = ICmpInst::ICMP_SGT;
1362 else
1363 predicate = ICmpInst::ICMP_UGT;
1364 return Instruction::ICmp;
1365 }
1366 }
1367}
1368
1369static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1370 switch (op) {
1371 default : assert(0 && "Invalid OldMemoryOps");
1372 case MallocOp : return Instruction::Malloc;
1373 case FreeOp : return Instruction::Free;
1374 case AllocaOp : return Instruction::Alloca;
1375 case LoadOp : return Instruction::Load;
1376 case StoreOp : return Instruction::Store;
1377 case GetElementPtrOp : return Instruction::GetElementPtr;
1378 }
1379}
1380
1381static inline Instruction::OtherOps
1382getOtherOp(OtherOps op, Signedness Sign) {
1383 switch (op) {
1384 default : assert(0 && "Invalid OldOtherOps");
1385 case PHIOp : return Instruction::PHI;
1386 case CallOp : return Instruction::Call;
1387 case ShlOp : return Instruction::Shl;
1388 case ShrOp :
1389 if (Sign == Signed)
1390 return Instruction::AShr;
1391 return Instruction::LShr;
1392 case SelectOp : return Instruction::Select;
1393 case UserOp1 : return Instruction::UserOp1;
1394 case UserOp2 : return Instruction::UserOp2;
1395 case VAArg : return Instruction::VAArg;
1396 case ExtractElementOp : return Instruction::ExtractElement;
1397 case InsertElementOp : return Instruction::InsertElement;
1398 case ShuffleVectorOp : return Instruction::ShuffleVector;
1399 case ICmpOp : return Instruction::ICmp;
1400 case FCmpOp : return Instruction::FCmp;
1401 case LShrOp : return Instruction::LShr;
1402 case AShrOp : return Instruction::AShr;
1403 };
1404}
1405
1406static inline Value*
1407getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1408 Signedness DstSign, bool ForceInstruction = false) {
1409 Instruction::CastOps Opcode;
1410 const Type* SrcTy = Src->getType();
1411 if (op == CastOp) {
1412 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1413 // fp -> ptr cast is no longer supported but we must upgrade this
1414 // by doing a double cast: fp -> int -> ptr
1415 SrcTy = Type::Int64Ty;
1416 Opcode = Instruction::IntToPtr;
1417 if (isa<Constant>(Src)) {
1418 Src = ConstantExpr::getCast(Instruction::FPToUI,
1419 cast<Constant>(Src), SrcTy);
1420 } else {
1421 std::string NewName(makeNameUnique(Src->getName()));
1422 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1423 }
1424 } else if (isa<IntegerType>(DstTy) &&
1425 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1426 // cast type %x to bool was previously defined as setne type %x, null
1427 // The cast semantic is now to truncate, not compare so we must retain
1428 // the original intent by replacing the cast with a setne
1429 Constant* Null = Constant::getNullValue(SrcTy);
1430 Instruction::OtherOps Opcode = Instruction::ICmp;
1431 unsigned short predicate = ICmpInst::ICMP_NE;
1432 if (SrcTy->isFloatingPoint()) {
1433 Opcode = Instruction::FCmp;
1434 predicate = FCmpInst::FCMP_ONE;
1435 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1436 error("Invalid cast to bool");
1437 }
1438 if (isa<Constant>(Src) && !ForceInstruction)
1439 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1440 else
1441 return CmpInst::create(Opcode, predicate, Src, Null);
1442 }
1443 // Determine the opcode to use by calling CastInst::getCastOpcode
1444 Opcode =
1445 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1446
1447 } else switch (op) {
1448 default: assert(0 && "Invalid cast token");
1449 case TruncOp: Opcode = Instruction::Trunc; break;
1450 case ZExtOp: Opcode = Instruction::ZExt; break;
1451 case SExtOp: Opcode = Instruction::SExt; break;
1452 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1453 case FPExtOp: Opcode = Instruction::FPExt; break;
1454 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1455 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1456 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1457 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1458 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1459 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1460 case BitCastOp: Opcode = Instruction::BitCast; break;
1461 }
1462
1463 if (isa<Constant>(Src) && !ForceInstruction)
1464 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1465 return CastInst::create(Opcode, Src, DstTy);
1466}
1467
1468static Instruction *
1469upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1470 std::vector<Value*>& Args) {
1471
1472 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1473 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1474 if (Args.size() != 2)
1475 error("Invalid prototype for " + Name + " prototype");
1476 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1477 } else {
1478 static unsigned upgradeCount = 1;
1479 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1480 std::vector<const Type*> Params;
1481 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1482 if (Args.size() != 1)
1483 error("Invalid prototype for " + Name + " prototype");
1484 Params.push_back(PtrTy);
1485 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1486 const PointerType *PFTy = PointerType::get(FTy);
1487 Value* Func = getVal(PFTy, ID);
1488 std::string InstName("va_upgrade");
1489 InstName += llvm::utostr(upgradeCount++);
1490 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1491 return new CallInst(Func, Args);
1492 } else if (Name == "llvm.va_copy") {
1493 if (Args.size() != 2)
1494 error("Invalid prototype for " + Name + " prototype");
1495 Params.push_back(PtrTy);
1496 Params.push_back(PtrTy);
1497 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1498 const PointerType *PFTy = PointerType::get(FTy);
1499 Value* Func = getVal(PFTy, ID);
1500 std::string InstName0("va_upgrade");
1501 InstName0 += llvm::utostr(upgradeCount++);
1502 std::string InstName1("va_upgrade");
1503 InstName1 += llvm::utostr(upgradeCount++);
1504 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1505 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1506 return new CallInst(Func, Args);
1507 }
1508 }
1509 return 0;
1510}
1511
1512const Type* upgradeGEPIndices(const Type* PTy,
1513 std::vector<ValueInfo> *Indices,
1514 std::vector<Value*> &VIndices,
1515 std::vector<Constant*> *CIndices = 0) {
1516 // Traverse the indices with a gep_type_iterator so we can build the list
1517 // of constant and value indices for use later. Also perform upgrades
1518 VIndices.clear();
1519 if (CIndices) CIndices->clear();
1520 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1521 VIndices.push_back((*Indices)[i].V);
1522 generic_gep_type_iterator<std::vector<Value*>::iterator>
1523 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1524 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1525 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1526 Value *Index = VIndices[i];
1527 if (CIndices && !isa<Constant>(Index))
1528 error("Indices to constant getelementptr must be constants");
1529 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1530 // struct indices to i32 struct indices with ZExt for compatibility.
1531 else if (isa<StructType>(*GTI)) { // Only change struct indices
1532 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1533 if (CUI->getType()->getBitWidth() == 8)
1534 Index =
1535 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1536 } else {
1537 // Make sure that unsigned SequentialType indices are zext'd to
1538 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1539 // all indices for SequentialType elements. We must retain the same
1540 // semantic (zext) for unsigned types.
1541 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001542 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001543 if (CIndices)
1544 Index = ConstantExpr::getCast(Instruction::ZExt,
1545 cast<Constant>(Index), Type::Int64Ty);
1546 else
1547 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencerd7c4f8c2007-01-26 19:59:25 +00001548 makeNameUnique("gep_upgrade"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001549 VIndices[i] = Index;
1550 }
Reid Spencer950bf602007-01-26 08:19:09 +00001551 }
1552 // Add to the CIndices list, if requested.
1553 if (CIndices)
1554 CIndices->push_back(cast<Constant>(Index));
1555 }
1556
1557 const Type *IdxTy =
1558 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1559 if (!IdxTy)
1560 error("Index list invalid for constant getelementptr");
1561 return IdxTy;
1562}
1563
1564Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1565 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001566{
1567 Upgradelineno = 1;
1568 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001569 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001570 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001571 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001572 ObsoleteVarArgs = false;
1573 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001574
Reid Spencer950bf602007-01-26 08:19:09 +00001575 CurModule.CurrentModule = new Module(CurFilename);
1576
1577 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001578 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001579 if (ParserResult)
1580 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001581 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001582 return 0;
1583 }
1584
Reid Spencer950bf602007-01-26 08:19:09 +00001585 // Check to make sure that parsing produced a result
1586 if (!ParserResult) {
1587 std::cerr << "llvm-upgrade: no parse result.\n";
1588 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001589 }
1590
Reid Spencer950bf602007-01-26 08:19:09 +00001591 // Reset ParserResult variable while saving its value for the result.
1592 Module *Result = ParserResult;
1593 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001594
Reid Spencer950bf602007-01-26 08:19:09 +00001595 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001596 {
Reid Spencer950bf602007-01-26 08:19:09 +00001597 Function* F;
1598 if ((F = Result->getNamedFunction("llvm.va_start"))
1599 && F->getFunctionType()->getNumParams() == 0)
1600 ObsoleteVarArgs = true;
1601 if((F = Result->getNamedFunction("llvm.va_copy"))
1602 && F->getFunctionType()->getNumParams() == 1)
1603 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001604 }
Reid Spencer319a7302007-01-05 17:20:02 +00001605
Reid Spencer950bf602007-01-26 08:19:09 +00001606 if (ObsoleteVarArgs && NewVarArgs) {
1607 error("This file is corrupt: it uses both new and old style varargs");
1608 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001609 }
Reid Spencer319a7302007-01-05 17:20:02 +00001610
Reid Spencer950bf602007-01-26 08:19:09 +00001611 if(ObsoleteVarArgs) {
1612 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1613 if (F->arg_size() != 0) {
1614 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001615 return 0;
1616 }
Reid Spencer950bf602007-01-26 08:19:09 +00001617
1618 //foo = va_start()
1619 // ->
1620 //bar = alloca typeof(foo)
1621 //va_start(bar)
1622 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001623
Reid Spencer950bf602007-01-26 08:19:09 +00001624 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1625 const Type* ArgTy = F->getFunctionType()->getReturnType();
1626 const Type* ArgTyPtr = PointerType::get(ArgTy);
1627 Function* NF = cast<Function>(Result->getOrInsertFunction(
1628 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1629
1630 while (!F->use_empty()) {
1631 CallInst* CI = cast<CallInst>(F->use_back());
1632 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1633 new CallInst(NF, bar, "", CI);
1634 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1635 CI->replaceAllUsesWith(foo);
1636 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001637 }
Reid Spencer950bf602007-01-26 08:19:09 +00001638 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001639 }
Reid Spencer950bf602007-01-26 08:19:09 +00001640
1641 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1642 if(F->arg_size() != 1) {
1643 error("Obsolete va_end takes 1 argument");
1644 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001645 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001646
Reid Spencer950bf602007-01-26 08:19:09 +00001647 //vaend foo
1648 // ->
1649 //bar = alloca 1 of typeof(foo)
1650 //vaend bar
1651 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1652 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1653 const Type* ArgTyPtr = PointerType::get(ArgTy);
1654 Function* NF = cast<Function>(Result->getOrInsertFunction(
1655 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001656
Reid Spencer950bf602007-01-26 08:19:09 +00001657 while (!F->use_empty()) {
1658 CallInst* CI = cast<CallInst>(F->use_back());
1659 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1660 new StoreInst(CI->getOperand(1), bar, CI);
1661 new CallInst(NF, bar, "", CI);
1662 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001663 }
Reid Spencer950bf602007-01-26 08:19:09 +00001664 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001665 }
Reid Spencer950bf602007-01-26 08:19:09 +00001666
1667 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1668 if(F->arg_size() != 1) {
1669 error("Obsolete va_copy takes 1 argument");
1670 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001671 }
Reid Spencer950bf602007-01-26 08:19:09 +00001672 //foo = vacopy(bar)
1673 // ->
1674 //a = alloca 1 of typeof(foo)
1675 //b = alloca 1 of typeof(foo)
1676 //store bar -> b
1677 //vacopy(a, b)
1678 //foo = load a
1679
1680 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1681 const Type* ArgTy = F->getFunctionType()->getReturnType();
1682 const Type* ArgTyPtr = PointerType::get(ArgTy);
1683 Function* NF = cast<Function>(Result->getOrInsertFunction(
1684 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001685
Reid Spencer950bf602007-01-26 08:19:09 +00001686 while (!F->use_empty()) {
1687 CallInst* CI = cast<CallInst>(F->use_back());
1688 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1689 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1690 new StoreInst(CI->getOperand(1), b, CI);
1691 new CallInst(NF, a, b, "", CI);
1692 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1693 CI->replaceAllUsesWith(foo);
1694 CI->getParent()->getInstList().erase(CI);
1695 }
1696 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001697 }
1698 }
1699
Reid Spencer52402b02007-01-02 05:45:11 +00001700 return Result;
1701}
1702
Reid Spencer950bf602007-01-26 08:19:09 +00001703} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001704
Reid Spencer950bf602007-01-26 08:19:09 +00001705using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001706
1707
Reid Spencer319a7302007-01-05 17:20:02 +00001708
1709/* Enabling traces. */
1710#ifndef YYDEBUG
1711# define YYDEBUG 0
1712#endif
1713
1714/* Enabling verbose error messages. */
1715#ifdef YYERROR_VERBOSE
1716# undef YYERROR_VERBOSE
1717# define YYERROR_VERBOSE 1
1718#else
1719# define YYERROR_VERBOSE 0
1720#endif
1721
Reid Spencer950bf602007-01-26 08:19:09 +00001722/* Enabling the token table. */
1723#ifndef YYTOKEN_TABLE
1724# define YYTOKEN_TABLE 0
1725#endif
1726
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001727#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1728typedef union YYSTYPE
1729#line 1339 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
1730{
Reid Spencer950bf602007-01-26 08:19:09 +00001731 llvm::Module *ModuleVal;
1732 llvm::Function *FunctionVal;
1733 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1734 llvm::BasicBlock *BasicBlockVal;
1735 llvm::TerminatorInst *TermInstVal;
1736 llvm::InstrInfo InstVal;
1737 llvm::ConstInfo ConstVal;
1738 llvm::ValueInfo ValueVal;
1739 llvm::PATypeInfo TypeVal;
1740 llvm::TypeInfo PrimType;
1741 llvm::PHIListInfo PHIList;
1742 std::list<llvm::PATypeInfo> *TypeList;
1743 std::vector<llvm::ValueInfo> *ValueList;
1744 std::vector<llvm::ConstInfo> *ConstVector;
1745
1746
1747 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1748 // Represent the RHS of PHI node
1749 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1750
1751 llvm::GlobalValue::LinkageTypes Linkage;
1752 int64_t SInt64Val;
1753 uint64_t UInt64Val;
1754 int SIntVal;
1755 unsigned UIntVal;
1756 double FPVal;
1757 bool BoolVal;
1758
1759 char *StrVal; // This memory is strdup'd!
1760 llvm::ValID ValIDVal; // strdup'd memory maybe!
1761
1762 llvm::BinaryOps BinaryOpVal;
1763 llvm::TermOps TermOpVal;
1764 llvm::MemoryOps MemOpVal;
1765 llvm::OtherOps OtherOpVal;
1766 llvm::CastOps CastOpVal;
1767 llvm::ICmpInst::Predicate IPred;
1768 llvm::FCmpInst::Predicate FPred;
1769 llvm::Module::Endianness Endianness;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001770}
1771/* Line 187 of yacc.c. */
1772#line 1773 "UpgradeParser.tab.c"
1773 YYSTYPE;
Reid Spencer950bf602007-01-26 08:19:09 +00001774# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1775# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001776# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001777#endif
1778
Reid Spencer950bf602007-01-26 08:19:09 +00001779
Reid Spencere7c3c602006-11-30 06:36:44 +00001780
Reid Spencer319a7302007-01-05 17:20:02 +00001781/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001782
1783
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001784/* Line 216 of yacc.c. */
1785#line 1786 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001786
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001787#ifdef short
1788# undef short
Reid Spencer950bf602007-01-26 08:19:09 +00001789#endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001790
1791#ifdef YYTYPE_UINT8
1792typedef YYTYPE_UINT8 yytype_uint8;
1793#else
1794typedef unsigned char yytype_uint8;
Reid Spencer950bf602007-01-26 08:19:09 +00001795#endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001796
1797#ifdef YYTYPE_INT8
1798typedef YYTYPE_INT8 yytype_int8;
1799#elif (defined __STDC__ || defined __C99__FUNC__ \
1800 || defined __cplusplus || defined _MSC_VER)
1801typedef signed char yytype_int8;
1802#else
1803typedef short int yytype_int8;
Reid Spencer950bf602007-01-26 08:19:09 +00001804#endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001805
1806#ifdef YYTYPE_UINT16
1807typedef YYTYPE_UINT16 yytype_uint16;
1808#else
1809typedef unsigned short int yytype_uint16;
Reid Spencer950bf602007-01-26 08:19:09 +00001810#endif
1811
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001812#ifdef YYTYPE_INT16
1813typedef YYTYPE_INT16 yytype_int16;
1814#else
1815typedef short int yytype_int16;
1816#endif
1817
1818#ifndef YYSIZE_T
1819# ifdef __SIZE_TYPE__
1820# define YYSIZE_T __SIZE_TYPE__
1821# elif defined size_t
1822# define YYSIZE_T size_t
1823# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1824 || defined __cplusplus || defined _MSC_VER)
1825# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1826# define YYSIZE_T size_t
1827# else
1828# define YYSIZE_T unsigned int
1829# endif
1830#endif
1831
1832#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1833
Reid Spencer950bf602007-01-26 08:19:09 +00001834#ifndef YY_
1835# if YYENABLE_NLS
1836# if ENABLE_NLS
1837# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1838# define YY_(msgid) dgettext ("bison-runtime", msgid)
1839# endif
1840# endif
1841# ifndef YY_
1842# define YY_(msgid) msgid
1843# endif
1844#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001845
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001846/* Suppress unused-variable warnings by "using" E. */
1847#if ! defined lint || defined __GNUC__
1848# define YYUSE(e) ((void) (e))
1849#else
1850# define YYUSE(e) /* empty */
1851#endif
1852
1853/* Identity function, used to suppress warnings about constant conditions. */
1854#ifndef lint
1855# define YYID(n) (n)
1856#else
1857#if (defined __STDC__ || defined __C99__FUNC__ \
1858 || defined __cplusplus || defined _MSC_VER)
1859static int
1860YYID (int i)
1861#else
1862static int
1863YYID (i)
1864 int i;
1865#endif
1866{
1867 return i;
1868}
1869#endif
1870
1871#if ! defined yyoverflow || YYERROR_VERBOSE
Reid Spencer319a7302007-01-05 17:20:02 +00001872
1873/* The parser invokes alloca or malloc; define the necessary symbols. */
1874
Reid Spencer950bf602007-01-26 08:19:09 +00001875# ifdef YYSTACK_USE_ALLOCA
1876# if YYSTACK_USE_ALLOCA
1877# ifdef __GNUC__
1878# define YYSTACK_ALLOC __builtin_alloca
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001879# elif defined __BUILTIN_VA_ARG_INCR
1880# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1881# elif defined _AIX
1882# define YYSTACK_ALLOC __alloca
1883# elif defined _MSC_VER
1884# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1885# define alloca _alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001886# else
Reid Spencer950bf602007-01-26 08:19:09 +00001887# define YYSTACK_ALLOC alloca
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001888# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1889 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00001890# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001891# ifndef _STDLIB_H
1892# define _STDLIB_H 1
1893# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001894# endif
1895# endif
1896# endif
1897# endif
1898
1899# ifdef YYSTACK_ALLOC
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001900 /* Pacify GCC's `empty if-body' warning. */
1901# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
Reid Spencer950bf602007-01-26 08:19:09 +00001902# ifndef YYSTACK_ALLOC_MAXIMUM
1903 /* The OS might guarantee only one guard page at the bottom of the stack,
1904 and a page size can be as small as 4096 bytes. So we cannot safely
1905 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1906 to allow for a few compiler-allocated temporary stack slots. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001907# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
Reid Spencer319a7302007-01-05 17:20:02 +00001908# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001909# else
1910# define YYSTACK_ALLOC YYMALLOC
1911# define YYSTACK_FREE YYFREE
1912# ifndef YYSTACK_ALLOC_MAXIMUM
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001913# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
Reid Spencer950bf602007-01-26 08:19:09 +00001914# endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001915# if (defined __cplusplus && ! defined _STDLIB_H \
1916 && ! ((defined YYMALLOC || defined malloc) \
1917 && (defined YYFREE || defined free)))
1918# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1919# ifndef _STDLIB_H
1920# define _STDLIB_H 1
1921# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001922# endif
1923# ifndef YYMALLOC
1924# define YYMALLOC malloc
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001925# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1926 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00001927void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1928# endif
1929# endif
1930# ifndef YYFREE
1931# define YYFREE free
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001932# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1933 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00001934void free (void *); /* INFRINGES ON USER NAME SPACE */
1935# endif
1936# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001937# endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001938#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00001939
1940
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001941#if (! defined yyoverflow \
1942 && (! defined __cplusplus \
1943 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001944
1945/* A type that is properly aligned for any stack member. */
1946union yyalloc
1947{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001948 yytype_int16 yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00001949 YYSTYPE yyvs;
1950 };
1951
1952/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00001953# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00001954
1955/* The size of an array large to enough to hold all stacks, each with
1956 N elements. */
1957# define YYSTACK_BYTES(N) \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001958 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
Reid Spencer950bf602007-01-26 08:19:09 +00001959 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00001960
1961/* Copy COUNT objects from FROM to TO. The source and destination do
1962 not overlap. */
1963# ifndef YYCOPY
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001964# if defined __GNUC__ && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00001965# define YYCOPY(To, From, Count) \
1966 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1967# else
1968# define YYCOPY(To, From, Count) \
1969 do \
1970 { \
Reid Spencer950bf602007-01-26 08:19:09 +00001971 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00001972 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00001973 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00001974 } \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001975 while (YYID (0))
Reid Spencer319a7302007-01-05 17:20:02 +00001976# endif
1977# endif
1978
1979/* Relocate STACK from its old location to the new one. The
1980 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1981 elements in the stack, and YYPTR gives the new location of the
1982 stack. Advance YYPTR to a properly aligned location for the next
1983 stack. */
1984# define YYSTACK_RELOCATE(Stack) \
1985 do \
1986 { \
1987 YYSIZE_T yynewbytes; \
1988 YYCOPY (&yyptr->Stack, Stack, yysize); \
1989 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00001990 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00001991 yyptr += yynewbytes / sizeof (*yyptr); \
1992 } \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001993 while (YYID (0))
Reid Spencere7c3c602006-11-30 06:36:44 +00001994
1995#endif
1996
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001997/* YYFINAL -- State number of the termination state. */
Reid Spencer319a7302007-01-05 17:20:02 +00001998#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00001999/* YYLAST -- Last index in YYTABLE. */
2000#define YYLAST 1712
Reid Spencer319a7302007-01-05 17:20:02 +00002001
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002002/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002003#define YYNTOKENS 166
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002004/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002005#define YYNNTS 79
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002006/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00002007#define YYNRULES 308
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002008/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00002009#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00002010
2011/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2012#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00002013#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00002014
Reid Spencer950bf602007-01-26 08:19:09 +00002015#define YYTRANSLATE(YYX) \
2016 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00002017
2018/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002019static const yytype_uint8 yytranslate[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002020{
2021 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2022 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2023 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2024 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002025 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002026 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002027 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002028 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2029 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002030 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002031 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002033 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002034 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2035 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2036 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2037 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2038 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2039 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2041 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2042 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2043 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2044 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2045 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2046 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2047 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2048 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2049 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2050 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2051 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2052 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2053 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2054 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2055 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2056 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2057 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2058 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2059 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2060 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002061 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002062};
2063
2064#if YYDEBUG
2065/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2066 YYRHS. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002067static const yytype_uint16 yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002068{
2069 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2070 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2071 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2072 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2073 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2074 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2075 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2076 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2077 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002078 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002079 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2080 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2081 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2082 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2083 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002084 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2085 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2086 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2087 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2088 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2089 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2090 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2091 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2092 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2093 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2094 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2095 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2096 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2097 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2098 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2099 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002100};
2101
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002102/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2103static const yytype_int16 yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002104{
Reid Spencer950bf602007-01-26 08:19:09 +00002105 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002106 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2107 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2108 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2109 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
Reid Spencer950bf602007-01-26 08:19:09 +00002110 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2111 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2112 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2113 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2114 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2115 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2116 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2117 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2118 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2119 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2120 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2121 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2122 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2123 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2124 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2125 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2126 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2127 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002128 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002129 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2130 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2131 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2132 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2133 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2134 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2135 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2136 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2137 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2138 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2139 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2140 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2141 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2142 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2143 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2144 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2145 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2146 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2147 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2148 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2149 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2150 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2151 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2152 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2153 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2154 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2155 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2156 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2157 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2158 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2159 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2160 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2161 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2162 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2163 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2164 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2165 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2166 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2167 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2168 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2169 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2170 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2171 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2172 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2173 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2174 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2175 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2176 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2177 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2178 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2179 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2180 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2181 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2182 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2183 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2184 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2185 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2186 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2187 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2188 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2189 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2190 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2191 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2192 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2193 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2194 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2195 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2196 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2197 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2198 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2199 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2200 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2201 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002202};
2203
2204/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002205static const yytype_uint16 yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002206{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002207 0, 1479, 1479, 1480, 1488, 1489, 1499, 1499, 1499, 1499,
2208 1499, 1499, 1499, 1499, 1499, 1499, 1499, 1503, 1503, 1503,
2209 1507, 1507, 1507, 1507, 1507, 1507, 1511, 1511, 1512, 1512,
2210 1513, 1513, 1514, 1514, 1515, 1515, 1519, 1519, 1520, 1520,
2211 1521, 1521, 1522, 1522, 1523, 1523, 1524, 1524, 1525, 1525,
2212 1526, 1527, 1530, 1530, 1530, 1530, 1534, 1534, 1534, 1534,
2213 1534, 1534, 1534, 1535, 1535, 1535, 1535, 1535, 1535, 1541,
2214 1541, 1541, 1541, 1545, 1545, 1545, 1545, 1549, 1549, 1553,
2215 1553, 1558, 1561, 1566, 1567, 1568, 1569, 1570, 1571, 1572,
2216 1573, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1594,
2217 1595, 1603, 1604, 1612, 1621, 1622, 1629, 1630, 1634, 1638,
2218 1654, 1655, 1662, 1663, 1670, 1678, 1678, 1678, 1678, 1678,
2219 1678, 1678, 1679, 1679, 1679, 1679, 1679, 1684, 1688, 1692,
2220 1697, 1706, 1722, 1728, 1741, 1750, 1754, 1765, 1769, 1782,
2221 1786, 1793, 1794, 1800, 1807, 1819, 1849, 1862, 1885, 1913,
2222 1935, 1946, 1968, 1979, 1988, 1993, 2051, 2058, 2066, 2073,
2223 2080, 2084, 2088, 2097, 2112, 2125, 2134, 2162, 2175, 2184,
2224 2190, 2196, 2205, 2211, 2217, 2228, 2229, 2238, 2239, 2251,
2225 2260, 2261, 2262, 2263, 2264, 2280, 2300, 2302, 2304, 2304,
2226 2311, 2311, 2318, 2318, 2325, 2325, 2333, 2335, 2337, 2342,
2227 2356, 2357, 2361, 2364, 2372, 2376, 2383, 2387, 2391, 2395,
2228 2403, 2403, 2407, 2408, 2412, 2420, 2425, 2433, 2434, 2441,
2229 2448, 2452, 2558, 2558, 2562, 2572, 2572, 2576, 2580, 2582,
2230 2583, 2587, 2587, 2599, 2600, 2605, 2606, 2607, 2608, 2609,
2231 2610, 2611, 2612, 2613, 2634, 2637, 2652, 2653, 2658, 2658,
2232 2666, 2675, 2678, 2687, 2697, 2702, 2711, 2722, 2722, 2725,
2233 2728, 2731, 2735, 2741, 2756, 2762, 2813, 2816, 2822, 2832,
2234 2845, 2874, 2882, 2890, 2894, 2901, 2902, 2906, 2909, 2915,
2235 2932, 2948, 2962, 2974, 2986, 2997, 3006, 3015, 3024, 3031,
2236 3052, 3076, 3082, 3088, 3094, 3110, 3183, 3191, 3192, 3196,
2237 3197, 3201, 3207, 3213, 3219, 3225, 3232, 3244, 3258
Reid Spencer319a7302007-01-05 17:20:02 +00002238};
2239#endif
2240
Reid Spencer950bf602007-01-26 08:19:09 +00002241#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2242/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002243 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer319a7302007-01-05 17:20:02 +00002244static const char *const yytname[] =
2245{
Reid Spencer950bf602007-01-26 08:19:09 +00002246 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2247 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2248 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2249 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2250 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2251 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2252 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2253 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2254 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2255 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2256 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2257 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2258 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2259 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2260 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2261 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2262 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2263 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2264 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2265 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2266 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2267 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2268 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2269 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2270 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2271 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2272 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2273 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2274 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2275 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2276 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2277 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2278 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2279 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2280 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2281 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2282 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2283 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2284 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002285 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002286};
2287#endif
2288
2289# ifdef YYPRINT
2290/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2291 token YYLEX-NUM. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002292static const yytype_uint16 yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002293{
2294 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2295 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2296 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2297 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2298 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2299 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2300 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2301 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2302 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2303 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2304 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2305 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2306 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2307 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2308 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002309 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2310 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002311};
2312# endif
2313
2314/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002315static const yytype_uint8 yyr1[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002316{
Reid Spencer950bf602007-01-26 08:19:09 +00002317 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2318 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2319 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2320 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2321 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2322 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2323 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2324 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2325 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2326 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2327 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2328 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2329 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2330 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2331 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2332 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2333 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2334 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2335 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2336 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2337 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2338 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2339 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2340 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2341 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2342 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2343 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2344 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2345 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2346 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2347 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002348};
2349
2350/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002351static const yytype_uint8 yyr2[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002352{
2353 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2356 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2357 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2358 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2359 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2360 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2361 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002362 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002363 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2364 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2365 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2366 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2367 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002368 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2369 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2370 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2371 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2372 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2373 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2374 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2375 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2376 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2377 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2378 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2379 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2380 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2381 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2382 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2383 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002384};
2385
2386/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2387 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2388 means the default is an error. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002389static const yytype_uint16 yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002390{
Reid Spencer950bf602007-01-26 08:19:09 +00002391 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2392 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2393 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2394 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2395 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2396 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2397 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2398 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2399 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2400 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2401 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2402 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2403 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2404 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2405 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2406 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2407 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2408 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2409 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2410 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2411 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2412 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2413 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2414 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2415 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2416 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2417 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2418 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2419 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002420 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002421 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2422 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002424 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2425 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2426 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2427 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2428 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2429 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2430 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2431 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2432 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2433 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2434 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2435 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2436 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2437 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2438 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2439 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2440 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2441 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2442 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2443 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2444 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2445 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2446 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2447 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2448 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2449 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2450 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2451 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002452};
2453
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002454/* YYDEFGOTO[NTERM-NUM]. */
2455static const yytype_int16 yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002456{
Reid Spencer950bf602007-01-26 08:19:09 +00002457 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2458 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2459 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2460 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2461 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2462 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2463 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2464 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002465};
2466
2467/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2468 STATE-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002469#define YYPACT_NINF -508
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002470static const yytype_int16 yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002471{
Reid Spencer950bf602007-01-26 08:19:09 +00002472 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2473 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2474 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2475 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2476 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2477 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2478 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2479 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2480 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2481 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2482 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2483 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2484 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2485 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2486 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2487 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2488 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2489 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2490 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2491 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2492 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2493 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2494 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2495 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2496 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2497 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2498 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2499 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2500 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2501 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2502 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2503 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2504 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2505 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2506 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2507 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2508 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2509 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2510 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2511 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2512 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2513 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2514 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2515 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2516 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2517 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2518 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2519 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2520 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2521 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2522 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2523 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2524 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2525 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2526 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2527 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2528 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2529 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2530 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2531 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2532 898, 898, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002533};
2534
2535/* YYPGOTO[NTERM-NUM]. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002536static const yytype_int16 yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002537{
Reid Spencer950bf602007-01-26 08:19:09 +00002538 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2539 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2540 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2541 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2542 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2543 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2544 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2545 -508, -508, 43, -22, -508, -508, 21, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002546};
2547
2548/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2549 positive, shift that token. If negative, reduce the rule which
2550 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002551 If YYTABLE_NINF, syntax error. */
2552#define YYTABLE_NINF -180
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002553static const yytype_int16 yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002554{
Reid Spencer950bf602007-01-26 08:19:09 +00002555 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2556 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2557 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2558 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2559 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2560 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2561 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2562 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2563 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2564 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2565 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2566 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2567 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2568 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2569 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2570 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2571 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2572 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2573 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2574 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2575 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2576 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2577 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2578 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2579 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2580 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2581 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2582 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2583 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2584 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2585 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2586 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2587 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2588 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2589 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2590 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2591 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2592 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2593 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2594 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2595 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2596 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2597 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2598 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2599 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2600 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2601 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2602 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2603 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2604 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2605 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2606 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2607 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2608 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2609 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2610 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2611 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2612 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2613 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2614 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2615 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2616 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2617 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2618 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2619 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2620 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2621 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2622 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2623 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2624 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2625 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2626 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2627 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2628 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2629 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2630 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2631 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2632 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2633 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2634 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2635 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2636 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2637 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
Reid Spencerc4d96252007-01-13 00:03:30 +00002638 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002639 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2640 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2641 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2642 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002643 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002644 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2645 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2646 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2647 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2648 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2649 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2650 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2651 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2652 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2653 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2654 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2655 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2656 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2657 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2658 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2659 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2660 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2661 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2662 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2663 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2664 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2665 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2666 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2667 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2668 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2669 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2670 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2671 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2672 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2673 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2674 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2675 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2676 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2677 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2678 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2679 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2680 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2681 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2682 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2683 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2684 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2685 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2686 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2687 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2688 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2689 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2690 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2691 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2692 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2693 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2694 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2695 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2696 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2697 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2698 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2699 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2700 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2701 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2702 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2703 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2704 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2706 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2707 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2708 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002709 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2710 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002711 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2712 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2713 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2714 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002715 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002716 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2717 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2718 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2719 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2720 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2721 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2722 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2723 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2724 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2725 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2726 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002727};
2728
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002729static const yytype_int16 yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002730{
Reid Spencer950bf602007-01-26 08:19:09 +00002731 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2732 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2733 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2734 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2735 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2736 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2737 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2738 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2739 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2740 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2741 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2742 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2743 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2744 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2745 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2746 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2747 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2748 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2749 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2750 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2751 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2752 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2753 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2754 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2755 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2756 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2757 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2758 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2759 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2760 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2761 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2762 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2763 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2764 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2765 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2766 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2767 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2768 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2769 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2770 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2771 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2772 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2773 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2774 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2775 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2776 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2777 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2778 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2779 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2780 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2781 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2782 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
Reid Spencerc4d96252007-01-13 00:03:30 +00002783 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
Reid Spencer950bf602007-01-26 08:19:09 +00002784 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2785 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2786 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2787 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2788 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2789 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2790 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2791 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2792 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2793 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2794 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2795 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2796 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2797 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2798 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2799 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2800 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2801 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2802 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2803 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2804 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2805 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2806 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2807 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2808 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2809 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2810 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2811 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2812 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2813 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2814 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2815 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2816 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2817 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2818 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2819 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2820 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2821 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2822 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2823 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2824 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2825 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2826 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2827 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2828 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2829 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2830 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2831 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2832 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2833 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2834 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2835 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2836 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2837 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2838 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2839 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2840 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2841 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2842 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2843 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2844 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2845 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2846 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2847 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2848 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2849 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2850 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2851 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2852 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2853 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2854 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2855 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2856 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2857 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2858 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2859 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2860 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2861 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2862 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2863 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2864 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2865 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2866 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2867 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2868 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2869 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2870 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2871 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2872 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2873 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2874 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2875 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2876 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2877 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2878 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2879 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2880 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2881 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2882 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2883 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2884 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2885 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2886 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2887 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2888 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2889 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2890 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2891 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2892 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2893 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2894 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2895 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2896 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2897 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2898 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2899 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2900 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2901 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2902 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002903};
2904
2905/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2906 symbol of state STATE-NUM. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002907static const yytype_uint8 yystos[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002908{
Reid Spencer950bf602007-01-26 08:19:09 +00002909 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2910 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2911 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2912 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2913 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2914 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2915 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2916 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2917 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2918 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2919 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2920 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2921 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2922 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2923 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2924 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2925 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2926 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2927 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2928 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2929 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2930 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2931 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2932 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2933 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2934 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2935 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2936 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2937 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2938 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2939 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2940 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2941 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2942 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2943 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2944 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2945 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2946 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2947 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
2948 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
2949 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
2950 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
2951 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
2952 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
2953 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
2954 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
2955 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
2956 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
2957 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
2958 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
2959 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
2960 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
2961 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
2962 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
2963 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
2964 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
2965 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
2966 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
2967 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
2968 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
2969 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00002970};
Reid Spencere7c3c602006-11-30 06:36:44 +00002971
2972#define yyerrok (yyerrstatus = 0)
2973#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00002974#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00002975#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00002976
Reid Spencere7c3c602006-11-30 06:36:44 +00002977#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00002978#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00002979#define YYERROR goto yyerrorlab
2980
Reid Spencer319a7302007-01-05 17:20:02 +00002981
2982/* Like YYERROR except do call yyerror. This remains here temporarily
2983 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00002984 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00002985
Reid Spencere7c3c602006-11-30 06:36:44 +00002986#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00002987
Reid Spencere7c3c602006-11-30 06:36:44 +00002988#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00002989
2990#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00002991do \
2992 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00002993 { \
2994 yychar = (Token); \
2995 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00002996 yytoken = YYTRANSLATE (yychar); \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002997 YYPOPSTACK (1); \
Reid Spencere7c3c602006-11-30 06:36:44 +00002998 goto yybackup; \
2999 } \
3000 else \
Reid Spencer950bf602007-01-26 08:19:09 +00003001 { \
3002 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00003003 YYERROR; \
3004 } \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003005while (YYID (0))
Reid Spencere7c3c602006-11-30 06:36:44 +00003006
Reid Spencer950bf602007-01-26 08:19:09 +00003007
Reid Spencere7c3c602006-11-30 06:36:44 +00003008#define YYTERROR 1
3009#define YYERRCODE 256
3010
Reid Spencer319a7302007-01-05 17:20:02 +00003011
Reid Spencer950bf602007-01-26 08:19:09 +00003012/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3013 If N is 0, then set CURRENT to the empty location which ends
3014 the previous symbol: RHS[0] (always defined). */
3015
3016#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00003017#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00003018# define YYLLOC_DEFAULT(Current, Rhs, N) \
3019 do \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003020 if (YYID (N)) \
Reid Spencer950bf602007-01-26 08:19:09 +00003021 { \
3022 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3023 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3024 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3025 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3026 } \
3027 else \
3028 { \
3029 (Current).first_line = (Current).last_line = \
3030 YYRHSLOC (Rhs, 0).last_line; \
3031 (Current).first_column = (Current).last_column = \
3032 YYRHSLOC (Rhs, 0).last_column; \
3033 } \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003034 while (YYID (0))
Reid Spencere7c3c602006-11-30 06:36:44 +00003035#endif
3036
Reid Spencer950bf602007-01-26 08:19:09 +00003037
3038/* YY_LOCATION_PRINT -- Print the location on the stream.
3039 This macro was not mandated originally: define only if we know
3040 we won't break user code: when these are the locations we know. */
3041
3042#ifndef YY_LOCATION_PRINT
3043# if YYLTYPE_IS_TRIVIAL
3044# define YY_LOCATION_PRINT(File, Loc) \
3045 fprintf (File, "%d.%d-%d.%d", \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003046 (Loc).first_line, (Loc).first_column, \
3047 (Loc).last_line, (Loc).last_column)
Reid Spencer950bf602007-01-26 08:19:09 +00003048# else
3049# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3050# endif
3051#endif
3052
3053
Reid Spencer319a7302007-01-05 17:20:02 +00003054/* YYLEX -- calling `yylex' with the right arguments. */
3055
Reid Spencer950bf602007-01-26 08:19:09 +00003056#ifdef YYLEX_PARAM
3057# define YYLEX yylex (YYLEX_PARAM)
3058#else
3059# define YYLEX yylex ()
3060#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003061
3062/* Enable debugging if requested. */
3063#if YYDEBUG
3064
3065# ifndef YYFPRINTF
3066# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3067# define YYFPRINTF fprintf
3068# endif
3069
3070# define YYDPRINTF(Args) \
3071do { \
3072 if (yydebug) \
3073 YYFPRINTF Args; \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003074} while (YYID (0))
Reid Spencer950bf602007-01-26 08:19:09 +00003075
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003076# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3077do { \
3078 if (yydebug) \
3079 { \
3080 YYFPRINTF (stderr, "%s ", Title); \
3081 yy_symbol_print (stderr, \
3082 Type, Value); \
3083 YYFPRINTF (stderr, "\n"); \
3084 } \
3085} while (YYID (0))
3086
3087
3088/*--------------------------------.
3089| Print this symbol on YYOUTPUT. |
3090`--------------------------------*/
3091
3092/*ARGSUSED*/
3093#if (defined __STDC__ || defined __C99__FUNC__ \
3094 || defined __cplusplus || defined _MSC_VER)
3095static void
3096yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3097#else
3098static void
3099yy_symbol_value_print (yyoutput, yytype, yyvaluep)
3100 FILE *yyoutput;
3101 int yytype;
3102 YYSTYPE const * const yyvaluep;
3103#endif
3104{
3105 if (!yyvaluep)
3106 return;
3107# ifdef YYPRINT
3108 if (yytype < YYNTOKENS)
3109 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3110# else
3111 YYUSE (yyoutput);
3112# endif
3113 switch (yytype)
3114 {
3115 default:
3116 break;
3117 }
3118}
3119
3120
3121/*--------------------------------.
3122| Print this symbol on YYOUTPUT. |
3123`--------------------------------*/
3124
3125#if (defined __STDC__ || defined __C99__FUNC__ \
3126 || defined __cplusplus || defined _MSC_VER)
3127static void
3128yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3129#else
3130static void
3131yy_symbol_print (yyoutput, yytype, yyvaluep)
3132 FILE *yyoutput;
3133 int yytype;
3134 YYSTYPE const * const yyvaluep;
3135#endif
3136{
3137 if (yytype < YYNTOKENS)
3138 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3139 else
3140 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3141
3142 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3143 YYFPRINTF (yyoutput, ")");
3144}
Reid Spencer950bf602007-01-26 08:19:09 +00003145
3146/*------------------------------------------------------------------.
3147| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3148| TOP (included). |
3149`------------------------------------------------------------------*/
3150
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003151#if (defined __STDC__ || defined __C99__FUNC__ \
3152 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00003153static void
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003154yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
Reid Spencer950bf602007-01-26 08:19:09 +00003155#else
3156static void
3157yy_stack_print (bottom, top)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003158 yytype_int16 *bottom;
3159 yytype_int16 *top;
Reid Spencer950bf602007-01-26 08:19:09 +00003160#endif
3161{
3162 YYFPRINTF (stderr, "Stack now");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003163 for (; bottom <= top; ++bottom)
Reid Spencer950bf602007-01-26 08:19:09 +00003164 YYFPRINTF (stderr, " %d", *bottom);
3165 YYFPRINTF (stderr, "\n");
3166}
3167
3168# define YY_STACK_PRINT(Bottom, Top) \
3169do { \
3170 if (yydebug) \
3171 yy_stack_print ((Bottom), (Top)); \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003172} while (YYID (0))
Reid Spencer950bf602007-01-26 08:19:09 +00003173
3174
3175/*------------------------------------------------.
3176| Report that the YYRULE is going to be reduced. |
3177`------------------------------------------------*/
3178
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003179#if (defined __STDC__ || defined __C99__FUNC__ \
3180 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00003181static void
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003182yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003183#else
3184static void
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003185yy_reduce_print (yyvsp, yyrule)
3186 YYSTYPE *yyvsp;
Reid Spencer950bf602007-01-26 08:19:09 +00003187 int yyrule;
3188#endif
3189{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003190 int yynrhs = yyr2[yyrule];
Reid Spencer950bf602007-01-26 08:19:09 +00003191 int yyi;
3192 unsigned long int yylno = yyrline[yyrule];
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003193 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3194 yyrule - 1, yylno);
3195 /* The symbols being reduced. */
3196 for (yyi = 0; yyi < yynrhs; yyi++)
3197 {
3198 fprintf (stderr, " $%d = ", yyi + 1);
3199 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3200 &(yyvsp[(yyi + 1) - (yynrhs)])
3201 );
3202 fprintf (stderr, "\n");
3203 }
Reid Spencer950bf602007-01-26 08:19:09 +00003204}
3205
3206# define YY_REDUCE_PRINT(Rule) \
3207do { \
3208 if (yydebug) \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003209 yy_reduce_print (yyvsp, Rule); \
3210} while (YYID (0))
Reid Spencer950bf602007-01-26 08:19:09 +00003211
Reid Spencer319a7302007-01-05 17:20:02 +00003212/* Nonzero means print parse trace. It is left uninitialized so that
3213 multiple parsers can coexist. */
3214int yydebug;
3215#else /* !YYDEBUG */
3216# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003217# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3218# define YY_STACK_PRINT(Bottom, Top)
3219# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003220#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003221
Reid Spencer950bf602007-01-26 08:19:09 +00003222
Reid Spencer319a7302007-01-05 17:20:02 +00003223/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003224#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003225# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003226#endif
3227
Reid Spencer319a7302007-01-05 17:20:02 +00003228/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3229 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003230
Reid Spencer319a7302007-01-05 17:20:02 +00003231 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003232 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003233 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003234
3235#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003236# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003237#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003238
Reid Spencere7c3c602006-11-30 06:36:44 +00003239
3240
Reid Spencer319a7302007-01-05 17:20:02 +00003241#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003242
Reid Spencer319a7302007-01-05 17:20:02 +00003243# ifndef yystrlen
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003244# if defined __GLIBC__ && defined _STRING_H
Reid Spencer319a7302007-01-05 17:20:02 +00003245# define yystrlen strlen
3246# else
3247/* Return the length of YYSTR. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003248#if (defined __STDC__ || defined __C99__FUNC__ \
3249 || defined __cplusplus || defined _MSC_VER)
Reid Spencer319a7302007-01-05 17:20:02 +00003250static YYSIZE_T
Reid Spencer319a7302007-01-05 17:20:02 +00003251yystrlen (const char *yystr)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003252#else
3253static YYSIZE_T
Reid Spencer319a7302007-01-05 17:20:02 +00003254yystrlen (yystr)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003255 const char *yystr;
3256#endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003257{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003258 YYSIZE_T yylen;
3259 for (yylen = 0; yystr[yylen]; yylen++)
Reid Spencer319a7302007-01-05 17:20:02 +00003260 continue;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003261 return yylen;
Chris Lattner37e01c52007-01-04 18:46:42 +00003262}
Reid Spencer319a7302007-01-05 17:20:02 +00003263# endif
3264# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003265
Reid Spencer319a7302007-01-05 17:20:02 +00003266# ifndef yystpcpy
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003267# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
Reid Spencer319a7302007-01-05 17:20:02 +00003268# define yystpcpy stpcpy
3269# else
3270/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3271 YYDEST. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003272#if (defined __STDC__ || defined __C99__FUNC__ \
3273 || defined __cplusplus || defined _MSC_VER)
Reid Spencer319a7302007-01-05 17:20:02 +00003274static char *
Reid Spencer319a7302007-01-05 17:20:02 +00003275yystpcpy (char *yydest, const char *yysrc)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003276#else
3277static char *
Reid Spencer319a7302007-01-05 17:20:02 +00003278yystpcpy (yydest, yysrc)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003279 char *yydest;
3280 const char *yysrc;
3281#endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003282{
Reid Spencer950bf602007-01-26 08:19:09 +00003283 char *yyd = yydest;
3284 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003285
Reid Spencer319a7302007-01-05 17:20:02 +00003286 while ((*yyd++ = *yys++) != '\0')
3287 continue;
3288
3289 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003290}
Reid Spencer319a7302007-01-05 17:20:02 +00003291# endif
3292# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003293
Reid Spencer950bf602007-01-26 08:19:09 +00003294# ifndef yytnamerr
3295/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3296 quotes and backslashes, so that it's suitable for yyerror. The
3297 heuristic is that double-quoting is unnecessary unless the string
3298 contains an apostrophe, a comma, or backslash (other than
3299 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3300 null, do not copy; instead, return the length of what the result
3301 would have been. */
3302static YYSIZE_T
3303yytnamerr (char *yyres, const char *yystr)
3304{
3305 if (*yystr == '"')
3306 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003307 YYSIZE_T yyn = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00003308 char const *yyp = yystr;
3309
3310 for (;;)
3311 switch (*++yyp)
3312 {
3313 case '\'':
3314 case ',':
3315 goto do_not_strip_quotes;
3316
3317 case '\\':
3318 if (*++yyp != '\\')
3319 goto do_not_strip_quotes;
3320 /* Fall through. */
3321 default:
3322 if (yyres)
3323 yyres[yyn] = *yyp;
3324 yyn++;
3325 break;
3326
3327 case '"':
3328 if (yyres)
3329 yyres[yyn] = '\0';
3330 return yyn;
3331 }
3332 do_not_strip_quotes: ;
3333 }
3334
3335 if (! yyres)
3336 return yystrlen (yystr);
3337
3338 return yystpcpy (yyres, yystr) - yyres;
3339}
3340# endif
3341
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003342/* Copy into YYRESULT an error message about the unexpected token
3343 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3344 including the terminating null byte. If YYRESULT is null, do not
3345 copy anything; just return the number of bytes that would be
3346 copied. As a special case, return 0 if an ordinary "syntax error"
3347 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3348 size calculation. */
3349static YYSIZE_T
3350yysyntax_error (char *yyresult, int yystate, int yychar)
3351{
3352 int yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003353
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003354 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3355 return 0;
3356 else
3357 {
3358 int yytype = YYTRANSLATE (yychar);
3359 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3360 YYSIZE_T yysize = yysize0;
3361 YYSIZE_T yysize1;
3362 int yysize_overflow = 0;
3363 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3364 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3365 int yyx;
3366
3367# if 0
3368 /* This is so xgettext sees the translatable formats that are
3369 constructed on the fly. */
3370 YY_("syntax error, unexpected %s");
3371 YY_("syntax error, unexpected %s, expecting %s");
3372 YY_("syntax error, unexpected %s, expecting %s or %s");
3373 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3374 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3375# endif
3376 char *yyfmt;
3377 char const *yyf;
3378 static char const yyunexpected[] = "syntax error, unexpected %s";
3379 static char const yyexpecting[] = ", expecting %s";
3380 static char const yyor[] = " or %s";
3381 char yyformat[sizeof yyunexpected
3382 + sizeof yyexpecting - 1
3383 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3384 * (sizeof yyor - 1))];
3385 char const *yyprefix = yyexpecting;
3386
3387 /* Start YYX at -YYN if negative to avoid negative indexes in
3388 YYCHECK. */
3389 int yyxbegin = yyn < 0 ? -yyn : 0;
3390
3391 /* Stay within bounds of both yycheck and yytname. */
3392 int yychecklim = YYLAST - yyn + 1;
3393 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3394 int yycount = 1;
3395
3396 yyarg[0] = yytname[yytype];
3397 yyfmt = yystpcpy (yyformat, yyunexpected);
3398
3399 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3400 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3401 {
3402 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3403 {
3404 yycount = 1;
3405 yysize = yysize0;
3406 yyformat[sizeof yyunexpected - 1] = '\0';
3407 break;
3408 }
3409 yyarg[yycount++] = yytname[yyx];
3410 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3411 yysize_overflow |= (yysize1 < yysize);
3412 yysize = yysize1;
3413 yyfmt = yystpcpy (yyfmt, yyprefix);
3414 yyprefix = yyor;
3415 }
3416
3417 yyf = YY_(yyformat);
3418 yysize1 = yysize + yystrlen (yyf);
3419 yysize_overflow |= (yysize1 < yysize);
3420 yysize = yysize1;
3421
3422 if (yysize_overflow)
3423 return YYSIZE_MAXIMUM;
3424
3425 if (yyresult)
3426 {
3427 /* Avoid sprintf, as that infringes on the user's name space.
3428 Don't have undefined behavior even if the translation
3429 produced a string with the wrong number of "%s"s. */
3430 char *yyp = yyresult;
3431 int yyi = 0;
3432 while ((*yyp = *yyf) != '\0')
3433 {
3434 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3435 {
3436 yyp += yytnamerr (yyp, yyarg[yyi++]);
3437 yyf += 2;
3438 }
3439 else
3440 {
3441 yyp++;
3442 yyf++;
3443 }
3444 }
3445 }
3446 return yysize;
3447 }
3448}
3449#endif /* YYERROR_VERBOSE */
Reid Spencere7c3c602006-11-30 06:36:44 +00003450
3451
Reid Spencer319a7302007-01-05 17:20:02 +00003452/*-----------------------------------------------.
3453| Release the memory associated to this symbol. |
3454`-----------------------------------------------*/
3455
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003456/*ARGSUSED*/
3457#if (defined __STDC__ || defined __C99__FUNC__ \
3458 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00003459static void
3460yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003461#else
Reid Spencer950bf602007-01-26 08:19:09 +00003462static void
3463yydestruct (yymsg, yytype, yyvaluep)
3464 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003465 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003466 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003467#endif
3468{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003469 YYUSE (yyvaluep);
Reid Spencer950bf602007-01-26 08:19:09 +00003470
3471 if (!yymsg)
3472 yymsg = "Deleting";
3473 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003474
3475 switch (yytype)
3476 {
Reid Spencer950bf602007-01-26 08:19:09 +00003477
Reid Spencer319a7302007-01-05 17:20:02 +00003478 default:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003479 break;
Reid Spencer319a7302007-01-05 17:20:02 +00003480 }
3481}
3482
3483
Reid Spencer950bf602007-01-26 08:19:09 +00003484/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003485
3486#ifdef YYPARSE_PARAM
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003487#if defined __STDC__ || defined __cplusplus
Reid Spencer950bf602007-01-26 08:19:09 +00003488int yyparse (void *YYPARSE_PARAM);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003489#else
Reid Spencer950bf602007-01-26 08:19:09 +00003490int yyparse ();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003491#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003492#else /* ! YYPARSE_PARAM */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003493#if defined __STDC__ || defined __cplusplus
Reid Spencere7c3c602006-11-30 06:36:44 +00003494int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003495#else
3496int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003497#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003498#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003499
3500
Reid Spencer950bf602007-01-26 08:19:09 +00003501
3502/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003503int yychar;
3504
Reid Spencer950bf602007-01-26 08:19:09 +00003505/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003506YYSTYPE yylval;
3507
Reid Spencer950bf602007-01-26 08:19:09 +00003508/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003509int yynerrs;
3510
3511
Reid Spencer950bf602007-01-26 08:19:09 +00003512
3513/*----------.
3514| yyparse. |
3515`----------*/
3516
3517#ifdef YYPARSE_PARAM
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003518#if (defined __STDC__ || defined __C99__FUNC__ \
3519 || defined __cplusplus || defined _MSC_VER)
3520int
3521yyparse (void *YYPARSE_PARAM)
3522#else
3523int
3524yyparse (YYPARSE_PARAM)
3525 void *YYPARSE_PARAM;
3526#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003527#else /* ! YYPARSE_PARAM */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003528#if (defined __STDC__ || defined __C99__FUNC__ \
3529 || defined __cplusplus || defined _MSC_VER)
Reid Spencer319a7302007-01-05 17:20:02 +00003530int
Reid Spencer950bf602007-01-26 08:19:09 +00003531yyparse (void)
3532#else
3533int
3534yyparse ()
3535
3536#endif
3537#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003538{
3539
Reid Spencer950bf602007-01-26 08:19:09 +00003540 int yystate;
3541 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003542 int yyresult;
3543 /* Number of tokens to shift before error messages enabled. */
3544 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003545 /* Look-ahead token as an internal (translated) token number. */
3546 int yytoken = 0;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003547#if YYERROR_VERBOSE
3548 /* Buffer for error messages, and its allocated size. */
3549 char yymsgbuf[128];
3550 char *yymsg = yymsgbuf;
3551 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3552#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003553
3554 /* Three stacks and their tools:
3555 `yyss': related to states,
3556 `yyvs': related to semantic values,
3557 `yyls': related to locations.
3558
3559 Refer to the stacks thru separate pointers, to allow yyoverflow
3560 to reallocate them elsewhere. */
3561
3562 /* The state stack. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003563 yytype_int16 yyssa[YYINITDEPTH];
3564 yytype_int16 *yyss = yyssa;
3565 yytype_int16 *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003566
3567 /* The semantic value stack. */
3568 YYSTYPE yyvsa[YYINITDEPTH];
3569 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003570 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003571
3572
3573
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003574#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
Reid Spencere7c3c602006-11-30 06:36:44 +00003575
Reid Spencer319a7302007-01-05 17:20:02 +00003576 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003577
Reid Spencer319a7302007-01-05 17:20:02 +00003578 /* The variables used to return semantic value and location from the
3579 action routines. */
3580 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003581
3582
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003583 /* The number of symbols on the RHS of the reduced rule.
3584 Keep to zero when no symbol should be popped. */
3585 int yylen = 0;
Reid Spencere7c3c602006-11-30 06:36:44 +00003586
Reid Spencer319a7302007-01-05 17:20:02 +00003587 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003588
3589 yystate = 0;
3590 yyerrstatus = 0;
3591 yynerrs = 0;
3592 yychar = YYEMPTY; /* Cause a token to be read. */
3593
3594 /* Initialize stack pointers.
3595 Waste one element of value and location stack
3596 so that they stay on the same level as the state stack.
3597 The wasted elements are never initialized. */
3598
Reid Spencer319a7302007-01-05 17:20:02 +00003599 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003600 yyvsp = yyvs;
3601
Reid Spencer319a7302007-01-05 17:20:02 +00003602 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003603
Reid Spencer319a7302007-01-05 17:20:02 +00003604/*------------------------------------------------------------.
3605| yynewstate -- Push a new state, which is found in yystate. |
3606`------------------------------------------------------------*/
3607 yynewstate:
3608 /* In all cases, when you get here, the value and location stacks
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003609 have just been pushed. So pushing a state here evens the stacks. */
Reid Spencer319a7302007-01-05 17:20:02 +00003610 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003611
Reid Spencer319a7302007-01-05 17:20:02 +00003612 yysetstate:
3613 *yyssp = yystate;
3614
Reid Spencer950bf602007-01-26 08:19:09 +00003615 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003616 {
3617 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003618 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003619
3620#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003621 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003622 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer319a7302007-01-05 17:20:02 +00003623 these so that the &'s don't force the real ones into
3624 memory. */
3625 YYSTYPE *yyvs1 = yyvs;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003626 yytype_int16 *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003627
Reid Spencer319a7302007-01-05 17:20:02 +00003628
3629 /* Each stack pointer address is followed by the size of the
3630 data in use in that stack, in bytes. This used to be a
3631 conditional around just the two extra args, but that might
3632 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003633 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003634 &yyss1, yysize * sizeof (*yyssp),
3635 &yyvs1, yysize * sizeof (*yyvsp),
3636
3637 &yystacksize);
3638
3639 yyss = yyss1;
3640 yyvs = yyvs1;
3641 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003642#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003643# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003644 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003645# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003646 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003647 if (YYMAXDEPTH <= yystacksize)
3648 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003649 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003650 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003651 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003652
3653 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003654 yytype_int16 *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003655 union yyalloc *yyptr =
3656 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3657 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003658 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003659 YYSTACK_RELOCATE (yyss);
3660 YYSTACK_RELOCATE (yyvs);
3661
3662# undef YYSTACK_RELOCATE
3663 if (yyss1 != yyssa)
3664 YYSTACK_FREE (yyss1);
3665 }
3666# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003667#endif /* no yyoverflow */
3668
Reid Spencer319a7302007-01-05 17:20:02 +00003669 yyssp = yyss + yysize - 1;
3670 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003671
3672
Reid Spencer319a7302007-01-05 17:20:02 +00003673 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3674 (unsigned long int) yystacksize));
3675
Reid Spencer950bf602007-01-26 08:19:09 +00003676 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003677 YYABORT;
3678 }
3679
Reid Spencer319a7302007-01-05 17:20:02 +00003680 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003681
3682 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003683
3684/*-----------.
3685| yybackup. |
3686`-----------*/
3687yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003688
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003689 /* Do appropriate processing given the current state. Read a
3690 look-ahead token if we need one and don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003691
Reid Spencer950bf602007-01-26 08:19:09 +00003692 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003693 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003694 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003695 goto yydefault;
3696
Reid Spencer950bf602007-01-26 08:19:09 +00003697 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003698
Reid Spencer950bf602007-01-26 08:19:09 +00003699 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003700 if (yychar == YYEMPTY)
3701 {
Reid Spencer319a7302007-01-05 17:20:02 +00003702 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003703 yychar = YYLEX;
3704 }
3705
Reid Spencer950bf602007-01-26 08:19:09 +00003706 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003707 {
Reid Spencer950bf602007-01-26 08:19:09 +00003708 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003709 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003710 }
3711 else
3712 {
Reid Spencer950bf602007-01-26 08:19:09 +00003713 yytoken = YYTRANSLATE (yychar);
3714 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003715 }
3716
Reid Spencer950bf602007-01-26 08:19:09 +00003717 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003718 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003719 yyn += yytoken;
3720 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003721 goto yydefault;
3722 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003723 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003724 {
Reid Spencer319a7302007-01-05 17:20:02 +00003725 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003726 goto yyerrlab;
3727 yyn = -yyn;
3728 goto yyreduce;
3729 }
3730
3731 if (yyn == YYFINAL)
3732 YYACCEPT;
3733
Reid Spencer319a7302007-01-05 17:20:02 +00003734 /* Count tokens shifted since error; after three, turn off error
3735 status. */
3736 if (yyerrstatus)
3737 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003738
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003739 /* Shift the look-ahead token. */
3740 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3741
3742 /* Discard the shifted token unless it is eof. */
3743 if (yychar != YYEOF)
3744 yychar = YYEMPTY;
3745
Reid Spencere7c3c602006-11-30 06:36:44 +00003746 yystate = yyn;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003747 *++yyvsp = yylval;
3748
Reid Spencere7c3c602006-11-30 06:36:44 +00003749 goto yynewstate;
3750
Chris Lattner37e01c52007-01-04 18:46:42 +00003751
Reid Spencer319a7302007-01-05 17:20:02 +00003752/*-----------------------------------------------------------.
3753| yydefault -- do the default action for the current state. |
3754`-----------------------------------------------------------*/
3755yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003756 yyn = yydefact[yystate];
3757 if (yyn == 0)
3758 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003759 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003760
Reid Spencer319a7302007-01-05 17:20:02 +00003761
3762/*-----------------------------.
3763| yyreduce -- Do a reduction. |
3764`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003765yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003766 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003767 yylen = yyr2[yyn];
3768
Reid Spencer319a7302007-01-05 17:20:02 +00003769 /* If YYLEN is nonzero, implement the default value of the action:
3770 `$$ = $1'.
3771
3772 Otherwise, the following line sets YYVAL to garbage.
3773 This behavior is undocumented and Bison
3774 users should not rely upon it. Assigning to YYVAL
3775 unconditionally makes the parser a bit smaller, and it avoids a
3776 GCC warning that YYVAL may be used uninitialized. */
3777 yyval = yyvsp[1-yylen];
3778
3779
Reid Spencer950bf602007-01-26 08:19:09 +00003780 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003781 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003782 {
Reid Spencer950bf602007-01-26 08:19:09 +00003783 case 3:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003784#line 1480 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003785 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003786 if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003787 error("Value too large for type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003788 (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003789 ;}
3790 break;
3791
3792 case 5:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003793#line 1489 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003794 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003795 if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003796 error("Value too large for type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003797 (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003798 ;}
3799 break;
3800
3801 case 26:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003802#line 1511 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003803 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3804 break;
3805
3806 case 27:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003807#line 1511 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003808 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3809 break;
3810
3811 case 28:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003812#line 1512 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003813 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3814 break;
3815
3816 case 29:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003817#line 1512 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003818 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3819 break;
3820
3821 case 30:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003822#line 1513 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003823 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3824 break;
3825
3826 case 31:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003827#line 1513 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003828 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3829 break;
3830
3831 case 32:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003832#line 1514 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003833 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3834 break;
3835
3836 case 33:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003837#line 1514 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003838 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3839 break;
3840
3841 case 34:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003842#line 1515 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003843 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3844 break;
3845
3846 case 35:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003847#line 1515 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003848 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3849 break;
3850
3851 case 36:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003852#line 1519 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003853 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3854 break;
3855
3856 case 37:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003857#line 1519 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003858 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3859 break;
3860
3861 case 38:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003862#line 1520 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003863 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3864 break;
3865
3866 case 39:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003867#line 1520 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003868 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3869 break;
3870
3871 case 40:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003872#line 1521 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003873 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3874 break;
3875
3876 case 41:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003877#line 1521 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003878 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3879 break;
3880
3881 case 42:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003882#line 1522 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003883 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3884 break;
3885
3886 case 43:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003887#line 1522 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003888 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3889 break;
3890
3891 case 44:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003892#line 1523 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003893 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3894 break;
3895
3896 case 45:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003897#line 1523 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003898 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3899 break;
3900
3901 case 46:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003902#line 1524 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003903 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3904 break;
3905
3906 case 47:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003907#line 1524 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003908 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3909 break;
3910
3911 case 48:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003912#line 1525 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003913 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3914 break;
3915
3916 case 49:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003917#line 1525 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003918 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3919 break;
3920
3921 case 50:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003922#line 1526 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003923 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3924 break;
3925
3926 case 51:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003927#line 1527 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003928 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3929 break;
3930
3931 case 81:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003932#line 1558 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003933 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003934 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003935 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003936 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003937
Reid Spencer319a7302007-01-05 17:20:02 +00003938 case 82:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003939#line 1561 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003940 {
Reid Spencer950bf602007-01-26 08:19:09 +00003941 (yyval.StrVal) = 0;
3942 ;}
3943 break;
3944
3945 case 83:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003946#line 1566 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003947 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3948 break;
3949
3950 case 84:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003951#line 1567 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003952 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3953 break;
3954
3955 case 85:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003956#line 1568 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003957 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3958 break;
3959
3960 case 86:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003961#line 1569 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003962 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3963 break;
3964
3965 case 87:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003966#line 1570 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003967 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3968 break;
3969
3970 case 88:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003971#line 1571 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003972 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3973 break;
3974
3975 case 89:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003976#line 1572 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003977 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003978 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003979
Reid Spencer319a7302007-01-05 17:20:02 +00003980 case 90:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003981#line 1573 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003982 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3983 break;
3984
3985 case 91:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003986#line 1577 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003987 { (yyval.UIntVal) = CallingConv::C; ;}
3988 break;
3989
3990 case 92:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003991#line 1578 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003992 { (yyval.UIntVal) = CallingConv::C; ;}
3993 break;
3994
3995 case 93:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003996#line 1579 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
3997 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00003998 break;
3999
4000 case 94:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004001#line 1580 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004002 { (yyval.UIntVal) = CallingConv::Fast; ;}
4003 break;
4004
4005 case 95:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004006#line 1581 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004007 { (yyval.UIntVal) = CallingConv::Cold; ;}
4008 break;
4009
4010 case 96:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004011#line 1582 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004012 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004013 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00004014
Reid Spencer319a7302007-01-05 17:20:02 +00004015 case 97:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004016#line 1583 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004017 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004018 break;
Reid Spencer16244f42006-12-01 21:10:07 +00004019
Reid Spencer319a7302007-01-05 17:20:02 +00004020 case 98:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004021#line 1584 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004022 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004023 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004024 error("Calling conv too large");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004025 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00004026 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004027 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00004028
Reid Spencer319a7302007-01-05 17:20:02 +00004029 case 99:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004030#line 1594 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004031 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004032 break;
4033
Reid Spencerc4d96252007-01-13 00:03:30 +00004034 case 100:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004035#line 1595 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004036 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004037 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00004038 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4039 error("Alignment must be a power of two");
4040 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004041 break;
4042
4043 case 101:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004044#line 1603 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004045 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004046 break;
4047
4048 case 102:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004049#line 1604 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004050 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004051 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00004052 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4053 error("Alignment must be a power of two");
4054 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004055 break;
4056
4057 case 103:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004058#line 1612 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004059 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004060 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
4061 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00004062 error("Invalid character in section name");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004063 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004064 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004065 break;
4066
4067 case 104:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004068#line 1621 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004069 { (yyval.StrVal) = 0; ;}
4070 break;
4071
4072 case 105:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004073#line 1622 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4074 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004075 break;
4076
Reid Spencerc4d96252007-01-13 00:03:30 +00004077 case 106:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004078#line 1629 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004079 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004080 break;
4081
Reid Spencer319a7302007-01-05 17:20:02 +00004082 case 107:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004083#line 1630 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004084 {;}
4085 break;
4086
4087 case 108:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004088#line 1634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004089 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004090 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
4091 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004092 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004093 break;
4094
4095 case 109:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004096#line 1638 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004097 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004098 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004099 error("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004100 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004101
4102 ;}
4103 break;
4104
4105 case 111:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004106#line 1655 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004107 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004108 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00004109 (yyval.TypeVal).S = Signless;
4110 ;}
4111 break;
4112
4113 case 113:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004114#line 1663 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004115 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004116 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00004117 (yyval.TypeVal).S = Signless;
4118 ;}
4119 break;
4120
4121 case 114:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004122#line 1670 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004123 {
4124 if (!UpRefs.empty())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004125 error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).T)->getDescription());
4126 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004127 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004128 break;
4129
4130 case 127:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004131#line 1684 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004132 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004133 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4134 (yyval.TypeVal).S = (yyvsp[(1) - (1)].PrimType).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004135 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004136 break;
4137
4138 case 128:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004139#line 1688 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004140 {
4141 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4142 (yyval.TypeVal).S = Signless;
4143 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004144 break;
4145
4146 case 129:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004147#line 1692 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004148 { // Named types are also simple types...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004149 const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004150 (yyval.TypeVal).T = new PATypeHolder(tmp);
4151 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4152 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004153 break;
4154
4155 case 130:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004156#line 1697 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004157 { // Type UpReference
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004158 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004159 error("Value out of range");
4160 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004161 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
Reid Spencer950bf602007-01-26 08:19:09 +00004162 (yyval.TypeVal).T = new PATypeHolder(OT);
4163 (yyval.TypeVal).S = Signless;
4164 UR_OUT("New Upreference!\n");
4165 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004166 break;
4167
4168 case 131:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004169#line 1706 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004170 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004171 std::vector<const Type*> Params;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004172 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
4173 E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004174 Params.push_back(I->T->get());
4175 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004176 }
Reid Spencer950bf602007-01-26 08:19:09 +00004177 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4178 if (isVarArg) Params.pop_back();
4179
4180 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004181 FunctionType::get((yyvsp[(1) - (4)].TypeVal).T->get(),Params,isVarArg)));
4182 (yyval.TypeVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4183 delete (yyvsp[(1) - (4)].TypeVal).T; // Delete the return type handle
4184 delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00004185 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004186 break;
4187
4188 case 132:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004189#line 1722 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004190 { // Sized array type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004191 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).T->get(),
4192 (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4193 (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4194 delete (yyvsp[(4) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004195 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004196 break;
4197
4198 case 133:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004199#line 1728 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004200 { // Packed array type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004201 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).T->get();
4202 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004203 error("Unsigned result not equal to signed result");
4204 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4205 error("Elements of a PackedType must be integer or floating point");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004206 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004207 error("PackedType length should be a power of 2");
4208 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004209 (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4210 (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4211 delete (yyvsp[(4) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004212 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004213 break;
4214
4215 case 134:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004216#line 1741 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004217 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004218 std::vector<const Type*> Elements;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004219 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4220 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Reid Spencer950bf602007-01-26 08:19:09 +00004221 Elements.push_back(I->T->get());
4222 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4223 (yyval.TypeVal).S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004224 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004225 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004226 break;
4227
4228 case 135:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004229#line 1750 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004230 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004231 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4232 (yyval.TypeVal).S = Signless;
4233 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004234 break;
4235
4236 case 136:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004237#line 1754 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004238 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004239 std::vector<const Type*> Elements;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004240 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4241 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004242 Elements.push_back(I->T->get());
4243 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004244 }
Reid Spencer950bf602007-01-26 08:19:09 +00004245 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4246 (yyval.TypeVal).S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004247 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004248 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004249 break;
4250
4251 case 137:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004252#line 1765 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004253 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004254 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4255 (yyval.TypeVal).S = Signless;
4256 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004257 break;
4258
4259 case 138:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004260#line 1769 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004261 { // Pointer type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004262 if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004263 error("Cannot form a pointer to a basic block");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004264 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).T->get())));
4265 (yyval.TypeVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4266 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004267 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004268 break;
4269
4270 case 139:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004271#line 1782 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004272 {
Reid Spencer950bf602007-01-26 08:19:09 +00004273 (yyval.TypeList) = new std::list<PATypeInfo>();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004274 (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004275 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004276 break;
4277
4278 case 140:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004279#line 1786 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004280 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004281 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004282 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004283 break;
4284
4285 case 142:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004286#line 1794 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004287 {
Reid Spencer950bf602007-01-26 08:19:09 +00004288 PATypeInfo VoidTI;
4289 VoidTI.T = new PATypeHolder(Type::VoidTy);
4290 VoidTI.S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004291 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
Reid Spencer950bf602007-01-26 08:19:09 +00004292 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004293 break;
4294
4295 case 143:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004296#line 1800 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004297 {
Reid Spencer950bf602007-01-26 08:19:09 +00004298 (yyval.TypeList) = new std::list<PATypeInfo>();
4299 PATypeInfo VoidTI;
4300 VoidTI.T = new PATypeHolder(Type::VoidTy);
4301 VoidTI.S = Signless;
4302 (yyval.TypeList)->push_back(VoidTI);
4303 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004304 break;
4305
4306 case 144:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004307#line 1807 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004308 {
Reid Spencer950bf602007-01-26 08:19:09 +00004309 (yyval.TypeList) = new std::list<PATypeInfo>();
4310 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004311 break;
4312
4313 case 145:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004314#line 1819 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004315 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004316 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004317 if (ATy == 0)
4318 error("Cannot make array constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004319 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004320 const Type *ETy = ATy->getElementType();
4321 int NumElements = ATy->getNumElements();
4322
4323 // Verify that we have the correct size...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004324 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004325 error("Type mismatch: constant sized array initialized with " +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004326 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004327 itostr(NumElements) + "");
4328
4329 // Verify all elements are correct type!
4330 std::vector<Constant*> Elems;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004331 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4332 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004333 const Type* ValTy = C->getType();
4334 if (ETy != ValTy)
4335 error("Element #" + utostr(i) + " is not of type '" +
4336 ETy->getDescription() +"' as required!\nIt is of type '"+
4337 ValTy->getDescription() + "'");
4338 Elems.push_back(C);
4339 }
4340 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004341 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4342 delete (yyvsp[(1) - (4)].TypeVal).T;
4343 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004344 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004345 break;
4346
4347 case 146:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004348#line 1849 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004349 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004350 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004351 if (ATy == 0)
4352 error("Cannot make array constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004353 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004354 int NumElements = ATy->getNumElements();
4355 if (NumElements != -1 && NumElements != 0)
4356 error("Type mismatch: constant sized array initialized with 0"
4357 " arguments, but has size of " + itostr(NumElements) +"");
4358 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004359 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4360 delete (yyvsp[(1) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004361 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004362 break;
4363
4364 case 147:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004365#line 1862 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004366 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004367 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004368 if (ATy == 0)
4369 error("Cannot make array constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004370 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004371 int NumElements = ATy->getNumElements();
4372 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4373 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4374 error("String arrays require type i8, not '" + ETy->getDescription() +
4375 "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004376 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4377 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004378 error("Can't build string constant of size " +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004379 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004380 itostr(NumElements) + "");
4381 std::vector<Constant*> Vals;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004382 for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004383 Vals.push_back(ConstantInt::get(ETy, *C));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004384 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004385 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004386 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4387 delete (yyvsp[(1) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004388 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004389 break;
4390
4391 case 148:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004392#line 1885 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004393 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004394 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[(1) - (4)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004395 if (PTy == 0)
4396 error("Cannot make packed constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004397 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004398 const Type *ETy = PTy->getElementType();
4399 int NumElements = PTy->getNumElements();
4400 // Verify that we have the correct size...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004401 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004402 error("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004403 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004404 itostr(NumElements) + "");
4405 // Verify all elements are correct type!
4406 std::vector<Constant*> Elems;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004407 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4408 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004409 const Type* ValTy = C->getType();
4410 if (ETy != ValTy)
4411 error("Element #" + utostr(i) + " is not of type '" +
4412 ETy->getDescription() +"' as required!\nIt is of type '"+
4413 ValTy->getDescription() + "'");
4414 Elems.push_back(C);
4415 }
4416 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004417 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4418 delete (yyvsp[(1) - (4)].TypeVal).T;
4419 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004420 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004421 break;
4422
4423 case 149:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004424#line 1913 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004425 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004426 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004427 if (STy == 0)
4428 error("Cannot make struct constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004429 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4430 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004431 error("Illegal number of initializers for structure type");
4432
4433 // Check to ensure that constants are compatible with the type initializer!
4434 std::vector<Constant*> Fields;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004435 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
4436 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004437 if (C->getType() != STy->getElementType(i))
4438 error("Expected type '" + STy->getElementType(i)->getDescription() +
4439 "' for element #" + utostr(i) + " of structure initializer");
4440 Fields.push_back(C);
4441 }
4442 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004443 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4444 delete (yyvsp[(1) - (4)].TypeVal).T;
4445 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004446 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004447 break;
4448
4449 case 150:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004450#line 1935 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004451 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004452 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004453 if (STy == 0)
4454 error("Cannot make struct constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004455 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004456 if (STy->getNumContainedTypes() != 0)
4457 error("Illegal number of initializers for structure type");
4458 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004459 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4460 delete (yyvsp[(1) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004461 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004462 break;
4463
4464 case 151:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004465#line 1946 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004466 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004467 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004468 if (STy == 0)
4469 error("Cannot make packed struct constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004470 (yyvsp[(1) - (6)].TypeVal).T->get()->getDescription() + "'");
4471 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004472 error("Illegal number of initializers for packed structure type");
4473
4474 // Check to ensure that constants are compatible with the type initializer!
4475 std::vector<Constant*> Fields;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004476 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
4477 Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004478 if (C->getType() != STy->getElementType(i))
4479 error("Expected type '" + STy->getElementType(i)->getDescription() +
4480 "' for element #" + utostr(i) + " of packed struct initializer");
4481 Fields.push_back(C);
4482 }
4483 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004484 (yyval.ConstVal).S = (yyvsp[(1) - (6)].TypeVal).S;
4485 delete (yyvsp[(1) - (6)].TypeVal).T;
4486 delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004487 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004488 break;
4489
4490 case 152:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004491#line 1968 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004492 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004493 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004494 if (STy == 0)
4495 error("Cannot make packed struct constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004496 (yyvsp[(1) - (5)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004497 if (STy->getNumContainedTypes() != 0)
4498 error("Illegal number of initializers for packed structure type");
4499 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004500 (yyval.ConstVal).S = (yyvsp[(1) - (5)].TypeVal).S;
4501 delete (yyvsp[(1) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004502 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004503 break;
4504
4505 case 153:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004506#line 1979 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004507 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004508 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004509 if (PTy == 0)
4510 error("Cannot make null pointer constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004511 (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004512 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004513 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4514 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004515 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004516 break;
4517
4518 case 154:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004519#line 1988 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004520 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004521 (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).T->get());
4522 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4523 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004524 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004525 break;
4526
4527 case 155:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004528#line 1993 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004529 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004530 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004531 if (Ty == 0)
4532 error("Global const reference must be a pointer type, not" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004533 (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004534
4535 // ConstExprs can exist in the body of a function, thus creating
4536 // GlobalValues whenever they refer to a variable. Because we are in
4537 // the context of a function, getExistingValue will search the functions
4538 // symbol table instead of the module symbol table for the global symbol,
4539 // which throws things all off. To get around this, we just tell
4540 // getExistingValue that we are at global scope here.
4541 //
4542 Function *SavedCurFn = CurFun.CurrentFunction;
4543 CurFun.CurrentFunction = 0;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004544 Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004545 CurFun.CurrentFunction = SavedCurFn;
4546
4547 // If this is an initializer for a constant pointer, which is referencing a
4548 // (currently) undefined variable, create a stub now that shall be replaced
4549 // in the future with the right type of variable.
4550 //
4551 if (V == 0) {
4552 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4553 const PointerType *PT = cast<PointerType>(Ty);
4554
4555 // First check to see if the forward references value is already created!
4556 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004557 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004558
4559 if (I != CurModule.GlobalRefs.end()) {
4560 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004561 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004562 } else {
4563 std::string Name;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004564 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004565
4566 // Create the forward referenced global.
4567 GlobalValue *GV;
4568 if (const FunctionType *FTy =
4569 dyn_cast<FunctionType>(PT->getElementType())) {
4570 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4571 CurModule.CurrentModule);
4572 } else {
4573 GV = new GlobalVariable(PT->getElementType(), false,
4574 GlobalValue::ExternalLinkage, 0,
4575 Name, CurModule.CurrentModule);
4576 }
4577
4578 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004579 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004580 V = GV;
4581 }
4582 }
4583 (yyval.ConstVal).C = cast<GlobalValue>(V);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004584 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4585 delete (yyvsp[(1) - (2)].TypeVal).T; // Free the type handle
Reid Spencer950bf602007-01-26 08:19:09 +00004586 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004587 break;
4588
4589 case 156:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004590#line 2051 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004591 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004592 if ((yyvsp[(1) - (2)].TypeVal).T->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004593 error("Mismatched types for constant expression");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004594 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4595 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4596 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004597 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004598 break;
4599
4600 case 157:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004601#line 2058 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004602 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004603 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004604 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4605 error("Cannot create a null initialized value of this type");
4606 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004607 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4608 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004609 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004610 break;
4611
4612 case 158:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004613#line 2066 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004614 { // integral constants
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004615 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4616 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004617 error("Constant value doesn't fit in type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004618 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004619 (yyval.ConstVal).S = Signed;
4620 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004621 break;
4622
4623 case 159:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004624#line 2073 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004625 { // integral constants
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004626 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4627 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004628 error("Constant value doesn't fit in type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004629 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004630 (yyval.ConstVal).S = Unsigned;
4631 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004632 break;
4633
4634 case 160:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004635#line 2080 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004636 { // Boolean constants
4637 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4638 (yyval.ConstVal).S = Unsigned;
4639 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004640 break;
4641
4642 case 161:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004643#line 2084 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004644 { // Boolean constants
4645 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4646 (yyval.ConstVal).S = Unsigned;
4647 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004648 break;
4649
4650 case 162:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004651#line 2088 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004652 { // Float & Double constants
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004653 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004654 error("Floating point constant invalid for type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004655 (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004656 (yyval.ConstVal).S = Signless;
4657 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004658 break;
4659
4660 case 163:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004661#line 2097 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004662 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004663 const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
4664 const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).T->get();
4665 Signedness SrcSign = (yyvsp[(3) - (6)].ConstVal).S;
4666 Signedness DstSign = (yyvsp[(5) - (6)].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004667 if (!SrcTy->isFirstClassType())
4668 error("cast constant expression from a non-primitive type: '" +
4669 SrcTy->getDescription() + "'");
4670 if (!DstTy->isFirstClassType())
4671 error("cast constant expression to a non-primitive type: '" +
4672 DstTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004673 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencer950bf602007-01-26 08:19:09 +00004674 (yyval.ConstVal).S = DstSign;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004675 delete (yyvsp[(5) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004676 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004677 break;
4678
4679 case 164:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004680#line 2112 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004681 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004682 const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004683 if (!isa<PointerType>(Ty))
4684 error("GetElementPtr requires a pointer operand");
4685
4686 std::vector<Value*> VIndices;
4687 std::vector<Constant*> CIndices;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004688 upgradeGEPIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004689
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004690 delete (yyvsp[(4) - (5)].ValueList);
4691 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004692 (yyval.ConstVal).S = Signless;
4693 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004694 break;
4695
4696 case 165:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004697#line 2125 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004698 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004699 if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
4700 cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004701 error("Select condition must be bool type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004702 if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004703 error("Select operand types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004704 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004705 (yyval.ConstVal).S = Unsigned;
4706 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004707 break;
4708
4709 case 166:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004710#line 2134 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004711 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004712 const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4713 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004714 error("Binary operator types must match");
4715 // First, make sure we're dealing with the right opcode by upgrading from
4716 // obsolete versions.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004717 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004718
4719 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4720 // To retain backward compatibility with these early compilers, we emit a
4721 // cast to the appropriate integer type automatically if we are in the
4722 // broken case. See PR424 for more information.
4723 if (!isa<PointerType>(Ty)) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004724 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004725 } else {
4726 const Type *IntPtrTy = 0;
4727 switch (CurModule.CurrentModule->getPointerSize()) {
4728 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4729 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4730 default: error("invalid pointer binary constant expr");
4731 }
4732 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004733 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
4734 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
Reid Spencer950bf602007-01-26 08:19:09 +00004735 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4736 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004737 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004738 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004739 break;
4740
4741 case 167:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004742#line 2162 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004743 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004744 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4745 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004746 error("Logical operator types must match");
4747 if (!Ty->isInteger()) {
4748 if (!isa<PackedType>(Ty) ||
4749 !cast<PackedType>(Ty)->getElementType()->isInteger())
4750 error("Logical operator requires integer operands");
4751 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004752 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
4753 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4754 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004755 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004756 break;
4757
4758 case 168:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004759#line 2175 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004760 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004761 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4762 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004763 error("setcc operand types must match");
4764 unsigned short pred;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004765 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
4766 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004767 (yyval.ConstVal).S = Unsigned;
4768 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004769 break;
4770
4771 case 169:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004772#line 2184 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004773 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004774 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004775 error("icmp operand types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004776 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004777 (yyval.ConstVal).S = Unsigned;
4778 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004779 break;
4780
4781 case 170:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004782#line 2190 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004783 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004784 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004785 error("fcmp operand types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004786 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004787 (yyval.ConstVal).S = Unsigned;
4788 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004789 break;
4790
4791 case 171:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004792#line 2196 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004793 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004794 if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
4795 cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004796 error("Shift count for shift constant must be unsigned byte");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004797 if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004798 error("Shift constant expression requires integer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004799 (yyval.ConstVal).C = ConstantExpr::get(getOtherOp((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(3) - (6)].ConstVal).S), (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4800 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004801 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004802 break;
4803
4804 case 172:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004805#line 2205 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004806 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004807 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004808 error("Invalid extractelement operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004809 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4810 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004811 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004812 break;
4813
4814 case 173:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004815#line 2211 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004816 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004817 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004818 error("Invalid insertelement operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004819 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4820 (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004821 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004822 break;
4823
4824 case 174:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004825#line 2217 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004826 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004827 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004828 error("Invalid shufflevector operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004829 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4830 (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004831 ;}
4832 break;
4833
4834 case 175:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004835#line 2228 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4836 { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004837 break;
4838
4839 case 176:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004840#line 2229 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004841 {
4842 (yyval.ConstVector) = new std::vector<ConstInfo>();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004843 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004844 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004845 break;
4846
4847 case 177:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004848#line 2238 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004849 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004850 break;
4851
4852 case 178:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004853#line 2239 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004854 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004855 break;
4856
4857 case 179:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004858#line 2251 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004859 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004860 (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004861 CurModule.ModuleDone();
4862 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004863 break;
4864
4865 case 180:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004866#line 2260 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4867 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004868 break;
4869
4870 case 181:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004871#line 2261 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4872 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004873 break;
4874
4875 case 182:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004876#line 2262 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4877 { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004878 break;
4879
4880 case 183:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004881#line 2263 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
4882 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004883 break;
4884
4885 case 184:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004886#line 2264 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004887 {
4888 (yyval.ModuleVal) = CurModule.CurrentModule;
4889 // Emit an error if there are any unresolved types left.
4890 if (!CurModule.LateResolveTypes.empty()) {
4891 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4892 if (DID.Type == ValID::NameVal) {
4893 error("Reference to an undefined type: '"+DID.getName() + "'");
4894 } else {
4895 error("Reference to an undefined type: #" + itostr(DID.Num));
4896 }
4897 }
4898 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004899 break;
4900
4901 case 185:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004902#line 2280 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004903 {
Reid Spencer950bf602007-01-26 08:19:09 +00004904 // Eagerly resolve types. This is not an optimization, this is a
4905 // requirement that is due to the fact that we could have this:
4906 //
4907 // %list = type { %list * }
4908 // %list = type { %list * } ; repeated type decl
4909 //
4910 // If types are not resolved eagerly, then the two types will not be
4911 // determined to be the same type!
4912 //
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004913 const Type* Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
4914 ResolveTypeTo((yyvsp[(2) - (4)].StrVal), Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004915
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004916 if (!setTypeName(Ty, (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
Reid Spencer950bf602007-01-26 08:19:09 +00004917 // If this is a named type that is not a redefinition, add it to the slot
4918 // table.
4919 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004920 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004921 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004922 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004923 break;
4924
4925 case 186:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004926#line 2300 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004927 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004928 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004929 break;
4930
4931 case 187:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004932#line 2302 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004933 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004934 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004935 break;
4936
4937 case 188:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004938#line 2304 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004939 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004940 if ((yyvsp[(5) - (5)].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00004941 error("Global value initializer is not a constant");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004942 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), (yyvsp[(3) - (5)].Linkage), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal).C->getType(), (yyvsp[(5) - (5)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004943 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004944 break;
4945
4946 case 189:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004947#line 2308 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004948 {
Reid Spencer950bf602007-01-26 08:19:09 +00004949 CurGV = 0;
4950 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004951 break;
4952
4953 case 190:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004954#line 2311 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004955 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004956 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
4957 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4958 delete (yyvsp[(5) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004959 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004960 break;
4961
4962 case 191:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004963#line 2315 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004964 {
Reid Spencer950bf602007-01-26 08:19:09 +00004965 CurGV = 0;
4966 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004967 break;
4968
4969 case 192:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004970#line 2318 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004971 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004972 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
4973 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4974 delete (yyvsp[(5) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004975 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004976 break;
4977
4978 case 193:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004979#line 2322 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004980 {
Reid Spencer950bf602007-01-26 08:19:09 +00004981 CurGV = 0;
4982 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004983 break;
4984
4985 case 194:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004986#line 2325 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004987 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004988 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004989 CurGV =
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004990 ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
4991 delete (yyvsp[(5) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004992 ;}
4993 break;
4994
4995 case 195:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004996#line 2330 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004997 {
4998 CurGV = 0;
4999 ;}
5000 break;
5001
5002 case 196:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005003#line 2333 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005004 {
Reid Spencer950bf602007-01-26 08:19:09 +00005005 ;}
5006 break;
5007
5008 case 197:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005009#line 2335 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005010 {
5011 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005012 break;
5013
5014 case 198:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005015#line 2337 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005016 {
5017 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005018 break;
5019
5020 case 199:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005021#line 2342 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005022 {
Reid Spencer950bf602007-01-26 08:19:09 +00005023 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005024 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
5025 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
5026 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005027
5028 if (AsmSoFar.empty())
5029 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5030 else
5031 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
5032 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005033 break;
5034
5035 case 200:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005036#line 2356 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005037 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005038 break;
5039
5040 case 201:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005041#line 2357 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005042 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005043 break;
5044
5045 case 202:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005046#line 2361 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005047 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005048 CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
Reid Spencer950bf602007-01-26 08:19:09 +00005049 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005050 break;
5051
5052 case 203:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005053#line 2364 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005054 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005055 if ((yyvsp[(3) - (3)].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00005056 CurModule.setPointerSize(Module::Pointer32);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005057 else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00005058 CurModule.setPointerSize(Module::Pointer64);
5059 else
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005060 error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00005061 ;}
5062 break;
5063
5064 case 204:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005065#line 2372 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005066 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005067 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
5068 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005069 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005070 break;
5071
5072 case 205:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005073#line 2376 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005074 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005075 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
5076 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005077 ;}
5078 break;
5079
5080 case 207:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005081#line 2387 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005082 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005083 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
5084 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005085 ;}
5086 break;
5087
5088 case 208:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005089#line 2391 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005090 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005091 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
5092 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005093 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005094 break;
5095
5096 case 209:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005097#line 2395 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005098 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005099 break;
5100
Reid Spencerc4d96252007-01-13 00:03:30 +00005101 case 213:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005102#line 2408 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005103 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005104 break;
5105
Reid Spencer319a7302007-01-05 17:20:02 +00005106 case 214:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005107#line 2412 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005108 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005109 if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::VoidTy)
Reid Spencer950bf602007-01-26 08:19:09 +00005110 error("void typed arguments are invalid");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005111 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005112 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005113 break;
5114
5115 case 215:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005116#line 2420 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005117 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005118 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5119 (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
5120 delete (yyvsp[(3) - (3)].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005121 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005122 break;
5123
5124 case 216:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005125#line 2425 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005126 {
5127 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005128 (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
5129 delete (yyvsp[(1) - (1)].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005130 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005131 break;
5132
5133 case 217:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005134#line 2433 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5135 { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005136 break;
5137
5138 case 218:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005139#line 2434 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005140 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005141 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Reid Spencer950bf602007-01-26 08:19:09 +00005142 PATypeInfo VoidTI;
5143 VoidTI.T = new PATypeHolder(Type::VoidTy);
5144 VoidTI.S = Signless;
5145 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5146 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005147 break;
5148
5149 case 219:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005150#line 2441 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005151 {
5152 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5153 PATypeInfo VoidTI;
5154 VoidTI.T = new PATypeHolder(Type::VoidTy);
5155 VoidTI.S = Signless;
5156 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5157 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005158 break;
5159
5160 case 220:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005161#line 2448 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005162 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005163 break;
5164
5165 case 221:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005166#line 2452 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005167 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005168 UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
5169 std::string FunctionName((yyvsp[(3) - (8)].StrVal));
5170 free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory!
Reid Spencer950bf602007-01-26 08:19:09 +00005171
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005172 const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005173
5174 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5175 error("LLVM functions cannot return aggregate types");
5176
5177 std::vector<const Type*> ParamTypeList;
5178
5179 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5180 // i8*. We check here for those names and override the parameter list
5181 // types to ensure the prototype is correct.
5182 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5183 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5184 } else if (FunctionName == "llvm.va_copy") {
5185 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5186 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005187 } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005188 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005189 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005190 const Type *Ty = I->first.T->get();
5191 ParamTypeList.push_back(Ty);
5192 }
5193 }
5194
5195 bool isVarArg =
5196 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5197 if (isVarArg) ParamTypeList.pop_back();
5198
5199 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
5200 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005201 delete (yyvsp[(2) - (8)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005202
5203 ValID ID;
5204 if (!FunctionName.empty()) {
5205 ID = ValID::create((char*)FunctionName.c_str());
5206 } else {
5207 ID = ValID::create((int)CurModule.Values[PFT].size());
5208 }
5209
5210 Function *Fn = 0;
5211 // See if this function was forward referenced. If so, recycle the object.
5212 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5213 // Move the function to the end of the list, from whereever it was
5214 // previously inserted.
5215 Fn = cast<Function>(FWRef);
5216 CurModule.CurrentModule->getFunctionList().remove(Fn);
5217 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5218 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5219 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5220 // If this is the case, either we need to be a forward decl, or it needs
5221 // to be.
5222 if (!CurFun.isDeclare && !Fn->isExternal())
5223 error("Redefinition of function '" + FunctionName + "'");
5224
5225 // Make sure to strip off any argument names so we can't get conflicts.
5226 if (Fn->isExternal())
5227 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5228 AI != AE; ++AI)
5229 AI->setName("");
5230 } else { // Not already defined?
5231 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5232 CurModule.CurrentModule);
5233
5234 InsertValue(Fn, CurModule.Values);
5235 }
5236
5237 CurFun.FunctionStart(Fn);
5238
5239 if (CurFun.isDeclare) {
5240 // If we have declaration, always overwrite linkage. This will allow us
5241 // to correctly handle cases, when pointer to function is passed as
5242 // argument to another function.
5243 Fn->setLinkage(CurFun.Linkage);
5244 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005245 Fn->setCallingConv((yyvsp[(1) - (8)].UIntVal));
5246 Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
5247 if ((yyvsp[(7) - (8)].StrVal)) {
5248 Fn->setSection((yyvsp[(7) - (8)].StrVal));
5249 free((yyvsp[(7) - (8)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005250 }
5251
5252 // Add all of the arguments we parsed to the function...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005253 if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005254 if (isVarArg) { // Nuke the last entry
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005255 assert((yyvsp[(5) - (8)].ArgList)->back().first.T->get() == Type::VoidTy &&
5256 (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
5257 delete (yyvsp[(5) - (8)].ArgList)->back().first.T;
5258 (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005259 }
5260 Function::arg_iterator ArgIt = Fn->arg_begin();
5261 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005262 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I, ++ArgIt) {
Reid Spencer950bf602007-01-26 08:19:09 +00005263 delete I->first.T; // Delete the typeholder...
5264 setValueName(ArgIt, I->second); // Insert arg into symtab...
5265 InsertValue(ArgIt);
5266 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005267 delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005268 }
5269 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005270 break;
5271
5272 case 224:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005273#line 2562 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005274 {
5275 (yyval.FunctionVal) = CurFun.CurrentFunction;
5276
5277 // Make sure that we keep track of the linkage type even if there was a
5278 // previous "declare".
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005279 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (3)].Linkage));
Reid Spencer950bf602007-01-26 08:19:09 +00005280 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005281 break;
5282
5283 case 227:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005284#line 2576 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005285 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005286 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005287 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005288 break;
5289
5290 case 229:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005291#line 2582 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005292 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5293 break;
5294
5295 case 230:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005296#line 2583 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005297 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5298 break;
5299
5300 case 231:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005301#line 2587 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005302 { CurFun.isDeclare = true; ;}
5303 break;
5304
5305 case 232:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005306#line 2587 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005307 {
5308 (yyval.FunctionVal) = CurFun.CurrentFunction;
5309 CurFun.FunctionDone();
5310
5311 ;}
5312 break;
5313
5314 case 233:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005315#line 2599 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005316 { (yyval.BoolVal) = false; ;}
5317 break;
5318
5319 case 234:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005320#line 2600 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005321 { (yyval.BoolVal) = true; ;}
5322 break;
5323
5324 case 235:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005325#line 2605 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5326 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005327 break;
5328
5329 case 236:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005330#line 2606 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5331 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005332 break;
5333
5334 case 237:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005335#line 2607 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5336 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005337 break;
5338
5339 case 238:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005340#line 2608 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005341 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005342 break;
5343
Reid Spencerc4d96252007-01-13 00:03:30 +00005344 case 239:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005345#line 2609 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005346 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5347 break;
5348
5349 case 240:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005350#line 2610 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005351 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005352 break;
5353
Reid Spencerc4d96252007-01-13 00:03:30 +00005354 case 241:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005355#line 2611 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005356 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5357 break;
5358
5359 case 242:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005360#line 2612 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005361 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5362 break;
5363
5364 case 243:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005365#line 2613 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005366 { // Nonempty unsized packed vector
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005367 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
5368 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer950bf602007-01-26 08:19:09 +00005369 PackedType* pt = PackedType::get(ETy, NumElements);
5370 PATypeHolder* PTy = new PATypeHolder(
5371 HandleUpRefs(PackedType::get(ETy, NumElements)));
5372
5373 // Verify all elements are correct type!
5374 std::vector<Constant*> Elems;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005375 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5376 Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005377 const Type *CTy = C->getType();
5378 if (ETy != CTy)
5379 error("Element #" + utostr(i) + " is not of type '" +
5380 ETy->getDescription() +"' as required!\nIt is of type '" +
5381 CTy->getDescription() + "'");
5382 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005383 }
Reid Spencer950bf602007-01-26 08:19:09 +00005384 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005385 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00005386 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005387 break;
5388
Reid Spencerc4d96252007-01-13 00:03:30 +00005389 case 244:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005390#line 2634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005391 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005392 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00005393 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005394 break;
5395
Reid Spencerc4d96252007-01-13 00:03:30 +00005396 case 245:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005397#line 2637 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005398 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005399 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5400 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5401 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5402 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5403 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5404 free((yyvsp[(3) - (5)].StrVal));
5405 free((yyvsp[(5) - (5)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005406 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005407 break;
5408
Reid Spencerc4d96252007-01-13 00:03:30 +00005409 case 246:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005410#line 2652 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5411 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005412 break;
5413
Reid Spencer319a7302007-01-05 17:20:02 +00005414 case 247:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005415#line 2653 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
5416 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005417 break;
5418
5419 case 250:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005420#line 2666 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005421 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005422 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
5423 (yyval.ValueVal).S = (yyvsp[(1) - (2)].TypeVal).S;
5424 (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
5425 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005426 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005427 break;
5428
Reid Spencerc4d96252007-01-13 00:03:30 +00005429 case 251:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005430#line 2675 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005431 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005432 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005433 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005434 break;
5435
Reid Spencerc4d96252007-01-13 00:03:30 +00005436 case 252:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005437#line 2678 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005438 { // Do not allow functions with 0 basic blocks
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005439 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005440 ;}
5441 break;
5442
5443 case 253:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005444#line 2687 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005445 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005446 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
5447 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5448 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5449 InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5450 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005451 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005452 break;
5453
Reid Spencerc4d96252007-01-13 00:03:30 +00005454 case 254:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005455#line 2697 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005456 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005457 if ((yyvsp[(2) - (2)].InstVal).I)
5458 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
5459 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005460 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005461 break;
5462
Reid Spencerc4d96252007-01-13 00:03:30 +00005463 case 255:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005464#line 2702 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005465 {
5466 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5467 // Make sure to move the basic block to the correct location in the
5468 // function, instead of leaving it inserted wherever it was first
5469 // referenced.
5470 Function::BasicBlockListType &BBL =
5471 CurFun.CurrentFunction->getBasicBlockList();
5472 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5473 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005474 break;
5475
Reid Spencerc4d96252007-01-13 00:03:30 +00005476 case 256:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005477#line 2711 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005478 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005479 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005480 // Make sure to move the basic block to the correct location in the
5481 // function, instead of leaving it inserted wherever it was first
5482 // referenced.
5483 Function::BasicBlockListType &BBL =
5484 CurFun.CurrentFunction->getBasicBlockList();
5485 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5486 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005487 break;
5488
Reid Spencerc4d96252007-01-13 00:03:30 +00005489 case 259:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005490#line 2725 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005491 { // Return with a result...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005492 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005493 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005494 break;
5495
Reid Spencerc4d96252007-01-13 00:03:30 +00005496 case 260:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005497#line 2728 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005498 { // Return with no result...
5499 (yyval.TermInstVal) = new ReturnInst();
5500 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005501 break;
5502
Reid Spencerc4d96252007-01-13 00:03:30 +00005503 case 261:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005504#line 2731 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005505 { // Unconditional Branch...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005506 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005507 (yyval.TermInstVal) = new BranchInst(tmpBB);
5508 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005509 break;
5510
Reid Spencer319a7302007-01-05 17:20:02 +00005511 case 262:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005512#line 2735 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005513 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005514 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5515 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5516 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005517 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5518 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005519 break;
5520
5521 case 263:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005522#line 2741 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005523 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005524 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
5525 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5526 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
Reid Spencer950bf602007-01-26 08:19:09 +00005527 (yyval.TermInstVal) = S;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005528 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5529 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005530 for (; I != E; ++I) {
5531 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5532 S->addCase(CI, I->second);
5533 else
5534 error("Switch case is constant, but not a simple integer");
5535 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005536 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer950bf602007-01-26 08:19:09 +00005537 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005538 break;
5539
5540 case 264:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005541#line 2756 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005542 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005543 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
5544 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005545 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5546 (yyval.TermInstVal) = S;
5547 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005548 break;
5549
Reid Spencerc4d96252007-01-13 00:03:30 +00005550 case 265:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005551#line 2763 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005552 {
Reid Spencer950bf602007-01-26 08:19:09 +00005553 const PointerType *PFTy;
5554 const FunctionType *Ty;
5555
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005556 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005557 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5558 // Pull out the types of all of the arguments...
5559 std::vector<const Type*> ParamTypes;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005560 if ((yyvsp[(6) - (13)].ValueList)) {
5561 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005562 I != E; ++I)
5563 ParamTypes.push_back((*I).V->getType());
5564 }
5565 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5566 if (isVarArg) ParamTypes.pop_back();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005567 Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).T->get(), ParamTypes, isVarArg);
Reid Spencer950bf602007-01-26 08:19:09 +00005568 PFTy = PointerType::get(Ty);
5569 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005570 Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling...
5571 BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
5572 BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005573
5574 // Create the call node...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005575 if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005576 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5577 } else { // Has arguments?
5578 // Loop through FunctionType's arguments and ensure they are specified
5579 // correctly!
5580 //
5581 FunctionType::param_iterator I = Ty->param_begin();
5582 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005583 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005584
5585 std::vector<Value*> Args;
5586 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5587 if ((*ArgI).V->getType() != *I)
5588 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5589 (*I)->getDescription() + "'");
5590 Args.push_back((*ArgI).V);
5591 }
5592
5593 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5594 error("Invalid number of parameters detected");
5595
5596 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5597 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005598 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[(2) - (13)].UIntVal));
5599 delete (yyvsp[(3) - (13)].TypeVal).T;
5600 delete (yyvsp[(6) - (13)].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005601 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005602 break;
5603
Reid Spencerc4d96252007-01-13 00:03:30 +00005604 case 266:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005605#line 2813 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005606 {
Reid Spencer950bf602007-01-26 08:19:09 +00005607 (yyval.TermInstVal) = new UnwindInst();
5608 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005609 break;
5610
Reid Spencerc4d96252007-01-13 00:03:30 +00005611 case 267:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005612#line 2816 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005613 {
5614 (yyval.TermInstVal) = new UnreachableInst();
5615 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005616 break;
5617
Reid Spencerc4d96252007-01-13 00:03:30 +00005618 case 268:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005619#line 2822 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005620 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005621 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5622 Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005623
5624 if (V == 0)
5625 error("May only switch on a constant pool value");
5626
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005627 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005628 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5629 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005630 break;
5631
Reid Spencerc4d96252007-01-13 00:03:30 +00005632 case 269:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005633#line 2832 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005634 {
Reid Spencer950bf602007-01-26 08:19:09 +00005635 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005636 Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005637
5638 if (V == 0)
5639 error("May only switch on a constant pool value");
5640
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005641 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005642 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5643 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005644 break;
5645
Reid Spencerc4d96252007-01-13 00:03:30 +00005646 case 270:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005647#line 2845 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005648 {
Reid Spencer950bf602007-01-26 08:19:09 +00005649 bool omit = false;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005650 if ((yyvsp[(1) - (2)].StrVal))
5651 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005652 if (BCI->getSrcTy() == BCI->getDestTy() &&
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005653 BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005654 // This is a useless bit cast causing a name redefinition. It is
5655 // a bit cast from a type to the same type of an operand with the
5656 // same name as the name we would give this instruction. Since this
5657 // instruction results in no code generation, it is safe to omit
5658 // the instruction. This situation can occur because of collapsed
5659 // type planes. For example:
5660 // %X = add int %Y, %Z
5661 // %X = cast int %Y to uint
5662 // After upgrade, this looks like:
5663 // %X = add i32 %Y, %Z
5664 // %X = bitcast i32 to i32
5665 // The bitcast is clearly useless so we omit it.
5666 omit = true;
5667 if (omit) {
5668 (yyval.InstVal).I = 0;
5669 (yyval.InstVal).S = Signless;
5670 } else {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005671 setValueName((yyvsp[(2) - (2)].InstVal).I, (yyvsp[(1) - (2)].StrVal));
5672 InsertValue((yyvsp[(2) - (2)].InstVal).I);
5673 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005674 }
5675 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005676 break;
5677
Reid Spencerc4d96252007-01-13 00:03:30 +00005678 case 271:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005679#line 2874 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005680 { // Used for PHI nodes
5681 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005682 (yyval.PHIList).S = (yyvsp[(1) - (6)].TypeVal).S;
5683 Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).T->get(), (yyvsp[(3) - (6)].ValIDVal));
5684 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005685 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005686 delete (yyvsp[(1) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005687 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005688 break;
5689
Reid Spencerc4d96252007-01-13 00:03:30 +00005690 case 272:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005691#line 2882 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005692 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005693 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5694 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
5695 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
5696 (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer950bf602007-01-26 08:19:09 +00005697 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005698 break;
5699
Reid Spencerc4d96252007-01-13 00:03:30 +00005700 case 273:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005701#line 2890 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005702 { // Used for call statements, and memory insts...
5703 (yyval.ValueList) = new std::vector<ValueInfo>();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005704 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005705 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005706 break;
5707
Reid Spencer950bf602007-01-26 08:19:09 +00005708 case 274:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005709#line 2894 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005710 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005711 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5712 (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005713 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005714 break;
5715
Reid Spencerc4d96252007-01-13 00:03:30 +00005716 case 276:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005717#line 2902 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005718 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005719 break;
5720
Reid Spencerc4d96252007-01-13 00:03:30 +00005721 case 277:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005722#line 2906 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005723 {
Reid Spencer950bf602007-01-26 08:19:09 +00005724 (yyval.BoolVal) = true;
5725 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005726 break;
5727
Reid Spencer319a7302007-01-05 17:20:02 +00005728 case 278:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005729#line 2909 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005730 {
Reid Spencer950bf602007-01-26 08:19:09 +00005731 (yyval.BoolVal) = false;
5732 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005733 break;
5734
5735 case 279:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005736#line 2915 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005737 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005738 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005739 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5740 error("Arithmetic operator requires integer, FP, or packed operands");
5741 if (isa<PackedType>(Ty) &&
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005742 ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp))
Reid Spencer950bf602007-01-26 08:19:09 +00005743 error("Remainder not supported on packed types");
5744 // Upgrade the opcode from obsolete versions before we do anything with it.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005745 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5746 Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5747 Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005748 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5749 if ((yyval.InstVal).I == 0)
5750 error("binary operator returned null");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005751 (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5752 delete (yyvsp[(2) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005753 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005754 break;
5755
5756 case 280:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005757#line 2932 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005758 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005759 const Type *Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005760 if (!Ty->isInteger()) {
5761 if (!isa<PackedType>(Ty) ||
5762 !cast<PackedType>(Ty)->getElementType()->isInteger())
5763 error("Logical operator requires integral operands");
5764 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005765 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5766 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5767 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005768 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5769 if ((yyval.InstVal).I == 0)
5770 error("binary operator returned null");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005771 (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5772 delete (yyvsp[(2) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005773 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005774 break;
5775
Reid Spencerc4d96252007-01-13 00:03:30 +00005776 case 281:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005777#line 2948 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005778 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005779 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005780 if(isa<PackedType>(Ty))
5781 error("PackedTypes currently not supported in setcc instructions");
5782 unsigned short pred;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005783 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
5784 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5785 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005786 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5787 if ((yyval.InstVal).I == 0)
5788 error("binary operator returned null");
5789 (yyval.InstVal).S = Unsigned;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005790 delete (yyvsp[(2) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005791 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005792 break;
5793
Reid Spencerc4d96252007-01-13 00:03:30 +00005794 case 282:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005795#line 2962 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005796 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005797 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005798 if (isa<PackedType>(Ty))
5799 error("PackedTypes currently not supported in icmp instructions");
5800 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5801 error("icmp requires integer or pointer typed operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005802 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5803 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5804 (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005805 (yyval.InstVal).S = Unsigned;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005806 delete (yyvsp[(3) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005807 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005808 break;
5809
Reid Spencerc4d96252007-01-13 00:03:30 +00005810 case 283:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005811#line 2974 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005812 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005813 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005814 if (isa<PackedType>(Ty))
5815 error("PackedTypes currently not supported in fcmp instructions");
5816 else if (!Ty->isFloatingPoint())
5817 error("fcmp instruction requires floating point operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005818 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5819 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5820 (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005821 (yyval.InstVal).S = Unsigned;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005822 delete (yyvsp[(3) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005823 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005824 break;
5825
Reid Spencerc4d96252007-01-13 00:03:30 +00005826 case 284:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005827#line 2986 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005828 {
Reid Spencer950bf602007-01-26 08:19:09 +00005829 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005830 const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005831 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5832 if (Ones == 0)
5833 error("Expected integral type for not instruction");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005834 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
Reid Spencer950bf602007-01-26 08:19:09 +00005835 if ((yyval.InstVal).I == 0)
5836 error("Could not create a xor instruction");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005837 (yyval.InstVal).S = (yyvsp[(2) - (2)].ValueVal).S
Reid Spencer950bf602007-01-26 08:19:09 +00005838 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005839 break;
5840
5841 case 285:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005842#line 2997 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005843 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005844 if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
5845 cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005846 error("Shift amount must be int8");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005847 if (!(yyvsp[(2) - (4)].ValueVal).V->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005848 error("Shift constant expression requires integer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005849 (yyval.InstVal).I = new ShiftInst(getOtherOp((yyvsp[(1) - (4)].OtherOpVal), (yyvsp[(2) - (4)].ValueVal).S), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
5850 (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005851 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005852 break;
5853
5854 case 286:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005855#line 3006 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005856 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005857 const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005858 if (!DstTy->isFirstClassType())
5859 error("cast instruction to a non-primitive type: '" +
5860 DstTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005861 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[(1) - (4)].CastOpVal), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(2) - (4)].ValueVal).S, DstTy, (yyvsp[(4) - (4)].TypeVal).S, true));
5862 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5863 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005864 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005865 break;
5866
5867 case 287:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005868#line 3015 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005869 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005870 if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
5871 cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005872 error("select condition must be bool");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005873 if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005874 error("select value types should match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005875 (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5876 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005877 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005878 break;
5879
Reid Spencerc4d96252007-01-13 00:03:30 +00005880 case 288:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005881#line 3024 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005882 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005883 const Type *Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005884 NewVarArgs = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005885 (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
5886 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5887 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005888 ;}
5889 break;
5890
5891 case 289:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005892#line 3031 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005893 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005894 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5895 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005896 ObsoleteVarArgs = true;
5897 Function* NF = cast<Function>(CurModule.CurrentModule->
5898 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5899
5900 //b = vaarg a, t ->
5901 //foo = alloca 1 of t
5902 //bar = vacopy a
5903 //store bar -> foo
5904 //b = vaarg foo, t
5905 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5906 CurBB->getInstList().push_back(foo);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005907 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005908 CurBB->getInstList().push_back(bar);
5909 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5910 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005911 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5912 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005913 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005914 break;
5915
Reid Spencerc4d96252007-01-13 00:03:30 +00005916 case 290:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005917#line 3052 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005918 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005919 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5920 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005921 ObsoleteVarArgs = true;
5922 Function* NF = cast<Function>(CurModule.CurrentModule->
5923 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5924
5925 //b = vanext a, t ->
5926 //foo = alloca 1 of t
5927 //bar = vacopy a
5928 //store bar -> foo
5929 //tmp = vaarg foo, t
5930 //b = load foo
5931 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5932 CurBB->getInstList().push_back(foo);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005933 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005934 CurBB->getInstList().push_back(bar);
5935 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5936 Instruction* tmp = new VAArgInst(foo, DstTy);
5937 CurBB->getInstList().push_back(tmp);
5938 (yyval.InstVal).I = new LoadInst(foo);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005939 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5940 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005941 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005942 break;
5943
Reid Spencerc4d96252007-01-13 00:03:30 +00005944 case 291:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005945#line 3076 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005946 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005947 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005948 error("Invalid extractelement operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005949 (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
5950 (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005951 ;}
5952 break;
5953
5954 case 292:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005955#line 3082 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005956 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005957 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005958 error("Invalid insertelement operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005959 (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5960 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005961 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005962 break;
5963
Reid Spencerc4d96252007-01-13 00:03:30 +00005964 case 293:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005965#line 3088 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005966 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005967 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00005968 error("Invalid shufflevector operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005969 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5970 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005971 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005972 break;
5973
Reid Spencerc4d96252007-01-13 00:03:30 +00005974 case 294:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005975#line 3094 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005976 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005977 const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005978 if (!Ty->isFirstClassType())
5979 error("PHI node operands must be of first class type");
5980 PHINode *PHI = new PHINode(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005981 PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
5982 while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
5983 if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00005984 error("All elements of a PHI node must be of the same type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005985 PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
5986 (yyvsp[(2) - (2)].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00005987 }
5988 (yyval.InstVal).I = PHI;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005989 (yyval.InstVal).S = (yyvsp[(2) - (2)].PHIList).S;
5990 delete (yyvsp[(2) - (2)].PHIList).P; // Free the list...
Reid Spencer950bf602007-01-26 08:19:09 +00005991 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005992 break;
5993
5994 case 295:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005995#line 3110 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005996 {
Reid Spencer950bf602007-01-26 08:19:09 +00005997
5998 // Handle the short call syntax
5999 const PointerType *PFTy;
6000 const FunctionType *FTy;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006001 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006002 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6003 // Pull out the types of all of the arguments...
6004 std::vector<const Type*> ParamTypes;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006005 if ((yyvsp[(6) - (7)].ValueList)) {
6006 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006007 I != E; ++I)
6008 ParamTypes.push_back((*I).V->getType());
6009 }
6010
6011 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6012 if (isVarArg) ParamTypes.pop_back();
6013
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006014 const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006015 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6016 error("Functions cannot return aggregate types");
6017
6018 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
6019 PFTy = PointerType::get(FTy);
6020 }
6021
6022 // First upgrade any intrinsic calls.
6023 std::vector<Value*> Args;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006024 if ((yyvsp[(6) - (7)].ValueList))
6025 for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i)
6026 Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
6027 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[(4) - (7)].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006028
6029 // If we got an upgraded intrinsic
6030 if (Inst) {
6031 (yyval.InstVal).I = Inst;
6032 (yyval.InstVal).S = Signless;
6033 } else {
6034 // Get the function we're calling
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006035 Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006036
6037 // Check the argument values match
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006038 if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006039 // Make sure no arguments is a good thing!
6040 if (FTy->getNumParams() != 0)
6041 error("No arguments passed to a function that expects arguments");
6042 } else { // Has arguments?
6043 // Loop through FunctionType's arguments and ensure they are specified
6044 // correctly!
6045 //
6046 FunctionType::param_iterator I = FTy->param_begin();
6047 FunctionType::param_iterator E = FTy->param_end();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006048 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006049
6050 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6051 if ((*ArgI).V->getType() != *I)
6052 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6053 (*I)->getDescription() + "'");
6054
6055 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6056 error("Invalid number of parameters detected");
6057 }
6058
6059 // Create the call instruction
6060 CallInst *CI = new CallInst(V, Args);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006061 CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
6062 CI->setCallingConv((yyvsp[(2) - (7)].UIntVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006063 (yyval.InstVal).I = CI;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006064 (yyval.InstVal).S = (yyvsp[(3) - (7)].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006065 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006066 delete (yyvsp[(3) - (7)].TypeVal).T;
6067 delete (yyvsp[(6) - (7)].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006068 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006069 break;
6070
Reid Spencerc4d96252007-01-13 00:03:30 +00006071 case 296:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006072#line 3183 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00006073 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006074 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00006075 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00006076 break;
6077
Reid Spencer609ca3e2007-01-12 20:10:51 +00006078 case 297:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006079#line 3191 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
6080 { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00006081 break;
6082
6083 case 298:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006084#line 3192 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006085 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006086 break;
6087
Reid Spencerc4d96252007-01-13 00:03:30 +00006088 case 299:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006089#line 3196 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006090 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006091 break;
6092
Reid Spencerc4d96252007-01-13 00:03:30 +00006093 case 300:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006094#line 3197 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006095 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006096 break;
6097
Reid Spencerc4d96252007-01-13 00:03:30 +00006098 case 301:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006099#line 3201 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006100 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006101 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6102 (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6103 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6104 delete (yyvsp[(2) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006105 ;}
6106 break;
6107
6108 case 302:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006109#line 3207 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006110 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006111 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6112 (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6113 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6114 delete (yyvsp[(2) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006115 ;}
6116 break;
6117
6118 case 303:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006119#line 3213 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006120 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006121 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6122 (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6123 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6124 delete (yyvsp[(2) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006125 ;}
6126 break;
6127
6128 case 304:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006129#line 3219 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006130 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006131 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6132 (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6133 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6134 delete (yyvsp[(2) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006135 ;}
6136 break;
6137
6138 case 305:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006139#line 3225 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006140 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006141 const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006142 if (!isa<PointerType>(PTy))
6143 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006144 (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006145 (yyval.InstVal).S = Signless;
6146 ;}
6147 break;
6148
6149 case 306:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006150#line 3232 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006151 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006152 const Type* Ty = (yyvsp[(3) - (4)].TypeVal).T->get();
6153 (yyval.InstVal).S = (yyvsp[(3) - (4)].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006154 if (!isa<PointerType>(Ty))
6155 error("Can't load from nonpointer type: " + Ty->getDescription());
6156 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6157 error("Can't load from pointer of non-first-class type: " +
6158 Ty->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006159 Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
6160 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
6161 delete (yyvsp[(3) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006162 ;}
6163 break;
6164
6165 case 307:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006166#line 3244 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006167 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006168 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00006169 if (!PTy)
6170 error("Can't store to a nonpointer type: " +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006171 (yyvsp[(5) - (6)].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00006172 const Type *ElTy = PTy->getElementType();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006173 if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType())
6174 error("Can't store '" + (yyvsp[(3) - (6)].ValueVal).V->getType()->getDescription() +
Reid Spencer950bf602007-01-26 08:19:09 +00006175 "' into space of type '" + ElTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006176 Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
6177 (yyval.InstVal).I = new StoreInst((yyvsp[(3) - (6)].ValueVal).V, tmpVal, (yyvsp[(1) - (6)].BoolVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006178 (yyval.InstVal).S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006179 delete (yyvsp[(5) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006180 ;}
6181 break;
6182
6183 case 308:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006184#line 3258 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006185 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006186 const Type* Ty = (yyvsp[(2) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006187 if (!isa<PointerType>(Ty))
6188 error("getelementptr insn requires pointer operand");
6189
6190 std::vector<Value*> VIndices;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006191 upgradeGEPIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006192
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006193 Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006194 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6195 (yyval.InstVal).S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006196 delete (yyvsp[(2) - (4)].TypeVal).T;
6197 delete (yyvsp[(4) - (4)].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006198 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006199 break;
6200
6201
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006202/* Line 1267 of yacc.c. */
6203#line 6204 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00006204 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006205 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006206 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
Reid Spencer319a7302007-01-05 17:20:02 +00006207
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006208 YYPOPSTACK (yylen);
6209 yylen = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00006210 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006211
6212 *++yyvsp = yyval;
6213
6214
Reid Spencer319a7302007-01-05 17:20:02 +00006215 /* Now `shift' the result of the reduction. Determine what state
6216 that goes to, based on the state we popped back to and the rule
6217 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006218
6219 yyn = yyr1[yyn];
6220
Reid Spencer319a7302007-01-05 17:20:02 +00006221 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6222 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006223 yystate = yytable[yystate];
6224 else
Reid Spencer319a7302007-01-05 17:20:02 +00006225 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006226
6227 goto yynewstate;
6228
6229
Reid Spencer319a7302007-01-05 17:20:02 +00006230/*------------------------------------.
6231| yyerrlab -- here on detecting error |
6232`------------------------------------*/
6233yyerrlab:
6234 /* If not already recovering from an error, report this error. */
6235 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006236 {
6237 ++yynerrs;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006238#if ! YYERROR_VERBOSE
6239 yyerror (YY_("syntax error"));
6240#else
6241 {
6242 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6243 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6244 {
6245 YYSIZE_T yyalloc = 2 * yysize;
6246 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6247 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6248 if (yymsg != yymsgbuf)
Reid Spencer319a7302007-01-05 17:20:02 +00006249 YYSTACK_FREE (yymsg);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006250 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6251 if (yymsg)
6252 yymsg_alloc = yyalloc;
6253 else
6254 {
6255 yymsg = yymsgbuf;
6256 yymsg_alloc = sizeof yymsgbuf;
6257 }
6258 }
6259
6260 if (0 < yysize && yysize <= yymsg_alloc)
6261 {
6262 (void) yysyntax_error (yymsg, yystate, yychar);
6263 yyerror (yymsg);
6264 }
6265 else
6266 {
6267 yyerror (YY_("syntax error"));
6268 if (yysize != 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006269 goto yyexhaustedlab;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006270 }
6271 }
6272#endif
Reid Spencere7c3c602006-11-30 06:36:44 +00006273 }
Reid Spencer950bf602007-01-26 08:19:09 +00006274
6275
6276
6277 if (yyerrstatus == 3)
6278 {
6279 /* If just tried and failed to reuse look-ahead token after an
6280 error, discard it. */
6281
6282 if (yychar <= YYEOF)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006283 {
Reid Spencer950bf602007-01-26 08:19:09 +00006284 /* Return failure if at end of input. */
6285 if (yychar == YYEOF)
6286 YYABORT;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006287 }
Reid Spencer950bf602007-01-26 08:19:09 +00006288 else
6289 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006290 yydestruct ("Error: discarding",
6291 yytoken, &yylval);
Reid Spencer950bf602007-01-26 08:19:09 +00006292 yychar = YYEMPTY;
6293 }
6294 }
6295
6296 /* Else will try to reuse look-ahead token after shifting the error
6297 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006298 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006299
Reid Spencer319a7302007-01-05 17:20:02 +00006300
Reid Spencer950bf602007-01-26 08:19:09 +00006301/*---------------------------------------------------.
6302| yyerrorlab -- error raised explicitly by YYERROR. |
6303`---------------------------------------------------*/
6304yyerrorlab:
6305
6306 /* Pacify compilers like GCC when the user code never invokes
6307 YYERROR and the label yyerrorlab therefore never appears in user
6308 code. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006309 if (/*CONSTCOND*/ 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006310 goto yyerrorlab;
6311
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006312 /* Do not reclaim the symbols of the rule which action triggered
6313 this YYERROR. */
6314 YYPOPSTACK (yylen);
6315 yylen = 0;
6316 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer950bf602007-01-26 08:19:09 +00006317 yystate = *yyssp;
6318 goto yyerrlab1;
6319
6320
6321/*-------------------------------------------------------------.
6322| yyerrlab1 -- common code for both syntax error and YYERROR. |
6323`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006324yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006325 yyerrstatus = 3; /* Each real token shifted decrements this. */
6326
6327 for (;;)
6328 {
6329 yyn = yypact[yystate];
6330 if (yyn != YYPACT_NINF)
6331 {
6332 yyn += YYTERROR;
6333 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6334 {
6335 yyn = yytable[yyn];
6336 if (0 < yyn)
6337 break;
6338 }
6339 }
6340
6341 /* Pop the current state because it cannot handle the error token. */
6342 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006343 YYABORT;
6344
6345
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006346 yydestruct ("Error: popping",
6347 yystos[yystate], yyvsp);
6348 YYPOPSTACK (1);
Reid Spencer950bf602007-01-26 08:19:09 +00006349 yystate = *yyssp;
6350 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006351 }
6352
6353 if (yyn == YYFINAL)
6354 YYACCEPT;
6355
6356 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006357
6358
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006359 /* Shift the error token. */
Reid Spencer950bf602007-01-26 08:19:09 +00006360 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6361
Reid Spencere7c3c602006-11-30 06:36:44 +00006362 yystate = yyn;
6363 goto yynewstate;
6364
Chris Lattner37e01c52007-01-04 18:46:42 +00006365
Reid Spencer319a7302007-01-05 17:20:02 +00006366/*-------------------------------------.
6367| yyacceptlab -- YYACCEPT comes here. |
6368`-------------------------------------*/
6369yyacceptlab:
6370 yyresult = 0;
6371 goto yyreturn;
6372
6373/*-----------------------------------.
6374| yyabortlab -- YYABORT comes here. |
6375`-----------------------------------*/
6376yyabortlab:
6377 yyresult = 1;
6378 goto yyreturn;
6379
6380#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006381/*-------------------------------------------------.
6382| yyexhaustedlab -- memory exhaustion comes here. |
6383`-------------------------------------------------*/
6384yyexhaustedlab:
6385 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006386 yyresult = 2;
6387 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006388#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006389
6390yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006391 if (yychar != YYEOF && yychar != YYEMPTY)
6392 yydestruct ("Cleanup: discarding lookahead",
6393 yytoken, &yylval);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006394 /* Do not reclaim the symbols of the rule which action triggered
6395 this YYABORT or YYACCEPT. */
6396 YYPOPSTACK (yylen);
6397 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer950bf602007-01-26 08:19:09 +00006398 while (yyssp != yyss)
6399 {
6400 yydestruct ("Cleanup: popping",
6401 yystos[*yyssp], yyvsp);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006402 YYPOPSTACK (1);
Reid Spencer950bf602007-01-26 08:19:09 +00006403 }
Reid Spencer319a7302007-01-05 17:20:02 +00006404#ifndef yyoverflow
6405 if (yyss != yyssa)
6406 YYSTACK_FREE (yyss);
6407#endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006408#if YYERROR_VERBOSE
6409 if (yymsg != yymsgbuf)
6410 YYSTACK_FREE (yymsg);
6411#endif
6412 /* Make sure YYID is used. */
6413 return YYID (yyresult);
Reid Spencere7c3c602006-11-30 06:36:44 +00006414}
Reid Spencer319a7302007-01-05 17:20:02 +00006415
6416
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006417#line 3274 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006418
6419
6420int yyerror(const char *ErrorMsg) {
6421 std::string where
6422 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006423 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6424 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6425 if (yychar != YYEMPTY && yychar != 0)
6426 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6427 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006428 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006429 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006430 exit(1);
6431}
Reid Spencer319a7302007-01-05 17:20:02 +00006432
Reid Spencer30d0c582007-01-15 00:26:18 +00006433void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006434 std::string where
6435 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006436 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6437 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6438 if (yychar != YYEMPTY && yychar != 0)
6439 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6440 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006441 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6442}
6443
Reid Spencer950bf602007-01-26 08:19:09 +00006444void error(const std::string& ErrorMsg, int LineNo) {
6445 if (LineNo == -1) LineNo = Upgradelineno;
6446 Upgradelineno = LineNo;
6447 yyerror(ErrorMsg.c_str());
6448}
6449
6450