blob: 93d91d328316d53b690063afdd6ce7766340bf2d [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 : "";
1811 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1812 if (Args.size() != 2)
1813 error("Invalid prototype for " + Name + " prototype");
1814 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1815 } else {
Reid Spencer950bf602007-01-26 08:19:09 +00001816 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1817 std::vector<const Type*> Params;
1818 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1819 if (Args.size() != 1)
1820 error("Invalid prototype for " + Name + " prototype");
1821 Params.push_back(PtrTy);
1822 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1823 const PointerType *PFTy = PointerType::get(FTy);
1824 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001825 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
Chris Lattnercf3d0612007-02-13 06:04:17 +00001826 return new CallInst(Func, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00001827 } else if (Name == "llvm.va_copy") {
1828 if (Args.size() != 2)
1829 error("Invalid prototype for " + Name + " prototype");
1830 Params.push_back(PtrTy);
1831 Params.push_back(PtrTy);
1832 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1833 const PointerType *PFTy = PointerType::get(FTy);
1834 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001835 std::string InstName0(makeNameUnique("va0"));
1836 std::string InstName1(makeNameUnique("va1"));
Reid Spencer950bf602007-01-26 08:19:09 +00001837 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1838 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
Chris Lattnercf3d0612007-02-13 06:04:17 +00001839 return new CallInst(Func, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00001840 }
1841 }
1842 return 0;
1843}
1844
1845const Type* upgradeGEPIndices(const Type* PTy,
1846 std::vector<ValueInfo> *Indices,
1847 std::vector<Value*> &VIndices,
1848 std::vector<Constant*> *CIndices = 0) {
1849 // Traverse the indices with a gep_type_iterator so we can build the list
1850 // of constant and value indices for use later. Also perform upgrades
1851 VIndices.clear();
1852 if (CIndices) CIndices->clear();
1853 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1854 VIndices.push_back((*Indices)[i].V);
1855 generic_gep_type_iterator<std::vector<Value*>::iterator>
1856 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1857 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1858 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1859 Value *Index = VIndices[i];
1860 if (CIndices && !isa<Constant>(Index))
1861 error("Indices to constant getelementptr must be constants");
1862 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1863 // struct indices to i32 struct indices with ZExt for compatibility.
1864 else if (isa<StructType>(*GTI)) { // Only change struct indices
1865 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1866 if (CUI->getType()->getBitWidth() == 8)
1867 Index =
1868 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1869 } else {
1870 // Make sure that unsigned SequentialType indices are zext'd to
1871 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1872 // all indices for SequentialType elements. We must retain the same
1873 // semantic (zext) for unsigned types.
1874 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencerbb1fd572007-03-21 17:15:50 +00001875 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001876 if (CIndices)
1877 Index = ConstantExpr::getCast(Instruction::ZExt,
1878 cast<Constant>(Index), Type::Int64Ty);
1879 else
1880 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001881 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001882 VIndices[i] = Index;
1883 }
Reid Spencer950bf602007-01-26 08:19:09 +00001884 }
1885 // Add to the CIndices list, if requested.
1886 if (CIndices)
1887 CIndices->push_back(cast<Constant>(Index));
1888 }
1889
1890 const Type *IdxTy =
Chris Lattner1bc3fa62007-02-12 22:58:38 +00001891 GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true);
Reid Spencer950bf602007-01-26 08:19:09 +00001892 if (!IdxTy)
1893 error("Index list invalid for constant getelementptr");
1894 return IdxTy;
1895}
1896
Reid Spencerb7046c72007-01-29 05:41:34 +00001897unsigned upgradeCallingConv(unsigned CC) {
1898 switch (CC) {
1899 case OldCallingConv::C : return CallingConv::C;
1900 case OldCallingConv::CSRet : return CallingConv::C;
1901 case OldCallingConv::Fast : return CallingConv::Fast;
1902 case OldCallingConv::Cold : return CallingConv::Cold;
1903 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1904 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1905 default:
1906 return CC;
1907 }
1908}
1909
Reid Spencer950bf602007-01-26 08:19:09 +00001910Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1911 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001912{
1913 Upgradelineno = 1;
1914 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001915 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001916 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001917 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001918 ObsoleteVarArgs = false;
1919 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001920
Reid Spencer950bf602007-01-26 08:19:09 +00001921 CurModule.CurrentModule = new Module(CurFilename);
1922
1923 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001924 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001925 if (ParserResult)
1926 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001927 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001928 return 0;
1929 }
1930
Reid Spencer950bf602007-01-26 08:19:09 +00001931 // Check to make sure that parsing produced a result
1932 if (!ParserResult) {
1933 std::cerr << "llvm-upgrade: no parse result.\n";
1934 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001935 }
1936
Reid Spencer950bf602007-01-26 08:19:09 +00001937 // Reset ParserResult variable while saving its value for the result.
1938 Module *Result = ParserResult;
1939 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001940
Reid Spencer950bf602007-01-26 08:19:09 +00001941 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001942 {
Reid Spencer950bf602007-01-26 08:19:09 +00001943 Function* F;
Reid Spencer688b0492007-02-05 21:19:13 +00001944 if ((F = Result->getFunction("llvm.va_start"))
Reid Spencer950bf602007-01-26 08:19:09 +00001945 && F->getFunctionType()->getNumParams() == 0)
1946 ObsoleteVarArgs = true;
Reid Spencer688b0492007-02-05 21:19:13 +00001947 if((F = Result->getFunction("llvm.va_copy"))
Reid Spencer950bf602007-01-26 08:19:09 +00001948 && F->getFunctionType()->getNumParams() == 1)
1949 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001950 }
Reid Spencer319a7302007-01-05 17:20:02 +00001951
Reid Spencer950bf602007-01-26 08:19:09 +00001952 if (ObsoleteVarArgs && NewVarArgs) {
1953 error("This file is corrupt: it uses both new and old style varargs");
1954 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001955 }
Reid Spencer319a7302007-01-05 17:20:02 +00001956
Reid Spencer950bf602007-01-26 08:19:09 +00001957 if(ObsoleteVarArgs) {
Reid Spencer688b0492007-02-05 21:19:13 +00001958 if(Function* F = Result->getFunction("llvm.va_start")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001959 if (F->arg_size() != 0) {
1960 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001961 return 0;
1962 }
Reid Spencer950bf602007-01-26 08:19:09 +00001963
1964 //foo = va_start()
1965 // ->
1966 //bar = alloca typeof(foo)
1967 //va_start(bar)
1968 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001969
Reid Spencer950bf602007-01-26 08:19:09 +00001970 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1971 const Type* ArgTy = F->getFunctionType()->getReturnType();
1972 const Type* ArgTyPtr = PointerType::get(ArgTy);
1973 Function* NF = cast<Function>(Result->getOrInsertFunction(
1974 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1975
1976 while (!F->use_empty()) {
1977 CallInst* CI = cast<CallInst>(F->use_back());
1978 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1979 new CallInst(NF, bar, "", CI);
1980 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1981 CI->replaceAllUsesWith(foo);
1982 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001983 }
Reid Spencer950bf602007-01-26 08:19:09 +00001984 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001985 }
Reid Spencer950bf602007-01-26 08:19:09 +00001986
Reid Spencer688b0492007-02-05 21:19:13 +00001987 if(Function* F = Result->getFunction("llvm.va_end")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001988 if(F->arg_size() != 1) {
1989 error("Obsolete va_end takes 1 argument");
1990 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001991 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001992
Reid Spencer950bf602007-01-26 08:19:09 +00001993 //vaend foo
1994 // ->
1995 //bar = alloca 1 of typeof(foo)
1996 //vaend bar
1997 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1998 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1999 const Type* ArgTyPtr = PointerType::get(ArgTy);
2000 Function* NF = cast<Function>(Result->getOrInsertFunction(
2001 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00002002
Reid Spencer950bf602007-01-26 08:19:09 +00002003 while (!F->use_empty()) {
2004 CallInst* CI = cast<CallInst>(F->use_back());
2005 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
2006 new StoreInst(CI->getOperand(1), bar, CI);
2007 new CallInst(NF, bar, "", CI);
2008 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00002009 }
Reid Spencer950bf602007-01-26 08:19:09 +00002010 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00002011 }
Reid Spencer950bf602007-01-26 08:19:09 +00002012
Reid Spencer688b0492007-02-05 21:19:13 +00002013 if(Function* F = Result->getFunction("llvm.va_copy")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002014 if(F->arg_size() != 1) {
2015 error("Obsolete va_copy takes 1 argument");
2016 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00002017 }
Reid Spencer950bf602007-01-26 08:19:09 +00002018 //foo = vacopy(bar)
2019 // ->
2020 //a = alloca 1 of typeof(foo)
2021 //b = alloca 1 of typeof(foo)
2022 //store bar -> b
2023 //vacopy(a, b)
2024 //foo = load a
2025
2026 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2027 const Type* ArgTy = F->getFunctionType()->getReturnType();
2028 const Type* ArgTyPtr = PointerType::get(ArgTy);
2029 Function* NF = cast<Function>(Result->getOrInsertFunction(
2030 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00002031
Reid Spencer950bf602007-01-26 08:19:09 +00002032 while (!F->use_empty()) {
2033 CallInst* CI = cast<CallInst>(F->use_back());
2034 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
2035 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
2036 new StoreInst(CI->getOperand(1), b, CI);
2037 new CallInst(NF, a, b, "", CI);
2038 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
2039 CI->replaceAllUsesWith(foo);
2040 CI->getParent()->getInstList().erase(CI);
2041 }
2042 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00002043 }
2044 }
2045
Reid Spencer52402b02007-01-02 05:45:11 +00002046 return Result;
2047}
2048
Reid Spencer950bf602007-01-26 08:19:09 +00002049} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00002050
Reid Spencer950bf602007-01-26 08:19:09 +00002051using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00002052
2053
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002054
2055/* Enabling traces. */
2056#ifndef YYDEBUG
2057# define YYDEBUG 0
2058#endif
2059
2060/* Enabling verbose error messages. */
2061#ifdef YYERROR_VERBOSE
2062# undef YYERROR_VERBOSE
2063# define YYERROR_VERBOSE 1
2064#else
2065# define YYERROR_VERBOSE 0
2066#endif
2067
2068/* Enabling the token table. */
2069#ifndef YYTOKEN_TABLE
2070# define YYTOKEN_TABLE 0
2071#endif
2072
2073#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencerbb1fd572007-03-21 17:15:50 +00002074#line 1693 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002075typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00002076 llvm::Module *ModuleVal;
2077 llvm::Function *FunctionVal;
2078 std::pair<llvm::PATypeInfo, char*> *ArgVal;
2079 llvm::BasicBlock *BasicBlockVal;
Reid Spencerbb1fd572007-03-21 17:15:50 +00002080 llvm::TermInstInfo TermInstVal;
Reid Spencer950bf602007-01-26 08:19:09 +00002081 llvm::InstrInfo InstVal;
2082 llvm::ConstInfo ConstVal;
2083 llvm::ValueInfo ValueVal;
2084 llvm::PATypeInfo TypeVal;
2085 llvm::TypeInfo PrimType;
2086 llvm::PHIListInfo PHIList;
2087 std::list<llvm::PATypeInfo> *TypeList;
2088 std::vector<llvm::ValueInfo> *ValueList;
2089 std::vector<llvm::ConstInfo> *ConstVector;
2090
2091
2092 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
2093 // Represent the RHS of PHI node
2094 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
2095
2096 llvm::GlobalValue::LinkageTypes Linkage;
2097 int64_t SInt64Val;
2098 uint64_t UInt64Val;
2099 int SIntVal;
2100 unsigned UIntVal;
2101 double FPVal;
2102 bool BoolVal;
2103
2104 char *StrVal; // This memory is strdup'd!
2105 llvm::ValID ValIDVal; // strdup'd memory maybe!
2106
2107 llvm::BinaryOps BinaryOpVal;
2108 llvm::TermOps TermOpVal;
2109 llvm::MemoryOps MemOpVal;
2110 llvm::OtherOps OtherOpVal;
2111 llvm::CastOps CastOpVal;
2112 llvm::ICmpInst::Predicate IPred;
2113 llvm::FCmpInst::Predicate FPred;
2114 llvm::Module::Endianness Endianness;
Chris Lattnercf3d0612007-02-13 06:04:17 +00002115} YYSTYPE;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002116/* Line 196 of yacc.c. */
Reid Spencerbb1fd572007-03-21 17:15:50 +00002117#line 2116 "UpgradeParser.tab.c"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002118# define yystype YYSTYPE /* obsolescent; will be withdrawn */
2119# define YYSTYPE_IS_DECLARED 1
2120# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00002121#endif
2122
Reid Spencer950bf602007-01-26 08:19:09 +00002123
Reid Spencere7c3c602006-11-30 06:36:44 +00002124
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002125/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002126
2127
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002128/* Line 219 of yacc.c. */
Reid Spencerbb1fd572007-03-21 17:15:50 +00002129#line 2128 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00002130
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002131#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2132# define YYSIZE_T __SIZE_TYPE__
2133#endif
2134#if ! defined (YYSIZE_T) && defined (size_t)
2135# define YYSIZE_T size_t
2136#endif
2137#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
2138# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2139# define YYSIZE_T size_t
2140#endif
2141#if ! defined (YYSIZE_T)
2142# define YYSIZE_T unsigned int
2143#endif
Chris Lattnercf3d0612007-02-13 06:04:17 +00002144
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002145#ifndef YY_
2146# if YYENABLE_NLS
2147# if ENABLE_NLS
2148# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
2149# define YY_(msgid) dgettext ("bison-runtime", msgid)
2150# endif
2151# endif
2152# ifndef YY_
2153# define YY_(msgid) msgid
2154# endif
2155#endif
2156
2157#if ! defined (yyoverflow) || YYERROR_VERBOSE
2158
2159/* The parser invokes alloca or malloc; define the necessary symbols. */
2160
2161# ifdef YYSTACK_USE_ALLOCA
2162# if YYSTACK_USE_ALLOCA
2163# ifdef __GNUC__
2164# define YYSTACK_ALLOC __builtin_alloca
2165# else
2166# define YYSTACK_ALLOC alloca
2167# if defined (__STDC__) || defined (__cplusplus)
2168# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2169# define YYINCLUDED_STDLIB_H
2170# endif
2171# endif
2172# endif
2173# endif
2174
2175# ifdef YYSTACK_ALLOC
2176 /* Pacify GCC's `empty if-body' warning. */
2177# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
2178# ifndef YYSTACK_ALLOC_MAXIMUM
2179 /* The OS might guarantee only one guard page at the bottom of the stack,
2180 and a page size can be as small as 4096 bytes. So we cannot safely
2181 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
2182 to allow for a few compiler-allocated temporary stack slots. */
2183# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
2184# endif
2185# else
2186# define YYSTACK_ALLOC YYMALLOC
2187# define YYSTACK_FREE YYFREE
2188# ifndef YYSTACK_ALLOC_MAXIMUM
2189# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
2190# endif
2191# ifdef __cplusplus
2192extern "C" {
2193# endif
2194# ifndef YYMALLOC
2195# define YYMALLOC malloc
2196# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
2197 && (defined (__STDC__) || defined (__cplusplus)))
2198void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
2199# endif
2200# endif
2201# ifndef YYFREE
2202# define YYFREE free
2203# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
2204 && (defined (__STDC__) || defined (__cplusplus)))
2205void free (void *); /* INFRINGES ON USER NAME SPACE */
2206# endif
2207# endif
2208# ifdef __cplusplus
2209}
2210# endif
2211# endif
2212#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
2213
2214
2215#if (! defined (yyoverflow) \
2216 && (! defined (__cplusplus) \
2217 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
2218
2219/* A type that is properly aligned for any stack member. */
2220union yyalloc
2221{
2222 short int yyss;
2223 YYSTYPE yyvs;
2224 };
2225
2226/* The size of the maximum gap between one aligned stack and the next. */
2227# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2228
2229/* The size of an array large to enough to hold all stacks, each with
2230 N elements. */
2231# define YYSTACK_BYTES(N) \
2232 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
2233 + YYSTACK_GAP_MAXIMUM)
2234
2235/* Copy COUNT objects from FROM to TO. The source and destination do
2236 not overlap. */
2237# ifndef YYCOPY
2238# if defined (__GNUC__) && 1 < __GNUC__
2239# define YYCOPY(To, From, Count) \
2240 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2241# else
2242# define YYCOPY(To, From, Count) \
2243 do \
2244 { \
2245 YYSIZE_T yyi; \
2246 for (yyi = 0; yyi < (Count); yyi++) \
2247 (To)[yyi] = (From)[yyi]; \
2248 } \
2249 while (0)
2250# endif
2251# endif
2252
2253/* Relocate STACK from its old location to the new one. The
2254 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2255 elements in the stack, and YYPTR gives the new location of the
2256 stack. Advance YYPTR to a properly aligned location for the next
2257 stack. */
2258# define YYSTACK_RELOCATE(Stack) \
2259 do \
2260 { \
2261 YYSIZE_T yynewbytes; \
2262 YYCOPY (&yyptr->Stack, Stack, yysize); \
2263 Stack = &yyptr->Stack; \
2264 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2265 yyptr += yynewbytes / sizeof (*yyptr); \
2266 } \
2267 while (0)
Chris Lattnercf3d0612007-02-13 06:04:17 +00002268
Reid Spencere7c3c602006-11-30 06:36:44 +00002269#endif
2270
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002271#if defined (__STDC__) || defined (__cplusplus)
2272 typedef signed char yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002273#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002274 typedef short int yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002275#endif
2276
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002277/* YYFINAL -- State number of the termination state. */
2278#define YYFINAL 4
2279/* YYLAST -- Last index in YYTABLE. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002280#define YYLAST 1630
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002281
2282/* YYNTOKENS -- Number of terminals. */
2283#define YYNTOKENS 166
2284/* YYNNTS -- Number of nonterminals. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002285#define YYNNTS 81
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002286/* YYNRULES -- Number of rules. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002287#define YYNRULES 310
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002288/* YYNRULES -- Number of states. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002289#define YYNSTATES 606
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002290
2291/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2292#define YYUNDEFTOK 2
2293#define YYMAXUTOK 406
2294
2295#define YYTRANSLATE(YYX) \
2296 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2297
2298/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2299static const unsigned char yytranslate[] =
2300{
2301 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2302 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2303 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2304 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2305 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2306 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2307 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2308 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2309 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2310 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2311 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2312 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2313 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2314 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2315 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2316 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2317 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2318 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2319 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2320 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2321 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2322 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2323 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2324 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2325 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2326 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2327 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2328 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2329 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2330 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2331 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2332 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2333 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2334 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2335 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2336 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2337 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2338 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2339 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2340 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2341 145, 146, 147, 148, 149, 150, 151
2342};
2343
2344#if YYDEBUG
2345/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2346 YYRHS. */
2347static const unsigned short int yyprhs[] =
2348{
2349 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2350 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2351 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2352 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2353 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2354 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2355 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2356 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2357 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2358 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2359 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2360 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2361 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2362 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2363 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2364 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2365 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2366 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2367 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2368 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2369 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2370 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002371 622, 623, 632, 634, 636, 637, 642, 644, 646, 649,
2372 650, 652, 654, 655, 656, 662, 663, 665, 667, 669,
2373 671, 673, 675, 677, 679, 681, 685, 687, 693, 695,
2374 697, 699, 701, 704, 707, 710, 714, 717, 718, 720,
2375 722, 724, 727, 730, 734, 744, 754, 763, 777, 779,
2376 781, 788, 794, 797, 804, 812, 814, 818, 820, 821,
2377 824, 826, 832, 838, 844, 851, 858, 861, 866, 871,
2378 878, 883, 888, 893, 898, 905, 912, 915, 923, 925,
2379 928, 929, 931, 932, 936, 943, 947, 954, 957, 962,
2380 969
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002381};
2382
2383/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2384static const short int yyrhs[] =
2385{
2386 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2387 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2388 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2389 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2390 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2391 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2392 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2393 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2394 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2395 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2396 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2397 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2398 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2399 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2400 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2401 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2402 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2403 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2404 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2405 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2406 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2407 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2408 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2409 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2410 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002411 -1, 19, -1, 21, -1, 192, -1, 48, -1, 229,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002412 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2413 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2414 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2415 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2416 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2417 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2418 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2419 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2420 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2421 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002422 191, 39, -1, 191, 229, -1, 191, 197, -1, 191,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002423 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2424 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002425 36, 191, 156, -1, 110, 155, 196, 244, 156, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002426 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2427 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2428 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2429 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2430 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2431 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2432 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2433 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2434 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002435 201, 222, -1, 201, 224, -1, 201, 62, 61, 207,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002436 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002437 -1, 202, 224, -1, 202, 62, 61, 207, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002438 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2439 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2440 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2441 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2442 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2443 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2444 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2445 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2446 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2447 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2448 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002449 183, -1, 29, -1, 162, -1, -1, 181, 220, 217,
2450 218, -1, 30, -1, 163, -1, 232, 221, -1, -1,
2451 45, -1, 47, -1, -1, -1, 31, 225, 223, 226,
2452 217, -1, -1, 63, -1, 3, -1, 4, -1, 7,
2453 -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
2454 -1, 160, 198, 161, -1, 197, -1, 61, 227, 24,
2455 153, 24, -1, 167, -1, 212, -1, 229, -1, 228,
2456 -1, 191, 230, -1, 232, 233, -1, 219, 233, -1,
2457 234, 180, 236, -1, 234, 238, -1, -1, 23, -1,
2458 77, -1, 78, -1, 72, 231, -1, 72, 8, -1,
2459 73, 21, 230, -1, 73, 9, 230, 153, 21, 230,
2460 153, 21, 230, -1, 74, 178, 230, 153, 21, 230,
2461 157, 237, 159, -1, 74, 178, 230, 153, 21, 230,
2462 157, 159, -1, 75, 182, 189, 230, 155, 241, 156,
2463 36, 21, 230, 235, 21, 230, -1, 235, -1, 76,
2464 -1, 237, 178, 228, 153, 21, 230, -1, 178, 228,
2465 153, 21, 230, -1, 180, 243, -1, 191, 157, 230,
2466 153, 230, 159, -1, 239, 153, 157, 230, 153, 230,
2467 159, -1, 231, -1, 240, 153, 231, -1, 240, -1,
2468 -1, 60, 59, -1, 59, -1, 169, 191, 230, 153,
2469 230, -1, 170, 191, 230, 153, 230, -1, 171, 191,
2470 230, 153, 230, -1, 103, 172, 191, 230, 153, 230,
2471 -1, 104, 173, 191, 230, 153, 230, -1, 49, 231,
2472 -1, 174, 231, 153, 231, -1, 175, 231, 36, 191,
2473 -1, 112, 231, 153, 231, 153, 231, -1, 113, 231,
2474 153, 191, -1, 117, 231, 153, 191, -1, 118, 231,
2475 153, 191, -1, 114, 231, 153, 231, -1, 115, 231,
2476 153, 231, 153, 231, -1, 116, 231, 153, 231, 153,
2477 231, -1, 111, 239, -1, 242, 182, 189, 230, 155,
2478 241, 156, -1, 246, -1, 153, 240, -1, -1, 35,
2479 -1, -1, 105, 191, 184, -1, 105, 191, 153, 15,
2480 230, 184, -1, 106, 191, 184, -1, 106, 191, 153,
2481 15, 230, 184, -1, 107, 231, -1, 245, 108, 191,
2482 230, -1, 245, 109, 231, 153, 191, 230, -1, 110,
2483 191, 230, 244, -1
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002484};
2485
2486/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2487static const unsigned short int yyrline[] =
2488{
Reid Spencerbb1fd572007-03-21 17:15:50 +00002489 0, 1833, 1833, 1834, 1842, 1843, 1853, 1853, 1853, 1853,
2490 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1857, 1857, 1857,
2491 1861, 1861, 1861, 1861, 1861, 1861, 1865, 1865, 1866, 1866,
2492 1867, 1867, 1868, 1868, 1869, 1869, 1873, 1873, 1874, 1874,
2493 1875, 1875, 1876, 1876, 1877, 1877, 1878, 1878, 1879, 1879,
2494 1880, 1881, 1884, 1884, 1884, 1884, 1888, 1888, 1888, 1888,
2495 1888, 1888, 1888, 1889, 1889, 1889, 1889, 1889, 1889, 1895,
2496 1895, 1895, 1895, 1899, 1899, 1899, 1899, 1903, 1903, 1907,
2497 1907, 1912, 1915, 1920, 1921, 1922, 1923, 1924, 1925, 1926,
2498 1927, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1948,
2499 1949, 1957, 1958, 1966, 1975, 1976, 1983, 1984, 1988, 1992,
2500 2008, 2009, 2016, 2017, 2024, 2032, 2032, 2032, 2032, 2032,
2501 2032, 2032, 2033, 2033, 2033, 2033, 2033, 2038, 2042, 2046,
2502 2051, 2060, 2078, 2084, 2097, 2108, 2112, 2125, 2129, 2143,
2503 2147, 2154, 2155, 2161, 2168, 2180, 2210, 2223, 2246, 2274,
2504 2296, 2307, 2329, 2340, 2349, 2354, 2413, 2420, 2428, 2435,
2505 2442, 2446, 2450, 2459, 2474, 2487, 2496, 2524, 2537, 2546,
2506 2552, 2558, 2569, 2575, 2581, 2592, 2593, 2602, 2603, 2615,
2507 2624, 2625, 2626, 2627, 2628, 2644, 2664, 2666, 2668, 2668,
2508 2675, 2675, 2683, 2683, 2691, 2691, 2700, 2702, 2704, 2709,
2509 2723, 2724, 2728, 2731, 2739, 2743, 2750, 2754, 2758, 2762,
2510 2770, 2770, 2774, 2775, 2779, 2787, 2792, 2800, 2801, 2808,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002511 2815, 2819, 3000, 3000, 3004, 3004, 3014, 3014, 3018, 3023,
2512 3024, 3025, 3029, 3030, 3029, 3042, 3043, 3048, 3049, 3050,
2513 3051, 3055, 3059, 3060, 3061, 3062, 3083, 3087, 3101, 3102,
2514 3107, 3107, 3115, 3125, 3128, 3137, 3148, 3153, 3162, 3173,
2515 3173, 3176, 3180, 3184, 3189, 3199, 3217, 3226, 3291, 3295,
2516 3302, 3314, 3329, 3359, 3369, 3379, 3383, 3390, 3391, 3395,
2517 3398, 3404, 3423, 3441, 3457, 3471, 3485, 3496, 3514, 3523,
2518 3532, 3539, 3560, 3584, 3590, 3596, 3602, 3618, 3702, 3710,
2519 3711, 3715, 3716, 3720, 3726, 3733, 3739, 3746, 3753, 3766,
2520 3792
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002521};
2522#endif
2523
2524#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2525/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2526 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2527static const char *const yytname[] =
2528{
2529 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2530 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2531 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2532 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2533 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2534 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2535 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2536 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2537 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2538 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2539 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2540 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2541 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2542 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2543 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2544 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2545 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2546 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2547 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2548 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2549 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2550 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2551 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2552 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2553 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2554 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2555 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2556 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2557 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2558 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2559 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2560 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2561 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2562 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
Reid Spencerd2920cd2007-03-21 17:27:53 +00002563 "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7",
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002564 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2565 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2566 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2567 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2568 "OptVolatile", "MemoryInst", 0
2569};
2570#endif
2571
2572# ifdef YYPRINT
2573/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2574 token YYLEX-NUM. */
2575static const unsigned short int yytoknum[] =
2576{
2577 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2578 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2579 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2580 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2581 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2582 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2583 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2584 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2585 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2586 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2587 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2588 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2589 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2590 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2591 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2592 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2593 60, 62, 123, 125, 42, 99
2594};
2595# endif
2596
2597/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2598static const unsigned char yyr1[] =
2599{
2600 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2601 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2602 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2603 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2604 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2605 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2606 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2607 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2608 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2609 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2610 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2611 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2612 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2613 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2614 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2615 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2616 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2617 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2618 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2619 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2620 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2621 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002622 216, 217, 218, 218, 220, 219, 221, 221, 222, 223,
2623 223, 223, 225, 226, 224, 227, 227, 228, 228, 228,
2624 228, 228, 228, 228, 228, 228, 228, 228, 229, 229,
2625 230, 230, 231, 232, 232, 233, 234, 234, 234, 235,
2626 235, 236, 236, 236, 236, 236, 236, 236, 236, 236,
2627 237, 237, 238, 239, 239, 240, 240, 241, 241, 242,
2628 242, 243, 243, 243, 243, 243, 243, 243, 243, 243,
2629 243, 243, 243, 243, 243, 243, 243, 243, 243, 244,
2630 244, 245, 245, 246, 246, 246, 246, 246, 246, 246,
2631 246
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002632};
2633
2634/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2635static const unsigned char yyr2[] =
2636{
2637 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2638 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2639 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2640 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2641 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2642 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2643 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2644 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2645 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2646 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2647 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2648 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2649 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2650 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2651 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2652 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2653 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2654 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2655 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2656 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2657 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2658 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002659 0, 8, 1, 1, 0, 4, 1, 1, 2, 0,
2660 1, 1, 0, 0, 5, 0, 1, 1, 1, 1,
2661 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
2662 1, 1, 2, 2, 2, 3, 2, 0, 1, 1,
2663 1, 2, 2, 3, 9, 9, 8, 13, 1, 1,
2664 6, 5, 2, 6, 7, 1, 3, 1, 0, 2,
2665 1, 5, 5, 5, 6, 6, 2, 4, 4, 6,
2666 4, 4, 4, 4, 6, 6, 2, 7, 1, 2,
2667 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
2668 4
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002669};
2670
2671/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2672 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2673 means the default is an error. */
2674static const unsigned short int yydefact[] =
2675{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002676 198, 0, 90, 184, 1, 183, 232, 83, 84, 85,
2677 86, 87, 88, 89, 0, 224, 257, 180, 181, 257,
2678 210, 211, 0, 0, 0, 90, 0, 186, 229, 0,
2679 91, 258, 254, 82, 226, 227, 228, 253, 0, 0,
2680 0, 0, 196, 0, 0, 0, 0, 0, 0, 0,
2681 81, 230, 231, 233, 199, 182, 0, 92, 93, 94,
2682 95, 96, 97, 0, 0, 302, 256, 0, 0, 0,
2683 0, 209, 197, 187, 2, 3, 111, 115, 116, 117,
2684 118, 119, 120, 121, 122, 123, 124, 125, 126, 128,
2685 0, 0, 0, 0, 248, 185, 0, 110, 127, 114,
2686 249, 129, 177, 178, 0, 0, 0, 0, 91, 98,
2687 0, 222, 223, 225, 301, 0, 280, 0, 0, 0,
2688 0, 91, 269, 259, 260, 6, 7, 8, 9, 10,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002689 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2690 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2691 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2692 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2693 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002694 0, 268, 255, 91, 272, 0, 298, 204, 201, 200,
2695 202, 203, 205, 208, 0, 130, 0, 0, 0, 113,
2696 135, 139, 0, 144, 138, 192, 194, 190, 115, 116,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002697 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002698 0, 0, 0, 188, 234, 0, 0, 286, 279, 262,
2699 261, 0, 0, 72, 76, 71, 75, 70, 74, 69,
2700 73, 77, 78, 0, 0, 26, 27, 28, 29, 30,
2701 31, 32, 33, 34, 35, 0, 50, 51, 46, 47,
2702 48, 49, 36, 37, 38, 39, 40, 41, 42, 43,
2703 44, 45, 0, 101, 101, 307, 0, 0, 296, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002704 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002705 0, 0, 0, 0, 0, 206, 0, 0, 0, 0,
2706 0, 134, 143, 141, 0, 106, 106, 106, 160, 161,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002707 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2708 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002709 0, 0, 0, 0, 156, 155, 106, 220, 237, 238,
2710 239, 244, 240, 241, 242, 243, 235, 0, 246, 251,
2711 250, 252, 0, 263, 0, 0, 0, 0, 0, 303,
2712 0, 305, 300, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002713 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002714 207, 112, 112, 137, 0, 140, 0, 131, 0, 193,
2715 195, 191, 0, 0, 0, 0, 0, 0, 0, 146,
2716 176, 0, 0, 0, 150, 0, 147, 0, 0, 0,
2717 0, 0, 189, 219, 213, 216, 217, 0, 236, 0,
2718 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2719 310, 0, 0, 0, 290, 293, 0, 0, 291, 292,
2720 0, 0, 0, 287, 288, 0, 308, 0, 132, 133,
2721 136, 142, 0, 0, 108, 106, 0, 0, 300, 0,
2722 0, 0, 0, 0, 145, 135, 114, 0, 148, 149,
2723 0, 0, 0, 0, 0, 212, 214, 0, 104, 0,
2724 245, 0, 0, 278, 0, 0, 101, 102, 101, 275,
2725 299, 0, 0, 0, 0, 0, 281, 282, 283, 278,
2726 0, 103, 109, 107, 0, 0, 0, 0, 0, 0,
2727 0, 175, 152, 0, 0, 0, 0, 0, 0, 218,
2728 215, 105, 99, 0, 0, 0, 277, 0, 284, 285,
2729 0, 304, 306, 0, 0, 0, 289, 294, 295, 0,
2730 309, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2731 0, 0, 0, 0, 0, 221, 247, 0, 0, 0,
2732 276, 273, 0, 297, 0, 0, 0, 172, 0, 0,
2733 166, 167, 168, 171, 163, 100, 0, 266, 0, 0,
2734 0, 274, 169, 170, 0, 0, 0, 264, 0, 265,
2735 0, 0, 165, 173, 174, 0, 0, 0, 0, 0,
2736 0, 271, 0, 0, 270, 267
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002737};
2738
2739/* YYDEFGOTO[NTERM-NUM]. */
2740static const short int yydefgoto[] =
2741{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002742 -1, 94, 312, 329, 330, 331, 255, 272, 332, 333,
2743 219, 220, 243, 221, 25, 15, 63, 555, 359, 454,
2744 522, 389, 455, 95, 96, 222, 98, 99, 202, 304,
2745 400, 348, 401, 104, 1, 2, 3, 336, 307, 305,
2746 306, 55, 190, 42, 72, 194, 100, 476, 415, 416,
2747 417, 64, 113, 16, 30, 36, 17, 53, 18, 28,
2748 108, 419, 349, 101, 351, 489, 19, 32, 33, 181,
2749 182, 579, 66, 278, 526, 527, 183, 184, 430, 185,
2750 186
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002751};
2752
2753/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2754 STATE-NUM. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002755#define YYPACT_NINF -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002756static const short int yypact[] =
2757{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002758 -542, 13, 162, 567, -542, -542, -542, -542, -542, -542,
2759 -542, -542, -542, -542, 83, -542, 19, -542, -542, -14,
2760 -542, -542, 50, -87, 87, 233, 27, -542, 123, 141,
2761 175, -542, -542, 98, -542, -542, -542, -542, 33, 40,
2762 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156,
2763 -542, -542, -542, -542, -542, -542, 221, -542, -542, -542,
2764 -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226,
2765 227, 235, -542, -542, -542, -542, 81, -542, -542, -542,
2766 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2767 256, 257, 4, 15, -542, -542, 108, -542, -542, 12,
2768 -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542,
2769 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116,
2770 479, 175, -542, -542, -542, -542, -542, -542, -542, -542,
2771 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2772 -542, -542, -542, -542, -542, -542, -542, -542, -542, 355,
2773 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306,
2774 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542,
2775 -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306,
2776 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542,
2777 -542, -542, -542, -542, -13, -542, 110, 111, 75, -542,
2778 -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208,
2779 266, 210, 267, 212, 268, 230, 277, 275, 278, 246,
2780 280, 279, 566, -542, -542, 136, 766, -542, -542, 81,
2781 -542, 766, 766, -542, -542, -542, -542, -542, -542, -542,
2782 -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542,
2783 -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542,
2784 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2785 -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147,
2786 148, 149, 151, 152, 158, 160, 766, 766, 766, 161,
2787 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27,
2788 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542,
2789 -542, -542, -542, -542, -542, -542, -542, -542, 355, 429,
2790 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184,
2791 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542,
2792 -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542,
2793 -542, -542, 193, -542, 194, 766, 766, 766, 7, -542,
2794 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306,
2795 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207,
2796 -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542,
2797 -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542,
2798 -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326,
2799 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337,
2800 -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306,
2801 -542, 223, 766, 224, -542, -542, 225, 234, -542, -542,
2802 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542,
2803 -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236,
2804 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542,
2805 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252,
2806 -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542,
2807 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306,
2808 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326,
2809 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542,
2810 -542, -542, 368, 402, 274, 276, 259, 287, -542, -542,
2811 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290,
2812 -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296,
2813 297, 299, 302, 303, 430, -542, -542, 414, 41, 425,
2814 -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326,
2815 -542, -542, -542, -542, -542, -542, 766, -542, 893, 144,
2816 448, -542, -542, -542, 314, 315, 316, -542, 331, -542,
2817 893, 766, -542, -542, -542, 464, 334, 180, 766, 481,
2818 482, -542, 766, 766, -542, -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002819};
2820
2821/* YYPGOTO[NTERM-NUM]. */
2822static const short int yypgoto[] =
2823{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002824 -542, -542, -542, 435, 439, 441, 191, 197, 442, 445,
2825 -119, -116, -541, -542, 478, 489, -107, -542, -267, 37,
2826 -542, -238, -542, -60, -542, -45, -542, -74, -51, -542,
2827 -101, 300, -252, 134, -542, -542, -542, -542, -542, -542,
2828 -542, 473, -542, -542, -542, -542, 8, -542, 46, -542,
2829 -542, 410, -542, -542, -542, -542, -542, -542, 518, -542,
2830 -542, -542, -528, 142, -90, -113, -542, 505, -542, -72,
2831 -542, -542, -542, -542, 97, 28, -542, -542, 70, -542,
2832 -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002833};
2834
2835/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2836 positive, shift that token. If negative, reduce the rule which
2837 number is the opposite. If zero, do what YYDEFACT says.
2838 If YYTABLE_NINF, syntax error. */
2839#define YYTABLE_NINF -180
2840static const short int yytable[] =
2841{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002842 97, 241, 227, 110, 242, 230, 223, 361, 197, 31,
2843 111, 26, 449, 4, 244, 204, 34, 578, 97, 201,
2844 74, 75, 426, 199, 77, 78, 79, 80, 81, 82,
2845 83, 84, 85, 86, 87, 428, 88, 20, 590, 21,
2846 275, 26, 31, 279, 280, 281, 282, 283, 284, 285,
2847 588, 233, 234, 235, 236, 237, 238, 239, 240, 205,
2848 206, 207, 596, 89, 427, 43, 289, 290, 390, 391,
2849 226, 463, 300, 226, 403, 405, 291, 427, 452, 468,
2850 74, 75, 301, 199, 77, 78, 79, 80, 81, 82,
2851 83, 84, 85, 86, 87, 420, 88, 20, 412, 21,
2852 448, 453, 38, 39, 40, 204, 273, 274, 226, 276,
2853 277, 226, 226, 226, 226, 226, 226, 226, 225, 463,
2854 20, 41, 21, 89, 201, 231, 300, 480, -139, 201,
2855 -112, 286, 287, 288, 226, 226, 384, 232, -139, 204,
2856 294, 352, 353, 112, 29, 463, 295, 299, 44, 35,
2857 467, 464, 303, 354, 233, 234, 235, 236, 237, 238,
2858 239, 240, -179, 463, 463, 54, 198, -112, 51, 90,
2859 52, 71, 91, 469, 513, 92, 204, 93, 200, 50,
2860 379, 105, 106, 107, 355, 67, 362, 5, 102, 103,
2861 188, 189, 68, 6, 292, 293, 372, 373, 374, 97,
2862 577, 308, 309, 7, 8, 9, 10, 11, 12, 13,
2863 356, -72, -72, -71, -71, -70, -70, 503, 69, 531,
2864 70, 532, 381, 382, 14, 109, 385, 357, 187, 90,
2865 191, 377, 91, -69, -69, 92, -113, 93, 298, 56,
2866 57, 58, 59, 60, 61, 62, 97, 378, 226, 310,
2867 311, 192, 433, 45, 435, 436, 437, 123, 124, 193,
2868 195, 196, 443, 203, 228, 423, 424, 425, 296, 297,
2869 -76, -75, -74, 431, 7, 8, 9, 10, 46, 12,
2870 47, -73, -79, 48, 313, -80, 314, 445, 446, 363,
2871 358, 337, 414, 458, 459, 460, 461, 462, 360, 364,
2872 365, 366, 367, 589, 368, 369, 470, 471, 472, 473,
2873 474, 370, 385, 371, 375, 380, 383, 376, 386, 387,
2874 226, 434, 226, 226, 226, 438, 439, 394, 466, 388,
2875 226, 444, 395, 396, 397, 406, 486, 398, 488, 407,
2876 408, 409, 492, 410, 411, 418, 421, 422, 429, 432,
2877 496, 497, 498, 440, 441, 504, 505, 450, 456, 442,
2878 447, 479, 511, 481, 335, 478, 457, 477, 350, 482,
2879 483, 484, 485, 350, 350, 487, 491, 493, 494, 502,
2880 536, 537, 538, 499, 226, 350, 501, 495, 518, 507,
2881 508, 524, 525, 509, 528, 529, 510, 514, 515, 512,
2882 516, 534, 500, 517, 452, 523, 544, 545, 546, 547,
2883 540, 530, 533, 549, 550, 551, 552, 535, 350, 543,
2884 560, 548, 475, 541, 542, 554, 556, 557, 350, 350,
2885 350, 427, 414, 558, 575, 576, 566, 568, 226, 241,
2886 564, 565, 242, 559, 561, 562, 563, 569, 226, 226,
2887 226, 567, 570, 571, 226, 572, 256, 257, 573, 574,
2888 241, 580, 582, 242, 581, 584, 583, 585, 586, 591,
2889 592, 593, 594, 553, 245, 246, 247, 248, 249, 250,
2890 251, 252, 253, 254, 595, 598, 587, 599, 226, 233,
2891 234, 235, 236, 237, 238, 239, 240, 350, 350, 350,
2892 176, 597, 602, 603, 177, 350, 178, 179, 601, 392,
2893 180, 65, 604, 605, 49, 521, 393, 73, 224, 350,
2894 350, 27, 334, 520, 37, 600, 490, 539, 506, 0,
2895 0, 0, 0, 0, 74, 75, 0, 199, 208, 209,
2896 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2897 88, 20, 0, 21, 258, 259, 260, 261, 262, 263,
2898 264, 265, 266, 267, 268, 269, 270, 271, 350, 0,
2899 350, 74, 75, 0, 350, 0, 0, 89, 0, 0,
2900 0, 0, 350, 350, 350, 0, 0, -82, 20, 20,
2901 21, 21, 315, 0, 0, 0, 0, 0, 6, -82,
2902 -82, 0, 0, 0, 316, 317, 0, 0, -82, -82,
2903 -82, -82, -82, -82, -82, 0, 0, -82, 22, 0,
2904 0, 0, 0, 350, 350, 23, 350, 350, 0, 24,
2905 0, 0, 0, 350, 0, 0, 0, 0, 0, 0,
2906 0, 0, 350, 0, 0, 125, 126, 127, 128, 129,
2907 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2908 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
2909 319, 0, 0, 0, 0, 0, 320, 350, 321, 0,
2910 322, 323, 324, 90, 0, 0, 91, 0, 0, 92,
2911 0, 93, 404, 0, 0, 0, 0, 0, 0, 0,
2912 0, 0, 0, 0, 0, 163, 164, 165, 166, 167,
2913 168, 169, 170, 171, 172, 173, 174, 175, 350, 0,
2914 0, 0, 0, 325, 0, 0, 326, 0, 327, 0,
2915 0, 328, 0, 350, 0, 0, 0, 0, 0, 0,
2916 350, 0, 0, 0, 350, 350, 74, 75, 0, 199,
2917 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
2918 218, 0, 88, 20, 0, 21, 0, 0, 0, 338,
2919 339, 74, 75, 340, 0, 0, 0, 0, 0, 0,
2920 0, 0, 0, 0, 0, 0, 0, 0, 20, 89,
2921 21, 0, 341, 342, 343, 0, 0, 0, 0, 0,
2922 0, 0, 0, 0, 344, 345, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002923 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002924 0, 0, 0, 0, 0, 0, 0, 346, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002925 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002926 0, 0, 0, 0, 0, 125, 126, 127, 128, 129,
2927 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2928 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002929 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
2930 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002931 0, 0, 0, 0, 0, 90, 338, 339, 91, 0,
2932 340, 92, 0, 93, 465, 163, 164, 165, 166, 167,
2933 168, 169, 170, 171, 172, 173, 174, 175, 0, 341,
2934 342, 343, 0, 0, 0, 0, 347, 0, 0, 0,
2935 0, 344, 345, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002936 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002937 0, 0, 0, 0, 346, 0, 0, 0, 0, 0,
2938 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2939 0, 0, 125, 126, 127, 128, 129, 130, 131, 132,
2940 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
2941 143, 144, 145, 146, 147, 148, 318, 319, 0, 0,
2942 0, 0, 0, 320, 0, 321, 0, 322, 323, 324,
2943 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2944 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2945 0, 0, 163, 164, 165, 166, 167, 168, 169, 170,
2946 171, 172, 173, 174, 175, 0, 0, 0, 0, 0,
2947 0, 74, 75, 347, 199, 77, 78, 79, 80, 81,
2948 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
2949 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2950 0, 0, 0, 302, 0, 0, 0, 0, 0, 0,
2951 0, 0, 74, 75, 89, 199, 208, 209, 210, 211,
2952 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
2953 0, 21, 74, 75, 0, 199, 77, 78, 79, 80,
2954 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
2955 0, 21, 0, 0, 0, 89, 0, 0, 0, 0,
2956 0, 0, 0, 0, 413, 0, 0, 0, 0, 0,
2957 0, 0, 0, 74, 75, 89, 199, 77, 78, 79,
2958 80, 81, 82, 83, 84, 85, 86, 87, 0, 88,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002959 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002960 0, 0, 0, 0, 0, 451, 0, 0, 0, 0,
2961 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
2962 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
2963 74, 75, 0, 199, 77, 78, 79, 80, 81, 82,
2964 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002965 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002966 0, 90, 519, 0, 91, 0, 399, 92, 0, 93,
2967 0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
2968 0, 90, 0, 0, 91, 0, 0, 92, 0, 93,
2969 74, 75, 0, 76, 77, 78, 79, 80, 81, 82,
2970 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
2971 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2972 0, 0, 90, 0, 0, 91, 0, 0, 92, 0,
2973 93, 74, 75, 89, 199, 77, 78, 79, 80, 81,
2974 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
2975 21, 74, 75, 0, 199, 208, 209, 210, 211, 212,
2976 213, 214, 215, 216, 217, 218, 0, 88, 20, 0,
2977 21, 0, 0, 0, 89, 0, 0, 0, 0, 90,
2978 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
2979 0, 0, 74, 75, 89, 229, 77, 78, 79, 80,
2980 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
2981 0, 21, 74, 75, 0, 199, 208, 209, 210, 211,
2982 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
2983 0, 21, 0, 0, 0, 89, 0, 0, 0, 90,
2984 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
2985 0, 0, 0, 0, 0, 89, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002986 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2987 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002988 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002989 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002990 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002991 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2992 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002993 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
2994 0, 90, 0, 0, 91, 0, 0, 92, 115, 93,
2995 0, 0, 0, 0, 0, 0, 0, 0, 116, 117,
2996 0, 90, 0, 0, 91, 0, 0, 92, 0, 402,
2997 0, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2998 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
2999 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
3000 147, 148, 149, 150, 151, 152, 153, 0, 0, 154,
3001 155, 156, 157, 158, 159, 160, 161, 162, 0, 0,
3002 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3003 0, 0, 0, 0, 0, 0, 0, 0, 163, 164,
3004 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
3005 175
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003006};
3007
3008static const short int yycheck[] =
3009{
Reid Spencerd2920cd2007-03-21 17:27:53 +00003010 45, 120, 115, 63, 120, 118, 107, 274, 4, 23,
3011 29, 3, 161, 0, 121, 164, 30, 558, 63, 93,
3012 5, 6, 15, 8, 9, 10, 11, 12, 13, 14,
3013 15, 16, 17, 18, 19, 15, 21, 22, 579, 24,
3014 153, 33, 23, 156, 157, 158, 159, 160, 161, 162,
3015 578, 10, 11, 12, 13, 14, 15, 16, 17, 104,
3016 105, 106, 590, 48, 57, 152, 179, 180, 306, 307,
3017 115, 153, 153, 118, 326, 327, 183, 57, 34, 161,
3018 5, 6, 163, 8, 9, 10, 11, 12, 13, 14,
3019 15, 16, 17, 18, 19, 347, 21, 22, 336, 24,
3020 159, 57, 52, 53, 54, 164, 151, 152, 153, 154,
3021 155, 156, 157, 158, 159, 160, 161, 162, 110, 153,
3022 22, 71, 24, 48, 198, 9, 153, 161, 153, 203,
3023 155, 176, 177, 178, 179, 180, 163, 21, 163, 164,
3024 153, 231, 232, 162, 61, 153, 159, 198, 61, 163,
3025 402, 159, 203, 243, 10, 11, 12, 13, 14, 15,
3026 16, 17, 0, 153, 153, 24, 162, 155, 45, 154,
3027 47, 157, 157, 163, 163, 160, 164, 162, 163, 152,
3028 293, 47, 48, 49, 244, 152, 276, 25, 32, 33,
3029 55, 56, 152, 31, 108, 109, 286, 287, 288, 244,
3030 159, 27, 28, 41, 42, 43, 44, 45, 46, 47,
3031 255, 3, 4, 3, 4, 3, 4, 455, 152, 486,
3032 152, 488, 296, 297, 62, 4, 300, 272, 24, 154,
3033 4, 291, 157, 3, 4, 160, 155, 162, 163, 64,
3034 65, 66, 67, 68, 69, 70, 291, 292, 293, 3,
3035 4, 24, 365, 20, 367, 368, 369, 77, 78, 24,
3036 4, 4, 375, 155, 59, 355, 356, 357, 158, 158,
3037 4, 4, 4, 363, 41, 42, 43, 44, 45, 46,
3038 47, 4, 7, 50, 4, 7, 7, 377, 378, 157,
3039 153, 155, 337, 394, 395, 396, 397, 398, 153, 153,
3040 153, 153, 153, 159, 153, 153, 407, 408, 409, 410,
3041 411, 153, 386, 153, 153, 24, 161, 36, 153, 156,
3042 365, 366, 367, 368, 369, 370, 371, 155, 402, 153,
3043 375, 376, 155, 155, 155, 24, 426, 155, 428, 155,
3044 155, 155, 432, 155, 155, 63, 153, 153, 153, 157,
3045 440, 441, 442, 153, 153, 456, 457, 161, 155, 153,
3046 153, 24, 463, 21, 222, 156, 155, 153, 226, 21,
3047 155, 153, 153, 231, 232, 4, 153, 153, 153, 4,
3048 493, 494, 495, 155, 429, 243, 24, 153, 36, 153,
3049 153, 481, 482, 153, 484, 485, 153, 153, 153, 161,
3050 153, 491, 447, 153, 34, 153, 507, 508, 509, 510,
3051 500, 153, 153, 514, 515, 516, 517, 153, 276, 156,
3052 533, 161, 414, 153, 153, 57, 24, 153, 286, 287,
3053 288, 57, 477, 157, 4, 21, 153, 153, 483, 558,
3054 541, 542, 558, 156, 159, 535, 156, 153, 493, 494,
3055 495, 156, 156, 156, 499, 156, 27, 28, 156, 156,
3056 579, 36, 156, 579, 159, 566, 156, 568, 569, 21,
3057 156, 156, 156, 518, 119, 120, 121, 122, 123, 124,
3058 125, 126, 127, 128, 153, 21, 576, 153, 533, 10,
3059 11, 12, 13, 14, 15, 16, 17, 355, 356, 357,
3060 65, 591, 21, 21, 65, 363, 65, 65, 598, 318,
3061 65, 33, 602, 603, 25, 478, 319, 44, 108, 377,
3062 378, 3, 222, 477, 19, 597, 429, 499, 458, -1,
3063 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
3064 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3065 21, 22, -1, 24, 125, 126, 127, 128, 129, 130,
3066 131, 132, 133, 134, 135, 136, 137, 138, 426, -1,
3067 428, 5, 6, -1, 432, -1, -1, 48, -1, -1,
3068 -1, -1, 440, 441, 442, -1, -1, 20, 22, 22,
3069 24, 24, 26, -1, -1, -1, -1, -1, 31, 32,
3070 33, -1, -1, -1, 38, 39, -1, -1, 41, 42,
3071 43, 44, 45, 46, 47, -1, -1, 50, 51, -1,
3072 -1, -1, -1, 481, 482, 58, 484, 485, -1, 62,
3073 -1, -1, -1, 491, -1, -1, -1, -1, -1, -1,
3074 -1, -1, 500, -1, -1, 79, 80, 81, 82, 83,
3075 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3076 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3077 104, -1, -1, -1, -1, -1, 110, 535, 112, -1,
3078 114, 115, 116, 154, -1, -1, 157, -1, -1, 160,
3079 -1, 162, 163, -1, -1, -1, -1, -1, -1, -1,
3080 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
3081 144, 145, 146, 147, 148, 149, 150, 151, 576, -1,
3082 -1, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3083 -1, 165, -1, 591, -1, -1, -1, -1, -1, -1,
3084 598, -1, -1, -1, 602, 603, 5, 6, -1, 8,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003085 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003086 19, -1, 21, 22, -1, 24, -1, -1, -1, 3,
3087 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
3088 -1, -1, -1, -1, -1, -1, -1, -1, 22, 48,
3089 24, -1, 26, 27, 28, -1, -1, -1, -1, -1,
3090 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003091 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3092 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
3093 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3094 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
3095 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3096 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3097 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
3098 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003099 -1, -1, -1, -1, -1, 154, 3, 4, 157, -1,
3100 7, 160, -1, 162, 163, 139, 140, 141, 142, 143,
3101 144, 145, 146, 147, 148, 149, 150, 151, -1, 26,
3102 27, 28, -1, -1, -1, -1, 160, -1, -1, -1,
3103 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003104 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003105 -1, -1, -1, -1, 61, -1, -1, -1, -1, -1,
3106 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3107 -1, -1, 79, 80, 81, 82, 83, 84, 85, 86,
3108 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
3109 97, 98, 99, 100, 101, 102, 103, 104, -1, -1,
3110 -1, -1, -1, 110, -1, 112, -1, 114, 115, 116,
3111 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3112 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3113 -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
3114 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
3115 -1, 5, 6, 160, 8, 9, 10, 11, 12, 13,
3116 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3117 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3118 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
3119 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003120 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003121 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3122 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3123 -1, 24, -1, -1, -1, 48, -1, -1, -1, -1,
3124 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
3125 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003126 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
3127 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003128 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
3129 -1, -1, -1, -1, -1, -1, 48, -1, -1, -1,
3130 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3131 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3132 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
3133 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3134 -1, 154, 37, -1, 157, -1, 159, 160, -1, 162,
3135 -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003136 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003137 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3138 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003139 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003140 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003141 162, 5, 6, 48, 8, 9, 10, 11, 12, 13,
3142 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3143 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
3144 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3145 24, -1, -1, -1, 48, -1, -1, -1, -1, 154,
3146 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3147 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
3148 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3149 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3150 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3151 -1, 24, -1, -1, -1, 48, -1, -1, -1, 154,
3152 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3153 -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003154 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3155 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003156 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003157 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003158 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003159 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3160 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003161 -1, -1, -1, -1, 35, -1, -1, -1, -1, -1,
3162 -1, 154, -1, -1, 157, -1, -1, 160, 49, 162,
3163 -1, -1, -1, -1, -1, -1, -1, -1, 59, 60,
3164 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3165 -1, 72, 73, 74, 75, 76, 77, 78, 79, 80,
3166 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
3167 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
3168 101, 102, 103, 104, 105, 106, 107, -1, -1, 110,
3169 111, 112, 113, 114, 115, 116, 117, 118, -1, -1,
3170 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3171 -1, -1, -1, -1, -1, -1, -1, -1, 139, 140,
3172 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
3173 151
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003174};
3175
3176/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
3177 symbol of state STATE-NUM. */
3178static const unsigned char yystos[] =
3179{
3180 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003181 44, 45, 46, 47, 62, 181, 219, 222, 224, 232,
3182 22, 24, 51, 58, 62, 180, 212, 224, 225, 61,
3183 220, 23, 233, 234, 30, 163, 221, 233, 52, 53,
3184 54, 71, 209, 152, 61, 20, 45, 47, 50, 181,
3185 152, 45, 47, 223, 24, 207, 64, 65, 66, 67,
3186 68, 69, 70, 182, 217, 180, 238, 152, 152, 152,
3187 152, 157, 210, 207, 5, 6, 8, 9, 10, 11,
3188 12, 13, 14, 15, 16, 17, 18, 19, 21, 48,
3189 154, 157, 160, 162, 167, 189, 190, 191, 192, 193,
3190 212, 229, 32, 33, 199, 199, 199, 199, 226, 4,
3191 189, 29, 162, 218, 35, 49, 59, 60, 72, 73,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003192 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
3193 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3194 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3195 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
3196 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
3197 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003198 175, 235, 236, 242, 243, 245, 246, 24, 55, 56,
3199 208, 4, 24, 24, 211, 4, 4, 4, 162, 8,
3200 163, 193, 194, 155, 164, 191, 191, 191, 9, 10,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003201 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003202 177, 179, 191, 196, 217, 212, 191, 231, 59, 8,
3203 231, 9, 21, 10, 11, 12, 13, 14, 15, 16,
3204 17, 176, 177, 178, 182, 119, 120, 121, 122, 123,
3205 124, 125, 126, 127, 128, 172, 27, 28, 125, 126,
3206 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3207 137, 138, 173, 191, 191, 231, 191, 191, 239, 231,
3208 231, 231, 231, 231, 231, 231, 191, 191, 191, 231,
3209 231, 182, 108, 109, 153, 159, 158, 158, 163, 194,
3210 153, 163, 37, 194, 195, 205, 206, 204, 27, 28,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003211 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
3212 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003213 170, 171, 174, 175, 197, 229, 203, 155, 3, 4,
3214 7, 26, 27, 28, 38, 39, 61, 160, 197, 228,
3215 229, 230, 230, 230, 230, 189, 191, 191, 153, 184,
3216 153, 184, 230, 157, 153, 153, 153, 153, 153, 153,
3217 153, 153, 230, 230, 230, 153, 36, 189, 191, 231,
3218 24, 193, 193, 161, 163, 193, 153, 156, 153, 187,
3219 187, 187, 172, 173, 155, 155, 155, 155, 155, 159,
3220 196, 198, 162, 198, 163, 198, 24, 155, 155, 155,
3221 155, 155, 187, 37, 191, 214, 215, 216, 63, 227,
3222 198, 153, 153, 230, 230, 230, 15, 57, 15, 153,
3223 244, 230, 157, 231, 191, 231, 231, 231, 191, 191,
3224 153, 153, 153, 231, 191, 230, 230, 153, 159, 161,
3225 161, 37, 34, 57, 185, 188, 155, 155, 196, 196,
3226 196, 196, 196, 153, 159, 163, 193, 198, 161, 163,
3227 196, 196, 196, 196, 196, 212, 213, 153, 156, 24,
3228 161, 21, 21, 155, 153, 153, 230, 4, 230, 231,
3229 240, 153, 230, 153, 153, 153, 230, 230, 230, 155,
3230 191, 24, 4, 187, 196, 196, 244, 153, 153, 153,
3231 153, 196, 161, 163, 153, 153, 153, 153, 36, 37,
3232 214, 185, 186, 153, 230, 230, 240, 241, 230, 230,
3233 153, 184, 184, 153, 230, 153, 231, 231, 231, 241,
3234 230, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3235 196, 196, 196, 191, 57, 183, 24, 153, 157, 156,
3236 231, 159, 230, 156, 196, 196, 153, 156, 153, 153,
3237 156, 156, 156, 156, 156, 4, 21, 159, 178, 237,
3238 36, 159, 156, 156, 196, 196, 196, 230, 228, 159,
3239 178, 21, 156, 156, 156, 153, 228, 230, 21, 153,
3240 235, 230, 21, 21, 230, 230
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003241};
Reid Spencere7c3c602006-11-30 06:36:44 +00003242
3243#define yyerrok (yyerrstatus = 0)
3244#define yyclearin (yychar = YYEMPTY)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003245#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003246#define YYEOF 0
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003247
Reid Spencere7c3c602006-11-30 06:36:44 +00003248#define YYACCEPT goto yyacceptlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003249#define YYABORT goto yyabortlab
3250#define YYERROR goto yyerrorlab
3251
3252
3253/* Like YYERROR except do call yyerror. This remains here temporarily
3254 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003255 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003256
Reid Spencere7c3c602006-11-30 06:36:44 +00003257#define YYFAIL goto yyerrlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003258
Reid Spencere7c3c602006-11-30 06:36:44 +00003259#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003260
3261#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003262do \
3263 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003264 { \
3265 yychar = (Token); \
3266 yylval = (Value); \
3267 yytoken = YYTRANSLATE (yychar); \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003268 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003269 goto yybackup; \
3270 } \
3271 else \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003272 { \
3273 yyerror (YY_("syntax error: cannot back up")); \
3274 YYERROR; \
3275 } \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003276while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003277
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003278
Reid Spencere7c3c602006-11-30 06:36:44 +00003279#define YYTERROR 1
3280#define YYERRCODE 256
3281
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003282
3283/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3284 If N is 0, then set CURRENT to the empty location which ends
3285 the previous symbol: RHS[0] (always defined). */
3286
3287#define YYRHSLOC(Rhs, K) ((Rhs)[K])
3288#ifndef YYLLOC_DEFAULT
3289# define YYLLOC_DEFAULT(Current, Rhs, N) \
3290 do \
3291 if (N) \
3292 { \
3293 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3294 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3295 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3296 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3297 } \
3298 else \
3299 { \
3300 (Current).first_line = (Current).last_line = \
3301 YYRHSLOC (Rhs, 0).last_line; \
3302 (Current).first_column = (Current).last_column = \
3303 YYRHSLOC (Rhs, 0).last_column; \
3304 } \
3305 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003306#endif
3307
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003308
3309/* YY_LOCATION_PRINT -- Print the location on the stream.
3310 This macro was not mandated originally: define only if we know
3311 we won't break user code: when these are the locations we know. */
3312
3313#ifndef YY_LOCATION_PRINT
3314# if YYLTYPE_IS_TRIVIAL
3315# define YY_LOCATION_PRINT(File, Loc) \
3316 fprintf (File, "%d.%d-%d.%d", \
3317 (Loc).first_line, (Loc).first_column, \
3318 (Loc).last_line, (Loc).last_column)
3319# else
3320# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3321# endif
3322#endif
3323
3324
3325/* YYLEX -- calling `yylex' with the right arguments. */
3326
Reid Spencer950bf602007-01-26 08:19:09 +00003327#ifdef YYLEX_PARAM
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003328# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer950bf602007-01-26 08:19:09 +00003329#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003330# define YYLEX yylex ()
Chris Lattner4227bdb2007-02-19 07:34:02 +00003331#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003332
3333/* Enable debugging if requested. */
3334#if YYDEBUG
3335
3336# ifndef YYFPRINTF
3337# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3338# define YYFPRINTF fprintf
3339# endif
3340
3341# define YYDPRINTF(Args) \
3342do { \
3343 if (yydebug) \
3344 YYFPRINTF Args; \
3345} while (0)
3346
3347# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3348do { \
3349 if (yydebug) \
3350 { \
3351 YYFPRINTF (stderr, "%s ", Title); \
3352 yysymprint (stderr, \
3353 Type, Value); \
3354 YYFPRINTF (stderr, "\n"); \
3355 } \
3356} while (0)
3357
3358/*------------------------------------------------------------------.
3359| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3360| TOP (included). |
3361`------------------------------------------------------------------*/
3362
3363#if defined (__STDC__) || defined (__cplusplus)
3364static void
3365yy_stack_print (short int *bottom, short int *top)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003366#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003367static void
3368yy_stack_print (bottom, top)
3369 short int *bottom;
3370 short int *top;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003371#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003372{
3373 YYFPRINTF (stderr, "Stack now");
3374 for (/* Nothing. */; bottom <= top; ++bottom)
3375 YYFPRINTF (stderr, " %d", *bottom);
3376 YYFPRINTF (stderr, "\n");
3377}
3378
3379# define YY_STACK_PRINT(Bottom, Top) \
3380do { \
3381 if (yydebug) \
3382 yy_stack_print ((Bottom), (Top)); \
3383} while (0)
3384
3385
3386/*------------------------------------------------.
3387| Report that the YYRULE is going to be reduced. |
3388`------------------------------------------------*/
3389
3390#if defined (__STDC__) || defined (__cplusplus)
3391static void
3392yy_reduce_print (int yyrule)
3393#else
3394static void
3395yy_reduce_print (yyrule)
3396 int yyrule;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003397#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003398{
3399 int yyi;
3400 unsigned long int yylno = yyrline[yyrule];
3401 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3402 yyrule - 1, yylno);
3403 /* Print the symbols being reduced, and their result. */
3404 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3405 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3406 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3407}
Reid Spencer9d6565a2007-02-15 02:26:10 +00003408
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003409# define YY_REDUCE_PRINT(Rule) \
3410do { \
3411 if (yydebug) \
3412 yy_reduce_print (Rule); \
3413} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00003414
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003415/* Nonzero means print parse trace. It is left uninitialized so that
3416 multiple parsers can coexist. */
3417int yydebug;
3418#else /* !YYDEBUG */
3419# define YYDPRINTF(Args)
3420# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3421# define YY_STACK_PRINT(Bottom, Top)
3422# define YY_REDUCE_PRINT(Rule)
3423#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00003424
Reid Spencer9d6565a2007-02-15 02:26:10 +00003425
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003426/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003427#ifndef YYINITDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003428# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003429#endif
3430
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003431/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3432 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003433
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003434 Do not make this value too large; the results are undefined if
3435 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3436 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003437
3438#ifndef YYMAXDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003439# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003440#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003441
Reid Spencere7c3c602006-11-30 06:36:44 +00003442
3443
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003444#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003445
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003446# ifndef yystrlen
3447# if defined (__GLIBC__) && defined (_STRING_H)
3448# define yystrlen strlen
3449# else
3450/* Return the length of YYSTR. */
3451static YYSIZE_T
3452# if defined (__STDC__) || defined (__cplusplus)
3453yystrlen (const char *yystr)
3454# else
3455yystrlen (yystr)
3456 const char *yystr;
3457# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003458{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003459 const char *yys = yystr;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003460
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003461 while (*yys++ != '\0')
3462 continue;
3463
3464 return yys - yystr - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003465}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003466# endif
3467# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003468
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003469# ifndef yystpcpy
3470# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3471# define yystpcpy stpcpy
3472# else
3473/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3474 YYDEST. */
3475static char *
3476# if defined (__STDC__) || defined (__cplusplus)
3477yystpcpy (char *yydest, const char *yysrc)
3478# else
3479yystpcpy (yydest, yysrc)
3480 char *yydest;
3481 const char *yysrc;
3482# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003483{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003484 char *yyd = yydest;
3485 const char *yys = yysrc;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003486
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003487 while ((*yyd++ = *yys++) != '\0')
3488 continue;
3489
3490 return yyd - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003491}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003492# endif
3493# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003494
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003495# ifndef yytnamerr
3496/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3497 quotes and backslashes, so that it's suitable for yyerror. The
3498 heuristic is that double-quoting is unnecessary unless the string
3499 contains an apostrophe, a comma, or backslash (other than
3500 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3501 null, do not copy; instead, return the length of what the result
3502 would have been. */
3503static YYSIZE_T
3504yytnamerr (char *yyres, const char *yystr)
3505{
3506 if (*yystr == '"')
3507 {
3508 size_t yyn = 0;
3509 char const *yyp = yystr;
3510
3511 for (;;)
3512 switch (*++yyp)
3513 {
3514 case '\'':
3515 case ',':
3516 goto do_not_strip_quotes;
3517
3518 case '\\':
3519 if (*++yyp != '\\')
3520 goto do_not_strip_quotes;
3521 /* Fall through. */
3522 default:
3523 if (yyres)
3524 yyres[yyn] = *yyp;
3525 yyn++;
3526 break;
3527
3528 case '"':
3529 if (yyres)
3530 yyres[yyn] = '\0';
3531 return yyn;
3532 }
3533 do_not_strip_quotes: ;
3534 }
3535
3536 if (! yyres)
3537 return yystrlen (yystr);
3538
3539 return yystpcpy (yyres, yystr) - yyres;
3540}
3541# endif
3542
3543#endif /* YYERROR_VERBOSE */
3544
Reid Spencer9d6565a2007-02-15 02:26:10 +00003545
3546
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003547#if YYDEBUG
3548/*--------------------------------.
3549| Print this symbol on YYOUTPUT. |
3550`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00003551
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003552#if defined (__STDC__) || defined (__cplusplus)
3553static void
3554yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003555#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003556static void
3557yysymprint (yyoutput, yytype, yyvaluep)
3558 FILE *yyoutput;
3559 int yytype;
3560 YYSTYPE *yyvaluep;
3561#endif
3562{
3563 /* Pacify ``unused variable'' warnings. */
3564 (void) yyvaluep;
3565
3566 if (yytype < YYNTOKENS)
3567 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3568 else
3569 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3570
3571
3572# ifdef YYPRINT
3573 if (yytype < YYNTOKENS)
3574 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3575# endif
3576 switch (yytype)
3577 {
3578 default:
3579 break;
3580 }
3581 YYFPRINTF (yyoutput, ")");
3582}
3583
3584#endif /* ! YYDEBUG */
3585/*-----------------------------------------------.
3586| Release the memory associated to this symbol. |
3587`-----------------------------------------------*/
3588
3589#if defined (__STDC__) || defined (__cplusplus)
3590static void
3591yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3592#else
3593static void
3594yydestruct (yymsg, yytype, yyvaluep)
3595 const char *yymsg;
3596 int yytype;
3597 YYSTYPE *yyvaluep;
3598#endif
3599{
3600 /* Pacify ``unused variable'' warnings. */
3601 (void) yyvaluep;
3602
3603 if (!yymsg)
3604 yymsg = "Deleting";
3605 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3606
3607 switch (yytype)
3608 {
3609
3610 default:
3611 break;
3612 }
3613}
3614
3615
3616/* Prevent warnings from -Wmissing-prototypes. */
3617
3618#ifdef YYPARSE_PARAM
3619# if defined (__STDC__) || defined (__cplusplus)
3620int yyparse (void *YYPARSE_PARAM);
3621# else
3622int yyparse ();
3623# endif
3624#else /* ! YYPARSE_PARAM */
3625#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003626int yyparse (void);
Chris Lattner4227bdb2007-02-19 07:34:02 +00003627#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003628int yyparse ();
3629#endif
3630#endif /* ! YYPARSE_PARAM */
3631
3632
3633
3634/* The look-ahead symbol. */
3635int yychar;
3636
3637/* The semantic value of the look-ahead symbol. */
3638YYSTYPE yylval;
3639
3640/* Number of syntax errors so far. */
3641int yynerrs;
3642
3643
3644
3645/*----------.
3646| yyparse. |
3647`----------*/
3648
3649#ifdef YYPARSE_PARAM
3650# if defined (__STDC__) || defined (__cplusplus)
3651int yyparse (void *YYPARSE_PARAM)
3652# else
3653int yyparse (YYPARSE_PARAM)
3654 void *YYPARSE_PARAM;
3655# endif
3656#else /* ! YYPARSE_PARAM */
3657#if defined (__STDC__) || defined (__cplusplus)
3658int
3659yyparse (void)
3660#else
3661int
3662yyparse ()
3663
3664#endif
3665#endif
3666{
3667
3668 int yystate;
3669 int yyn;
3670 int yyresult;
3671 /* Number of tokens to shift before error messages enabled. */
3672 int yyerrstatus;
3673 /* Look-ahead token as an internal (translated) token number. */
3674 int yytoken = 0;
3675
3676 /* Three stacks and their tools:
3677 `yyss': related to states,
3678 `yyvs': related to semantic values,
3679 `yyls': related to locations.
3680
3681 Refer to the stacks thru separate pointers, to allow yyoverflow
3682 to reallocate them elsewhere. */
3683
3684 /* The state stack. */
3685 short int yyssa[YYINITDEPTH];
3686 short int *yyss = yyssa;
3687 short int *yyssp;
3688
3689 /* The semantic value stack. */
3690 YYSTYPE yyvsa[YYINITDEPTH];
3691 YYSTYPE *yyvs = yyvsa;
3692 YYSTYPE *yyvsp;
3693
3694
3695
Chris Lattnercf3d0612007-02-13 06:04:17 +00003696#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003697
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003698 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003699
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003700 /* The variables used to return semantic value and location from the
3701 action routines. */
3702 YYSTYPE yyval;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003703
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003704
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003705 /* When reducing, the number of symbols on the RHS of the reduced
3706 rule. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003707 int yylen;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003708
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003709 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003710
Reid Spencere7c3c602006-11-30 06:36:44 +00003711 yystate = 0;
3712 yyerrstatus = 0;
3713 yynerrs = 0;
3714 yychar = YYEMPTY; /* Cause a token to be read. */
3715
3716 /* Initialize stack pointers.
3717 Waste one element of value and location stack
3718 so that they stay on the same level as the state stack.
3719 The wasted elements are never initialized. */
3720
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003721 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003722 yyvsp = yyvs;
3723
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003724 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003725
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003726/*------------------------------------------------------------.
3727| yynewstate -- Push a new state, which is found in yystate. |
3728`------------------------------------------------------------*/
3729 yynewstate:
3730 /* In all cases, when you get here, the value and location stacks
3731 have just been pushed. so pushing a state here evens the stacks.
3732 */
3733 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003734
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003735 yysetstate:
3736 *yyssp = yystate;
3737
3738 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003739 {
3740 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003741 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003742
3743#ifdef yyoverflow
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003744 {
3745 /* Give user a chance to reallocate the stack. Use copies of
3746 these so that the &'s don't force the real ones into
3747 memory. */
3748 YYSTYPE *yyvs1 = yyvs;
3749 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003750
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003751
3752 /* Each stack pointer address is followed by the size of the
3753 data in use in that stack, in bytes. This used to be a
3754 conditional around just the two extra args, but that might
3755 be undefined if yyoverflow is a macro. */
3756 yyoverflow (YY_("memory exhausted"),
3757 &yyss1, yysize * sizeof (*yyssp),
3758 &yyvs1, yysize * sizeof (*yyvsp),
3759
3760 &yystacksize);
3761
3762 yyss = yyss1;
3763 yyvs = yyvs1;
3764 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003765#else /* no yyoverflow */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003766# ifndef YYSTACK_RELOCATE
3767 goto yyexhaustedlab;
3768# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003769 /* Extend the stack our own way. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003770 if (YYMAXDEPTH <= yystacksize)
3771 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003772 yystacksize *= 2;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003773 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003774 yystacksize = YYMAXDEPTH;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003775
3776 {
3777 short int *yyss1 = yyss;
3778 union yyalloc *yyptr =
3779 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3780 if (! yyptr)
3781 goto yyexhaustedlab;
3782 YYSTACK_RELOCATE (yyss);
3783 YYSTACK_RELOCATE (yyvs);
3784
3785# undef YYSTACK_RELOCATE
3786 if (yyss1 != yyssa)
3787 YYSTACK_FREE (yyss1);
3788 }
3789# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003790#endif /* no yyoverflow */
3791
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003792 yyssp = yyss + yysize - 1;
3793 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003794
3795
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003796 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3797 (unsigned long int) yystacksize));
3798
3799 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003800 YYABORT;
3801 }
3802
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003803 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003804
3805 goto yybackup;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003806
3807/*-----------.
3808| yybackup. |
3809`-----------*/
3810yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003811
Chris Lattnercf3d0612007-02-13 06:04:17 +00003812/* Do appropriate processing given the current state. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003813/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003814/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003815
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003816 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003817
Reid Spencere7c3c602006-11-30 06:36:44 +00003818 yyn = yypact[yystate];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003819 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003820 goto yydefault;
3821
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003822 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003823
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003824 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003825 if (yychar == YYEMPTY)
3826 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003827 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003828 yychar = YYLEX;
3829 }
3830
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003831 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003832 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003833 yychar = yytoken = YYEOF;
3834 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003835 }
3836 else
3837 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003838 yytoken = YYTRANSLATE (yychar);
3839 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003840 }
3841
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003842 /* If the proper action on seeing token YYTOKEN is to reduce or to
3843 detect an error, take that action. */
3844 yyn += yytoken;
3845 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003846 goto yydefault;
3847 yyn = yytable[yyn];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003848 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003849 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003850 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003851 goto yyerrlab;
3852 yyn = -yyn;
3853 goto yyreduce;
3854 }
3855
3856 if (yyn == YYFINAL)
3857 YYACCEPT;
3858
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003859 /* Shift the look-ahead token. */
3860 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencerb7046c72007-01-29 05:41:34 +00003861
Chris Lattnercf3d0612007-02-13 06:04:17 +00003862 /* Discard the token being shifted unless it is eof. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003863 if (yychar != YYEOF)
3864 yychar = YYEMPTY;
3865
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003866 *++yyvsp = yylval;
3867
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003868
3869 /* Count tokens shifted since error; after three, turn off error
3870 status. */
3871 if (yyerrstatus)
3872 yyerrstatus--;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003873
3874 yystate = yyn;
Reid Spencere7c3c602006-11-30 06:36:44 +00003875 goto yynewstate;
3876
Chris Lattner4227bdb2007-02-19 07:34:02 +00003877
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003878/*-----------------------------------------------------------.
3879| yydefault -- do the default action for the current state. |
3880`-----------------------------------------------------------*/
3881yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003882 yyn = yydefact[yystate];
3883 if (yyn == 0)
3884 goto yyerrlab;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003885 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003886
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003887
3888/*-----------------------------.
3889| yyreduce -- Do a reduction. |
3890`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003891yyreduce:
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003892 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003893 yylen = yyr2[yyn];
3894
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003895 /* If YYLEN is nonzero, implement the default value of the action:
3896 `$$ = $1'.
3897
3898 Otherwise, the following line sets YYVAL to garbage.
3899 This behavior is undocumented and Bison
3900 users should not rely upon it. Assigning to YYVAL
3901 unconditionally makes the parser a bit smaller, and it avoids a
3902 GCC warning that YYVAL may be used uninitialized. */
3903 yyval = yyvsp[1-yylen];
3904
3905
3906 YY_REDUCE_PRINT (yyn);
3907 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003908 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003909 case 3:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003910#line 1834 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003911 {
3912 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003913 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003914 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3915 ;}
3916 break;
3917
3918 case 5:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003919#line 1843 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003920 {
3921 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003922 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003923 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3924 ;}
3925 break;
3926
3927 case 26:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003928#line 1865 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003929 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3930 break;
3931
3932 case 27:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003933#line 1865 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003934 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3935 break;
3936
3937 case 28:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003938#line 1866 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003939 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3940 break;
3941
3942 case 29:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003943#line 1866 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003944 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3945 break;
3946
3947 case 30:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003948#line 1867 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003949 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3950 break;
3951
3952 case 31:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003953#line 1867 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003954 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3955 break;
3956
3957 case 32:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003958#line 1868 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003959 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3960 break;
3961
3962 case 33:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003963#line 1868 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003964 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3965 break;
3966
3967 case 34:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003968#line 1869 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003969 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3970 break;
3971
3972 case 35:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003973#line 1869 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003974 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3975 break;
3976
3977 case 36:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003978#line 1873 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003979 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3980 break;
3981
3982 case 37:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003983#line 1873 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003984 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
3985 break;
3986
3987 case 38:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003988#line 1874 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003989 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
3990 break;
3991
3992 case 39:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003993#line 1874 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003994 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
3995 break;
3996
3997 case 40:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003998#line 1875 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003999 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
4000 break;
4001
4002 case 41:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004003#line 1875 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004004 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
4005 break;
4006
4007 case 42:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004008#line 1876 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004009 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
4010 break;
4011
4012 case 43:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004013#line 1876 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004014 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
4015 break;
4016
4017 case 44:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004018#line 1877 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004019 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
4020 break;
4021
4022 case 45:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004023#line 1877 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004024 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
4025 break;
4026
4027 case 46:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004028#line 1878 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004029 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
4030 break;
4031
4032 case 47:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004033#line 1878 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004034 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
4035 break;
4036
4037 case 48:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004038#line 1879 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004039 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
4040 break;
4041
4042 case 49:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004043#line 1879 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004044 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
4045 break;
4046
4047 case 50:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004048#line 1880 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004049 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
4050 break;
4051
4052 case 51:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004053#line 1881 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004054 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
4055 break;
4056
4057 case 81:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004058#line 1912 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004059 {
4060 (yyval.StrVal) = (yyvsp[-1].StrVal);
4061 ;}
4062 break;
4063
4064 case 82:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004065#line 1915 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004066 {
4067 (yyval.StrVal) = 0;
4068 ;}
4069 break;
4070
4071 case 83:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004072#line 1920 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004073 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
4074 break;
4075
4076 case 84:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004077#line 1921 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004078 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
4079 break;
4080
4081 case 85:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004082#line 1922 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004083 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
4084 break;
4085
4086 case 86:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004087#line 1923 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004088 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
4089 break;
4090
4091 case 87:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004092#line 1924 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004093 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
4094 break;
4095
4096 case 88:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004097#line 1925 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004098 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
4099 break;
4100
4101 case 89:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004102#line 1926 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004103 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
4104 break;
4105
4106 case 90:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004107#line 1927 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004108 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
4109 break;
4110
4111 case 91:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004112#line 1931 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004113 { (yyval.UIntVal) = OldCallingConv::C; ;}
4114 break;
4115
4116 case 92:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004117#line 1932 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004118 { (yyval.UIntVal) = OldCallingConv::C; ;}
4119 break;
4120
4121 case 93:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004122#line 1933 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004123 { (yyval.UIntVal) = OldCallingConv::CSRet; ;}
4124 break;
4125
4126 case 94:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004127#line 1934 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004128 { (yyval.UIntVal) = OldCallingConv::Fast; ;}
4129 break;
4130
4131 case 95:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004132#line 1935 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004133 { (yyval.UIntVal) = OldCallingConv::Cold; ;}
4134 break;
4135
4136 case 96:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004137#line 1936 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004138 { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
4139 break;
4140
4141 case 97:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004142#line 1937 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004143 { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
4144 break;
4145
4146 case 98:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004147#line 1938 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004148 {
4149 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004150 error("Calling conv too large");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004151 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4152 ;}
4153 break;
4154
4155 case 99:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004156#line 1948 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004157 { (yyval.UIntVal) = 0; ;}
4158 break;
4159
4160 case 100:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004161#line 1949 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004162 {
4163 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4164 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004165 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004166 ;}
4167 break;
4168
4169 case 101:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004170#line 1957 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004171 { (yyval.UIntVal) = 0; ;}
4172 break;
4173
4174 case 102:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004175#line 1958 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004176 {
4177 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4178 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004179 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004180 ;}
4181 break;
4182
4183 case 103:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004184#line 1966 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004185 {
4186 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
4187 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00004188 error("Invalid character in section name");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004189 (yyval.StrVal) = (yyvsp[0].StrVal);
4190 ;}
4191 break;
4192
4193 case 104:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004194#line 1975 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004195 { (yyval.StrVal) = 0; ;}
4196 break;
4197
4198 case 105:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004199#line 1976 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004200 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
4201 break;
4202
4203 case 106:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004204#line 1983 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004205 {;}
4206 break;
4207
4208 case 107:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004209#line 1984 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004210 {;}
4211 break;
4212
4213 case 108:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004214#line 1988 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004215 {
4216 CurGV->setSection((yyvsp[0].StrVal));
4217 free((yyvsp[0].StrVal));
4218 ;}
4219 break;
4220
4221 case 109:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004222#line 1992 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004223 {
4224 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004225 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004226 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004227
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004228 ;}
4229 break;
4230
4231 case 111:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004232#line 2009 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004233 {
4234 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004235 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004236 ;}
4237 break;
4238
4239 case 113:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004240#line 2017 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004241 {
4242 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004243 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004244 ;}
4245 break;
4246
4247 case 114:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004248#line 2024 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004249 {
Reid Spencer950bf602007-01-26 08:19:09 +00004250 if (!UpRefs.empty())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004251 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription());
4252 (yyval.TypeVal) = (yyvsp[0].TypeVal);
4253 ;}
4254 break;
4255
4256 case 127:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004257#line 2038 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004258 {
4259 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004260 (yyval.TypeVal).S.copy((yyvsp[0].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004261 ;}
4262 break;
4263
4264 case 128:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004265#line 2042 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004266 {
4267 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004268 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004269 ;}
4270 break;
4271
4272 case 129:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004273#line 2046 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004274 { // Named types are also simple types...
Reid Spencerbb1fd572007-03-21 17:15:50 +00004275 (yyval.TypeVal).S.copy(getTypeSign((yyvsp[0].ValIDVal)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004276 const Type* tmp = getType((yyvsp[0].ValIDVal));
4277 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004278 ;}
4279 break;
4280
4281 case 130:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004282#line 2051 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004283 { // Type UpReference
4284 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004285 error("Value out of range");
4286 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004287 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
4288 (yyval.TypeVal).PAT = new PATypeHolder(OT);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004289 (yyval.TypeVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00004290 UR_OUT("New Upreference!\n");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004291 ;}
4292 break;
4293
4294 case 131:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004295#line 2060 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004296 { // Function derived type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004297 (yyval.TypeVal).S.makeComposite((yyvsp[-3].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004298 std::vector<const Type*> Params;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004299 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4300 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004301 Params.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004302 (yyval.TypeVal).S.add(I->S);
Reid Spencer52402b02007-01-02 05:45:11 +00004303 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004304 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00004305 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4306 if (isVarArg) Params.pop_back();
4307
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004308 (yyval.TypeVal).PAT = new PATypeHolder(
4309 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg,
Reid Spencerbb1fd572007-03-21 17:15:50 +00004310 ParamAttrs), (yyval.TypeVal).S));
4311 delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004312 delete (yyvsp[-1].TypeList); // Delete the argument list
4313 ;}
4314 break;
4315
4316 case 132:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004317#line 2078 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004318 { // Sized array type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004319 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004320 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(),
Reid Spencerbb1fd572007-03-21 17:15:50 +00004321 (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004322 delete (yyvsp[-1].TypeVal).PAT;
4323 ;}
4324 break;
4325
4326 case 133:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004327#line 2084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004328 { // Vector type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004329 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get();
4330 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
4331 error("Unsigned result not equal to signed result");
4332 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4333 error("Elements of a VectorType must be integer or floating point");
4334 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
4335 error("VectorType length should be a power of 2");
4336 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
4337 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4338 (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S));
4339 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004340 ;}
4341 break;
4342
4343 case 134:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004344#line 2097 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004345 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004346 std::vector<const Type*> Elements;
Reid Spencerbb1fd572007-03-21 17:15:50 +00004347 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004348 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
Reid Spencerbb1fd572007-03-21 17:15:50 +00004349 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004350 Elements.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004351 (yyval.TypeVal).S.add(I->S);
4352 }
4353 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004354 delete (yyvsp[-1].TypeList);
4355 ;}
4356 break;
4357
4358 case 135:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004359#line 2108 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004360 { // Empty structure type?
4361 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004362 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004363 ;}
4364 break;
4365
4366 case 136:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004367#line 2112 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004368 { // Packed Structure type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004369 (yyval.TypeVal).S.makeComposite();
Reid Spencer950bf602007-01-26 08:19:09 +00004370 std::vector<const Type*> Elements;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004371 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4372 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004373 Elements.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004374 (yyval.TypeVal).S.add(I->S);
Reid Spencered96d1e2007-02-08 09:08:52 +00004375 delete I->PAT;
Reid Spencer52402b02007-01-02 05:45:11 +00004376 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00004377 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
4378 (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004379 delete (yyvsp[-2].TypeList);
4380 ;}
4381 break;
4382
4383 case 137:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004384#line 2125 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004385 { // Empty packed structure type?
4386 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004387 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004388 ;}
4389 break;
4390
4391 case 138:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004392#line 2129 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004393 { // Pointer type?
4394 if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004395 error("Cannot form a pointer to a basic block");
Reid Spencerbb1fd572007-03-21 17:15:50 +00004396 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
4397 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get()),
4398 (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004399 delete (yyvsp[-1].TypeVal).PAT;
4400 ;}
4401 break;
4402
4403 case 139:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004404#line 2143 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004405 {
4406 (yyval.TypeList) = new std::list<PATypeInfo>();
4407 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4408 ;}
4409 break;
4410
4411 case 140:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004412#line 2147 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004413 {
4414 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4415 ;}
4416 break;
4417
4418 case 142:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004419#line 2155 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004420 {
Reid Spencer950bf602007-01-26 08:19:09 +00004421 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004422 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004423 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004424 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4425 ;}
4426 break;
4427
4428 case 143:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004429#line 2161 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004430 {
4431 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencer950bf602007-01-26 08:19:09 +00004432 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004433 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004434 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004435 (yyval.TypeList)->push_back(VoidTI);
4436 ;}
4437 break;
4438
4439 case 144:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004440#line 2168 "/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 ;}
4444 break;
4445
4446 case 145:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004447#line 2180 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004448 { // Nonempty unsized arr
4449 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004450 if (ATy == 0)
4451 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004452 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004453 const Type *ETy = ATy->getElementType();
4454 int NumElements = ATy->getNumElements();
4455
4456 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004457 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004458 error("Type mismatch: constant sized array initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004459 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004460 itostr(NumElements) + "");
4461
4462 // Verify all elements are correct type!
4463 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004464 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4465 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004466 const Type* ValTy = C->getType();
4467 if (ETy != ValTy)
4468 error("Element #" + utostr(i) + " is not of type '" +
4469 ETy->getDescription() +"' as required!\nIt is of type '"+
4470 ValTy->getDescription() + "'");
4471 Elems.push_back(C);
4472 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004473 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004474 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004475 delete (yyvsp[-3].TypeVal).PAT;
4476 delete (yyvsp[-1].ConstVector);
4477 ;}
4478 break;
4479
4480 case 146:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004481#line 2210 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004482 {
4483 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004484 if (ATy == 0)
4485 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004486 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004487 int NumElements = ATy->getNumElements();
4488 if (NumElements != -1 && NumElements != 0)
4489 error("Type mismatch: constant sized array initialized with 0"
4490 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004491 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004492 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004493 delete (yyvsp[-2].TypeVal).PAT;
4494 ;}
4495 break;
4496
4497 case 147:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004498#line 2223 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004499 {
4500 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004501 if (ATy == 0)
4502 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004503 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004504 int NumElements = ATy->getNumElements();
4505 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4506 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4507 error("String arrays require type i8, not '" + ETy->getDescription() +
4508 "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004509 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4510 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004511 error("Can't build string constant of size " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004512 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004513 itostr(NumElements) + "");
4514 std::vector<Constant*> Vals;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004515 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004516 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004517 free((yyvsp[0].StrVal));
4518 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004519 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004520 delete (yyvsp[-2].TypeVal).PAT;
4521 ;}
4522 break;
4523
4524 case 148:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004525#line 2246 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004526 { // Nonempty unsized arr
4527 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004528 if (PTy == 0)
4529 error("Cannot make packed constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004530 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004531 const Type *ETy = PTy->getElementType();
4532 int NumElements = PTy->getNumElements();
4533 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004534 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004535 error("Type mismatch: constant sized packed initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004536 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004537 itostr(NumElements) + "");
4538 // Verify all elements are correct type!
4539 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004540 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4541 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004542 const Type* ValTy = C->getType();
4543 if (ETy != ValTy)
4544 error("Element #" + utostr(i) + " is not of type '" +
4545 ETy->getDescription() +"' as required!\nIt is of type '"+
4546 ValTy->getDescription() + "'");
4547 Elems.push_back(C);
4548 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004549 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004550 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004551 delete (yyvsp[-3].TypeVal).PAT;
4552 delete (yyvsp[-1].ConstVector);
4553 ;}
4554 break;
4555
4556 case 149:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004557#line 2274 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004558 {
4559 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004560 if (STy == 0)
4561 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004562 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
4563 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004564 error("Illegal number of initializers for structure type");
4565
4566 // Check to ensure that constants are compatible with the type initializer!
4567 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004568 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4569 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004570 if (C->getType() != STy->getElementType(i))
4571 error("Expected type '" + STy->getElementType(i)->getDescription() +
4572 "' for element #" + utostr(i) + " of structure initializer");
4573 Fields.push_back(C);
4574 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004575 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004576 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004577 delete (yyvsp[-3].TypeVal).PAT;
4578 delete (yyvsp[-1].ConstVector);
4579 ;}
4580 break;
4581
4582 case 150:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004583#line 2296 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004584 {
4585 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004586 if (STy == 0)
4587 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004588 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004589 if (STy->getNumContainedTypes() != 0)
4590 error("Illegal number of initializers for structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004591 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004592 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004593 delete (yyvsp[-2].TypeVal).PAT;
4594 ;}
4595 break;
4596
4597 case 151:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004598#line 2307 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004599 {
4600 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004601 if (STy == 0)
4602 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004603 (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'");
4604 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004605 error("Illegal number of initializers for packed structure type");
4606
4607 // Check to ensure that constants are compatible with the type initializer!
4608 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004609 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4610 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004611 if (C->getType() != STy->getElementType(i))
4612 error("Expected type '" + STy->getElementType(i)->getDescription() +
4613 "' for element #" + utostr(i) + " of packed struct initializer");
4614 Fields.push_back(C);
4615 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004616 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004617 (yyval.ConstVal).S.copy((yyvsp[-5].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004618 delete (yyvsp[-5].TypeVal).PAT;
4619 delete (yyvsp[-2].ConstVector);
4620 ;}
4621 break;
4622
4623 case 152:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004624#line 2329 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004625 {
4626 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004627 if (STy == 0)
4628 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004629 (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004630 if (STy->getNumContainedTypes() != 0)
4631 error("Illegal number of initializers for packed structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004632 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004633 (yyval.ConstVal).S.copy((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004634 delete (yyvsp[-4].TypeVal).PAT;
4635 ;}
4636 break;
4637
4638 case 153:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004639#line 2340 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004640 {
4641 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004642 if (PTy == 0)
4643 error("Cannot make null pointer constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004644 (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'");
4645 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004646 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004647 delete (yyvsp[-1].TypeVal).PAT;
4648 ;}
4649 break;
4650
4651 case 154:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004652#line 2349 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004653 {
4654 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004655 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004656 delete (yyvsp[-1].TypeVal).PAT;
4657 ;}
4658 break;
4659
4660 case 155:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004661#line 2354 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004662 {
4663 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004664 if (Ty == 0)
4665 error("Global const reference must be a pointer type, not" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004666 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004667
4668 // ConstExprs can exist in the body of a function, thus creating
4669 // GlobalValues whenever they refer to a variable. Because we are in
4670 // the context of a function, getExistingValue will search the functions
4671 // symbol table instead of the module symbol table for the global symbol,
4672 // which throws things all off. To get around this, we just tell
4673 // getExistingValue that we are at global scope here.
4674 //
4675 Function *SavedCurFn = CurFun.CurrentFunction;
4676 CurFun.CurrentFunction = 0;
Reid Spencerbb1fd572007-03-21 17:15:50 +00004677 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004678 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004679 CurFun.CurrentFunction = SavedCurFn;
4680
4681 // If this is an initializer for a constant pointer, which is referencing a
4682 // (currently) undefined variable, create a stub now that shall be replaced
4683 // in the future with the right type of variable.
4684 //
4685 if (V == 0) {
4686 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4687 const PointerType *PT = cast<PointerType>(Ty);
4688
4689 // First check to see if the forward references value is already created!
4690 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004691 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004692
4693 if (I != CurModule.GlobalRefs.end()) {
4694 V = I->second; // Placeholder already exists, use it...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004695 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004696 } else {
4697 std::string Name;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004698 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004699
4700 // Create the forward referenced global.
4701 GlobalValue *GV;
4702 if (const FunctionType *FTy =
4703 dyn_cast<FunctionType>(PT->getElementType())) {
4704 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4705 CurModule.CurrentModule);
4706 } else {
4707 GV = new GlobalVariable(PT->getElementType(), false,
4708 GlobalValue::ExternalLinkage, 0,
4709 Name, CurModule.CurrentModule);
4710 }
4711
4712 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004713 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004714 V = GV;
4715 }
4716 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004717 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004718 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004719 delete (yyvsp[-1].TypeVal).PAT; // Free the type handle
4720 ;}
4721 break;
4722
4723 case 156:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004724#line 2413 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004725 {
4726 if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004727 error("Mismatched types for constant expression");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004728 (yyval.ConstVal) = (yyvsp[0].ConstVal);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004729 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004730 delete (yyvsp[-1].TypeVal).PAT;
4731 ;}
4732 break;
4733
4734 case 157:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004735#line 2420 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004736 {
4737 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004738 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4739 error("Cannot create a null initialized value of this type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004740 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004741 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004742 delete (yyvsp[-1].TypeVal).PAT;
4743 ;}
4744 break;
4745
4746 case 158:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004747#line 2428 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004748 { // integral constants
4749 const Type *Ty = (yyvsp[-1].PrimType).T;
4750 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004751 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004752 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004753 (yyval.ConstVal).S.makeSigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004754 ;}
4755 break;
4756
4757 case 159:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004758#line 2435 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004759 { // integral constants
4760 const Type *Ty = (yyvsp[-1].PrimType).T;
4761 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004762 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004763 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004764 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004765 ;}
4766 break;
4767
4768 case 160:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004769#line 2442 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004770 { // Boolean constants
4771 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004772 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004773 ;}
4774 break;
4775
4776 case 161:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004777#line 2446 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004778 { // Boolean constants
4779 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004780 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004781 ;}
4782 break;
4783
4784 case 162:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004785#line 2450 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004786 { // Float & Double constants
4787 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004788 error("Floating point constant invalid for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004789 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004790 (yyval.ConstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004791 ;}
4792 break;
4793
4794 case 163:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004795#line 2459 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004796 {
4797 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4798 const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00004799 Signedness SrcSign((yyvsp[-3].ConstVal).S);
4800 Signedness DstSign((yyvsp[-1].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004801 if (!SrcTy->isFirstClassType())
4802 error("cast constant expression from a non-primitive type: '" +
4803 SrcTy->getDescription() + "'");
4804 if (!DstTy->isFirstClassType())
4805 error("cast constant expression to a non-primitive type: '" +
4806 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004807 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004808 (yyval.ConstVal).S.copy(DstSign);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004809 delete (yyvsp[-1].TypeVal).PAT;
4810 ;}
4811 break;
4812
4813 case 164:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004814#line 2474 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004815 {
4816 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004817 if (!isa<PointerType>(Ty))
4818 error("GetElementPtr requires a pointer operand");
4819
4820 std::vector<Value*> VIndices;
4821 std::vector<Constant*> CIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004822 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004823
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004824 delete (yyvsp[-1].ValueList);
4825 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, &CIndices[0], CIndices.size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004826 (yyval.ConstVal).S.copy(getElementSign((yyvsp[-2].ConstVal), CIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004827 ;}
4828 break;
4829
4830 case 165:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004831#line 2487 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004832 {
4833 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4834 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004835 error("Select condition must be bool type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004836 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004837 error("Select operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004838 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004839 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004840 ;}
4841 break;
4842
4843 case 166:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004844#line 2496 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004845 {
4846 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4847 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004848 error("Binary operator types must match");
4849 // First, make sure we're dealing with the right opcode by upgrading from
4850 // obsolete versions.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004851 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004852
4853 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4854 // To retain backward compatibility with these early compilers, we emit a
4855 // cast to the appropriate integer type automatically if we are in the
4856 // broken case. See PR424 for more information.
4857 if (!isa<PointerType>(Ty)) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004858 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004859 } else {
4860 const Type *IntPtrTy = 0;
4861 switch (CurModule.CurrentModule->getPointerSize()) {
4862 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4863 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4864 default: error("invalid pointer binary constant expr");
4865 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004866 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4867 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4868 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4869 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004870 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00004871 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004872 ;}
4873 break;
4874
4875 case 167:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004876#line 2524 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004877 {
4878 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4879 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004880 error("Logical operator types must match");
4881 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00004882 if (!isa<VectorType>(Ty) ||
4883 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004884 error("Logical operator requires integer operands");
4885 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004886 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4887 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004888 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004889 ;}
4890 break;
4891
4892 case 168:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004893#line 2537 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004894 {
4895 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4896 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004897 error("setcc operand types must match");
4898 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004899 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4900 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004901 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004902 ;}
4903 break;
4904
4905 case 169:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004906#line 2546 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004907 {
4908 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004909 error("icmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004910 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004911 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004912 ;}
4913 break;
4914
4915 case 170:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004916#line 2552 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004917 {
4918 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004919 error("fcmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004920 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004921 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004922 ;}
4923 break;
4924
4925 case 171:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004926#line 2558 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004927 {
4928 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4929 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004930 error("Shift count for shift constant must be unsigned byte");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004931 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4932 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004933 error("Shift constant expression requires integer operand");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004934 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4935 (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 +00004936 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004937 ;}
4938 break;
4939
4940 case 172:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004941#line 2569 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004942 {
4943 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004944 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004945 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004946 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004947 ;}
4948 break;
4949
4950 case 173:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004951#line 2575 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004952 {
4953 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004954 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004955 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004956 (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004957 ;}
4958 break;
4959
4960 case 174:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004961#line 2581 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004962 {
4963 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004964 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004965 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004966 (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004967 ;}
4968 break;
4969
4970 case 175:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004971#line 2592 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004972 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
4973 break;
4974
4975 case 176:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004976#line 2593 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004977 {
4978 (yyval.ConstVector) = new std::vector<ConstInfo>();
4979 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4980 ;}
4981 break;
4982
4983 case 177:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004984#line 2602 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004985 { (yyval.BoolVal) = false; ;}
4986 break;
4987
4988 case 178:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004989#line 2603 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004990 { (yyval.BoolVal) = true; ;}
4991 break;
4992
4993 case 179:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004994#line 2615 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004995 {
4996 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00004997 CurModule.ModuleDone();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004998 ;}
4999 break;
5000
5001 case 180:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005002#line 2624 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005003 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
5004 break;
5005
5006 case 181:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005007#line 2625 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005008 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
5009 break;
5010
5011 case 182:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005012#line 2626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005013 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
5014 break;
5015
5016 case 183:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005017#line 2627 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005018 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
5019 break;
5020
5021 case 184:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005022#line 2628 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005023 {
5024 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer950bf602007-01-26 08:19:09 +00005025 // Emit an error if there are any unresolved types left.
5026 if (!CurModule.LateResolveTypes.empty()) {
5027 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5028 if (DID.Type == ValID::NameVal) {
5029 error("Reference to an undefined type: '"+DID.getName() + "'");
5030 } else {
5031 error("Reference to an undefined type: #" + itostr(DID.Num));
5032 }
5033 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005034 ;}
5035 break;
5036
5037 case 185:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005038#line 2644 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005039 {
Reid Spencer950bf602007-01-26 08:19:09 +00005040 // Eagerly resolve types. This is not an optimization, this is a
5041 // requirement that is due to the fact that we could have this:
5042 //
5043 // %list = type { %list * }
5044 // %list = type { %list * } ; repeated type decl
5045 //
5046 // If types are not resolved eagerly, then the two types will not be
5047 // determined to be the same type!
5048 //
Reid Spencerbb1fd572007-03-21 17:15:50 +00005049 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].TypeVal).PAT->get(), (yyvsp[0].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00005050
Reid Spencerbb1fd572007-03-21 17:15:50 +00005051 if (!setTypeName((yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
5052 // If this is a numbered type that is not a redefinition, add it to the
5053 // slot table.
5054 CurModule.Types.push_back((yyvsp[0].TypeVal).PAT->get());
5055 CurModule.TypeSigns.push_back((yyvsp[0].TypeVal).S);
Reid Spencera50d5962006-12-02 04:11:07 +00005056 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005057 delete (yyvsp[0].TypeVal).PAT;
5058 ;}
5059 break;
5060
5061 case 186:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005062#line 2664 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005063 { // Function prototypes can be in const pool
5064 ;}
5065 break;
5066
5067 case 187:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005068#line 2666 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005069 { // Asm blocks can be in the const pool
5070 ;}
5071 break;
5072
5073 case 188:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005074#line 2668 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005075 {
5076 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005077 error("Global value initializer is not a constant");
Reid Spencerbb1fd572007-03-21 17:15:50 +00005078 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 +00005079 ;}
5080 break;
5081
5082 case 189:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005083#line 2672 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005084 {
Reid Spencer950bf602007-01-26 08:19:09 +00005085 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005086 ;}
5087 break;
5088
5089 case 190:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005090#line 2675 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005091 {
5092 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005093 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5094 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005095 delete (yyvsp[0].TypeVal).PAT;
5096 ;}
5097 break;
5098
5099 case 191:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005100#line 2680 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005101 {
Reid Spencer950bf602007-01-26 08:19:09 +00005102 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005103 ;}
5104 break;
5105
5106 case 192:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005107#line 2683 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005108 {
5109 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005110 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5111 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005112 delete (yyvsp[0].TypeVal).PAT;
5113 ;}
5114 break;
5115
5116 case 193:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005117#line 2688 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005118 {
Reid Spencer950bf602007-01-26 08:19:09 +00005119 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005120 ;}
5121 break;
5122
5123 case 194:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005124#line 2691 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005125 {
5126 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005127 CurGV =
Reid Spencerbb1fd572007-03-21 17:15:50 +00005128 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5129 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005130 delete (yyvsp[0].TypeVal).PAT;
5131 ;}
5132 break;
5133
5134 case 195:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005135#line 2697 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005136 {
Reid Spencer950bf602007-01-26 08:19:09 +00005137 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005138 ;}
5139 break;
5140
5141 case 196:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005142#line 2700 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005143 {
5144 ;}
5145 break;
5146
5147 case 197:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005148#line 2702 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005149 {
5150 ;}
5151 break;
5152
5153 case 198:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005154#line 2704 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005155 {
5156 ;}
5157 break;
5158
5159 case 199:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005160#line 2709 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005161 {
Reid Spencer950bf602007-01-26 08:19:09 +00005162 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005163 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
5164 std::string NewAsm((yyvsp[0].StrVal), EndStr);
5165 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005166
5167 if (AsmSoFar.empty())
5168 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5169 else
5170 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005171 ;}
5172 break;
5173
5174 case 200:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005175#line 2723 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005176 { (yyval.Endianness) = Module::BigEndian; ;}
5177 break;
5178
5179 case 201:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005180#line 2724 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005181 { (yyval.Endianness) = Module::LittleEndian; ;}
5182 break;
5183
5184 case 202:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005185#line 2728 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005186 {
5187 CurModule.setEndianness((yyvsp[0].Endianness));
5188 ;}
5189 break;
5190
5191 case 203:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005192#line 2731 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005193 {
5194 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00005195 CurModule.setPointerSize(Module::Pointer32);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005196 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00005197 CurModule.setPointerSize(Module::Pointer64);
5198 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005199 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
5200 ;}
5201 break;
Reid Spencer9d6565a2007-02-15 02:26:10 +00005202
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005203 case 204:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005204#line 2739 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005205 {
5206 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
5207 free((yyvsp[0].StrVal));
5208 ;}
5209 break;
5210
5211 case 205:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005212#line 2743 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005213 {
5214 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
5215 free((yyvsp[0].StrVal));
5216 ;}
5217 break;
5218
5219 case 207:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005220#line 2754 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005221 {
5222 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5223 free((yyvsp[0].StrVal));
5224 ;}
5225 break;
5226
5227 case 208:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005228#line 2758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005229 {
5230 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5231 free((yyvsp[0].StrVal));
5232 ;}
5233 break;
5234
5235 case 209:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005236#line 2762 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005237 { ;}
5238 break;
5239
5240 case 213:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005241#line 2775 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005242 { (yyval.StrVal) = 0; ;}
5243 break;
5244
5245 case 214:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005246#line 2779 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005247 {
5248 if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy)
5249 error("void typed arguments are invalid");
5250 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
5251 ;}
5252 break;
5253
5254 case 215:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005255#line 2787 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005256 {
5257 (yyval.ArgList) = (yyvsp[-2].ArgList);
5258 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5259 delete (yyvsp[0].ArgVal);
5260 ;}
5261 break;
5262
5263 case 216:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005264#line 2792 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005265 {
5266 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5267 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5268 delete (yyvsp[0].ArgVal);
5269 ;}
5270 break;
5271
5272 case 217:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005273#line 2800 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005274 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
5275 break;
5276
5277 case 218:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005278#line 2801 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005279 {
5280 (yyval.ArgList) = (yyvsp[-2].ArgList);
5281 PATypeInfo VoidTI;
5282 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005283 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005284 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5285 ;}
5286 break;
5287
5288 case 219:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005289#line 2808 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005290 {
5291 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5292 PATypeInfo VoidTI;
5293 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005294 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005295 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5296 ;}
5297 break;
5298
5299 case 220:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005300#line 2815 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005301 { (yyval.ArgList) = 0; ;}
5302 break;
5303
5304 case 221:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005305#line 2819 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005306 {
5307 UnEscapeLexed((yyvsp[-5].StrVal));
5308 std::string FunctionName((yyvsp[-5].StrVal));
5309 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
5310
5311 const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005312
5313 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5314 error("LLVM functions cannot return aggregate types");
5315
Reid Spencerbb1fd572007-03-21 17:15:50 +00005316 Signedness FTySign;
5317 FTySign.makeComposite((yyvsp[-6].TypeVal).S);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005318 std::vector<const Type*> ParamTyList;
Reid Spencer950bf602007-01-26 08:19:09 +00005319
5320 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5321 // i8*. We check here for those names and override the parameter list
5322 // types to ensure the prototype is correct.
5323 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005324 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00005325 } else if (FunctionName == "llvm.va_copy") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005326 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5327 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005328 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005329 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005330 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005331 const Type *Ty = I->first.PAT->get();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005332 ParamTyList.push_back(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005333 FTySign.add(I->first.S);
Reid Spencer950bf602007-01-26 08:19:09 +00005334 }
5335 }
5336
Reid Spenceref9b9a72007-02-05 20:47:22 +00005337 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5338 if (isVarArg)
5339 ParamTyList.pop_back();
Reid Spencer950bf602007-01-26 08:19:09 +00005340
Reid Spencerb7046c72007-01-29 05:41:34 +00005341 // Convert the CSRet calling convention into the corresponding parameter
5342 // attribute.
5343 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005344 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00005345 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5346 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5347 }
5348
Reid Spenceref9b9a72007-02-05 20:47:22 +00005349 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
Reid Spencerb7046c72007-01-29 05:41:34 +00005350 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005351 const PointerType *PFT = PointerType::get(FT);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005352 delete (yyvsp[-6].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005353
5354 ValID ID;
5355 if (!FunctionName.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005356 ID = ValID::create((char*)FunctionName.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00005357 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005358 ID = ValID::create((int)CurModule.Values[PFT].size());
Reid Spencer950bf602007-01-26 08:19:09 +00005359 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005360 ID.S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00005361
5362 Function *Fn = 0;
Reid Spencered96d1e2007-02-08 09:08:52 +00005363 Module* M = CurModule.CurrentModule;
5364
Reid Spencer950bf602007-01-26 08:19:09 +00005365 // See if this function was forward referenced. If so, recycle the object.
5366 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5367 // Move the function to the end of the list, from whereever it was
5368 // previously inserted.
5369 Fn = cast<Function>(FWRef);
Reid Spencered96d1e2007-02-08 09:08:52 +00005370 M->getFunctionList().remove(Fn);
5371 M->getFunctionList().push_back(Fn);
5372 } else if (!FunctionName.empty()) {
5373 GlobalValue *Conflict = M->getFunction(FunctionName);
5374 if (!Conflict)
5375 Conflict = M->getNamedGlobal(FunctionName);
5376 if (Conflict && PFT == Conflict->getType()) {
5377 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5378 // We have two function definitions that conflict, same type, same
5379 // name. We should really check to make sure that this is the result
5380 // of integer type planes collapsing and generate an error if it is
5381 // not, but we'll just rename on the assumption that it is. However,
5382 // let's do it intelligently and rename the internal linkage one
5383 // if there is one.
5384 std::string NewName(makeNameUnique(FunctionName));
5385 if (Conflict->hasInternalLinkage()) {
5386 Conflict->setName(NewName);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005387 RenameMapKey Key =
5388 makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005389 CurModule.RenameMap[Key] = NewName;
5390 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5391 InsertValue(Fn, CurModule.Values);
5392 } else {
5393 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5394 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005395 RenameMapKey Key =
5396 makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005397 CurModule.RenameMap[Key] = NewName;
5398 }
5399 } else {
5400 // If they are not both definitions, then just use the function we
5401 // found since the types are the same.
5402 Fn = cast<Function>(Conflict);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005403
Reid Spencered96d1e2007-02-08 09:08:52 +00005404 // Make sure to strip off any argument names so we can't get
5405 // conflicts.
5406 if (Fn->isDeclaration())
5407 for (Function::arg_iterator AI = Fn->arg_begin(),
5408 AE = Fn->arg_end(); AI != AE; ++AI)
5409 AI->setName("");
5410 }
5411 } else if (Conflict) {
5412 // We have two globals with the same name and different types.
5413 // Previously, this was permitted because the symbol table had
5414 // "type planes" and names only needed to be distinct within a
5415 // type plane. After PR411 was fixed, this is no loner the case.
5416 // To resolve this we must rename one of the two.
5417 if (Conflict->hasInternalLinkage()) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005418 // We can safely rename the Conflict.
5419 RenameMapKey Key =
5420 makeRenameMapKey(Conflict->getName(), Conflict->getType(),
5421 CurModule.NamedValueSigns[Conflict->getName()]);
Reid Spencered96d1e2007-02-08 09:08:52 +00005422 Conflict->setName(makeNameUnique(Conflict->getName()));
Reid Spencered96d1e2007-02-08 09:08:52 +00005423 CurModule.RenameMap[Key] = Conflict->getName();
5424 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5425 InsertValue(Fn, CurModule.Values);
Reid Spencerd2920cd2007-03-21 17:27:53 +00005426 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005427 // We can't quietly rename either of these things, but we must
Reid Spencerd2920cd2007-03-21 17:27:53 +00005428 // rename one of them. Only if the function's linkage is internal can
5429 // we forgo a warning message about the renamed function.
Reid Spencered96d1e2007-02-08 09:08:52 +00005430 std::string NewName = makeNameUnique(FunctionName);
Reid Spencerd2920cd2007-03-21 17:27:53 +00005431 if (CurFun.Linkage != GlobalValue::InternalLinkage) {
5432 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5433 "' may cause linkage errors");
5434 }
5435 // Elect to rename the thing we're now defining.
Reid Spencered96d1e2007-02-08 09:08:52 +00005436 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5437 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005438 RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005439 CurModule.RenameMap[Key] = NewName;
Reid Spencerd2920cd2007-03-21 17:27:53 +00005440 }
Reid Spenceref9b9a72007-02-05 20:47:22 +00005441 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005442 // There's no conflict, just define the function
5443 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5444 InsertValue(Fn, CurModule.Values);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005445 }
Reid Spencer950bf602007-01-26 08:19:09 +00005446 }
5447
5448 CurFun.FunctionStart(Fn);
5449
5450 if (CurFun.isDeclare) {
5451 // If we have declaration, always overwrite linkage. This will allow us
5452 // to correctly handle cases, when pointer to function is passed as
5453 // argument to another function.
5454 Fn->setLinkage(CurFun.Linkage);
5455 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005456 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5457 Fn->setAlignment((yyvsp[0].UIntVal));
5458 if ((yyvsp[-1].StrVal)) {
5459 Fn->setSection((yyvsp[-1].StrVal));
5460 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005461 }
5462
5463 // Add all of the arguments we parsed to the function...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005464 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005465 if (isVarArg) { // Nuke the last entry
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005466 assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5467 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5468 delete (yyvsp[-3].ArgList)->back().first.PAT;
5469 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005470 }
5471 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005472 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005473 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
5474 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005475 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005476 delete I->first.PAT; // Delete the typeholder...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005477 ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
5478 setValueName(VI, I->second); // Insert arg into symtab...
Reid Spencer950bf602007-01-26 08:19:09 +00005479 InsertValue(ArgIt);
5480 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005481 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005482 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005483 ;}
5484 break;
5485
5486 case 224:
Reid Spencerd2920cd2007-03-21 17:27:53 +00005487#line 3004 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5488 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5489 break;
5490
5491 case 225:
5492#line 3004 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005493 {
5494 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005495
5496 // Make sure that we keep track of the linkage type even if there was a
5497 // previous "declare".
Reid Spencerd2920cd2007-03-21 17:27:53 +00005498 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005499 ;}
5500 break;
5501
Reid Spencerd2920cd2007-03-21 17:27:53 +00005502 case 228:
5503#line 3018 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005504 {
5505 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5506 ;}
5507 break;
5508
Reid Spencerd2920cd2007-03-21 17:27:53 +00005509 case 229:
5510#line 3023 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005511 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5512 break;
5513
Reid Spencerd2920cd2007-03-21 17:27:53 +00005514 case 230:
5515#line 3024 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005516 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
5517 break;
5518
Reid Spencerd2920cd2007-03-21 17:27:53 +00005519 case 231:
5520#line 3025 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005521 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
5522 break;
5523
Reid Spencerd2920cd2007-03-21 17:27:53 +00005524 case 232:
5525#line 3029 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005526 { CurFun.isDeclare = true; ;}
5527 break;
5528
Reid Spencerd2920cd2007-03-21 17:27:53 +00005529 case 233:
5530#line 3030 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005531 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5532 break;
5533
Reid Spencerd2920cd2007-03-21 17:27:53 +00005534 case 234:
5535#line 3030 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005536 {
5537 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005538 CurFun.FunctionDone();
5539
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005540 ;}
5541 break;
5542
Reid Spencerd2920cd2007-03-21 17:27:53 +00005543 case 235:
5544#line 3042 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005545 { (yyval.BoolVal) = false; ;}
5546 break;
5547
Reid Spencerd2920cd2007-03-21 17:27:53 +00005548 case 236:
5549#line 3043 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005550 { (yyval.BoolVal) = true; ;}
5551 break;
5552
Reid Spencerd2920cd2007-03-21 17:27:53 +00005553 case 237:
5554#line 3048 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005555 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005556 break;
5557
Reid Spencerd2920cd2007-03-21 17:27:53 +00005558 case 238:
5559#line 3049 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005560 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5561 break;
5562
Reid Spencerd2920cd2007-03-21 17:27:53 +00005563 case 239:
5564#line 3050 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005565 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5566 break;
5567
Reid Spencerd2920cd2007-03-21 17:27:53 +00005568 case 240:
5569#line 3051 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005570 {
5571 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true));
5572 (yyval.ValIDVal).S.makeUnsigned();
5573 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005574 break;
5575
Reid Spencerd2920cd2007-03-21 17:27:53 +00005576 case 241:
5577#line 3055 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005578 {
5579 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false));
5580 (yyval.ValIDVal).S.makeUnsigned();
5581 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005582 break;
5583
Reid Spencerd2920cd2007-03-21 17:27:53 +00005584 case 242:
5585#line 3059 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005586 { (yyval.ValIDVal) = ValID::createNull(); ;}
5587 break;
5588
Reid Spencerd2920cd2007-03-21 17:27:53 +00005589 case 243:
5590#line 3060 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005591 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5592 break;
5593
Reid Spencerd2920cd2007-03-21 17:27:53 +00005594 case 244:
5595#line 3061 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005596 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5597 break;
5598
Reid Spencerd2920cd2007-03-21 17:27:53 +00005599 case 245:
5600#line 3062 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005601 { // Nonempty unsized packed vector
5602 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5603 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005604 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005605 (yyval.ValIDVal).S.makeComposite((*(yyvsp[-1].ConstVector))[0].S);
5606 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S));
Reid Spencer950bf602007-01-26 08:19:09 +00005607
5608 // Verify all elements are correct type!
5609 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005610 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5611 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005612 const Type *CTy = C->getType();
5613 if (ETy != CTy)
5614 error("Element #" + utostr(i) + " is not of type '" +
5615 ETy->getDescription() +"' as required!\nIt is of type '" +
5616 CTy->getDescription() + "'");
5617 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005618 }
Reid Spencer5eb77c72007-03-15 03:26:42 +00005619 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005620 delete PTy; delete (yyvsp[-1].ConstVector);
5621 ;}
5622 break;
5623
Reid Spencerd2920cd2007-03-21 17:27:53 +00005624 case 246:
5625#line 3083 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005626 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005627 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005628 (yyval.ValIDVal).S.copy((yyvsp[0].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005629 ;}
5630 break;
5631
Reid Spencerd2920cd2007-03-21 17:27:53 +00005632 case 247:
5633#line 3087 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005634 {
5635 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5636 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5637 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5638 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5639 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5640 free((yyvsp[-2].StrVal));
5641 free((yyvsp[0].StrVal));
5642 ;}
5643 break;
5644
Reid Spencerd2920cd2007-03-21 17:27:53 +00005645 case 248:
5646#line 3101 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005647 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005648 break;
5649
Reid Spencerd2920cd2007-03-21 17:27:53 +00005650 case 249:
5651#line 3102 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005652 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005653 break;
5654
Reid Spencerd2920cd2007-03-21 17:27:53 +00005655 case 252:
5656#line 3115 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005657 {
5658 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005659 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer5eb77c72007-03-15 03:26:42 +00005660 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005661 (yyval.ValueVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005662 delete (yyvsp[-1].TypeVal).PAT;
5663 ;}
5664 break;
5665
Reid Spencerd2920cd2007-03-21 17:27:53 +00005666 case 253:
5667#line 3125 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005668 {
5669 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5670 ;}
5671 break;
5672
Reid Spencerd2920cd2007-03-21 17:27:53 +00005673 case 254:
5674#line 3128 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005675 { // Do not allow functions with 0 basic blocks
5676 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5677 ;}
5678 break;
5679
Reid Spencerd2920cd2007-03-21 17:27:53 +00005680 case 255:
5681#line 3137 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005682 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005683 ValueInfo VI; VI.V = (yyvsp[0].TermInstVal).TI; VI.S.copy((yyvsp[0].TermInstVal).S);
5684 setValueName(VI, (yyvsp[-1].StrVal));
5685 InsertValue((yyvsp[0].TermInstVal).TI);
5686 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal).TI);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005687 InsertValue((yyvsp[-2].BasicBlockVal));
5688 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5689 ;}
5690 break;
5691
Reid Spencerd2920cd2007-03-21 17:27:53 +00005692 case 256:
5693#line 3148 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005694 {
5695 if ((yyvsp[0].InstVal).I)
5696 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5697 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5698 ;}
5699 break;
5700
Reid Spencerd2920cd2007-03-21 17:27:53 +00005701 case 257:
5702#line 3153 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005703 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005704 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
Reid Spencer950bf602007-01-26 08:19:09 +00005705 // Make sure to move the basic block to the correct location in the
5706 // function, instead of leaving it inserted wherever it was first
5707 // referenced.
5708 Function::BasicBlockListType &BBL =
5709 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005710 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5711 ;}
5712 break;
5713
Reid Spencerd2920cd2007-03-21 17:27:53 +00005714 case 258:
5715#line 3162 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005716 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005717 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005718 // Make sure to move the basic block to the correct location in the
5719 // function, instead of leaving it inserted wherever it was first
5720 // referenced.
5721 Function::BasicBlockListType &BBL =
5722 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005723 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5724 ;}
5725 break;
5726
Reid Spencerd2920cd2007-03-21 17:27:53 +00005727 case 261:
5728#line 3176 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005729 { // Return with a result...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005730 (yyval.TermInstVal).TI = new ReturnInst((yyvsp[0].ValueVal).V);
5731 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005732 ;}
5733 break;
5734
Reid Spencerd2920cd2007-03-21 17:27:53 +00005735 case 262:
5736#line 3180 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005737 { // Return with no result...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005738 (yyval.TermInstVal).TI = new ReturnInst();
5739 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005740 ;}
5741 break;
5742
Reid Spencerd2920cd2007-03-21 17:27:53 +00005743 case 263:
5744#line 3184 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005745 { // Unconditional Branch...
5746 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005747 (yyval.TermInstVal).TI = new BranchInst(tmpBB);
5748 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005749 ;}
5750 break;
5751
Reid Spencerd2920cd2007-03-21 17:27:53 +00005752 case 264:
5753#line 3189 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005754 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005755 (yyvsp[-3].ValIDVal).S.makeSignless();
5756 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005757 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5758 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005759 (yyvsp[-6].ValIDVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005760 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005761 (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5762 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005763 ;}
5764 break;
5765
Reid Spencerd2920cd2007-03-21 17:27:53 +00005766 case 265:
5767#line 3199 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005768 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005769 (yyvsp[-6].ValIDVal).S.copy((yyvsp[-7].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005770 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005771 (yyvsp[-3].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005772 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5773 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00005774 (yyval.TermInstVal).TI = S;
5775 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005776 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5777 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005778 for (; I != E; ++I) {
5779 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5780 S->addCase(CI, I->second);
5781 else
5782 error("Switch case is constant, but not a simple integer");
5783 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005784 delete (yyvsp[-1].JumpTable);
5785 ;}
5786 break;
5787
Reid Spencerd2920cd2007-03-21 17:27:53 +00005788 case 266:
5789#line 3217 "/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[-5].ValIDVal).S.copy((yyvsp[-6].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005792 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005793 (yyvsp[-2].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005794 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005795 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005796 (yyval.TermInstVal).TI = S;
5797 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005798 ;}
5799 break;
5800
Reid Spencerd2920cd2007-03-21 17:27:53 +00005801 case 267:
5802#line 3227 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005803 {
Reid Spencer950bf602007-01-26 08:19:09 +00005804 const PointerType *PFTy;
5805 const FunctionType *Ty;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005806 Signedness FTySign;
Reid Spencer950bf602007-01-26 08:19:09 +00005807
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005808 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005809 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5810 // Pull out the types of all of the arguments...
5811 std::vector<const Type*> ParamTypes;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005812 FTySign.makeComposite((yyvsp[-10].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005813 if ((yyvsp[-7].ValueList)) {
5814 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005815 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005816 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00005817 FTySign.add(I->S);
5818 }
Reid Spencer950bf602007-01-26 08:19:09 +00005819 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005820 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005821 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00005822 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5823 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5824 }
Reid Spencer950bf602007-01-26 08:19:09 +00005825 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5826 if (isVarArg) ParamTypes.pop_back();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005827 Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005828 PFTy = PointerType::get(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005829 (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S);
5830 } else {
5831 FTySign = (yyvsp[-10].TypeVal).S;
5832 (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S.get(0)); // 0th element of FuncTy sign is result ty
Reid Spencer950bf602007-01-26 08:19:09 +00005833 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005834 (yyvsp[-9].ValIDVal).S.makeComposite(FTySign);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005835 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5836 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5837 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005838
5839 // Create the call node...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005840 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencerbb1fd572007-03-21 17:15:50 +00005841 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0);
Reid Spencer950bf602007-01-26 08:19:09 +00005842 } else { // Has arguments?
5843 // Loop through FunctionType's arguments and ensure they are specified
5844 // correctly!
5845 //
5846 FunctionType::param_iterator I = Ty->param_begin();
5847 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005848 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005849
5850 std::vector<Value*> Args;
5851 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5852 if ((*ArgI).V->getType() != *I)
5853 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5854 (*I)->getDescription() + "'");
5855 Args.push_back((*ArgI).V);
5856 }
5857
5858 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5859 error("Invalid number of parameters detected");
5860
Reid Spencerbb1fd572007-03-21 17:15:50 +00005861 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00005862 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005863 cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005864 delete (yyvsp[-10].TypeVal).PAT;
5865 delete (yyvsp[-7].ValueList);
5866 ;}
5867 break;
5868
Reid Spencerd2920cd2007-03-21 17:27:53 +00005869 case 268:
5870#line 3291 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005871 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005872 (yyval.TermInstVal).TI = new UnwindInst();
5873 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005874 ;}
5875 break;
5876
Reid Spencerd2920cd2007-03-21 17:27:53 +00005877 case 269:
5878#line 3295 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005879 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005880 (yyval.TermInstVal).TI = new UnreachableInst();
5881 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005882 ;}
5883 break;
5884
Reid Spencerd2920cd2007-03-21 17:27:53 +00005885 case 270:
5886#line 3302 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005887 {
5888 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005889 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005890 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005891
5892 if (V == 0)
5893 error("May only switch on a constant pool value");
5894
Reid Spencerbb1fd572007-03-21 17:15:50 +00005895 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005896 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5897 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5898 ;}
5899 break;
5900
Reid Spencerd2920cd2007-03-21 17:27:53 +00005901 case 271:
5902#line 3314 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005903 {
5904 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005905 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005906 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005907
5908 if (V == 0)
5909 error("May only switch on a constant pool value");
5910
Reid Spencerbb1fd572007-03-21 17:15:50 +00005911 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005912 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5913 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5914 ;}
5915 break;
5916
Reid Spencerd2920cd2007-03-21 17:27:53 +00005917 case 272:
5918#line 3329 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005919 {
Reid Spencer950bf602007-01-26 08:19:09 +00005920 bool omit = false;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005921 if ((yyvsp[-1].StrVal))
5922 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005923 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005924 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005925 // This is a useless bit cast causing a name redefinition. It is
5926 // a bit cast from a type to the same type of an operand with the
5927 // same name as the name we would give this instruction. Since this
5928 // instruction results in no code generation, it is safe to omit
5929 // the instruction. This situation can occur because of collapsed
5930 // type planes. For example:
5931 // %X = add int %Y, %Z
5932 // %X = cast int %Y to uint
5933 // After upgrade, this looks like:
5934 // %X = add i32 %Y, %Z
5935 // %X = bitcast i32 to i32
5936 // The bitcast is clearly useless so we omit it.
5937 omit = true;
5938 if (omit) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005939 (yyval.InstVal).I = 0;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005940 (yyval.InstVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00005941 } else {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005942 ValueInfo VI; VI.V = (yyvsp[0].InstVal).I; VI.S.copy((yyvsp[0].InstVal).S);
5943 setValueName(VI, (yyvsp[-1].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005944 InsertValue((yyvsp[0].InstVal).I);
5945 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005946 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005947 ;}
5948 break;
5949
Reid Spencerd2920cd2007-03-21 17:27:53 +00005950 case 273:
5951#line 3359 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005952 { // Used for PHI nodes
5953 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005954 (yyval.PHIList).S.copy((yyvsp[-5].TypeVal).S);
5955 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-5].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005956 Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005957 (yyvsp[-1].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005958 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5959 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5960 delete (yyvsp[-5].TypeVal).PAT;
5961 ;}
5962 break;
5963
Reid Spencerd2920cd2007-03-21 17:27:53 +00005964 case 274:
5965#line 3369 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005966 {
5967 (yyval.PHIList) = (yyvsp[-6].PHIList);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005968 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-6].PHIList).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005969 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005970 (yyvsp[-1].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005971 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5972 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5973 ;}
5974 break;
5975
Reid Spencerd2920cd2007-03-21 17:27:53 +00005976 case 275:
5977#line 3379 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005978 { // Used for call statements, and memory insts...
5979 (yyval.ValueList) = new std::vector<ValueInfo>();
5980 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5981 ;}
5982 break;
5983
Reid Spencerd2920cd2007-03-21 17:27:53 +00005984 case 276:
5985#line 3383 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005986 {
5987 (yyval.ValueList) = (yyvsp[-2].ValueList);
5988 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
5989 ;}
5990 break;
5991
Reid Spencerd2920cd2007-03-21 17:27:53 +00005992 case 278:
5993#line 3391 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005994 { (yyval.ValueList) = 0; ;}
5995 break;
5996
Reid Spencerd2920cd2007-03-21 17:27:53 +00005997 case 279:
5998#line 3395 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005999 {
6000 (yyval.BoolVal) = true;
6001 ;}
6002 break;
6003
Reid Spencerd2920cd2007-03-21 17:27:53 +00006004 case 280:
6005#line 3398 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006006 {
6007 (yyval.BoolVal) = false;
6008 ;}
6009 break;
6010
Reid Spencerd2920cd2007-03-21 17:27:53 +00006011 case 281:
6012#line 3404 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006013 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006014 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6015 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006016 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006017 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
Reid Spencer950bf602007-01-26 08:19:09 +00006018 error("Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer9d6565a2007-02-15 02:26:10 +00006019 if (isa<VectorType>(Ty) &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006020 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Chris Lattner4227bdb2007-02-19 07:34:02 +00006021 error("Remainder not supported on vector types");
Reid Spencer950bf602007-01-26 08:19:09 +00006022 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006023 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
6024 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6025 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
6026 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
6027 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006028 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006029 (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006030 delete (yyvsp[-3].TypeVal).PAT;
6031 ;}
6032 break;
6033
Reid Spencerd2920cd2007-03-21 17:27:53 +00006034 case 282:
6035#line 3423 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006036 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006037 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6038 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006039 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006040 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00006041 if (!isa<VectorType>(Ty) ||
6042 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006043 error("Logical operator requires integral operands");
6044 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006045 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
6046 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6047 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6048 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
6049 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006050 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006051 (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006052 delete (yyvsp[-3].TypeVal).PAT;
6053 ;}
6054 break;
6055
Reid Spencerd2920cd2007-03-21 17:27:53 +00006056 case 283:
6057#line 3441 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006058 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006059 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6060 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006061 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006062 if(isa<VectorType>(Ty))
6063 error("VectorTypes currently not supported in setcc instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006064 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006065 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
6066 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6067 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6068 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
6069 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006070 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006071 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006072 delete (yyvsp[-3].TypeVal).PAT;
6073 ;}
6074 break;
6075
Reid Spencerd2920cd2007-03-21 17:27:53 +00006076 case 284:
6077#line 3457 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006078 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006079 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6080 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006081 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006082 if (isa<VectorType>(Ty))
6083 error("VectorTypes currently not supported in icmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006084 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
6085 error("icmp requires integer or pointer typed operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006086 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6087 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6088 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006089 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006090 delete (yyvsp[-3].TypeVal).PAT;
6091 ;}
6092 break;
6093
Reid Spencerd2920cd2007-03-21 17:27:53 +00006094 case 285:
6095#line 3471 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006096 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006097 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6098 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006099 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006100 if (isa<VectorType>(Ty))
6101 error("VectorTypes currently not supported in fcmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006102 else if (!Ty->isFloatingPoint())
6103 error("fcmp instruction requires floating point operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006104 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6105 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6106 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006107 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006108 delete (yyvsp[-3].TypeVal).PAT;
6109 ;}
6110 break;
6111
Reid Spencerd2920cd2007-03-21 17:27:53 +00006112 case 286:
6113#line 3485 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006114 {
Reid Spencer950bf602007-01-26 08:19:09 +00006115 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006116 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006117 Value *Ones = ConstantInt::getAllOnesValue(Ty);
6118 if (Ones == 0)
6119 error("Expected integral type for not instruction");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006120 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
6121 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006122 error("Could not create a xor instruction");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006123 (yyval.InstVal).S.copy((yyvsp[0].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006124 ;}
6125 break;
6126
Reid Spencerd2920cd2007-03-21 17:27:53 +00006127 case 287:
6128#line 3496 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006129 {
6130 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
6131 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00006132 error("Shift amount must be int8");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006133 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
Reid Spencer832254e2007-02-02 02:16:23 +00006134 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006135 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00006136 Value* ShiftAmt = 0;
6137 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006138 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
Reid Spencer832254e2007-02-02 02:16:23 +00006139 ShiftAmt = ConstantExpr::getZExt(C, Ty);
6140 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006141 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
Reid Spencer832254e2007-02-02 02:16:23 +00006142 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006143 ShiftAmt = (yyvsp[0].ValueVal).V;
6144 (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 +00006145 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006146 ;}
6147 break;
6148
Reid Spencerd2920cd2007-03-21 17:27:53 +00006149 case 288:
6150#line 3514 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006151 {
6152 const Type *DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006153 if (!DstTy->isFirstClassType())
6154 error("cast instruction to a non-primitive type: '" +
6155 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006156 (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 +00006157 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006158 delete (yyvsp[0].TypeVal).PAT;
6159 ;}
6160 break;
6161
Reid Spencerd2920cd2007-03-21 17:27:53 +00006162 case 289:
6163#line 3523 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006164 {
6165 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
6166 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00006167 error("select condition must be bool");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006168 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00006169 error("select value types should match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006170 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006171 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006172 ;}
6173 break;
6174
Reid Spencerd2920cd2007-03-21 17:27:53 +00006175 case 290:
6176#line 3532 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006177 {
6178 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006179 NewVarArgs = true;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006180 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006181 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006182 delete (yyvsp[0].TypeVal).PAT;
6183 ;}
6184 break;
6185
Reid Spencerd2920cd2007-03-21 17:27:53 +00006186 case 291:
6187#line 3539 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006188 {
6189 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
6190 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006191 ObsoleteVarArgs = true;
6192 Function* NF = cast<Function>(CurModule.CurrentModule->
6193 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6194
6195 //b = vaarg a, t ->
6196 //foo = alloca 1 of t
6197 //bar = vacopy a
6198 //store bar -> foo
6199 //b = vaarg foo, t
6200 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
6201 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006202 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006203 CurBB->getInstList().push_back(bar);
6204 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006205 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006206 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006207 delete (yyvsp[0].TypeVal).PAT;
6208 ;}
6209 break;
6210
Reid Spencerd2920cd2007-03-21 17:27:53 +00006211 case 292:
6212#line 3560 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006213 {
6214 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
6215 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006216 ObsoleteVarArgs = true;
6217 Function* NF = cast<Function>(CurModule.CurrentModule->
6218 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6219
6220 //b = vanext a, t ->
6221 //foo = alloca 1 of t
6222 //bar = vacopy a
6223 //store bar -> foo
6224 //tmp = vaarg foo, t
6225 //b = load foo
6226 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
6227 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006228 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006229 CurBB->getInstList().push_back(bar);
6230 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6231 Instruction* tmp = new VAArgInst(foo, DstTy);
6232 CurBB->getInstList().push_back(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006233 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006234 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006235 delete (yyvsp[0].TypeVal).PAT;
6236 ;}
6237 break;
6238
Reid Spencerd2920cd2007-03-21 17:27:53 +00006239 case 293:
6240#line 3584 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006241 {
6242 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006243 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006244 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006245 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006246 ;}
6247 break;
6248
Reid Spencerd2920cd2007-03-21 17:27:53 +00006249 case 294:
6250#line 3590 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006251 {
6252 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006253 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006254 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006255 (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006256 ;}
6257 break;
6258
Reid Spencerd2920cd2007-03-21 17:27:53 +00006259 case 295:
6260#line 3596 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006261 {
6262 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006263 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006264 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006265 (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006266 ;}
6267 break;
6268
Reid Spencerd2920cd2007-03-21 17:27:53 +00006269 case 296:
6270#line 3602 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006271 {
6272 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006273 if (!Ty->isFirstClassType())
6274 error("PHI node operands must be of first class type");
6275 PHINode *PHI = new PHINode(Ty);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006276 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
6277 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
6278 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00006279 error("All elements of a PHI node must be of the same type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006280 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
6281 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00006282 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006283 (yyval.InstVal).I = PHI;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006284 (yyval.InstVal).S.copy((yyvsp[0].PHIList).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006285 delete (yyvsp[0].PHIList).P; // Free the list...
6286 ;}
6287 break;
Reid Spencer950bf602007-01-26 08:19:09 +00006288
Reid Spencerd2920cd2007-03-21 17:27:53 +00006289 case 297:
6290#line 3618 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006291 {
Reid Spencer950bf602007-01-26 08:19:09 +00006292 // Handle the short call syntax
6293 const PointerType *PFTy;
6294 const FunctionType *FTy;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006295 Signedness FTySign;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006296 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006297 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6298 // Pull out the types of all of the arguments...
6299 std::vector<const Type*> ParamTypes;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006300 FTySign.makeComposite((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006301 if ((yyvsp[-1].ValueList)) {
6302 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006303 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00006304 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006305 FTySign.add(I->S);
6306 }
Reid Spencer950bf602007-01-26 08:19:09 +00006307 }
6308
Reid Spencerb7046c72007-01-29 05:41:34 +00006309 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006310 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00006311 ParamAttrs.push_back(FunctionType::NoAttributeSet);
6312 ParamAttrs.push_back(FunctionType::StructRetAttribute);
6313 }
Reid Spencer950bf602007-01-26 08:19:09 +00006314 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6315 if (isVarArg) ParamTypes.pop_back();
6316
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006317 const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006318 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6319 error("Functions cannot return aggregate types");
6320
Reid Spencerb7046c72007-01-29 05:41:34 +00006321 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00006322 PFTy = PointerType::get(FTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006323 (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S);
6324 } else {
6325 FTySign = (yyvsp[-4].TypeVal).S;
6326 (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S.get(0)); // 0th element of FuncTy signedness is result sign
Reid Spencer950bf602007-01-26 08:19:09 +00006327 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00006328 (yyvsp[-3].ValIDVal).S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00006329
6330 // First upgrade any intrinsic calls.
6331 std::vector<Value*> Args;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006332 if ((yyvsp[-1].ValueList))
6333 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
6334 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
6335 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006336
6337 // If we got an upgraded intrinsic
6338 if (Inst) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006339 (yyval.InstVal).I = Inst;
Reid Spencer950bf602007-01-26 08:19:09 +00006340 } else {
6341 // Get the function we're calling
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006342 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006343
6344 // Check the argument values match
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006345 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006346 // Make sure no arguments is a good thing!
6347 if (FTy->getNumParams() != 0)
6348 error("No arguments passed to a function that expects arguments");
6349 } else { // Has arguments?
6350 // Loop through FunctionType's arguments and ensure they are specified
6351 // correctly!
6352 //
6353 FunctionType::param_iterator I = FTy->param_begin();
6354 FunctionType::param_iterator E = FTy->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006355 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006356
6357 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6358 if ((*ArgI).V->getType() != *I)
6359 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6360 (*I)->getDescription() + "'");
6361
6362 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6363 error("Invalid number of parameters detected");
6364 }
6365
6366 // Create the call instruction
Chris Lattnercf3d0612007-02-13 06:04:17 +00006367 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006368 CI->setTailCall((yyvsp[-6].BoolVal));
6369 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
6370 (yyval.InstVal).I = CI;
Reid Spencer950bf602007-01-26 08:19:09 +00006371 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006372 delete (yyvsp[-4].TypeVal).PAT;
6373 delete (yyvsp[-1].ValueList);
6374 ;}
6375 break;
6376
Reid Spencerd2920cd2007-03-21 17:27:53 +00006377 case 298:
6378#line 3702 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006379 {
6380 (yyval.InstVal) = (yyvsp[0].InstVal);
6381 ;}
6382 break;
6383
Reid Spencerd2920cd2007-03-21 17:27:53 +00006384 case 299:
6385#line 3710 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006386 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
6387 break;
6388
Reid Spencerd2920cd2007-03-21 17:27:53 +00006389 case 300:
6390#line 3711 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006391 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6392 break;
6393
Reid Spencerd2920cd2007-03-21 17:27:53 +00006394 case 301:
6395#line 3715 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006396 { (yyval.BoolVal) = true; ;}
6397 break;
6398
Reid Spencerd2920cd2007-03-21 17:27:53 +00006399 case 302:
6400#line 3716 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006401 { (yyval.BoolVal) = false; ;}
6402 break;
6403
Reid Spencerd2920cd2007-03-21 17:27:53 +00006404 case 303:
6405#line 3720 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006406 {
6407 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006408 (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006409 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6410 delete (yyvsp[-1].TypeVal).PAT;
6411 ;}
6412 break;
6413
Reid Spencerd2920cd2007-03-21 17:27:53 +00006414 case 304:
6415#line 3726 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006416 {
6417 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006418 (yyvsp[-1].ValIDVal).S.makeUnsigned();
6419 (yyval.InstVal).S.makeComposite((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006420 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6421 delete (yyvsp[-4].TypeVal).PAT;
6422 ;}
6423 break;
6424
Reid Spencerd2920cd2007-03-21 17:27:53 +00006425 case 305:
6426#line 3733 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006427 {
6428 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006429 (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006430 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6431 delete (yyvsp[-1].TypeVal).PAT;
6432 ;}
6433 break;
6434
Reid Spencerd2920cd2007-03-21 17:27:53 +00006435 case 306:
6436#line 3739 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006437 {
6438 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006439 (yyvsp[-1].ValIDVal).S.makeUnsigned();
6440 (yyval.InstVal).S.makeComposite((yyvsp[-2].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006441 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6442 delete (yyvsp[-4].TypeVal).PAT;
6443 ;}
6444 break;
6445
Reid Spencerd2920cd2007-03-21 17:27:53 +00006446 case 307:
6447#line 3746 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006448 {
6449 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006450 if (!isa<PointerType>(PTy))
6451 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006452 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006453 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006454 ;}
6455 break;
6456
Reid Spencerd2920cd2007-03-21 17:27:53 +00006457 case 308:
6458#line 3753 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006459 {
6460 const Type* Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006461 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00006462 if (!isa<PointerType>(Ty))
6463 error("Can't load from nonpointer type: " + Ty->getDescription());
6464 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6465 error("Can't load from pointer of non-first-class type: " +
6466 Ty->getDescription());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006467 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6468 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006469 (yyval.InstVal).S.copy((yyvsp[-1].TypeVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006470 delete (yyvsp[-1].TypeVal).PAT;
6471 ;}
6472 break;
6473
Reid Spencerd2920cd2007-03-21 17:27:53 +00006474 case 309:
6475#line 3766 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006476 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006477 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006478 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencered96d1e2007-02-08 09:08:52 +00006479 if (!PTy)
6480 error("Can't store to a nonpointer type: " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006481 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencered96d1e2007-02-08 09:08:52 +00006482 const Type *ElTy = PTy->getElementType();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006483 Value *StoreVal = (yyvsp[-3].ValueVal).V;
6484 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6485 if (ElTy != (yyvsp[-3].ValueVal).V->getType()) {
6486 StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy);
Reid Spencered96d1e2007-02-08 09:08:52 +00006487 if (!StoreVal)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006488 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencered96d1e2007-02-08 09:08:52 +00006489 "' into space of type '" + ElTy->getDescription() + "'");
6490 else {
6491 PTy = PointerType::get(StoreVal->getType());
6492 if (Constant *C = dyn_cast<Constant>(tmpVal))
6493 tmpVal = ConstantExpr::getBitCast(C, PTy);
6494 else
6495 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6496 }
6497 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006498 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006499 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006500 delete (yyvsp[-1].TypeVal).PAT;
6501 ;}
6502 break;
6503
Reid Spencerd2920cd2007-03-21 17:27:53 +00006504 case 310:
6505#line 3792 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006506 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006507 (yyvsp[-1].ValIDVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006508 const Type* Ty = (yyvsp[-2].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006509 if (!isa<PointerType>(Ty))
6510 error("getelementptr insn requires pointer operand");
6511
6512 std::vector<Value*> VIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006513 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006514
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006515 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
6516 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006517 ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[-2].TypeVal).S);
6518 (yyval.InstVal).S.copy(getElementSign(VI, VIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006519 delete (yyvsp[-2].TypeVal).PAT;
6520 delete (yyvsp[0].ValueList);
6521 ;}
6522 break;
6523
6524
6525 default: break;
6526 }
6527
6528/* Line 1126 of yacc.c. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00006529#line 6528 "UpgradeParser.tab.c"
Chris Lattnercf3d0612007-02-13 06:04:17 +00006530
6531 yyvsp -= yylen;
6532 yyssp -= yylen;
Reid Spencerb7046c72007-01-29 05:41:34 +00006533
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006534
6535 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006536
6537 *++yyvsp = yyval;
6538
6539
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006540 /* Now `shift' the result of the reduction. Determine what state
6541 that goes to, based on the state we popped back to and the rule
6542 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006543
6544 yyn = yyr1[yyn];
6545
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006546 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6547 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006548 yystate = yytable[yystate];
6549 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006550 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006551
6552 goto yynewstate;
6553
6554
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006555/*------------------------------------.
6556| yyerrlab -- here on detecting error |
6557`------------------------------------*/
6558yyerrlab:
6559 /* If not already recovering from an error, report this error. */
6560 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006561 {
6562 ++yynerrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006563#if YYERROR_VERBOSE
Chris Lattnercf3d0612007-02-13 06:04:17 +00006564 yyn = yypact[yystate];
6565
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006566 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006567 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006568 int yytype = YYTRANSLATE (yychar);
6569 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6570 YYSIZE_T yysize = yysize0;
6571 YYSIZE_T yysize1;
6572 int yysize_overflow = 0;
6573 char *yymsg = 0;
6574# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6575 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6576 int yyx;
Chris Lattnercf3d0612007-02-13 06:04:17 +00006577
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006578#if 0
6579 /* This is so xgettext sees the translatable formats that are
6580 constructed on the fly. */
6581 YY_("syntax error, unexpected %s");
6582 YY_("syntax error, unexpected %s, expecting %s");
6583 YY_("syntax error, unexpected %s, expecting %s or %s");
6584 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6585 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6586#endif
6587 char *yyfmt;
6588 char const *yyf;
6589 static char const yyunexpected[] = "syntax error, unexpected %s";
6590 static char const yyexpecting[] = ", expecting %s";
6591 static char const yyor[] = " or %s";
6592 char yyformat[sizeof yyunexpected
6593 + sizeof yyexpecting - 1
6594 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6595 * (sizeof yyor - 1))];
6596 char const *yyprefix = yyexpecting;
6597
6598 /* Start YYX at -YYN if negative to avoid negative indexes in
6599 YYCHECK. */
6600 int yyxbegin = yyn < 0 ? -yyn : 0;
6601
6602 /* Stay within bounds of both yycheck and yytname. */
6603 int yychecklim = YYLAST - yyn;
6604 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6605 int yycount = 1;
6606
6607 yyarg[0] = yytname[yytype];
6608 yyfmt = yystpcpy (yyformat, yyunexpected);
6609
6610 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6611 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6612 {
6613 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6614 {
6615 yycount = 1;
6616 yysize = yysize0;
6617 yyformat[sizeof yyunexpected - 1] = '\0';
6618 break;
6619 }
6620 yyarg[yycount++] = yytname[yyx];
6621 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6622 yysize_overflow |= yysize1 < yysize;
6623 yysize = yysize1;
6624 yyfmt = yystpcpy (yyfmt, yyprefix);
6625 yyprefix = yyor;
6626 }
6627
6628 yyf = YY_(yyformat);
6629 yysize1 = yysize + yystrlen (yyf);
6630 yysize_overflow |= yysize1 < yysize;
6631 yysize = yysize1;
6632
6633 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6634 yymsg = (char *) YYSTACK_ALLOC (yysize);
6635 if (yymsg)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006636 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006637 /* Avoid sprintf, as that infringes on the user's name space.
6638 Don't have undefined behavior even if the translation
6639 produced a string with the wrong number of "%s"s. */
6640 char *yyp = yymsg;
6641 int yyi = 0;
6642 while ((*yyp = *yyf))
Chris Lattnercf3d0612007-02-13 06:04:17 +00006643 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006644 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6645 {
6646 yyp += yytnamerr (yyp, yyarg[yyi++]);
6647 yyf += 2;
6648 }
6649 else
6650 {
6651 yyp++;
6652 yyf++;
6653 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006654 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006655 yyerror (yymsg);
6656 YYSTACK_FREE (yymsg);
Chris Lattnercf3d0612007-02-13 06:04:17 +00006657 }
6658 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006659 {
6660 yyerror (YY_("syntax error"));
6661 goto yyexhaustedlab;
6662 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006663 }
6664 else
6665#endif /* YYERROR_VERBOSE */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006666 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006667 }
Reid Spencer950bf602007-01-26 08:19:09 +00006668
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006669
Reid Spencer950bf602007-01-26 08:19:09 +00006670
6671 if (yyerrstatus == 3)
6672 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006673 /* If just tried and failed to reuse look-ahead token after an
6674 error, discard it. */
Reid Spencer950bf602007-01-26 08:19:09 +00006675
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006676 if (yychar <= YYEOF)
6677 {
6678 /* Return failure if at end of input. */
6679 if (yychar == YYEOF)
6680 YYABORT;
6681 }
6682 else
6683 {
6684 yydestruct ("Error: discarding", yytoken, &yylval);
6685 yychar = YYEMPTY;
6686 }
6687 }
6688
6689 /* Else will try to reuse look-ahead token after shifting the error
6690 token. */
6691 goto yyerrlab1;
6692
6693
6694/*---------------------------------------------------.
6695| yyerrorlab -- error raised explicitly by YYERROR. |
6696`---------------------------------------------------*/
6697yyerrorlab:
6698
6699 /* Pacify compilers like GCC when the user code never invokes
6700 YYERROR and the label yyerrorlab therefore never appears in user
6701 code. */
6702 if (0)
6703 goto yyerrorlab;
6704
6705yyvsp -= yylen;
6706 yyssp -= yylen;
6707 yystate = *yyssp;
6708 goto yyerrlab1;
6709
6710
6711/*-------------------------------------------------------------.
6712| yyerrlab1 -- common code for both syntax error and YYERROR. |
6713`-------------------------------------------------------------*/
6714yyerrlab1:
6715 yyerrstatus = 3; /* Each real token shifted decrements this. */
6716
6717 for (;;)
6718 {
6719 yyn = yypact[yystate];
6720 if (yyn != YYPACT_NINF)
6721 {
6722 yyn += YYTERROR;
6723 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6724 {
6725 yyn = yytable[yyn];
6726 if (0 < yyn)
6727 break;
6728 }
6729 }
6730
6731 /* Pop the current state because it cannot handle the error token. */
6732 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006733 YYABORT;
6734
6735
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006736 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6737 YYPOPSTACK;
6738 yystate = *yyssp;
6739 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006740 }
6741
6742 if (yyn == YYFINAL)
6743 YYACCEPT;
6744
6745 *++yyvsp = yylval;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006746
6747
6748 /* Shift the error token. */
6749 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer950bf602007-01-26 08:19:09 +00006750
Reid Spencere7c3c602006-11-30 06:36:44 +00006751 yystate = yyn;
6752 goto yynewstate;
6753
Chris Lattner4227bdb2007-02-19 07:34:02 +00006754
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006755/*-------------------------------------.
6756| yyacceptlab -- YYACCEPT comes here. |
6757`-------------------------------------*/
6758yyacceptlab:
6759 yyresult = 0;
6760 goto yyreturn;
6761
6762/*-----------------------------------.
6763| yyabortlab -- YYABORT comes here. |
6764`-----------------------------------*/
6765yyabortlab:
6766 yyresult = 1;
6767 goto yyreturn;
6768
6769#ifndef yyoverflow
6770/*-------------------------------------------------.
6771| yyexhaustedlab -- memory exhaustion comes here. |
6772`-------------------------------------------------*/
6773yyexhaustedlab:
6774 yyerror (YY_("memory exhausted"));
6775 yyresult = 2;
6776 /* Fall through. */
Chris Lattner4227bdb2007-02-19 07:34:02 +00006777#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006778
6779yyreturn:
6780 if (yychar != YYEOF && yychar != YYEMPTY)
6781 yydestruct ("Cleanup: discarding lookahead",
6782 yytoken, &yylval);
6783 while (yyssp != yyss)
6784 {
6785 yydestruct ("Cleanup: popping",
6786 yystos[*yyssp], yyvsp);
6787 YYPOPSTACK;
Chris Lattner4227bdb2007-02-19 07:34:02 +00006788 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006789#ifndef yyoverflow
6790 if (yyss != yyssa)
6791 YYSTACK_FREE (yyss);
6792#endif
6793 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006794}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006795
6796
Reid Spencerd2920cd2007-03-21 17:27:53 +00006797#line 3810 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006798
6799
6800int yyerror(const char *ErrorMsg) {
6801 std::string where
6802 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006803 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006804 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6805 if (yychar != YYEMPTY && yychar != 0)
6806 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6807 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006808 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006809 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006810 exit(1);
6811}
Reid Spencer319a7302007-01-05 17:20:02 +00006812
Reid Spencer30d0c582007-01-15 00:26:18 +00006813void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006814 std::string where
6815 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006816 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006817 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6818 if (yychar != YYEMPTY && yychar != 0)
6819 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6820 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006821 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6822}
6823
Reid Spencer950bf602007-01-26 08:19:09 +00006824void error(const std::string& ErrorMsg, int LineNo) {
6825 if (LineNo == -1) LineNo = Upgradelineno;
6826 Upgradelineno = LineNo;
6827 yyerror(ErrorMsg.c_str());
6828}
6829
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006830