blob: 914a87d71a821986d0cef105a1681e2a6ff6e78e [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
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000943/// @brief This just makes any name given to it unique, up to MAX_UINT times.
Reid Spencer950bf602007-01-26 08:19:09 +0000944static std::string makeNameUnique(const std::string& Name) {
945 static unsigned UniqueNameCounter = 1;
946 std::string Result(Name);
947 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
948 return Result;
949}
950
Anton Korobeynikovce13b852007-01-28 15:25:24 +0000951/// This is the implementation portion of TypeHasInteger. It traverses the
952/// type given, avoiding recursive types, and returns true as soon as it finds
953/// an integer type. If no integer type is found, it returns false.
954static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
955 // Handle some easy cases
956 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
957 return false;
958 if (Ty->isInteger())
959 return true;
960 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
961 return STy->getElementType()->isInteger();
962
963 // Avoid type structure recursion
964 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
965 I != E; ++I)
966 if (Ty == *I)
967 return false;
968
969 // Push us on the type stack
970 Stack.push_back(Ty);
971
972 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
973 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
974 return true;
975 FunctionType::param_iterator I = FTy->param_begin();
976 FunctionType::param_iterator E = FTy->param_end();
977 for (; I != E; ++I)
978 if (TypeHasIntegerI(*I, Stack))
979 return true;
980 return false;
981 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
982 StructType::element_iterator I = STy->element_begin();
983 StructType::element_iterator E = STy->element_end();
984 for (; I != E; ++I) {
985 if (TypeHasIntegerI(*I, Stack))
986 return true;
987 }
988 return false;
989 }
990 // There shouldn't be anything else, but its definitely not integer
991 assert(0 && "What type is this?");
992 return false;
993}
994
995/// This is the interface to TypeHasIntegerI. It just provides the type stack,
996/// to avoid recursion, and then calls TypeHasIntegerI.
997static inline bool TypeHasInteger(const Type *Ty) {
998 std::vector<const Type*> TyStack;
999 return TypeHasIntegerI(Ty, TyStack);
1000}
1001
Reid Spencer950bf602007-01-26 08:19:09 +00001002// setValueName - Set the specified value to the name given. The name may be
1003// null potentially, in which case this is a noop. The string passed in is
1004// assumed to be a malloc'd string buffer, and is free'd by this function.
1005//
1006static void setValueName(Value *V, char *NameStr) {
1007 if (NameStr) {
1008 std::string Name(NameStr); // Copy string
1009 free(NameStr); // Free old string
1010
1011 if (V->getType() == Type::VoidTy) {
1012 error("Can't assign name '" + Name + "' to value with void type");
1013 return;
1014 }
1015
Reid Spencer950bf602007-01-26 08:19:09 +00001016 assert(inFunctionScope() && "Must be in function scope");
1017
1018 // Search the function's symbol table for an existing value of this name
1019 Value* Existing = 0;
1020 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1021 SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
1022 for ( ; PI != PE; ++PI) {
1023 SymbolTable::value_const_iterator VI = PI->second.find(Name);
1024 if (VI != PI->second.end()) {
1025 Existing = VI->second;
1026 break;
1027 }
1028 }
1029 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001030 // An existing value of the same name was found. This might have happened
1031 // because of the integer type planes collapsing in LLVM 2.0.
1032 if (Existing->getType() == V->getType() &&
1033 !TypeHasInteger(Existing->getType())) {
1034 // If the type does not contain any integers in them then this can't be
1035 // a type plane collapsing issue. It truly is a redefinition and we
1036 // should error out as the assembly is invalid.
1037 error("Redefinition of value named '" + Name + "' of type '" +
1038 V->getType()->getDescription() + "'");
1039 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001040 }
1041 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1042 // function, regardless of Type. Previously re-use of names was okay as
1043 // long as they were distinct types. With type planes collapsing because
1044 // of the signedness change and because of PR411, this can no longer be
1045 // supported. We must search the entire symbol table for a conflicting
1046 // name and make the name unique. No warning is needed as this can't
1047 // cause a problem.
1048 std::string NewName = makeNameUnique(Name);
1049 // We're changing the name but it will probably be used by other
1050 // instructions as operands later on. Consequently we have to retain
1051 // a mapping of the renaming that we're doing.
1052 RenameMapKey Key = std::make_pair(Name,V->getType());
1053 CurFun.RenameMap[Key] = NewName;
1054 Name = NewName;
1055 }
1056
1057 // Set the name.
1058 V->setName(Name);
1059 }
1060}
1061
1062/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1063/// this is a declaration, otherwise it is a definition.
1064static GlobalVariable *
1065ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1066 bool isConstantGlobal, const Type *Ty,
1067 Constant *Initializer) {
1068 if (isa<FunctionType>(Ty))
1069 error("Cannot declare global vars of function type");
1070
1071 const PointerType *PTy = PointerType::get(Ty);
1072
1073 std::string Name;
1074 if (NameStr) {
1075 Name = NameStr; // Copy string
1076 free(NameStr); // Free old string
1077 }
1078
1079 // See if this global value was forward referenced. If so, recycle the
1080 // object.
1081 ValID ID;
1082 if (!Name.empty()) {
1083 ID = ValID::create((char*)Name.c_str());
1084 } else {
1085 ID = ValID::create((int)CurModule.Values[PTy].size());
1086 }
1087
1088 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1089 // Move the global to the end of the list, from whereever it was
1090 // previously inserted.
1091 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1092 CurModule.CurrentModule->getGlobalList().remove(GV);
1093 CurModule.CurrentModule->getGlobalList().push_back(GV);
1094 GV->setInitializer(Initializer);
1095 GV->setLinkage(Linkage);
1096 GV->setConstant(isConstantGlobal);
1097 InsertValue(GV, CurModule.Values);
1098 return GV;
1099 }
1100
1101 // If this global has a name, check to see if there is already a definition
1102 // of this global in the module and emit warnings if there are conflicts.
1103 if (!Name.empty()) {
1104 // The global has a name. See if there's an existing one of the same name.
1105 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1106 // We found an existing global ov the same name. This isn't allowed
1107 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1108 // can at least compile. This can happen because of type planes
1109 // There is alread a global of the same name which means there is a
1110 // conflict. Let's see what we can do about it.
1111 std::string NewName(makeNameUnique(Name));
1112 if (Linkage == GlobalValue::InternalLinkage) {
1113 // The linkage type is internal so just warn about the rename without
1114 // invoking "scarey language" about linkage failures. GVars with
1115 // InternalLinkage can be renamed at will.
1116 warning("Global variable '" + Name + "' was renamed to '"+
1117 NewName + "'");
1118 } else {
1119 // The linkage of this gval is external so we can't reliably rename
1120 // it because it could potentially create a linking problem.
1121 // However, we can't leave the name conflict in the output either or
1122 // it won't assemble with LLVM 2.0. So, all we can do is rename
1123 // this one to something unique and emit a warning about the problem.
1124 warning("Renaming global variable '" + Name + "' to '" + NewName +
1125 "' may cause linkage errors");
1126 }
1127
1128 // Put the renaming in the global rename map
1129 RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
1130 CurModule.RenameMap[Key] = NewName;
1131
1132 // Rename it
1133 Name = NewName;
1134 }
1135 }
1136
1137 // Otherwise there is no existing GV to use, create one now.
1138 GlobalVariable *GV =
1139 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1140 CurModule.CurrentModule);
1141 InsertValue(GV, CurModule.Values);
1142 return GV;
1143}
1144
1145// setTypeName - Set the specified type to the name given. The name may be
1146// null potentially, in which case this is a noop. The string passed in is
1147// assumed to be a malloc'd string buffer, and is freed by this function.
1148//
1149// This function returns true if the type has already been defined, but is
1150// allowed to be redefined in the specified context. If the name is a new name
1151// for the type plane, it is inserted and false is returned.
1152static bool setTypeName(const Type *T, char *NameStr) {
1153 assert(!inFunctionScope() && "Can't give types function-local names");
1154 if (NameStr == 0) return false;
1155
1156 std::string Name(NameStr); // Copy string
1157 free(NameStr); // Free old string
1158
1159 // We don't allow assigning names to void type
1160 if (T == Type::VoidTy) {
1161 error("Can't assign name '" + Name + "' to the void type");
1162 return false;
1163 }
1164
1165 // Set the type name, checking for conflicts as we do so.
1166 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1167
1168 if (AlreadyExists) { // Inserting a name that is already defined???
1169 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1170 assert(Existing && "Conflict but no matching type?");
1171
1172 // There is only one case where this is allowed: when we are refining an
1173 // opaque type. In this case, Existing will be an opaque type.
1174 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1175 // We ARE replacing an opaque type!
1176 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1177 return true;
1178 }
1179
1180 // Otherwise, this is an attempt to redefine a type. That's okay if
1181 // the redefinition is identical to the original. This will be so if
1182 // Existing and T point to the same Type object. In this one case we
1183 // allow the equivalent redefinition.
1184 if (Existing == T) return true; // Yes, it's equal.
1185
1186 // Any other kind of (non-equivalent) redefinition is an error.
1187 error("Redefinition of type named '" + Name + "' in the '" +
1188 T->getDescription() + "' type plane");
1189 }
1190
1191 return false;
1192}
1193
1194//===----------------------------------------------------------------------===//
1195// Code for handling upreferences in type names...
1196//
1197
1198// TypeContains - Returns true if Ty directly contains E in it.
1199//
1200static bool TypeContains(const Type *Ty, const Type *E) {
1201 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1202 E) != Ty->subtype_end();
1203}
1204
1205namespace {
1206 struct UpRefRecord {
1207 // NestingLevel - The number of nesting levels that need to be popped before
1208 // this type is resolved.
1209 unsigned NestingLevel;
1210
1211 // LastContainedTy - This is the type at the current binding level for the
1212 // type. Every time we reduce the nesting level, this gets updated.
1213 const Type *LastContainedTy;
1214
1215 // UpRefTy - This is the actual opaque type that the upreference is
1216 // represented with.
1217 OpaqueType *UpRefTy;
1218
1219 UpRefRecord(unsigned NL, OpaqueType *URTy)
1220 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1221 };
1222}
1223
1224// UpRefs - A list of the outstanding upreferences that need to be resolved.
1225static std::vector<UpRefRecord> UpRefs;
1226
1227/// HandleUpRefs - Every time we finish a new layer of types, this function is
1228/// called. It loops through the UpRefs vector, which is a list of the
1229/// currently active types. For each type, if the up reference is contained in
1230/// the newly completed type, we decrement the level count. When the level
1231/// count reaches zero, the upreferenced type is the type that is passed in:
1232/// thus we can complete the cycle.
1233///
1234static PATypeHolder HandleUpRefs(const Type *ty) {
1235 // If Ty isn't abstract, or if there are no up-references in it, then there is
1236 // nothing to resolve here.
1237 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1238
1239 PATypeHolder Ty(ty);
1240 UR_OUT("Type '" << Ty->getDescription() <<
1241 "' newly formed. Resolving upreferences.\n" <<
1242 UpRefs.size() << " upreferences active!\n");
1243
1244 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1245 // to zero), we resolve them all together before we resolve them to Ty. At
1246 // the end of the loop, if there is anything to resolve to Ty, it will be in
1247 // this variable.
1248 OpaqueType *TypeToResolve = 0;
1249
1250 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1251 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1252 << UpRefs[i].second->getDescription() << ") = "
1253 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1254 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1255 // Decrement level of upreference
1256 unsigned Level = --UpRefs[i].NestingLevel;
1257 UpRefs[i].LastContainedTy = Ty;
1258 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1259 if (Level == 0) { // Upreference should be resolved!
1260 if (!TypeToResolve) {
1261 TypeToResolve = UpRefs[i].UpRefTy;
1262 } else {
1263 UR_OUT(" * Resolving upreference for "
1264 << UpRefs[i].second->getDescription() << "\n";
1265 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1266 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1267 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1268 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1269 }
1270 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1271 --i; // Do not skip the next element...
1272 }
1273 }
1274 }
1275
1276 if (TypeToResolve) {
1277 UR_OUT(" * Resolving upreference for "
1278 << UpRefs[i].second->getDescription() << "\n";
1279 std::string OldName = TypeToResolve->getDescription());
1280 TypeToResolve->refineAbstractTypeTo(Ty);
1281 }
1282
1283 return Ty;
1284}
1285
1286static inline Instruction::TermOps
1287getTermOp(TermOps op) {
1288 switch (op) {
1289 default : assert(0 && "Invalid OldTermOp");
1290 case RetOp : return Instruction::Ret;
1291 case BrOp : return Instruction::Br;
1292 case SwitchOp : return Instruction::Switch;
1293 case InvokeOp : return Instruction::Invoke;
1294 case UnwindOp : return Instruction::Unwind;
1295 case UnreachableOp: return Instruction::Unreachable;
1296 }
1297}
1298
1299static inline Instruction::BinaryOps
1300getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) {
1301 switch (op) {
1302 default : assert(0 && "Invalid OldBinaryOps");
1303 case SetEQ :
1304 case SetNE :
1305 case SetLE :
1306 case SetGE :
1307 case SetLT :
1308 case SetGT : assert(0 && "Should use getCompareOp");
1309 case AddOp : return Instruction::Add;
1310 case SubOp : return Instruction::Sub;
1311 case MulOp : return Instruction::Mul;
1312 case DivOp : {
1313 // This is an obsolete instruction so we must upgrade it based on the
1314 // types of its operands.
1315 bool isFP = Ty->isFloatingPoint();
1316 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1317 // If its a packed type we want to use the element type
1318 isFP = PTy->getElementType()->isFloatingPoint();
1319 if (isFP)
1320 return Instruction::FDiv;
1321 else if (Sign == Signed)
1322 return Instruction::SDiv;
1323 return Instruction::UDiv;
1324 }
1325 case UDivOp : return Instruction::UDiv;
1326 case SDivOp : return Instruction::SDiv;
1327 case FDivOp : return Instruction::FDiv;
1328 case RemOp : {
1329 // This is an obsolete instruction so we must upgrade it based on the
1330 // types of its operands.
1331 bool isFP = Ty->isFloatingPoint();
1332 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1333 // If its a packed type we want to use the element type
1334 isFP = PTy->getElementType()->isFloatingPoint();
1335 // Select correct opcode
1336 if (isFP)
1337 return Instruction::FRem;
1338 else if (Sign == Signed)
1339 return Instruction::SRem;
1340 return Instruction::URem;
1341 }
1342 case URemOp : return Instruction::URem;
1343 case SRemOp : return Instruction::SRem;
1344 case FRemOp : return Instruction::FRem;
1345 case AndOp : return Instruction::And;
1346 case OrOp : return Instruction::Or;
1347 case XorOp : return Instruction::Xor;
1348 }
1349}
1350
1351static inline Instruction::OtherOps
1352getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1353 Signedness Sign) {
1354 bool isSigned = Sign == Signed;
1355 bool isFP = Ty->isFloatingPoint();
1356 switch (op) {
1357 default : assert(0 && "Invalid OldSetCC");
1358 case SetEQ :
1359 if (isFP) {
1360 predicate = FCmpInst::FCMP_OEQ;
1361 return Instruction::FCmp;
1362 } else {
1363 predicate = ICmpInst::ICMP_EQ;
1364 return Instruction::ICmp;
1365 }
1366 case SetNE :
1367 if (isFP) {
1368 predicate = FCmpInst::FCMP_UNE;
1369 return Instruction::FCmp;
1370 } else {
1371 predicate = ICmpInst::ICMP_NE;
1372 return Instruction::ICmp;
1373 }
1374 case SetLE :
1375 if (isFP) {
1376 predicate = FCmpInst::FCMP_OLE;
1377 return Instruction::FCmp;
1378 } else {
1379 if (isSigned)
1380 predicate = ICmpInst::ICMP_SLE;
1381 else
1382 predicate = ICmpInst::ICMP_ULE;
1383 return Instruction::ICmp;
1384 }
1385 case SetGE :
1386 if (isFP) {
1387 predicate = FCmpInst::FCMP_OGE;
1388 return Instruction::FCmp;
1389 } else {
1390 if (isSigned)
1391 predicate = ICmpInst::ICMP_SGE;
1392 else
1393 predicate = ICmpInst::ICMP_UGE;
1394 return Instruction::ICmp;
1395 }
1396 case SetLT :
1397 if (isFP) {
1398 predicate = FCmpInst::FCMP_OLT;
1399 return Instruction::FCmp;
1400 } else {
1401 if (isSigned)
1402 predicate = ICmpInst::ICMP_SLT;
1403 else
1404 predicate = ICmpInst::ICMP_ULT;
1405 return Instruction::ICmp;
1406 }
1407 case SetGT :
1408 if (isFP) {
1409 predicate = FCmpInst::FCMP_OGT;
1410 return Instruction::FCmp;
1411 } else {
1412 if (isSigned)
1413 predicate = ICmpInst::ICMP_SGT;
1414 else
1415 predicate = ICmpInst::ICMP_UGT;
1416 return Instruction::ICmp;
1417 }
1418 }
1419}
1420
1421static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1422 switch (op) {
1423 default : assert(0 && "Invalid OldMemoryOps");
1424 case MallocOp : return Instruction::Malloc;
1425 case FreeOp : return Instruction::Free;
1426 case AllocaOp : return Instruction::Alloca;
1427 case LoadOp : return Instruction::Load;
1428 case StoreOp : return Instruction::Store;
1429 case GetElementPtrOp : return Instruction::GetElementPtr;
1430 }
1431}
1432
1433static inline Instruction::OtherOps
1434getOtherOp(OtherOps op, Signedness Sign) {
1435 switch (op) {
1436 default : assert(0 && "Invalid OldOtherOps");
1437 case PHIOp : return Instruction::PHI;
1438 case CallOp : return Instruction::Call;
1439 case ShlOp : return Instruction::Shl;
1440 case ShrOp :
1441 if (Sign == Signed)
1442 return Instruction::AShr;
1443 return Instruction::LShr;
1444 case SelectOp : return Instruction::Select;
1445 case UserOp1 : return Instruction::UserOp1;
1446 case UserOp2 : return Instruction::UserOp2;
1447 case VAArg : return Instruction::VAArg;
1448 case ExtractElementOp : return Instruction::ExtractElement;
1449 case InsertElementOp : return Instruction::InsertElement;
1450 case ShuffleVectorOp : return Instruction::ShuffleVector;
1451 case ICmpOp : return Instruction::ICmp;
1452 case FCmpOp : return Instruction::FCmp;
1453 case LShrOp : return Instruction::LShr;
1454 case AShrOp : return Instruction::AShr;
1455 };
1456}
1457
1458static inline Value*
1459getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy,
1460 Signedness DstSign, bool ForceInstruction = false) {
1461 Instruction::CastOps Opcode;
1462 const Type* SrcTy = Src->getType();
1463 if (op == CastOp) {
1464 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1465 // fp -> ptr cast is no longer supported but we must upgrade this
1466 // by doing a double cast: fp -> int -> ptr
1467 SrcTy = Type::Int64Ty;
1468 Opcode = Instruction::IntToPtr;
1469 if (isa<Constant>(Src)) {
1470 Src = ConstantExpr::getCast(Instruction::FPToUI,
1471 cast<Constant>(Src), SrcTy);
1472 } else {
1473 std::string NewName(makeNameUnique(Src->getName()));
1474 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1475 }
1476 } else if (isa<IntegerType>(DstTy) &&
1477 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1478 // cast type %x to bool was previously defined as setne type %x, null
1479 // The cast semantic is now to truncate, not compare so we must retain
1480 // the original intent by replacing the cast with a setne
1481 Constant* Null = Constant::getNullValue(SrcTy);
1482 Instruction::OtherOps Opcode = Instruction::ICmp;
1483 unsigned short predicate = ICmpInst::ICMP_NE;
1484 if (SrcTy->isFloatingPoint()) {
1485 Opcode = Instruction::FCmp;
1486 predicate = FCmpInst::FCMP_ONE;
1487 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1488 error("Invalid cast to bool");
1489 }
1490 if (isa<Constant>(Src) && !ForceInstruction)
1491 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1492 else
1493 return CmpInst::create(Opcode, predicate, Src, Null);
1494 }
1495 // Determine the opcode to use by calling CastInst::getCastOpcode
1496 Opcode =
1497 CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed);
1498
1499 } else switch (op) {
1500 default: assert(0 && "Invalid cast token");
1501 case TruncOp: Opcode = Instruction::Trunc; break;
1502 case ZExtOp: Opcode = Instruction::ZExt; break;
1503 case SExtOp: Opcode = Instruction::SExt; break;
1504 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1505 case FPExtOp: Opcode = Instruction::FPExt; break;
1506 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1507 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1508 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1509 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1510 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1511 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1512 case BitCastOp: Opcode = Instruction::BitCast; break;
1513 }
1514
1515 if (isa<Constant>(Src) && !ForceInstruction)
1516 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1517 return CastInst::create(Opcode, Src, DstTy);
1518}
1519
1520static Instruction *
1521upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1522 std::vector<Value*>& Args) {
1523
1524 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1525 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1526 if (Args.size() != 2)
1527 error("Invalid prototype for " + Name + " prototype");
1528 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1529 } else {
1530 static unsigned upgradeCount = 1;
1531 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1532 std::vector<const Type*> Params;
1533 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1534 if (Args.size() != 1)
1535 error("Invalid prototype for " + Name + " prototype");
1536 Params.push_back(PtrTy);
1537 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1538 const PointerType *PFTy = PointerType::get(FTy);
1539 Value* Func = getVal(PFTy, ID);
1540 std::string InstName("va_upgrade");
1541 InstName += llvm::utostr(upgradeCount++);
1542 Args[0] = new BitCastInst(Args[0], PtrTy, InstName, CurBB);
1543 return new CallInst(Func, Args);
1544 } else if (Name == "llvm.va_copy") {
1545 if (Args.size() != 2)
1546 error("Invalid prototype for " + Name + " prototype");
1547 Params.push_back(PtrTy);
1548 Params.push_back(PtrTy);
1549 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1550 const PointerType *PFTy = PointerType::get(FTy);
1551 Value* Func = getVal(PFTy, ID);
1552 std::string InstName0("va_upgrade");
1553 InstName0 += llvm::utostr(upgradeCount++);
1554 std::string InstName1("va_upgrade");
1555 InstName1 += llvm::utostr(upgradeCount++);
1556 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1557 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1558 return new CallInst(Func, Args);
1559 }
1560 }
1561 return 0;
1562}
1563
1564const Type* upgradeGEPIndices(const Type* PTy,
1565 std::vector<ValueInfo> *Indices,
1566 std::vector<Value*> &VIndices,
1567 std::vector<Constant*> *CIndices = 0) {
1568 // Traverse the indices with a gep_type_iterator so we can build the list
1569 // of constant and value indices for use later. Also perform upgrades
1570 VIndices.clear();
1571 if (CIndices) CIndices->clear();
1572 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1573 VIndices.push_back((*Indices)[i].V);
1574 generic_gep_type_iterator<std::vector<Value*>::iterator>
1575 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1576 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1577 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1578 Value *Index = VIndices[i];
1579 if (CIndices && !isa<Constant>(Index))
1580 error("Indices to constant getelementptr must be constants");
1581 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1582 // struct indices to i32 struct indices with ZExt for compatibility.
1583 else if (isa<StructType>(*GTI)) { // Only change struct indices
1584 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1585 if (CUI->getType()->getBitWidth() == 8)
1586 Index =
1587 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1588 } else {
1589 // Make sure that unsigned SequentialType indices are zext'd to
1590 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1591 // all indices for SequentialType elements. We must retain the same
1592 // semantic (zext) for unsigned types.
1593 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencer38f682b2007-01-26 20:31:18 +00001594 if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) {
Reid Spencer950bf602007-01-26 08:19:09 +00001595 if (CIndices)
1596 Index = ConstantExpr::getCast(Instruction::ZExt,
1597 cast<Constant>(Index), Type::Int64Ty);
1598 else
1599 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencerd7c4f8c2007-01-26 19:59:25 +00001600 makeNameUnique("gep_upgrade"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001601 VIndices[i] = Index;
1602 }
Reid Spencer950bf602007-01-26 08:19:09 +00001603 }
1604 // Add to the CIndices list, if requested.
1605 if (CIndices)
1606 CIndices->push_back(cast<Constant>(Index));
1607 }
1608
1609 const Type *IdxTy =
1610 GetElementPtrInst::getIndexedType(PTy, VIndices, true);
1611 if (!IdxTy)
1612 error("Index list invalid for constant getelementptr");
1613 return IdxTy;
1614}
1615
1616Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1617 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001618{
1619 Upgradelineno = 1;
1620 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001621 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001622 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001623 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001624 ObsoleteVarArgs = false;
1625 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001626
Reid Spencer950bf602007-01-26 08:19:09 +00001627 CurModule.CurrentModule = new Module(CurFilename);
1628
1629 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001630 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001631 if (ParserResult)
1632 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001633 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001634 return 0;
1635 }
1636
Reid Spencer950bf602007-01-26 08:19:09 +00001637 // Check to make sure that parsing produced a result
1638 if (!ParserResult) {
1639 std::cerr << "llvm-upgrade: no parse result.\n";
1640 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001641 }
1642
Reid Spencer950bf602007-01-26 08:19:09 +00001643 // Reset ParserResult variable while saving its value for the result.
1644 Module *Result = ParserResult;
1645 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001646
Reid Spencer950bf602007-01-26 08:19:09 +00001647 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001648 {
Reid Spencer950bf602007-01-26 08:19:09 +00001649 Function* F;
1650 if ((F = Result->getNamedFunction("llvm.va_start"))
1651 && F->getFunctionType()->getNumParams() == 0)
1652 ObsoleteVarArgs = true;
1653 if((F = Result->getNamedFunction("llvm.va_copy"))
1654 && F->getFunctionType()->getNumParams() == 1)
1655 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001656 }
Reid Spencer319a7302007-01-05 17:20:02 +00001657
Reid Spencer950bf602007-01-26 08:19:09 +00001658 if (ObsoleteVarArgs && NewVarArgs) {
1659 error("This file is corrupt: it uses both new and old style varargs");
1660 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001661 }
Reid Spencer319a7302007-01-05 17:20:02 +00001662
Reid Spencer950bf602007-01-26 08:19:09 +00001663 if(ObsoleteVarArgs) {
1664 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1665 if (F->arg_size() != 0) {
1666 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001667 return 0;
1668 }
Reid Spencer950bf602007-01-26 08:19:09 +00001669
1670 //foo = va_start()
1671 // ->
1672 //bar = alloca typeof(foo)
1673 //va_start(bar)
1674 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001675
Reid Spencer950bf602007-01-26 08:19:09 +00001676 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1677 const Type* ArgTy = F->getFunctionType()->getReturnType();
1678 const Type* ArgTyPtr = PointerType::get(ArgTy);
1679 Function* NF = cast<Function>(Result->getOrInsertFunction(
1680 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1681
1682 while (!F->use_empty()) {
1683 CallInst* CI = cast<CallInst>(F->use_back());
1684 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1685 new CallInst(NF, bar, "", CI);
1686 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1687 CI->replaceAllUsesWith(foo);
1688 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001689 }
Reid Spencer950bf602007-01-26 08:19:09 +00001690 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001691 }
Reid Spencer950bf602007-01-26 08:19:09 +00001692
1693 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1694 if(F->arg_size() != 1) {
1695 error("Obsolete va_end takes 1 argument");
1696 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001697 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001698
Reid Spencer950bf602007-01-26 08:19:09 +00001699 //vaend foo
1700 // ->
1701 //bar = alloca 1 of typeof(foo)
1702 //vaend bar
1703 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1704 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1705 const Type* ArgTyPtr = PointerType::get(ArgTy);
1706 Function* NF = cast<Function>(Result->getOrInsertFunction(
1707 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00001708
Reid Spencer950bf602007-01-26 08:19:09 +00001709 while (!F->use_empty()) {
1710 CallInst* CI = cast<CallInst>(F->use_back());
1711 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1712 new StoreInst(CI->getOperand(1), bar, CI);
1713 new CallInst(NF, bar, "", CI);
1714 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00001715 }
Reid Spencer950bf602007-01-26 08:19:09 +00001716 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00001717 }
Reid Spencer950bf602007-01-26 08:19:09 +00001718
1719 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1720 if(F->arg_size() != 1) {
1721 error("Obsolete va_copy takes 1 argument");
1722 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00001723 }
Reid Spencer950bf602007-01-26 08:19:09 +00001724 //foo = vacopy(bar)
1725 // ->
1726 //a = alloca 1 of typeof(foo)
1727 //b = alloca 1 of typeof(foo)
1728 //store bar -> b
1729 //vacopy(a, b)
1730 //foo = load a
1731
1732 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1733 const Type* ArgTy = F->getFunctionType()->getReturnType();
1734 const Type* ArgTyPtr = PointerType::get(ArgTy);
1735 Function* NF = cast<Function>(Result->getOrInsertFunction(
1736 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00001737
Reid Spencer950bf602007-01-26 08:19:09 +00001738 while (!F->use_empty()) {
1739 CallInst* CI = cast<CallInst>(F->use_back());
1740 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1741 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1742 new StoreInst(CI->getOperand(1), b, CI);
1743 new CallInst(NF, a, b, "", CI);
1744 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1745 CI->replaceAllUsesWith(foo);
1746 CI->getParent()->getInstList().erase(CI);
1747 }
1748 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00001749 }
1750 }
1751
Reid Spencer52402b02007-01-02 05:45:11 +00001752 return Result;
1753}
1754
Reid Spencer950bf602007-01-26 08:19:09 +00001755} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00001756
Reid Spencer950bf602007-01-26 08:19:09 +00001757using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00001758
1759
Reid Spencer319a7302007-01-05 17:20:02 +00001760
1761/* Enabling traces. */
1762#ifndef YYDEBUG
1763# define YYDEBUG 0
1764#endif
1765
1766/* Enabling verbose error messages. */
1767#ifdef YYERROR_VERBOSE
1768# undef YYERROR_VERBOSE
1769# define YYERROR_VERBOSE 1
1770#else
1771# define YYERROR_VERBOSE 0
1772#endif
1773
Reid Spencer950bf602007-01-26 08:19:09 +00001774/* Enabling the token table. */
1775#ifndef YYTOKEN_TABLE
1776# define YYTOKEN_TABLE 0
1777#endif
1778
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001779#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1780typedef union YYSTYPE
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001781#line 1391 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001782{
Reid Spencer950bf602007-01-26 08:19:09 +00001783 llvm::Module *ModuleVal;
1784 llvm::Function *FunctionVal;
1785 std::pair<llvm::PATypeInfo, char*> *ArgVal;
1786 llvm::BasicBlock *BasicBlockVal;
1787 llvm::TerminatorInst *TermInstVal;
1788 llvm::InstrInfo InstVal;
1789 llvm::ConstInfo ConstVal;
1790 llvm::ValueInfo ValueVal;
1791 llvm::PATypeInfo TypeVal;
1792 llvm::TypeInfo PrimType;
1793 llvm::PHIListInfo PHIList;
1794 std::list<llvm::PATypeInfo> *TypeList;
1795 std::vector<llvm::ValueInfo> *ValueList;
1796 std::vector<llvm::ConstInfo> *ConstVector;
1797
1798
1799 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1800 // Represent the RHS of PHI node
1801 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1802
1803 llvm::GlobalValue::LinkageTypes Linkage;
1804 int64_t SInt64Val;
1805 uint64_t UInt64Val;
1806 int SIntVal;
1807 unsigned UIntVal;
1808 double FPVal;
1809 bool BoolVal;
1810
1811 char *StrVal; // This memory is strdup'd!
1812 llvm::ValID ValIDVal; // strdup'd memory maybe!
1813
1814 llvm::BinaryOps BinaryOpVal;
1815 llvm::TermOps TermOpVal;
1816 llvm::MemoryOps MemOpVal;
1817 llvm::OtherOps OtherOpVal;
1818 llvm::CastOps CastOpVal;
1819 llvm::ICmpInst::Predicate IPred;
1820 llvm::FCmpInst::Predicate FPred;
1821 llvm::Module::Endianness Endianness;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001822}
1823/* Line 187 of yacc.c. */
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001824#line 1825 "UpgradeParser.tab.c"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001825 YYSTYPE;
Reid Spencer950bf602007-01-26 08:19:09 +00001826# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1827# define YYSTYPE_IS_DECLARED 1
Reid Spencer319a7302007-01-05 17:20:02 +00001828# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00001829#endif
1830
Reid Spencer950bf602007-01-26 08:19:09 +00001831
Reid Spencere7c3c602006-11-30 06:36:44 +00001832
Reid Spencer319a7302007-01-05 17:20:02 +00001833/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00001834
1835
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001836/* Line 216 of yacc.c. */
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001837#line 1838 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00001838
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001839#ifdef short
1840# undef short
Reid Spencer950bf602007-01-26 08:19:09 +00001841#endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001842
1843#ifdef YYTYPE_UINT8
1844typedef YYTYPE_UINT8 yytype_uint8;
1845#else
1846typedef unsigned char yytype_uint8;
Reid Spencer950bf602007-01-26 08:19:09 +00001847#endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001848
1849#ifdef YYTYPE_INT8
1850typedef YYTYPE_INT8 yytype_int8;
1851#elif (defined __STDC__ || defined __C99__FUNC__ \
1852 || defined __cplusplus || defined _MSC_VER)
1853typedef signed char yytype_int8;
1854#else
1855typedef short int yytype_int8;
Reid Spencer950bf602007-01-26 08:19:09 +00001856#endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001857
1858#ifdef YYTYPE_UINT16
1859typedef YYTYPE_UINT16 yytype_uint16;
1860#else
1861typedef unsigned short int yytype_uint16;
Reid Spencer950bf602007-01-26 08:19:09 +00001862#endif
1863
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001864#ifdef YYTYPE_INT16
1865typedef YYTYPE_INT16 yytype_int16;
1866#else
1867typedef short int yytype_int16;
1868#endif
1869
1870#ifndef YYSIZE_T
1871# ifdef __SIZE_TYPE__
1872# define YYSIZE_T __SIZE_TYPE__
1873# elif defined size_t
1874# define YYSIZE_T size_t
1875# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1876 || defined __cplusplus || defined _MSC_VER)
1877# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1878# define YYSIZE_T size_t
1879# else
1880# define YYSIZE_T unsigned int
1881# endif
1882#endif
1883
1884#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1885
Reid Spencer950bf602007-01-26 08:19:09 +00001886#ifndef YY_
1887# if YYENABLE_NLS
1888# if ENABLE_NLS
1889# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1890# define YY_(msgid) dgettext ("bison-runtime", msgid)
1891# endif
1892# endif
1893# ifndef YY_
1894# define YY_(msgid) msgid
1895# endif
1896#endif
Reid Spencer319a7302007-01-05 17:20:02 +00001897
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001898/* Suppress unused-variable warnings by "using" E. */
1899#if ! defined lint || defined __GNUC__
1900# define YYUSE(e) ((void) (e))
1901#else
1902# define YYUSE(e) /* empty */
1903#endif
1904
1905/* Identity function, used to suppress warnings about constant conditions. */
1906#ifndef lint
1907# define YYID(n) (n)
1908#else
1909#if (defined __STDC__ || defined __C99__FUNC__ \
1910 || defined __cplusplus || defined _MSC_VER)
1911static int
1912YYID (int i)
1913#else
1914static int
1915YYID (i)
1916 int i;
1917#endif
1918{
1919 return i;
1920}
1921#endif
1922
1923#if ! defined yyoverflow || YYERROR_VERBOSE
Reid Spencer319a7302007-01-05 17:20:02 +00001924
1925/* The parser invokes alloca or malloc; define the necessary symbols. */
1926
Reid Spencer950bf602007-01-26 08:19:09 +00001927# ifdef YYSTACK_USE_ALLOCA
1928# if YYSTACK_USE_ALLOCA
1929# ifdef __GNUC__
1930# define YYSTACK_ALLOC __builtin_alloca
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001931# elif defined __BUILTIN_VA_ARG_INCR
1932# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1933# elif defined _AIX
1934# define YYSTACK_ALLOC __alloca
1935# elif defined _MSC_VER
1936# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1937# define alloca _alloca
Jeff Cohenac2dca92007-01-21 19:30:52 +00001938# else
Reid Spencer950bf602007-01-26 08:19:09 +00001939# define YYSTACK_ALLOC alloca
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001940# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1941 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00001942# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001943# ifndef _STDLIB_H
1944# define _STDLIB_H 1
1945# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001946# endif
1947# endif
1948# endif
1949# endif
1950
1951# ifdef YYSTACK_ALLOC
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001952 /* Pacify GCC's `empty if-body' warning. */
1953# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
Reid Spencer950bf602007-01-26 08:19:09 +00001954# ifndef YYSTACK_ALLOC_MAXIMUM
1955 /* The OS might guarantee only one guard page at the bottom of the stack,
1956 and a page size can be as small as 4096 bytes. So we cannot safely
1957 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1958 to allow for a few compiler-allocated temporary stack slots. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001959# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
Reid Spencer319a7302007-01-05 17:20:02 +00001960# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001961# else
1962# define YYSTACK_ALLOC YYMALLOC
1963# define YYSTACK_FREE YYFREE
1964# ifndef YYSTACK_ALLOC_MAXIMUM
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001965# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
Reid Spencer950bf602007-01-26 08:19:09 +00001966# endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001967# if (defined __cplusplus && ! defined _STDLIB_H \
1968 && ! ((defined YYMALLOC || defined malloc) \
1969 && (defined YYFREE || defined free)))
1970# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1971# ifndef _STDLIB_H
1972# define _STDLIB_H 1
1973# endif
Reid Spencer950bf602007-01-26 08:19:09 +00001974# endif
1975# ifndef YYMALLOC
1976# define YYMALLOC malloc
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001977# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1978 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00001979void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1980# endif
1981# endif
1982# ifndef YYFREE
1983# define YYFREE free
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001984# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1985 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00001986void free (void *); /* INFRINGES ON USER NAME SPACE */
1987# endif
1988# endif
Reid Spencer319a7302007-01-05 17:20:02 +00001989# endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001990#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
Reid Spencer319a7302007-01-05 17:20:02 +00001991
1992
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00001993#if (! defined yyoverflow \
1994 && (! defined __cplusplus \
1995 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
Reid Spencer319a7302007-01-05 17:20:02 +00001996
1997/* A type that is properly aligned for any stack member. */
1998union yyalloc
1999{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002000 yytype_int16 yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00002001 YYSTYPE yyvs;
2002 };
2003
2004/* The size of the maximum gap between one aligned stack and the next. */
Reid Spencer950bf602007-01-26 08:19:09 +00002005# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Reid Spencer319a7302007-01-05 17:20:02 +00002006
2007/* The size of an array large to enough to hold all stacks, each with
2008 N elements. */
2009# define YYSTACK_BYTES(N) \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002010 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
Reid Spencer950bf602007-01-26 08:19:09 +00002011 + YYSTACK_GAP_MAXIMUM)
Reid Spencer319a7302007-01-05 17:20:02 +00002012
2013/* Copy COUNT objects from FROM to TO. The source and destination do
2014 not overlap. */
2015# ifndef YYCOPY
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002016# if defined __GNUC__ && 1 < __GNUC__
Reid Spencer319a7302007-01-05 17:20:02 +00002017# define YYCOPY(To, From, Count) \
2018 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2019# else
2020# define YYCOPY(To, From, Count) \
2021 do \
2022 { \
Reid Spencer950bf602007-01-26 08:19:09 +00002023 YYSIZE_T yyi; \
Reid Spencer319a7302007-01-05 17:20:02 +00002024 for (yyi = 0; yyi < (Count); yyi++) \
Reid Spencer950bf602007-01-26 08:19:09 +00002025 (To)[yyi] = (From)[yyi]; \
Reid Spencer319a7302007-01-05 17:20:02 +00002026 } \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002027 while (YYID (0))
Reid Spencer319a7302007-01-05 17:20:02 +00002028# endif
2029# endif
2030
2031/* Relocate STACK from its old location to the new one. The
2032 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2033 elements in the stack, and YYPTR gives the new location of the
2034 stack. Advance YYPTR to a properly aligned location for the next
2035 stack. */
2036# define YYSTACK_RELOCATE(Stack) \
2037 do \
2038 { \
2039 YYSIZE_T yynewbytes; \
2040 YYCOPY (&yyptr->Stack, Stack, yysize); \
2041 Stack = &yyptr->Stack; \
Reid Spencer950bf602007-01-26 08:19:09 +00002042 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Reid Spencer319a7302007-01-05 17:20:02 +00002043 yyptr += yynewbytes / sizeof (*yyptr); \
2044 } \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002045 while (YYID (0))
Reid Spencere7c3c602006-11-30 06:36:44 +00002046
2047#endif
2048
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002049/* YYFINAL -- State number of the termination state. */
Reid Spencer319a7302007-01-05 17:20:02 +00002050#define YYFINAL 4
Reid Spencer950bf602007-01-26 08:19:09 +00002051/* YYLAST -- Last index in YYTABLE. */
2052#define YYLAST 1712
Reid Spencer319a7302007-01-05 17:20:02 +00002053
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002054/* YYNTOKENS -- Number of terminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002055#define YYNTOKENS 166
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002056/* YYNNTS -- Number of nonterminals. */
Reid Spencer950bf602007-01-26 08:19:09 +00002057#define YYNNTS 79
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002058/* YYNRULES -- Number of rules. */
Reid Spencer950bf602007-01-26 08:19:09 +00002059#define YYNRULES 308
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002060/* YYNRULES -- Number of states. */
Reid Spencer950bf602007-01-26 08:19:09 +00002061#define YYNSTATES 604
Reid Spencer319a7302007-01-05 17:20:02 +00002062
2063/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2064#define YYUNDEFTOK 2
Reid Spencer950bf602007-01-26 08:19:09 +00002065#define YYMAXUTOK 406
Reid Spencer319a7302007-01-05 17:20:02 +00002066
Reid Spencer950bf602007-01-26 08:19:09 +00002067#define YYTRANSLATE(YYX) \
2068 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Reid Spencer319a7302007-01-05 17:20:02 +00002069
2070/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002071static const yytype_uint8 yytranslate[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002072{
2073 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2074 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2075 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002077 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002079 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002080 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2081 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002082 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
Reid Spencer319a7302007-01-05 17:20:02 +00002083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2084 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer950bf602007-01-26 08:19:09 +00002085 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Reid Spencer319a7302007-01-05 17:20:02 +00002086 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2087 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2088 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2089 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2090 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2091 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2092 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2093 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2094 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2095 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2096 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2097 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2098 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2099 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2100 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2101 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2102 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2103 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2104 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2105 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2106 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2107 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2108 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2109 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2110 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2111 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2112 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer950bf602007-01-26 08:19:09 +00002113 145, 146, 147, 148, 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002114};
2115
2116#if YYDEBUG
2117/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2118 YYRHS. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002119static const yytype_uint16 yyprhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002120{
2121 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2122 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2123 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2124 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2125 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2126 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2127 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2128 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2129 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
Reid Spencer950bf602007-01-26 08:19:09 +00002130 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
Reid Spencer319a7302007-01-05 17:20:02 +00002131 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2132 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2133 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2134 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2135 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
Reid Spencer950bf602007-01-26 08:19:09 +00002136 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2137 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2138 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2139 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2140 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2141 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2142 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2143 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2144 650, 652, 653, 658, 659, 661, 663, 665, 667, 669,
2145 671, 673, 675, 677, 681, 683, 689, 691, 693, 695,
2146 697, 700, 703, 706, 710, 713, 714, 716, 718, 720,
2147 723, 726, 730, 740, 750, 759, 773, 775, 777, 784,
2148 790, 793, 800, 808, 810, 814, 816, 817, 820, 822,
2149 828, 834, 840, 847, 854, 857, 862, 867, 874, 879,
2150 884, 889, 894, 901, 908, 911, 919, 921, 924, 925,
2151 927, 928, 932, 939, 943, 950, 953, 958, 965
Reid Spencer319a7302007-01-05 17:20:02 +00002152};
2153
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002154/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2155static const yytype_int16 yyrhs[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002156{
Reid Spencer950bf602007-01-26 08:19:09 +00002157 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencerc4d96252007-01-13 00:03:30 +00002158 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2159 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2160 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
2161 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
Reid Spencer950bf602007-01-26 08:19:09 +00002162 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2163 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2164 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2165 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2166 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2167 -1, 28, -1, 109, -1, 110, -1, 111, -1, 112,
2168 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2169 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2170 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2171 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2172 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2173 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2174 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2175 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2176 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2177 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2178 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2179 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
Reid Spencer319a7302007-01-05 17:20:02 +00002180 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
Reid Spencer950bf602007-01-26 08:19:09 +00002181 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2182 -1, 19, -1, 21, -1, 192, -1, 48, -1, 227,
2183 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2184 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2185 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2186 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2187 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2188 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2189 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2190 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2191 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2192 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2193 191, 39, -1, 191, 227, -1, 191, 197, -1, 191,
2194 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2195 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2196 36, 191, 156, -1, 106, 155, 196, 242, 156, -1,
2197 108, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2198 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2199 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2200 99, 172, 155, 196, 153, 196, 156, -1, 100, 173,
2201 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2202 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2203 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2204 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2205 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2206 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2207 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2208 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2209 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2210 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2211 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2212 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2213 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2214 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2215 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2216 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2217 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2218 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2219 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2220 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2221 30, -1, 163, -1, 230, 220, -1, -1, 45, -1,
2222 47, -1, -1, 31, 224, 222, 217, -1, -1, 63,
2223 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
2224 -1, 38, -1, 39, -1, 26, -1, 160, 198, 161,
2225 -1, 197, -1, 61, 225, 24, 153, 24, -1, 167,
2226 -1, 212, -1, 227, -1, 226, -1, 191, 228, -1,
2227 230, 231, -1, 219, 231, -1, 232, 180, 234, -1,
2228 232, 236, -1, -1, 23, -1, 77, -1, 78, -1,
2229 72, 229, -1, 72, 8, -1, 73, 21, 228, -1,
2230 73, 9, 228, 153, 21, 228, 153, 21, 228, -1,
2231 74, 178, 228, 153, 21, 228, 157, 235, 159, -1,
2232 74, 178, 228, 153, 21, 228, 157, 159, -1, 75,
2233 182, 189, 228, 155, 239, 156, 36, 21, 228, 233,
2234 21, 228, -1, 233, -1, 76, -1, 235, 178, 226,
2235 153, 21, 228, -1, 178, 226, 153, 21, 228, -1,
2236 180, 241, -1, 191, 157, 228, 153, 228, 159, -1,
2237 237, 153, 157, 228, 153, 228, 159, -1, 229, -1,
2238 238, 153, 229, -1, 238, -1, -1, 60, 59, -1,
2239 59, -1, 169, 191, 228, 153, 228, -1, 170, 191,
2240 228, 153, 228, -1, 171, 191, 228, 153, 228, -1,
2241 99, 172, 191, 228, 153, 228, -1, 100, 173, 191,
2242 228, 153, 228, -1, 49, 229, -1, 174, 229, 153,
2243 229, -1, 175, 229, 36, 191, -1, 108, 229, 153,
2244 229, 153, 229, -1, 113, 229, 153, 191, -1, 117,
2245 229, 153, 191, -1, 118, 229, 153, 191, -1, 114,
2246 229, 153, 229, -1, 115, 229, 153, 229, 153, 229,
2247 -1, 116, 229, 153, 229, 153, 229, -1, 107, 237,
2248 -1, 240, 182, 189, 228, 155, 239, 156, -1, 244,
2249 -1, 153, 238, -1, -1, 35, -1, -1, 101, 191,
2250 184, -1, 101, 191, 153, 15, 228, 184, -1, 102,
2251 191, 184, -1, 102, 191, 153, 15, 228, 184, -1,
2252 103, 229, -1, 243, 104, 191, 228, -1, 243, 105,
2253 229, 153, 191, 228, -1, 106, 191, 228, 242, -1
Reid Spencer319a7302007-01-05 17:20:02 +00002254};
2255
2256/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002257static const yytype_uint16 yyrline[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002258{
Anton Korobeynikovce13b852007-01-28 15:25:24 +00002259 0, 1531, 1531, 1532, 1540, 1541, 1551, 1551, 1551, 1551,
2260 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1555, 1555, 1555,
2261 1559, 1559, 1559, 1559, 1559, 1559, 1563, 1563, 1564, 1564,
2262 1565, 1565, 1566, 1566, 1567, 1567, 1571, 1571, 1572, 1572,
2263 1573, 1573, 1574, 1574, 1575, 1575, 1576, 1576, 1577, 1577,
2264 1578, 1579, 1582, 1582, 1582, 1582, 1586, 1586, 1586, 1586,
2265 1586, 1586, 1586, 1587, 1587, 1587, 1587, 1587, 1587, 1593,
2266 1593, 1593, 1593, 1597, 1597, 1597, 1597, 1601, 1601, 1605,
2267 1605, 1610, 1613, 1618, 1619, 1620, 1621, 1622, 1623, 1624,
2268 1625, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1646,
2269 1647, 1655, 1656, 1664, 1673, 1674, 1681, 1682, 1686, 1690,
2270 1706, 1707, 1714, 1715, 1722, 1730, 1730, 1730, 1730, 1730,
2271 1730, 1730, 1731, 1731, 1731, 1731, 1731, 1736, 1740, 1744,
2272 1749, 1758, 1774, 1780, 1793, 1802, 1806, 1817, 1821, 1834,
2273 1838, 1845, 1846, 1852, 1859, 1871, 1901, 1914, 1937, 1965,
2274 1987, 1998, 2020, 2031, 2040, 2045, 2103, 2110, 2118, 2125,
2275 2132, 2136, 2140, 2149, 2164, 2177, 2186, 2214, 2227, 2236,
2276 2242, 2248, 2257, 2263, 2269, 2280, 2281, 2290, 2291, 2303,
2277 2312, 2313, 2314, 2315, 2316, 2332, 2352, 2354, 2356, 2356,
2278 2363, 2363, 2370, 2370, 2377, 2377, 2385, 2387, 2389, 2394,
2279 2408, 2409, 2413, 2416, 2424, 2428, 2435, 2439, 2443, 2447,
2280 2455, 2455, 2459, 2460, 2464, 2472, 2477, 2485, 2486, 2493,
2281 2500, 2504, 2610, 2610, 2614, 2624, 2624, 2628, 2632, 2634,
2282 2635, 2639, 2639, 2651, 2652, 2657, 2658, 2659, 2660, 2661,
2283 2662, 2663, 2664, 2665, 2686, 2689, 2704, 2705, 2710, 2710,
2284 2718, 2727, 2730, 2739, 2749, 2754, 2763, 2774, 2774, 2777,
2285 2780, 2783, 2787, 2793, 2808, 2814, 2865, 2868, 2874, 2884,
2286 2897, 2926, 2934, 2942, 2946, 2953, 2954, 2958, 2961, 2967,
2287 2984, 3000, 3014, 3026, 3038, 3049, 3058, 3067, 3076, 3083,
2288 3104, 3128, 3134, 3140, 3146, 3162, 3235, 3243, 3244, 3248,
2289 3249, 3253, 3259, 3265, 3271, 3277, 3284, 3296, 3310
Reid Spencer319a7302007-01-05 17:20:02 +00002290};
2291#endif
2292
Reid Spencer950bf602007-01-26 08:19:09 +00002293#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2294/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002295 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer319a7302007-01-05 17:20:02 +00002296static const char *const yytname[] =
2297{
Reid Spencer950bf602007-01-26 08:19:09 +00002298 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2299 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2300 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2301 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2302 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2303 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2304 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2305 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2306 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2307 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2308 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2309 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2310 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2311 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2312 "SREM", "FREM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT",
2313 "SETEQ", "SETNE", "ICMP", "FCMP", "MALLOC", "ALLOCA", "FREE", "LOAD",
2314 "STORE", "GETELEMENTPTR", "PHI_TOK", "SELECT", "SHL", "SHR", "ASHR",
2315 "LSHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2316 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2317 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2318 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2319 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2320 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2321 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2322 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2323 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2324 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2325 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2326 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2327 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2328 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2329 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2330 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2331 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2332 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
2333 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2334 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2335 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2336 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
Jeff Cohenac2dca92007-01-21 19:30:52 +00002337 "OptVolatile", "MemoryInst", 0
Reid Spencer319a7302007-01-05 17:20:02 +00002338};
2339#endif
2340
2341# ifdef YYPRINT
2342/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2343 token YYLEX-NUM. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002344static const yytype_uint16 yytoknum[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002345{
2346 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2347 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2348 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2349 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2350 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2351 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2352 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2353 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2354 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2355 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2356 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2357 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2358 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2359 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2360 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Reid Spencer950bf602007-01-26 08:19:09 +00002361 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2362 60, 62, 123, 125, 42, 99
Reid Spencer319a7302007-01-05 17:20:02 +00002363};
2364# endif
2365
2366/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002367static const yytype_uint8 yyr1[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002368{
Reid Spencer950bf602007-01-26 08:19:09 +00002369 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2370 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2371 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2372 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2373 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2374 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2375 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2376 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2377 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2378 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2379 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2380 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2381 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2382 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2383 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2384 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2385 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2386 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2387 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2388 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2389 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2390 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2391 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2392 222, 224, 223, 225, 225, 226, 226, 226, 226, 226,
2393 226, 226, 226, 226, 226, 226, 227, 227, 228, 228,
2394 229, 230, 230, 231, 232, 232, 232, 233, 233, 234,
2395 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
2396 236, 237, 237, 238, 238, 239, 239, 240, 240, 241,
2397 241, 241, 241, 241, 241, 241, 241, 241, 241, 241,
2398 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
2399 243, 244, 244, 244, 244, 244, 244, 244, 244
Reid Spencer319a7302007-01-05 17:20:02 +00002400};
2401
2402/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002403static const yytype_uint8 yyr2[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002404{
2405 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2413 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer950bf602007-01-26 08:19:09 +00002414 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002415 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2418 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2419 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
Reid Spencer950bf602007-01-26 08:19:09 +00002420 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2421 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2422 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2423 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2424 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2425 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2426 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2427 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2428 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
2429 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2430 2, 2, 2, 3, 2, 0, 1, 1, 1, 2,
2431 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
2432 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
2433 5, 5, 6, 6, 2, 4, 4, 6, 4, 4,
2434 4, 4, 6, 6, 2, 7, 1, 2, 0, 1,
2435 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer319a7302007-01-05 17:20:02 +00002436};
2437
2438/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2439 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2440 means the default is an error. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002441static const yytype_uint16 yydefact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002442{
Reid Spencer950bf602007-01-26 08:19:09 +00002443 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2444 86, 87, 88, 89, 0, 91, 255, 180, 181, 255,
2445 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2446 0, 92, 93, 94, 95, 96, 97, 0, 0, 256,
2447 252, 82, 225, 226, 227, 251, 0, 0, 0, 0,
2448 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2449 230, 91, 199, 182, 98, 2, 3, 111, 115, 116,
2450 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2451 128, 0, 0, 0, 0, 246, 0, 0, 110, 127,
2452 114, 247, 129, 222, 223, 224, 300, 254, 0, 0,
2453 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2454 0, 0, 232, 130, 0, 0, 0, 113, 135, 139,
2455 0, 0, 144, 138, 299, 0, 278, 0, 0, 0,
2456 0, 91, 267, 257, 258, 6, 7, 8, 9, 10,
2457 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2458 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
2459 0, 0, 0, 52, 53, 54, 55, 0, 0, 0,
2460 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2461 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2462 0, 266, 253, 91, 270, 0, 296, 204, 201, 200,
2463 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2464 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2465 0, 0, 0, 188, 0, 0, 0, 0, 0, 134,
2466 220, 143, 141, 0, 0, 284, 277, 260, 259, 0,
2467 0, 72, 76, 71, 75, 70, 74, 69, 73, 77,
2468 78, 0, 0, 26, 27, 28, 29, 30, 31, 32,
2469 33, 34, 35, 0, 50, 51, 46, 47, 48, 49,
2470 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
2471 0, 101, 101, 305, 0, 0, 294, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002472 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002473 0, 0, 0, 206, 106, 106, 106, 160, 161, 4,
2474 5, 158, 159, 162, 157, 153, 154, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002475 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002476 0, 0, 0, 156, 155, 106, 112, 112, 137, 0,
2477 140, 219, 213, 216, 217, 0, 0, 131, 235, 236,
2478 237, 242, 238, 239, 240, 241, 233, 0, 244, 249,
2479 248, 250, 0, 261, 0, 0, 0, 0, 0, 301,
2480 0, 303, 298, 0, 0, 0, 0, 0, 0, 0,
2481 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2482 207, 0, 193, 195, 191, 0, 0, 0, 0, 0,
2483 0, 0, 146, 176, 0, 0, 0, 150, 0, 147,
2484 0, 0, 0, 0, 0, 189, 132, 133, 136, 212,
2485 214, 0, 104, 142, 234, 0, 0, 0, 0, 0,
2486 0, 0, 0, 0, 0, 0, 308, 0, 0, 0,
2487 288, 291, 0, 0, 289, 290, 0, 0, 0, 285,
2488 286, 0, 306, 0, 0, 0, 108, 106, 0, 0,
2489 298, 0, 0, 0, 0, 0, 145, 135, 114, 0,
2490 148, 149, 0, 0, 0, 0, 0, 218, 215, 105,
2491 99, 0, 243, 0, 0, 276, 0, 0, 101, 102,
2492 101, 273, 297, 0, 0, 0, 0, 0, 279, 280,
2493 281, 276, 0, 103, 109, 107, 0, 0, 0, 0,
2494 0, 0, 0, 175, 152, 0, 0, 0, 0, 0,
2495 0, 0, 221, 0, 0, 0, 275, 0, 282, 283,
2496 0, 302, 304, 0, 0, 0, 287, 292, 293, 0,
2497 307, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2498 0, 0, 0, 0, 100, 245, 0, 0, 0, 274,
2499 271, 0, 295, 0, 0, 0, 172, 0, 0, 166,
2500 167, 168, 171, 163, 0, 264, 0, 0, 0, 272,
2501 169, 170, 0, 0, 0, 262, 0, 263, 0, 0,
2502 165, 173, 174, 0, 0, 0, 0, 0, 0, 269,
2503 0, 0, 268, 265
Reid Spencer319a7302007-01-05 17:20:02 +00002504};
2505
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002506/* YYDEFGOTO[NTERM-NUM]. */
2507static const yytype_int16 yydefgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002508{
Reid Spencer950bf602007-01-26 08:19:09 +00002509 -1, 85, 311, 328, 329, 330, 263, 280, 331, 332,
2510 219, 220, 251, 221, 25, 15, 37, 522, 369, 456,
2511 480, 392, 457, 86, 87, 222, 89, 90, 120, 233,
2512 403, 358, 404, 108, 1, 2, 3, 335, 306, 304,
2513 305, 63, 200, 50, 103, 204, 91, 420, 343, 344,
2514 345, 38, 95, 16, 44, 17, 61, 18, 28, 425,
2515 359, 92, 361, 491, 19, 40, 41, 191, 192, 577,
2516 97, 286, 526, 527, 193, 194, 436, 195, 196
Reid Spencer319a7302007-01-05 17:20:02 +00002517};
2518
2519/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2520 STATE-NUM. */
Reid Spencer950bf602007-01-26 08:19:09 +00002521#define YYPACT_NINF -508
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002522static const yytype_int16 yypact[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002523{
Reid Spencer950bf602007-01-26 08:19:09 +00002524 -508, 18, 144, 546, -508, -508, -508, -508, -508, -508,
2525 -508, -508, -508, -508, 2, 152, 47, -508, -508, -15,
2526 -508, -508, -30, -75, 29, 69, -10, -508, 98, 104,
2527 151, -508, -508, -508, -508, -508, -508, 1307, -8, -508,
2528 -508, 149, -508, -508, -508, -508, 11, 20, 22, 24,
2529 -508, 27, 104, 1307, 0, 0, 0, 0, -508, -508,
2530 -508, 152, -508, -508, -508, -508, -508, 37, -508, -508,
2531 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2532 -508, 194, 200, 3, 695, -508, 149, 54, -508, -508,
2533 -81, -508, -508, -508, -508, -508, 1561, -508, 186, -19,
2534 210, 188, 203, -508, -508, -508, -508, -508, 1368, 1368,
2535 1368, 1409, -508, -508, 66, 70, 715, -508, -508, -81,
2536 -85, 75, 781, -508, -508, 1368, -508, 172, 1429, 58,
2537 255, 152, -508, -508, -508, -508, -508, -508, -508, -508,
2538 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2539 -508, -508, -508, -508, -508, 208, 394, 1368, 1368, 1368,
2540 1368, 1368, 1368, -508, -508, -508, -508, 1368, 1368, 1368,
2541 1368, 1368, 1368, -508, -508, -508, -508, -508, -508, -508,
2542 -508, -508, -508, -508, -508, -508, 1368, 1368, 1368, 1368,
2543 1368, -508, -508, 152, -508, 55, -508, -508, -508, -508,
2544 -508, -508, -508, -508, -50, -508, -508, -508, 153, 179,
2545 228, 191, 229, 193, 230, 197, 231, 233, 234, 199,
2546 232, 235, 537, -508, 1368, 1368, 84, -45, 1368, -508,
2547 1149, -508, 93, 91, 898, -508, -508, 37, -508, 898,
2548 898, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2549 -508, 898, 1307, -508, -508, -508, -508, -508, -508, -508,
2550 -508, -508, -508, 1368, -508, -508, -508, -508, -508, -508,
2551 -508, -508, -508, -508, -508, -508, -508, -508, -508, -508,
2552 1368, 95, 96, -508, 898, 99, 97, 105, 106, 107,
2553 120, 123, 126, 127, 898, 898, 898, 128, 221, 1307,
2554 1368, 1368, 258, -508, 132, 132, 132, -508, -508, -508,
2555 -508, -508, -508, -508, -508, -508, -508, 208, 394, 131,
2556 134, 135, 136, 137, 1190, 1470, 736, 259, 139, 140,
2557 141, 142, 148, -508, -508, 132, -130, -23, -508, 143,
2558 -81, -508, 149, -508, 155, 154, 1210, -508, -508, -508,
2559 -508, -508, -508, -508, -508, -508, 224, 1409, -508, -508,
2560 -508, -508, 156, -508, 163, 898, 898, 898, 4, -508,
2561 5, -508, 164, 898, 162, 1368, 1368, 1368, 1368, 1368,
2562 1368, 1368, 167, 168, 169, 1368, 1368, 898, 898, 170,
2563 -508, -17, -508, -508, -508, 150, 182, 1409, 1409, 1409,
2564 1409, 1409, -508, -508, -13, 756, -24, -508, -36, -508,
2565 1409, 1409, 1409, 1409, 1409, -508, -508, -508, -508, -508,
2566 -508, 1251, 290, -508, -508, 301, -14, 324, 325, 198,
2567 201, 202, 898, 348, 898, 1368, -508, 204, 898, 205,
2568 -508, -508, 211, 214, -508, -508, 898, 898, 898, -508,
2569 -508, 213, -508, 1368, 332, 365, -508, 132, 1409, 1409,
2570 164, 217, 222, 223, 225, 1409, -508, 216, -71, -27,
2571 -508, -508, 226, 236, 237, 240, 338, -508, -508, -508,
2572 326, 241, -508, 898, 898, 1368, 898, 898, 242, -508,
2573 242, -508, 243, 898, 244, 1368, 1368, 1368, -508, -508,
2574 -508, 1368, 898, -508, -508, -508, 246, 247, 245, 1409,
2575 1409, 1409, 1409, -508, -508, 220, 1409, 1409, 1409, 1409,
2576 1368, 378, -508, 361, 249, 248, 243, 250, -508, -508,
2577 329, -508, -508, 1368, 256, 898, -508, -508, -508, 251,
2578 -508, 1409, 1409, -508, 261, 252, 270, 271, -508, 269,
2579 272, 275, 279, 280, -508, -508, 367, 40, 368, -508,
2580 -508, 267, -508, 281, 282, 1409, -508, 1409, 1409, -508,
2581 -508, -508, -508, -508, 898, -508, 996, 85, 382, -508,
2582 -508, -508, 283, 285, 288, -508, 274, -508, 996, 898,
2583 -508, -508, -508, 424, 293, 130, 898, 426, 430, -508,
2584 898, 898, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002585};
2586
2587/* YYPGOTO[NTERM-NUM]. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002588static const yytype_int16 yypgoto[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002589{
Reid Spencer950bf602007-01-26 08:19:09 +00002590 -508, -508, -508, 356, 357, 360, 145, 147, 371, 374,
2591 -128, -127, -497, -508, 416, 436, -117, -508, -277, 41,
2592 -508, -296, -508, -47, -508, -37, -508, -58, 46, -508,
2593 -99, 253, -298, 49, -508, -508, -508, -508, -508, -508,
2594 -508, 419, -508, -508, -508, -508, 8, -508, 51, -508,
2595 -508, 412, -508, -508, -508, -508, -508, 471, -508, -508,
2596 -507, -209, 67, -124, -508, 457, -508, -118, -508, -508,
2597 -508, -508, 43, -22, -508, -508, 21, -508, -508
Reid Spencer319a7302007-01-05 17:20:02 +00002598};
2599
2600/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2601 positive, shift that token. If negative, reduce the rule which
2602 number is the opposite. If zero, do what YYDEFACT says.
Reid Spencer950bf602007-01-26 08:19:09 +00002603 If YYTABLE_NINF, syntax error. */
2604#define YYTABLE_NINF -180
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002605static const yytype_int16 yytable[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002606{
Reid Spencer950bf602007-01-26 08:19:09 +00002607 88, 235, 249, 250, 238, 371, 105, 115, 39, 393,
2608 394, 26, 223, 334, 252, 42, 88, 454, 4, 432,
2609 434, 93, 46, 47, 48, 360, 119, 406, 408, 416,
2610 360, 360, 106, 107, 123, 283, 198, 199, 287, 415,
2611 455, 49, 360, 288, 289, 290, 291, 292, 293, 26,
2612 241, 242, 243, 244, 245, 246, 247, 248, 119, 426,
2613 576, 433, 433, 29, 119, 297, 298, 239, 228, 586,
2614 39, 205, 206, 207, -112, 360, 299, 51, 229, 240,
2615 588, 594, -139, 123, -112, 360, 360, 360, 234, 53,
2616 52, 234, -139, 123, 121, 241, 242, 243, 244, 245,
2617 246, 247, 248, 302, 109, 110, 111, 469, 228, 303,
2618 7, 8, 9, 10, 54, 12, 55, 465, 339, 56,
2619 281, 282, 234, 284, 285, 234, 465, 471, 62, 465,
2620 234, 234, 234, 234, 234, 234, 515, 470, 417, 465,
2621 465, 123, 58, 59, -179, 60, 466, 482, 43, 294,
2622 295, 296, 234, 234, 94, 64, 360, 360, 360, 300,
2623 301, 505, 227, 98, 360, 116, 336, 337, 232, 5,
2624 340, 20, 99, 21, 100, 6, 101, 389, 360, 360,
2625 307, 308, -72, -72, 102, 7, 8, 9, 10, 11,
2626 12, 13, -113, 342, -71, -71, -70, -70, 113, 575,
2627 -69, -69, 309, 310, 114, 365, 14, 133, 134, 122,
2628 197, 531, 202, 532, 201, 88, 30, 31, 32, 33,
2629 34, 35, 36, 360, 224, 360, 366, 203, 225, 360,
2630 230, 236, -76, -75, -74, -73, 312, 360, 360, 360,
2631 -79, -80, 313, 367, 587, 338, 346, 347, 368, 370,
2632 374, 439, 387, 441, 442, 443, 373, 386, 375, 376,
2633 377, 449, 88, 388, 234, 241, 242, 243, 244, 245,
2634 246, 247, 248, 378, 360, 360, 379, 360, 360, 380,
2635 381, 385, 390, 409, 360, 391, 397, 424, 340, 398,
2636 399, 400, 401, 360, 410, 411, 412, 413, 460, 461,
2637 462, 463, 464, 414, 418, 458, 362, 363, 421, 427,
2638 422, 472, 473, 474, 475, 476, 428, 435, 364, 438,
2639 446, 447, 448, 453, 454, 481, 360, 253, 254, 255,
2640 256, 257, 258, 259, 260, 261, 262, 459, 234, 440,
2641 234, 234, 234, 444, 445, 483, 484, 468, 234, 450,
2642 419, 372, 489, 485, 486, 487, 503, 493, 495, 506,
2643 507, 382, 383, 384, 496, 360, 513, 497, 501, 504,
2644 509, 536, 537, 538, 520, 510, 511, 514, 512, 516,
2645 360, 548, 554, 521, 342, 555, 433, 360, 574, 517,
2646 518, 360, 360, 519, 523, 530, 533, 535, 234, 541,
2647 542, 543, 556, 589, 578, 557, 558, 562, 566, 559,
2648 544, 545, 546, 547, 565, 560, 502, 549, 550, 551,
2649 552, 264, 265, 567, 568, 569, 579, 593, 570, 249,
2650 250, 571, 429, 430, 431, 572, 573, 580, 581, 590,
2651 437, 591, 563, 564, 592, 596, 597, 600, 234, 249,
2652 250, 601, 186, 187, 451, 452, 188, 96, 234, 234,
2653 234, 57, 395, 479, 234, 396, 582, 189, 583, 584,
2654 190, 104, 478, 112, 27, 333, 45, 598, 492, 539,
2655 0, 508, 0, 553, 0, 0, 0, 0, 0, 0,
2656 0, 0, 0, 0, 0, 0, 234, 0, 0, 488,
2657 0, 490, 0, 0, 0, 494, 0, 0, 0, 0,
2658 0, 0, 0, 498, 499, 500, 0, 0, 0, 266,
2659 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2660 277, 278, 279, 0, 0, 0, 0, 0, 0, 0,
2661 0, 0, 65, 66, 0, 0, 0, 0, 0, 0,
2662 524, 525, 0, 528, 529, 0, 0, 0, 0, 20,
2663 534, 21, 0, 314, 0, 0, -82, 0, 20, 540,
2664 21, 0, 0, 0, 0, 315, 316, 6, -82, -82,
2665 0, 0, 0, 0, 0, 0, 0, -82, -82, -82,
2666 -82, -82, -82, -82, 0, 0, -82, 22, 0, 0,
2667 0, 0, 561, 0, 23, 0, 0, 0, 24, 0,
2668 0, 0, 0, 0, 0, 0, 135, 136, 137, 138,
2669 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2670 149, 150, 151, 152, 153, 154, 317, 318, 0, 0,
2671 0, 585, 0, 319, 0, 320, 163, 164, 165, 166,
2672 0, 321, 322, 323, 0, 0, 595, 0, 0, 0,
2673 0, 0, 0, 599, 0, 0, 0, 602, 603, 0,
2674 0, 0, 0, 0, 0, 0, 173, 174, 175, 176,
2675 177, 178, 179, 180, 181, 182, 183, 184, 185, 0,
2676 0, 0, 0, 0, 324, 0, 0, 325, 0, 326,
2677 65, 66, 327, 117, 68, 69, 70, 71, 72, 73,
2678 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2679 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2680 74, 75, 76, 77, 78, 0, 79, 20, 0, 21,
2681 0, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2682 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2683 21, 65, 66, 80, 117, 208, 209, 210, 211, 212,
2684 213, 214, 215, 216, 217, 218, 0, 79, 20, 0,
2685 21, 0, 0, 0, 80, 0, 65, 66, 0, 117,
2686 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2687 78, 0, 79, 20, 80, 21, 0, 0, 0, 0,
2688 0, 0, 0, 0, 0, 0, 0, 0, 231, 0,
2689 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
Reid Spencerc4d96252007-01-13 00:03:30 +00002690 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002691 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2692 0, 0, 82, 0, 0, 83, 0, 84, 118, 0,
2693 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2694 0, 0, 82, 0, 0, 83, 0, 84, 226, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002695 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002696 81, 0, 0, 82, 0, 0, 83, 0, 84, 407,
2697 0, 348, 349, 65, 66, 350, 0, 0, 0, 0,
2698 81, 0, 0, 82, 0, 0, 83, 0, 84, 467,
2699 20, 0, 21, 0, 351, 352, 353, 0, 0, 0,
2700 0, 0, 0, 0, 0, 81, 354, 355, 82, 0,
2701 0, 83, 0, 84, 0, 0, 0, 0, 0, 0,
2702 0, 0, 0, 0, 0, 0, 0, 0, 0, 356,
2703 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2704 0, 0, 0, 0, 0, 0, 0, 135, 136, 137,
2705 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2706 148, 149, 150, 151, 152, 153, 154, 317, 318, 348,
2707 349, 0, 0, 350, 319, 0, 320, 163, 164, 165,
2708 166, 0, 321, 322, 323, 0, 0, 0, 0, 0,
2709 0, 0, 351, 352, 353, 0, 0, 0, 0, 0,
2710 0, 0, 0, 0, 354, 355, 0, 173, 174, 175,
2711 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2712 0, 0, 0, 0, 0, 0, 0, 356, 357, 0,
2713 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2714 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2715 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2716 150, 151, 152, 153, 154, 317, 318, 0, 0, 0,
2717 0, 0, 319, 0, 320, 163, 164, 165, 166, 0,
2718 321, 322, 323, 0, 0, 0, 0, 0, 0, 0,
2719 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2720 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2721 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2722 0, 0, 0, 0, 65, 66, 357, 117, 68, 69,
2723 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2724 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2725 0, 0, 0, 0, 0, 0, 341, 0, 0, 0,
2726 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2727 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2728 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2729 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2730 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2731 0, 0, 0, 0, 0, 0, 0, 423, 0, 0,
2732 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2733 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2734 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2735 0, 0, 0, 0, 0, 0, 0, 0, 477, 0,
2736 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2737 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2738 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2739 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2740 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2741 0, 0, 0, 0, 81, 0, 0, 82, 0, 402,
2742 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2743 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2744 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2745 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2746 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2747 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2748 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2749 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2750 79, 20, 0, 21, 65, 66, 0, 237, 68, 69,
2751 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2752 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2753 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2754 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2755 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2756 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2757 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2758 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2759 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2760 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer609ca3e2007-01-12 20:10:51 +00002761 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2762 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002763 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2764 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2765 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2766 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
Reid Spencer319a7302007-01-05 17:20:02 +00002767 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer950bf602007-01-26 08:19:09 +00002768 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2769 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
2770 83, 0, 405, 128, 129, 130, 131, 132, 133, 134,
2771 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2772 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
2773 155, 156, 157, 158, 159, 0, 0, 160, 161, 162,
2774 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
2775 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2776 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2777 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2778 183, 184, 185
Reid Spencer319a7302007-01-05 17:20:02 +00002779};
2780
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002781static const yytype_int16 yycheck[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002782{
Reid Spencer950bf602007-01-26 08:19:09 +00002783 37, 125, 130, 130, 128, 282, 53, 4, 23, 305,
2784 306, 3, 111, 222, 131, 30, 53, 34, 0, 15,
2785 15, 29, 52, 53, 54, 234, 84, 325, 326, 159,
2786 239, 240, 32, 33, 164, 159, 55, 56, 162, 335,
2787 57, 71, 251, 167, 168, 169, 170, 171, 172, 41,
2788 10, 11, 12, 13, 14, 15, 16, 17, 116, 357,
2789 557, 57, 57, 61, 122, 189, 190, 9, 153, 576,
2790 23, 108, 109, 110, 155, 284, 193, 152, 163, 21,
2791 577, 588, 153, 164, 155, 294, 295, 296, 125, 20,
2792 61, 128, 163, 164, 86, 10, 11, 12, 13, 14,
2793 15, 16, 17, 153, 55, 56, 57, 405, 153, 159,
2794 41, 42, 43, 44, 45, 46, 47, 153, 163, 50,
2795 157, 158, 159, 160, 161, 162, 153, 163, 24, 153,
2796 167, 168, 169, 170, 171, 172, 163, 161, 161, 153,
2797 153, 164, 152, 45, 0, 47, 159, 161, 163, 186,
2798 187, 188, 189, 190, 162, 4, 365, 366, 367, 104,
2799 105, 457, 116, 152, 373, 162, 224, 225, 122, 25,
2800 228, 22, 152, 24, 152, 31, 152, 301, 387, 388,
2801 27, 28, 3, 4, 157, 41, 42, 43, 44, 45,
2802 46, 47, 155, 230, 3, 4, 3, 4, 4, 159,
2803 3, 4, 3, 4, 4, 252, 62, 77, 78, 155,
2804 24, 488, 24, 490, 4, 252, 64, 65, 66, 67,
2805 68, 69, 70, 432, 158, 434, 263, 24, 158, 438,
2806 155, 59, 4, 4, 4, 4, 4, 446, 447, 448,
2807 7, 7, 7, 280, 159, 161, 153, 156, 153, 153,
2808 153, 375, 299, 377, 378, 379, 157, 36, 153, 153,
2809 153, 385, 299, 300, 301, 10, 11, 12, 13, 14,
2810 15, 16, 17, 153, 483, 484, 153, 486, 487, 153,
2811 153, 153, 24, 24, 493, 153, 155, 63, 346, 155,
2812 155, 155, 155, 502, 155, 155, 155, 155, 397, 398,
2813 399, 400, 401, 155, 161, 155, 239, 240, 153, 153,
2814 156, 410, 411, 412, 413, 414, 153, 153, 251, 157,
2815 153, 153, 153, 153, 34, 24, 535, 119, 120, 121,
2816 122, 123, 124, 125, 126, 127, 128, 155, 375, 376,
2817 377, 378, 379, 380, 381, 21, 21, 405, 385, 386,
2818 342, 284, 4, 155, 153, 153, 24, 153, 153, 458,
2819 459, 294, 295, 296, 153, 574, 465, 153, 155, 4,
2820 153, 495, 496, 497, 36, 153, 153, 161, 153, 153,
2821 589, 161, 4, 57, 421, 24, 57, 596, 21, 153,
2822 153, 600, 601, 153, 153, 153, 153, 153, 435, 153,
2823 153, 156, 153, 21, 36, 157, 156, 156, 156, 533,
2824 509, 510, 511, 512, 153, 159, 453, 516, 517, 518,
2825 519, 27, 28, 153, 153, 156, 159, 153, 156, 557,
2826 557, 156, 365, 366, 367, 156, 156, 156, 156, 156,
2827 373, 156, 541, 542, 156, 21, 153, 21, 485, 577,
2828 577, 21, 96, 96, 387, 388, 96, 41, 495, 496,
2829 497, 25, 317, 422, 501, 318, 565, 96, 567, 568,
2830 96, 52, 421, 61, 3, 222, 19, 595, 435, 501,
2831 -1, 460, -1, 520, -1, -1, -1, -1, -1, -1,
2832 -1, -1, -1, -1, -1, -1, 533, -1, -1, 432,
2833 -1, 434, -1, -1, -1, 438, -1, -1, -1, -1,
2834 -1, -1, -1, 446, 447, 448, -1, -1, -1, 125,
Reid Spencerc4d96252007-01-13 00:03:30 +00002835 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
Reid Spencer950bf602007-01-26 08:19:09 +00002836 136, 137, 138, -1, -1, -1, -1, -1, -1, -1,
2837 -1, -1, 5, 6, -1, -1, -1, -1, -1, -1,
2838 483, 484, -1, 486, 487, -1, -1, -1, -1, 22,
2839 493, 24, -1, 26, -1, -1, 20, -1, 22, 502,
2840 24, -1, -1, -1, -1, 38, 39, 31, 32, 33,
2841 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
2842 44, 45, 46, 47, -1, -1, 50, 51, -1, -1,
2843 -1, -1, 535, -1, 58, -1, -1, -1, 62, -1,
2844 -1, -1, -1, -1, -1, -1, 79, 80, 81, 82,
2845 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
2846 93, 94, 95, 96, 97, 98, 99, 100, -1, -1,
2847 -1, 574, -1, 106, -1, 108, 109, 110, 111, 112,
2848 -1, 114, 115, 116, -1, -1, 589, -1, -1, -1,
2849 -1, -1, -1, 596, -1, -1, -1, 600, 601, -1,
2850 -1, -1, -1, -1, -1, -1, 139, 140, 141, 142,
2851 143, 144, 145, 146, 147, 148, 149, 150, 151, -1,
2852 -1, -1, -1, -1, 157, -1, -1, 160, -1, 162,
2853 5, 6, 165, 8, 9, 10, 11, 12, 13, 14,
2854 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2855 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2856 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
2857 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2858 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2859 24, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2860 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
2861 24, -1, -1, -1, 48, -1, 5, 6, -1, 8,
2862 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2863 19, -1, 21, 22, 48, 24, -1, -1, -1, -1,
2864 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2865 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2866 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2867 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2868 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2869 -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
2870 -1, -1, 157, -1, -1, 160, -1, 162, 163, -1,
2871 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2872 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2873 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2874 154, -1, -1, 157, -1, -1, 160, -1, 162, 163,
2875 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2876 -1, -1, -1, -1, -1, 154, 38, 39, 157, -1,
2877 -1, 160, -1, 162, -1, -1, -1, -1, -1, -1,
2878 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2879 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2880 -1, -1, -1, -1, -1, -1, -1, 79, 80, 81,
2881 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2882 92, 93, 94, 95, 96, 97, 98, 99, 100, 3,
2883 4, -1, -1, 7, 106, -1, 108, 109, 110, 111,
2884 112, -1, 114, 115, 116, -1, -1, -1, -1, -1,
2885 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2886 -1, -1, -1, -1, 38, 39, -1, 139, 140, 141,
2887 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2888 -1, -1, -1, -1, -1, -1, -1, 61, 160, -1,
2889 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2890 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
2891 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2892 94, 95, 96, 97, 98, 99, 100, -1, -1, -1,
2893 -1, -1, 106, -1, 108, 109, 110, 111, 112, -1,
2894 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
2895 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2896 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
2897 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
2898 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
2899 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2900 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2901 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2902 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2903 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2904 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
2905 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2906 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
2907 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2908 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2909 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2910 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
2911 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2912 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2913 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2914 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
2915 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
2916 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2917 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
2918 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
2919 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
2920 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
2921 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
2922 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2923 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
2924 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
2925 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2926 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2927 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
2928 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2929 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
2930 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2931 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2932 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2933 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2934 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
2935 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
2936 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2937 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2938 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2939 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2940 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2941 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
2942 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
2943 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2944 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2945 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
2946 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
2947 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2948 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2949 99, 100, 101, 102, 103, -1, -1, 106, 107, 108,
2950 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2951 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2952 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2953 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
2954 149, 150, 151
Reid Spencer319a7302007-01-05 17:20:02 +00002955};
2956
2957/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2958 symbol of state STATE-NUM. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002959static const yytype_uint8 yystos[] =
Reid Spencer319a7302007-01-05 17:20:02 +00002960{
Reid Spencer950bf602007-01-26 08:19:09 +00002961 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
2962 44, 45, 46, 47, 62, 181, 219, 221, 223, 230,
2963 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
2964 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
2965 231, 232, 30, 163, 220, 231, 52, 53, 54, 71,
2966 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
2967 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
2968 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
2969 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
2970 193, 212, 227, 29, 162, 218, 180, 236, 152, 152,
2971 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
2972 199, 199, 217, 4, 4, 4, 162, 8, 163, 193,
2973 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
2974 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2975 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2976 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2977 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2978 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
2979 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
2980 175, 233, 234, 240, 241, 243, 244, 24, 55, 56,
2981 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
2982 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
2983 177, 179, 191, 196, 158, 158, 163, 194, 153, 163,
2984 155, 37, 194, 195, 191, 229, 59, 8, 229, 9,
2985 21, 10, 11, 12, 13, 14, 15, 16, 17, 176,
2986 177, 178, 182, 119, 120, 121, 122, 123, 124, 125,
2987 126, 127, 128, 172, 27, 28, 125, 126, 127, 128,
2988 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
2989 173, 191, 191, 229, 191, 191, 237, 229, 229, 229,
2990 229, 229, 229, 229, 191, 191, 191, 229, 229, 182,
2991 104, 105, 153, 159, 205, 206, 204, 27, 28, 3,
2992 4, 168, 4, 7, 26, 38, 39, 99, 100, 106,
2993 108, 114, 115, 116, 157, 160, 162, 165, 169, 170,
2994 171, 174, 175, 197, 227, 203, 193, 193, 161, 163,
2995 193, 37, 191, 214, 215, 216, 153, 156, 3, 4,
2996 7, 26, 27, 28, 38, 39, 61, 160, 197, 226,
2997 227, 228, 228, 228, 228, 189, 191, 191, 153, 184,
2998 153, 184, 228, 157, 153, 153, 153, 153, 153, 153,
2999 153, 153, 228, 228, 228, 153, 36, 189, 191, 229,
3000 24, 153, 187, 187, 187, 172, 173, 155, 155, 155,
3001 155, 155, 159, 196, 198, 162, 198, 163, 198, 24,
3002 155, 155, 155, 155, 155, 187, 159, 161, 161, 212,
3003 213, 153, 156, 37, 63, 225, 198, 153, 153, 228,
3004 228, 228, 15, 57, 15, 153, 242, 228, 157, 229,
3005 191, 229, 229, 229, 191, 191, 153, 153, 153, 229,
3006 191, 228, 228, 153, 34, 57, 185, 188, 155, 155,
3007 196, 196, 196, 196, 196, 153, 159, 163, 193, 198,
3008 161, 163, 196, 196, 196, 196, 196, 37, 214, 185,
3009 186, 24, 161, 21, 21, 155, 153, 153, 228, 4,
3010 228, 229, 238, 153, 228, 153, 153, 153, 228, 228,
3011 228, 155, 191, 24, 4, 187, 196, 196, 242, 153,
3012 153, 153, 153, 196, 161, 163, 153, 153, 153, 153,
3013 36, 57, 183, 153, 228, 228, 238, 239, 228, 228,
3014 153, 184, 184, 153, 228, 153, 229, 229, 229, 239,
3015 228, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3016 196, 196, 196, 191, 4, 24, 153, 157, 156, 229,
3017 159, 228, 156, 196, 196, 153, 156, 153, 153, 156,
3018 156, 156, 156, 156, 21, 159, 178, 235, 36, 159,
3019 156, 156, 196, 196, 196, 228, 226, 159, 178, 21,
3020 156, 156, 156, 153, 226, 228, 21, 153, 233, 228,
3021 21, 21, 228, 228
Reid Spencer319a7302007-01-05 17:20:02 +00003022};
Reid Spencere7c3c602006-11-30 06:36:44 +00003023
3024#define yyerrok (yyerrstatus = 0)
3025#define yyclearin (yychar = YYEMPTY)
Reid Spencer950bf602007-01-26 08:19:09 +00003026#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003027#define YYEOF 0
Reid Spencer319a7302007-01-05 17:20:02 +00003028
Reid Spencere7c3c602006-11-30 06:36:44 +00003029#define YYACCEPT goto yyacceptlab
Reid Spencer319a7302007-01-05 17:20:02 +00003030#define YYABORT goto yyabortlab
Reid Spencer950bf602007-01-26 08:19:09 +00003031#define YYERROR goto yyerrorlab
3032
Reid Spencer319a7302007-01-05 17:20:02 +00003033
3034/* Like YYERROR except do call yyerror. This remains here temporarily
3035 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003036 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer319a7302007-01-05 17:20:02 +00003037
Reid Spencere7c3c602006-11-30 06:36:44 +00003038#define YYFAIL goto yyerrlab
Reid Spencer319a7302007-01-05 17:20:02 +00003039
Reid Spencere7c3c602006-11-30 06:36:44 +00003040#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer319a7302007-01-05 17:20:02 +00003041
3042#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003043do \
3044 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer319a7302007-01-05 17:20:02 +00003045 { \
3046 yychar = (Token); \
3047 yylval = (Value); \
Reid Spencer950bf602007-01-26 08:19:09 +00003048 yytoken = YYTRANSLATE (yychar); \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003049 YYPOPSTACK (1); \
Reid Spencere7c3c602006-11-30 06:36:44 +00003050 goto yybackup; \
3051 } \
3052 else \
Reid Spencer950bf602007-01-26 08:19:09 +00003053 { \
3054 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer319a7302007-01-05 17:20:02 +00003055 YYERROR; \
3056 } \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003057while (YYID (0))
Reid Spencere7c3c602006-11-30 06:36:44 +00003058
Reid Spencer950bf602007-01-26 08:19:09 +00003059
Reid Spencere7c3c602006-11-30 06:36:44 +00003060#define YYTERROR 1
3061#define YYERRCODE 256
3062
Reid Spencer319a7302007-01-05 17:20:02 +00003063
Reid Spencer950bf602007-01-26 08:19:09 +00003064/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3065 If N is 0, then set CURRENT to the empty location which ends
3066 the previous symbol: RHS[0] (always defined). */
3067
3068#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer319a7302007-01-05 17:20:02 +00003069#ifndef YYLLOC_DEFAULT
Reid Spencer950bf602007-01-26 08:19:09 +00003070# define YYLLOC_DEFAULT(Current, Rhs, N) \
3071 do \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003072 if (YYID (N)) \
Reid Spencer950bf602007-01-26 08:19:09 +00003073 { \
3074 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3075 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3076 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3077 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3078 } \
3079 else \
3080 { \
3081 (Current).first_line = (Current).last_line = \
3082 YYRHSLOC (Rhs, 0).last_line; \
3083 (Current).first_column = (Current).last_column = \
3084 YYRHSLOC (Rhs, 0).last_column; \
3085 } \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003086 while (YYID (0))
Reid Spencere7c3c602006-11-30 06:36:44 +00003087#endif
3088
Reid Spencer950bf602007-01-26 08:19:09 +00003089
3090/* YY_LOCATION_PRINT -- Print the location on the stream.
3091 This macro was not mandated originally: define only if we know
3092 we won't break user code: when these are the locations we know. */
3093
3094#ifndef YY_LOCATION_PRINT
3095# if YYLTYPE_IS_TRIVIAL
3096# define YY_LOCATION_PRINT(File, Loc) \
3097 fprintf (File, "%d.%d-%d.%d", \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003098 (Loc).first_line, (Loc).first_column, \
3099 (Loc).last_line, (Loc).last_column)
Reid Spencer950bf602007-01-26 08:19:09 +00003100# else
3101# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3102# endif
3103#endif
3104
3105
Reid Spencer319a7302007-01-05 17:20:02 +00003106/* YYLEX -- calling `yylex' with the right arguments. */
3107
Reid Spencer950bf602007-01-26 08:19:09 +00003108#ifdef YYLEX_PARAM
3109# define YYLEX yylex (YYLEX_PARAM)
3110#else
3111# define YYLEX yylex ()
3112#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003113
3114/* Enable debugging if requested. */
3115#if YYDEBUG
3116
3117# ifndef YYFPRINTF
3118# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3119# define YYFPRINTF fprintf
3120# endif
3121
3122# define YYDPRINTF(Args) \
3123do { \
3124 if (yydebug) \
3125 YYFPRINTF Args; \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003126} while (YYID (0))
Reid Spencer950bf602007-01-26 08:19:09 +00003127
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003128# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3129do { \
3130 if (yydebug) \
3131 { \
3132 YYFPRINTF (stderr, "%s ", Title); \
3133 yy_symbol_print (stderr, \
3134 Type, Value); \
3135 YYFPRINTF (stderr, "\n"); \
3136 } \
3137} while (YYID (0))
3138
3139
3140/*--------------------------------.
3141| Print this symbol on YYOUTPUT. |
3142`--------------------------------*/
3143
3144/*ARGSUSED*/
3145#if (defined __STDC__ || defined __C99__FUNC__ \
3146 || defined __cplusplus || defined _MSC_VER)
3147static void
3148yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3149#else
3150static void
3151yy_symbol_value_print (yyoutput, yytype, yyvaluep)
3152 FILE *yyoutput;
3153 int yytype;
3154 YYSTYPE const * const yyvaluep;
3155#endif
3156{
3157 if (!yyvaluep)
3158 return;
3159# ifdef YYPRINT
3160 if (yytype < YYNTOKENS)
3161 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3162# else
3163 YYUSE (yyoutput);
3164# endif
3165 switch (yytype)
3166 {
3167 default:
3168 break;
3169 }
3170}
3171
3172
3173/*--------------------------------.
3174| Print this symbol on YYOUTPUT. |
3175`--------------------------------*/
3176
3177#if (defined __STDC__ || defined __C99__FUNC__ \
3178 || defined __cplusplus || defined _MSC_VER)
3179static void
3180yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3181#else
3182static void
3183yy_symbol_print (yyoutput, yytype, yyvaluep)
3184 FILE *yyoutput;
3185 int yytype;
3186 YYSTYPE const * const yyvaluep;
3187#endif
3188{
3189 if (yytype < YYNTOKENS)
3190 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3191 else
3192 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3193
3194 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3195 YYFPRINTF (yyoutput, ")");
3196}
Reid Spencer950bf602007-01-26 08:19:09 +00003197
3198/*------------------------------------------------------------------.
3199| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3200| TOP (included). |
3201`------------------------------------------------------------------*/
3202
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003203#if (defined __STDC__ || defined __C99__FUNC__ \
3204 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00003205static void
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003206yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
Reid Spencer950bf602007-01-26 08:19:09 +00003207#else
3208static void
3209yy_stack_print (bottom, top)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003210 yytype_int16 *bottom;
3211 yytype_int16 *top;
Reid Spencer950bf602007-01-26 08:19:09 +00003212#endif
3213{
3214 YYFPRINTF (stderr, "Stack now");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003215 for (; bottom <= top; ++bottom)
Reid Spencer950bf602007-01-26 08:19:09 +00003216 YYFPRINTF (stderr, " %d", *bottom);
3217 YYFPRINTF (stderr, "\n");
3218}
3219
3220# define YY_STACK_PRINT(Bottom, Top) \
3221do { \
3222 if (yydebug) \
3223 yy_stack_print ((Bottom), (Top)); \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003224} while (YYID (0))
Reid Spencer950bf602007-01-26 08:19:09 +00003225
3226
3227/*------------------------------------------------.
3228| Report that the YYRULE is going to be reduced. |
3229`------------------------------------------------*/
3230
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003231#if (defined __STDC__ || defined __C99__FUNC__ \
3232 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00003233static void
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003234yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
Reid Spencer950bf602007-01-26 08:19:09 +00003235#else
3236static void
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003237yy_reduce_print (yyvsp, yyrule)
3238 YYSTYPE *yyvsp;
Reid Spencer950bf602007-01-26 08:19:09 +00003239 int yyrule;
3240#endif
3241{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003242 int yynrhs = yyr2[yyrule];
Reid Spencer950bf602007-01-26 08:19:09 +00003243 int yyi;
3244 unsigned long int yylno = yyrline[yyrule];
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003245 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3246 yyrule - 1, yylno);
3247 /* The symbols being reduced. */
3248 for (yyi = 0; yyi < yynrhs; yyi++)
3249 {
3250 fprintf (stderr, " $%d = ", yyi + 1);
3251 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3252 &(yyvsp[(yyi + 1) - (yynrhs)])
3253 );
3254 fprintf (stderr, "\n");
3255 }
Reid Spencer950bf602007-01-26 08:19:09 +00003256}
3257
3258# define YY_REDUCE_PRINT(Rule) \
3259do { \
3260 if (yydebug) \
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003261 yy_reduce_print (yyvsp, Rule); \
3262} while (YYID (0))
Reid Spencer950bf602007-01-26 08:19:09 +00003263
Reid Spencer319a7302007-01-05 17:20:02 +00003264/* Nonzero means print parse trace. It is left uninitialized so that
3265 multiple parsers can coexist. */
3266int yydebug;
3267#else /* !YYDEBUG */
3268# define YYDPRINTF(Args)
Reid Spencer950bf602007-01-26 08:19:09 +00003269# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3270# define YY_STACK_PRINT(Bottom, Top)
3271# define YY_REDUCE_PRINT(Rule)
Reid Spencer319a7302007-01-05 17:20:02 +00003272#endif /* !YYDEBUG */
Reid Spencere7c3c602006-11-30 06:36:44 +00003273
Reid Spencer950bf602007-01-26 08:19:09 +00003274
Reid Spencer319a7302007-01-05 17:20:02 +00003275/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003276#ifndef YYINITDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003277# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003278#endif
3279
Reid Spencer319a7302007-01-05 17:20:02 +00003280/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3281 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003282
Reid Spencer319a7302007-01-05 17:20:02 +00003283 Do not make this value too large; the results are undefined if
Reid Spencer950bf602007-01-26 08:19:09 +00003284 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer319a7302007-01-05 17:20:02 +00003285 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003286
3287#ifndef YYMAXDEPTH
Reid Spencer319a7302007-01-05 17:20:02 +00003288# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003289#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003290
Reid Spencere7c3c602006-11-30 06:36:44 +00003291
3292
Reid Spencer319a7302007-01-05 17:20:02 +00003293#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003294
Reid Spencer319a7302007-01-05 17:20:02 +00003295# ifndef yystrlen
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003296# if defined __GLIBC__ && defined _STRING_H
Reid Spencer319a7302007-01-05 17:20:02 +00003297# define yystrlen strlen
3298# else
3299/* Return the length of YYSTR. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003300#if (defined __STDC__ || defined __C99__FUNC__ \
3301 || defined __cplusplus || defined _MSC_VER)
Reid Spencer319a7302007-01-05 17:20:02 +00003302static YYSIZE_T
Reid Spencer319a7302007-01-05 17:20:02 +00003303yystrlen (const char *yystr)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003304#else
3305static YYSIZE_T
Reid Spencer319a7302007-01-05 17:20:02 +00003306yystrlen (yystr)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003307 const char *yystr;
3308#endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003309{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003310 YYSIZE_T yylen;
3311 for (yylen = 0; yystr[yylen]; yylen++)
Reid Spencer319a7302007-01-05 17:20:02 +00003312 continue;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003313 return yylen;
Chris Lattner37e01c52007-01-04 18:46:42 +00003314}
Reid Spencer319a7302007-01-05 17:20:02 +00003315# endif
3316# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003317
Reid Spencer319a7302007-01-05 17:20:02 +00003318# ifndef yystpcpy
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003319# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
Reid Spencer319a7302007-01-05 17:20:02 +00003320# define yystpcpy stpcpy
3321# else
3322/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3323 YYDEST. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003324#if (defined __STDC__ || defined __C99__FUNC__ \
3325 || defined __cplusplus || defined _MSC_VER)
Reid Spencer319a7302007-01-05 17:20:02 +00003326static char *
Reid Spencer319a7302007-01-05 17:20:02 +00003327yystpcpy (char *yydest, const char *yysrc)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003328#else
3329static char *
Reid Spencer319a7302007-01-05 17:20:02 +00003330yystpcpy (yydest, yysrc)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003331 char *yydest;
3332 const char *yysrc;
3333#endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003334{
Reid Spencer950bf602007-01-26 08:19:09 +00003335 char *yyd = yydest;
3336 const char *yys = yysrc;
Chris Lattner37e01c52007-01-04 18:46:42 +00003337
Reid Spencer319a7302007-01-05 17:20:02 +00003338 while ((*yyd++ = *yys++) != '\0')
3339 continue;
3340
3341 return yyd - 1;
Chris Lattner37e01c52007-01-04 18:46:42 +00003342}
Reid Spencer319a7302007-01-05 17:20:02 +00003343# endif
3344# endif
Chris Lattner37e01c52007-01-04 18:46:42 +00003345
Reid Spencer950bf602007-01-26 08:19:09 +00003346# ifndef yytnamerr
3347/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3348 quotes and backslashes, so that it's suitable for yyerror. The
3349 heuristic is that double-quoting is unnecessary unless the string
3350 contains an apostrophe, a comma, or backslash (other than
3351 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3352 null, do not copy; instead, return the length of what the result
3353 would have been. */
3354static YYSIZE_T
3355yytnamerr (char *yyres, const char *yystr)
3356{
3357 if (*yystr == '"')
3358 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003359 YYSIZE_T yyn = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00003360 char const *yyp = yystr;
3361
3362 for (;;)
3363 switch (*++yyp)
3364 {
3365 case '\'':
3366 case ',':
3367 goto do_not_strip_quotes;
3368
3369 case '\\':
3370 if (*++yyp != '\\')
3371 goto do_not_strip_quotes;
3372 /* Fall through. */
3373 default:
3374 if (yyres)
3375 yyres[yyn] = *yyp;
3376 yyn++;
3377 break;
3378
3379 case '"':
3380 if (yyres)
3381 yyres[yyn] = '\0';
3382 return yyn;
3383 }
3384 do_not_strip_quotes: ;
3385 }
3386
3387 if (! yyres)
3388 return yystrlen (yystr);
3389
3390 return yystpcpy (yyres, yystr) - yyres;
3391}
3392# endif
3393
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003394/* Copy into YYRESULT an error message about the unexpected token
3395 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3396 including the terminating null byte. If YYRESULT is null, do not
3397 copy anything; just return the number of bytes that would be
3398 copied. As a special case, return 0 if an ordinary "syntax error"
3399 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3400 size calculation. */
3401static YYSIZE_T
3402yysyntax_error (char *yyresult, int yystate, int yychar)
3403{
3404 int yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003405
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003406 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3407 return 0;
3408 else
3409 {
3410 int yytype = YYTRANSLATE (yychar);
3411 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3412 YYSIZE_T yysize = yysize0;
3413 YYSIZE_T yysize1;
3414 int yysize_overflow = 0;
3415 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3416 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3417 int yyx;
3418
3419# if 0
3420 /* This is so xgettext sees the translatable formats that are
3421 constructed on the fly. */
3422 YY_("syntax error, unexpected %s");
3423 YY_("syntax error, unexpected %s, expecting %s");
3424 YY_("syntax error, unexpected %s, expecting %s or %s");
3425 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3426 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3427# endif
3428 char *yyfmt;
3429 char const *yyf;
3430 static char const yyunexpected[] = "syntax error, unexpected %s";
3431 static char const yyexpecting[] = ", expecting %s";
3432 static char const yyor[] = " or %s";
3433 char yyformat[sizeof yyunexpected
3434 + sizeof yyexpecting - 1
3435 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3436 * (sizeof yyor - 1))];
3437 char const *yyprefix = yyexpecting;
3438
3439 /* Start YYX at -YYN if negative to avoid negative indexes in
3440 YYCHECK. */
3441 int yyxbegin = yyn < 0 ? -yyn : 0;
3442
3443 /* Stay within bounds of both yycheck and yytname. */
3444 int yychecklim = YYLAST - yyn + 1;
3445 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3446 int yycount = 1;
3447
3448 yyarg[0] = yytname[yytype];
3449 yyfmt = yystpcpy (yyformat, yyunexpected);
3450
3451 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3452 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3453 {
3454 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3455 {
3456 yycount = 1;
3457 yysize = yysize0;
3458 yyformat[sizeof yyunexpected - 1] = '\0';
3459 break;
3460 }
3461 yyarg[yycount++] = yytname[yyx];
3462 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3463 yysize_overflow |= (yysize1 < yysize);
3464 yysize = yysize1;
3465 yyfmt = yystpcpy (yyfmt, yyprefix);
3466 yyprefix = yyor;
3467 }
3468
3469 yyf = YY_(yyformat);
3470 yysize1 = yysize + yystrlen (yyf);
3471 yysize_overflow |= (yysize1 < yysize);
3472 yysize = yysize1;
3473
3474 if (yysize_overflow)
3475 return YYSIZE_MAXIMUM;
3476
3477 if (yyresult)
3478 {
3479 /* Avoid sprintf, as that infringes on the user's name space.
3480 Don't have undefined behavior even if the translation
3481 produced a string with the wrong number of "%s"s. */
3482 char *yyp = yyresult;
3483 int yyi = 0;
3484 while ((*yyp = *yyf) != '\0')
3485 {
3486 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3487 {
3488 yyp += yytnamerr (yyp, yyarg[yyi++]);
3489 yyf += 2;
3490 }
3491 else
3492 {
3493 yyp++;
3494 yyf++;
3495 }
3496 }
3497 }
3498 return yysize;
3499 }
3500}
3501#endif /* YYERROR_VERBOSE */
Reid Spencere7c3c602006-11-30 06:36:44 +00003502
3503
Reid Spencer319a7302007-01-05 17:20:02 +00003504/*-----------------------------------------------.
3505| Release the memory associated to this symbol. |
3506`-----------------------------------------------*/
3507
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003508/*ARGSUSED*/
3509#if (defined __STDC__ || defined __C99__FUNC__ \
3510 || defined __cplusplus || defined _MSC_VER)
Reid Spencer950bf602007-01-26 08:19:09 +00003511static void
3512yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer319a7302007-01-05 17:20:02 +00003513#else
Reid Spencer950bf602007-01-26 08:19:09 +00003514static void
3515yydestruct (yymsg, yytype, yyvaluep)
3516 const char *yymsg;
Reid Spencer319a7302007-01-05 17:20:02 +00003517 int yytype;
Reid Spencer950bf602007-01-26 08:19:09 +00003518 YYSTYPE *yyvaluep;
Reid Spencer319a7302007-01-05 17:20:02 +00003519#endif
3520{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003521 YYUSE (yyvaluep);
Reid Spencer950bf602007-01-26 08:19:09 +00003522
3523 if (!yymsg)
3524 yymsg = "Deleting";
3525 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer319a7302007-01-05 17:20:02 +00003526
3527 switch (yytype)
3528 {
Reid Spencer950bf602007-01-26 08:19:09 +00003529
Reid Spencer319a7302007-01-05 17:20:02 +00003530 default:
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003531 break;
Reid Spencer319a7302007-01-05 17:20:02 +00003532 }
3533}
3534
3535
Reid Spencer950bf602007-01-26 08:19:09 +00003536/* Prevent warnings from -Wmissing-prototypes. */
Reid Spencer319a7302007-01-05 17:20:02 +00003537
3538#ifdef YYPARSE_PARAM
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003539#if defined __STDC__ || defined __cplusplus
Reid Spencer950bf602007-01-26 08:19:09 +00003540int yyparse (void *YYPARSE_PARAM);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003541#else
Reid Spencer950bf602007-01-26 08:19:09 +00003542int yyparse ();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003543#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003544#else /* ! YYPARSE_PARAM */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003545#if defined __STDC__ || defined __cplusplus
Reid Spencere7c3c602006-11-30 06:36:44 +00003546int yyparse (void);
Reid Spencer950bf602007-01-26 08:19:09 +00003547#else
3548int yyparse ();
Reid Spencer319a7302007-01-05 17:20:02 +00003549#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003550#endif /* ! YYPARSE_PARAM */
Reid Spencer319a7302007-01-05 17:20:02 +00003551
3552
Reid Spencer950bf602007-01-26 08:19:09 +00003553
3554/* The look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003555int yychar;
3556
Reid Spencer950bf602007-01-26 08:19:09 +00003557/* The semantic value of the look-ahead symbol. */
Reid Spencer319a7302007-01-05 17:20:02 +00003558YYSTYPE yylval;
3559
Reid Spencer950bf602007-01-26 08:19:09 +00003560/* Number of syntax errors so far. */
Reid Spencer319a7302007-01-05 17:20:02 +00003561int yynerrs;
3562
3563
Reid Spencer950bf602007-01-26 08:19:09 +00003564
3565/*----------.
3566| yyparse. |
3567`----------*/
3568
3569#ifdef YYPARSE_PARAM
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003570#if (defined __STDC__ || defined __C99__FUNC__ \
3571 || defined __cplusplus || defined _MSC_VER)
3572int
3573yyparse (void *YYPARSE_PARAM)
3574#else
3575int
3576yyparse (YYPARSE_PARAM)
3577 void *YYPARSE_PARAM;
3578#endif
Reid Spencer950bf602007-01-26 08:19:09 +00003579#else /* ! YYPARSE_PARAM */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003580#if (defined __STDC__ || defined __C99__FUNC__ \
3581 || defined __cplusplus || defined _MSC_VER)
Reid Spencer319a7302007-01-05 17:20:02 +00003582int
Reid Spencer950bf602007-01-26 08:19:09 +00003583yyparse (void)
3584#else
3585int
3586yyparse ()
3587
3588#endif
3589#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003590{
3591
Reid Spencer950bf602007-01-26 08:19:09 +00003592 int yystate;
3593 int yyn;
Reid Spencer319a7302007-01-05 17:20:02 +00003594 int yyresult;
3595 /* Number of tokens to shift before error messages enabled. */
3596 int yyerrstatus;
Reid Spencer950bf602007-01-26 08:19:09 +00003597 /* Look-ahead token as an internal (translated) token number. */
3598 int yytoken = 0;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003599#if YYERROR_VERBOSE
3600 /* Buffer for error messages, and its allocated size. */
3601 char yymsgbuf[128];
3602 char *yymsg = yymsgbuf;
3603 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3604#endif
Reid Spencer319a7302007-01-05 17:20:02 +00003605
3606 /* Three stacks and their tools:
3607 `yyss': related to states,
3608 `yyvs': related to semantic values,
3609 `yyls': related to locations.
3610
3611 Refer to the stacks thru separate pointers, to allow yyoverflow
3612 to reallocate them elsewhere. */
3613
3614 /* The state stack. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003615 yytype_int16 yyssa[YYINITDEPTH];
3616 yytype_int16 *yyss = yyssa;
3617 yytype_int16 *yyssp;
Reid Spencer319a7302007-01-05 17:20:02 +00003618
3619 /* The semantic value stack. */
3620 YYSTYPE yyvsa[YYINITDEPTH];
3621 YYSTYPE *yyvs = yyvsa;
Reid Spencer950bf602007-01-26 08:19:09 +00003622 YYSTYPE *yyvsp;
Reid Spencer319a7302007-01-05 17:20:02 +00003623
3624
3625
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003626#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
Reid Spencere7c3c602006-11-30 06:36:44 +00003627
Reid Spencer319a7302007-01-05 17:20:02 +00003628 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencere7c3c602006-11-30 06:36:44 +00003629
Reid Spencer319a7302007-01-05 17:20:02 +00003630 /* The variables used to return semantic value and location from the
3631 action routines. */
3632 YYSTYPE yyval;
Reid Spencere7c3c602006-11-30 06:36:44 +00003633
3634
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003635 /* The number of symbols on the RHS of the reduced rule.
3636 Keep to zero when no symbol should be popped. */
3637 int yylen = 0;
Reid Spencere7c3c602006-11-30 06:36:44 +00003638
Reid Spencer319a7302007-01-05 17:20:02 +00003639 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003640
3641 yystate = 0;
3642 yyerrstatus = 0;
3643 yynerrs = 0;
3644 yychar = YYEMPTY; /* Cause a token to be read. */
3645
3646 /* Initialize stack pointers.
3647 Waste one element of value and location stack
3648 so that they stay on the same level as the state stack.
3649 The wasted elements are never initialized. */
3650
Reid Spencer319a7302007-01-05 17:20:02 +00003651 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003652 yyvsp = yyvs;
3653
Reid Spencer319a7302007-01-05 17:20:02 +00003654 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003655
Reid Spencer319a7302007-01-05 17:20:02 +00003656/*------------------------------------------------------------.
3657| yynewstate -- Push a new state, which is found in yystate. |
3658`------------------------------------------------------------*/
3659 yynewstate:
3660 /* In all cases, when you get here, the value and location stacks
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003661 have just been pushed. So pushing a state here evens the stacks. */
Reid Spencer319a7302007-01-05 17:20:02 +00003662 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003663
Reid Spencer319a7302007-01-05 17:20:02 +00003664 yysetstate:
3665 *yyssp = yystate;
3666
Reid Spencer950bf602007-01-26 08:19:09 +00003667 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003668 {
3669 /* Get the current used size of the three stacks, in elements. */
Reid Spencer319a7302007-01-05 17:20:02 +00003670 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003671
3672#ifdef yyoverflow
Reid Spencer319a7302007-01-05 17:20:02 +00003673 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003674 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer319a7302007-01-05 17:20:02 +00003675 these so that the &'s don't force the real ones into
3676 memory. */
3677 YYSTYPE *yyvs1 = yyvs;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003678 yytype_int16 *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003679
Reid Spencer319a7302007-01-05 17:20:02 +00003680
3681 /* Each stack pointer address is followed by the size of the
3682 data in use in that stack, in bytes. This used to be a
3683 conditional around just the two extra args, but that might
3684 be undefined if yyoverflow is a macro. */
Reid Spencer950bf602007-01-26 08:19:09 +00003685 yyoverflow (YY_("memory exhausted"),
Reid Spencer319a7302007-01-05 17:20:02 +00003686 &yyss1, yysize * sizeof (*yyssp),
3687 &yyvs1, yysize * sizeof (*yyvsp),
3688
3689 &yystacksize);
3690
3691 yyss = yyss1;
3692 yyvs = yyvs1;
3693 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003694#else /* no yyoverflow */
Reid Spencer319a7302007-01-05 17:20:02 +00003695# ifndef YYSTACK_RELOCATE
Reid Spencer950bf602007-01-26 08:19:09 +00003696 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003697# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003698 /* Extend the stack our own way. */
Reid Spencer950bf602007-01-26 08:19:09 +00003699 if (YYMAXDEPTH <= yystacksize)
3700 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003701 yystacksize *= 2;
Reid Spencer950bf602007-01-26 08:19:09 +00003702 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003703 yystacksize = YYMAXDEPTH;
Reid Spencer319a7302007-01-05 17:20:02 +00003704
3705 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003706 yytype_int16 *yyss1 = yyss;
Reid Spencer319a7302007-01-05 17:20:02 +00003707 union yyalloc *yyptr =
3708 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3709 if (! yyptr)
Reid Spencer950bf602007-01-26 08:19:09 +00003710 goto yyexhaustedlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003711 YYSTACK_RELOCATE (yyss);
3712 YYSTACK_RELOCATE (yyvs);
3713
3714# undef YYSTACK_RELOCATE
3715 if (yyss1 != yyssa)
3716 YYSTACK_FREE (yyss1);
3717 }
3718# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003719#endif /* no yyoverflow */
3720
Reid Spencer319a7302007-01-05 17:20:02 +00003721 yyssp = yyss + yysize - 1;
3722 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003723
3724
Reid Spencer319a7302007-01-05 17:20:02 +00003725 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3726 (unsigned long int) yystacksize));
3727
Reid Spencer950bf602007-01-26 08:19:09 +00003728 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003729 YYABORT;
3730 }
3731
Reid Spencer319a7302007-01-05 17:20:02 +00003732 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003733
3734 goto yybackup;
Reid Spencer319a7302007-01-05 17:20:02 +00003735
3736/*-----------.
3737| yybackup. |
3738`-----------*/
3739yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003740
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003741 /* Do appropriate processing given the current state. Read a
3742 look-ahead token if we need one and don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003743
Reid Spencer950bf602007-01-26 08:19:09 +00003744 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003745 yyn = yypact[yystate];
Reid Spencer319a7302007-01-05 17:20:02 +00003746 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003747 goto yydefault;
3748
Reid Spencer950bf602007-01-26 08:19:09 +00003749 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003750
Reid Spencer950bf602007-01-26 08:19:09 +00003751 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003752 if (yychar == YYEMPTY)
3753 {
Reid Spencer319a7302007-01-05 17:20:02 +00003754 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003755 yychar = YYLEX;
3756 }
3757
Reid Spencer950bf602007-01-26 08:19:09 +00003758 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003759 {
Reid Spencer950bf602007-01-26 08:19:09 +00003760 yychar = yytoken = YYEOF;
Reid Spencer319a7302007-01-05 17:20:02 +00003761 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003762 }
3763 else
3764 {
Reid Spencer950bf602007-01-26 08:19:09 +00003765 yytoken = YYTRANSLATE (yychar);
3766 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003767 }
3768
Reid Spencer950bf602007-01-26 08:19:09 +00003769 /* If the proper action on seeing token YYTOKEN is to reduce or to
Reid Spencer319a7302007-01-05 17:20:02 +00003770 detect an error, take that action. */
Reid Spencer950bf602007-01-26 08:19:09 +00003771 yyn += yytoken;
3772 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003773 goto yydefault;
3774 yyn = yytable[yyn];
Reid Spencer319a7302007-01-05 17:20:02 +00003775 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003776 {
Reid Spencer319a7302007-01-05 17:20:02 +00003777 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003778 goto yyerrlab;
3779 yyn = -yyn;
3780 goto yyreduce;
3781 }
3782
3783 if (yyn == YYFINAL)
3784 YYACCEPT;
3785
Reid Spencer319a7302007-01-05 17:20:02 +00003786 /* Count tokens shifted since error; after three, turn off error
3787 status. */
3788 if (yyerrstatus)
3789 yyerrstatus--;
Reid Spencere7c3c602006-11-30 06:36:44 +00003790
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003791 /* Shift the look-ahead token. */
3792 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3793
3794 /* Discard the shifted token unless it is eof. */
3795 if (yychar != YYEOF)
3796 yychar = YYEMPTY;
3797
Reid Spencere7c3c602006-11-30 06:36:44 +00003798 yystate = yyn;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003799 *++yyvsp = yylval;
3800
Reid Spencere7c3c602006-11-30 06:36:44 +00003801 goto yynewstate;
3802
Chris Lattner37e01c52007-01-04 18:46:42 +00003803
Reid Spencer319a7302007-01-05 17:20:02 +00003804/*-----------------------------------------------------------.
3805| yydefault -- do the default action for the current state. |
3806`-----------------------------------------------------------*/
3807yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003808 yyn = yydefact[yystate];
3809 if (yyn == 0)
3810 goto yyerrlab;
Reid Spencer319a7302007-01-05 17:20:02 +00003811 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003812
Reid Spencer319a7302007-01-05 17:20:02 +00003813
3814/*-----------------------------.
3815| yyreduce -- Do a reduction. |
3816`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003817yyreduce:
Reid Spencer319a7302007-01-05 17:20:02 +00003818 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003819 yylen = yyr2[yyn];
3820
Reid Spencer319a7302007-01-05 17:20:02 +00003821 /* If YYLEN is nonzero, implement the default value of the action:
3822 `$$ = $1'.
3823
3824 Otherwise, the following line sets YYVAL to garbage.
3825 This behavior is undocumented and Bison
3826 users should not rely upon it. Assigning to YYVAL
3827 unconditionally makes the parser a bit smaller, and it avoids a
3828 GCC warning that YYVAL may be used uninitialized. */
3829 yyval = yyvsp[1-yylen];
3830
3831
Reid Spencer950bf602007-01-26 08:19:09 +00003832 YY_REDUCE_PRINT (yyn);
Reid Spencer319a7302007-01-05 17:20:02 +00003833 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003834 {
Reid Spencer950bf602007-01-26 08:19:09 +00003835 case 3:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003836#line 1532 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003837 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003838 if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003839 error("Value too large for type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003840 (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003841 ;}
3842 break;
3843
3844 case 5:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003845#line 1541 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003846 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003847 if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003848 error("Value too large for type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003849 (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00003850 ;}
3851 break;
3852
3853 case 26:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003854#line 1563 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003855 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3856 break;
3857
3858 case 27:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003859#line 1563 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003860 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3861 break;
3862
3863 case 28:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003864#line 1564 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003865 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3866 break;
3867
3868 case 29:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003869#line 1564 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003870 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3871 break;
3872
3873 case 30:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003874#line 1565 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003875 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3876 break;
3877
3878 case 31:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003879#line 1565 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003880 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3881 break;
3882
3883 case 32:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003884#line 1566 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003885 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3886 break;
3887
3888 case 33:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003889#line 1566 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003890 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3891 break;
3892
3893 case 34:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003894#line 1567 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003895 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3896 break;
3897
3898 case 35:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003899#line 1567 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003900 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3901 break;
3902
3903 case 36:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003904#line 1571 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003905 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3906 break;
3907
3908 case 37:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003909#line 1571 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003910 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3911 break;
3912
3913 case 38:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003914#line 1572 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003915 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3916 break;
3917
3918 case 39:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003919#line 1572 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003920 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3921 break;
3922
3923 case 40:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003924#line 1573 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003925 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
3926 break;
3927
3928 case 41:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003929#line 1573 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003930 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
3931 break;
3932
3933 case 42:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003934#line 1574 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003935 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
3936 break;
3937
3938 case 43:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003939#line 1574 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003940 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
3941 break;
3942
3943 case 44:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003944#line 1575 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003945 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
3946 break;
3947
3948 case 45:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003949#line 1575 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003950 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
3951 break;
3952
3953 case 46:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003954#line 1576 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003955 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
3956 break;
3957
3958 case 47:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003959#line 1576 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003960 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
3961 break;
3962
3963 case 48:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003964#line 1577 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003965 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
3966 break;
3967
3968 case 49:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003969#line 1577 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003970 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
3971 break;
3972
3973 case 50:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003974#line 1578 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003975 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
3976 break;
3977
3978 case 51:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003979#line 1579 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003980 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
3981 break;
3982
3983 case 81:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003984#line 1610 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003985 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003986 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00003987 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00003988 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00003989
Reid Spencer319a7302007-01-05 17:20:02 +00003990 case 82:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003991#line 1613 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00003992 {
Reid Spencer950bf602007-01-26 08:19:09 +00003993 (yyval.StrVal) = 0;
3994 ;}
3995 break;
3996
3997 case 83:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00003998#line 1618 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00003999 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
4000 break;
4001
4002 case 84:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004003#line 1619 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004004 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
4005 break;
4006
4007 case 85:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004008#line 1620 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004009 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
4010 break;
4011
4012 case 86:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004013#line 1621 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004014 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
4015 break;
4016
4017 case 87:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004018#line 1622 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004019 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
4020 break;
4021
4022 case 88:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004023#line 1623 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004024 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
4025 break;
4026
4027 case 89:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004028#line 1624 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004029 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004030 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00004031
Reid Spencer319a7302007-01-05 17:20:02 +00004032 case 90:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004033#line 1625 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004034 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
4035 break;
4036
4037 case 91:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004038#line 1629 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004039 { (yyval.UIntVal) = CallingConv::C; ;}
4040 break;
4041
4042 case 92:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004043#line 1630 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004044 { (yyval.UIntVal) = CallingConv::C; ;}
4045 break;
4046
4047 case 93:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004048#line 1631 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004049 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004050 break;
4051
4052 case 94:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004053#line 1632 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004054 { (yyval.UIntVal) = CallingConv::Fast; ;}
4055 break;
4056
4057 case 95:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004058#line 1633 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004059 { (yyval.UIntVal) = CallingConv::Cold; ;}
4060 break;
4061
4062 case 96:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004063#line 1634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004064 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004065 break;
Reid Spencere77e35e2006-12-01 20:26:20 +00004066
Reid Spencer319a7302007-01-05 17:20:02 +00004067 case 97:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004068#line 1635 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004069 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004070 break;
Reid Spencer16244f42006-12-01 21:10:07 +00004071
Reid Spencer319a7302007-01-05 17:20:02 +00004072 case 98:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004073#line 1636 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004074 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004075 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004076 error("Calling conv too large");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004077 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00004078 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004079 break;
Reid Spencere7c3c602006-11-30 06:36:44 +00004080
Reid Spencer319a7302007-01-05 17:20:02 +00004081 case 99:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004082#line 1646 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004083 { (yyval.UIntVal) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004084 break;
4085
Reid Spencerc4d96252007-01-13 00:03:30 +00004086 case 100:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004087#line 1647 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004088 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004089 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00004090 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4091 error("Alignment must be a power of two");
4092 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004093 break;
4094
4095 case 101:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004096#line 1655 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004097 { (yyval.UIntVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004098 break;
4099
4100 case 102:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004101#line 1656 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004102 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004103 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
Reid Spencer950bf602007-01-26 08:19:09 +00004104 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
4105 error("Alignment must be a power of two");
4106 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004107 break;
4108
4109 case 103:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004110#line 1664 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004111 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004112 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
4113 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00004114 error("Invalid character in section name");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004115 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004116 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004117 break;
4118
4119 case 104:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004120#line 1673 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004121 { (yyval.StrVal) = 0; ;}
4122 break;
4123
4124 case 105:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004125#line 1674 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004126 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004127 break;
4128
Reid Spencerc4d96252007-01-13 00:03:30 +00004129 case 106:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004130#line 1681 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004131 {;}
Reid Spencerc4d96252007-01-13 00:03:30 +00004132 break;
4133
Reid Spencer319a7302007-01-05 17:20:02 +00004134 case 107:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004135#line 1682 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004136 {;}
4137 break;
4138
4139 case 108:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004140#line 1686 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004141 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004142 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
4143 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004144 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004145 break;
4146
4147 case 109:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004148#line 1690 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004149 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004150 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004151 error("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004152 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004153
4154 ;}
4155 break;
4156
4157 case 111:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004158#line 1707 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004159 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004160 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00004161 (yyval.TypeVal).S = Signless;
4162 ;}
4163 break;
4164
4165 case 113:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004166#line 1715 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004167 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004168 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
Reid Spencer950bf602007-01-26 08:19:09 +00004169 (yyval.TypeVal).S = Signless;
4170 ;}
4171 break;
4172
4173 case 114:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004174#line 1722 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004175 {
4176 if (!UpRefs.empty())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004177 error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).T)->getDescription());
4178 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004179 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004180 break;
4181
4182 case 127:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004183#line 1736 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004184 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004185 (yyval.TypeVal).T = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4186 (yyval.TypeVal).S = (yyvsp[(1) - (1)].PrimType).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004187 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004188 break;
4189
4190 case 128:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004191#line 1740 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004192 {
4193 (yyval.TypeVal).T = new PATypeHolder(OpaqueType::get());
4194 (yyval.TypeVal).S = Signless;
4195 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004196 break;
4197
4198 case 129:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004199#line 1744 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004200 { // Named types are also simple types...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004201 const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004202 (yyval.TypeVal).T = new PATypeHolder(tmp);
4203 (yyval.TypeVal).S = Signless; // FIXME: what if its signed?
4204 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004205 break;
4206
4207 case 130:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004208#line 1749 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004209 { // Type UpReference
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004210 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004211 error("Value out of range");
4212 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004213 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
Reid Spencer950bf602007-01-26 08:19:09 +00004214 (yyval.TypeVal).T = new PATypeHolder(OT);
4215 (yyval.TypeVal).S = Signless;
4216 UR_OUT("New Upreference!\n");
4217 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004218 break;
4219
4220 case 131:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004221#line 1758 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004222 { // Function derived type?
Reid Spencer950bf602007-01-26 08:19:09 +00004223 std::vector<const Type*> Params;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004224 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
4225 E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004226 Params.push_back(I->T->get());
4227 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004228 }
Reid Spencer950bf602007-01-26 08:19:09 +00004229 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4230 if (isVarArg) Params.pop_back();
4231
4232 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004233 FunctionType::get((yyvsp[(1) - (4)].TypeVal).T->get(),Params,isVarArg)));
4234 (yyval.TypeVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4235 delete (yyvsp[(1) - (4)].TypeVal).T; // Delete the return type handle
4236 delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00004237 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004238 break;
4239
4240 case 132:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004241#line 1774 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004242 { // Sized array type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004243 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).T->get(),
4244 (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4245 (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4246 delete (yyvsp[(4) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004247 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004248 break;
4249
4250 case 133:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004251#line 1780 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004252 { // Packed array type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004253 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).T->get();
4254 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004255 error("Unsigned result not equal to signed result");
4256 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4257 error("Elements of a PackedType must be integer or floating point");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004258 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004259 error("PackedType length should be a power of 2");
4260 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PackedType::get(ElemTy,
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004261 (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4262 (yyval.TypeVal).S = (yyvsp[(4) - (5)].TypeVal).S;
4263 delete (yyvsp[(4) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004264 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004265 break;
4266
4267 case 134:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004268#line 1793 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004269 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004270 std::vector<const Type*> Elements;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004271 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4272 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Reid Spencer950bf602007-01-26 08:19:09 +00004273 Elements.push_back(I->T->get());
4274 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4275 (yyval.TypeVal).S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004276 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004277 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004278 break;
4279
4280 case 135:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004281#line 1802 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004282 { // Empty structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004283 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4284 (yyval.TypeVal).S = Signless;
4285 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004286 break;
4287
4288 case 136:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004289#line 1806 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004290 { // Packed Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004291 std::vector<const Type*> Elements;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004292 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4293 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00004294 Elements.push_back(I->T->get());
4295 delete I->T;
Reid Spencer52402b02007-01-02 05:45:11 +00004296 }
Reid Spencer950bf602007-01-26 08:19:09 +00004297 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4298 (yyval.TypeVal).S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004299 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer950bf602007-01-26 08:19:09 +00004300 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004301 break;
4302
4303 case 137:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004304#line 1817 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004305 { // Empty packed structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004306 (yyval.TypeVal).T = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4307 (yyval.TypeVal).S = Signless;
4308 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004309 break;
4310
4311 case 138:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004312#line 1821 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004313 { // Pointer type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004314 if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004315 error("Cannot form a pointer to a basic block");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004316 (yyval.TypeVal).T = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).T->get())));
4317 (yyval.TypeVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4318 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004319 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004320 break;
4321
4322 case 139:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004323#line 1834 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004324 {
Reid Spencer950bf602007-01-26 08:19:09 +00004325 (yyval.TypeList) = new std::list<PATypeInfo>();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004326 (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004327 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004328 break;
4329
4330 case 140:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004331#line 1838 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004332 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004333 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004334 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004335 break;
4336
4337 case 142:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004338#line 1846 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004339 {
Reid Spencer950bf602007-01-26 08:19:09 +00004340 PATypeInfo VoidTI;
4341 VoidTI.T = new PATypeHolder(Type::VoidTy);
4342 VoidTI.S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004343 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
Reid Spencer950bf602007-01-26 08:19:09 +00004344 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004345 break;
4346
4347 case 143:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004348#line 1852 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004349 {
Reid Spencer950bf602007-01-26 08:19:09 +00004350 (yyval.TypeList) = new std::list<PATypeInfo>();
4351 PATypeInfo VoidTI;
4352 VoidTI.T = new PATypeHolder(Type::VoidTy);
4353 VoidTI.S = Signless;
4354 (yyval.TypeList)->push_back(VoidTI);
4355 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004356 break;
4357
4358 case 144:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004359#line 1859 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004360 {
Reid Spencer950bf602007-01-26 08:19:09 +00004361 (yyval.TypeList) = new std::list<PATypeInfo>();
4362 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004363 break;
4364
4365 case 145:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004366#line 1871 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004367 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004368 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004369 if (ATy == 0)
4370 error("Cannot make array constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004371 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004372 const Type *ETy = ATy->getElementType();
4373 int NumElements = ATy->getNumElements();
4374
4375 // Verify that we have the correct size...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004376 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004377 error("Type mismatch: constant sized array initialized with " +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004378 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004379 itostr(NumElements) + "");
4380
4381 // Verify all elements are correct type!
4382 std::vector<Constant*> Elems;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004383 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4384 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004385 const Type* ValTy = C->getType();
4386 if (ETy != ValTy)
4387 error("Element #" + utostr(i) + " is not of type '" +
4388 ETy->getDescription() +"' as required!\nIt is of type '"+
4389 ValTy->getDescription() + "'");
4390 Elems.push_back(C);
4391 }
4392 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004393 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4394 delete (yyvsp[(1) - (4)].TypeVal).T;
4395 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004396 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004397 break;
4398
4399 case 146:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004400#line 1901 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004401 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004402 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004403 if (ATy == 0)
4404 error("Cannot make array constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004405 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004406 int NumElements = ATy->getNumElements();
4407 if (NumElements != -1 && NumElements != 0)
4408 error("Type mismatch: constant sized array initialized with 0"
4409 " arguments, but has size of " + itostr(NumElements) +"");
4410 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004411 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4412 delete (yyvsp[(1) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004413 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004414 break;
4415
4416 case 147:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004417#line 1914 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004418 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004419 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004420 if (ATy == 0)
4421 error("Cannot make array constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004422 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004423 int NumElements = ATy->getNumElements();
4424 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4425 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4426 error("String arrays require type i8, not '" + ETy->getDescription() +
4427 "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004428 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4429 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004430 error("Can't build string constant of size " +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004431 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004432 itostr(NumElements) + "");
4433 std::vector<Constant*> Vals;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004434 for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004435 Vals.push_back(ConstantInt::get(ETy, *C));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004436 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004437 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004438 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4439 delete (yyvsp[(1) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004440 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004441 break;
4442
4443 case 148:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004444#line 1937 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004445 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004446 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[(1) - (4)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004447 if (PTy == 0)
4448 error("Cannot make packed constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004449 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004450 const Type *ETy = PTy->getElementType();
4451 int NumElements = PTy->getNumElements();
4452 // Verify that we have the correct size...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004453 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004454 error("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004455 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004456 itostr(NumElements) + "");
4457 // Verify all elements are correct type!
4458 std::vector<Constant*> Elems;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004459 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4460 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004461 const Type* ValTy = C->getType();
4462 if (ETy != ValTy)
4463 error("Element #" + utostr(i) + " is not of type '" +
4464 ETy->getDescription() +"' as required!\nIt is of type '"+
4465 ValTy->getDescription() + "'");
4466 Elems.push_back(C);
4467 }
4468 (yyval.ConstVal).C = ConstantPacked::get(PTy, Elems);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004469 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4470 delete (yyvsp[(1) - (4)].TypeVal).T;
4471 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004472 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004473 break;
4474
4475 case 149:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004476#line 1965 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004477 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004478 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004479 if (STy == 0)
4480 error("Cannot make struct constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004481 (yyvsp[(1) - (4)].TypeVal).T->get()->getDescription() + "'");
4482 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004483 error("Illegal number of initializers for structure type");
4484
4485 // Check to ensure that constants are compatible with the type initializer!
4486 std::vector<Constant*> Fields;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004487 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
4488 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004489 if (C->getType() != STy->getElementType(i))
4490 error("Expected type '" + STy->getElementType(i)->getDescription() +
4491 "' for element #" + utostr(i) + " of structure initializer");
4492 Fields.push_back(C);
4493 }
4494 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004495 (yyval.ConstVal).S = (yyvsp[(1) - (4)].TypeVal).S;
4496 delete (yyvsp[(1) - (4)].TypeVal).T;
4497 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004498 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004499 break;
4500
4501 case 150:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004502#line 1987 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004503 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004504 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004505 if (STy == 0)
4506 error("Cannot make struct constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004507 (yyvsp[(1) - (3)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004508 if (STy->getNumContainedTypes() != 0)
4509 error("Illegal number of initializers for structure type");
4510 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004511 (yyval.ConstVal).S = (yyvsp[(1) - (3)].TypeVal).S;
4512 delete (yyvsp[(1) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004513 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004514 break;
4515
4516 case 151:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004517#line 1998 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004518 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004519 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004520 if (STy == 0)
4521 error("Cannot make packed struct constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004522 (yyvsp[(1) - (6)].TypeVal).T->get()->getDescription() + "'");
4523 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004524 error("Illegal number of initializers for packed structure type");
4525
4526 // Check to ensure that constants are compatible with the type initializer!
4527 std::vector<Constant*> Fields;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004528 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
4529 Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004530 if (C->getType() != STy->getElementType(i))
4531 error("Expected type '" + STy->getElementType(i)->getDescription() +
4532 "' for element #" + utostr(i) + " of packed struct initializer");
4533 Fields.push_back(C);
4534 }
4535 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004536 (yyval.ConstVal).S = (yyvsp[(1) - (6)].TypeVal).S;
4537 delete (yyvsp[(1) - (6)].TypeVal).T;
4538 delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00004539 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004540 break;
4541
4542 case 152:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004543#line 2020 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004544 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004545 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004546 if (STy == 0)
4547 error("Cannot make packed struct constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004548 (yyvsp[(1) - (5)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004549 if (STy->getNumContainedTypes() != 0)
4550 error("Illegal number of initializers for packed structure type");
4551 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004552 (yyval.ConstVal).S = (yyvsp[(1) - (5)].TypeVal).S;
4553 delete (yyvsp[(1) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004554 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004555 break;
4556
4557 case 153:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004558#line 2031 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004559 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004560 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004561 if (PTy == 0)
4562 error("Cannot make null pointer constant with type: '" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004563 (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004564 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004565 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4566 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004567 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004568 break;
4569
4570 case 154:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004571#line 2040 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004572 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004573 (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).T->get());
4574 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4575 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004576 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004577 break;
4578
4579 case 155:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004580#line 2045 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004581 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004582 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004583 if (Ty == 0)
4584 error("Global const reference must be a pointer type, not" +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004585 (yyvsp[(1) - (2)].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004586
4587 // ConstExprs can exist in the body of a function, thus creating
4588 // GlobalValues whenever they refer to a variable. Because we are in
4589 // the context of a function, getExistingValue will search the functions
4590 // symbol table instead of the module symbol table for the global symbol,
4591 // which throws things all off. To get around this, we just tell
4592 // getExistingValue that we are at global scope here.
4593 //
4594 Function *SavedCurFn = CurFun.CurrentFunction;
4595 CurFun.CurrentFunction = 0;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004596 Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004597 CurFun.CurrentFunction = SavedCurFn;
4598
4599 // If this is an initializer for a constant pointer, which is referencing a
4600 // (currently) undefined variable, create a stub now that shall be replaced
4601 // in the future with the right type of variable.
4602 //
4603 if (V == 0) {
4604 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4605 const PointerType *PT = cast<PointerType>(Ty);
4606
4607 // First check to see if the forward references value is already created!
4608 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004609 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004610
4611 if (I != CurModule.GlobalRefs.end()) {
4612 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004613 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004614 } else {
4615 std::string Name;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004616 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004617
4618 // Create the forward referenced global.
4619 GlobalValue *GV;
4620 if (const FunctionType *FTy =
4621 dyn_cast<FunctionType>(PT->getElementType())) {
4622 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4623 CurModule.CurrentModule);
4624 } else {
4625 GV = new GlobalVariable(PT->getElementType(), false,
4626 GlobalValue::ExternalLinkage, 0,
4627 Name, CurModule.CurrentModule);
4628 }
4629
4630 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004631 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004632 V = GV;
4633 }
4634 }
4635 (yyval.ConstVal).C = cast<GlobalValue>(V);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004636 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4637 delete (yyvsp[(1) - (2)].TypeVal).T; // Free the type handle
Reid Spencer950bf602007-01-26 08:19:09 +00004638 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004639 break;
4640
4641 case 156:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004642#line 2103 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004643 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004644 if ((yyvsp[(1) - (2)].TypeVal).T->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004645 error("Mismatched types for constant expression");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004646 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4647 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4648 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004649 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004650 break;
4651
4652 case 157:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004653#line 2110 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004654 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004655 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004656 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4657 error("Cannot create a null initialized value of this type");
4658 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004659 (yyval.ConstVal).S = (yyvsp[(1) - (2)].TypeVal).S;
4660 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004661 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004662 break;
4663
4664 case 158:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004665#line 2118 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004666 { // integral constants
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004667 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4668 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004669 error("Constant value doesn't fit in type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004670 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004671 (yyval.ConstVal).S = Signed;
4672 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004673 break;
4674
4675 case 159:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004676#line 2125 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004677 { // integral constants
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004678 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
4679 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004680 error("Constant value doesn't fit in type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004681 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004682 (yyval.ConstVal).S = Unsigned;
4683 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004684 break;
4685
4686 case 160:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004687#line 2132 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004688 { // Boolean constants
4689 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
4690 (yyval.ConstVal).S = Unsigned;
4691 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004692 break;
4693
4694 case 161:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004695#line 2136 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004696 { // Boolean constants
4697 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
4698 (yyval.ConstVal).S = Unsigned;
4699 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004700 break;
4701
4702 case 162:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004703#line 2140 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004704 { // Float & Double constants
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004705 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004706 error("Floating point constant invalid for type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004707 (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004708 (yyval.ConstVal).S = Signless;
4709 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004710 break;
4711
4712 case 163:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004713#line 2149 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004714 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004715 const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
4716 const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).T->get();
4717 Signedness SrcSign = (yyvsp[(3) - (6)].ConstVal).S;
4718 Signedness DstSign = (yyvsp[(5) - (6)].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004719 if (!SrcTy->isFirstClassType())
4720 error("cast constant expression from a non-primitive type: '" +
4721 SrcTy->getDescription() + "'");
4722 if (!DstTy->isFirstClassType())
4723 error("cast constant expression to a non-primitive type: '" +
4724 DstTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004725 (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 +00004726 (yyval.ConstVal).S = DstSign;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004727 delete (yyvsp[(5) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004728 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004729 break;
4730
4731 case 164:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004732#line 2164 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004733 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004734 const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004735 if (!isa<PointerType>(Ty))
4736 error("GetElementPtr requires a pointer operand");
4737
4738 std::vector<Value*> VIndices;
4739 std::vector<Constant*> CIndices;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004740 upgradeGEPIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004741
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004742 delete (yyvsp[(4) - (5)].ValueList);
4743 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004744 (yyval.ConstVal).S = Signless;
4745 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004746 break;
4747
4748 case 165:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004749#line 2177 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004750 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004751 if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
4752 cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004753 error("Select condition must be bool type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004754 if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004755 error("Select operand types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004756 (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 +00004757 (yyval.ConstVal).S = Unsigned;
4758 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004759 break;
4760
4761 case 166:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004762#line 2186 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004763 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004764 const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4765 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004766 error("Binary operator types must match");
4767 // First, make sure we're dealing with the right opcode by upgrading from
4768 // obsolete versions.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004769 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004770
4771 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4772 // To retain backward compatibility with these early compilers, we emit a
4773 // cast to the appropriate integer type automatically if we are in the
4774 // broken case. See PR424 for more information.
4775 if (!isa<PointerType>(Ty)) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004776 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004777 } else {
4778 const Type *IntPtrTy = 0;
4779 switch (CurModule.CurrentModule->getPointerSize()) {
4780 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4781 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4782 default: error("invalid pointer binary constant expr");
4783 }
4784 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004785 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
4786 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
Reid Spencer950bf602007-01-26 08:19:09 +00004787 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
4788 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004789 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004790 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004791 break;
4792
4793 case 167:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004794#line 2214 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004795 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004796 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4797 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004798 error("Logical operator types must match");
4799 if (!Ty->isInteger()) {
4800 if (!isa<PackedType>(Ty) ||
4801 !cast<PackedType>(Ty)->getElementType()->isInteger())
4802 error("Logical operator requires integer operands");
4803 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004804 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
4805 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4806 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004807 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004808 break;
4809
4810 case 168:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004811#line 2227 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004812 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004813 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
4814 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004815 error("setcc operand types must match");
4816 unsigned short pred;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004817 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
4818 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004819 (yyval.ConstVal).S = Unsigned;
4820 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004821 break;
4822
4823 case 169:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004824#line 2236 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004825 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004826 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004827 error("icmp operand types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004828 (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 +00004829 (yyval.ConstVal).S = Unsigned;
4830 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004831 break;
4832
4833 case 170:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004834#line 2242 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004835 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004836 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004837 error("fcmp operand types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004838 (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 +00004839 (yyval.ConstVal).S = Unsigned;
4840 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004841 break;
4842
4843 case 171:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004844#line 2248 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004845 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004846 if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
4847 cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004848 error("Shift count for shift constant must be unsigned byte");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004849 if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004850 error("Shift constant expression requires integer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004851 (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);
4852 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004853 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004854 break;
4855
4856 case 172:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004857#line 2257 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004858 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004859 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004860 error("Invalid extractelement operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004861 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
4862 (yyval.ConstVal).S = (yyvsp[(3) - (6)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004863 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004864 break;
4865
4866 case 173:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004867#line 2263 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004868 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004869 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 +00004870 error("Invalid insertelement operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004871 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4872 (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004873 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004874 break;
4875
4876 case 174:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004877#line 2269 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004878 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004879 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 +00004880 error("Invalid shufflevector operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004881 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
4882 (yyval.ConstVal).S = (yyvsp[(3) - (8)].ConstVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00004883 ;}
4884 break;
4885
4886 case 175:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004887#line 2280 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004888 { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004889 break;
4890
4891 case 176:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004892#line 2281 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004893 {
4894 (yyval.ConstVector) = new std::vector<ConstInfo>();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004895 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004896 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004897 break;
4898
4899 case 177:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004900#line 2290 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004901 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004902 break;
4903
4904 case 178:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004905#line 2291 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004906 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004907 break;
4908
4909 case 179:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004910#line 2303 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004911 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004912 (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004913 CurModule.ModuleDone();
4914 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004915 break;
4916
4917 case 180:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004918#line 2312 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004919 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004920 break;
4921
4922 case 181:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004923#line 2313 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004924 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004925 break;
4926
4927 case 182:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004928#line 2314 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004929 { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00004930 break;
4931
4932 case 183:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004933#line 2315 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004934 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004935 break;
4936
4937 case 184:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004938#line 2316 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00004939 {
4940 (yyval.ModuleVal) = CurModule.CurrentModule;
4941 // Emit an error if there are any unresolved types left.
4942 if (!CurModule.LateResolveTypes.empty()) {
4943 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4944 if (DID.Type == ValID::NameVal) {
4945 error("Reference to an undefined type: '"+DID.getName() + "'");
4946 } else {
4947 error("Reference to an undefined type: #" + itostr(DID.Num));
4948 }
4949 }
4950 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004951 break;
4952
4953 case 185:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004954#line 2332 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004955 {
Reid Spencer950bf602007-01-26 08:19:09 +00004956 // Eagerly resolve types. This is not an optimization, this is a
4957 // requirement that is due to the fact that we could have this:
4958 //
4959 // %list = type { %list * }
4960 // %list = type { %list * } ; repeated type decl
4961 //
4962 // If types are not resolved eagerly, then the two types will not be
4963 // determined to be the same type!
4964 //
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004965 const Type* Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
4966 ResolveTypeTo((yyvsp[(2) - (4)].StrVal), Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004967
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004968 if (!setTypeName(Ty, (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
Reid Spencer950bf602007-01-26 08:19:09 +00004969 // If this is a named type that is not a redefinition, add it to the slot
4970 // table.
4971 CurModule.Types.push_back(Ty);
Reid Spencera50d5962006-12-02 04:11:07 +00004972 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004973 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00004974 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004975 break;
4976
4977 case 186:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004978#line 2352 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004979 { // Function prototypes can be in const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004980 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004981 break;
4982
4983 case 187:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004984#line 2354 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004985 { // Asm blocks can be in the const pool
Reid Spencer950bf602007-01-26 08:19:09 +00004986 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004987 break;
4988
4989 case 188:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004990#line 2356 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00004991 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004992 if ((yyvsp[(5) - (5)].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00004993 error("Global value initializer is not a constant");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004994 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 +00004995 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00004996 break;
4997
4998 case 189:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00004999#line 2360 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005000 {
Reid Spencer950bf602007-01-26 08:19:09 +00005001 CurGV = 0;
5002 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005003 break;
5004
5005 case 190:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005006#line 2363 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005007 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005008 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
5009 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
5010 delete (yyvsp[(5) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005011 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005012 break;
5013
5014 case 191:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005015#line 2367 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005016 {
Reid Spencer950bf602007-01-26 08:19:09 +00005017 CurGV = 0;
5018 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005019 break;
5020
5021 case 192:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005022#line 2370 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005023 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005024 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
5025 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
5026 delete (yyvsp[(5) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005027 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005028 break;
5029
5030 case 193:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005031#line 2374 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005032 {
Reid Spencer950bf602007-01-26 08:19:09 +00005033 CurGV = 0;
5034 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005035 break;
5036
5037 case 194:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005038#line 2377 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005039 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005040 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005041 CurGV =
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005042 ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0);
5043 delete (yyvsp[(5) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005044 ;}
5045 break;
5046
5047 case 195:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005048#line 2382 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005049 {
5050 CurGV = 0;
5051 ;}
5052 break;
5053
5054 case 196:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005055#line 2385 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005056 {
Reid Spencer950bf602007-01-26 08:19:09 +00005057 ;}
5058 break;
5059
5060 case 197:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005061#line 2387 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005062 {
5063 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005064 break;
5065
5066 case 198:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005067#line 2389 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005068 {
5069 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005070 break;
5071
5072 case 199:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005073#line 2394 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005074 {
Reid Spencer950bf602007-01-26 08:19:09 +00005075 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005076 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
5077 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
5078 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005079
5080 if (AsmSoFar.empty())
5081 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5082 else
5083 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
5084 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005085 break;
5086
5087 case 200:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005088#line 2408 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005089 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005090 break;
5091
5092 case 201:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005093#line 2409 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005094 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005095 break;
5096
5097 case 202:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005098#line 2413 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005099 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005100 CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
Reid Spencer950bf602007-01-26 08:19:09 +00005101 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005102 break;
5103
5104 case 203:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005105#line 2416 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005106 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005107 if ((yyvsp[(3) - (3)].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00005108 CurModule.setPointerSize(Module::Pointer32);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005109 else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00005110 CurModule.setPointerSize(Module::Pointer64);
5111 else
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005112 error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00005113 ;}
5114 break;
5115
5116 case 204:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005117#line 2424 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005118 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005119 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
5120 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005121 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005122 break;
5123
5124 case 205:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005125#line 2428 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005126 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005127 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
5128 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005129 ;}
5130 break;
5131
5132 case 207:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005133#line 2439 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005134 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005135 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
5136 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005137 ;}
5138 break;
5139
5140 case 208:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005141#line 2443 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005142 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005143 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
5144 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005145 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005146 break;
5147
5148 case 209:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005149#line 2447 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005150 { ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005151 break;
5152
Reid Spencerc4d96252007-01-13 00:03:30 +00005153 case 213:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005154#line 2460 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005155 { (yyval.StrVal) = 0; ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005156 break;
5157
Reid Spencer319a7302007-01-05 17:20:02 +00005158 case 214:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005159#line 2464 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005160 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005161 if ((yyvsp[(1) - (2)].TypeVal).T->get() == Type::VoidTy)
Reid Spencer950bf602007-01-26 08:19:09 +00005162 error("void typed arguments are invalid");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005163 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005164 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005165 break;
5166
5167 case 215:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005168#line 2472 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005169 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005170 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5171 (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
5172 delete (yyvsp[(3) - (3)].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005173 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005174 break;
5175
5176 case 216:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005177#line 2477 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005178 {
5179 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005180 (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
5181 delete (yyvsp[(1) - (1)].ArgVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005182 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005183 break;
5184
5185 case 217:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005186#line 2485 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005187 { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005188 break;
5189
5190 case 218:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005191#line 2486 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005192 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005193 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Reid Spencer950bf602007-01-26 08:19:09 +00005194 PATypeInfo VoidTI;
5195 VoidTI.T = new PATypeHolder(Type::VoidTy);
5196 VoidTI.S = Signless;
5197 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5198 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005199 break;
5200
5201 case 219:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005202#line 2493 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005203 {
5204 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5205 PATypeInfo VoidTI;
5206 VoidTI.T = new PATypeHolder(Type::VoidTy);
5207 VoidTI.S = Signless;
5208 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5209 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005210 break;
5211
5212 case 220:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005213#line 2500 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005214 { (yyval.ArgList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005215 break;
5216
5217 case 221:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005218#line 2504 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005219 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005220 UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
5221 std::string FunctionName((yyvsp[(3) - (8)].StrVal));
5222 free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory!
Reid Spencer950bf602007-01-26 08:19:09 +00005223
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005224 const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005225
5226 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5227 error("LLVM functions cannot return aggregate types");
5228
5229 std::vector<const Type*> ParamTypeList;
5230
5231 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5232 // i8*. We check here for those names and override the parameter list
5233 // types to ensure the prototype is correct.
5234 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
5235 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5236 } else if (FunctionName == "llvm.va_copy") {
5237 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
5238 ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005239 } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005240 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005241 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005242 const Type *Ty = I->first.T->get();
5243 ParamTypeList.push_back(Ty);
5244 }
5245 }
5246
5247 bool isVarArg =
5248 ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5249 if (isVarArg) ParamTypeList.pop_back();
5250
5251 const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg);
5252 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005253 delete (yyvsp[(2) - (8)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005254
5255 ValID ID;
5256 if (!FunctionName.empty()) {
5257 ID = ValID::create((char*)FunctionName.c_str());
5258 } else {
5259 ID = ValID::create((int)CurModule.Values[PFT].size());
5260 }
5261
5262 Function *Fn = 0;
5263 // See if this function was forward referenced. If so, recycle the object.
5264 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5265 // Move the function to the end of the list, from whereever it was
5266 // previously inserted.
5267 Fn = cast<Function>(FWRef);
5268 CurModule.CurrentModule->getFunctionList().remove(Fn);
5269 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5270 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5271 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
5272 // If this is the case, either we need to be a forward decl, or it needs
5273 // to be.
5274 if (!CurFun.isDeclare && !Fn->isExternal())
5275 error("Redefinition of function '" + FunctionName + "'");
5276
5277 // Make sure to strip off any argument names so we can't get conflicts.
5278 if (Fn->isExternal())
5279 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5280 AI != AE; ++AI)
5281 AI->setName("");
5282 } else { // Not already defined?
5283 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5284 CurModule.CurrentModule);
5285
5286 InsertValue(Fn, CurModule.Values);
5287 }
5288
5289 CurFun.FunctionStart(Fn);
5290
5291 if (CurFun.isDeclare) {
5292 // If we have declaration, always overwrite linkage. This will allow us
5293 // to correctly handle cases, when pointer to function is passed as
5294 // argument to another function.
5295 Fn->setLinkage(CurFun.Linkage);
5296 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005297 Fn->setCallingConv((yyvsp[(1) - (8)].UIntVal));
5298 Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
5299 if ((yyvsp[(7) - (8)].StrVal)) {
5300 Fn->setSection((yyvsp[(7) - (8)].StrVal));
5301 free((yyvsp[(7) - (8)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005302 }
5303
5304 // Add all of the arguments we parsed to the function...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005305 if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005306 if (isVarArg) { // Nuke the last entry
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005307 assert((yyvsp[(5) - (8)].ArgList)->back().first.T->get() == Type::VoidTy &&
5308 (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
5309 delete (yyvsp[(5) - (8)].ArgList)->back().first.T;
5310 (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005311 }
5312 Function::arg_iterator ArgIt = Fn->arg_begin();
5313 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005314 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I, ++ArgIt) {
Reid Spencer950bf602007-01-26 08:19:09 +00005315 delete I->first.T; // Delete the typeholder...
5316 setValueName(ArgIt, I->second); // Insert arg into symtab...
5317 InsertValue(ArgIt);
5318 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005319 delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005320 }
5321 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005322 break;
5323
5324 case 224:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005325#line 2614 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005326 {
5327 (yyval.FunctionVal) = CurFun.CurrentFunction;
5328
5329 // Make sure that we keep track of the linkage type even if there was a
5330 // previous "declare".
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005331 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (3)].Linkage));
Reid Spencer950bf602007-01-26 08:19:09 +00005332 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005333 break;
5334
5335 case 227:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005336#line 2628 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005337 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005338 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005339 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005340 break;
5341
5342 case 229:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005343#line 2634 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005344 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
5345 break;
5346
5347 case 230:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005348#line 2635 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005349 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
5350 break;
5351
5352 case 231:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005353#line 2639 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005354 { CurFun.isDeclare = true; ;}
5355 break;
5356
5357 case 232:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005358#line 2639 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005359 {
5360 (yyval.FunctionVal) = CurFun.CurrentFunction;
5361 CurFun.FunctionDone();
5362
5363 ;}
5364 break;
5365
5366 case 233:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005367#line 2651 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005368 { (yyval.BoolVal) = false; ;}
5369 break;
5370
5371 case 234:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005372#line 2652 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005373 { (yyval.BoolVal) = true; ;}
5374 break;
5375
5376 case 235:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005377#line 2657 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005378 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005379 break;
5380
5381 case 236:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005382#line 2658 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005383 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005384 break;
5385
5386 case 237:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005387#line 2659 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005388 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
Reid Spencer950bf602007-01-26 08:19:09 +00005389 break;
5390
5391 case 238:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005392#line 2660 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005393 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005394 break;
5395
Reid Spencerc4d96252007-01-13 00:03:30 +00005396 case 239:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005397#line 2661 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005398 { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;}
5399 break;
5400
5401 case 240:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005402#line 2662 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005403 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005404 break;
5405
Reid Spencerc4d96252007-01-13 00:03:30 +00005406 case 241:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005407#line 2663 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005408 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5409 break;
5410
5411 case 242:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005412#line 2664 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005413 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5414 break;
5415
5416 case 243:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005417#line 2665 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005418 { // Nonempty unsized packed vector
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005419 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
5420 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer950bf602007-01-26 08:19:09 +00005421 PackedType* pt = PackedType::get(ETy, NumElements);
5422 PATypeHolder* PTy = new PATypeHolder(
5423 HandleUpRefs(PackedType::get(ETy, NumElements)));
5424
5425 // Verify all elements are correct type!
5426 std::vector<Constant*> Elems;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005427 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5428 Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005429 const Type *CTy = C->getType();
5430 if (ETy != CTy)
5431 error("Element #" + utostr(i) + " is not of type '" +
5432 ETy->getDescription() +"' as required!\nIt is of type '" +
5433 CTy->getDescription() + "'");
5434 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005435 }
Reid Spencer950bf602007-01-26 08:19:09 +00005436 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, Elems));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005437 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer950bf602007-01-26 08:19:09 +00005438 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005439 break;
5440
Reid Spencerc4d96252007-01-13 00:03:30 +00005441 case 244:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005442#line 2686 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005443 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005444 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00005445 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005446 break;
5447
Reid Spencerc4d96252007-01-13 00:03:30 +00005448 case 245:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005449#line 2689 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005450 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005451 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5452 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5453 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5454 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5455 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5456 free((yyvsp[(3) - (5)].StrVal));
5457 free((yyvsp[(5) - (5)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005458 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005459 break;
5460
Reid Spencerc4d96252007-01-13 00:03:30 +00005461 case 246:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005462#line 2704 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005463 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005464 break;
5465
Reid Spencer319a7302007-01-05 17:20:02 +00005466 case 247:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005467#line 2705 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005468 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005469 break;
5470
5471 case 250:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005472#line 2718 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005473 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005474 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).T->get();
5475 (yyval.ValueVal).S = (yyvsp[(1) - (2)].TypeVal).S;
5476 (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
5477 delete (yyvsp[(1) - (2)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005478 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005479 break;
5480
Reid Spencerc4d96252007-01-13 00:03:30 +00005481 case 251:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005482#line 2727 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005483 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005484 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005485 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005486 break;
5487
Reid Spencerc4d96252007-01-13 00:03:30 +00005488 case 252:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005489#line 2730 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005490 { // Do not allow functions with 0 basic blocks
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005491 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005492 ;}
5493 break;
5494
5495 case 253:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005496#line 2739 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005497 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005498 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
5499 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5500 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5501 InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5502 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005503 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005504 break;
5505
Reid Spencerc4d96252007-01-13 00:03:30 +00005506 case 254:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005507#line 2749 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005508 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005509 if ((yyvsp[(2) - (2)].InstVal).I)
5510 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
5511 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005512 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005513 break;
5514
Reid Spencerc4d96252007-01-13 00:03:30 +00005515 case 255:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005516#line 2754 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005517 {
5518 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
5519 // Make sure to move the basic block to the correct location in the
5520 // function, instead of leaving it inserted wherever it was first
5521 // referenced.
5522 Function::BasicBlockListType &BBL =
5523 CurFun.CurrentFunction->getBasicBlockList();
5524 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5525 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005526 break;
5527
Reid Spencerc4d96252007-01-13 00:03:30 +00005528 case 256:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005529#line 2763 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005530 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005531 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005532 // Make sure to move the basic block to the correct location in the
5533 // function, instead of leaving it inserted wherever it was first
5534 // referenced.
5535 Function::BasicBlockListType &BBL =
5536 CurFun.CurrentFunction->getBasicBlockList();
5537 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5538 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005539 break;
5540
Reid Spencerc4d96252007-01-13 00:03:30 +00005541 case 259:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005542#line 2777 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005543 { // Return with a result...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005544 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005545 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005546 break;
5547
Reid Spencerc4d96252007-01-13 00:03:30 +00005548 case 260:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005549#line 2780 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005550 { // Return with no result...
5551 (yyval.TermInstVal) = new ReturnInst();
5552 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005553 break;
5554
Reid Spencerc4d96252007-01-13 00:03:30 +00005555 case 261:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005556#line 2783 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005557 { // Unconditional Branch...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005558 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005559 (yyval.TermInstVal) = new BranchInst(tmpBB);
5560 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005561 break;
5562
Reid Spencer319a7302007-01-05 17:20:02 +00005563 case 262:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005564#line 2787 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005565 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005566 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5567 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5568 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005569 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5570 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005571 break;
5572
5573 case 263:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005574#line 2793 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005575 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005576 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
5577 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5578 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
Reid Spencer950bf602007-01-26 08:19:09 +00005579 (yyval.TermInstVal) = S;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005580 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5581 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005582 for (; I != E; ++I) {
5583 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5584 S->addCase(CI, I->second);
5585 else
5586 error("Switch case is constant, but not a simple integer");
5587 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005588 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer950bf602007-01-26 08:19:09 +00005589 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005590 break;
5591
5592 case 264:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005593#line 2808 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005594 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005595 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
5596 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005597 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5598 (yyval.TermInstVal) = S;
5599 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005600 break;
5601
Reid Spencerc4d96252007-01-13 00:03:30 +00005602 case 265:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005603#line 2815 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005604 {
Reid Spencer950bf602007-01-26 08:19:09 +00005605 const PointerType *PFTy;
5606 const FunctionType *Ty;
5607
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005608 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005609 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5610 // Pull out the types of all of the arguments...
5611 std::vector<const Type*> ParamTypes;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005612 if ((yyvsp[(6) - (13)].ValueList)) {
5613 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005614 I != E; ++I)
5615 ParamTypes.push_back((*I).V->getType());
5616 }
5617 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5618 if (isVarArg) ParamTypes.pop_back();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005619 Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).T->get(), ParamTypes, isVarArg);
Reid Spencer950bf602007-01-26 08:19:09 +00005620 PFTy = PointerType::get(Ty);
5621 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005622 Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling...
5623 BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
5624 BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005625
5626 // Create the call node...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005627 if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00005628 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
5629 } else { // Has arguments?
5630 // Loop through FunctionType's arguments and ensure they are specified
5631 // correctly!
5632 //
5633 FunctionType::param_iterator I = Ty->param_begin();
5634 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005635 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005636
5637 std::vector<Value*> Args;
5638 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5639 if ((*ArgI).V->getType() != *I)
5640 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5641 (*I)->getDescription() + "'");
5642 Args.push_back((*ArgI).V);
5643 }
5644
5645 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5646 error("Invalid number of parameters detected");
5647
5648 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, Args);
5649 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005650 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[(2) - (13)].UIntVal));
5651 delete (yyvsp[(3) - (13)].TypeVal).T;
5652 delete (yyvsp[(6) - (13)].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00005653 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005654 break;
5655
Reid Spencerc4d96252007-01-13 00:03:30 +00005656 case 266:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005657#line 2865 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005658 {
Reid Spencer950bf602007-01-26 08:19:09 +00005659 (yyval.TermInstVal) = new UnwindInst();
5660 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005661 break;
5662
Reid Spencerc4d96252007-01-13 00:03:30 +00005663 case 267:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005664#line 2868 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005665 {
5666 (yyval.TermInstVal) = new UnreachableInst();
5667 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005668 break;
5669
Reid Spencerc4d96252007-01-13 00:03:30 +00005670 case 268:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005671#line 2874 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005672 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005673 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5674 Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005675
5676 if (V == 0)
5677 error("May only switch on a constant pool value");
5678
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005679 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005680 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5681 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005682 break;
5683
Reid Spencerc4d96252007-01-13 00:03:30 +00005684 case 269:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005685#line 2884 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005686 {
Reid Spencer950bf602007-01-26 08:19:09 +00005687 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005688 Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005689
5690 if (V == 0)
5691 error("May only switch on a constant pool value");
5692
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005693 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005694 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5695 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005696 break;
5697
Reid Spencerc4d96252007-01-13 00:03:30 +00005698 case 270:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005699#line 2897 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005700 {
Reid Spencer950bf602007-01-26 08:19:09 +00005701 bool omit = false;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005702 if ((yyvsp[(1) - (2)].StrVal))
5703 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005704 if (BCI->getSrcTy() == BCI->getDestTy() &&
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005705 BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005706 // This is a useless bit cast causing a name redefinition. It is
5707 // a bit cast from a type to the same type of an operand with the
5708 // same name as the name we would give this instruction. Since this
5709 // instruction results in no code generation, it is safe to omit
5710 // the instruction. This situation can occur because of collapsed
5711 // type planes. For example:
5712 // %X = add int %Y, %Z
5713 // %X = cast int %Y to uint
5714 // After upgrade, this looks like:
5715 // %X = add i32 %Y, %Z
5716 // %X = bitcast i32 to i32
5717 // The bitcast is clearly useless so we omit it.
5718 omit = true;
5719 if (omit) {
5720 (yyval.InstVal).I = 0;
5721 (yyval.InstVal).S = Signless;
5722 } else {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005723 setValueName((yyvsp[(2) - (2)].InstVal).I, (yyvsp[(1) - (2)].StrVal));
5724 InsertValue((yyvsp[(2) - (2)].InstVal).I);
5725 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005726 }
5727 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005728 break;
5729
Reid Spencerc4d96252007-01-13 00:03:30 +00005730 case 271:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005731#line 2926 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005732 { // Used for PHI nodes
5733 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005734 (yyval.PHIList).S = (yyvsp[(1) - (6)].TypeVal).S;
5735 Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).T->get(), (yyvsp[(3) - (6)].ValIDVal));
5736 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005737 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005738 delete (yyvsp[(1) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005739 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005740 break;
5741
Reid Spencerc4d96252007-01-13 00:03:30 +00005742 case 272:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005743#line 2934 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005744 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005745 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5746 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
5747 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
5748 (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer950bf602007-01-26 08:19:09 +00005749 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005750 break;
5751
Reid Spencerc4d96252007-01-13 00:03:30 +00005752 case 273:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005753#line 2942 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005754 { // Used for call statements, and memory insts...
5755 (yyval.ValueList) = new std::vector<ValueInfo>();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005756 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005757 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005758 break;
5759
Reid Spencer950bf602007-01-26 08:19:09 +00005760 case 274:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005761#line 2946 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005762 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005763 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5764 (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005765 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005766 break;
5767
Reid Spencerc4d96252007-01-13 00:03:30 +00005768 case 276:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005769#line 2954 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005770 { (yyval.ValueList) = 0; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005771 break;
5772
Reid Spencerc4d96252007-01-13 00:03:30 +00005773 case 277:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005774#line 2958 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005775 {
Reid Spencer950bf602007-01-26 08:19:09 +00005776 (yyval.BoolVal) = true;
5777 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005778 break;
5779
Reid Spencer319a7302007-01-05 17:20:02 +00005780 case 278:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005781#line 2961 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005782 {
Reid Spencer950bf602007-01-26 08:19:09 +00005783 (yyval.BoolVal) = false;
5784 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005785 break;
5786
5787 case 279:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005788#line 2967 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005789 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005790 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005791 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<PackedType>(Ty))
5792 error("Arithmetic operator requires integer, FP, or packed operands");
5793 if (isa<PackedType>(Ty) &&
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005794 ((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 +00005795 error("Remainder not supported on packed types");
5796 // Upgrade the opcode from obsolete versions before we do anything with it.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005797 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5798 Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5799 Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005800 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
5801 if ((yyval.InstVal).I == 0)
5802 error("binary operator returned null");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005803 (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5804 delete (yyvsp[(2) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005805 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005806 break;
5807
5808 case 280:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005809#line 2984 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005810 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005811 const Type *Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005812 if (!Ty->isInteger()) {
5813 if (!isa<PackedType>(Ty) ||
5814 !cast<PackedType>(Ty)->getElementType()->isInteger())
5815 error("Logical operator requires integral operands");
5816 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005817 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
5818 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5819 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005820 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5821 if ((yyval.InstVal).I == 0)
5822 error("binary operator returned null");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005823 (yyval.InstVal).S = (yyvsp[(2) - (5)].TypeVal).S;
5824 delete (yyvsp[(2) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005825 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005826 break;
5827
Reid Spencerc4d96252007-01-13 00:03:30 +00005828 case 281:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005829#line 3000 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005830 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005831 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005832 if(isa<PackedType>(Ty))
5833 error("PackedTypes currently not supported in setcc instructions");
5834 unsigned short pred;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005835 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
5836 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
5837 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005838 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5839 if ((yyval.InstVal).I == 0)
5840 error("binary operator returned null");
5841 (yyval.InstVal).S = Unsigned;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005842 delete (yyvsp[(2) - (5)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005843 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005844 break;
5845
Reid Spencerc4d96252007-01-13 00:03:30 +00005846 case 282:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005847#line 3014 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005848 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005849 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005850 if (isa<PackedType>(Ty))
5851 error("PackedTypes currently not supported in icmp instructions");
5852 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5853 error("icmp requires integer or pointer typed operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005854 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5855 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5856 (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005857 (yyval.InstVal).S = Unsigned;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005858 delete (yyvsp[(3) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005859 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005860 break;
5861
Reid Spencerc4d96252007-01-13 00:03:30 +00005862 case 283:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005863#line 3026 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005864 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005865 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005866 if (isa<PackedType>(Ty))
5867 error("PackedTypes currently not supported in fcmp instructions");
5868 else if (!Ty->isFloatingPoint())
5869 error("fcmp instruction requires floating point operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005870 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
5871 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
5872 (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
Reid Spencer950bf602007-01-26 08:19:09 +00005873 (yyval.InstVal).S = Unsigned;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005874 delete (yyvsp[(3) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005875 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005876 break;
5877
Reid Spencerc4d96252007-01-13 00:03:30 +00005878 case 284:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005879#line 3038 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005880 {
Reid Spencer950bf602007-01-26 08:19:09 +00005881 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005882 const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005883 Value *Ones = ConstantInt::getAllOnesValue(Ty);
5884 if (Ones == 0)
5885 error("Expected integral type for not instruction");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005886 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
Reid Spencer950bf602007-01-26 08:19:09 +00005887 if ((yyval.InstVal).I == 0)
5888 error("Could not create a xor instruction");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005889 (yyval.InstVal).S = (yyvsp[(2) - (2)].ValueVal).S
Reid Spencer950bf602007-01-26 08:19:09 +00005890 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005891 break;
5892
5893 case 285:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005894#line 3049 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005895 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005896 if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
5897 cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005898 error("Shift amount must be int8");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005899 if (!(yyvsp[(2) - (4)].ValueVal).V->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005900 error("Shift constant expression requires integer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005901 (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);
5902 (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005903 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005904 break;
5905
5906 case 286:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005907#line 3058 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00005908 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005909 const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005910 if (!DstTy->isFirstClassType())
5911 error("cast instruction to a non-primitive type: '" +
5912 DstTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005913 (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));
5914 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5915 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005916 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00005917 break;
5918
5919 case 287:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005920#line 3067 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005921 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005922 if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
5923 cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005924 error("select condition must be bool");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005925 if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005926 error("select value types should match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005927 (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
5928 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00005929 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005930 break;
5931
Reid Spencerc4d96252007-01-13 00:03:30 +00005932 case 288:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005933#line 3076 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00005934 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005935 const Type *Ty = (yyvsp[(4) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005936 NewVarArgs = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005937 (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
5938 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5939 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005940 ;}
5941 break;
5942
5943 case 289:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005944#line 3083 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005945 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005946 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5947 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005948 ObsoleteVarArgs = true;
5949 Function* NF = cast<Function>(CurModule.CurrentModule->
5950 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5951
5952 //b = vaarg a, t ->
5953 //foo = alloca 1 of t
5954 //bar = vacopy a
5955 //store bar -> foo
5956 //b = vaarg foo, t
5957 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5958 CurBB->getInstList().push_back(foo);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005959 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005960 CurBB->getInstList().push_back(bar);
5961 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5962 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005963 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5964 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005965 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005966 break;
5967
Reid Spencerc4d96252007-01-13 00:03:30 +00005968 case 290:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005969#line 3104 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005970 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005971 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
5972 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005973 ObsoleteVarArgs = true;
5974 Function* NF = cast<Function>(CurModule.CurrentModule->
5975 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5976
5977 //b = vanext a, t ->
5978 //foo = alloca 1 of t
5979 //bar = vacopy a
5980 //store bar -> foo
5981 //tmp = vaarg foo, t
5982 //b = load foo
5983 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5984 CurBB->getInstList().push_back(foo);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005985 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00005986 CurBB->getInstList().push_back(bar);
5987 CurBB->getInstList().push_back(new StoreInst(bar, foo));
5988 Instruction* tmp = new VAArgInst(foo, DstTy);
5989 CurBB->getInstList().push_back(tmp);
5990 (yyval.InstVal).I = new LoadInst(foo);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005991 (yyval.InstVal).S = (yyvsp[(4) - (4)].TypeVal).S;
5992 delete (yyvsp[(4) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00005993 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00005994 break;
5995
Reid Spencerc4d96252007-01-13 00:03:30 +00005996 case 291:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00005997#line 3128 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00005998 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005999 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006000 error("Invalid extractelement operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006001 (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
6002 (yyval.InstVal).S = (yyvsp[(2) - (4)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006003 ;}
6004 break;
6005
6006 case 292:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006007#line 3134 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006008 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006009 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 +00006010 error("Invalid insertelement operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006011 (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6012 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006013 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006014 break;
6015
Reid Spencerc4d96252007-01-13 00:03:30 +00006016 case 293:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006017#line 3140 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006018 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006019 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 +00006020 error("Invalid shufflevector operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006021 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6022 (yyval.InstVal).S = (yyvsp[(2) - (6)].ValueVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006023 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006024 break;
6025
Reid Spencerc4d96252007-01-13 00:03:30 +00006026 case 294:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006027#line 3146 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006028 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006029 const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006030 if (!Ty->isFirstClassType())
6031 error("PHI node operands must be of first class type");
6032 PHINode *PHI = new PHINode(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006033 PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
6034 while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
6035 if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00006036 error("All elements of a PHI node must be of the same type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006037 PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
6038 (yyvsp[(2) - (2)].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00006039 }
6040 (yyval.InstVal).I = PHI;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006041 (yyval.InstVal).S = (yyvsp[(2) - (2)].PHIList).S;
6042 delete (yyvsp[(2) - (2)].PHIList).P; // Free the list...
Reid Spencer950bf602007-01-26 08:19:09 +00006043 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006044 break;
6045
6046 case 295:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006047#line 3162 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006048 {
Reid Spencer950bf602007-01-26 08:19:09 +00006049
6050 // Handle the short call syntax
6051 const PointerType *PFTy;
6052 const FunctionType *FTy;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006053 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).T->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006054 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6055 // Pull out the types of all of the arguments...
6056 std::vector<const Type*> ParamTypes;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006057 if ((yyvsp[(6) - (7)].ValueList)) {
6058 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006059 I != E; ++I)
6060 ParamTypes.push_back((*I).V->getType());
6061 }
6062
6063 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6064 if (isVarArg) ParamTypes.pop_back();
6065
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006066 const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006067 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6068 error("Functions cannot return aggregate types");
6069
6070 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
6071 PFTy = PointerType::get(FTy);
6072 }
6073
6074 // First upgrade any intrinsic calls.
6075 std::vector<Value*> Args;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006076 if ((yyvsp[(6) - (7)].ValueList))
6077 for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i)
6078 Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
6079 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[(4) - (7)].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006080
6081 // If we got an upgraded intrinsic
6082 if (Inst) {
6083 (yyval.InstVal).I = Inst;
6084 (yyval.InstVal).S = Signless;
6085 } else {
6086 // Get the function we're calling
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006087 Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006088
6089 // Check the argument values match
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006090 if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006091 // Make sure no arguments is a good thing!
6092 if (FTy->getNumParams() != 0)
6093 error("No arguments passed to a function that expects arguments");
6094 } else { // Has arguments?
6095 // Loop through FunctionType's arguments and ensure they are specified
6096 // correctly!
6097 //
6098 FunctionType::param_iterator I = FTy->param_begin();
6099 FunctionType::param_iterator E = FTy->param_end();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006100 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006101
6102 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6103 if ((*ArgI).V->getType() != *I)
6104 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6105 (*I)->getDescription() + "'");
6106
6107 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6108 error("Invalid number of parameters detected");
6109 }
6110
6111 // Create the call instruction
6112 CallInst *CI = new CallInst(V, Args);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006113 CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
6114 CI->setCallingConv((yyvsp[(2) - (7)].UIntVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006115 (yyval.InstVal).I = CI;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006116 (yyval.InstVal).S = (yyvsp[(3) - (7)].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006117 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006118 delete (yyvsp[(3) - (7)].TypeVal).T;
6119 delete (yyvsp[(6) - (7)].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006120 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006121 break;
6122
Reid Spencerc4d96252007-01-13 00:03:30 +00006123 case 296:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006124#line 3235 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerc4d96252007-01-13 00:03:30 +00006125 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006126 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00006127 ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00006128 break;
6129
Reid Spencer609ca3e2007-01-12 20:10:51 +00006130 case 297:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006131#line 3243 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006132 { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
Reid Spencerc4d96252007-01-13 00:03:30 +00006133 break;
6134
6135 case 298:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006136#line 3244 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006137 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006138 break;
6139
Reid Spencerc4d96252007-01-13 00:03:30 +00006140 case 299:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006141#line 3248 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006142 { (yyval.BoolVal) = true; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006143 break;
6144
Reid Spencerc4d96252007-01-13 00:03:30 +00006145 case 300:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006146#line 3249 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006147 { (yyval.BoolVal) = false; ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006148 break;
6149
Reid Spencerc4d96252007-01-13 00:03:30 +00006150 case 301:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006151#line 3253 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +00006152 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006153 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6154 (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6155 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6156 delete (yyvsp[(2) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006157 ;}
6158 break;
6159
6160 case 302:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006161#line 3259 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006162 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006163 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6164 (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6165 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6166 delete (yyvsp[(2) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006167 ;}
6168 break;
6169
6170 case 303:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006171#line 3265 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006172 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006173 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).T->get();
6174 (yyval.InstVal).S = (yyvsp[(2) - (3)].TypeVal).S;
6175 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6176 delete (yyvsp[(2) - (3)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006177 ;}
6178 break;
6179
6180 case 304:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006181#line 3271 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006182 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006183 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).T->get();
6184 (yyval.InstVal).S = (yyvsp[(2) - (6)].TypeVal).S;
6185 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6186 delete (yyvsp[(2) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006187 ;}
6188 break;
6189
6190 case 305:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006191#line 3277 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006192 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006193 const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006194 if (!isa<PointerType>(PTy))
6195 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006196 (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006197 (yyval.InstVal).S = Signless;
6198 ;}
6199 break;
6200
6201 case 306:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006202#line 3284 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006203 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006204 const Type* Ty = (yyvsp[(3) - (4)].TypeVal).T->get();
6205 (yyval.InstVal).S = (yyvsp[(3) - (4)].TypeVal).S;
Reid Spencer950bf602007-01-26 08:19:09 +00006206 if (!isa<PointerType>(Ty))
6207 error("Can't load from nonpointer type: " + Ty->getDescription());
6208 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6209 error("Can't load from pointer of non-first-class type: " +
6210 Ty->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006211 Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
6212 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
6213 delete (yyvsp[(3) - (4)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006214 ;}
6215 break;
6216
6217 case 307:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006218#line 3296 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006219 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006220 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).T->get());
Reid Spencer950bf602007-01-26 08:19:09 +00006221 if (!PTy)
6222 error("Can't store to a nonpointer type: " +
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006223 (yyvsp[(5) - (6)].TypeVal).T->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00006224 const Type *ElTy = PTy->getElementType();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006225 if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType())
6226 error("Can't store '" + (yyvsp[(3) - (6)].ValueVal).V->getType()->getDescription() +
Reid Spencer950bf602007-01-26 08:19:09 +00006227 "' into space of type '" + ElTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006228 Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
6229 (yyval.InstVal).I = new StoreInst((yyvsp[(3) - (6)].ValueVal).V, tmpVal, (yyvsp[(1) - (6)].BoolVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006230 (yyval.InstVal).S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006231 delete (yyvsp[(5) - (6)].TypeVal).T;
Reid Spencer950bf602007-01-26 08:19:09 +00006232 ;}
6233 break;
6234
6235 case 308:
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006236#line 3310 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer950bf602007-01-26 08:19:09 +00006237 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006238 const Type* Ty = (yyvsp[(2) - (4)].TypeVal).T->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006239 if (!isa<PointerType>(Ty))
6240 error("getelementptr insn requires pointer operand");
6241
6242 std::vector<Value*> VIndices;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006243 upgradeGEPIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006244
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006245 Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006246 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices);
6247 (yyval.InstVal).S = Signless;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006248 delete (yyvsp[(2) - (4)].TypeVal).T;
6249 delete (yyvsp[(4) - (4)].ValueList);
Reid Spencer950bf602007-01-26 08:19:09 +00006250 ;}
Reid Spencer319a7302007-01-05 17:20:02 +00006251 break;
6252
6253
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006254/* Line 1267 of yacc.c. */
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006255#line 6256 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00006256 default: break;
Reid Spencer319a7302007-01-05 17:20:02 +00006257 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006258 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
Reid Spencer319a7302007-01-05 17:20:02 +00006259
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006260 YYPOPSTACK (yylen);
6261 yylen = 0;
Reid Spencer950bf602007-01-26 08:19:09 +00006262 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006263
6264 *++yyvsp = yyval;
6265
6266
Reid Spencer319a7302007-01-05 17:20:02 +00006267 /* Now `shift' the result of the reduction. Determine what state
6268 that goes to, based on the state we popped back to and the rule
6269 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006270
6271 yyn = yyr1[yyn];
6272
Reid Spencer319a7302007-01-05 17:20:02 +00006273 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6274 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006275 yystate = yytable[yystate];
6276 else
Reid Spencer319a7302007-01-05 17:20:02 +00006277 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006278
6279 goto yynewstate;
6280
6281
Reid Spencer319a7302007-01-05 17:20:02 +00006282/*------------------------------------.
6283| yyerrlab -- here on detecting error |
6284`------------------------------------*/
6285yyerrlab:
6286 /* If not already recovering from an error, report this error. */
6287 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006288 {
6289 ++yynerrs;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006290#if ! YYERROR_VERBOSE
6291 yyerror (YY_("syntax error"));
6292#else
6293 {
6294 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6295 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6296 {
6297 YYSIZE_T yyalloc = 2 * yysize;
6298 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6299 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6300 if (yymsg != yymsgbuf)
Reid Spencer319a7302007-01-05 17:20:02 +00006301 YYSTACK_FREE (yymsg);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006302 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6303 if (yymsg)
6304 yymsg_alloc = yyalloc;
6305 else
6306 {
6307 yymsg = yymsgbuf;
6308 yymsg_alloc = sizeof yymsgbuf;
6309 }
6310 }
6311
6312 if (0 < yysize && yysize <= yymsg_alloc)
6313 {
6314 (void) yysyntax_error (yymsg, yystate, yychar);
6315 yyerror (yymsg);
6316 }
6317 else
6318 {
6319 yyerror (YY_("syntax error"));
6320 if (yysize != 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006321 goto yyexhaustedlab;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006322 }
6323 }
6324#endif
Reid Spencere7c3c602006-11-30 06:36:44 +00006325 }
Reid Spencer950bf602007-01-26 08:19:09 +00006326
6327
6328
6329 if (yyerrstatus == 3)
6330 {
6331 /* If just tried and failed to reuse look-ahead token after an
6332 error, discard it. */
6333
6334 if (yychar <= YYEOF)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006335 {
Reid Spencer950bf602007-01-26 08:19:09 +00006336 /* Return failure if at end of input. */
6337 if (yychar == YYEOF)
6338 YYABORT;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006339 }
Reid Spencer950bf602007-01-26 08:19:09 +00006340 else
6341 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006342 yydestruct ("Error: discarding",
6343 yytoken, &yylval);
Reid Spencer950bf602007-01-26 08:19:09 +00006344 yychar = YYEMPTY;
6345 }
6346 }
6347
6348 /* Else will try to reuse look-ahead token after shifting the error
6349 token. */
Jeff Cohenac2dca92007-01-21 19:30:52 +00006350 goto yyerrlab1;
Reid Spencere7c3c602006-11-30 06:36:44 +00006351
Reid Spencer319a7302007-01-05 17:20:02 +00006352
Reid Spencer950bf602007-01-26 08:19:09 +00006353/*---------------------------------------------------.
6354| yyerrorlab -- error raised explicitly by YYERROR. |
6355`---------------------------------------------------*/
6356yyerrorlab:
6357
6358 /* Pacify compilers like GCC when the user code never invokes
6359 YYERROR and the label yyerrorlab therefore never appears in user
6360 code. */
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006361 if (/*CONSTCOND*/ 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006362 goto yyerrorlab;
6363
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006364 /* Do not reclaim the symbols of the rule which action triggered
6365 this YYERROR. */
6366 YYPOPSTACK (yylen);
6367 yylen = 0;
6368 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer950bf602007-01-26 08:19:09 +00006369 yystate = *yyssp;
6370 goto yyerrlab1;
6371
6372
6373/*-------------------------------------------------------------.
6374| yyerrlab1 -- common code for both syntax error and YYERROR. |
6375`-------------------------------------------------------------*/
Jeff Cohenac2dca92007-01-21 19:30:52 +00006376yyerrlab1:
Reid Spencer319a7302007-01-05 17:20:02 +00006377 yyerrstatus = 3; /* Each real token shifted decrements this. */
6378
6379 for (;;)
6380 {
6381 yyn = yypact[yystate];
6382 if (yyn != YYPACT_NINF)
6383 {
6384 yyn += YYTERROR;
6385 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6386 {
6387 yyn = yytable[yyn];
6388 if (0 < yyn)
6389 break;
6390 }
6391 }
6392
6393 /* Pop the current state because it cannot handle the error token. */
6394 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006395 YYABORT;
6396
6397
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006398 yydestruct ("Error: popping",
6399 yystos[yystate], yyvsp);
6400 YYPOPSTACK (1);
Reid Spencer950bf602007-01-26 08:19:09 +00006401 yystate = *yyssp;
6402 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006403 }
6404
6405 if (yyn == YYFINAL)
6406 YYACCEPT;
6407
6408 *++yyvsp = yylval;
Reid Spencer319a7302007-01-05 17:20:02 +00006409
6410
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006411 /* Shift the error token. */
Reid Spencer950bf602007-01-26 08:19:09 +00006412 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6413
Reid Spencere7c3c602006-11-30 06:36:44 +00006414 yystate = yyn;
6415 goto yynewstate;
6416
Chris Lattner37e01c52007-01-04 18:46:42 +00006417
Reid Spencer319a7302007-01-05 17:20:02 +00006418/*-------------------------------------.
6419| yyacceptlab -- YYACCEPT comes here. |
6420`-------------------------------------*/
6421yyacceptlab:
6422 yyresult = 0;
6423 goto yyreturn;
6424
6425/*-----------------------------------.
6426| yyabortlab -- YYABORT comes here. |
6427`-----------------------------------*/
6428yyabortlab:
6429 yyresult = 1;
6430 goto yyreturn;
6431
6432#ifndef yyoverflow
Reid Spencer950bf602007-01-26 08:19:09 +00006433/*-------------------------------------------------.
6434| yyexhaustedlab -- memory exhaustion comes here. |
6435`-------------------------------------------------*/
6436yyexhaustedlab:
6437 yyerror (YY_("memory exhausted"));
Reid Spencer319a7302007-01-05 17:20:02 +00006438 yyresult = 2;
6439 /* Fall through. */
Chris Lattner37e01c52007-01-04 18:46:42 +00006440#endif
Reid Spencer319a7302007-01-05 17:20:02 +00006441
6442yyreturn:
Reid Spencer950bf602007-01-26 08:19:09 +00006443 if (yychar != YYEOF && yychar != YYEMPTY)
6444 yydestruct ("Cleanup: discarding lookahead",
6445 yytoken, &yylval);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006446 /* Do not reclaim the symbols of the rule which action triggered
6447 this YYABORT or YYACCEPT. */
6448 YYPOPSTACK (yylen);
6449 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer950bf602007-01-26 08:19:09 +00006450 while (yyssp != yyss)
6451 {
6452 yydestruct ("Cleanup: popping",
6453 yystos[*yyssp], yyvsp);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006454 YYPOPSTACK (1);
Reid Spencer950bf602007-01-26 08:19:09 +00006455 }
Reid Spencer319a7302007-01-05 17:20:02 +00006456#ifndef yyoverflow
6457 if (yyss != yyssa)
6458 YYSTACK_FREE (yyss);
6459#endif
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006460#if YYERROR_VERBOSE
6461 if (yymsg != yymsgbuf)
6462 YYSTACK_FREE (yymsg);
6463#endif
6464 /* Make sure YYID is used. */
6465 return YYID (yyresult);
Reid Spencere7c3c602006-11-30 06:36:44 +00006466}
Reid Spencer319a7302007-01-05 17:20:02 +00006467
6468
Anton Korobeynikovce13b852007-01-28 15:25:24 +00006469#line 3326 "/home/asl/proj/llvm/src/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006470
6471
6472int yyerror(const char *ErrorMsg) {
6473 std::string where
6474 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006475 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6476 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6477 if (yychar != YYEMPTY && yychar != 0)
6478 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6479 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006480 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006481 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006482 exit(1);
6483}
Reid Spencer319a7302007-01-05 17:20:02 +00006484
Reid Spencer30d0c582007-01-15 00:26:18 +00006485void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006486 std::string where
6487 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencer950bf602007-01-26 08:19:09 +00006488 + ":" + llvm::utostr((unsigned) Upgradelineno-1) + ": ";
6489 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6490 if (yychar != YYEMPTY && yychar != 0)
6491 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6492 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006493 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6494}
6495
Reid Spencer950bf602007-01-26 08:19:09 +00006496void error(const std::string& ErrorMsg, int LineNo) {
6497 if (LineNo == -1) LineNo = Upgradelineno;
6498 Upgradelineno = LineNo;
6499 yyerror(ErrorMsg.c_str());
6500}
6501
6502