blob: a53944163ecd673b170960c88670bdf91dcc3b6d [file] [log] [blame]
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00005
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Reid Spencere7c3c602006-11-30 06:36:44 +000010
Reid Spencer3fae7ba2007-03-14 23:13:06 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000052#define yyparse Upgradeparse
Reid Spencer3fae7ba2007-03-14 23:13:06 +000053#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000054#define yyerror Upgradeerror
Reid Spencer3fae7ba2007-03-14 23:13:06 +000055#define yylval Upgradelval
56#define yychar Upgradechar
Reid Spencere7c3c602006-11-30 06:36:44 +000057#define yydebug Upgradedebug
58#define yynerrs Upgradenerrs
59
Reid Spencer3fae7ba2007-03-14 23:13:06 +000060
61/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 BOOL = 264,
74 SBYTE = 265,
75 UBYTE = 266,
76 SHORT = 267,
77 USHORT = 268,
78 INT = 269,
79 UINT = 270,
80 LONG = 271,
81 ULONG = 272,
82 FLOAT = 273,
83 DOUBLE = 274,
84 TYPE = 275,
85 LABEL = 276,
86 VAR_ID = 277,
87 LABELSTR = 278,
88 STRINGCONSTANT = 279,
89 IMPLEMENTATION = 280,
90 ZEROINITIALIZER = 281,
91 TRUETOK = 282,
92 FALSETOK = 283,
93 BEGINTOK = 284,
94 ENDTOK = 285,
95 DECLARE = 286,
96 GLOBAL = 287,
97 CONSTANT = 288,
98 SECTION = 289,
99 VOLATILE = 290,
100 TO = 291,
101 DOTDOTDOT = 292,
102 NULL_TOK = 293,
103 UNDEF = 294,
104 CONST = 295,
105 INTERNAL = 296,
106 LINKONCE = 297,
107 WEAK = 298,
108 APPENDING = 299,
109 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
112 OPAQUE = 303,
113 NOT = 304,
114 EXTERNAL = 305,
115 TARGET = 306,
116 TRIPLE = 307,
117 ENDIAN = 308,
118 POINTERSIZE = 309,
119 LITTLE = 310,
120 BIG = 311,
121 ALIGN = 312,
122 DEPLIBS = 313,
123 CALL = 314,
124 TAIL = 315,
125 ASM_TOK = 316,
126 MODULE = 317,
127 SIDEEFFECT = 318,
128 CC_TOK = 319,
129 CCC_TOK = 320,
130 CSRETCC_TOK = 321,
131 FASTCC_TOK = 322,
132 COLDCC_TOK = 323,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
135 DATALAYOUT = 326,
136 RET = 327,
137 BR = 328,
138 SWITCH = 329,
139 INVOKE = 330,
140 UNREACHABLE = 331,
141 UNWIND = 332,
142 EXCEPT = 333,
143 ADD = 334,
144 SUB = 335,
145 MUL = 336,
146 DIV = 337,
147 UDIV = 338,
148 SDIV = 339,
149 FDIV = 340,
150 REM = 341,
151 UREM = 342,
152 SREM = 343,
153 FREM = 344,
154 AND = 345,
155 OR = 346,
156 XOR = 347,
157 SHL = 348,
158 SHR = 349,
159 ASHR = 350,
160 LSHR = 351,
161 SETLE = 352,
162 SETGE = 353,
163 SETLT = 354,
164 SETGT = 355,
165 SETEQ = 356,
166 SETNE = 357,
167 ICMP = 358,
168 FCMP = 359,
169 MALLOC = 360,
170 ALLOCA = 361,
171 FREE = 362,
172 LOAD = 363,
173 STORE = 364,
174 GETELEMENTPTR = 365,
175 PHI_TOK = 366,
176 SELECT = 367,
177 VAARG = 368,
178 EXTRACTELEMENT = 369,
179 INSERTELEMENT = 370,
180 SHUFFLEVECTOR = 371,
181 VAARG_old = 372,
182 VANEXT_old = 373,
183 EQ = 374,
184 NE = 375,
185 SLT = 376,
186 SGT = 377,
187 SLE = 378,
188 SGE = 379,
189 ULT = 380,
190 UGT = 381,
191 ULE = 382,
192 UGE = 383,
193 OEQ = 384,
194 ONE = 385,
195 OLT = 386,
196 OGT = 387,
197 OLE = 388,
198 OGE = 389,
199 ORD = 390,
200 UNO = 391,
201 UEQ = 392,
202 UNE = 393,
203 CAST = 394,
204 TRUNC = 395,
205 ZEXT = 396,
206 SEXT = 397,
207 FPTRUNC = 398,
208 FPEXT = 399,
209 FPTOUI = 400,
210 FPTOSI = 401,
211 UITOFP = 402,
212 SITOFP = 403,
213 PTRTOINT = 404,
214 INTTOPTR = 405,
215 BITCAST = 406
216 };
217#endif
218/* Tokens. */
219#define ESINT64VAL 258
220#define EUINT64VAL 259
221#define SINTVAL 260
222#define UINTVAL 261
223#define FPVAL 262
224#define VOID 263
225#define BOOL 264
226#define SBYTE 265
227#define UBYTE 266
228#define SHORT 267
229#define USHORT 268
230#define INT 269
231#define UINT 270
232#define LONG 271
233#define ULONG 272
234#define FLOAT 273
235#define DOUBLE 274
236#define TYPE 275
237#define LABEL 276
238#define VAR_ID 277
239#define LABELSTR 278
240#define STRINGCONSTANT 279
241#define IMPLEMENTATION 280
242#define ZEROINITIALIZER 281
243#define TRUETOK 282
244#define FALSETOK 283
245#define BEGINTOK 284
246#define ENDTOK 285
247#define DECLARE 286
248#define GLOBAL 287
249#define CONSTANT 288
250#define SECTION 289
251#define VOLATILE 290
252#define TO 291
253#define DOTDOTDOT 292
254#define NULL_TOK 293
255#define UNDEF 294
256#define CONST 295
257#define INTERNAL 296
258#define LINKONCE 297
259#define WEAK 298
260#define APPENDING 299
261#define DLLIMPORT 300
262#define DLLEXPORT 301
263#define EXTERN_WEAK 302
264#define OPAQUE 303
265#define NOT 304
266#define EXTERNAL 305
267#define TARGET 306
268#define TRIPLE 307
269#define ENDIAN 308
270#define POINTERSIZE 309
271#define LITTLE 310
272#define BIG 311
273#define ALIGN 312
274#define DEPLIBS 313
275#define CALL 314
276#define TAIL 315
277#define ASM_TOK 316
278#define MODULE 317
279#define SIDEEFFECT 318
280#define CC_TOK 319
281#define CCC_TOK 320
282#define CSRETCC_TOK 321
283#define FASTCC_TOK 322
284#define COLDCC_TOK 323
285#define X86_STDCALLCC_TOK 324
286#define X86_FASTCALLCC_TOK 325
287#define DATALAYOUT 326
288#define RET 327
289#define BR 328
290#define SWITCH 329
291#define INVOKE 330
292#define UNREACHABLE 331
293#define UNWIND 332
294#define EXCEPT 333
295#define ADD 334
296#define SUB 335
297#define MUL 336
298#define DIV 337
299#define UDIV 338
300#define SDIV 339
301#define FDIV 340
302#define REM 341
303#define UREM 342
304#define SREM 343
305#define FREM 344
306#define AND 345
307#define OR 346
308#define XOR 347
309#define SHL 348
310#define SHR 349
311#define ASHR 350
312#define LSHR 351
313#define SETLE 352
314#define SETGE 353
315#define SETLT 354
316#define SETGT 355
317#define SETEQ 356
318#define SETNE 357
319#define ICMP 358
320#define FCMP 359
321#define MALLOC 360
322#define ALLOCA 361
323#define FREE 362
324#define LOAD 363
325#define STORE 364
326#define GETELEMENTPTR 365
327#define PHI_TOK 366
328#define SELECT 367
329#define VAARG 368
330#define EXTRACTELEMENT 369
331#define INSERTELEMENT 370
332#define SHUFFLEVECTOR 371
333#define VAARG_old 372
334#define VANEXT_old 373
335#define EQ 374
336#define NE 375
337#define SLT 376
338#define SGT 377
339#define SLE 378
340#define SGE 379
341#define ULT 380
342#define UGT 381
343#define ULE 382
344#define UGE 383
345#define OEQ 384
346#define ONE 385
347#define OLT 386
348#define OGT 387
349#define OLE 388
350#define OGE 389
351#define ORD 390
352#define UNO 391
353#define UEQ 392
354#define UNE 393
355#define CAST 394
356#define TRUNC 395
357#define ZEXT 396
358#define SEXT 397
359#define FPTRUNC 398
360#define FPEXT 399
361#define FPTOUI 400
362#define FPTOSI 401
363#define UITOFP 402
364#define SITOFP 403
365#define PTRTOINT 404
366#define INTTOPTR 405
367#define BITCAST 406
368
369
370
371
372/* Copy the first part of user declarations. */
373#line 14 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +0000374
375#include "UpgradeInternals.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000376#include "llvm/CallingConv.h"
377#include "llvm/InlineAsm.h"
378#include "llvm/Instructions.h"
379#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000380#include "llvm/ValueSymbolTable.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000381#include "llvm/Support/GetElementPtrTypeIterator.h"
382#include "llvm/ADT/STLExtras.h"
383#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000384#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000385#include <iostream>
Chris Lattner8adde282007-02-11 21:40:10 +0000386#include <map>
Reid Spencer950bf602007-01-26 08:19:09 +0000387#include <list>
388#include <utility>
389
390// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
391// relating to upreferences in the input stream.
392//
393//#define DEBUG_UPREFS 1
394#ifdef DEBUG_UPREFS
395#define UR_OUT(X) std::cerr << X
396#else
397#define UR_OUT(X)
398#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000399
Reid Spencere77e35e2006-12-01 20:26:20 +0000400#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000401#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000402#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000403
Reid Spencer950bf602007-01-26 08:19:09 +0000404int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000405int yyparse();
406
Reid Spencer950bf602007-01-26 08:19:09 +0000407int yyerror(const char*);
408static void warning(const std::string& WarningMsg);
409
410namespace llvm {
411
Reid Spencer950bf602007-01-26 08:19:09 +0000412std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000413static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000414
Reid Spencer71d2ec92006-12-31 06:02:26 +0000415// This bool controls whether attributes are ever added to function declarations
416// definitions and calls.
417static bool AddAttributes = false;
418
Reid Spencer950bf602007-01-26 08:19:09 +0000419static Module *ParserResult;
420static bool ObsoleteVarArgs;
421static bool NewVarArgs;
422static BasicBlock *CurBB;
423static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000424
Reid Spencer950bf602007-01-26 08:19:09 +0000425// This contains info used when building the body of a function. It is
426// destroyed when the function is completed.
427//
428typedef std::vector<Value *> ValueList; // Numbered defs
429
Reid Spencerbb1fd572007-03-21 17:15:50 +0000430typedef std::pair<std::string,TypeInfo> RenameMapKey;
Reid Spencer950bf602007-01-26 08:19:09 +0000431typedef std::map<RenameMapKey,std::string> RenameMapType;
432
433static void
434ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
435 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
436
437static struct PerModuleInfo {
438 Module *CurrentModule;
439 std::map<const Type *, ValueList> Values; // Module level numbered definitions
440 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencerbb1fd572007-03-21 17:15:50 +0000441 std::vector<PATypeHolder> Types;
442 std::vector<Signedness> TypeSigns;
443 std::map<std::string,Signedness> NamedTypeSigns;
444 std::map<std::string,Signedness> NamedValueSigns;
Reid Spencer950bf602007-01-26 08:19:09 +0000445 std::map<ValID, PATypeHolder> LateResolveTypes;
446 static Module::Endianness Endian;
447 static Module::PointerSize PointerSize;
448 RenameMapType RenameMap;
449
450 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
451 /// how they were referenced and on which line of the input they came from so
452 /// that we can resolve them later and print error messages as appropriate.
453 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
454
455 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
456 // references to global values. Global values may be referenced before they
457 // are defined, and if so, the temporary object that they represent is held
458 // here. This is used for forward references of GlobalValues.
459 //
460 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
461 GlobalRefsType;
462 GlobalRefsType GlobalRefs;
463
464 void ModuleDone() {
465 // If we could not resolve some functions at function compilation time
466 // (calls to functions before they are defined), resolve them now... Types
467 // are resolved when the constant pool has been completely parsed.
468 //
469 ResolveDefinitions(LateResolveValues);
470
471 // Check to make sure that all global value forward references have been
472 // resolved!
473 //
474 if (!GlobalRefs.empty()) {
475 std::string UndefinedReferences = "Unresolved global references exist:\n";
476
477 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
478 I != E; ++I) {
479 UndefinedReferences += " " + I->first.first->getDescription() + " " +
480 I->first.second.getName() + "\n";
481 }
482 error(UndefinedReferences);
483 return;
484 }
485
486 if (CurrentModule->getDataLayout().empty()) {
487 std::string dataLayout;
488 if (Endian != Module::AnyEndianness)
489 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
490 if (PointerSize != Module::AnyPointerSize) {
491 if (!dataLayout.empty())
492 dataLayout += "-";
493 dataLayout.append(PointerSize == Module::Pointer64 ?
494 "p:64:64" : "p:32:32");
495 }
496 CurrentModule->setDataLayout(dataLayout);
497 }
498
499 Values.clear(); // Clear out function local definitions
500 Types.clear();
Reid Spencerbb1fd572007-03-21 17:15:50 +0000501 TypeSigns.clear();
502 NamedTypeSigns.clear();
503 NamedValueSigns.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000504 CurrentModule = 0;
505 }
506
507 // GetForwardRefForGlobal - Check to see if there is a forward reference
508 // for this global. If so, remove it from the GlobalRefs map and return it.
509 // If not, just return null.
510 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
511 // Check to see if there is a forward reference to this global variable...
512 // if there is, eliminate it and patch the reference to use the new def'n.
513 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
514 GlobalValue *Ret = 0;
515 if (I != GlobalRefs.end()) {
516 Ret = I->second;
517 GlobalRefs.erase(I);
518 }
519 return Ret;
520 }
521 void setEndianness(Module::Endianness E) { Endian = E; }
522 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
523} CurModule;
524
525Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
526Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
527
528static struct PerFunctionInfo {
529 Function *CurrentFunction; // Pointer to current function being created
530
531 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
532 std::map<const Type*, ValueList> LateResolveValues;
533 bool isDeclare; // Is this function a forward declararation?
534 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
535
536 /// BBForwardRefs - When we see forward references to basic blocks, keep
537 /// track of them here.
538 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
539 std::vector<BasicBlock*> NumberedBlocks;
540 RenameMapType RenameMap;
Reid Spencer950bf602007-01-26 08:19:09 +0000541 unsigned NextBBNum;
542
543 inline PerFunctionInfo() {
544 CurrentFunction = 0;
545 isDeclare = false;
546 Linkage = GlobalValue::ExternalLinkage;
547 }
548
549 inline void FunctionStart(Function *M) {
550 CurrentFunction = M;
551 NextBBNum = 0;
552 }
553
554 void FunctionDone() {
555 NumberedBlocks.clear();
556
557 // Any forward referenced blocks left?
558 if (!BBForwardRefs.empty()) {
559 error("Undefined reference to label " +
560 BBForwardRefs.begin()->first->getName());
561 return;
562 }
563
564 // Resolve all forward references now.
565 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
566
567 Values.clear(); // Clear out function local definitions
568 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000569 CurrentFunction = 0;
570 isDeclare = false;
571 Linkage = GlobalValue::ExternalLinkage;
572 }
573} CurFun; // Info for the current function...
574
575static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
576
Reid Spencerbb1fd572007-03-21 17:15:50 +0000577/// This function is just a utility to make a Key value for the rename map.
578/// The Key is a combination of the name, type, Signedness of the original
579/// value (global/function). This just constructs the key and ensures that
580/// named Signedness values are resolved to the actual Signedness.
581/// @brief Make a key for the RenameMaps
582static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty,
583 const Signedness &Sign) {
584 TypeInfo TI;
585 TI.T = Ty;
586 if (Sign.isNamed())
587 // Don't allow Named Signedness nodes because they won't match. The actual
588 // Signedness must be looked up in the NamedTypeSigns map.
589 TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]);
590 else
591 TI.S.copy(Sign);
592 return std::make_pair(Name, TI);
593}
594
Reid Spencer950bf602007-01-26 08:19:09 +0000595
596//===----------------------------------------------------------------------===//
597// Code to handle definitions of all the types
598//===----------------------------------------------------------------------===//
599
600static int InsertValue(Value *V,
601 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
602 if (V->hasName()) return -1; // Is this a numbered definition?
603
604 // Yes, insert the value into the value table...
605 ValueList &List = ValueTab[V->getType()];
606 List.push_back(V);
607 return List.size()-1;
608}
609
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000610static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000611 switch (D.Type) {
612 case ValID::NumberVal: // Is it a numbered definition?
613 // Module constants occupy the lowest numbered slots...
614 if ((unsigned)D.Num < CurModule.Types.size()) {
615 return CurModule.Types[(unsigned)D.Num];
616 }
617 break;
618 case ValID::NameVal: // Is it a named definition?
619 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
Reid Spencer950bf602007-01-26 08:19:09 +0000620 return N;
621 }
622 break;
623 default:
624 error("Internal parser error: Invalid symbol type reference");
625 return 0;
626 }
627
628 // If we reached here, we referenced either a symbol that we don't know about
629 // or an id number that hasn't been read yet. We may be referencing something
630 // forward, so just create an entry to be resolved later and get to it...
631 //
632 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
633
Reid Spencer950bf602007-01-26 08:19:09 +0000634 if (inFunctionScope()) {
635 if (D.Type == ValID::NameVal) {
636 error("Reference to an undefined type: '" + D.getName() + "'");
637 return 0;
638 } else {
639 error("Reference to an undefined type: #" + itostr(D.Num));
640 return 0;
641 }
642 }
643
644 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
645 if (I != CurModule.LateResolveTypes.end())
646 return I->second;
647
648 Type *Typ = OpaqueType::get();
649 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
650 return Typ;
Reid Spencerbb1fd572007-03-21 17:15:50 +0000651}
652
653/// This is like the getType method except that instead of looking up the type
654/// for a given ID, it looks up that type's sign.
655/// @brief Get the signedness of a referenced type
656static Signedness getTypeSign(const ValID &D) {
657 switch (D.Type) {
658 case ValID::NumberVal: // Is it a numbered definition?
659 // Module constants occupy the lowest numbered slots...
660 if ((unsigned)D.Num < CurModule.TypeSigns.size()) {
661 return CurModule.TypeSigns[(unsigned)D.Num];
662 }
663 break;
664 case ValID::NameVal: { // Is it a named definition?
665 std::map<std::string,Signedness>::const_iterator I =
666 CurModule.NamedTypeSigns.find(D.Name);
667 if (I != CurModule.NamedTypeSigns.end())
668 return I->second;
669 // Perhaps its a named forward .. just cache the name
670 Signedness S;
671 S.makeNamed(D.Name);
672 return S;
673 }
674 default:
675 break;
676 }
677 // If we don't find it, its signless
678 Signedness S;
679 S.makeSignless();
680 return S;
681}
682
683/// This function is analagous to getElementType in LLVM. It provides the same
684/// function except that it looks up the Signedness instead of the type. This is
685/// used when processing GEP instructions that need to extract the type of an
686/// indexed struct/array/ptr member.
687/// @brief Look up an element's sign.
688static Signedness getElementSign(const ValueInfo& VI,
689 const std::vector<Value*> &Indices) {
690 const Type *Ptr = VI.V->getType();
691 assert(isa<PointerType>(Ptr) && "Need pointer type");
692
693 unsigned CurIdx = 0;
694 Signedness S(VI.S);
695 while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
696 if (CurIdx == Indices.size())
697 break;
698
699 Value *Index = Indices[CurIdx++];
700 assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type");
701 Ptr = CT->getTypeAtIndex(Index);
702 if (const Type* Ty = Ptr->getForwardedType())
703 Ptr = Ty;
704 assert(S.isComposite() && "Bad Signedness type");
705 if (isa<StructType>(CT)) {
706 S = S.get(cast<ConstantInt>(Index)->getZExtValue());
707 } else {
708 S = S.get(0UL);
709 }
710 if (S.isNamed())
711 S = CurModule.NamedTypeSigns[S.getName()];
712 }
713 Signedness Result;
714 Result.makeComposite(S);
715 return Result;
716}
717
718/// This function just translates a ConstantInfo into a ValueInfo and calls
719/// getElementSign(ValueInfo,...). Its just a convenience.
720/// @brief ConstantInfo version of getElementSign.
721static Signedness getElementSign(const ConstInfo& CI,
722 const std::vector<Constant*> &Indices) {
723 ValueInfo VI;
724 VI.V = CI.C;
725 VI.S.copy(CI.S);
726 std::vector<Value*> Idx;
727 for (unsigned i = 0; i < Indices.size(); ++i)
728 Idx.push_back(Indices[i]);
729 Signedness result = getElementSign(VI, Idx);
730 VI.destroy();
731 return result;
732}
Reid Spencer950bf602007-01-26 08:19:09 +0000733
Reid Spencered96d1e2007-02-08 09:08:52 +0000734/// This function determines if two function types differ only in their use of
735/// the sret parameter attribute in the first argument. If they are identical
736/// in all other respects, it returns true. Otherwise, it returns false.
Reid Spencerbb1fd572007-03-21 17:15:50 +0000737static bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
738 const FunctionType *F2) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000739 if (F1->getReturnType() != F2->getReturnType() ||
740 F1->getNumParams() != F2->getNumParams() ||
741 F1->getParamAttrs(0) != F2->getParamAttrs(0))
742 return false;
743 unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute);
744 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
745 if (F1->getParamType(i) != F2->getParamType(i) ||
746 unsigned(F1->getParamAttrs(i+1)) & SRetMask !=
747 unsigned(F2->getParamAttrs(i+1)) & SRetMask)
748 return false;
749 }
750 return true;
751}
752
Reid Spencerbb1fd572007-03-21 17:15:50 +0000753/// This function determines if the type of V and Ty differ only by the SRet
754/// parameter attribute. This is a more generalized case of
755/// FuncTysDIfferOnlyBySRet since it doesn't require FunctionType arguments.
756static bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) {
757 if (V->getType() == Ty)
758 return true;
759 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
760 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
761 if (PF1 && PF2) {
762 const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType());
763 const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType());
764 if (FT1 && FT2)
765 return FuncTysDifferOnlyBySRet(FT1, FT2);
766 }
767 return false;
768}
769
Reid Spencered96d1e2007-02-08 09:08:52 +0000770// The upgrade of csretcc to sret param attribute may have caused a function
771// to not be found because the param attribute changed the type of the called
772// function. This helper function, used in getExistingValue, detects that
Reid Spencerbb1fd572007-03-21 17:15:50 +0000773// situation and bitcasts the function to the correct type.
Reid Spencered96d1e2007-02-08 09:08:52 +0000774static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
775 // Handle degenerate cases
776 if (!V)
777 return 0;
778 if (V->getType() == Ty)
779 return V;
780
Reid Spencered96d1e2007-02-08 09:08:52 +0000781 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
782 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
783 if (PF1 && PF2) {
Reid Spencerbb1fd572007-03-21 17:15:50 +0000784 const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType());
785 const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType());
Reid Spencered96d1e2007-02-08 09:08:52 +0000786 if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2))
787 if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute))
Reid Spencerbb1fd572007-03-21 17:15:50 +0000788 return V;
Reid Spencered96d1e2007-02-08 09:08:52 +0000789 else if (Constant *C = dyn_cast<Constant>(V))
Reid Spencerbb1fd572007-03-21 17:15:50 +0000790 return ConstantExpr::getBitCast(C, PF1);
Reid Spencered96d1e2007-02-08 09:08:52 +0000791 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000792 return new BitCastInst(V, PF1, "upgrd.cast", CurBB);
793
Reid Spencered96d1e2007-02-08 09:08:52 +0000794 }
Reid Spencerbb1fd572007-03-21 17:15:50 +0000795 return 0;
Reid Spencered96d1e2007-02-08 09:08:52 +0000796}
797
Reid Spencer950bf602007-01-26 08:19:09 +0000798// getExistingValue - Look up the value specified by the provided type and
799// the provided ValID. If the value exists and has already been defined, return
800// it. Otherwise return null.
801//
802static Value *getExistingValue(const Type *Ty, const ValID &D) {
803 if (isa<FunctionType>(Ty)) {
804 error("Functions are not values and must be referenced as pointers");
805 }
806
807 switch (D.Type) {
808 case ValID::NumberVal: { // Is it a numbered definition?
809 unsigned Num = (unsigned)D.Num;
810
811 // Module constants occupy the lowest numbered slots...
812 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
813 if (VI != CurModule.Values.end()) {
814 if (Num < VI->second.size())
815 return VI->second[Num];
816 Num -= VI->second.size();
817 }
818
819 // Make sure that our type is within bounds
820 VI = CurFun.Values.find(Ty);
821 if (VI == CurFun.Values.end()) return 0;
822
823 // Check that the number is within bounds...
824 if (VI->second.size() <= Num) return 0;
825
826 return VI->second[Num];
827 }
828
829 case ValID::NameVal: { // Is it a named definition?
830 // Get the name out of the ID
Reid Spencerbb1fd572007-03-21 17:15:50 +0000831 RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
832 Value *V = 0;
Reid Spencer950bf602007-01-26 08:19:09 +0000833 if (inFunctionScope()) {
834 // See if the name was renamed
835 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
836 std::string LookupName;
837 if (I != CurFun.RenameMap.end())
838 LookupName = I->second;
839 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000840 LookupName = D.Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000841 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
842 V = SymTab.lookup(LookupName);
Reid Spencerbb1fd572007-03-21 17:15:50 +0000843 if (V && V->getType() != Ty)
844 V = handleSRetFuncTypeMerge(V, Ty);
845 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
Reid Spencer950bf602007-01-26 08:19:09 +0000846 }
847 if (!V) {
848 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
849 std::string LookupName;
850 if (I != CurModule.RenameMap.end())
851 LookupName = I->second;
852 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000853 LookupName = D.Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000854 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
Reid Spencerbb1fd572007-03-21 17:15:50 +0000855 if (V && V->getType() != Ty)
856 V = handleSRetFuncTypeMerge(V, Ty);
857 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
Reid Spencer950bf602007-01-26 08:19:09 +0000858 }
Reid Spenceref9b9a72007-02-05 20:47:22 +0000859 if (!V)
Reid Spencer950bf602007-01-26 08:19:09 +0000860 return 0;
861
862 D.destroy(); // Free old strdup'd memory...
863 return V;
864 }
865
866 // Check to make sure that "Ty" is an integral type, and that our
867 // value will fit into the specified type...
868 case ValID::ConstSIntVal: // Is it a constant pool reference??
869 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
870 error("Signed integral constant '" + itostr(D.ConstPool64) +
871 "' is invalid for type '" + Ty->getDescription() + "'");
872 }
873 return ConstantInt::get(Ty, D.ConstPool64);
874
875 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
876 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
877 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
878 error("Integral constant '" + utostr(D.UConstPool64) +
879 "' is invalid or out of range");
880 else // This is really a signed reference. Transmogrify.
881 return ConstantInt::get(Ty, D.ConstPool64);
882 } else
883 return ConstantInt::get(Ty, D.UConstPool64);
884
885 case ValID::ConstFPVal: // Is it a floating point const pool reference?
886 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
887 error("FP constant invalid for type");
888 return ConstantFP::get(Ty, D.ConstPoolFP);
889
890 case ValID::ConstNullVal: // Is it a null value?
891 if (!isa<PointerType>(Ty))
892 error("Cannot create a a non pointer null");
893 return ConstantPointerNull::get(cast<PointerType>(Ty));
894
895 case ValID::ConstUndefVal: // Is it an undef value?
896 return UndefValue::get(Ty);
897
898 case ValID::ConstZeroVal: // Is it a zero value?
899 return Constant::getNullValue(Ty);
900
901 case ValID::ConstantVal: // Fully resolved constant?
902 if (D.ConstantValue->getType() != Ty)
903 error("Constant expression type different from required type");
904 return D.ConstantValue;
905
906 case ValID::InlineAsmVal: { // Inline asm expression
907 const PointerType *PTy = dyn_cast<PointerType>(Ty);
908 const FunctionType *FTy =
909 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
910 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
911 error("Invalid type for asm constraint string");
912 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
913 D.IAD->HasSideEffects);
914 D.destroy(); // Free InlineAsmDescriptor.
915 return IA;
916 }
917 default:
918 assert(0 && "Unhandled case");
919 return 0;
920 } // End of switch
921
922 assert(0 && "Unhandled case");
923 return 0;
924}
925
926// getVal - This function is identical to getExistingValue, except that if a
927// value is not already defined, it "improvises" by creating a placeholder var
928// that looks and acts just like the requested variable. When the value is
929// defined later, all uses of the placeholder variable are replaced with the
930// real thing.
931//
932static Value *getVal(const Type *Ty, const ValID &ID) {
933 if (Ty == Type::LabelTy)
934 error("Cannot use a basic block here");
935
936 // See if the value has already been defined.
937 Value *V = getExistingValue(Ty, ID);
938 if (V) return V;
939
940 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
941 error("Invalid use of a composite type");
942
943 // If we reached here, we referenced either a symbol that we don't know about
944 // or an id number that hasn't been read yet. We may be referencing something
945 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000946 V = new Argument(Ty);
947
948 // Remember where this forward reference came from. FIXME, shouldn't we try
949 // to recycle these things??
950 CurModule.PlaceHolderInfo.insert(
Reid Spenceref9b9a72007-02-05 20:47:22 +0000951 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
Reid Spencer950bf602007-01-26 08:19:09 +0000952
953 if (inFunctionScope())
954 InsertValue(V, CurFun.LateResolveValues);
955 else
956 InsertValue(V, CurModule.LateResolveValues);
957 return V;
958}
959
Reid Spencered96d1e2007-02-08 09:08:52 +0000960/// @brief This just makes any name given to it unique, up to MAX_UINT times.
961static std::string makeNameUnique(const std::string& Name) {
962 static unsigned UniqueNameCounter = 1;
963 std::string Result(Name);
964 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
965 return Result;
966}
967
Reid Spencer950bf602007-01-26 08:19:09 +0000968/// getBBVal - This is used for two purposes:
969/// * If isDefinition is true, a new basic block with the specified ID is being
970/// defined.
971/// * If isDefinition is true, this is a reference to a basic block, which may
972/// or may not be a forward reference.
973///
974static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
975 assert(inFunctionScope() && "Can't get basic block at global scope");
976
977 std::string Name;
978 BasicBlock *BB = 0;
979 switch (ID.Type) {
980 default:
981 error("Illegal label reference " + ID.getName());
982 break;
983 case ValID::NumberVal: // Is it a numbered definition?
984 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
985 CurFun.NumberedBlocks.resize(ID.Num+1);
986 BB = CurFun.NumberedBlocks[ID.Num];
987 break;
988 case ValID::NameVal: // Is it a named definition?
989 Name = ID.Name;
Reid Spencerbb1fd572007-03-21 17:15:50 +0000990 if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000991 if (N->getType() != Type::LabelTy) {
992 // Register names didn't use to conflict with basic block names
993 // because of type planes. Now they all have to be unique. So, we just
994 // rename the register and treat this name as if no basic block
995 // had been found.
Reid Spencerbb1fd572007-03-21 17:15:50 +0000996 RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +0000997 N->setName(makeNameUnique(N->getName()));
998 CurModule.RenameMap[Key] = N->getName();
999 BB = 0;
1000 } else {
1001 BB = cast<BasicBlock>(N);
1002 }
Reid Spencer950bf602007-01-26 08:19:09 +00001003 }
1004 break;
1005 }
1006
1007 // See if the block has already been defined.
1008 if (BB) {
1009 // If this is the definition of the block, make sure the existing value was
1010 // just a forward reference. If it was a forward reference, there will be
1011 // an entry for it in the PlaceHolderInfo map.
1012 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
1013 // The existing value was a definition, not a forward reference.
1014 error("Redefinition of label " + ID.getName());
1015
1016 ID.destroy(); // Free strdup'd memory.
1017 return BB;
1018 }
1019
1020 // Otherwise this block has not been seen before.
1021 BB = new BasicBlock("", CurFun.CurrentFunction);
1022 if (ID.Type == ValID::NameVal) {
1023 BB->setName(ID.Name);
1024 } else {
1025 CurFun.NumberedBlocks[ID.Num] = BB;
1026 }
1027
1028 // If this is not a definition, keep track of it so we can use it as a forward
1029 // reference.
1030 if (!isDefinition) {
1031 // Remember where this forward reference came from.
1032 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
1033 } else {
1034 // The forward declaration could have been inserted anywhere in the
1035 // function: insert it into the correct place now.
1036 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
1037 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
1038 }
1039 ID.destroy();
1040 return BB;
1041}
1042
1043
1044//===----------------------------------------------------------------------===//
1045// Code to handle forward references in instructions
1046//===----------------------------------------------------------------------===//
1047//
1048// This code handles the late binding needed with statements that reference
1049// values not defined yet... for example, a forward branch, or the PHI node for
1050// a loop body.
1051//
1052// This keeps a table (CurFun.LateResolveValues) of all such forward references
1053// and back patchs after we are done.
1054//
1055
1056// ResolveDefinitions - If we could not resolve some defs at parsing
1057// time (forward branches, phi functions for loops, etc...) resolve the
1058// defs now...
1059//
1060static void
1061ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
1062 std::map<const Type*,ValueList> *FutureLateResolvers) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001063
Reid Spencer950bf602007-01-26 08:19:09 +00001064 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1065 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
1066 E = LateResolvers.end(); LRI != E; ++LRI) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001067 const Type* Ty = LRI->first;
Reid Spencer950bf602007-01-26 08:19:09 +00001068 ValueList &List = LRI->second;
1069 while (!List.empty()) {
1070 Value *V = List.back();
1071 List.pop_back();
1072
1073 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1074 CurModule.PlaceHolderInfo.find(V);
1075 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
1076
1077 ValID &DID = PHI->second.first;
1078
Reid Spencered96d1e2007-02-08 09:08:52 +00001079 Value *TheRealValue = getExistingValue(Ty, DID);
Reid Spencer950bf602007-01-26 08:19:09 +00001080 if (TheRealValue) {
1081 V->replaceAllUsesWith(TheRealValue);
1082 delete V;
1083 CurModule.PlaceHolderInfo.erase(PHI);
1084 } else if (FutureLateResolvers) {
1085 // Functions have their unresolved items forwarded to the module late
1086 // resolver table
1087 InsertValue(V, *FutureLateResolvers);
1088 } else {
1089 if (DID.Type == ValID::NameVal) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001090 error("Reference to an invalid definition: '" + DID.getName() +
1091 "' of type '" + V->getType()->getDescription() + "'",
1092 PHI->second.second);
Reid Spencer7de2e012007-01-29 19:08:46 +00001093 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001094 } else {
1095 error("Reference to an invalid definition: #" +
1096 itostr(DID.Num) + " of type '" +
1097 V->getType()->getDescription() + "'", PHI->second.second);
1098 return;
1099 }
1100 }
1101 }
1102 }
1103
1104 LateResolvers.clear();
1105}
1106
Reid Spencerbb1fd572007-03-21 17:15:50 +00001107/// This function is used for type resolution and upref handling. When a type
1108/// becomes concrete, this function is called to adjust the signedness for the
1109/// concrete type.
1110static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
1111 std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
1112 if (!TyName.empty())
1113 CurModule.NamedTypeSigns[TyName] = Sign;
1114}
1115
1116/// ResolveTypeTo - A brand new type was just declared. This means that (if
1117/// name is not null) things referencing Name can be resolved. Otherwise,
1118/// things refering to the number can be resolved. Do this now.
1119static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
Reid Spencer950bf602007-01-26 08:19:09 +00001120 ValID D;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001121 if (Name)
1122 D = ValID::create(Name);
1123 else
1124 D = ValID::create((int)CurModule.Types.size());
1125 D.S.copy(Sign);
1126
1127 CurModule.NamedTypeSigns[Name] = Sign;
Reid Spencer950bf602007-01-26 08:19:09 +00001128
1129 std::map<ValID, PATypeHolder>::iterator I =
1130 CurModule.LateResolveTypes.find(D);
1131 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00001132 const Type *OldTy = I->second.get();
1133 ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
Reid Spencer950bf602007-01-26 08:19:09 +00001134 CurModule.LateResolveTypes.erase(I);
1135 }
1136}
1137
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001138/// This is the implementation portion of TypeHasInteger. It traverses the
1139/// type given, avoiding recursive types, and returns true as soon as it finds
1140/// an integer type. If no integer type is found, it returns false.
1141static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
1142 // Handle some easy cases
1143 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
1144 return false;
1145 if (Ty->isInteger())
1146 return true;
1147 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
1148 return STy->getElementType()->isInteger();
1149
1150 // Avoid type structure recursion
1151 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
1152 I != E; ++I)
1153 if (Ty == *I)
1154 return false;
1155
1156 // Push us on the type stack
1157 Stack.push_back(Ty);
1158
1159 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1160 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1161 return true;
1162 FunctionType::param_iterator I = FTy->param_begin();
1163 FunctionType::param_iterator E = FTy->param_end();
1164 for (; I != E; ++I)
1165 if (TypeHasIntegerI(*I, Stack))
1166 return true;
1167 return false;
1168 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1169 StructType::element_iterator I = STy->element_begin();
1170 StructType::element_iterator E = STy->element_end();
1171 for (; I != E; ++I) {
1172 if (TypeHasIntegerI(*I, Stack))
1173 return true;
1174 }
1175 return false;
1176 }
1177 // There shouldn't be anything else, but its definitely not integer
1178 assert(0 && "What type is this?");
1179 return false;
1180}
1181
1182/// This is the interface to TypeHasIntegerI. It just provides the type stack,
1183/// to avoid recursion, and then calls TypeHasIntegerI.
1184static inline bool TypeHasInteger(const Type *Ty) {
1185 std::vector<const Type*> TyStack;
1186 return TypeHasIntegerI(Ty, TyStack);
1187}
1188
Reid Spencer950bf602007-01-26 08:19:09 +00001189// setValueName - Set the specified value to the name given. The name may be
1190// null potentially, in which case this is a noop. The string passed in is
1191// assumed to be a malloc'd string buffer, and is free'd by this function.
1192//
Reid Spencerbb1fd572007-03-21 17:15:50 +00001193static void setValueName(const ValueInfo &V, char *NameStr) {
Reid Spencer950bf602007-01-26 08:19:09 +00001194 if (NameStr) {
1195 std::string Name(NameStr); // Copy string
1196 free(NameStr); // Free old string
1197
Reid Spencerbb1fd572007-03-21 17:15:50 +00001198 if (V.V->getType() == Type::VoidTy) {
Reid Spencer950bf602007-01-26 08:19:09 +00001199 error("Can't assign name '" + Name + "' to value with void type");
1200 return;
1201 }
1202
Reid Spencer950bf602007-01-26 08:19:09 +00001203 assert(inFunctionScope() && "Must be in function scope");
1204
1205 // Search the function's symbol table for an existing value of this name
Reid Spenceref9b9a72007-02-05 20:47:22 +00001206 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1207 Value* Existing = ST.lookup(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001208 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001209 // An existing value of the same name was found. This might have happened
1210 // because of the integer type planes collapsing in LLVM 2.0.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001211 if (Existing->getType() == V.V->getType() &&
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001212 !TypeHasInteger(Existing->getType())) {
1213 // If the type does not contain any integers in them then this can't be
1214 // a type plane collapsing issue. It truly is a redefinition and we
1215 // should error out as the assembly is invalid.
1216 error("Redefinition of value named '" + Name + "' of type '" +
Reid Spencerbb1fd572007-03-21 17:15:50 +00001217 V.V->getType()->getDescription() + "'");
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001218 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001219 }
1220 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1221 // function, regardless of Type. Previously re-use of names was okay as
1222 // long as they were distinct types. With type planes collapsing because
1223 // of the signedness change and because of PR411, this can no longer be
1224 // supported. We must search the entire symbol table for a conflicting
1225 // name and make the name unique. No warning is needed as this can't
1226 // cause a problem.
1227 std::string NewName = makeNameUnique(Name);
1228 // We're changing the name but it will probably be used by other
1229 // instructions as operands later on. Consequently we have to retain
1230 // a mapping of the renaming that we're doing.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001231 RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
Reid Spencer950bf602007-01-26 08:19:09 +00001232 CurFun.RenameMap[Key] = NewName;
1233 Name = NewName;
1234 }
1235
1236 // Set the name.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001237 V.V->setName(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001238 }
1239}
1240
1241/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1242/// this is a declaration, otherwise it is a definition.
1243static GlobalVariable *
1244ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1245 bool isConstantGlobal, const Type *Ty,
Reid Spencerbb1fd572007-03-21 17:15:50 +00001246 Constant *Initializer,
1247 const Signedness &Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001248 if (isa<FunctionType>(Ty))
1249 error("Cannot declare global vars of function type");
1250
1251 const PointerType *PTy = PointerType::get(Ty);
1252
1253 std::string Name;
1254 if (NameStr) {
1255 Name = NameStr; // Copy string
1256 free(NameStr); // Free old string
1257 }
1258
1259 // See if this global value was forward referenced. If so, recycle the
1260 // object.
1261 ValID ID;
1262 if (!Name.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00001263 ID = ValID::create((char*)Name.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00001264 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00001265 ID = ValID::create((int)CurModule.Values[PTy].size());
Reid Spencer950bf602007-01-26 08:19:09 +00001266 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00001267 ID.S.makeComposite(Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001268
1269 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1270 // Move the global to the end of the list, from whereever it was
1271 // previously inserted.
1272 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1273 CurModule.CurrentModule->getGlobalList().remove(GV);
1274 CurModule.CurrentModule->getGlobalList().push_back(GV);
1275 GV->setInitializer(Initializer);
1276 GV->setLinkage(Linkage);
1277 GV->setConstant(isConstantGlobal);
1278 InsertValue(GV, CurModule.Values);
1279 return GV;
1280 }
1281
1282 // If this global has a name, check to see if there is already a definition
1283 // of this global in the module and emit warnings if there are conflicts.
1284 if (!Name.empty()) {
1285 // The global has a name. See if there's an existing one of the same name.
1286 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1287 // We found an existing global ov the same name. This isn't allowed
1288 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1289 // can at least compile. This can happen because of type planes
1290 // There is alread a global of the same name which means there is a
1291 // conflict. Let's see what we can do about it.
1292 std::string NewName(makeNameUnique(Name));
Reid Spencerbb1fd572007-03-21 17:15:50 +00001293 if (Linkage != GlobalValue::InternalLinkage) {
Reid Spencer950bf602007-01-26 08:19:09 +00001294 // The linkage of this gval is external so we can't reliably rename
1295 // it because it could potentially create a linking problem.
1296 // However, we can't leave the name conflict in the output either or
1297 // it won't assemble with LLVM 2.0. So, all we can do is rename
1298 // this one to something unique and emit a warning about the problem.
1299 warning("Renaming global variable '" + Name + "' to '" + NewName +
1300 "' may cause linkage errors");
1301 }
1302
1303 // Put the renaming in the global rename map
Reid Spencerbb1fd572007-03-21 17:15:50 +00001304 RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
Reid Spencer950bf602007-01-26 08:19:09 +00001305 CurModule.RenameMap[Key] = NewName;
1306
1307 // Rename it
1308 Name = NewName;
1309 }
1310 }
1311
1312 // Otherwise there is no existing GV to use, create one now.
1313 GlobalVariable *GV =
1314 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1315 CurModule.CurrentModule);
1316 InsertValue(GV, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00001317 // Remember the sign of this global.
1318 CurModule.NamedValueSigns[Name] = ID.S;
Reid Spencer950bf602007-01-26 08:19:09 +00001319 return GV;
1320}
1321
1322// setTypeName - Set the specified type to the name given. The name may be
1323// null potentially, in which case this is a noop. The string passed in is
1324// assumed to be a malloc'd string buffer, and is freed by this function.
1325//
1326// This function returns true if the type has already been defined, but is
1327// allowed to be redefined in the specified context. If the name is a new name
1328// for the type plane, it is inserted and false is returned.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001329static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
Reid Spencer950bf602007-01-26 08:19:09 +00001330 assert(!inFunctionScope() && "Can't give types function-local names");
1331 if (NameStr == 0) return false;
1332
1333 std::string Name(NameStr); // Copy string
1334 free(NameStr); // Free old string
1335
Reid Spencerbb1fd572007-03-21 17:15:50 +00001336 const Type* Ty = TI.PAT->get();
1337
Reid Spencer950bf602007-01-26 08:19:09 +00001338 // We don't allow assigning names to void type
Reid Spencerbb1fd572007-03-21 17:15:50 +00001339 if (Ty == Type::VoidTy) {
Reid Spencer950bf602007-01-26 08:19:09 +00001340 error("Can't assign name '" + Name + "' to the void type");
1341 return false;
1342 }
1343
1344 // Set the type name, checking for conflicts as we do so.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001345 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
1346
1347 // Save the sign information for later use
1348 CurModule.NamedTypeSigns[Name] = TI.S;
Reid Spencer950bf602007-01-26 08:19:09 +00001349
1350 if (AlreadyExists) { // Inserting a name that is already defined???
1351 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1352 assert(Existing && "Conflict but no matching type?");
1353
1354 // There is only one case where this is allowed: when we are refining an
1355 // opaque type. In this case, Existing will be an opaque type.
1356 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1357 // We ARE replacing an opaque type!
Reid Spencerbb1fd572007-03-21 17:15:50 +00001358 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00001359 return true;
1360 }
1361
1362 // Otherwise, this is an attempt to redefine a type. That's okay if
1363 // the redefinition is identical to the original. This will be so if
1364 // Existing and T point to the same Type object. In this one case we
1365 // allow the equivalent redefinition.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001366 if (Existing == Ty) return true; // Yes, it's equal.
Reid Spencer950bf602007-01-26 08:19:09 +00001367
1368 // Any other kind of (non-equivalent) redefinition is an error.
1369 error("Redefinition of type named '" + Name + "' in the '" +
Reid Spencerbb1fd572007-03-21 17:15:50 +00001370 Ty->getDescription() + "' type plane");
Reid Spencer950bf602007-01-26 08:19:09 +00001371 }
1372
1373 return false;
1374}
1375
1376//===----------------------------------------------------------------------===//
1377// Code for handling upreferences in type names...
1378//
1379
1380// TypeContains - Returns true if Ty directly contains E in it.
1381//
1382static bool TypeContains(const Type *Ty, const Type *E) {
1383 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1384 E) != Ty->subtype_end();
1385}
1386
1387namespace {
1388 struct UpRefRecord {
1389 // NestingLevel - The number of nesting levels that need to be popped before
1390 // this type is resolved.
1391 unsigned NestingLevel;
1392
1393 // LastContainedTy - This is the type at the current binding level for the
1394 // type. Every time we reduce the nesting level, this gets updated.
1395 const Type *LastContainedTy;
1396
1397 // UpRefTy - This is the actual opaque type that the upreference is
1398 // represented with.
1399 OpaqueType *UpRefTy;
1400
1401 UpRefRecord(unsigned NL, OpaqueType *URTy)
Reid Spencerbb1fd572007-03-21 17:15:50 +00001402 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
Reid Spencer950bf602007-01-26 08:19:09 +00001403 };
1404}
1405
1406// UpRefs - A list of the outstanding upreferences that need to be resolved.
1407static std::vector<UpRefRecord> UpRefs;
1408
1409/// HandleUpRefs - Every time we finish a new layer of types, this function is
1410/// called. It loops through the UpRefs vector, which is a list of the
1411/// currently active types. For each type, if the up reference is contained in
1412/// the newly completed type, we decrement the level count. When the level
1413/// count reaches zero, the upreferenced type is the type that is passed in:
1414/// thus we can complete the cycle.
1415///
Reid Spencerbb1fd572007-03-21 17:15:50 +00001416static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001417 // If Ty isn't abstract, or if there are no up-references in it, then there is
1418 // nothing to resolve here.
1419 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1420
1421 PATypeHolder Ty(ty);
1422 UR_OUT("Type '" << Ty->getDescription() <<
1423 "' newly formed. Resolving upreferences.\n" <<
1424 UpRefs.size() << " upreferences active!\n");
1425
1426 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1427 // to zero), we resolve them all together before we resolve them to Ty. At
1428 // the end of the loop, if there is anything to resolve to Ty, it will be in
1429 // this variable.
1430 OpaqueType *TypeToResolve = 0;
1431
Reid Spencerbb1fd572007-03-21 17:15:50 +00001432 unsigned i = 0;
1433 for (; i != UpRefs.size(); ++i) {
Reid Spencer950bf602007-01-26 08:19:09 +00001434 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001435 << UpRefs[i].UpRefTy->getDescription() << ") = "
1436 << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
Reid Spencer950bf602007-01-26 08:19:09 +00001437 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1438 // Decrement level of upreference
1439 unsigned Level = --UpRefs[i].NestingLevel;
1440 UpRefs[i].LastContainedTy = Ty;
1441 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1442 if (Level == 0) { // Upreference should be resolved!
1443 if (!TypeToResolve) {
1444 TypeToResolve = UpRefs[i].UpRefTy;
1445 } else {
1446 UR_OUT(" * Resolving upreference for "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001447 << UpRefs[i].UpRefTy->getDescription() << "\n";
1448 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1449 ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001450 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1451 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1452 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1453 }
1454 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1455 --i; // Do not skip the next element...
1456 }
1457 }
1458 }
1459
1460 if (TypeToResolve) {
1461 UR_OUT(" * Resolving upreference for "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001462 << UpRefs[i].UpRefTy->getDescription() << "\n";
Reid Spencer950bf602007-01-26 08:19:09 +00001463 std::string OldName = TypeToResolve->getDescription());
Reid Spencerbb1fd572007-03-21 17:15:50 +00001464 ResolveTypeSign(TypeToResolve, Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001465 TypeToResolve->refineAbstractTypeTo(Ty);
1466 }
1467
1468 return Ty;
1469}
1470
Reid Spencerbb1fd572007-03-21 17:15:50 +00001471bool Signedness::operator<(const Signedness &that) const {
1472 if (isNamed()) {
1473 if (that.isNamed())
1474 return *(this->name) < *(that.name);
1475 else
1476 return CurModule.NamedTypeSigns[*name] < that;
1477 } else if (that.isNamed()) {
1478 return *this < CurModule.NamedTypeSigns[*that.name];
1479 }
1480
1481 if (isComposite() && that.isComposite()) {
1482 if (sv->size() == that.sv->size()) {
1483 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1484 SignVector::const_iterator thatI = that.sv->begin(),
1485 thatE = that.sv->end();
1486 for (; thisI != thisE; ++thisI, ++thatI) {
1487 if (*thisI < *thatI)
1488 return true;
1489 else if (!(*thisI == *thatI))
1490 return false;
1491 }
1492 return false;
1493 }
1494 return sv->size() < that.sv->size();
1495 }
1496 return kind < that.kind;
1497}
1498
1499bool Signedness::operator==(const Signedness &that) const {
1500 if (isNamed())
1501 if (that.isNamed())
1502 return *(this->name) == *(that.name);
1503 else
1504 return CurModule.NamedTypeSigns[*(this->name)] == that;
1505 else if (that.isNamed())
1506 return *this == CurModule.NamedTypeSigns[*(that.name)];
1507 if (isComposite() && that.isComposite()) {
1508 if (sv->size() == that.sv->size()) {
1509 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1510 SignVector::const_iterator thatI = that.sv->begin(),
1511 thatE = that.sv->end();
1512 for (; thisI != thisE; ++thisI, ++thatI) {
1513 if (!(*thisI == *thatI))
1514 return false;
1515 }
1516 return true;
1517 }
1518 return false;
1519 }
1520 return kind == that.kind;
1521}
1522
1523void Signedness::copy(const Signedness &that) {
1524 if (that.isNamed()) {
1525 kind = Named;
1526 name = new std::string(*that.name);
1527 } else if (that.isComposite()) {
1528 kind = Composite;
1529 sv = new SignVector();
1530 *sv = *that.sv;
1531 } else {
1532 kind = that.kind;
1533 sv = 0;
1534 }
1535}
1536
1537void Signedness::destroy() {
1538 if (isNamed()) {
1539 delete name;
1540 } else if (isComposite()) {
1541 delete sv;
1542 }
1543}
1544
Evan Cheng2b484202007-03-22 07:43:51 +00001545#ifndef NDEBUG
Reid Spencerbb1fd572007-03-21 17:15:50 +00001546void Signedness::dump() const {
1547 if (isComposite()) {
1548 if (sv->size() == 1) {
1549 (*sv)[0].dump();
1550 std::cerr << "*";
1551 } else {
1552 std::cerr << "{ " ;
1553 for (unsigned i = 0; i < sv->size(); ++i) {
1554 if (i != 0)
1555 std::cerr << ", ";
1556 (*sv)[i].dump();
1557 }
1558 std::cerr << "} " ;
1559 }
1560 } else if (isNamed()) {
1561 std::cerr << *name;
1562 } else if (isSigned()) {
1563 std::cerr << "S";
1564 } else if (isUnsigned()) {
1565 std::cerr << "U";
1566 } else
1567 std::cerr << ".";
1568}
Evan Cheng2b484202007-03-22 07:43:51 +00001569#endif
Reid Spencerbb1fd572007-03-21 17:15:50 +00001570
Reid Spencer950bf602007-01-26 08:19:09 +00001571static inline Instruction::TermOps
1572getTermOp(TermOps op) {
1573 switch (op) {
1574 default : assert(0 && "Invalid OldTermOp");
1575 case RetOp : return Instruction::Ret;
1576 case BrOp : return Instruction::Br;
1577 case SwitchOp : return Instruction::Switch;
1578 case InvokeOp : return Instruction::Invoke;
1579 case UnwindOp : return Instruction::Unwind;
1580 case UnreachableOp: return Instruction::Unreachable;
1581 }
1582}
1583
1584static inline Instruction::BinaryOps
Reid Spencerbb1fd572007-03-21 17:15:50 +00001585getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001586 switch (op) {
1587 default : assert(0 && "Invalid OldBinaryOps");
1588 case SetEQ :
1589 case SetNE :
1590 case SetLE :
1591 case SetGE :
1592 case SetLT :
1593 case SetGT : assert(0 && "Should use getCompareOp");
1594 case AddOp : return Instruction::Add;
1595 case SubOp : return Instruction::Sub;
1596 case MulOp : return Instruction::Mul;
1597 case DivOp : {
1598 // This is an obsolete instruction so we must upgrade it based on the
1599 // types of its operands.
1600 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001601 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001602 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001603 isFP = PTy->getElementType()->isFloatingPoint();
1604 if (isFP)
1605 return Instruction::FDiv;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001606 else if (Sign.isSigned())
Reid Spencer950bf602007-01-26 08:19:09 +00001607 return Instruction::SDiv;
1608 return Instruction::UDiv;
1609 }
1610 case UDivOp : return Instruction::UDiv;
1611 case SDivOp : return Instruction::SDiv;
1612 case FDivOp : return Instruction::FDiv;
1613 case RemOp : {
1614 // This is an obsolete instruction so we must upgrade it based on the
1615 // types of its operands.
1616 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001617 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001618 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001619 isFP = PTy->getElementType()->isFloatingPoint();
1620 // Select correct opcode
1621 if (isFP)
1622 return Instruction::FRem;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001623 else if (Sign.isSigned())
Reid Spencer950bf602007-01-26 08:19:09 +00001624 return Instruction::SRem;
1625 return Instruction::URem;
1626 }
1627 case URemOp : return Instruction::URem;
1628 case SRemOp : return Instruction::SRem;
1629 case FRemOp : return Instruction::FRem;
Reid Spencer832254e2007-02-02 02:16:23 +00001630 case LShrOp : return Instruction::LShr;
1631 case AShrOp : return Instruction::AShr;
1632 case ShlOp : return Instruction::Shl;
1633 case ShrOp :
Reid Spencerbb1fd572007-03-21 17:15:50 +00001634 if (Sign.isSigned())
Reid Spencer832254e2007-02-02 02:16:23 +00001635 return Instruction::AShr;
1636 return Instruction::LShr;
Reid Spencer950bf602007-01-26 08:19:09 +00001637 case AndOp : return Instruction::And;
1638 case OrOp : return Instruction::Or;
1639 case XorOp : return Instruction::Xor;
1640 }
1641}
1642
1643static inline Instruction::OtherOps
1644getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
Reid Spencerbb1fd572007-03-21 17:15:50 +00001645 const Signedness &Sign) {
1646 bool isSigned = Sign.isSigned();
Reid Spencer950bf602007-01-26 08:19:09 +00001647 bool isFP = Ty->isFloatingPoint();
1648 switch (op) {
1649 default : assert(0 && "Invalid OldSetCC");
1650 case SetEQ :
1651 if (isFP) {
1652 predicate = FCmpInst::FCMP_OEQ;
1653 return Instruction::FCmp;
1654 } else {
1655 predicate = ICmpInst::ICMP_EQ;
1656 return Instruction::ICmp;
1657 }
1658 case SetNE :
1659 if (isFP) {
1660 predicate = FCmpInst::FCMP_UNE;
1661 return Instruction::FCmp;
1662 } else {
1663 predicate = ICmpInst::ICMP_NE;
1664 return Instruction::ICmp;
1665 }
1666 case SetLE :
1667 if (isFP) {
1668 predicate = FCmpInst::FCMP_OLE;
1669 return Instruction::FCmp;
1670 } else {
1671 if (isSigned)
1672 predicate = ICmpInst::ICMP_SLE;
1673 else
1674 predicate = ICmpInst::ICMP_ULE;
1675 return Instruction::ICmp;
1676 }
1677 case SetGE :
1678 if (isFP) {
1679 predicate = FCmpInst::FCMP_OGE;
1680 return Instruction::FCmp;
1681 } else {
1682 if (isSigned)
1683 predicate = ICmpInst::ICMP_SGE;
1684 else
1685 predicate = ICmpInst::ICMP_UGE;
1686 return Instruction::ICmp;
1687 }
1688 case SetLT :
1689 if (isFP) {
1690 predicate = FCmpInst::FCMP_OLT;
1691 return Instruction::FCmp;
1692 } else {
1693 if (isSigned)
1694 predicate = ICmpInst::ICMP_SLT;
1695 else
1696 predicate = ICmpInst::ICMP_ULT;
1697 return Instruction::ICmp;
1698 }
1699 case SetGT :
1700 if (isFP) {
1701 predicate = FCmpInst::FCMP_OGT;
1702 return Instruction::FCmp;
1703 } else {
1704 if (isSigned)
1705 predicate = ICmpInst::ICMP_SGT;
1706 else
1707 predicate = ICmpInst::ICMP_UGT;
1708 return Instruction::ICmp;
1709 }
1710 }
1711}
1712
1713static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1714 switch (op) {
1715 default : assert(0 && "Invalid OldMemoryOps");
1716 case MallocOp : return Instruction::Malloc;
1717 case FreeOp : return Instruction::Free;
1718 case AllocaOp : return Instruction::Alloca;
1719 case LoadOp : return Instruction::Load;
1720 case StoreOp : return Instruction::Store;
1721 case GetElementPtrOp : return Instruction::GetElementPtr;
1722 }
1723}
1724
1725static inline Instruction::OtherOps
Reid Spencerbb1fd572007-03-21 17:15:50 +00001726getOtherOp(OtherOps op, const Signedness &Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001727 switch (op) {
1728 default : assert(0 && "Invalid OldOtherOps");
1729 case PHIOp : return Instruction::PHI;
1730 case CallOp : return Instruction::Call;
Reid Spencer950bf602007-01-26 08:19:09 +00001731 case SelectOp : return Instruction::Select;
1732 case UserOp1 : return Instruction::UserOp1;
1733 case UserOp2 : return Instruction::UserOp2;
1734 case VAArg : return Instruction::VAArg;
1735 case ExtractElementOp : return Instruction::ExtractElement;
1736 case InsertElementOp : return Instruction::InsertElement;
1737 case ShuffleVectorOp : return Instruction::ShuffleVector;
1738 case ICmpOp : return Instruction::ICmp;
1739 case FCmpOp : return Instruction::FCmp;
Reid Spencer950bf602007-01-26 08:19:09 +00001740 };
1741}
1742
1743static inline Value*
Reid Spencerbb1fd572007-03-21 17:15:50 +00001744getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
1745 const Signedness &DstSign, bool ForceInstruction = false) {
Reid Spencer950bf602007-01-26 08:19:09 +00001746 Instruction::CastOps Opcode;
1747 const Type* SrcTy = Src->getType();
1748 if (op == CastOp) {
1749 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1750 // fp -> ptr cast is no longer supported but we must upgrade this
1751 // by doing a double cast: fp -> int -> ptr
1752 SrcTy = Type::Int64Ty;
1753 Opcode = Instruction::IntToPtr;
1754 if (isa<Constant>(Src)) {
1755 Src = ConstantExpr::getCast(Instruction::FPToUI,
1756 cast<Constant>(Src), SrcTy);
1757 } else {
1758 std::string NewName(makeNameUnique(Src->getName()));
1759 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1760 }
1761 } else if (isa<IntegerType>(DstTy) &&
1762 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1763 // cast type %x to bool was previously defined as setne type %x, null
1764 // The cast semantic is now to truncate, not compare so we must retain
1765 // the original intent by replacing the cast with a setne
1766 Constant* Null = Constant::getNullValue(SrcTy);
1767 Instruction::OtherOps Opcode = Instruction::ICmp;
1768 unsigned short predicate = ICmpInst::ICMP_NE;
1769 if (SrcTy->isFloatingPoint()) {
1770 Opcode = Instruction::FCmp;
1771 predicate = FCmpInst::FCMP_ONE;
1772 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1773 error("Invalid cast to bool");
1774 }
1775 if (isa<Constant>(Src) && !ForceInstruction)
1776 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1777 else
1778 return CmpInst::create(Opcode, predicate, Src, Null);
1779 }
1780 // Determine the opcode to use by calling CastInst::getCastOpcode
1781 Opcode =
Reid Spencerbb1fd572007-03-21 17:15:50 +00001782 CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
1783 DstSign.isSigned());
Reid Spencer950bf602007-01-26 08:19:09 +00001784
1785 } else switch (op) {
1786 default: assert(0 && "Invalid cast token");
1787 case TruncOp: Opcode = Instruction::Trunc; break;
1788 case ZExtOp: Opcode = Instruction::ZExt; break;
1789 case SExtOp: Opcode = Instruction::SExt; break;
1790 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1791 case FPExtOp: Opcode = Instruction::FPExt; break;
1792 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1793 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1794 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1795 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1796 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1797 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1798 case BitCastOp: Opcode = Instruction::BitCast; break;
1799 }
1800
1801 if (isa<Constant>(Src) && !ForceInstruction)
1802 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1803 return CastInst::create(Opcode, Src, DstTy);
1804}
1805
1806static Instruction *
1807upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1808 std::vector<Value*>& Args) {
1809
1810 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
Reid Spencer41b213e2007-04-02 01:14:00 +00001811 switch (Name[5]) {
1812 case 'i':
1813 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1814 if (Args.size() != 2)
1815 error("Invalid prototype for " + Name);
1816 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1817 }
1818 break;
1819 case 'b':
1820 if (Name.length() == 14 && !memcmp(&Name[5], "bswap.i", 7)) {
1821 const Type* ArgTy = Args[0]->getType();
1822 Name += ".i" + utostr(cast<IntegerType>(ArgTy)->getBitWidth());
1823 Function *F = cast<Function>(
1824 CurModule.CurrentModule->getOrInsertFunction(Name, RetTy, ArgTy,
1825 (void*)0));
1826 return new CallInst(F, Args[0]);
1827 }
1828 break;
Reid Spencer8166a6c2007-04-02 02:08:35 +00001829 case 'c':
1830 if ((Name.length() <= 14 && !memcmp(&Name[5], "ctpop.i", 7)) ||
1831 (Name.length() <= 13 && !memcmp(&Name[5], "ctlz.i", 6)) ||
1832 (Name.length() <= 13 && !memcmp(&Name[5], "cttz.i", 6))) {
1833 // These intrinsics changed their result type.
1834 const Type* ArgTy = Args[0]->getType();
1835 Function *OldF = CurModule.CurrentModule->getFunction(Name);
1836 if (OldF)
1837 OldF->setName("upgrd.rm." + Name);
1838
1839 Function *NewF = cast<Function>(
1840 CurModule.CurrentModule->getOrInsertFunction(Name, Type::Int32Ty,
1841 ArgTy, (void*)0));
1842
1843 Instruction *Call = new CallInst(NewF, Args[0], "", CurBB);
1844 return CastInst::createIntegerCast(Call, RetTy, false);
1845 }
1846 break;
1847
Reid Spencer41b213e2007-04-02 01:14:00 +00001848 case 'v' : {
1849 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1850 std::vector<const Type*> Params;
1851 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1852 if (Args.size() != 1)
1853 error("Invalid prototype for " + Name + " prototype");
1854 Params.push_back(PtrTy);
1855 const FunctionType *FTy =
1856 FunctionType::get(Type::VoidTy, Params, false);
1857 const PointerType *PFTy = PointerType::get(FTy);
1858 Value* Func = getVal(PFTy, ID);
1859 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
1860 return new CallInst(Func, &Args[0], Args.size());
1861 } else if (Name == "llvm.va_copy") {
1862 if (Args.size() != 2)
1863 error("Invalid prototype for " + Name + " prototype");
1864 Params.push_back(PtrTy);
1865 Params.push_back(PtrTy);
1866 const FunctionType *FTy =
1867 FunctionType::get(Type::VoidTy, Params, false);
1868 const PointerType *PFTy = PointerType::get(FTy);
1869 Value* Func = getVal(PFTy, ID);
1870 std::string InstName0(makeNameUnique("va0"));
1871 std::string InstName1(makeNameUnique("va1"));
1872 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1873 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1874 return new CallInst(Func, &Args[0], Args.size());
1875 }
Reid Spencer950bf602007-01-26 08:19:09 +00001876 }
1877 }
1878 return 0;
1879}
1880
1881const Type* upgradeGEPIndices(const Type* PTy,
1882 std::vector<ValueInfo> *Indices,
1883 std::vector<Value*> &VIndices,
1884 std::vector<Constant*> *CIndices = 0) {
1885 // Traverse the indices with a gep_type_iterator so we can build the list
1886 // of constant and value indices for use later. Also perform upgrades
1887 VIndices.clear();
1888 if (CIndices) CIndices->clear();
1889 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1890 VIndices.push_back((*Indices)[i].V);
1891 generic_gep_type_iterator<std::vector<Value*>::iterator>
1892 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1893 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1894 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1895 Value *Index = VIndices[i];
1896 if (CIndices && !isa<Constant>(Index))
1897 error("Indices to constant getelementptr must be constants");
1898 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1899 // struct indices to i32 struct indices with ZExt for compatibility.
1900 else if (isa<StructType>(*GTI)) { // Only change struct indices
1901 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1902 if (CUI->getType()->getBitWidth() == 8)
1903 Index =
1904 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1905 } else {
1906 // Make sure that unsigned SequentialType indices are zext'd to
1907 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1908 // all indices for SequentialType elements. We must retain the same
1909 // semantic (zext) for unsigned types.
1910 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencerbb1fd572007-03-21 17:15:50 +00001911 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001912 if (CIndices)
1913 Index = ConstantExpr::getCast(Instruction::ZExt,
1914 cast<Constant>(Index), Type::Int64Ty);
1915 else
1916 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001917 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001918 VIndices[i] = Index;
1919 }
Reid Spencer950bf602007-01-26 08:19:09 +00001920 }
1921 // Add to the CIndices list, if requested.
1922 if (CIndices)
1923 CIndices->push_back(cast<Constant>(Index));
1924 }
1925
1926 const Type *IdxTy =
Chris Lattner1bc3fa62007-02-12 22:58:38 +00001927 GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true);
Reid Spencer950bf602007-01-26 08:19:09 +00001928 if (!IdxTy)
1929 error("Index list invalid for constant getelementptr");
1930 return IdxTy;
1931}
1932
Reid Spencerb7046c72007-01-29 05:41:34 +00001933unsigned upgradeCallingConv(unsigned CC) {
1934 switch (CC) {
1935 case OldCallingConv::C : return CallingConv::C;
1936 case OldCallingConv::CSRet : return CallingConv::C;
1937 case OldCallingConv::Fast : return CallingConv::Fast;
1938 case OldCallingConv::Cold : return CallingConv::Cold;
1939 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1940 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1941 default:
1942 return CC;
1943 }
1944}
1945
Reid Spencer950bf602007-01-26 08:19:09 +00001946Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1947 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001948{
1949 Upgradelineno = 1;
1950 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001951 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001952 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001953 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001954 ObsoleteVarArgs = false;
1955 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001956
Reid Spencer950bf602007-01-26 08:19:09 +00001957 CurModule.CurrentModule = new Module(CurFilename);
1958
1959 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001960 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001961 if (ParserResult)
1962 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001963 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001964 return 0;
1965 }
1966
Reid Spencer950bf602007-01-26 08:19:09 +00001967 // Check to make sure that parsing produced a result
1968 if (!ParserResult) {
1969 std::cerr << "llvm-upgrade: no parse result.\n";
1970 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001971 }
1972
Reid Spencer950bf602007-01-26 08:19:09 +00001973 // Reset ParserResult variable while saving its value for the result.
1974 Module *Result = ParserResult;
1975 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001976
Reid Spencer950bf602007-01-26 08:19:09 +00001977 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001978 {
Reid Spencer950bf602007-01-26 08:19:09 +00001979 Function* F;
Reid Spencer688b0492007-02-05 21:19:13 +00001980 if ((F = Result->getFunction("llvm.va_start"))
Reid Spencer950bf602007-01-26 08:19:09 +00001981 && F->getFunctionType()->getNumParams() == 0)
1982 ObsoleteVarArgs = true;
Reid Spencer688b0492007-02-05 21:19:13 +00001983 if((F = Result->getFunction("llvm.va_copy"))
Reid Spencer950bf602007-01-26 08:19:09 +00001984 && F->getFunctionType()->getNumParams() == 1)
1985 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001986 }
Reid Spencer319a7302007-01-05 17:20:02 +00001987
Reid Spencer950bf602007-01-26 08:19:09 +00001988 if (ObsoleteVarArgs && NewVarArgs) {
1989 error("This file is corrupt: it uses both new and old style varargs");
1990 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001991 }
Reid Spencer319a7302007-01-05 17:20:02 +00001992
Reid Spencer950bf602007-01-26 08:19:09 +00001993 if(ObsoleteVarArgs) {
Reid Spencer688b0492007-02-05 21:19:13 +00001994 if(Function* F = Result->getFunction("llvm.va_start")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001995 if (F->arg_size() != 0) {
1996 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001997 return 0;
1998 }
Reid Spencer950bf602007-01-26 08:19:09 +00001999
2000 //foo = va_start()
2001 // ->
2002 //bar = alloca typeof(foo)
2003 //va_start(bar)
2004 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00002005
Reid Spencer950bf602007-01-26 08:19:09 +00002006 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2007 const Type* ArgTy = F->getFunctionType()->getReturnType();
2008 const Type* ArgTyPtr = PointerType::get(ArgTy);
2009 Function* NF = cast<Function>(Result->getOrInsertFunction(
2010 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
2011
2012 while (!F->use_empty()) {
2013 CallInst* CI = cast<CallInst>(F->use_back());
2014 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
2015 new CallInst(NF, bar, "", CI);
2016 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
2017 CI->replaceAllUsesWith(foo);
2018 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00002019 }
Reid Spencer950bf602007-01-26 08:19:09 +00002020 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00002021 }
Reid Spencer950bf602007-01-26 08:19:09 +00002022
Reid Spencer688b0492007-02-05 21:19:13 +00002023 if(Function* F = Result->getFunction("llvm.va_end")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002024 if(F->arg_size() != 1) {
2025 error("Obsolete va_end takes 1 argument");
2026 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00002027 }
Reid Spencerf8383de2007-01-06 06:04:32 +00002028
Reid Spencer950bf602007-01-26 08:19:09 +00002029 //vaend foo
2030 // ->
2031 //bar = alloca 1 of typeof(foo)
2032 //vaend bar
2033 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2034 const Type* ArgTy = F->getFunctionType()->getParamType(0);
2035 const Type* ArgTyPtr = PointerType::get(ArgTy);
2036 Function* NF = cast<Function>(Result->getOrInsertFunction(
2037 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00002038
Reid Spencer950bf602007-01-26 08:19:09 +00002039 while (!F->use_empty()) {
2040 CallInst* CI = cast<CallInst>(F->use_back());
2041 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
2042 new StoreInst(CI->getOperand(1), bar, CI);
2043 new CallInst(NF, bar, "", CI);
2044 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00002045 }
Reid Spencer950bf602007-01-26 08:19:09 +00002046 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00002047 }
Reid Spencer950bf602007-01-26 08:19:09 +00002048
Reid Spencer688b0492007-02-05 21:19:13 +00002049 if(Function* F = Result->getFunction("llvm.va_copy")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002050 if(F->arg_size() != 1) {
2051 error("Obsolete va_copy takes 1 argument");
2052 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00002053 }
Reid Spencer950bf602007-01-26 08:19:09 +00002054 //foo = vacopy(bar)
2055 // ->
2056 //a = alloca 1 of typeof(foo)
2057 //b = alloca 1 of typeof(foo)
2058 //store bar -> b
2059 //vacopy(a, b)
2060 //foo = load a
2061
2062 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2063 const Type* ArgTy = F->getFunctionType()->getReturnType();
2064 const Type* ArgTyPtr = PointerType::get(ArgTy);
2065 Function* NF = cast<Function>(Result->getOrInsertFunction(
2066 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00002067
Reid Spencer950bf602007-01-26 08:19:09 +00002068 while (!F->use_empty()) {
2069 CallInst* CI = cast<CallInst>(F->use_back());
2070 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
2071 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
2072 new StoreInst(CI->getOperand(1), b, CI);
2073 new CallInst(NF, a, b, "", CI);
2074 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
2075 CI->replaceAllUsesWith(foo);
2076 CI->getParent()->getInstList().erase(CI);
2077 }
2078 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00002079 }
2080 }
2081
Reid Spencer52402b02007-01-02 05:45:11 +00002082 return Result;
2083}
2084
Reid Spencer950bf602007-01-26 08:19:09 +00002085} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00002086
Reid Spencer950bf602007-01-26 08:19:09 +00002087using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00002088
2089
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002090
2091/* Enabling traces. */
2092#ifndef YYDEBUG
2093# define YYDEBUG 0
2094#endif
2095
2096/* Enabling verbose error messages. */
2097#ifdef YYERROR_VERBOSE
2098# undef YYERROR_VERBOSE
2099# define YYERROR_VERBOSE 1
2100#else
2101# define YYERROR_VERBOSE 0
2102#endif
2103
2104/* Enabling the token table. */
2105#ifndef YYTOKEN_TABLE
2106# define YYTOKEN_TABLE 0
2107#endif
2108
2109#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer8166a6c2007-04-02 02:08:35 +00002110#line 1731 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002111typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00002112 llvm::Module *ModuleVal;
2113 llvm::Function *FunctionVal;
2114 std::pair<llvm::PATypeInfo, char*> *ArgVal;
2115 llvm::BasicBlock *BasicBlockVal;
Reid Spencerbb1fd572007-03-21 17:15:50 +00002116 llvm::TermInstInfo TermInstVal;
Reid Spencer950bf602007-01-26 08:19:09 +00002117 llvm::InstrInfo InstVal;
2118 llvm::ConstInfo ConstVal;
2119 llvm::ValueInfo ValueVal;
2120 llvm::PATypeInfo TypeVal;
2121 llvm::TypeInfo PrimType;
2122 llvm::PHIListInfo PHIList;
2123 std::list<llvm::PATypeInfo> *TypeList;
2124 std::vector<llvm::ValueInfo> *ValueList;
2125 std::vector<llvm::ConstInfo> *ConstVector;
2126
2127
2128 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
2129 // Represent the RHS of PHI node
2130 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
2131
2132 llvm::GlobalValue::LinkageTypes Linkage;
2133 int64_t SInt64Val;
2134 uint64_t UInt64Val;
2135 int SIntVal;
2136 unsigned UIntVal;
2137 double FPVal;
2138 bool BoolVal;
2139
2140 char *StrVal; // This memory is strdup'd!
2141 llvm::ValID ValIDVal; // strdup'd memory maybe!
2142
2143 llvm::BinaryOps BinaryOpVal;
2144 llvm::TermOps TermOpVal;
2145 llvm::MemoryOps MemOpVal;
2146 llvm::OtherOps OtherOpVal;
2147 llvm::CastOps CastOpVal;
2148 llvm::ICmpInst::Predicate IPred;
2149 llvm::FCmpInst::Predicate FPred;
2150 llvm::Module::Endianness Endianness;
Chris Lattnercf3d0612007-02-13 06:04:17 +00002151} YYSTYPE;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002152/* Line 196 of yacc.c. */
Reid Spencer8166a6c2007-04-02 02:08:35 +00002153#line 2154 "UpgradeParser.tab.c"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002154# define yystype YYSTYPE /* obsolescent; will be withdrawn */
2155# define YYSTYPE_IS_DECLARED 1
2156# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00002157#endif
2158
Reid Spencer950bf602007-01-26 08:19:09 +00002159
Reid Spencere7c3c602006-11-30 06:36:44 +00002160
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002161/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002162
2163
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002164/* Line 219 of yacc.c. */
Reid Spencer8166a6c2007-04-02 02:08:35 +00002165#line 2166 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00002166
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002167#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2168# define YYSIZE_T __SIZE_TYPE__
2169#endif
2170#if ! defined (YYSIZE_T) && defined (size_t)
2171# define YYSIZE_T size_t
2172#endif
2173#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
2174# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2175# define YYSIZE_T size_t
2176#endif
2177#if ! defined (YYSIZE_T)
2178# define YYSIZE_T unsigned int
2179#endif
Chris Lattnercf3d0612007-02-13 06:04:17 +00002180
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002181#ifndef YY_
2182# if YYENABLE_NLS
2183# if ENABLE_NLS
2184# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
2185# define YY_(msgid) dgettext ("bison-runtime", msgid)
2186# endif
2187# endif
2188# ifndef YY_
2189# define YY_(msgid) msgid
2190# endif
2191#endif
2192
2193#if ! defined (yyoverflow) || YYERROR_VERBOSE
2194
2195/* The parser invokes alloca or malloc; define the necessary symbols. */
2196
2197# ifdef YYSTACK_USE_ALLOCA
2198# if YYSTACK_USE_ALLOCA
2199# ifdef __GNUC__
2200# define YYSTACK_ALLOC __builtin_alloca
2201# else
2202# define YYSTACK_ALLOC alloca
2203# if defined (__STDC__) || defined (__cplusplus)
2204# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2205# define YYINCLUDED_STDLIB_H
2206# endif
2207# endif
2208# endif
2209# endif
2210
2211# ifdef YYSTACK_ALLOC
2212 /* Pacify GCC's `empty if-body' warning. */
2213# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
2214# ifndef YYSTACK_ALLOC_MAXIMUM
2215 /* The OS might guarantee only one guard page at the bottom of the stack,
2216 and a page size can be as small as 4096 bytes. So we cannot safely
2217 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
2218 to allow for a few compiler-allocated temporary stack slots. */
2219# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
2220# endif
2221# else
2222# define YYSTACK_ALLOC YYMALLOC
2223# define YYSTACK_FREE YYFREE
2224# ifndef YYSTACK_ALLOC_MAXIMUM
2225# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
2226# endif
2227# ifdef __cplusplus
2228extern "C" {
2229# endif
2230# ifndef YYMALLOC
2231# define YYMALLOC malloc
2232# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
2233 && (defined (__STDC__) || defined (__cplusplus)))
2234void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
2235# endif
2236# endif
2237# ifndef YYFREE
2238# define YYFREE free
2239# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
2240 && (defined (__STDC__) || defined (__cplusplus)))
2241void free (void *); /* INFRINGES ON USER NAME SPACE */
2242# endif
2243# endif
2244# ifdef __cplusplus
2245}
2246# endif
2247# endif
2248#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
2249
2250
2251#if (! defined (yyoverflow) \
2252 && (! defined (__cplusplus) \
2253 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
2254
2255/* A type that is properly aligned for any stack member. */
2256union yyalloc
2257{
2258 short int yyss;
2259 YYSTYPE yyvs;
2260 };
2261
2262/* The size of the maximum gap between one aligned stack and the next. */
2263# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2264
2265/* The size of an array large to enough to hold all stacks, each with
2266 N elements. */
2267# define YYSTACK_BYTES(N) \
2268 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
2269 + YYSTACK_GAP_MAXIMUM)
2270
2271/* Copy COUNT objects from FROM to TO. The source and destination do
2272 not overlap. */
2273# ifndef YYCOPY
2274# if defined (__GNUC__) && 1 < __GNUC__
2275# define YYCOPY(To, From, Count) \
2276 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2277# else
2278# define YYCOPY(To, From, Count) \
2279 do \
2280 { \
2281 YYSIZE_T yyi; \
2282 for (yyi = 0; yyi < (Count); yyi++) \
2283 (To)[yyi] = (From)[yyi]; \
2284 } \
2285 while (0)
2286# endif
2287# endif
2288
2289/* Relocate STACK from its old location to the new one. The
2290 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2291 elements in the stack, and YYPTR gives the new location of the
2292 stack. Advance YYPTR to a properly aligned location for the next
2293 stack. */
2294# define YYSTACK_RELOCATE(Stack) \
2295 do \
2296 { \
2297 YYSIZE_T yynewbytes; \
2298 YYCOPY (&yyptr->Stack, Stack, yysize); \
2299 Stack = &yyptr->Stack; \
2300 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2301 yyptr += yynewbytes / sizeof (*yyptr); \
2302 } \
2303 while (0)
Chris Lattnercf3d0612007-02-13 06:04:17 +00002304
Reid Spencere7c3c602006-11-30 06:36:44 +00002305#endif
2306
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002307#if defined (__STDC__) || defined (__cplusplus)
2308 typedef signed char yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002309#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002310 typedef short int yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002311#endif
2312
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002313/* YYFINAL -- State number of the termination state. */
2314#define YYFINAL 4
2315/* YYLAST -- Last index in YYTABLE. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002316#define YYLAST 1630
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002317
2318/* YYNTOKENS -- Number of terminals. */
2319#define YYNTOKENS 166
2320/* YYNNTS -- Number of nonterminals. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002321#define YYNNTS 81
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002322/* YYNRULES -- Number of rules. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002323#define YYNRULES 310
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002324/* YYNRULES -- Number of states. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002325#define YYNSTATES 606
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002326
2327/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2328#define YYUNDEFTOK 2
2329#define YYMAXUTOK 406
2330
2331#define YYTRANSLATE(YYX) \
2332 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2333
2334/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2335static const unsigned char yytranslate[] =
2336{
2337 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2338 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2339 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2340 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2341 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2342 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2343 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2344 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2345 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2346 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2347 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2348 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2349 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2350 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2351 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2352 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2353 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2354 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2355 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2356 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2357 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2358 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2359 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2360 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2361 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2362 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2363 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2364 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2365 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2366 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2367 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2368 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2369 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2370 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2371 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2372 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2373 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2374 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2375 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2376 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2377 145, 146, 147, 148, 149, 150, 151
2378};
2379
2380#if YYDEBUG
2381/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2382 YYRHS. */
2383static const unsigned short int yyprhs[] =
2384{
2385 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2386 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2387 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2388 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2389 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2390 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2391 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2392 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2393 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2394 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2395 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2396 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2397 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2398 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2399 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2400 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2401 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2402 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2403 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2404 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2405 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2406 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002407 622, 623, 632, 634, 636, 637, 642, 644, 646, 649,
2408 650, 652, 654, 655, 656, 662, 663, 665, 667, 669,
2409 671, 673, 675, 677, 679, 681, 685, 687, 693, 695,
2410 697, 699, 701, 704, 707, 710, 714, 717, 718, 720,
2411 722, 724, 727, 730, 734, 744, 754, 763, 777, 779,
2412 781, 788, 794, 797, 804, 812, 814, 818, 820, 821,
2413 824, 826, 832, 838, 844, 851, 858, 861, 866, 871,
2414 878, 883, 888, 893, 898, 905, 912, 915, 923, 925,
2415 928, 929, 931, 932, 936, 943, 947, 954, 957, 962,
2416 969
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002417};
2418
2419/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2420static const short int yyrhs[] =
2421{
2422 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2423 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2424 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2425 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2426 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2427 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2428 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2429 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2430 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2431 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2432 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2433 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2434 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2435 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2436 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2437 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2438 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2439 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2440 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2441 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2442 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2443 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2444 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2445 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2446 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002447 -1, 19, -1, 21, -1, 192, -1, 48, -1, 229,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002448 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2449 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2450 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2451 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2452 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2453 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2454 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2455 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2456 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2457 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002458 191, 39, -1, 191, 229, -1, 191, 197, -1, 191,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002459 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2460 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002461 36, 191, 156, -1, 110, 155, 196, 244, 156, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002462 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2463 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2464 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2465 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2466 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2467 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2468 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2469 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2470 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002471 201, 222, -1, 201, 224, -1, 201, 62, 61, 207,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002472 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002473 -1, 202, 224, -1, 202, 62, 61, 207, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002474 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2475 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2476 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2477 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2478 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2479 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2480 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2481 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2482 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2483 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2484 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002485 183, -1, 29, -1, 162, -1, -1, 181, 220, 217,
2486 218, -1, 30, -1, 163, -1, 232, 221, -1, -1,
2487 45, -1, 47, -1, -1, -1, 31, 225, 223, 226,
2488 217, -1, -1, 63, -1, 3, -1, 4, -1, 7,
2489 -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
2490 -1, 160, 198, 161, -1, 197, -1, 61, 227, 24,
2491 153, 24, -1, 167, -1, 212, -1, 229, -1, 228,
2492 -1, 191, 230, -1, 232, 233, -1, 219, 233, -1,
2493 234, 180, 236, -1, 234, 238, -1, -1, 23, -1,
2494 77, -1, 78, -1, 72, 231, -1, 72, 8, -1,
2495 73, 21, 230, -1, 73, 9, 230, 153, 21, 230,
2496 153, 21, 230, -1, 74, 178, 230, 153, 21, 230,
2497 157, 237, 159, -1, 74, 178, 230, 153, 21, 230,
2498 157, 159, -1, 75, 182, 189, 230, 155, 241, 156,
2499 36, 21, 230, 235, 21, 230, -1, 235, -1, 76,
2500 -1, 237, 178, 228, 153, 21, 230, -1, 178, 228,
2501 153, 21, 230, -1, 180, 243, -1, 191, 157, 230,
2502 153, 230, 159, -1, 239, 153, 157, 230, 153, 230,
2503 159, -1, 231, -1, 240, 153, 231, -1, 240, -1,
2504 -1, 60, 59, -1, 59, -1, 169, 191, 230, 153,
2505 230, -1, 170, 191, 230, 153, 230, -1, 171, 191,
2506 230, 153, 230, -1, 103, 172, 191, 230, 153, 230,
2507 -1, 104, 173, 191, 230, 153, 230, -1, 49, 231,
2508 -1, 174, 231, 153, 231, -1, 175, 231, 36, 191,
2509 -1, 112, 231, 153, 231, 153, 231, -1, 113, 231,
2510 153, 191, -1, 117, 231, 153, 191, -1, 118, 231,
2511 153, 191, -1, 114, 231, 153, 231, -1, 115, 231,
2512 153, 231, 153, 231, -1, 116, 231, 153, 231, 153,
2513 231, -1, 111, 239, -1, 242, 182, 189, 230, 155,
2514 241, 156, -1, 246, -1, 153, 240, -1, -1, 35,
2515 -1, -1, 105, 191, 184, -1, 105, 191, 153, 15,
2516 230, 184, -1, 106, 191, 184, -1, 106, 191, 153,
2517 15, 230, 184, -1, 107, 231, -1, 245, 108, 191,
2518 230, -1, 245, 109, 231, 153, 191, 230, -1, 110,
2519 191, 230, 244, -1
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002520};
2521
2522/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2523static const unsigned short int yyrline[] =
2524{
Reid Spencer8166a6c2007-04-02 02:08:35 +00002525 0, 1871, 1871, 1872, 1880, 1881, 1891, 1891, 1891, 1891,
2526 1891, 1891, 1891, 1891, 1891, 1891, 1891, 1895, 1895, 1895,
2527 1899, 1899, 1899, 1899, 1899, 1899, 1903, 1903, 1904, 1904,
2528 1905, 1905, 1906, 1906, 1907, 1907, 1911, 1911, 1912, 1912,
2529 1913, 1913, 1914, 1914, 1915, 1915, 1916, 1916, 1917, 1917,
2530 1918, 1919, 1922, 1922, 1922, 1922, 1926, 1926, 1926, 1926,
2531 1926, 1926, 1926, 1927, 1927, 1927, 1927, 1927, 1927, 1933,
2532 1933, 1933, 1933, 1937, 1937, 1937, 1937, 1941, 1941, 1945,
2533 1945, 1950, 1953, 1958, 1959, 1960, 1961, 1962, 1963, 1964,
2534 1965, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1986,
2535 1987, 1995, 1996, 2004, 2013, 2014, 2021, 2022, 2026, 2030,
2536 2046, 2047, 2054, 2055, 2062, 2070, 2070, 2070, 2070, 2070,
2537 2070, 2070, 2071, 2071, 2071, 2071, 2071, 2076, 2080, 2084,
2538 2089, 2098, 2116, 2122, 2135, 2146, 2150, 2163, 2167, 2181,
2539 2185, 2192, 2193, 2199, 2206, 2218, 2248, 2261, 2284, 2312,
2540 2334, 2345, 2367, 2378, 2387, 2392, 2451, 2458, 2466, 2473,
2541 2480, 2484, 2488, 2497, 2512, 2525, 2534, 2562, 2575, 2584,
2542 2590, 2596, 2607, 2613, 2619, 2630, 2631, 2640, 2641, 2653,
2543 2662, 2663, 2664, 2665, 2666, 2682, 2702, 2704, 2706, 2706,
2544 2713, 2713, 2721, 2721, 2729, 2729, 2738, 2740, 2742, 2747,
2545 2761, 2762, 2766, 2769, 2777, 2781, 2788, 2792, 2796, 2800,
2546 2808, 2808, 2812, 2813, 2817, 2825, 2830, 2838, 2839, 2846,
2547 2853, 2857, 3038, 3038, 3042, 3042, 3052, 3052, 3056, 3061,
2548 3062, 3063, 3067, 3068, 3067, 3080, 3081, 3086, 3087, 3088,
2549 3089, 3093, 3097, 3098, 3099, 3100, 3121, 3125, 3139, 3140,
2550 3145, 3145, 3153, 3163, 3166, 3175, 3186, 3191, 3200, 3211,
Reid Spencera3b12dd2007-04-07 16:14:01 +00002551 3211, 3214, 3218, 3222, 3227, 3237, 3255, 3264, 3332, 3336,
2552 3343, 3355, 3370, 3400, 3410, 3420, 3424, 3431, 3432, 3436,
2553 3439, 3445, 3464, 3482, 3498, 3512, 3526, 3537, 3555, 3564,
2554 3573, 3580, 3601, 3625, 3631, 3637, 3643, 3659, 3746, 3754,
2555 3755, 3759, 3760, 3764, 3770, 3777, 3783, 3790, 3797, 3810,
2556 3836
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002557};
2558#endif
2559
2560#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2561/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2562 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2563static const char *const yytname[] =
2564{
2565 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2566 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2567 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2568 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2569 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2570 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2571 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2572 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2573 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2574 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2575 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2576 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2577 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2578 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2579 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2580 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2581 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2582 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2583 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2584 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2585 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2586 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2587 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2588 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2589 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2590 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2591 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2592 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2593 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2594 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2595 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2596 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2597 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2598 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
Reid Spencerd2920cd2007-03-21 17:27:53 +00002599 "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7",
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002600 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2601 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2602 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2603 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2604 "OptVolatile", "MemoryInst", 0
2605};
2606#endif
2607
2608# ifdef YYPRINT
2609/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2610 token YYLEX-NUM. */
2611static const unsigned short int yytoknum[] =
2612{
2613 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2614 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2615 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2616 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2617 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2618 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2619 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2620 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2621 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2622 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2623 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2624 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2625 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2626 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2627 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2628 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2629 60, 62, 123, 125, 42, 99
2630};
2631# endif
2632
2633/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2634static const unsigned char yyr1[] =
2635{
2636 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2637 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2638 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2639 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2640 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2641 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2642 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2643 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2644 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2645 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2646 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2647 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2648 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2649 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2650 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2651 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2652 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2653 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2654 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2655 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2656 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2657 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002658 216, 217, 218, 218, 220, 219, 221, 221, 222, 223,
2659 223, 223, 225, 226, 224, 227, 227, 228, 228, 228,
2660 228, 228, 228, 228, 228, 228, 228, 228, 229, 229,
2661 230, 230, 231, 232, 232, 233, 234, 234, 234, 235,
2662 235, 236, 236, 236, 236, 236, 236, 236, 236, 236,
2663 237, 237, 238, 239, 239, 240, 240, 241, 241, 242,
2664 242, 243, 243, 243, 243, 243, 243, 243, 243, 243,
2665 243, 243, 243, 243, 243, 243, 243, 243, 243, 244,
2666 244, 245, 245, 246, 246, 246, 246, 246, 246, 246,
2667 246
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002668};
2669
2670/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2671static const unsigned char yyr2[] =
2672{
2673 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2674 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2675 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2676 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2677 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2678 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2679 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2680 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2681 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2682 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2683 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2684 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2685 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2686 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2687 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2688 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2689 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2690 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2691 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2692 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2693 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2694 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002695 0, 8, 1, 1, 0, 4, 1, 1, 2, 0,
2696 1, 1, 0, 0, 5, 0, 1, 1, 1, 1,
2697 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
2698 1, 1, 2, 2, 2, 3, 2, 0, 1, 1,
2699 1, 2, 2, 3, 9, 9, 8, 13, 1, 1,
2700 6, 5, 2, 6, 7, 1, 3, 1, 0, 2,
2701 1, 5, 5, 5, 6, 6, 2, 4, 4, 6,
2702 4, 4, 4, 4, 6, 6, 2, 7, 1, 2,
2703 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
2704 4
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002705};
2706
2707/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2708 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2709 means the default is an error. */
2710static const unsigned short int yydefact[] =
2711{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002712 198, 0, 90, 184, 1, 183, 232, 83, 84, 85,
2713 86, 87, 88, 89, 0, 224, 257, 180, 181, 257,
2714 210, 211, 0, 0, 0, 90, 0, 186, 229, 0,
2715 91, 258, 254, 82, 226, 227, 228, 253, 0, 0,
2716 0, 0, 196, 0, 0, 0, 0, 0, 0, 0,
2717 81, 230, 231, 233, 199, 182, 0, 92, 93, 94,
2718 95, 96, 97, 0, 0, 302, 256, 0, 0, 0,
2719 0, 209, 197, 187, 2, 3, 111, 115, 116, 117,
2720 118, 119, 120, 121, 122, 123, 124, 125, 126, 128,
2721 0, 0, 0, 0, 248, 185, 0, 110, 127, 114,
2722 249, 129, 177, 178, 0, 0, 0, 0, 91, 98,
2723 0, 222, 223, 225, 301, 0, 280, 0, 0, 0,
2724 0, 91, 269, 259, 260, 6, 7, 8, 9, 10,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002725 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2726 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2727 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2728 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2729 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002730 0, 268, 255, 91, 272, 0, 298, 204, 201, 200,
2731 202, 203, 205, 208, 0, 130, 0, 0, 0, 113,
2732 135, 139, 0, 144, 138, 192, 194, 190, 115, 116,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002733 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002734 0, 0, 0, 188, 234, 0, 0, 286, 279, 262,
2735 261, 0, 0, 72, 76, 71, 75, 70, 74, 69,
2736 73, 77, 78, 0, 0, 26, 27, 28, 29, 30,
2737 31, 32, 33, 34, 35, 0, 50, 51, 46, 47,
2738 48, 49, 36, 37, 38, 39, 40, 41, 42, 43,
2739 44, 45, 0, 101, 101, 307, 0, 0, 296, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002740 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002741 0, 0, 0, 0, 0, 206, 0, 0, 0, 0,
2742 0, 134, 143, 141, 0, 106, 106, 106, 160, 161,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002743 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2744 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002745 0, 0, 0, 0, 156, 155, 106, 220, 237, 238,
2746 239, 244, 240, 241, 242, 243, 235, 0, 246, 251,
2747 250, 252, 0, 263, 0, 0, 0, 0, 0, 303,
2748 0, 305, 300, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002749 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002750 207, 112, 112, 137, 0, 140, 0, 131, 0, 193,
2751 195, 191, 0, 0, 0, 0, 0, 0, 0, 146,
2752 176, 0, 0, 0, 150, 0, 147, 0, 0, 0,
2753 0, 0, 189, 219, 213, 216, 217, 0, 236, 0,
2754 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2755 310, 0, 0, 0, 290, 293, 0, 0, 291, 292,
2756 0, 0, 0, 287, 288, 0, 308, 0, 132, 133,
2757 136, 142, 0, 0, 108, 106, 0, 0, 300, 0,
2758 0, 0, 0, 0, 145, 135, 114, 0, 148, 149,
2759 0, 0, 0, 0, 0, 212, 214, 0, 104, 0,
2760 245, 0, 0, 278, 0, 0, 101, 102, 101, 275,
2761 299, 0, 0, 0, 0, 0, 281, 282, 283, 278,
2762 0, 103, 109, 107, 0, 0, 0, 0, 0, 0,
2763 0, 175, 152, 0, 0, 0, 0, 0, 0, 218,
2764 215, 105, 99, 0, 0, 0, 277, 0, 284, 285,
2765 0, 304, 306, 0, 0, 0, 289, 294, 295, 0,
2766 309, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2767 0, 0, 0, 0, 0, 221, 247, 0, 0, 0,
2768 276, 273, 0, 297, 0, 0, 0, 172, 0, 0,
2769 166, 167, 168, 171, 163, 100, 0, 266, 0, 0,
2770 0, 274, 169, 170, 0, 0, 0, 264, 0, 265,
2771 0, 0, 165, 173, 174, 0, 0, 0, 0, 0,
2772 0, 271, 0, 0, 270, 267
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002773};
2774
2775/* YYDEFGOTO[NTERM-NUM]. */
2776static const short int yydefgoto[] =
2777{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002778 -1, 94, 312, 329, 330, 331, 255, 272, 332, 333,
2779 219, 220, 243, 221, 25, 15, 63, 555, 359, 454,
2780 522, 389, 455, 95, 96, 222, 98, 99, 202, 304,
2781 400, 348, 401, 104, 1, 2, 3, 336, 307, 305,
2782 306, 55, 190, 42, 72, 194, 100, 476, 415, 416,
2783 417, 64, 113, 16, 30, 36, 17, 53, 18, 28,
2784 108, 419, 349, 101, 351, 489, 19, 32, 33, 181,
2785 182, 579, 66, 278, 526, 527, 183, 184, 430, 185,
2786 186
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002787};
2788
2789/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2790 STATE-NUM. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002791#define YYPACT_NINF -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002792static const short int yypact[] =
2793{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002794 -542, 13, 162, 567, -542, -542, -542, -542, -542, -542,
2795 -542, -542, -542, -542, 83, -542, 19, -542, -542, -14,
2796 -542, -542, 50, -87, 87, 233, 27, -542, 123, 141,
2797 175, -542, -542, 98, -542, -542, -542, -542, 33, 40,
2798 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156,
2799 -542, -542, -542, -542, -542, -542, 221, -542, -542, -542,
2800 -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226,
2801 227, 235, -542, -542, -542, -542, 81, -542, -542, -542,
2802 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2803 256, 257, 4, 15, -542, -542, 108, -542, -542, 12,
2804 -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542,
2805 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116,
2806 479, 175, -542, -542, -542, -542, -542, -542, -542, -542,
2807 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2808 -542, -542, -542, -542, -542, -542, -542, -542, -542, 355,
2809 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306,
2810 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542,
2811 -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306,
2812 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542,
2813 -542, -542, -542, -542, -13, -542, 110, 111, 75, -542,
2814 -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208,
2815 266, 210, 267, 212, 268, 230, 277, 275, 278, 246,
2816 280, 279, 566, -542, -542, 136, 766, -542, -542, 81,
2817 -542, 766, 766, -542, -542, -542, -542, -542, -542, -542,
2818 -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542,
2819 -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542,
2820 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2821 -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147,
2822 148, 149, 151, 152, 158, 160, 766, 766, 766, 161,
2823 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27,
2824 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542,
2825 -542, -542, -542, -542, -542, -542, -542, -542, 355, 429,
2826 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184,
2827 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542,
2828 -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542,
2829 -542, -542, 193, -542, 194, 766, 766, 766, 7, -542,
2830 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306,
2831 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207,
2832 -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542,
2833 -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542,
2834 -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326,
2835 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337,
2836 -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306,
2837 -542, 223, 766, 224, -542, -542, 225, 234, -542, -542,
2838 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542,
2839 -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236,
2840 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542,
2841 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252,
2842 -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542,
2843 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306,
2844 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326,
2845 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542,
2846 -542, -542, 368, 402, 274, 276, 259, 287, -542, -542,
2847 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290,
2848 -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296,
2849 297, 299, 302, 303, 430, -542, -542, 414, 41, 425,
2850 -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326,
2851 -542, -542, -542, -542, -542, -542, 766, -542, 893, 144,
2852 448, -542, -542, -542, 314, 315, 316, -542, 331, -542,
2853 893, 766, -542, -542, -542, 464, 334, 180, 766, 481,
2854 482, -542, 766, 766, -542, -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002855};
2856
2857/* YYPGOTO[NTERM-NUM]. */
2858static const short int yypgoto[] =
2859{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002860 -542, -542, -542, 435, 439, 441, 191, 197, 442, 445,
2861 -119, -116, -541, -542, 478, 489, -107, -542, -267, 37,
2862 -542, -238, -542, -60, -542, -45, -542, -74, -51, -542,
2863 -101, 300, -252, 134, -542, -542, -542, -542, -542, -542,
2864 -542, 473, -542, -542, -542, -542, 8, -542, 46, -542,
2865 -542, 410, -542, -542, -542, -542, -542, -542, 518, -542,
2866 -542, -542, -528, 142, -90, -113, -542, 505, -542, -72,
2867 -542, -542, -542, -542, 97, 28, -542, -542, 70, -542,
2868 -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002869};
2870
2871/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2872 positive, shift that token. If negative, reduce the rule which
2873 number is the opposite. If zero, do what YYDEFACT says.
2874 If YYTABLE_NINF, syntax error. */
2875#define YYTABLE_NINF -180
2876static const short int yytable[] =
2877{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002878 97, 241, 227, 110, 242, 230, 223, 361, 197, 31,
2879 111, 26, 449, 4, 244, 204, 34, 578, 97, 201,
2880 74, 75, 426, 199, 77, 78, 79, 80, 81, 82,
2881 83, 84, 85, 86, 87, 428, 88, 20, 590, 21,
2882 275, 26, 31, 279, 280, 281, 282, 283, 284, 285,
2883 588, 233, 234, 235, 236, 237, 238, 239, 240, 205,
2884 206, 207, 596, 89, 427, 43, 289, 290, 390, 391,
2885 226, 463, 300, 226, 403, 405, 291, 427, 452, 468,
2886 74, 75, 301, 199, 77, 78, 79, 80, 81, 82,
2887 83, 84, 85, 86, 87, 420, 88, 20, 412, 21,
2888 448, 453, 38, 39, 40, 204, 273, 274, 226, 276,
2889 277, 226, 226, 226, 226, 226, 226, 226, 225, 463,
2890 20, 41, 21, 89, 201, 231, 300, 480, -139, 201,
2891 -112, 286, 287, 288, 226, 226, 384, 232, -139, 204,
2892 294, 352, 353, 112, 29, 463, 295, 299, 44, 35,
2893 467, 464, 303, 354, 233, 234, 235, 236, 237, 238,
2894 239, 240, -179, 463, 463, 54, 198, -112, 51, 90,
2895 52, 71, 91, 469, 513, 92, 204, 93, 200, 50,
2896 379, 105, 106, 107, 355, 67, 362, 5, 102, 103,
2897 188, 189, 68, 6, 292, 293, 372, 373, 374, 97,
2898 577, 308, 309, 7, 8, 9, 10, 11, 12, 13,
2899 356, -72, -72, -71, -71, -70, -70, 503, 69, 531,
2900 70, 532, 381, 382, 14, 109, 385, 357, 187, 90,
2901 191, 377, 91, -69, -69, 92, -113, 93, 298, 56,
2902 57, 58, 59, 60, 61, 62, 97, 378, 226, 310,
2903 311, 192, 433, 45, 435, 436, 437, 123, 124, 193,
2904 195, 196, 443, 203, 228, 423, 424, 425, 296, 297,
2905 -76, -75, -74, 431, 7, 8, 9, 10, 46, 12,
2906 47, -73, -79, 48, 313, -80, 314, 445, 446, 363,
2907 358, 337, 414, 458, 459, 460, 461, 462, 360, 364,
2908 365, 366, 367, 589, 368, 369, 470, 471, 472, 473,
2909 474, 370, 385, 371, 375, 380, 383, 376, 386, 387,
2910 226, 434, 226, 226, 226, 438, 439, 394, 466, 388,
2911 226, 444, 395, 396, 397, 406, 486, 398, 488, 407,
2912 408, 409, 492, 410, 411, 418, 421, 422, 429, 432,
2913 496, 497, 498, 440, 441, 504, 505, 450, 456, 442,
2914 447, 479, 511, 481, 335, 478, 457, 477, 350, 482,
2915 483, 484, 485, 350, 350, 487, 491, 493, 494, 502,
2916 536, 537, 538, 499, 226, 350, 501, 495, 518, 507,
2917 508, 524, 525, 509, 528, 529, 510, 514, 515, 512,
2918 516, 534, 500, 517, 452, 523, 544, 545, 546, 547,
2919 540, 530, 533, 549, 550, 551, 552, 535, 350, 543,
2920 560, 548, 475, 541, 542, 554, 556, 557, 350, 350,
2921 350, 427, 414, 558, 575, 576, 566, 568, 226, 241,
2922 564, 565, 242, 559, 561, 562, 563, 569, 226, 226,
2923 226, 567, 570, 571, 226, 572, 256, 257, 573, 574,
2924 241, 580, 582, 242, 581, 584, 583, 585, 586, 591,
2925 592, 593, 594, 553, 245, 246, 247, 248, 249, 250,
2926 251, 252, 253, 254, 595, 598, 587, 599, 226, 233,
2927 234, 235, 236, 237, 238, 239, 240, 350, 350, 350,
2928 176, 597, 602, 603, 177, 350, 178, 179, 601, 392,
2929 180, 65, 604, 605, 49, 521, 393, 73, 224, 350,
2930 350, 27, 334, 520, 37, 600, 490, 539, 506, 0,
2931 0, 0, 0, 0, 74, 75, 0, 199, 208, 209,
2932 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2933 88, 20, 0, 21, 258, 259, 260, 261, 262, 263,
2934 264, 265, 266, 267, 268, 269, 270, 271, 350, 0,
2935 350, 74, 75, 0, 350, 0, 0, 89, 0, 0,
2936 0, 0, 350, 350, 350, 0, 0, -82, 20, 20,
2937 21, 21, 315, 0, 0, 0, 0, 0, 6, -82,
2938 -82, 0, 0, 0, 316, 317, 0, 0, -82, -82,
2939 -82, -82, -82, -82, -82, 0, 0, -82, 22, 0,
2940 0, 0, 0, 350, 350, 23, 350, 350, 0, 24,
2941 0, 0, 0, 350, 0, 0, 0, 0, 0, 0,
2942 0, 0, 350, 0, 0, 125, 126, 127, 128, 129,
2943 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2944 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
2945 319, 0, 0, 0, 0, 0, 320, 350, 321, 0,
2946 322, 323, 324, 90, 0, 0, 91, 0, 0, 92,
2947 0, 93, 404, 0, 0, 0, 0, 0, 0, 0,
2948 0, 0, 0, 0, 0, 163, 164, 165, 166, 167,
2949 168, 169, 170, 171, 172, 173, 174, 175, 350, 0,
2950 0, 0, 0, 325, 0, 0, 326, 0, 327, 0,
2951 0, 328, 0, 350, 0, 0, 0, 0, 0, 0,
2952 350, 0, 0, 0, 350, 350, 74, 75, 0, 199,
2953 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
2954 218, 0, 88, 20, 0, 21, 0, 0, 0, 338,
2955 339, 74, 75, 340, 0, 0, 0, 0, 0, 0,
2956 0, 0, 0, 0, 0, 0, 0, 0, 20, 89,
2957 21, 0, 341, 342, 343, 0, 0, 0, 0, 0,
2958 0, 0, 0, 0, 344, 345, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002959 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002960 0, 0, 0, 0, 0, 0, 0, 346, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002961 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002962 0, 0, 0, 0, 0, 125, 126, 127, 128, 129,
2963 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2964 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002965 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
2966 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002967 0, 0, 0, 0, 0, 90, 338, 339, 91, 0,
2968 340, 92, 0, 93, 465, 163, 164, 165, 166, 167,
2969 168, 169, 170, 171, 172, 173, 174, 175, 0, 341,
2970 342, 343, 0, 0, 0, 0, 347, 0, 0, 0,
2971 0, 344, 345, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002972 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002973 0, 0, 0, 0, 346, 0, 0, 0, 0, 0,
2974 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2975 0, 0, 125, 126, 127, 128, 129, 130, 131, 132,
2976 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
2977 143, 144, 145, 146, 147, 148, 318, 319, 0, 0,
2978 0, 0, 0, 320, 0, 321, 0, 322, 323, 324,
2979 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2980 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2981 0, 0, 163, 164, 165, 166, 167, 168, 169, 170,
2982 171, 172, 173, 174, 175, 0, 0, 0, 0, 0,
2983 0, 74, 75, 347, 199, 77, 78, 79, 80, 81,
2984 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
2985 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2986 0, 0, 0, 302, 0, 0, 0, 0, 0, 0,
2987 0, 0, 74, 75, 89, 199, 208, 209, 210, 211,
2988 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
2989 0, 21, 74, 75, 0, 199, 77, 78, 79, 80,
2990 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
2991 0, 21, 0, 0, 0, 89, 0, 0, 0, 0,
2992 0, 0, 0, 0, 413, 0, 0, 0, 0, 0,
2993 0, 0, 0, 74, 75, 89, 199, 77, 78, 79,
2994 80, 81, 82, 83, 84, 85, 86, 87, 0, 88,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002995 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002996 0, 0, 0, 0, 0, 451, 0, 0, 0, 0,
2997 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
2998 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
2999 74, 75, 0, 199, 77, 78, 79, 80, 81, 82,
3000 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003001 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003002 0, 90, 519, 0, 91, 0, 399, 92, 0, 93,
3003 0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
3004 0, 90, 0, 0, 91, 0, 0, 92, 0, 93,
3005 74, 75, 0, 76, 77, 78, 79, 80, 81, 82,
3006 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
3007 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3008 0, 0, 90, 0, 0, 91, 0, 0, 92, 0,
3009 93, 74, 75, 89, 199, 77, 78, 79, 80, 81,
3010 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
3011 21, 74, 75, 0, 199, 208, 209, 210, 211, 212,
3012 213, 214, 215, 216, 217, 218, 0, 88, 20, 0,
3013 21, 0, 0, 0, 89, 0, 0, 0, 0, 90,
3014 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3015 0, 0, 74, 75, 89, 229, 77, 78, 79, 80,
3016 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3017 0, 21, 74, 75, 0, 199, 208, 209, 210, 211,
3018 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3019 0, 21, 0, 0, 0, 89, 0, 0, 0, 90,
3020 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3021 0, 0, 0, 0, 0, 89, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003022 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3023 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003024 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003025 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003026 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003027 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3028 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003029 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
3030 0, 90, 0, 0, 91, 0, 0, 92, 115, 93,
3031 0, 0, 0, 0, 0, 0, 0, 0, 116, 117,
3032 0, 90, 0, 0, 91, 0, 0, 92, 0, 402,
3033 0, 118, 119, 120, 121, 122, 123, 124, 125, 126,
3034 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3035 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
3036 147, 148, 149, 150, 151, 152, 153, 0, 0, 154,
3037 155, 156, 157, 158, 159, 160, 161, 162, 0, 0,
3038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3039 0, 0, 0, 0, 0, 0, 0, 0, 163, 164,
3040 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
3041 175
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003042};
3043
3044static const short int yycheck[] =
3045{
Reid Spencerd2920cd2007-03-21 17:27:53 +00003046 45, 120, 115, 63, 120, 118, 107, 274, 4, 23,
3047 29, 3, 161, 0, 121, 164, 30, 558, 63, 93,
3048 5, 6, 15, 8, 9, 10, 11, 12, 13, 14,
3049 15, 16, 17, 18, 19, 15, 21, 22, 579, 24,
3050 153, 33, 23, 156, 157, 158, 159, 160, 161, 162,
3051 578, 10, 11, 12, 13, 14, 15, 16, 17, 104,
3052 105, 106, 590, 48, 57, 152, 179, 180, 306, 307,
3053 115, 153, 153, 118, 326, 327, 183, 57, 34, 161,
3054 5, 6, 163, 8, 9, 10, 11, 12, 13, 14,
3055 15, 16, 17, 18, 19, 347, 21, 22, 336, 24,
3056 159, 57, 52, 53, 54, 164, 151, 152, 153, 154,
3057 155, 156, 157, 158, 159, 160, 161, 162, 110, 153,
3058 22, 71, 24, 48, 198, 9, 153, 161, 153, 203,
3059 155, 176, 177, 178, 179, 180, 163, 21, 163, 164,
3060 153, 231, 232, 162, 61, 153, 159, 198, 61, 163,
3061 402, 159, 203, 243, 10, 11, 12, 13, 14, 15,
3062 16, 17, 0, 153, 153, 24, 162, 155, 45, 154,
3063 47, 157, 157, 163, 163, 160, 164, 162, 163, 152,
3064 293, 47, 48, 49, 244, 152, 276, 25, 32, 33,
3065 55, 56, 152, 31, 108, 109, 286, 287, 288, 244,
3066 159, 27, 28, 41, 42, 43, 44, 45, 46, 47,
3067 255, 3, 4, 3, 4, 3, 4, 455, 152, 486,
3068 152, 488, 296, 297, 62, 4, 300, 272, 24, 154,
3069 4, 291, 157, 3, 4, 160, 155, 162, 163, 64,
3070 65, 66, 67, 68, 69, 70, 291, 292, 293, 3,
3071 4, 24, 365, 20, 367, 368, 369, 77, 78, 24,
3072 4, 4, 375, 155, 59, 355, 356, 357, 158, 158,
3073 4, 4, 4, 363, 41, 42, 43, 44, 45, 46,
3074 47, 4, 7, 50, 4, 7, 7, 377, 378, 157,
3075 153, 155, 337, 394, 395, 396, 397, 398, 153, 153,
3076 153, 153, 153, 159, 153, 153, 407, 408, 409, 410,
3077 411, 153, 386, 153, 153, 24, 161, 36, 153, 156,
3078 365, 366, 367, 368, 369, 370, 371, 155, 402, 153,
3079 375, 376, 155, 155, 155, 24, 426, 155, 428, 155,
3080 155, 155, 432, 155, 155, 63, 153, 153, 153, 157,
3081 440, 441, 442, 153, 153, 456, 457, 161, 155, 153,
3082 153, 24, 463, 21, 222, 156, 155, 153, 226, 21,
3083 155, 153, 153, 231, 232, 4, 153, 153, 153, 4,
3084 493, 494, 495, 155, 429, 243, 24, 153, 36, 153,
3085 153, 481, 482, 153, 484, 485, 153, 153, 153, 161,
3086 153, 491, 447, 153, 34, 153, 507, 508, 509, 510,
3087 500, 153, 153, 514, 515, 516, 517, 153, 276, 156,
3088 533, 161, 414, 153, 153, 57, 24, 153, 286, 287,
3089 288, 57, 477, 157, 4, 21, 153, 153, 483, 558,
3090 541, 542, 558, 156, 159, 535, 156, 153, 493, 494,
3091 495, 156, 156, 156, 499, 156, 27, 28, 156, 156,
3092 579, 36, 156, 579, 159, 566, 156, 568, 569, 21,
3093 156, 156, 156, 518, 119, 120, 121, 122, 123, 124,
3094 125, 126, 127, 128, 153, 21, 576, 153, 533, 10,
3095 11, 12, 13, 14, 15, 16, 17, 355, 356, 357,
3096 65, 591, 21, 21, 65, 363, 65, 65, 598, 318,
3097 65, 33, 602, 603, 25, 478, 319, 44, 108, 377,
3098 378, 3, 222, 477, 19, 597, 429, 499, 458, -1,
3099 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
3100 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3101 21, 22, -1, 24, 125, 126, 127, 128, 129, 130,
3102 131, 132, 133, 134, 135, 136, 137, 138, 426, -1,
3103 428, 5, 6, -1, 432, -1, -1, 48, -1, -1,
3104 -1, -1, 440, 441, 442, -1, -1, 20, 22, 22,
3105 24, 24, 26, -1, -1, -1, -1, -1, 31, 32,
3106 33, -1, -1, -1, 38, 39, -1, -1, 41, 42,
3107 43, 44, 45, 46, 47, -1, -1, 50, 51, -1,
3108 -1, -1, -1, 481, 482, 58, 484, 485, -1, 62,
3109 -1, -1, -1, 491, -1, -1, -1, -1, -1, -1,
3110 -1, -1, 500, -1, -1, 79, 80, 81, 82, 83,
3111 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3112 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3113 104, -1, -1, -1, -1, -1, 110, 535, 112, -1,
3114 114, 115, 116, 154, -1, -1, 157, -1, -1, 160,
3115 -1, 162, 163, -1, -1, -1, -1, -1, -1, -1,
3116 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
3117 144, 145, 146, 147, 148, 149, 150, 151, 576, -1,
3118 -1, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3119 -1, 165, -1, 591, -1, -1, -1, -1, -1, -1,
3120 598, -1, -1, -1, 602, 603, 5, 6, -1, 8,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003121 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003122 19, -1, 21, 22, -1, 24, -1, -1, -1, 3,
3123 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
3124 -1, -1, -1, -1, -1, -1, -1, -1, 22, 48,
3125 24, -1, 26, 27, 28, -1, -1, -1, -1, -1,
3126 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003127 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3128 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
3129 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3130 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
3131 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3132 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3133 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
3134 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003135 -1, -1, -1, -1, -1, 154, 3, 4, 157, -1,
3136 7, 160, -1, 162, 163, 139, 140, 141, 142, 143,
3137 144, 145, 146, 147, 148, 149, 150, 151, -1, 26,
3138 27, 28, -1, -1, -1, -1, 160, -1, -1, -1,
3139 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003140 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003141 -1, -1, -1, -1, 61, -1, -1, -1, -1, -1,
3142 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3143 -1, -1, 79, 80, 81, 82, 83, 84, 85, 86,
3144 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
3145 97, 98, 99, 100, 101, 102, 103, 104, -1, -1,
3146 -1, -1, -1, 110, -1, 112, -1, 114, 115, 116,
3147 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3148 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3149 -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
3150 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
3151 -1, 5, 6, 160, 8, 9, 10, 11, 12, 13,
3152 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3153 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3154 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
3155 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003156 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003157 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3158 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3159 -1, 24, -1, -1, -1, 48, -1, -1, -1, -1,
3160 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
3161 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003162 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
3163 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003164 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
3165 -1, -1, -1, -1, -1, -1, 48, -1, -1, -1,
3166 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3167 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3168 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
3169 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3170 -1, 154, 37, -1, 157, -1, 159, 160, -1, 162,
3171 -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003172 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003173 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3174 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003175 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003176 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003177 162, 5, 6, 48, 8, 9, 10, 11, 12, 13,
3178 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3179 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
3180 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3181 24, -1, -1, -1, 48, -1, -1, -1, -1, 154,
3182 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3183 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
3184 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3185 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3186 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3187 -1, 24, -1, -1, -1, 48, -1, -1, -1, 154,
3188 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3189 -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003190 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3191 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003192 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003193 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003194 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003195 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3196 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003197 -1, -1, -1, -1, 35, -1, -1, -1, -1, -1,
3198 -1, 154, -1, -1, 157, -1, -1, 160, 49, 162,
3199 -1, -1, -1, -1, -1, -1, -1, -1, 59, 60,
3200 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3201 -1, 72, 73, 74, 75, 76, 77, 78, 79, 80,
3202 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
3203 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
3204 101, 102, 103, 104, 105, 106, 107, -1, -1, 110,
3205 111, 112, 113, 114, 115, 116, 117, 118, -1, -1,
3206 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3207 -1, -1, -1, -1, -1, -1, -1, -1, 139, 140,
3208 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
3209 151
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003210};
3211
3212/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
3213 symbol of state STATE-NUM. */
3214static const unsigned char yystos[] =
3215{
3216 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003217 44, 45, 46, 47, 62, 181, 219, 222, 224, 232,
3218 22, 24, 51, 58, 62, 180, 212, 224, 225, 61,
3219 220, 23, 233, 234, 30, 163, 221, 233, 52, 53,
3220 54, 71, 209, 152, 61, 20, 45, 47, 50, 181,
3221 152, 45, 47, 223, 24, 207, 64, 65, 66, 67,
3222 68, 69, 70, 182, 217, 180, 238, 152, 152, 152,
3223 152, 157, 210, 207, 5, 6, 8, 9, 10, 11,
3224 12, 13, 14, 15, 16, 17, 18, 19, 21, 48,
3225 154, 157, 160, 162, 167, 189, 190, 191, 192, 193,
3226 212, 229, 32, 33, 199, 199, 199, 199, 226, 4,
3227 189, 29, 162, 218, 35, 49, 59, 60, 72, 73,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003228 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
3229 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3230 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3231 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
3232 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
3233 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003234 175, 235, 236, 242, 243, 245, 246, 24, 55, 56,
3235 208, 4, 24, 24, 211, 4, 4, 4, 162, 8,
3236 163, 193, 194, 155, 164, 191, 191, 191, 9, 10,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003237 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003238 177, 179, 191, 196, 217, 212, 191, 231, 59, 8,
3239 231, 9, 21, 10, 11, 12, 13, 14, 15, 16,
3240 17, 176, 177, 178, 182, 119, 120, 121, 122, 123,
3241 124, 125, 126, 127, 128, 172, 27, 28, 125, 126,
3242 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3243 137, 138, 173, 191, 191, 231, 191, 191, 239, 231,
3244 231, 231, 231, 231, 231, 231, 191, 191, 191, 231,
3245 231, 182, 108, 109, 153, 159, 158, 158, 163, 194,
3246 153, 163, 37, 194, 195, 205, 206, 204, 27, 28,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003247 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
3248 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003249 170, 171, 174, 175, 197, 229, 203, 155, 3, 4,
3250 7, 26, 27, 28, 38, 39, 61, 160, 197, 228,
3251 229, 230, 230, 230, 230, 189, 191, 191, 153, 184,
3252 153, 184, 230, 157, 153, 153, 153, 153, 153, 153,
3253 153, 153, 230, 230, 230, 153, 36, 189, 191, 231,
3254 24, 193, 193, 161, 163, 193, 153, 156, 153, 187,
3255 187, 187, 172, 173, 155, 155, 155, 155, 155, 159,
3256 196, 198, 162, 198, 163, 198, 24, 155, 155, 155,
3257 155, 155, 187, 37, 191, 214, 215, 216, 63, 227,
3258 198, 153, 153, 230, 230, 230, 15, 57, 15, 153,
3259 244, 230, 157, 231, 191, 231, 231, 231, 191, 191,
3260 153, 153, 153, 231, 191, 230, 230, 153, 159, 161,
3261 161, 37, 34, 57, 185, 188, 155, 155, 196, 196,
3262 196, 196, 196, 153, 159, 163, 193, 198, 161, 163,
3263 196, 196, 196, 196, 196, 212, 213, 153, 156, 24,
3264 161, 21, 21, 155, 153, 153, 230, 4, 230, 231,
3265 240, 153, 230, 153, 153, 153, 230, 230, 230, 155,
3266 191, 24, 4, 187, 196, 196, 244, 153, 153, 153,
3267 153, 196, 161, 163, 153, 153, 153, 153, 36, 37,
3268 214, 185, 186, 153, 230, 230, 240, 241, 230, 230,
3269 153, 184, 184, 153, 230, 153, 231, 231, 231, 241,
3270 230, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3271 196, 196, 196, 191, 57, 183, 24, 153, 157, 156,
3272 231, 159, 230, 156, 196, 196, 153, 156, 153, 153,
3273 156, 156, 156, 156, 156, 4, 21, 159, 178, 237,
3274 36, 159, 156, 156, 196, 196, 196, 230, 228, 159,
3275 178, 21, 156, 156, 156, 153, 228, 230, 21, 153,
3276 235, 230, 21, 21, 230, 230
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003277};
Reid Spencere7c3c602006-11-30 06:36:44 +00003278
3279#define yyerrok (yyerrstatus = 0)
3280#define yyclearin (yychar = YYEMPTY)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003281#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003282#define YYEOF 0
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003283
Reid Spencere7c3c602006-11-30 06:36:44 +00003284#define YYACCEPT goto yyacceptlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003285#define YYABORT goto yyabortlab
3286#define YYERROR goto yyerrorlab
3287
3288
3289/* Like YYERROR except do call yyerror. This remains here temporarily
3290 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003291 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003292
Reid Spencere7c3c602006-11-30 06:36:44 +00003293#define YYFAIL goto yyerrlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003294
Reid Spencere7c3c602006-11-30 06:36:44 +00003295#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003296
3297#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003298do \
3299 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003300 { \
3301 yychar = (Token); \
3302 yylval = (Value); \
3303 yytoken = YYTRANSLATE (yychar); \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003304 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003305 goto yybackup; \
3306 } \
3307 else \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003308 { \
3309 yyerror (YY_("syntax error: cannot back up")); \
3310 YYERROR; \
3311 } \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003312while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003313
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003314
Reid Spencere7c3c602006-11-30 06:36:44 +00003315#define YYTERROR 1
3316#define YYERRCODE 256
3317
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003318
3319/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3320 If N is 0, then set CURRENT to the empty location which ends
3321 the previous symbol: RHS[0] (always defined). */
3322
3323#define YYRHSLOC(Rhs, K) ((Rhs)[K])
3324#ifndef YYLLOC_DEFAULT
3325# define YYLLOC_DEFAULT(Current, Rhs, N) \
3326 do \
3327 if (N) \
3328 { \
3329 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3330 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3331 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3332 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3333 } \
3334 else \
3335 { \
3336 (Current).first_line = (Current).last_line = \
3337 YYRHSLOC (Rhs, 0).last_line; \
3338 (Current).first_column = (Current).last_column = \
3339 YYRHSLOC (Rhs, 0).last_column; \
3340 } \
3341 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003342#endif
3343
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003344
3345/* YY_LOCATION_PRINT -- Print the location on the stream.
3346 This macro was not mandated originally: define only if we know
3347 we won't break user code: when these are the locations we know. */
3348
3349#ifndef YY_LOCATION_PRINT
3350# if YYLTYPE_IS_TRIVIAL
3351# define YY_LOCATION_PRINT(File, Loc) \
3352 fprintf (File, "%d.%d-%d.%d", \
3353 (Loc).first_line, (Loc).first_column, \
3354 (Loc).last_line, (Loc).last_column)
3355# else
3356# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3357# endif
3358#endif
3359
3360
3361/* YYLEX -- calling `yylex' with the right arguments. */
3362
Reid Spencer950bf602007-01-26 08:19:09 +00003363#ifdef YYLEX_PARAM
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003364# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer950bf602007-01-26 08:19:09 +00003365#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003366# define YYLEX yylex ()
Chris Lattner4227bdb2007-02-19 07:34:02 +00003367#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003368
3369/* Enable debugging if requested. */
3370#if YYDEBUG
3371
3372# ifndef YYFPRINTF
3373# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3374# define YYFPRINTF fprintf
3375# endif
3376
3377# define YYDPRINTF(Args) \
3378do { \
3379 if (yydebug) \
3380 YYFPRINTF Args; \
3381} while (0)
3382
3383# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3384do { \
3385 if (yydebug) \
3386 { \
3387 YYFPRINTF (stderr, "%s ", Title); \
3388 yysymprint (stderr, \
3389 Type, Value); \
3390 YYFPRINTF (stderr, "\n"); \
3391 } \
3392} while (0)
3393
3394/*------------------------------------------------------------------.
3395| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3396| TOP (included). |
3397`------------------------------------------------------------------*/
3398
3399#if defined (__STDC__) || defined (__cplusplus)
3400static void
3401yy_stack_print (short int *bottom, short int *top)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003402#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003403static void
3404yy_stack_print (bottom, top)
3405 short int *bottom;
3406 short int *top;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003407#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003408{
3409 YYFPRINTF (stderr, "Stack now");
3410 for (/* Nothing. */; bottom <= top; ++bottom)
3411 YYFPRINTF (stderr, " %d", *bottom);
3412 YYFPRINTF (stderr, "\n");
3413}
3414
3415# define YY_STACK_PRINT(Bottom, Top) \
3416do { \
3417 if (yydebug) \
3418 yy_stack_print ((Bottom), (Top)); \
3419} while (0)
3420
3421
3422/*------------------------------------------------.
3423| Report that the YYRULE is going to be reduced. |
3424`------------------------------------------------*/
3425
3426#if defined (__STDC__) || defined (__cplusplus)
3427static void
3428yy_reduce_print (int yyrule)
3429#else
3430static void
3431yy_reduce_print (yyrule)
3432 int yyrule;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003433#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003434{
3435 int yyi;
3436 unsigned long int yylno = yyrline[yyrule];
3437 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3438 yyrule - 1, yylno);
3439 /* Print the symbols being reduced, and their result. */
3440 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3441 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3442 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3443}
Reid Spencer9d6565a2007-02-15 02:26:10 +00003444
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003445# define YY_REDUCE_PRINT(Rule) \
3446do { \
3447 if (yydebug) \
3448 yy_reduce_print (Rule); \
3449} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00003450
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003451/* Nonzero means print parse trace. It is left uninitialized so that
3452 multiple parsers can coexist. */
3453int yydebug;
3454#else /* !YYDEBUG */
3455# define YYDPRINTF(Args)
3456# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3457# define YY_STACK_PRINT(Bottom, Top)
3458# define YY_REDUCE_PRINT(Rule)
3459#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00003460
Reid Spencer9d6565a2007-02-15 02:26:10 +00003461
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003462/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003463#ifndef YYINITDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003464# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003465#endif
3466
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003467/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3468 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003469
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003470 Do not make this value too large; the results are undefined if
3471 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3472 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003473
3474#ifndef YYMAXDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003475# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003476#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003477
Reid Spencere7c3c602006-11-30 06:36:44 +00003478
3479
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003480#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003481
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003482# ifndef yystrlen
3483# if defined (__GLIBC__) && defined (_STRING_H)
3484# define yystrlen strlen
3485# else
3486/* Return the length of YYSTR. */
3487static YYSIZE_T
3488# if defined (__STDC__) || defined (__cplusplus)
3489yystrlen (const char *yystr)
3490# else
3491yystrlen (yystr)
3492 const char *yystr;
3493# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003494{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003495 const char *yys = yystr;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003496
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003497 while (*yys++ != '\0')
3498 continue;
3499
3500 return yys - yystr - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003501}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003502# endif
3503# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003504
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003505# ifndef yystpcpy
3506# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3507# define yystpcpy stpcpy
3508# else
3509/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3510 YYDEST. */
3511static char *
3512# if defined (__STDC__) || defined (__cplusplus)
3513yystpcpy (char *yydest, const char *yysrc)
3514# else
3515yystpcpy (yydest, yysrc)
3516 char *yydest;
3517 const char *yysrc;
3518# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003519{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003520 char *yyd = yydest;
3521 const char *yys = yysrc;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003522
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003523 while ((*yyd++ = *yys++) != '\0')
3524 continue;
3525
3526 return yyd - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003527}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003528# endif
3529# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003530
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003531# ifndef yytnamerr
3532/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3533 quotes and backslashes, so that it's suitable for yyerror. The
3534 heuristic is that double-quoting is unnecessary unless the string
3535 contains an apostrophe, a comma, or backslash (other than
3536 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3537 null, do not copy; instead, return the length of what the result
3538 would have been. */
3539static YYSIZE_T
3540yytnamerr (char *yyres, const char *yystr)
3541{
3542 if (*yystr == '"')
3543 {
3544 size_t yyn = 0;
3545 char const *yyp = yystr;
3546
3547 for (;;)
3548 switch (*++yyp)
3549 {
3550 case '\'':
3551 case ',':
3552 goto do_not_strip_quotes;
3553
3554 case '\\':
3555 if (*++yyp != '\\')
3556 goto do_not_strip_quotes;
3557 /* Fall through. */
3558 default:
3559 if (yyres)
3560 yyres[yyn] = *yyp;
3561 yyn++;
3562 break;
3563
3564 case '"':
3565 if (yyres)
3566 yyres[yyn] = '\0';
3567 return yyn;
3568 }
3569 do_not_strip_quotes: ;
3570 }
3571
3572 if (! yyres)
3573 return yystrlen (yystr);
3574
3575 return yystpcpy (yyres, yystr) - yyres;
3576}
3577# endif
3578
3579#endif /* YYERROR_VERBOSE */
3580
Reid Spencer9d6565a2007-02-15 02:26:10 +00003581
3582
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003583#if YYDEBUG
3584/*--------------------------------.
3585| Print this symbol on YYOUTPUT. |
3586`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00003587
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003588#if defined (__STDC__) || defined (__cplusplus)
3589static void
3590yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003591#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003592static void
3593yysymprint (yyoutput, yytype, yyvaluep)
3594 FILE *yyoutput;
3595 int yytype;
3596 YYSTYPE *yyvaluep;
3597#endif
3598{
3599 /* Pacify ``unused variable'' warnings. */
3600 (void) yyvaluep;
3601
3602 if (yytype < YYNTOKENS)
3603 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3604 else
3605 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3606
3607
3608# ifdef YYPRINT
3609 if (yytype < YYNTOKENS)
3610 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3611# endif
3612 switch (yytype)
3613 {
3614 default:
3615 break;
3616 }
3617 YYFPRINTF (yyoutput, ")");
3618}
3619
3620#endif /* ! YYDEBUG */
3621/*-----------------------------------------------.
3622| Release the memory associated to this symbol. |
3623`-----------------------------------------------*/
3624
3625#if defined (__STDC__) || defined (__cplusplus)
3626static void
3627yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3628#else
3629static void
3630yydestruct (yymsg, yytype, yyvaluep)
3631 const char *yymsg;
3632 int yytype;
3633 YYSTYPE *yyvaluep;
3634#endif
3635{
3636 /* Pacify ``unused variable'' warnings. */
3637 (void) yyvaluep;
3638
3639 if (!yymsg)
3640 yymsg = "Deleting";
3641 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3642
3643 switch (yytype)
3644 {
3645
3646 default:
3647 break;
3648 }
3649}
3650
3651
3652/* Prevent warnings from -Wmissing-prototypes. */
3653
3654#ifdef YYPARSE_PARAM
3655# if defined (__STDC__) || defined (__cplusplus)
3656int yyparse (void *YYPARSE_PARAM);
3657# else
3658int yyparse ();
3659# endif
3660#else /* ! YYPARSE_PARAM */
3661#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003662int yyparse (void);
Chris Lattner4227bdb2007-02-19 07:34:02 +00003663#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003664int yyparse ();
3665#endif
3666#endif /* ! YYPARSE_PARAM */
3667
3668
3669
3670/* The look-ahead symbol. */
3671int yychar;
3672
3673/* The semantic value of the look-ahead symbol. */
3674YYSTYPE yylval;
3675
3676/* Number of syntax errors so far. */
3677int yynerrs;
3678
3679
3680
3681/*----------.
3682| yyparse. |
3683`----------*/
3684
3685#ifdef YYPARSE_PARAM
3686# if defined (__STDC__) || defined (__cplusplus)
3687int yyparse (void *YYPARSE_PARAM)
3688# else
3689int yyparse (YYPARSE_PARAM)
3690 void *YYPARSE_PARAM;
3691# endif
3692#else /* ! YYPARSE_PARAM */
3693#if defined (__STDC__) || defined (__cplusplus)
3694int
3695yyparse (void)
3696#else
3697int
3698yyparse ()
3699
3700#endif
3701#endif
3702{
3703
3704 int yystate;
3705 int yyn;
3706 int yyresult;
3707 /* Number of tokens to shift before error messages enabled. */
3708 int yyerrstatus;
3709 /* Look-ahead token as an internal (translated) token number. */
3710 int yytoken = 0;
3711
3712 /* Three stacks and their tools:
3713 `yyss': related to states,
3714 `yyvs': related to semantic values,
3715 `yyls': related to locations.
3716
3717 Refer to the stacks thru separate pointers, to allow yyoverflow
3718 to reallocate them elsewhere. */
3719
3720 /* The state stack. */
3721 short int yyssa[YYINITDEPTH];
3722 short int *yyss = yyssa;
3723 short int *yyssp;
3724
3725 /* The semantic value stack. */
3726 YYSTYPE yyvsa[YYINITDEPTH];
3727 YYSTYPE *yyvs = yyvsa;
3728 YYSTYPE *yyvsp;
3729
3730
3731
Chris Lattnercf3d0612007-02-13 06:04:17 +00003732#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003733
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003734 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003735
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003736 /* The variables used to return semantic value and location from the
3737 action routines. */
3738 YYSTYPE yyval;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003739
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003740
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003741 /* When reducing, the number of symbols on the RHS of the reduced
3742 rule. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003743 int yylen;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003744
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003745 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003746
Reid Spencere7c3c602006-11-30 06:36:44 +00003747 yystate = 0;
3748 yyerrstatus = 0;
3749 yynerrs = 0;
3750 yychar = YYEMPTY; /* Cause a token to be read. */
3751
3752 /* Initialize stack pointers.
3753 Waste one element of value and location stack
3754 so that they stay on the same level as the state stack.
3755 The wasted elements are never initialized. */
3756
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003757 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003758 yyvsp = yyvs;
3759
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003760 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003761
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003762/*------------------------------------------------------------.
3763| yynewstate -- Push a new state, which is found in yystate. |
3764`------------------------------------------------------------*/
3765 yynewstate:
3766 /* In all cases, when you get here, the value and location stacks
3767 have just been pushed. so pushing a state here evens the stacks.
3768 */
3769 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003770
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003771 yysetstate:
3772 *yyssp = yystate;
3773
3774 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003775 {
3776 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003777 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003778
3779#ifdef yyoverflow
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003780 {
3781 /* Give user a chance to reallocate the stack. Use copies of
3782 these so that the &'s don't force the real ones into
3783 memory. */
3784 YYSTYPE *yyvs1 = yyvs;
3785 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003786
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003787
3788 /* Each stack pointer address is followed by the size of the
3789 data in use in that stack, in bytes. This used to be a
3790 conditional around just the two extra args, but that might
3791 be undefined if yyoverflow is a macro. */
3792 yyoverflow (YY_("memory exhausted"),
3793 &yyss1, yysize * sizeof (*yyssp),
3794 &yyvs1, yysize * sizeof (*yyvsp),
3795
3796 &yystacksize);
3797
3798 yyss = yyss1;
3799 yyvs = yyvs1;
3800 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003801#else /* no yyoverflow */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003802# ifndef YYSTACK_RELOCATE
3803 goto yyexhaustedlab;
3804# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003805 /* Extend the stack our own way. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003806 if (YYMAXDEPTH <= yystacksize)
3807 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003808 yystacksize *= 2;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003809 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003810 yystacksize = YYMAXDEPTH;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003811
3812 {
3813 short int *yyss1 = yyss;
3814 union yyalloc *yyptr =
3815 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3816 if (! yyptr)
3817 goto yyexhaustedlab;
3818 YYSTACK_RELOCATE (yyss);
3819 YYSTACK_RELOCATE (yyvs);
3820
3821# undef YYSTACK_RELOCATE
3822 if (yyss1 != yyssa)
3823 YYSTACK_FREE (yyss1);
3824 }
3825# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003826#endif /* no yyoverflow */
3827
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003828 yyssp = yyss + yysize - 1;
3829 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003830
3831
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003832 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3833 (unsigned long int) yystacksize));
3834
3835 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003836 YYABORT;
3837 }
3838
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003839 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003840
3841 goto yybackup;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003842
3843/*-----------.
3844| yybackup. |
3845`-----------*/
3846yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003847
Chris Lattnercf3d0612007-02-13 06:04:17 +00003848/* Do appropriate processing given the current state. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003849/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003850/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003851
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003852 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003853
Reid Spencere7c3c602006-11-30 06:36:44 +00003854 yyn = yypact[yystate];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003855 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003856 goto yydefault;
3857
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003858 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003859
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003860 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003861 if (yychar == YYEMPTY)
3862 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003863 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003864 yychar = YYLEX;
3865 }
3866
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003867 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003868 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003869 yychar = yytoken = YYEOF;
3870 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003871 }
3872 else
3873 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003874 yytoken = YYTRANSLATE (yychar);
3875 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003876 }
3877
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003878 /* If the proper action on seeing token YYTOKEN is to reduce or to
3879 detect an error, take that action. */
3880 yyn += yytoken;
3881 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003882 goto yydefault;
3883 yyn = yytable[yyn];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003884 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003885 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003886 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003887 goto yyerrlab;
3888 yyn = -yyn;
3889 goto yyreduce;
3890 }
3891
3892 if (yyn == YYFINAL)
3893 YYACCEPT;
3894
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003895 /* Shift the look-ahead token. */
3896 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencerb7046c72007-01-29 05:41:34 +00003897
Chris Lattnercf3d0612007-02-13 06:04:17 +00003898 /* Discard the token being shifted unless it is eof. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003899 if (yychar != YYEOF)
3900 yychar = YYEMPTY;
3901
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003902 *++yyvsp = yylval;
3903
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003904
3905 /* Count tokens shifted since error; after three, turn off error
3906 status. */
3907 if (yyerrstatus)
3908 yyerrstatus--;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003909
3910 yystate = yyn;
Reid Spencere7c3c602006-11-30 06:36:44 +00003911 goto yynewstate;
3912
Chris Lattner4227bdb2007-02-19 07:34:02 +00003913
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003914/*-----------------------------------------------------------.
3915| yydefault -- do the default action for the current state. |
3916`-----------------------------------------------------------*/
3917yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003918 yyn = yydefact[yystate];
3919 if (yyn == 0)
3920 goto yyerrlab;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003921 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003922
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003923
3924/*-----------------------------.
3925| yyreduce -- Do a reduction. |
3926`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003927yyreduce:
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003928 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003929 yylen = yyr2[yyn];
3930
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003931 /* If YYLEN is nonzero, implement the default value of the action:
3932 `$$ = $1'.
3933
3934 Otherwise, the following line sets YYVAL to garbage.
3935 This behavior is undocumented and Bison
3936 users should not rely upon it. Assigning to YYVAL
3937 unconditionally makes the parser a bit smaller, and it avoids a
3938 GCC warning that YYVAL may be used uninitialized. */
3939 yyval = yyvsp[1-yylen];
3940
3941
3942 YY_REDUCE_PRINT (yyn);
3943 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003944 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003945 case 3:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003946#line 1872 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003947 {
3948 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003949 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003950 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3951 ;}
3952 break;
3953
3954 case 5:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003955#line 1881 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003956 {
3957 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003958 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003959 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3960 ;}
3961 break;
3962
3963 case 26:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003964#line 1903 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003965 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3966 break;
3967
3968 case 27:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003969#line 1903 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003970 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3971 break;
3972
3973 case 28:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003974#line 1904 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003975 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3976 break;
3977
3978 case 29:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003979#line 1904 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003980 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3981 break;
3982
3983 case 30:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003984#line 1905 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003985 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3986 break;
3987
3988 case 31:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003989#line 1905 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003990 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3991 break;
3992
3993 case 32:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003994#line 1906 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003995 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3996 break;
3997
3998 case 33:
Reid Spencer8166a6c2007-04-02 02:08:35 +00003999#line 1906 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004000 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
4001 break;
4002
4003 case 34:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004004#line 1907 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004005 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
4006 break;
4007
4008 case 35:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004009#line 1907 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004010 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
4011 break;
4012
4013 case 36:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004014#line 1911 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004015 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
4016 break;
4017
4018 case 37:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004019#line 1911 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004020 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
4021 break;
4022
4023 case 38:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004024#line 1912 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004025 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
4026 break;
4027
4028 case 39:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004029#line 1912 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004030 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
4031 break;
4032
4033 case 40:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004034#line 1913 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004035 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
4036 break;
4037
4038 case 41:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004039#line 1913 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004040 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
4041 break;
4042
4043 case 42:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004044#line 1914 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004045 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
4046 break;
4047
4048 case 43:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004049#line 1914 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004050 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
4051 break;
4052
4053 case 44:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004054#line 1915 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004055 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
4056 break;
4057
4058 case 45:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004059#line 1915 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004060 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
4061 break;
4062
4063 case 46:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004064#line 1916 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004065 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
4066 break;
4067
4068 case 47:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004069#line 1916 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004070 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
4071 break;
4072
4073 case 48:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004074#line 1917 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004075 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
4076 break;
4077
4078 case 49:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004079#line 1917 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004080 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
4081 break;
4082
4083 case 50:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004084#line 1918 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004085 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
4086 break;
4087
4088 case 51:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004089#line 1919 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004090 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
4091 break;
4092
4093 case 81:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004094#line 1950 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004095 {
4096 (yyval.StrVal) = (yyvsp[-1].StrVal);
4097 ;}
4098 break;
4099
4100 case 82:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004101#line 1953 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004102 {
4103 (yyval.StrVal) = 0;
4104 ;}
4105 break;
4106
4107 case 83:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004108#line 1958 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004109 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
4110 break;
4111
4112 case 84:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004113#line 1959 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004114 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
4115 break;
4116
4117 case 85:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004118#line 1960 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004119 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
4120 break;
4121
4122 case 86:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004123#line 1961 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004124 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
4125 break;
4126
4127 case 87:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004128#line 1962 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004129 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
4130 break;
4131
4132 case 88:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004133#line 1963 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004134 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
4135 break;
4136
4137 case 89:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004138#line 1964 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004139 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
4140 break;
4141
4142 case 90:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004143#line 1965 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004144 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
4145 break;
4146
4147 case 91:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004148#line 1969 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004149 { (yyval.UIntVal) = OldCallingConv::C; ;}
4150 break;
4151
4152 case 92:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004153#line 1970 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004154 { (yyval.UIntVal) = OldCallingConv::C; ;}
4155 break;
4156
4157 case 93:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004158#line 1971 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004159 { (yyval.UIntVal) = OldCallingConv::CSRet; ;}
4160 break;
4161
4162 case 94:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004163#line 1972 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004164 { (yyval.UIntVal) = OldCallingConv::Fast; ;}
4165 break;
4166
4167 case 95:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004168#line 1973 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004169 { (yyval.UIntVal) = OldCallingConv::Cold; ;}
4170 break;
4171
4172 case 96:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004173#line 1974 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004174 { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
4175 break;
4176
4177 case 97:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004178#line 1975 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004179 { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
4180 break;
4181
4182 case 98:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004183#line 1976 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004184 {
4185 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004186 error("Calling conv too large");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004187 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4188 ;}
4189 break;
4190
4191 case 99:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004192#line 1986 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004193 { (yyval.UIntVal) = 0; ;}
4194 break;
4195
4196 case 100:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004197#line 1987 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004198 {
4199 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4200 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004201 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004202 ;}
4203 break;
4204
4205 case 101:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004206#line 1995 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004207 { (yyval.UIntVal) = 0; ;}
4208 break;
4209
4210 case 102:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004211#line 1996 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004212 {
4213 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4214 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004215 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004216 ;}
4217 break;
4218
4219 case 103:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004220#line 2004 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004221 {
4222 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
4223 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00004224 error("Invalid character in section name");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004225 (yyval.StrVal) = (yyvsp[0].StrVal);
4226 ;}
4227 break;
4228
4229 case 104:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004230#line 2013 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004231 { (yyval.StrVal) = 0; ;}
4232 break;
4233
4234 case 105:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004235#line 2014 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004236 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
4237 break;
4238
4239 case 106:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004240#line 2021 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004241 {;}
4242 break;
4243
4244 case 107:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004245#line 2022 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004246 {;}
4247 break;
4248
4249 case 108:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004250#line 2026 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004251 {
4252 CurGV->setSection((yyvsp[0].StrVal));
4253 free((yyvsp[0].StrVal));
4254 ;}
4255 break;
4256
4257 case 109:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004258#line 2030 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004259 {
4260 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004261 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004262 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004263
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004264 ;}
4265 break;
4266
4267 case 111:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004268#line 2047 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004269 {
4270 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004271 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004272 ;}
4273 break;
4274
4275 case 113:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004276#line 2055 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004277 {
4278 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004279 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004280 ;}
4281 break;
4282
4283 case 114:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004284#line 2062 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004285 {
Reid Spencer950bf602007-01-26 08:19:09 +00004286 if (!UpRefs.empty())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004287 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription());
4288 (yyval.TypeVal) = (yyvsp[0].TypeVal);
4289 ;}
4290 break;
4291
4292 case 127:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004293#line 2076 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004294 {
4295 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004296 (yyval.TypeVal).S.copy((yyvsp[0].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004297 ;}
4298 break;
4299
4300 case 128:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004301#line 2080 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004302 {
4303 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004304 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004305 ;}
4306 break;
4307
4308 case 129:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004309#line 2084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004310 { // Named types are also simple types...
Reid Spencerbb1fd572007-03-21 17:15:50 +00004311 (yyval.TypeVal).S.copy(getTypeSign((yyvsp[0].ValIDVal)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004312 const Type* tmp = getType((yyvsp[0].ValIDVal));
4313 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004314 ;}
4315 break;
4316
4317 case 130:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004318#line 2089 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004319 { // Type UpReference
4320 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004321 error("Value out of range");
4322 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004323 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
4324 (yyval.TypeVal).PAT = new PATypeHolder(OT);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004325 (yyval.TypeVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00004326 UR_OUT("New Upreference!\n");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004327 ;}
4328 break;
4329
4330 case 131:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004331#line 2098 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004332 { // Function derived type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004333 (yyval.TypeVal).S.makeComposite((yyvsp[-3].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004334 std::vector<const Type*> Params;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004335 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4336 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004337 Params.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004338 (yyval.TypeVal).S.add(I->S);
Reid Spencer52402b02007-01-02 05:45:11 +00004339 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004340 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00004341 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4342 if (isVarArg) Params.pop_back();
4343
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004344 (yyval.TypeVal).PAT = new PATypeHolder(
4345 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg,
Reid Spencerbb1fd572007-03-21 17:15:50 +00004346 ParamAttrs), (yyval.TypeVal).S));
4347 delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004348 delete (yyvsp[-1].TypeList); // Delete the argument list
4349 ;}
4350 break;
4351
4352 case 132:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004353#line 2116 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004354 { // Sized array type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004355 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004356 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(),
Reid Spencerbb1fd572007-03-21 17:15:50 +00004357 (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004358 delete (yyvsp[-1].TypeVal).PAT;
4359 ;}
4360 break;
4361
4362 case 133:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004363#line 2122 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004364 { // Vector type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004365 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get();
4366 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
4367 error("Unsigned result not equal to signed result");
4368 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4369 error("Elements of a VectorType must be integer or floating point");
4370 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
4371 error("VectorType length should be a power of 2");
4372 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
4373 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4374 (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S));
4375 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004376 ;}
4377 break;
4378
4379 case 134:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004380#line 2135 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004381 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004382 std::vector<const Type*> Elements;
Reid Spencerbb1fd572007-03-21 17:15:50 +00004383 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004384 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
Reid Spencerbb1fd572007-03-21 17:15:50 +00004385 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004386 Elements.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004387 (yyval.TypeVal).S.add(I->S);
4388 }
4389 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004390 delete (yyvsp[-1].TypeList);
4391 ;}
4392 break;
4393
4394 case 135:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004395#line 2146 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004396 { // Empty structure type?
4397 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004398 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004399 ;}
4400 break;
4401
4402 case 136:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004403#line 2150 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004404 { // Packed Structure type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004405 (yyval.TypeVal).S.makeComposite();
Reid Spencer950bf602007-01-26 08:19:09 +00004406 std::vector<const Type*> Elements;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004407 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4408 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004409 Elements.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004410 (yyval.TypeVal).S.add(I->S);
Reid Spencered96d1e2007-02-08 09:08:52 +00004411 delete I->PAT;
Reid Spencer52402b02007-01-02 05:45:11 +00004412 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00004413 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
4414 (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004415 delete (yyvsp[-2].TypeList);
4416 ;}
4417 break;
4418
4419 case 137:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004420#line 2163 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004421 { // Empty packed structure type?
4422 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004423 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004424 ;}
4425 break;
4426
4427 case 138:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004428#line 2167 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004429 { // Pointer type?
4430 if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004431 error("Cannot form a pointer to a basic block");
Reid Spencerbb1fd572007-03-21 17:15:50 +00004432 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
4433 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get()),
4434 (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004435 delete (yyvsp[-1].TypeVal).PAT;
4436 ;}
4437 break;
4438
4439 case 139:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004440#line 2181 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004441 {
4442 (yyval.TypeList) = new std::list<PATypeInfo>();
4443 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4444 ;}
4445 break;
4446
4447 case 140:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004448#line 2185 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004449 {
4450 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4451 ;}
4452 break;
4453
4454 case 142:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004455#line 2193 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004456 {
Reid Spencer950bf602007-01-26 08:19:09 +00004457 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004458 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004459 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004460 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4461 ;}
4462 break;
4463
4464 case 143:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004465#line 2199 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004466 {
4467 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencer950bf602007-01-26 08:19:09 +00004468 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004469 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004470 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004471 (yyval.TypeList)->push_back(VoidTI);
4472 ;}
4473 break;
4474
4475 case 144:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004476#line 2206 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004477 {
4478 (yyval.TypeList) = new std::list<PATypeInfo>();
4479 ;}
4480 break;
4481
4482 case 145:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004483#line 2218 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004484 { // Nonempty unsized arr
4485 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004486 if (ATy == 0)
4487 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004488 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004489 const Type *ETy = ATy->getElementType();
4490 int NumElements = ATy->getNumElements();
4491
4492 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004493 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004494 error("Type mismatch: constant sized array initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004495 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004496 itostr(NumElements) + "");
4497
4498 // Verify all elements are correct type!
4499 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004500 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4501 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004502 const Type* ValTy = C->getType();
4503 if (ETy != ValTy)
4504 error("Element #" + utostr(i) + " is not of type '" +
4505 ETy->getDescription() +"' as required!\nIt is of type '"+
4506 ValTy->getDescription() + "'");
4507 Elems.push_back(C);
4508 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004509 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004510 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004511 delete (yyvsp[-3].TypeVal).PAT;
4512 delete (yyvsp[-1].ConstVector);
4513 ;}
4514 break;
4515
4516 case 146:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004517#line 2248 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004518 {
4519 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004520 if (ATy == 0)
4521 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004522 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004523 int NumElements = ATy->getNumElements();
4524 if (NumElements != -1 && NumElements != 0)
4525 error("Type mismatch: constant sized array initialized with 0"
4526 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004527 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004528 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004529 delete (yyvsp[-2].TypeVal).PAT;
4530 ;}
4531 break;
4532
4533 case 147:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004534#line 2261 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004535 {
4536 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004537 if (ATy == 0)
4538 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004539 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004540 int NumElements = ATy->getNumElements();
4541 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4542 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4543 error("String arrays require type i8, not '" + ETy->getDescription() +
4544 "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004545 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4546 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004547 error("Can't build string constant of size " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004548 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004549 itostr(NumElements) + "");
4550 std::vector<Constant*> Vals;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004551 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004552 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004553 free((yyvsp[0].StrVal));
4554 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004555 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004556 delete (yyvsp[-2].TypeVal).PAT;
4557 ;}
4558 break;
4559
4560 case 148:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004561#line 2284 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004562 { // Nonempty unsized arr
4563 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004564 if (PTy == 0)
4565 error("Cannot make packed constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004566 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004567 const Type *ETy = PTy->getElementType();
4568 int NumElements = PTy->getNumElements();
4569 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004570 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004571 error("Type mismatch: constant sized packed initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004572 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004573 itostr(NumElements) + "");
4574 // Verify all elements are correct type!
4575 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004576 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4577 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004578 const Type* ValTy = C->getType();
4579 if (ETy != ValTy)
4580 error("Element #" + utostr(i) + " is not of type '" +
4581 ETy->getDescription() +"' as required!\nIt is of type '"+
4582 ValTy->getDescription() + "'");
4583 Elems.push_back(C);
4584 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004585 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004586 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004587 delete (yyvsp[-3].TypeVal).PAT;
4588 delete (yyvsp[-1].ConstVector);
4589 ;}
4590 break;
4591
4592 case 149:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004593#line 2312 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004594 {
4595 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004596 if (STy == 0)
4597 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004598 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
4599 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004600 error("Illegal number of initializers for structure type");
4601
4602 // Check to ensure that constants are compatible with the type initializer!
4603 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004604 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4605 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004606 if (C->getType() != STy->getElementType(i))
4607 error("Expected type '" + STy->getElementType(i)->getDescription() +
4608 "' for element #" + utostr(i) + " of structure initializer");
4609 Fields.push_back(C);
4610 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004611 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004612 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004613 delete (yyvsp[-3].TypeVal).PAT;
4614 delete (yyvsp[-1].ConstVector);
4615 ;}
4616 break;
4617
4618 case 150:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004619#line 2334 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004620 {
4621 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004622 if (STy == 0)
4623 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004624 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004625 if (STy->getNumContainedTypes() != 0)
4626 error("Illegal number of initializers for structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004627 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004628 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004629 delete (yyvsp[-2].TypeVal).PAT;
4630 ;}
4631 break;
4632
4633 case 151:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004634#line 2345 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004635 {
4636 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004637 if (STy == 0)
4638 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004639 (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'");
4640 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004641 error("Illegal number of initializers for packed structure type");
4642
4643 // Check to ensure that constants are compatible with the type initializer!
4644 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004645 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4646 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004647 if (C->getType() != STy->getElementType(i))
4648 error("Expected type '" + STy->getElementType(i)->getDescription() +
4649 "' for element #" + utostr(i) + " of packed struct initializer");
4650 Fields.push_back(C);
4651 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004652 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004653 (yyval.ConstVal).S.copy((yyvsp[-5].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004654 delete (yyvsp[-5].TypeVal).PAT;
4655 delete (yyvsp[-2].ConstVector);
4656 ;}
4657 break;
4658
4659 case 152:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004660#line 2367 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004661 {
4662 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004663 if (STy == 0)
4664 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004665 (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004666 if (STy->getNumContainedTypes() != 0)
4667 error("Illegal number of initializers for packed structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004668 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004669 (yyval.ConstVal).S.copy((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004670 delete (yyvsp[-4].TypeVal).PAT;
4671 ;}
4672 break;
4673
4674 case 153:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004675#line 2378 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004676 {
4677 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004678 if (PTy == 0)
4679 error("Cannot make null pointer constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004680 (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'");
4681 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004682 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004683 delete (yyvsp[-1].TypeVal).PAT;
4684 ;}
4685 break;
4686
4687 case 154:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004688#line 2387 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004689 {
4690 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004691 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004692 delete (yyvsp[-1].TypeVal).PAT;
4693 ;}
4694 break;
4695
4696 case 155:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004697#line 2392 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004698 {
4699 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004700 if (Ty == 0)
4701 error("Global const reference must be a pointer type, not" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004702 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004703
4704 // ConstExprs can exist in the body of a function, thus creating
4705 // GlobalValues whenever they refer to a variable. Because we are in
4706 // the context of a function, getExistingValue will search the functions
4707 // symbol table instead of the module symbol table for the global symbol,
4708 // which throws things all off. To get around this, we just tell
4709 // getExistingValue that we are at global scope here.
4710 //
4711 Function *SavedCurFn = CurFun.CurrentFunction;
4712 CurFun.CurrentFunction = 0;
Reid Spencerbb1fd572007-03-21 17:15:50 +00004713 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004714 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004715 CurFun.CurrentFunction = SavedCurFn;
4716
4717 // If this is an initializer for a constant pointer, which is referencing a
4718 // (currently) undefined variable, create a stub now that shall be replaced
4719 // in the future with the right type of variable.
4720 //
4721 if (V == 0) {
4722 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4723 const PointerType *PT = cast<PointerType>(Ty);
4724
4725 // First check to see if the forward references value is already created!
4726 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004727 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004728
4729 if (I != CurModule.GlobalRefs.end()) {
4730 V = I->second; // Placeholder already exists, use it...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004731 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004732 } else {
4733 std::string Name;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004734 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004735
4736 // Create the forward referenced global.
4737 GlobalValue *GV;
4738 if (const FunctionType *FTy =
4739 dyn_cast<FunctionType>(PT->getElementType())) {
4740 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4741 CurModule.CurrentModule);
4742 } else {
4743 GV = new GlobalVariable(PT->getElementType(), false,
4744 GlobalValue::ExternalLinkage, 0,
4745 Name, CurModule.CurrentModule);
4746 }
4747
4748 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004749 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004750 V = GV;
4751 }
4752 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004753 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004754 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004755 delete (yyvsp[-1].TypeVal).PAT; // Free the type handle
4756 ;}
4757 break;
4758
4759 case 156:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004760#line 2451 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004761 {
4762 if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004763 error("Mismatched types for constant expression");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004764 (yyval.ConstVal) = (yyvsp[0].ConstVal);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004765 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004766 delete (yyvsp[-1].TypeVal).PAT;
4767 ;}
4768 break;
4769
4770 case 157:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004771#line 2458 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004772 {
4773 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004774 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4775 error("Cannot create a null initialized value of this type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004776 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004777 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004778 delete (yyvsp[-1].TypeVal).PAT;
4779 ;}
4780 break;
4781
4782 case 158:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004783#line 2466 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004784 { // integral constants
4785 const Type *Ty = (yyvsp[-1].PrimType).T;
4786 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004787 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004788 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004789 (yyval.ConstVal).S.makeSigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004790 ;}
4791 break;
4792
4793 case 159:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004794#line 2473 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004795 { // integral constants
4796 const Type *Ty = (yyvsp[-1].PrimType).T;
4797 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004798 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004799 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004800 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004801 ;}
4802 break;
4803
4804 case 160:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004805#line 2480 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004806 { // Boolean constants
4807 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004808 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004809 ;}
4810 break;
4811
4812 case 161:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004813#line 2484 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004814 { // Boolean constants
4815 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004816 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004817 ;}
4818 break;
4819
4820 case 162:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004821#line 2488 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004822 { // Float & Double constants
4823 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004824 error("Floating point constant invalid for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004825 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004826 (yyval.ConstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004827 ;}
4828 break;
4829
4830 case 163:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004831#line 2497 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004832 {
4833 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4834 const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00004835 Signedness SrcSign((yyvsp[-3].ConstVal).S);
4836 Signedness DstSign((yyvsp[-1].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004837 if (!SrcTy->isFirstClassType())
4838 error("cast constant expression from a non-primitive type: '" +
4839 SrcTy->getDescription() + "'");
4840 if (!DstTy->isFirstClassType())
4841 error("cast constant expression to a non-primitive type: '" +
4842 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004843 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004844 (yyval.ConstVal).S.copy(DstSign);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004845 delete (yyvsp[-1].TypeVal).PAT;
4846 ;}
4847 break;
4848
4849 case 164:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004850#line 2512 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004851 {
4852 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004853 if (!isa<PointerType>(Ty))
4854 error("GetElementPtr requires a pointer operand");
4855
4856 std::vector<Value*> VIndices;
4857 std::vector<Constant*> CIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004858 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004859
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004860 delete (yyvsp[-1].ValueList);
4861 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, &CIndices[0], CIndices.size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004862 (yyval.ConstVal).S.copy(getElementSign((yyvsp[-2].ConstVal), CIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004863 ;}
4864 break;
4865
4866 case 165:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004867#line 2525 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004868 {
4869 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4870 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004871 error("Select condition must be bool type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004872 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004873 error("Select operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004874 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004875 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004876 ;}
4877 break;
4878
4879 case 166:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004880#line 2534 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004881 {
4882 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4883 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004884 error("Binary operator types must match");
4885 // First, make sure we're dealing with the right opcode by upgrading from
4886 // obsolete versions.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004887 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004888
4889 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4890 // To retain backward compatibility with these early compilers, we emit a
4891 // cast to the appropriate integer type automatically if we are in the
4892 // broken case. See PR424 for more information.
4893 if (!isa<PointerType>(Ty)) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004894 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004895 } else {
4896 const Type *IntPtrTy = 0;
4897 switch (CurModule.CurrentModule->getPointerSize()) {
4898 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4899 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4900 default: error("invalid pointer binary constant expr");
4901 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004902 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4903 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4904 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4905 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004906 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00004907 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004908 ;}
4909 break;
4910
4911 case 167:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004912#line 2562 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004913 {
4914 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4915 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004916 error("Logical operator types must match");
4917 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00004918 if (!isa<VectorType>(Ty) ||
4919 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004920 error("Logical operator requires integer operands");
4921 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004922 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4923 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004924 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004925 ;}
4926 break;
4927
4928 case 168:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004929#line 2575 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004930 {
4931 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4932 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004933 error("setcc operand types must match");
4934 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004935 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4936 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004937 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004938 ;}
4939 break;
4940
4941 case 169:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004942#line 2584 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004943 {
4944 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004945 error("icmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004946 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004947 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004948 ;}
4949 break;
4950
4951 case 170:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004952#line 2590 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004953 {
4954 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004955 error("fcmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004956 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004957 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004958 ;}
4959 break;
4960
4961 case 171:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004962#line 2596 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004963 {
4964 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4965 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004966 error("Shift count for shift constant must be unsigned byte");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004967 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4968 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004969 error("Shift constant expression requires integer operand");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004970 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4971 (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, ShiftAmt);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004972 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004973 ;}
4974 break;
4975
4976 case 172:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004977#line 2607 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004978 {
4979 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004980 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004981 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004982 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004983 ;}
4984 break;
4985
4986 case 173:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004987#line 2613 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004988 {
4989 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004990 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004991 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004992 (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004993 ;}
4994 break;
4995
4996 case 174:
Reid Spencer8166a6c2007-04-02 02:08:35 +00004997#line 2619 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004998 {
4999 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00005000 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005001 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005002 (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005003 ;}
5004 break;
5005
5006 case 175:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005007#line 2630 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005008 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
5009 break;
5010
5011 case 176:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005012#line 2631 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005013 {
5014 (yyval.ConstVector) = new std::vector<ConstInfo>();
5015 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
5016 ;}
5017 break;
5018
5019 case 177:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005020#line 2640 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005021 { (yyval.BoolVal) = false; ;}
5022 break;
5023
5024 case 178:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005025#line 2641 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005026 { (yyval.BoolVal) = true; ;}
5027 break;
5028
5029 case 179:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005030#line 2653 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005031 {
5032 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005033 CurModule.ModuleDone();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005034 ;}
5035 break;
5036
5037 case 180:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005038#line 2662 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005039 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
5040 break;
5041
5042 case 181:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005043#line 2663 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005044 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
5045 break;
5046
5047 case 182:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005048#line 2664 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005049 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
5050 break;
5051
5052 case 183:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005053#line 2665 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005054 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
5055 break;
5056
5057 case 184:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005058#line 2666 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005059 {
5060 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer950bf602007-01-26 08:19:09 +00005061 // Emit an error if there are any unresolved types left.
5062 if (!CurModule.LateResolveTypes.empty()) {
5063 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5064 if (DID.Type == ValID::NameVal) {
5065 error("Reference to an undefined type: '"+DID.getName() + "'");
5066 } else {
5067 error("Reference to an undefined type: #" + itostr(DID.Num));
5068 }
5069 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005070 ;}
5071 break;
5072
5073 case 185:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005074#line 2682 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005075 {
Reid Spencer950bf602007-01-26 08:19:09 +00005076 // Eagerly resolve types. This is not an optimization, this is a
5077 // requirement that is due to the fact that we could have this:
5078 //
5079 // %list = type { %list * }
5080 // %list = type { %list * } ; repeated type decl
5081 //
5082 // If types are not resolved eagerly, then the two types will not be
5083 // determined to be the same type!
5084 //
Reid Spencerbb1fd572007-03-21 17:15:50 +00005085 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].TypeVal).PAT->get(), (yyvsp[0].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00005086
Reid Spencerbb1fd572007-03-21 17:15:50 +00005087 if (!setTypeName((yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
5088 // If this is a numbered type that is not a redefinition, add it to the
5089 // slot table.
5090 CurModule.Types.push_back((yyvsp[0].TypeVal).PAT->get());
5091 CurModule.TypeSigns.push_back((yyvsp[0].TypeVal).S);
Reid Spencera50d5962006-12-02 04:11:07 +00005092 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005093 delete (yyvsp[0].TypeVal).PAT;
5094 ;}
5095 break;
5096
5097 case 186:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005098#line 2702 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005099 { // Function prototypes can be in const pool
5100 ;}
5101 break;
5102
5103 case 187:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005104#line 2704 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005105 { // Asm blocks can be in the const pool
5106 ;}
5107 break;
5108
5109 case 188:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005110#line 2706 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005111 {
5112 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005113 error("Global value initializer is not a constant");
Reid Spencerbb1fd572007-03-21 17:15:50 +00005114 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C, (yyvsp[0].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005115 ;}
5116 break;
5117
5118 case 189:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005119#line 2710 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005120 {
Reid Spencer950bf602007-01-26 08:19:09 +00005121 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005122 ;}
5123 break;
5124
5125 case 190:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005126#line 2713 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005127 {
5128 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005129 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5130 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005131 delete (yyvsp[0].TypeVal).PAT;
5132 ;}
5133 break;
5134
5135 case 191:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005136#line 2718 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005137 {
Reid Spencer950bf602007-01-26 08:19:09 +00005138 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005139 ;}
5140 break;
5141
5142 case 192:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005143#line 2721 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005144 {
5145 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005146 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5147 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005148 delete (yyvsp[0].TypeVal).PAT;
5149 ;}
5150 break;
5151
5152 case 193:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005153#line 2726 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005154 {
Reid Spencer950bf602007-01-26 08:19:09 +00005155 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005156 ;}
5157 break;
5158
5159 case 194:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005160#line 2729 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005161 {
5162 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005163 CurGV =
Reid Spencerbb1fd572007-03-21 17:15:50 +00005164 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5165 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005166 delete (yyvsp[0].TypeVal).PAT;
5167 ;}
5168 break;
5169
5170 case 195:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005171#line 2735 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005172 {
Reid Spencer950bf602007-01-26 08:19:09 +00005173 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005174 ;}
5175 break;
5176
5177 case 196:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005178#line 2738 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005179 {
5180 ;}
5181 break;
5182
5183 case 197:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005184#line 2740 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005185 {
5186 ;}
5187 break;
5188
5189 case 198:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005190#line 2742 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005191 {
5192 ;}
5193 break;
5194
5195 case 199:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005196#line 2747 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005197 {
Reid Spencer950bf602007-01-26 08:19:09 +00005198 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005199 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
5200 std::string NewAsm((yyvsp[0].StrVal), EndStr);
5201 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005202
5203 if (AsmSoFar.empty())
5204 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5205 else
5206 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005207 ;}
5208 break;
5209
5210 case 200:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005211#line 2761 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005212 { (yyval.Endianness) = Module::BigEndian; ;}
5213 break;
5214
5215 case 201:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005216#line 2762 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005217 { (yyval.Endianness) = Module::LittleEndian; ;}
5218 break;
5219
5220 case 202:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005221#line 2766 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005222 {
5223 CurModule.setEndianness((yyvsp[0].Endianness));
5224 ;}
5225 break;
5226
5227 case 203:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005228#line 2769 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005229 {
5230 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00005231 CurModule.setPointerSize(Module::Pointer32);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005232 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00005233 CurModule.setPointerSize(Module::Pointer64);
5234 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005235 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
5236 ;}
5237 break;
Reid Spencer9d6565a2007-02-15 02:26:10 +00005238
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005239 case 204:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005240#line 2777 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005241 {
5242 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
5243 free((yyvsp[0].StrVal));
5244 ;}
5245 break;
5246
5247 case 205:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005248#line 2781 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005249 {
5250 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
5251 free((yyvsp[0].StrVal));
5252 ;}
5253 break;
5254
5255 case 207:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005256#line 2792 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005257 {
5258 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5259 free((yyvsp[0].StrVal));
5260 ;}
5261 break;
5262
5263 case 208:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005264#line 2796 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005265 {
5266 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5267 free((yyvsp[0].StrVal));
5268 ;}
5269 break;
5270
5271 case 209:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005272#line 2800 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005273 { ;}
5274 break;
5275
5276 case 213:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005277#line 2813 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005278 { (yyval.StrVal) = 0; ;}
5279 break;
5280
5281 case 214:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005282#line 2817 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005283 {
5284 if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy)
5285 error("void typed arguments are invalid");
5286 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
5287 ;}
5288 break;
5289
5290 case 215:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005291#line 2825 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005292 {
5293 (yyval.ArgList) = (yyvsp[-2].ArgList);
5294 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5295 delete (yyvsp[0].ArgVal);
5296 ;}
5297 break;
5298
5299 case 216:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005300#line 2830 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005301 {
5302 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5303 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5304 delete (yyvsp[0].ArgVal);
5305 ;}
5306 break;
5307
5308 case 217:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005309#line 2838 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005310 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
5311 break;
5312
5313 case 218:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005314#line 2839 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005315 {
5316 (yyval.ArgList) = (yyvsp[-2].ArgList);
5317 PATypeInfo VoidTI;
5318 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005319 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005320 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5321 ;}
5322 break;
5323
5324 case 219:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005325#line 2846 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005326 {
5327 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5328 PATypeInfo VoidTI;
5329 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005330 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005331 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5332 ;}
5333 break;
5334
5335 case 220:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005336#line 2853 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005337 { (yyval.ArgList) = 0; ;}
5338 break;
5339
5340 case 221:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005341#line 2857 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005342 {
5343 UnEscapeLexed((yyvsp[-5].StrVal));
5344 std::string FunctionName((yyvsp[-5].StrVal));
5345 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
5346
5347 const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005348
5349 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5350 error("LLVM functions cannot return aggregate types");
5351
Reid Spencerbb1fd572007-03-21 17:15:50 +00005352 Signedness FTySign;
5353 FTySign.makeComposite((yyvsp[-6].TypeVal).S);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005354 std::vector<const Type*> ParamTyList;
Reid Spencer950bf602007-01-26 08:19:09 +00005355
5356 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5357 // i8*. We check here for those names and override the parameter list
5358 // types to ensure the prototype is correct.
5359 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005360 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00005361 } else if (FunctionName == "llvm.va_copy") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005362 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5363 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005364 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005365 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005366 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005367 const Type *Ty = I->first.PAT->get();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005368 ParamTyList.push_back(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005369 FTySign.add(I->first.S);
Reid Spencer950bf602007-01-26 08:19:09 +00005370 }
5371 }
5372
Reid Spenceref9b9a72007-02-05 20:47:22 +00005373 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5374 if (isVarArg)
5375 ParamTyList.pop_back();
Reid Spencer950bf602007-01-26 08:19:09 +00005376
Reid Spencerb7046c72007-01-29 05:41:34 +00005377 // Convert the CSRet calling convention into the corresponding parameter
5378 // attribute.
5379 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005380 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00005381 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5382 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5383 }
5384
Reid Spenceref9b9a72007-02-05 20:47:22 +00005385 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
Reid Spencerb7046c72007-01-29 05:41:34 +00005386 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005387 const PointerType *PFT = PointerType::get(FT);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005388 delete (yyvsp[-6].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005389
5390 ValID ID;
5391 if (!FunctionName.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005392 ID = ValID::create((char*)FunctionName.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00005393 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005394 ID = ValID::create((int)CurModule.Values[PFT].size());
Reid Spencer950bf602007-01-26 08:19:09 +00005395 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005396 ID.S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00005397
5398 Function *Fn = 0;
Reid Spencered96d1e2007-02-08 09:08:52 +00005399 Module* M = CurModule.CurrentModule;
5400
Reid Spencer950bf602007-01-26 08:19:09 +00005401 // See if this function was forward referenced. If so, recycle the object.
5402 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5403 // Move the function to the end of the list, from whereever it was
5404 // previously inserted.
5405 Fn = cast<Function>(FWRef);
Reid Spencered96d1e2007-02-08 09:08:52 +00005406 M->getFunctionList().remove(Fn);
5407 M->getFunctionList().push_back(Fn);
5408 } else if (!FunctionName.empty()) {
5409 GlobalValue *Conflict = M->getFunction(FunctionName);
5410 if (!Conflict)
5411 Conflict = M->getNamedGlobal(FunctionName);
5412 if (Conflict && PFT == Conflict->getType()) {
5413 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5414 // We have two function definitions that conflict, same type, same
5415 // name. We should really check to make sure that this is the result
5416 // of integer type planes collapsing and generate an error if it is
5417 // not, but we'll just rename on the assumption that it is. However,
5418 // let's do it intelligently and rename the internal linkage one
5419 // if there is one.
5420 std::string NewName(makeNameUnique(FunctionName));
5421 if (Conflict->hasInternalLinkage()) {
5422 Conflict->setName(NewName);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005423 RenameMapKey Key =
5424 makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005425 CurModule.RenameMap[Key] = NewName;
5426 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5427 InsertValue(Fn, CurModule.Values);
5428 } else {
5429 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5430 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005431 RenameMapKey Key =
5432 makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005433 CurModule.RenameMap[Key] = NewName;
5434 }
5435 } else {
5436 // If they are not both definitions, then just use the function we
5437 // found since the types are the same.
5438 Fn = cast<Function>(Conflict);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005439
Reid Spencered96d1e2007-02-08 09:08:52 +00005440 // Make sure to strip off any argument names so we can't get
5441 // conflicts.
5442 if (Fn->isDeclaration())
5443 for (Function::arg_iterator AI = Fn->arg_begin(),
5444 AE = Fn->arg_end(); AI != AE; ++AI)
5445 AI->setName("");
5446 }
5447 } else if (Conflict) {
5448 // We have two globals with the same name and different types.
5449 // Previously, this was permitted because the symbol table had
5450 // "type planes" and names only needed to be distinct within a
5451 // type plane. After PR411 was fixed, this is no loner the case.
5452 // To resolve this we must rename one of the two.
5453 if (Conflict->hasInternalLinkage()) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005454 // We can safely rename the Conflict.
5455 RenameMapKey Key =
5456 makeRenameMapKey(Conflict->getName(), Conflict->getType(),
5457 CurModule.NamedValueSigns[Conflict->getName()]);
Reid Spencered96d1e2007-02-08 09:08:52 +00005458 Conflict->setName(makeNameUnique(Conflict->getName()));
Reid Spencered96d1e2007-02-08 09:08:52 +00005459 CurModule.RenameMap[Key] = Conflict->getName();
5460 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5461 InsertValue(Fn, CurModule.Values);
Reid Spencerd2920cd2007-03-21 17:27:53 +00005462 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005463 // We can't quietly rename either of these things, but we must
Reid Spencerd2920cd2007-03-21 17:27:53 +00005464 // rename one of them. Only if the function's linkage is internal can
5465 // we forgo a warning message about the renamed function.
Reid Spencered96d1e2007-02-08 09:08:52 +00005466 std::string NewName = makeNameUnique(FunctionName);
Reid Spencerd2920cd2007-03-21 17:27:53 +00005467 if (CurFun.Linkage != GlobalValue::InternalLinkage) {
5468 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5469 "' may cause linkage errors");
5470 }
5471 // Elect to rename the thing we're now defining.
Reid Spencered96d1e2007-02-08 09:08:52 +00005472 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5473 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005474 RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005475 CurModule.RenameMap[Key] = NewName;
Reid Spencerd2920cd2007-03-21 17:27:53 +00005476 }
Reid Spenceref9b9a72007-02-05 20:47:22 +00005477 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005478 // There's no conflict, just define the function
5479 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5480 InsertValue(Fn, CurModule.Values);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005481 }
Reid Spencer950bf602007-01-26 08:19:09 +00005482 }
5483
5484 CurFun.FunctionStart(Fn);
5485
5486 if (CurFun.isDeclare) {
5487 // If we have declaration, always overwrite linkage. This will allow us
5488 // to correctly handle cases, when pointer to function is passed as
5489 // argument to another function.
5490 Fn->setLinkage(CurFun.Linkage);
5491 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005492 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5493 Fn->setAlignment((yyvsp[0].UIntVal));
5494 if ((yyvsp[-1].StrVal)) {
5495 Fn->setSection((yyvsp[-1].StrVal));
5496 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005497 }
5498
5499 // Add all of the arguments we parsed to the function...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005500 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005501 if (isVarArg) { // Nuke the last entry
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005502 assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5503 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5504 delete (yyvsp[-3].ArgList)->back().first.PAT;
5505 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005506 }
5507 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005508 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005509 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
5510 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005511 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005512 delete I->first.PAT; // Delete the typeholder...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005513 ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
5514 setValueName(VI, I->second); // Insert arg into symtab...
Reid Spencer950bf602007-01-26 08:19:09 +00005515 InsertValue(ArgIt);
5516 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005517 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005518 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005519 ;}
5520 break;
5521
5522 case 224:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005523#line 3042 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerd2920cd2007-03-21 17:27:53 +00005524 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5525 break;
5526
5527 case 225:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005528#line 3042 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005529 {
5530 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005531
5532 // Make sure that we keep track of the linkage type even if there was a
5533 // previous "declare".
Reid Spencerd2920cd2007-03-21 17:27:53 +00005534 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005535 ;}
5536 break;
5537
Reid Spencerd2920cd2007-03-21 17:27:53 +00005538 case 228:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005539#line 3056 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005540 {
5541 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5542 ;}
5543 break;
5544
Reid Spencerd2920cd2007-03-21 17:27:53 +00005545 case 229:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005546#line 3061 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005547 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5548 break;
5549
Reid Spencerd2920cd2007-03-21 17:27:53 +00005550 case 230:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005551#line 3062 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005552 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
5553 break;
5554
Reid Spencerd2920cd2007-03-21 17:27:53 +00005555 case 231:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005556#line 3063 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005557 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
5558 break;
5559
Reid Spencerd2920cd2007-03-21 17:27:53 +00005560 case 232:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005561#line 3067 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005562 { CurFun.isDeclare = true; ;}
5563 break;
5564
Reid Spencerd2920cd2007-03-21 17:27:53 +00005565 case 233:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005566#line 3068 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005567 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5568 break;
5569
Reid Spencerd2920cd2007-03-21 17:27:53 +00005570 case 234:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005571#line 3068 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005572 {
5573 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005574 CurFun.FunctionDone();
5575
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005576 ;}
5577 break;
5578
Reid Spencerd2920cd2007-03-21 17:27:53 +00005579 case 235:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005580#line 3080 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005581 { (yyval.BoolVal) = false; ;}
5582 break;
5583
Reid Spencerd2920cd2007-03-21 17:27:53 +00005584 case 236:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005585#line 3081 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005586 { (yyval.BoolVal) = true; ;}
5587 break;
5588
Reid Spencerd2920cd2007-03-21 17:27:53 +00005589 case 237:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005590#line 3086 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005591 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005592 break;
5593
Reid Spencerd2920cd2007-03-21 17:27:53 +00005594 case 238:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005595#line 3087 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005596 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5597 break;
5598
Reid Spencerd2920cd2007-03-21 17:27:53 +00005599 case 239:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005600#line 3088 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005601 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5602 break;
5603
Reid Spencerd2920cd2007-03-21 17:27:53 +00005604 case 240:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005605#line 3089 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005606 {
5607 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true));
5608 (yyval.ValIDVal).S.makeUnsigned();
5609 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005610 break;
5611
Reid Spencerd2920cd2007-03-21 17:27:53 +00005612 case 241:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005613#line 3093 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005614 {
5615 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false));
5616 (yyval.ValIDVal).S.makeUnsigned();
5617 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005618 break;
5619
Reid Spencerd2920cd2007-03-21 17:27:53 +00005620 case 242:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005621#line 3097 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005622 { (yyval.ValIDVal) = ValID::createNull(); ;}
5623 break;
5624
Reid Spencerd2920cd2007-03-21 17:27:53 +00005625 case 243:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005626#line 3098 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005627 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5628 break;
5629
Reid Spencerd2920cd2007-03-21 17:27:53 +00005630 case 244:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005631#line 3099 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005632 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5633 break;
5634
Reid Spencerd2920cd2007-03-21 17:27:53 +00005635 case 245:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005636#line 3100 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005637 { // Nonempty unsized packed vector
5638 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5639 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005640 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005641 (yyval.ValIDVal).S.makeComposite((*(yyvsp[-1].ConstVector))[0].S);
5642 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S));
Reid Spencer950bf602007-01-26 08:19:09 +00005643
5644 // Verify all elements are correct type!
5645 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005646 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5647 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005648 const Type *CTy = C->getType();
5649 if (ETy != CTy)
5650 error("Element #" + utostr(i) + " is not of type '" +
5651 ETy->getDescription() +"' as required!\nIt is of type '" +
5652 CTy->getDescription() + "'");
5653 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005654 }
Reid Spencer5eb77c72007-03-15 03:26:42 +00005655 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005656 delete PTy; delete (yyvsp[-1].ConstVector);
5657 ;}
5658 break;
5659
Reid Spencerd2920cd2007-03-21 17:27:53 +00005660 case 246:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005661#line 3121 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005662 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005663 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005664 (yyval.ValIDVal).S.copy((yyvsp[0].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005665 ;}
5666 break;
5667
Reid Spencerd2920cd2007-03-21 17:27:53 +00005668 case 247:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005669#line 3125 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005670 {
5671 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5672 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5673 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5674 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5675 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5676 free((yyvsp[-2].StrVal));
5677 free((yyvsp[0].StrVal));
5678 ;}
5679 break;
5680
Reid Spencerd2920cd2007-03-21 17:27:53 +00005681 case 248:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005682#line 3139 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005683 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005684 break;
5685
Reid Spencerd2920cd2007-03-21 17:27:53 +00005686 case 249:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005687#line 3140 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005688 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005689 break;
5690
Reid Spencerd2920cd2007-03-21 17:27:53 +00005691 case 252:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005692#line 3153 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005693 {
5694 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005695 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer5eb77c72007-03-15 03:26:42 +00005696 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005697 (yyval.ValueVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005698 delete (yyvsp[-1].TypeVal).PAT;
5699 ;}
5700 break;
5701
Reid Spencerd2920cd2007-03-21 17:27:53 +00005702 case 253:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005703#line 3163 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005704 {
5705 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5706 ;}
5707 break;
5708
Reid Spencerd2920cd2007-03-21 17:27:53 +00005709 case 254:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005710#line 3166 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005711 { // Do not allow functions with 0 basic blocks
5712 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5713 ;}
5714 break;
5715
Reid Spencerd2920cd2007-03-21 17:27:53 +00005716 case 255:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005717#line 3175 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005718 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005719 ValueInfo VI; VI.V = (yyvsp[0].TermInstVal).TI; VI.S.copy((yyvsp[0].TermInstVal).S);
5720 setValueName(VI, (yyvsp[-1].StrVal));
5721 InsertValue((yyvsp[0].TermInstVal).TI);
5722 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal).TI);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005723 InsertValue((yyvsp[-2].BasicBlockVal));
5724 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5725 ;}
5726 break;
5727
Reid Spencerd2920cd2007-03-21 17:27:53 +00005728 case 256:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005729#line 3186 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005730 {
5731 if ((yyvsp[0].InstVal).I)
5732 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5733 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5734 ;}
5735 break;
5736
Reid Spencerd2920cd2007-03-21 17:27:53 +00005737 case 257:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005738#line 3191 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005739 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005740 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
Reid Spencer950bf602007-01-26 08:19:09 +00005741 // Make sure to move the basic block to the correct location in the
5742 // function, instead of leaving it inserted wherever it was first
5743 // referenced.
5744 Function::BasicBlockListType &BBL =
5745 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005746 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5747 ;}
5748 break;
5749
Reid Spencerd2920cd2007-03-21 17:27:53 +00005750 case 258:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005751#line 3200 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005752 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005753 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005754 // Make sure to move the basic block to the correct location in the
5755 // function, instead of leaving it inserted wherever it was first
5756 // referenced.
5757 Function::BasicBlockListType &BBL =
5758 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005759 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5760 ;}
5761 break;
5762
Reid Spencerd2920cd2007-03-21 17:27:53 +00005763 case 261:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005764#line 3214 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005765 { // Return with a result...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005766 (yyval.TermInstVal).TI = new ReturnInst((yyvsp[0].ValueVal).V);
5767 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005768 ;}
5769 break;
5770
Reid Spencerd2920cd2007-03-21 17:27:53 +00005771 case 262:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005772#line 3218 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005773 { // Return with no result...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005774 (yyval.TermInstVal).TI = new ReturnInst();
5775 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005776 ;}
5777 break;
5778
Reid Spencerd2920cd2007-03-21 17:27:53 +00005779 case 263:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005780#line 3222 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005781 { // Unconditional Branch...
5782 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005783 (yyval.TermInstVal).TI = new BranchInst(tmpBB);
5784 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005785 ;}
5786 break;
5787
Reid Spencerd2920cd2007-03-21 17:27:53 +00005788 case 264:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005789#line 3227 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005790 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005791 (yyvsp[-3].ValIDVal).S.makeSignless();
5792 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005793 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5794 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005795 (yyvsp[-6].ValIDVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005796 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005797 (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5798 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005799 ;}
5800 break;
5801
Reid Spencerd2920cd2007-03-21 17:27:53 +00005802 case 265:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005803#line 3237 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005804 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005805 (yyvsp[-6].ValIDVal).S.copy((yyvsp[-7].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005806 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005807 (yyvsp[-3].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005808 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5809 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00005810 (yyval.TermInstVal).TI = S;
5811 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005812 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5813 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005814 for (; I != E; ++I) {
5815 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5816 S->addCase(CI, I->second);
5817 else
5818 error("Switch case is constant, but not a simple integer");
5819 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005820 delete (yyvsp[-1].JumpTable);
5821 ;}
5822 break;
5823
Reid Spencerd2920cd2007-03-21 17:27:53 +00005824 case 266:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005825#line 3255 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005826 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005827 (yyvsp[-5].ValIDVal).S.copy((yyvsp[-6].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005828 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005829 (yyvsp[-2].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005830 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005831 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005832 (yyval.TermInstVal).TI = S;
5833 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005834 ;}
5835 break;
5836
Reid Spencerd2920cd2007-03-21 17:27:53 +00005837 case 267:
Reid Spencer8166a6c2007-04-02 02:08:35 +00005838#line 3265 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005839 {
Reid Spencer950bf602007-01-26 08:19:09 +00005840 const PointerType *PFTy;
5841 const FunctionType *Ty;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005842 Signedness FTySign;
Reid Spencer950bf602007-01-26 08:19:09 +00005843
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005844 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005845 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5846 // Pull out the types of all of the arguments...
5847 std::vector<const Type*> ParamTypes;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005848 FTySign.makeComposite((yyvsp[-10].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005849 if ((yyvsp[-7].ValueList)) {
5850 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005851 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005852 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00005853 FTySign.add(I->S);
5854 }
Reid Spencer950bf602007-01-26 08:19:09 +00005855 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005856 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005857 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00005858 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5859 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5860 }
Reid Spencer950bf602007-01-26 08:19:09 +00005861 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5862 if (isVarArg) ParamTypes.pop_back();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005863 Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005864 PFTy = PointerType::get(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005865 (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S);
5866 } else {
5867 FTySign = (yyvsp[-10].TypeVal).S;
Reid Spencera3b12dd2007-04-07 16:14:01 +00005868 // Get the signedness of the result type. $3 is the pointer to the
5869 // function type so we get the 0th element to extract the function type,
5870 // and then the 0th element again to get the result type.
5871 (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S.get(0).get(0));
Reid Spencer950bf602007-01-26 08:19:09 +00005872 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005873 (yyvsp[-9].ValIDVal).S.makeComposite(FTySign);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005874 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5875 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5876 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005877
5878 // Create the call node...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005879 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencerbb1fd572007-03-21 17:15:50 +00005880 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0);
Reid Spencer950bf602007-01-26 08:19:09 +00005881 } else { // Has arguments?
5882 // Loop through FunctionType's arguments and ensure they are specified
5883 // correctly!
5884 //
5885 FunctionType::param_iterator I = Ty->param_begin();
5886 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005887 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005888
5889 std::vector<Value*> Args;
5890 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5891 if ((*ArgI).V->getType() != *I)
5892 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5893 (*I)->getDescription() + "'");
5894 Args.push_back((*ArgI).V);
5895 }
5896
5897 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5898 error("Invalid number of parameters detected");
5899
Reid Spencerbb1fd572007-03-21 17:15:50 +00005900 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00005901 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005902 cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005903 delete (yyvsp[-10].TypeVal).PAT;
5904 delete (yyvsp[-7].ValueList);
5905 ;}
5906 break;
5907
Reid Spencerd2920cd2007-03-21 17:27:53 +00005908 case 268:
Reid Spencera3b12dd2007-04-07 16:14:01 +00005909#line 3332 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005910 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005911 (yyval.TermInstVal).TI = new UnwindInst();
5912 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005913 ;}
5914 break;
5915
Reid Spencerd2920cd2007-03-21 17:27:53 +00005916 case 269:
Reid Spencera3b12dd2007-04-07 16:14:01 +00005917#line 3336 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005918 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005919 (yyval.TermInstVal).TI = new UnreachableInst();
5920 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005921 ;}
5922 break;
5923
Reid Spencerd2920cd2007-03-21 17:27:53 +00005924 case 270:
Reid Spencera3b12dd2007-04-07 16:14:01 +00005925#line 3343 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005926 {
5927 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005928 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005929 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005930
5931 if (V == 0)
5932 error("May only switch on a constant pool value");
5933
Reid Spencerbb1fd572007-03-21 17:15:50 +00005934 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005935 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5936 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5937 ;}
5938 break;
5939
Reid Spencerd2920cd2007-03-21 17:27:53 +00005940 case 271:
Reid Spencera3b12dd2007-04-07 16:14:01 +00005941#line 3355 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005942 {
5943 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005944 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005945 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005946
5947 if (V == 0)
5948 error("May only switch on a constant pool value");
5949
Reid Spencerbb1fd572007-03-21 17:15:50 +00005950 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005951 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5952 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5953 ;}
5954 break;
5955
Reid Spencerd2920cd2007-03-21 17:27:53 +00005956 case 272:
Reid Spencera3b12dd2007-04-07 16:14:01 +00005957#line 3370 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005958 {
Reid Spencer950bf602007-01-26 08:19:09 +00005959 bool omit = false;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005960 if ((yyvsp[-1].StrVal))
5961 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005962 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005963 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005964 // This is a useless bit cast causing a name redefinition. It is
5965 // a bit cast from a type to the same type of an operand with the
5966 // same name as the name we would give this instruction. Since this
5967 // instruction results in no code generation, it is safe to omit
5968 // the instruction. This situation can occur because of collapsed
5969 // type planes. For example:
5970 // %X = add int %Y, %Z
5971 // %X = cast int %Y to uint
5972 // After upgrade, this looks like:
5973 // %X = add i32 %Y, %Z
5974 // %X = bitcast i32 to i32
5975 // The bitcast is clearly useless so we omit it.
5976 omit = true;
5977 if (omit) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005978 (yyval.InstVal).I = 0;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005979 (yyval.InstVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00005980 } else {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005981 ValueInfo VI; VI.V = (yyvsp[0].InstVal).I; VI.S.copy((yyvsp[0].InstVal).S);
5982 setValueName(VI, (yyvsp[-1].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005983 InsertValue((yyvsp[0].InstVal).I);
5984 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005985 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005986 ;}
5987 break;
5988
Reid Spencerd2920cd2007-03-21 17:27:53 +00005989 case 273:
Reid Spencera3b12dd2007-04-07 16:14:01 +00005990#line 3400 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005991 { // Used for PHI nodes
5992 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005993 (yyval.PHIList).S.copy((yyvsp[-5].TypeVal).S);
5994 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-5].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005995 Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005996 (yyvsp[-1].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005997 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5998 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5999 delete (yyvsp[-5].TypeVal).PAT;
6000 ;}
6001 break;
6002
Reid Spencerd2920cd2007-03-21 17:27:53 +00006003 case 274:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006004#line 3410 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006005 {
6006 (yyval.PHIList) = (yyvsp[-6].PHIList);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006007 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-6].PHIList).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006008 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006009 (yyvsp[-1].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006010 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
6011 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
6012 ;}
6013 break;
6014
Reid Spencerd2920cd2007-03-21 17:27:53 +00006015 case 275:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006016#line 3420 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006017 { // Used for call statements, and memory insts...
6018 (yyval.ValueList) = new std::vector<ValueInfo>();
6019 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
6020 ;}
6021 break;
6022
Reid Spencerd2920cd2007-03-21 17:27:53 +00006023 case 276:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006024#line 3424 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006025 {
6026 (yyval.ValueList) = (yyvsp[-2].ValueList);
6027 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
6028 ;}
6029 break;
6030
Reid Spencerd2920cd2007-03-21 17:27:53 +00006031 case 278:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006032#line 3432 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006033 { (yyval.ValueList) = 0; ;}
6034 break;
6035
Reid Spencerd2920cd2007-03-21 17:27:53 +00006036 case 279:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006037#line 3436 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006038 {
6039 (yyval.BoolVal) = true;
6040 ;}
6041 break;
6042
Reid Spencerd2920cd2007-03-21 17:27:53 +00006043 case 280:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006044#line 3439 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006045 {
6046 (yyval.BoolVal) = false;
6047 ;}
6048 break;
6049
Reid Spencerd2920cd2007-03-21 17:27:53 +00006050 case 281:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006051#line 3445 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006052 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006053 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6054 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006055 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006056 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
Reid Spencer950bf602007-01-26 08:19:09 +00006057 error("Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer9d6565a2007-02-15 02:26:10 +00006058 if (isa<VectorType>(Ty) &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006059 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Chris Lattner4227bdb2007-02-19 07:34:02 +00006060 error("Remainder not supported on vector types");
Reid Spencer950bf602007-01-26 08:19:09 +00006061 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006062 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
6063 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6064 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
6065 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
6066 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006067 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006068 (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006069 delete (yyvsp[-3].TypeVal).PAT;
6070 ;}
6071 break;
6072
Reid Spencerd2920cd2007-03-21 17:27:53 +00006073 case 282:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006074#line 3464 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006075 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006076 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6077 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006078 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006079 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00006080 if (!isa<VectorType>(Ty) ||
6081 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006082 error("Logical operator requires integral operands");
6083 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006084 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
6085 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6086 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6087 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
6088 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006089 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006090 (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006091 delete (yyvsp[-3].TypeVal).PAT;
6092 ;}
6093 break;
6094
Reid Spencerd2920cd2007-03-21 17:27:53 +00006095 case 283:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006096#line 3482 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006097 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006098 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6099 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006100 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006101 if(isa<VectorType>(Ty))
6102 error("VectorTypes currently not supported in setcc instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006103 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006104 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
6105 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6106 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6107 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
6108 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006109 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006110 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006111 delete (yyvsp[-3].TypeVal).PAT;
6112 ;}
6113 break;
6114
Reid Spencerd2920cd2007-03-21 17:27:53 +00006115 case 284:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006116#line 3498 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006117 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006118 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6119 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006120 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006121 if (isa<VectorType>(Ty))
6122 error("VectorTypes currently not supported in icmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006123 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
6124 error("icmp requires integer or pointer typed operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006125 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6126 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6127 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006128 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006129 delete (yyvsp[-3].TypeVal).PAT;
6130 ;}
6131 break;
6132
Reid Spencerd2920cd2007-03-21 17:27:53 +00006133 case 285:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006134#line 3512 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006135 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006136 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6137 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006138 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006139 if (isa<VectorType>(Ty))
6140 error("VectorTypes currently not supported in fcmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006141 else if (!Ty->isFloatingPoint())
6142 error("fcmp instruction requires floating point operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006143 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6144 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6145 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006146 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006147 delete (yyvsp[-3].TypeVal).PAT;
6148 ;}
6149 break;
6150
Reid Spencerd2920cd2007-03-21 17:27:53 +00006151 case 286:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006152#line 3526 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006153 {
Reid Spencer950bf602007-01-26 08:19:09 +00006154 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006155 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006156 Value *Ones = ConstantInt::getAllOnesValue(Ty);
6157 if (Ones == 0)
6158 error("Expected integral type for not instruction");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006159 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
6160 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006161 error("Could not create a xor instruction");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006162 (yyval.InstVal).S.copy((yyvsp[0].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006163 ;}
6164 break;
6165
Reid Spencerd2920cd2007-03-21 17:27:53 +00006166 case 287:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006167#line 3537 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006168 {
6169 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
6170 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00006171 error("Shift amount must be int8");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006172 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
Reid Spencer832254e2007-02-02 02:16:23 +00006173 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006174 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00006175 Value* ShiftAmt = 0;
6176 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006177 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
Reid Spencer832254e2007-02-02 02:16:23 +00006178 ShiftAmt = ConstantExpr::getZExt(C, Ty);
6179 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006180 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
Reid Spencer832254e2007-02-02 02:16:23 +00006181 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006182 ShiftAmt = (yyvsp[0].ValueVal).V;
6183 (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[-3].BinaryOpVal), Ty, (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, ShiftAmt);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006184 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006185 ;}
6186 break;
6187
Reid Spencerd2920cd2007-03-21 17:27:53 +00006188 case 288:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006189#line 3555 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006190 {
6191 const Type *DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006192 if (!DstTy->isFirstClassType())
6193 error("cast instruction to a non-primitive type: '" +
6194 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006195 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006196 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006197 delete (yyvsp[0].TypeVal).PAT;
6198 ;}
6199 break;
6200
Reid Spencerd2920cd2007-03-21 17:27:53 +00006201 case 289:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006202#line 3564 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006203 {
6204 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
6205 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00006206 error("select condition must be bool");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006207 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00006208 error("select value types should match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006209 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006210 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006211 ;}
6212 break;
6213
Reid Spencerd2920cd2007-03-21 17:27:53 +00006214 case 290:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006215#line 3573 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006216 {
6217 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006218 NewVarArgs = true;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006219 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006220 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006221 delete (yyvsp[0].TypeVal).PAT;
6222 ;}
6223 break;
6224
Reid Spencerd2920cd2007-03-21 17:27:53 +00006225 case 291:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006226#line 3580 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006227 {
6228 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
6229 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006230 ObsoleteVarArgs = true;
6231 Function* NF = cast<Function>(CurModule.CurrentModule->
6232 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6233
6234 //b = vaarg a, t ->
6235 //foo = alloca 1 of t
6236 //bar = vacopy a
6237 //store bar -> foo
6238 //b = vaarg foo, t
6239 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
6240 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006241 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006242 CurBB->getInstList().push_back(bar);
6243 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006244 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006245 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006246 delete (yyvsp[0].TypeVal).PAT;
6247 ;}
6248 break;
6249
Reid Spencerd2920cd2007-03-21 17:27:53 +00006250 case 292:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006251#line 3601 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006252 {
6253 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
6254 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006255 ObsoleteVarArgs = true;
6256 Function* NF = cast<Function>(CurModule.CurrentModule->
6257 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6258
6259 //b = vanext a, t ->
6260 //foo = alloca 1 of t
6261 //bar = vacopy a
6262 //store bar -> foo
6263 //tmp = vaarg foo, t
6264 //b = load foo
6265 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
6266 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006267 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006268 CurBB->getInstList().push_back(bar);
6269 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6270 Instruction* tmp = new VAArgInst(foo, DstTy);
6271 CurBB->getInstList().push_back(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006272 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006273 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006274 delete (yyvsp[0].TypeVal).PAT;
6275 ;}
6276 break;
6277
Reid Spencerd2920cd2007-03-21 17:27:53 +00006278 case 293:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006279#line 3625 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006280 {
6281 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006282 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006283 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006284 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006285 ;}
6286 break;
6287
Reid Spencerd2920cd2007-03-21 17:27:53 +00006288 case 294:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006289#line 3631 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006290 {
6291 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006292 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006293 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006294 (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006295 ;}
6296 break;
6297
Reid Spencerd2920cd2007-03-21 17:27:53 +00006298 case 295:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006299#line 3637 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006300 {
6301 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006302 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006303 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006304 (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006305 ;}
6306 break;
6307
Reid Spencerd2920cd2007-03-21 17:27:53 +00006308 case 296:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006309#line 3643 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006310 {
6311 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006312 if (!Ty->isFirstClassType())
6313 error("PHI node operands must be of first class type");
6314 PHINode *PHI = new PHINode(Ty);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006315 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
6316 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
6317 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00006318 error("All elements of a PHI node must be of the same type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006319 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
6320 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00006321 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006322 (yyval.InstVal).I = PHI;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006323 (yyval.InstVal).S.copy((yyvsp[0].PHIList).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006324 delete (yyvsp[0].PHIList).P; // Free the list...
6325 ;}
6326 break;
Reid Spencer950bf602007-01-26 08:19:09 +00006327
Reid Spencerd2920cd2007-03-21 17:27:53 +00006328 case 297:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006329#line 3659 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006330 {
Reid Spencer950bf602007-01-26 08:19:09 +00006331 // Handle the short call syntax
6332 const PointerType *PFTy;
6333 const FunctionType *FTy;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006334 Signedness FTySign;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006335 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006336 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6337 // Pull out the types of all of the arguments...
6338 std::vector<const Type*> ParamTypes;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006339 FTySign.makeComposite((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006340 if ((yyvsp[-1].ValueList)) {
6341 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006342 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00006343 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006344 FTySign.add(I->S);
6345 }
Reid Spencer950bf602007-01-26 08:19:09 +00006346 }
6347
Reid Spencerb7046c72007-01-29 05:41:34 +00006348 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006349 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00006350 ParamAttrs.push_back(FunctionType::NoAttributeSet);
6351 ParamAttrs.push_back(FunctionType::StructRetAttribute);
6352 }
Reid Spencer950bf602007-01-26 08:19:09 +00006353 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6354 if (isVarArg) ParamTypes.pop_back();
6355
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006356 const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006357 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6358 error("Functions cannot return aggregate types");
6359
Reid Spencerb7046c72007-01-29 05:41:34 +00006360 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00006361 PFTy = PointerType::get(FTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006362 (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S);
6363 } else {
6364 FTySign = (yyvsp[-4].TypeVal).S;
Reid Spencera3b12dd2007-04-07 16:14:01 +00006365 // Get the signedness of the result type. $3 is the pointer to the
6366 // function type so we get the 0th element to extract the function type,
6367 // and then the 0th element again to get the result type.
6368 (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S.get(0).get(0));
Reid Spencer950bf602007-01-26 08:19:09 +00006369 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00006370 (yyvsp[-3].ValIDVal).S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00006371
6372 // First upgrade any intrinsic calls.
6373 std::vector<Value*> Args;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006374 if ((yyvsp[-1].ValueList))
6375 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
6376 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
Reid Spencer41b213e2007-04-02 01:14:00 +00006377 Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006378
6379 // If we got an upgraded intrinsic
6380 if (Inst) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006381 (yyval.InstVal).I = Inst;
Reid Spencer950bf602007-01-26 08:19:09 +00006382 } else {
6383 // Get the function we're calling
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006384 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006385
6386 // Check the argument values match
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006387 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006388 // Make sure no arguments is a good thing!
6389 if (FTy->getNumParams() != 0)
6390 error("No arguments passed to a function that expects arguments");
6391 } else { // Has arguments?
6392 // Loop through FunctionType's arguments and ensure they are specified
6393 // correctly!
6394 //
6395 FunctionType::param_iterator I = FTy->param_begin();
6396 FunctionType::param_iterator E = FTy->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006397 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006398
6399 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6400 if ((*ArgI).V->getType() != *I)
6401 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6402 (*I)->getDescription() + "'");
6403
6404 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6405 error("Invalid number of parameters detected");
6406 }
6407
6408 // Create the call instruction
Chris Lattnercf3d0612007-02-13 06:04:17 +00006409 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006410 CI->setTailCall((yyvsp[-6].BoolVal));
6411 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
6412 (yyval.InstVal).I = CI;
Reid Spencer950bf602007-01-26 08:19:09 +00006413 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006414 delete (yyvsp[-4].TypeVal).PAT;
6415 delete (yyvsp[-1].ValueList);
6416 ;}
6417 break;
6418
Reid Spencerd2920cd2007-03-21 17:27:53 +00006419 case 298:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006420#line 3746 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006421 {
6422 (yyval.InstVal) = (yyvsp[0].InstVal);
6423 ;}
6424 break;
6425
Reid Spencerd2920cd2007-03-21 17:27:53 +00006426 case 299:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006427#line 3754 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006428 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
6429 break;
6430
Reid Spencerd2920cd2007-03-21 17:27:53 +00006431 case 300:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006432#line 3755 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006433 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6434 break;
6435
Reid Spencerd2920cd2007-03-21 17:27:53 +00006436 case 301:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006437#line 3759 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006438 { (yyval.BoolVal) = true; ;}
6439 break;
6440
Reid Spencerd2920cd2007-03-21 17:27:53 +00006441 case 302:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006442#line 3760 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006443 { (yyval.BoolVal) = false; ;}
6444 break;
6445
Reid Spencerd2920cd2007-03-21 17:27:53 +00006446 case 303:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006447#line 3764 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006448 {
6449 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006450 (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006451 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6452 delete (yyvsp[-1].TypeVal).PAT;
6453 ;}
6454 break;
6455
Reid Spencerd2920cd2007-03-21 17:27:53 +00006456 case 304:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006457#line 3770 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006458 {
6459 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006460 (yyvsp[-1].ValIDVal).S.makeUnsigned();
6461 (yyval.InstVal).S.makeComposite((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006462 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6463 delete (yyvsp[-4].TypeVal).PAT;
6464 ;}
6465 break;
6466
Reid Spencerd2920cd2007-03-21 17:27:53 +00006467 case 305:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006468#line 3777 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006469 {
6470 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006471 (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006472 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6473 delete (yyvsp[-1].TypeVal).PAT;
6474 ;}
6475 break;
6476
Reid Spencerd2920cd2007-03-21 17:27:53 +00006477 case 306:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006478#line 3783 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006479 {
6480 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006481 (yyvsp[-1].ValIDVal).S.makeUnsigned();
6482 (yyval.InstVal).S.makeComposite((yyvsp[-2].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006483 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6484 delete (yyvsp[-4].TypeVal).PAT;
6485 ;}
6486 break;
6487
Reid Spencerd2920cd2007-03-21 17:27:53 +00006488 case 307:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006489#line 3790 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006490 {
6491 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006492 if (!isa<PointerType>(PTy))
6493 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006494 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006495 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006496 ;}
6497 break;
6498
Reid Spencerd2920cd2007-03-21 17:27:53 +00006499 case 308:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006500#line 3797 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006501 {
6502 const Type* Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006503 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00006504 if (!isa<PointerType>(Ty))
6505 error("Can't load from nonpointer type: " + Ty->getDescription());
6506 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6507 error("Can't load from pointer of non-first-class type: " +
6508 Ty->getDescription());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006509 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6510 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006511 (yyval.InstVal).S.copy((yyvsp[-1].TypeVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006512 delete (yyvsp[-1].TypeVal).PAT;
6513 ;}
6514 break;
6515
Reid Spencerd2920cd2007-03-21 17:27:53 +00006516 case 309:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006517#line 3810 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006518 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006519 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006520 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencered96d1e2007-02-08 09:08:52 +00006521 if (!PTy)
6522 error("Can't store to a nonpointer type: " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006523 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencered96d1e2007-02-08 09:08:52 +00006524 const Type *ElTy = PTy->getElementType();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006525 Value *StoreVal = (yyvsp[-3].ValueVal).V;
6526 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6527 if (ElTy != (yyvsp[-3].ValueVal).V->getType()) {
6528 StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy);
Reid Spencered96d1e2007-02-08 09:08:52 +00006529 if (!StoreVal)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006530 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencered96d1e2007-02-08 09:08:52 +00006531 "' into space of type '" + ElTy->getDescription() + "'");
6532 else {
6533 PTy = PointerType::get(StoreVal->getType());
6534 if (Constant *C = dyn_cast<Constant>(tmpVal))
6535 tmpVal = ConstantExpr::getBitCast(C, PTy);
6536 else
6537 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6538 }
6539 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006540 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006541 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006542 delete (yyvsp[-1].TypeVal).PAT;
6543 ;}
6544 break;
6545
Reid Spencerd2920cd2007-03-21 17:27:53 +00006546 case 310:
Reid Spencera3b12dd2007-04-07 16:14:01 +00006547#line 3836 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006548 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006549 (yyvsp[-1].ValIDVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006550 const Type* Ty = (yyvsp[-2].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006551 if (!isa<PointerType>(Ty))
6552 error("getelementptr insn requires pointer operand");
6553
6554 std::vector<Value*> VIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006555 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006556
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006557 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
6558 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006559 ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[-2].TypeVal).S);
6560 (yyval.InstVal).S.copy(getElementSign(VI, VIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006561 delete (yyvsp[-2].TypeVal).PAT;
6562 delete (yyvsp[0].ValueList);
6563 ;}
6564 break;
6565
6566
6567 default: break;
6568 }
6569
6570/* Line 1126 of yacc.c. */
Reid Spencera3b12dd2007-04-07 16:14:01 +00006571#line 6572 "UpgradeParser.tab.c"
Chris Lattnercf3d0612007-02-13 06:04:17 +00006572
6573 yyvsp -= yylen;
6574 yyssp -= yylen;
Reid Spencerb7046c72007-01-29 05:41:34 +00006575
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006576
6577 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006578
6579 *++yyvsp = yyval;
6580
6581
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006582 /* Now `shift' the result of the reduction. Determine what state
6583 that goes to, based on the state we popped back to and the rule
6584 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006585
6586 yyn = yyr1[yyn];
6587
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006588 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6589 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006590 yystate = yytable[yystate];
6591 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006592 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006593
6594 goto yynewstate;
6595
6596
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006597/*------------------------------------.
6598| yyerrlab -- here on detecting error |
6599`------------------------------------*/
6600yyerrlab:
6601 /* If not already recovering from an error, report this error. */
6602 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006603 {
6604 ++yynerrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006605#if YYERROR_VERBOSE
Chris Lattnercf3d0612007-02-13 06:04:17 +00006606 yyn = yypact[yystate];
6607
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006608 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006609 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006610 int yytype = YYTRANSLATE (yychar);
6611 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6612 YYSIZE_T yysize = yysize0;
6613 YYSIZE_T yysize1;
6614 int yysize_overflow = 0;
6615 char *yymsg = 0;
6616# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6617 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6618 int yyx;
Chris Lattnercf3d0612007-02-13 06:04:17 +00006619
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006620#if 0
6621 /* This is so xgettext sees the translatable formats that are
6622 constructed on the fly. */
6623 YY_("syntax error, unexpected %s");
6624 YY_("syntax error, unexpected %s, expecting %s");
6625 YY_("syntax error, unexpected %s, expecting %s or %s");
6626 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6627 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6628#endif
6629 char *yyfmt;
6630 char const *yyf;
6631 static char const yyunexpected[] = "syntax error, unexpected %s";
6632 static char const yyexpecting[] = ", expecting %s";
6633 static char const yyor[] = " or %s";
6634 char yyformat[sizeof yyunexpected
6635 + sizeof yyexpecting - 1
6636 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6637 * (sizeof yyor - 1))];
6638 char const *yyprefix = yyexpecting;
6639
6640 /* Start YYX at -YYN if negative to avoid negative indexes in
6641 YYCHECK. */
6642 int yyxbegin = yyn < 0 ? -yyn : 0;
6643
6644 /* Stay within bounds of both yycheck and yytname. */
6645 int yychecklim = YYLAST - yyn;
6646 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6647 int yycount = 1;
6648
6649 yyarg[0] = yytname[yytype];
6650 yyfmt = yystpcpy (yyformat, yyunexpected);
6651
6652 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6653 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6654 {
6655 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6656 {
6657 yycount = 1;
6658 yysize = yysize0;
6659 yyformat[sizeof yyunexpected - 1] = '\0';
6660 break;
6661 }
6662 yyarg[yycount++] = yytname[yyx];
6663 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6664 yysize_overflow |= yysize1 < yysize;
6665 yysize = yysize1;
6666 yyfmt = yystpcpy (yyfmt, yyprefix);
6667 yyprefix = yyor;
6668 }
6669
6670 yyf = YY_(yyformat);
6671 yysize1 = yysize + yystrlen (yyf);
6672 yysize_overflow |= yysize1 < yysize;
6673 yysize = yysize1;
6674
6675 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6676 yymsg = (char *) YYSTACK_ALLOC (yysize);
6677 if (yymsg)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006678 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006679 /* Avoid sprintf, as that infringes on the user's name space.
6680 Don't have undefined behavior even if the translation
6681 produced a string with the wrong number of "%s"s. */
6682 char *yyp = yymsg;
6683 int yyi = 0;
6684 while ((*yyp = *yyf))
Chris Lattnercf3d0612007-02-13 06:04:17 +00006685 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006686 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6687 {
6688 yyp += yytnamerr (yyp, yyarg[yyi++]);
6689 yyf += 2;
6690 }
6691 else
6692 {
6693 yyp++;
6694 yyf++;
6695 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006696 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006697 yyerror (yymsg);
6698 YYSTACK_FREE (yymsg);
Chris Lattnercf3d0612007-02-13 06:04:17 +00006699 }
6700 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006701 {
6702 yyerror (YY_("syntax error"));
6703 goto yyexhaustedlab;
6704 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006705 }
6706 else
6707#endif /* YYERROR_VERBOSE */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006708 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006709 }
Reid Spencer950bf602007-01-26 08:19:09 +00006710
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006711
Reid Spencer950bf602007-01-26 08:19:09 +00006712
6713 if (yyerrstatus == 3)
6714 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006715 /* If just tried and failed to reuse look-ahead token after an
6716 error, discard it. */
Reid Spencer950bf602007-01-26 08:19:09 +00006717
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006718 if (yychar <= YYEOF)
6719 {
6720 /* Return failure if at end of input. */
6721 if (yychar == YYEOF)
6722 YYABORT;
6723 }
6724 else
6725 {
6726 yydestruct ("Error: discarding", yytoken, &yylval);
6727 yychar = YYEMPTY;
6728 }
6729 }
6730
6731 /* Else will try to reuse look-ahead token after shifting the error
6732 token. */
6733 goto yyerrlab1;
6734
6735
6736/*---------------------------------------------------.
6737| yyerrorlab -- error raised explicitly by YYERROR. |
6738`---------------------------------------------------*/
6739yyerrorlab:
6740
6741 /* Pacify compilers like GCC when the user code never invokes
6742 YYERROR and the label yyerrorlab therefore never appears in user
6743 code. */
6744 if (0)
6745 goto yyerrorlab;
6746
6747yyvsp -= yylen;
6748 yyssp -= yylen;
6749 yystate = *yyssp;
6750 goto yyerrlab1;
6751
6752
6753/*-------------------------------------------------------------.
6754| yyerrlab1 -- common code for both syntax error and YYERROR. |
6755`-------------------------------------------------------------*/
6756yyerrlab1:
6757 yyerrstatus = 3; /* Each real token shifted decrements this. */
6758
6759 for (;;)
6760 {
6761 yyn = yypact[yystate];
6762 if (yyn != YYPACT_NINF)
6763 {
6764 yyn += YYTERROR;
6765 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6766 {
6767 yyn = yytable[yyn];
6768 if (0 < yyn)
6769 break;
6770 }
6771 }
6772
6773 /* Pop the current state because it cannot handle the error token. */
6774 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006775 YYABORT;
6776
6777
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006778 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6779 YYPOPSTACK;
6780 yystate = *yyssp;
6781 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006782 }
6783
6784 if (yyn == YYFINAL)
6785 YYACCEPT;
6786
6787 *++yyvsp = yylval;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006788
6789
6790 /* Shift the error token. */
6791 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer950bf602007-01-26 08:19:09 +00006792
Reid Spencere7c3c602006-11-30 06:36:44 +00006793 yystate = yyn;
6794 goto yynewstate;
6795
Chris Lattner4227bdb2007-02-19 07:34:02 +00006796
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006797/*-------------------------------------.
6798| yyacceptlab -- YYACCEPT comes here. |
6799`-------------------------------------*/
6800yyacceptlab:
6801 yyresult = 0;
6802 goto yyreturn;
6803
6804/*-----------------------------------.
6805| yyabortlab -- YYABORT comes here. |
6806`-----------------------------------*/
6807yyabortlab:
6808 yyresult = 1;
6809 goto yyreturn;
6810
6811#ifndef yyoverflow
6812/*-------------------------------------------------.
6813| yyexhaustedlab -- memory exhaustion comes here. |
6814`-------------------------------------------------*/
6815yyexhaustedlab:
6816 yyerror (YY_("memory exhausted"));
6817 yyresult = 2;
6818 /* Fall through. */
Chris Lattner4227bdb2007-02-19 07:34:02 +00006819#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006820
6821yyreturn:
6822 if (yychar != YYEOF && yychar != YYEMPTY)
6823 yydestruct ("Cleanup: discarding lookahead",
6824 yytoken, &yylval);
6825 while (yyssp != yyss)
6826 {
6827 yydestruct ("Cleanup: popping",
6828 yystos[*yyssp], yyvsp);
6829 YYPOPSTACK;
Chris Lattner4227bdb2007-02-19 07:34:02 +00006830 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006831#ifndef yyoverflow
6832 if (yyss != yyssa)
6833 YYSTACK_FREE (yyss);
6834#endif
6835 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006836}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006837
6838
Reid Spencera3b12dd2007-04-07 16:14:01 +00006839#line 3854 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006840
6841
6842int yyerror(const char *ErrorMsg) {
6843 std::string where
6844 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006845 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006846 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6847 if (yychar != YYEMPTY && yychar != 0)
6848 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6849 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006850 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006851 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006852 exit(1);
6853}
Reid Spencer319a7302007-01-05 17:20:02 +00006854
Reid Spencer30d0c582007-01-15 00:26:18 +00006855void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006856 std::string where
6857 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006858 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006859 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6860 if (yychar != YYEMPTY && yychar != 0)
6861 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6862 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006863 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6864}
6865
Reid Spencer950bf602007-01-26 08:19:09 +00006866void error(const std::string& ErrorMsg, int LineNo) {
6867 if (LineNo == -1) LineNo = Upgradelineno;
6868 Upgradelineno = LineNo;
6869 yyerror(ErrorMsg.c_str());
6870}
6871
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006872