blob: bf154251962ceb7fe0bbe7d4edd03a88c65dabf9 [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
1545void Signedness::dump() const {
1546 if (isComposite()) {
1547 if (sv->size() == 1) {
1548 (*sv)[0].dump();
1549 std::cerr << "*";
1550 } else {
1551 std::cerr << "{ " ;
1552 for (unsigned i = 0; i < sv->size(); ++i) {
1553 if (i != 0)
1554 std::cerr << ", ";
1555 (*sv)[i].dump();
1556 }
1557 std::cerr << "} " ;
1558 }
1559 } else if (isNamed()) {
1560 std::cerr << *name;
1561 } else if (isSigned()) {
1562 std::cerr << "S";
1563 } else if (isUnsigned()) {
1564 std::cerr << "U";
1565 } else
1566 std::cerr << ".";
1567}
1568
Reid Spencer950bf602007-01-26 08:19:09 +00001569static inline Instruction::TermOps
1570getTermOp(TermOps op) {
1571 switch (op) {
1572 default : assert(0 && "Invalid OldTermOp");
1573 case RetOp : return Instruction::Ret;
1574 case BrOp : return Instruction::Br;
1575 case SwitchOp : return Instruction::Switch;
1576 case InvokeOp : return Instruction::Invoke;
1577 case UnwindOp : return Instruction::Unwind;
1578 case UnreachableOp: return Instruction::Unreachable;
1579 }
1580}
1581
1582static inline Instruction::BinaryOps
Reid Spencerbb1fd572007-03-21 17:15:50 +00001583getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001584 switch (op) {
1585 default : assert(0 && "Invalid OldBinaryOps");
1586 case SetEQ :
1587 case SetNE :
1588 case SetLE :
1589 case SetGE :
1590 case SetLT :
1591 case SetGT : assert(0 && "Should use getCompareOp");
1592 case AddOp : return Instruction::Add;
1593 case SubOp : return Instruction::Sub;
1594 case MulOp : return Instruction::Mul;
1595 case DivOp : {
1596 // This is an obsolete instruction so we must upgrade it based on the
1597 // types of its operands.
1598 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001599 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001600 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001601 isFP = PTy->getElementType()->isFloatingPoint();
1602 if (isFP)
1603 return Instruction::FDiv;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001604 else if (Sign.isSigned())
Reid Spencer950bf602007-01-26 08:19:09 +00001605 return Instruction::SDiv;
1606 return Instruction::UDiv;
1607 }
1608 case UDivOp : return Instruction::UDiv;
1609 case SDivOp : return Instruction::SDiv;
1610 case FDivOp : return Instruction::FDiv;
1611 case RemOp : {
1612 // This is an obsolete instruction so we must upgrade it based on the
1613 // types of its operands.
1614 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001615 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001616 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001617 isFP = PTy->getElementType()->isFloatingPoint();
1618 // Select correct opcode
1619 if (isFP)
1620 return Instruction::FRem;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001621 else if (Sign.isSigned())
Reid Spencer950bf602007-01-26 08:19:09 +00001622 return Instruction::SRem;
1623 return Instruction::URem;
1624 }
1625 case URemOp : return Instruction::URem;
1626 case SRemOp : return Instruction::SRem;
1627 case FRemOp : return Instruction::FRem;
Reid Spencer832254e2007-02-02 02:16:23 +00001628 case LShrOp : return Instruction::LShr;
1629 case AShrOp : return Instruction::AShr;
1630 case ShlOp : return Instruction::Shl;
1631 case ShrOp :
Reid Spencerbb1fd572007-03-21 17:15:50 +00001632 if (Sign.isSigned())
Reid Spencer832254e2007-02-02 02:16:23 +00001633 return Instruction::AShr;
1634 return Instruction::LShr;
Reid Spencer950bf602007-01-26 08:19:09 +00001635 case AndOp : return Instruction::And;
1636 case OrOp : return Instruction::Or;
1637 case XorOp : return Instruction::Xor;
1638 }
1639}
1640
1641static inline Instruction::OtherOps
1642getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
Reid Spencerbb1fd572007-03-21 17:15:50 +00001643 const Signedness &Sign) {
1644 bool isSigned = Sign.isSigned();
Reid Spencer950bf602007-01-26 08:19:09 +00001645 bool isFP = Ty->isFloatingPoint();
1646 switch (op) {
1647 default : assert(0 && "Invalid OldSetCC");
1648 case SetEQ :
1649 if (isFP) {
1650 predicate = FCmpInst::FCMP_OEQ;
1651 return Instruction::FCmp;
1652 } else {
1653 predicate = ICmpInst::ICMP_EQ;
1654 return Instruction::ICmp;
1655 }
1656 case SetNE :
1657 if (isFP) {
1658 predicate = FCmpInst::FCMP_UNE;
1659 return Instruction::FCmp;
1660 } else {
1661 predicate = ICmpInst::ICMP_NE;
1662 return Instruction::ICmp;
1663 }
1664 case SetLE :
1665 if (isFP) {
1666 predicate = FCmpInst::FCMP_OLE;
1667 return Instruction::FCmp;
1668 } else {
1669 if (isSigned)
1670 predicate = ICmpInst::ICMP_SLE;
1671 else
1672 predicate = ICmpInst::ICMP_ULE;
1673 return Instruction::ICmp;
1674 }
1675 case SetGE :
1676 if (isFP) {
1677 predicate = FCmpInst::FCMP_OGE;
1678 return Instruction::FCmp;
1679 } else {
1680 if (isSigned)
1681 predicate = ICmpInst::ICMP_SGE;
1682 else
1683 predicate = ICmpInst::ICMP_UGE;
1684 return Instruction::ICmp;
1685 }
1686 case SetLT :
1687 if (isFP) {
1688 predicate = FCmpInst::FCMP_OLT;
1689 return Instruction::FCmp;
1690 } else {
1691 if (isSigned)
1692 predicate = ICmpInst::ICMP_SLT;
1693 else
1694 predicate = ICmpInst::ICMP_ULT;
1695 return Instruction::ICmp;
1696 }
1697 case SetGT :
1698 if (isFP) {
1699 predicate = FCmpInst::FCMP_OGT;
1700 return Instruction::FCmp;
1701 } else {
1702 if (isSigned)
1703 predicate = ICmpInst::ICMP_SGT;
1704 else
1705 predicate = ICmpInst::ICMP_UGT;
1706 return Instruction::ICmp;
1707 }
1708 }
1709}
1710
1711static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1712 switch (op) {
1713 default : assert(0 && "Invalid OldMemoryOps");
1714 case MallocOp : return Instruction::Malloc;
1715 case FreeOp : return Instruction::Free;
1716 case AllocaOp : return Instruction::Alloca;
1717 case LoadOp : return Instruction::Load;
1718 case StoreOp : return Instruction::Store;
1719 case GetElementPtrOp : return Instruction::GetElementPtr;
1720 }
1721}
1722
1723static inline Instruction::OtherOps
Reid Spencerbb1fd572007-03-21 17:15:50 +00001724getOtherOp(OtherOps op, const Signedness &Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001725 switch (op) {
1726 default : assert(0 && "Invalid OldOtherOps");
1727 case PHIOp : return Instruction::PHI;
1728 case CallOp : return Instruction::Call;
Reid Spencer950bf602007-01-26 08:19:09 +00001729 case SelectOp : return Instruction::Select;
1730 case UserOp1 : return Instruction::UserOp1;
1731 case UserOp2 : return Instruction::UserOp2;
1732 case VAArg : return Instruction::VAArg;
1733 case ExtractElementOp : return Instruction::ExtractElement;
1734 case InsertElementOp : return Instruction::InsertElement;
1735 case ShuffleVectorOp : return Instruction::ShuffleVector;
1736 case ICmpOp : return Instruction::ICmp;
1737 case FCmpOp : return Instruction::FCmp;
Reid Spencer950bf602007-01-26 08:19:09 +00001738 };
1739}
1740
1741static inline Value*
Reid Spencerbb1fd572007-03-21 17:15:50 +00001742getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
1743 const Signedness &DstSign, bool ForceInstruction = false) {
Reid Spencer950bf602007-01-26 08:19:09 +00001744 Instruction::CastOps Opcode;
1745 const Type* SrcTy = Src->getType();
1746 if (op == CastOp) {
1747 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1748 // fp -> ptr cast is no longer supported but we must upgrade this
1749 // by doing a double cast: fp -> int -> ptr
1750 SrcTy = Type::Int64Ty;
1751 Opcode = Instruction::IntToPtr;
1752 if (isa<Constant>(Src)) {
1753 Src = ConstantExpr::getCast(Instruction::FPToUI,
1754 cast<Constant>(Src), SrcTy);
1755 } else {
1756 std::string NewName(makeNameUnique(Src->getName()));
1757 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1758 }
1759 } else if (isa<IntegerType>(DstTy) &&
1760 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1761 // cast type %x to bool was previously defined as setne type %x, null
1762 // The cast semantic is now to truncate, not compare so we must retain
1763 // the original intent by replacing the cast with a setne
1764 Constant* Null = Constant::getNullValue(SrcTy);
1765 Instruction::OtherOps Opcode = Instruction::ICmp;
1766 unsigned short predicate = ICmpInst::ICMP_NE;
1767 if (SrcTy->isFloatingPoint()) {
1768 Opcode = Instruction::FCmp;
1769 predicate = FCmpInst::FCMP_ONE;
1770 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1771 error("Invalid cast to bool");
1772 }
1773 if (isa<Constant>(Src) && !ForceInstruction)
1774 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1775 else
1776 return CmpInst::create(Opcode, predicate, Src, Null);
1777 }
1778 // Determine the opcode to use by calling CastInst::getCastOpcode
1779 Opcode =
Reid Spencerbb1fd572007-03-21 17:15:50 +00001780 CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
1781 DstSign.isSigned());
Reid Spencer950bf602007-01-26 08:19:09 +00001782
1783 } else switch (op) {
1784 default: assert(0 && "Invalid cast token");
1785 case TruncOp: Opcode = Instruction::Trunc; break;
1786 case ZExtOp: Opcode = Instruction::ZExt; break;
1787 case SExtOp: Opcode = Instruction::SExt; break;
1788 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1789 case FPExtOp: Opcode = Instruction::FPExt; break;
1790 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1791 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1792 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1793 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1794 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1795 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1796 case BitCastOp: Opcode = Instruction::BitCast; break;
1797 }
1798
1799 if (isa<Constant>(Src) && !ForceInstruction)
1800 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1801 return CastInst::create(Opcode, Src, DstTy);
1802}
1803
1804static Instruction *
1805upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1806 std::vector<Value*>& Args) {
1807
1808 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1809 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1810 if (Args.size() != 2)
1811 error("Invalid prototype for " + Name + " prototype");
1812 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1813 } else {
Reid Spencer950bf602007-01-26 08:19:09 +00001814 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1815 std::vector<const Type*> Params;
1816 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1817 if (Args.size() != 1)
1818 error("Invalid prototype for " + Name + " prototype");
1819 Params.push_back(PtrTy);
1820 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1821 const PointerType *PFTy = PointerType::get(FTy);
1822 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001823 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
Chris Lattnercf3d0612007-02-13 06:04:17 +00001824 return new CallInst(Func, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00001825 } else if (Name == "llvm.va_copy") {
1826 if (Args.size() != 2)
1827 error("Invalid prototype for " + Name + " prototype");
1828 Params.push_back(PtrTy);
1829 Params.push_back(PtrTy);
1830 const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
1831 const PointerType *PFTy = PointerType::get(FTy);
1832 Value* Func = getVal(PFTy, ID);
Reid Spencer832254e2007-02-02 02:16:23 +00001833 std::string InstName0(makeNameUnique("va0"));
1834 std::string InstName1(makeNameUnique("va1"));
Reid Spencer950bf602007-01-26 08:19:09 +00001835 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1836 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
Chris Lattnercf3d0612007-02-13 06:04:17 +00001837 return new CallInst(Func, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00001838 }
1839 }
1840 return 0;
1841}
1842
1843const Type* upgradeGEPIndices(const Type* PTy,
1844 std::vector<ValueInfo> *Indices,
1845 std::vector<Value*> &VIndices,
1846 std::vector<Constant*> *CIndices = 0) {
1847 // Traverse the indices with a gep_type_iterator so we can build the list
1848 // of constant and value indices for use later. Also perform upgrades
1849 VIndices.clear();
1850 if (CIndices) CIndices->clear();
1851 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1852 VIndices.push_back((*Indices)[i].V);
1853 generic_gep_type_iterator<std::vector<Value*>::iterator>
1854 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1855 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1856 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1857 Value *Index = VIndices[i];
1858 if (CIndices && !isa<Constant>(Index))
1859 error("Indices to constant getelementptr must be constants");
1860 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1861 // struct indices to i32 struct indices with ZExt for compatibility.
1862 else if (isa<StructType>(*GTI)) { // Only change struct indices
1863 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1864 if (CUI->getType()->getBitWidth() == 8)
1865 Index =
1866 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1867 } else {
1868 // Make sure that unsigned SequentialType indices are zext'd to
1869 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1870 // all indices for SequentialType elements. We must retain the same
1871 // semantic (zext) for unsigned types.
1872 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencerbb1fd572007-03-21 17:15:50 +00001873 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001874 if (CIndices)
1875 Index = ConstantExpr::getCast(Instruction::ZExt,
1876 cast<Constant>(Index), Type::Int64Ty);
1877 else
1878 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001879 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001880 VIndices[i] = Index;
1881 }
Reid Spencer950bf602007-01-26 08:19:09 +00001882 }
1883 // Add to the CIndices list, if requested.
1884 if (CIndices)
1885 CIndices->push_back(cast<Constant>(Index));
1886 }
1887
1888 const Type *IdxTy =
Chris Lattner1bc3fa62007-02-12 22:58:38 +00001889 GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true);
Reid Spencer950bf602007-01-26 08:19:09 +00001890 if (!IdxTy)
1891 error("Index list invalid for constant getelementptr");
1892 return IdxTy;
1893}
1894
Reid Spencerb7046c72007-01-29 05:41:34 +00001895unsigned upgradeCallingConv(unsigned CC) {
1896 switch (CC) {
1897 case OldCallingConv::C : return CallingConv::C;
1898 case OldCallingConv::CSRet : return CallingConv::C;
1899 case OldCallingConv::Fast : return CallingConv::Fast;
1900 case OldCallingConv::Cold : return CallingConv::Cold;
1901 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1902 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1903 default:
1904 return CC;
1905 }
1906}
1907
Reid Spencer950bf602007-01-26 08:19:09 +00001908Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1909 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001910{
1911 Upgradelineno = 1;
1912 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001913 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001914 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001915 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001916 ObsoleteVarArgs = false;
1917 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001918
Reid Spencer950bf602007-01-26 08:19:09 +00001919 CurModule.CurrentModule = new Module(CurFilename);
1920
1921 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001922 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001923 if (ParserResult)
1924 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001925 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001926 return 0;
1927 }
1928
Reid Spencer950bf602007-01-26 08:19:09 +00001929 // Check to make sure that parsing produced a result
1930 if (!ParserResult) {
1931 std::cerr << "llvm-upgrade: no parse result.\n";
1932 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001933 }
1934
Reid Spencer950bf602007-01-26 08:19:09 +00001935 // Reset ParserResult variable while saving its value for the result.
1936 Module *Result = ParserResult;
1937 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001938
Reid Spencer950bf602007-01-26 08:19:09 +00001939 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001940 {
Reid Spencer950bf602007-01-26 08:19:09 +00001941 Function* F;
Reid Spencer688b0492007-02-05 21:19:13 +00001942 if ((F = Result->getFunction("llvm.va_start"))
Reid Spencer950bf602007-01-26 08:19:09 +00001943 && F->getFunctionType()->getNumParams() == 0)
1944 ObsoleteVarArgs = true;
Reid Spencer688b0492007-02-05 21:19:13 +00001945 if((F = Result->getFunction("llvm.va_copy"))
Reid Spencer950bf602007-01-26 08:19:09 +00001946 && F->getFunctionType()->getNumParams() == 1)
1947 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001948 }
Reid Spencer319a7302007-01-05 17:20:02 +00001949
Reid Spencer950bf602007-01-26 08:19:09 +00001950 if (ObsoleteVarArgs && NewVarArgs) {
1951 error("This file is corrupt: it uses both new and old style varargs");
1952 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00001953 }
Reid Spencer319a7302007-01-05 17:20:02 +00001954
Reid Spencer950bf602007-01-26 08:19:09 +00001955 if(ObsoleteVarArgs) {
Reid Spencer688b0492007-02-05 21:19:13 +00001956 if(Function* F = Result->getFunction("llvm.va_start")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001957 if (F->arg_size() != 0) {
1958 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00001959 return 0;
1960 }
Reid Spencer950bf602007-01-26 08:19:09 +00001961
1962 //foo = va_start()
1963 // ->
1964 //bar = alloca typeof(foo)
1965 //va_start(bar)
1966 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00001967
Reid Spencer950bf602007-01-26 08:19:09 +00001968 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1969 const Type* ArgTy = F->getFunctionType()->getReturnType();
1970 const Type* ArgTyPtr = PointerType::get(ArgTy);
1971 Function* NF = cast<Function>(Result->getOrInsertFunction(
1972 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1973
1974 while (!F->use_empty()) {
1975 CallInst* CI = cast<CallInst>(F->use_back());
1976 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1977 new CallInst(NF, bar, "", CI);
1978 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1979 CI->replaceAllUsesWith(foo);
1980 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00001981 }
Reid Spencer950bf602007-01-26 08:19:09 +00001982 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00001983 }
Reid Spencer950bf602007-01-26 08:19:09 +00001984
Reid Spencer688b0492007-02-05 21:19:13 +00001985 if(Function* F = Result->getFunction("llvm.va_end")) {
Reid Spencer950bf602007-01-26 08:19:09 +00001986 if(F->arg_size() != 1) {
1987 error("Obsolete va_end takes 1 argument");
1988 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00001989 }
Reid Spencerf8383de2007-01-06 06:04:32 +00001990
Reid Spencer950bf602007-01-26 08:19:09 +00001991 //vaend foo
1992 // ->
1993 //bar = alloca 1 of typeof(foo)
1994 //vaend bar
1995 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1996 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1997 const Type* ArgTyPtr = PointerType::get(ArgTy);
1998 Function* NF = cast<Function>(Result->getOrInsertFunction(
1999 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00002000
Reid Spencer950bf602007-01-26 08:19:09 +00002001 while (!F->use_empty()) {
2002 CallInst* CI = cast<CallInst>(F->use_back());
2003 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
2004 new StoreInst(CI->getOperand(1), bar, CI);
2005 new CallInst(NF, bar, "", CI);
2006 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00002007 }
Reid Spencer950bf602007-01-26 08:19:09 +00002008 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00002009 }
Reid Spencer950bf602007-01-26 08:19:09 +00002010
Reid Spencer688b0492007-02-05 21:19:13 +00002011 if(Function* F = Result->getFunction("llvm.va_copy")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002012 if(F->arg_size() != 1) {
2013 error("Obsolete va_copy takes 1 argument");
2014 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00002015 }
Reid Spencer950bf602007-01-26 08:19:09 +00002016 //foo = vacopy(bar)
2017 // ->
2018 //a = alloca 1 of typeof(foo)
2019 //b = alloca 1 of typeof(foo)
2020 //store bar -> b
2021 //vacopy(a, b)
2022 //foo = load a
2023
2024 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2025 const Type* ArgTy = F->getFunctionType()->getReturnType();
2026 const Type* ArgTyPtr = PointerType::get(ArgTy);
2027 Function* NF = cast<Function>(Result->getOrInsertFunction(
2028 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00002029
Reid Spencer950bf602007-01-26 08:19:09 +00002030 while (!F->use_empty()) {
2031 CallInst* CI = cast<CallInst>(F->use_back());
2032 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
2033 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
2034 new StoreInst(CI->getOperand(1), b, CI);
2035 new CallInst(NF, a, b, "", CI);
2036 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
2037 CI->replaceAllUsesWith(foo);
2038 CI->getParent()->getInstList().erase(CI);
2039 }
2040 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00002041 }
2042 }
2043
Reid Spencer52402b02007-01-02 05:45:11 +00002044 return Result;
2045}
2046
Reid Spencer950bf602007-01-26 08:19:09 +00002047} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00002048
Reid Spencer950bf602007-01-26 08:19:09 +00002049using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00002050
2051
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002052
2053/* Enabling traces. */
2054#ifndef YYDEBUG
2055# define YYDEBUG 0
2056#endif
2057
2058/* Enabling verbose error messages. */
2059#ifdef YYERROR_VERBOSE
2060# undef YYERROR_VERBOSE
2061# define YYERROR_VERBOSE 1
2062#else
2063# define YYERROR_VERBOSE 0
2064#endif
2065
2066/* Enabling the token table. */
2067#ifndef YYTOKEN_TABLE
2068# define YYTOKEN_TABLE 0
2069#endif
2070
2071#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencerbb1fd572007-03-21 17:15:50 +00002072#line 1693 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002073typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00002074 llvm::Module *ModuleVal;
2075 llvm::Function *FunctionVal;
2076 std::pair<llvm::PATypeInfo, char*> *ArgVal;
2077 llvm::BasicBlock *BasicBlockVal;
Reid Spencerbb1fd572007-03-21 17:15:50 +00002078 llvm::TermInstInfo TermInstVal;
Reid Spencer950bf602007-01-26 08:19:09 +00002079 llvm::InstrInfo InstVal;
2080 llvm::ConstInfo ConstVal;
2081 llvm::ValueInfo ValueVal;
2082 llvm::PATypeInfo TypeVal;
2083 llvm::TypeInfo PrimType;
2084 llvm::PHIListInfo PHIList;
2085 std::list<llvm::PATypeInfo> *TypeList;
2086 std::vector<llvm::ValueInfo> *ValueList;
2087 std::vector<llvm::ConstInfo> *ConstVector;
2088
2089
2090 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
2091 // Represent the RHS of PHI node
2092 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
2093
2094 llvm::GlobalValue::LinkageTypes Linkage;
2095 int64_t SInt64Val;
2096 uint64_t UInt64Val;
2097 int SIntVal;
2098 unsigned UIntVal;
2099 double FPVal;
2100 bool BoolVal;
2101
2102 char *StrVal; // This memory is strdup'd!
2103 llvm::ValID ValIDVal; // strdup'd memory maybe!
2104
2105 llvm::BinaryOps BinaryOpVal;
2106 llvm::TermOps TermOpVal;
2107 llvm::MemoryOps MemOpVal;
2108 llvm::OtherOps OtherOpVal;
2109 llvm::CastOps CastOpVal;
2110 llvm::ICmpInst::Predicate IPred;
2111 llvm::FCmpInst::Predicate FPred;
2112 llvm::Module::Endianness Endianness;
Chris Lattnercf3d0612007-02-13 06:04:17 +00002113} YYSTYPE;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002114/* Line 196 of yacc.c. */
Reid Spencerbb1fd572007-03-21 17:15:50 +00002115#line 2116 "UpgradeParser.tab.c"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002116# define yystype YYSTYPE /* obsolescent; will be withdrawn */
2117# define YYSTYPE_IS_DECLARED 1
2118# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00002119#endif
2120
Reid Spencer950bf602007-01-26 08:19:09 +00002121
Reid Spencere7c3c602006-11-30 06:36:44 +00002122
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002123/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002124
2125
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002126/* Line 219 of yacc.c. */
Reid Spencerbb1fd572007-03-21 17:15:50 +00002127#line 2128 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00002128
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002129#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2130# define YYSIZE_T __SIZE_TYPE__
2131#endif
2132#if ! defined (YYSIZE_T) && defined (size_t)
2133# define YYSIZE_T size_t
2134#endif
2135#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
2136# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2137# define YYSIZE_T size_t
2138#endif
2139#if ! defined (YYSIZE_T)
2140# define YYSIZE_T unsigned int
2141#endif
Chris Lattnercf3d0612007-02-13 06:04:17 +00002142
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002143#ifndef YY_
2144# if YYENABLE_NLS
2145# if ENABLE_NLS
2146# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
2147# define YY_(msgid) dgettext ("bison-runtime", msgid)
2148# endif
2149# endif
2150# ifndef YY_
2151# define YY_(msgid) msgid
2152# endif
2153#endif
2154
2155#if ! defined (yyoverflow) || YYERROR_VERBOSE
2156
2157/* The parser invokes alloca or malloc; define the necessary symbols. */
2158
2159# ifdef YYSTACK_USE_ALLOCA
2160# if YYSTACK_USE_ALLOCA
2161# ifdef __GNUC__
2162# define YYSTACK_ALLOC __builtin_alloca
2163# else
2164# define YYSTACK_ALLOC alloca
2165# if defined (__STDC__) || defined (__cplusplus)
2166# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2167# define YYINCLUDED_STDLIB_H
2168# endif
2169# endif
2170# endif
2171# endif
2172
2173# ifdef YYSTACK_ALLOC
2174 /* Pacify GCC's `empty if-body' warning. */
2175# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
2176# ifndef YYSTACK_ALLOC_MAXIMUM
2177 /* The OS might guarantee only one guard page at the bottom of the stack,
2178 and a page size can be as small as 4096 bytes. So we cannot safely
2179 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
2180 to allow for a few compiler-allocated temporary stack slots. */
2181# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
2182# endif
2183# else
2184# define YYSTACK_ALLOC YYMALLOC
2185# define YYSTACK_FREE YYFREE
2186# ifndef YYSTACK_ALLOC_MAXIMUM
2187# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
2188# endif
2189# ifdef __cplusplus
2190extern "C" {
2191# endif
2192# ifndef YYMALLOC
2193# define YYMALLOC malloc
2194# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
2195 && (defined (__STDC__) || defined (__cplusplus)))
2196void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
2197# endif
2198# endif
2199# ifndef YYFREE
2200# define YYFREE free
2201# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
2202 && (defined (__STDC__) || defined (__cplusplus)))
2203void free (void *); /* INFRINGES ON USER NAME SPACE */
2204# endif
2205# endif
2206# ifdef __cplusplus
2207}
2208# endif
2209# endif
2210#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
2211
2212
2213#if (! defined (yyoverflow) \
2214 && (! defined (__cplusplus) \
2215 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
2216
2217/* A type that is properly aligned for any stack member. */
2218union yyalloc
2219{
2220 short int yyss;
2221 YYSTYPE yyvs;
2222 };
2223
2224/* The size of the maximum gap between one aligned stack and the next. */
2225# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2226
2227/* The size of an array large to enough to hold all stacks, each with
2228 N elements. */
2229# define YYSTACK_BYTES(N) \
2230 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
2231 + YYSTACK_GAP_MAXIMUM)
2232
2233/* Copy COUNT objects from FROM to TO. The source and destination do
2234 not overlap. */
2235# ifndef YYCOPY
2236# if defined (__GNUC__) && 1 < __GNUC__
2237# define YYCOPY(To, From, Count) \
2238 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2239# else
2240# define YYCOPY(To, From, Count) \
2241 do \
2242 { \
2243 YYSIZE_T yyi; \
2244 for (yyi = 0; yyi < (Count); yyi++) \
2245 (To)[yyi] = (From)[yyi]; \
2246 } \
2247 while (0)
2248# endif
2249# endif
2250
2251/* Relocate STACK from its old location to the new one. The
2252 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2253 elements in the stack, and YYPTR gives the new location of the
2254 stack. Advance YYPTR to a properly aligned location for the next
2255 stack. */
2256# define YYSTACK_RELOCATE(Stack) \
2257 do \
2258 { \
2259 YYSIZE_T yynewbytes; \
2260 YYCOPY (&yyptr->Stack, Stack, yysize); \
2261 Stack = &yyptr->Stack; \
2262 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2263 yyptr += yynewbytes / sizeof (*yyptr); \
2264 } \
2265 while (0)
Chris Lattnercf3d0612007-02-13 06:04:17 +00002266
Reid Spencere7c3c602006-11-30 06:36:44 +00002267#endif
2268
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002269#if defined (__STDC__) || defined (__cplusplus)
2270 typedef signed char yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002271#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002272 typedef short int yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002273#endif
2274
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002275/* YYFINAL -- State number of the termination state. */
2276#define YYFINAL 4
2277/* YYLAST -- Last index in YYTABLE. */
2278#define YYLAST 1762
2279
2280/* YYNTOKENS -- Number of terminals. */
2281#define YYNTOKENS 166
2282/* YYNNTS -- Number of nonterminals. */
2283#define YYNNTS 80
2284/* YYNRULES -- Number of rules. */
2285#define YYNRULES 309
2286/* YYNRULES -- Number of states. */
2287#define YYNSTATES 605
2288
2289/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2290#define YYUNDEFTOK 2
2291#define YYMAXUTOK 406
2292
2293#define YYTRANSLATE(YYX) \
2294 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2295
2296/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2297static const unsigned char yytranslate[] =
2298{
2299 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2300 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2301 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2302 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2303 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2304 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2305 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2306 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2307 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2308 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2309 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2310 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2311 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2312 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2313 2, 2, 2, 2, 2, 2, 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, 1, 2, 3, 4,
2325 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2326 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2327 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2328 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2329 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2330 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2331 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2332 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2333 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2334 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2335 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2336 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2337 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2338 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2339 145, 146, 147, 148, 149, 150, 151
2340};
2341
2342#if YYDEBUG
2343/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2344 YYRHS. */
2345static const unsigned short int yyprhs[] =
2346{
2347 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2348 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2349 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2350 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2351 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2352 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2353 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2354 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2355 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2356 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2357 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2358 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2359 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2360 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2361 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2362 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2363 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2364 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2365 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2366 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2367 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2368 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
2369 622, 623, 632, 634, 636, 640, 642, 644, 647, 648,
2370 650, 652, 653, 654, 660, 661, 663, 665, 667, 669,
2371 671, 673, 675, 677, 679, 683, 685, 691, 693, 695,
2372 697, 699, 702, 705, 708, 712, 715, 716, 718, 720,
2373 722, 725, 728, 732, 742, 752, 761, 775, 777, 779,
2374 786, 792, 795, 802, 810, 812, 816, 818, 819, 822,
2375 824, 830, 836, 842, 849, 856, 859, 864, 869, 876,
2376 881, 886, 891, 896, 903, 910, 913, 921, 923, 926,
2377 927, 929, 930, 934, 941, 945, 952, 955, 960, 967
2378};
2379
2380/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2381static const short int yyrhs[] =
2382{
2383 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2384 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2385 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2386 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2387 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2388 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2389 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2390 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2391 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2392 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2393 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2394 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2395 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2396 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2397 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2398 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2399 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2400 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2401 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2402 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2403 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2404 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2405 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2406 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2407 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
2408 -1, 19, -1, 21, -1, 192, -1, 48, -1, 228,
2409 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2410 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2411 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2412 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2413 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2414 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2415 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2416 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2417 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2418 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
2419 191, 39, -1, 191, 228, -1, 191, 197, -1, 191,
2420 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2421 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
2422 36, 191, 156, -1, 110, 155, 196, 243, 156, -1,
2423 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2424 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2425 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2426 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2427 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2428 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2429 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2430 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2431 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
2432 201, 221, -1, 201, 223, -1, 201, 62, 61, 207,
2433 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
2434 -1, 202, 223, -1, 202, 62, 61, 207, -1, -1,
2435 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2436 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2437 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2438 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2439 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2440 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2441 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2442 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2443 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2444 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2445 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
2446 183, -1, 29, -1, 162, -1, 181, 217, 218, -1,
2447 30, -1, 163, -1, 231, 220, -1, -1, 45, -1,
2448 47, -1, -1, -1, 31, 224, 222, 225, 217, -1,
2449 -1, 63, -1, 3, -1, 4, -1, 7, -1, 27,
2450 -1, 28, -1, 38, -1, 39, -1, 26, -1, 160,
2451 198, 161, -1, 197, -1, 61, 226, 24, 153, 24,
2452 -1, 167, -1, 212, -1, 228, -1, 227, -1, 191,
2453 229, -1, 231, 232, -1, 219, 232, -1, 233, 180,
2454 235, -1, 233, 237, -1, -1, 23, -1, 77, -1,
2455 78, -1, 72, 230, -1, 72, 8, -1, 73, 21,
2456 229, -1, 73, 9, 229, 153, 21, 229, 153, 21,
2457 229, -1, 74, 178, 229, 153, 21, 229, 157, 236,
2458 159, -1, 74, 178, 229, 153, 21, 229, 157, 159,
2459 -1, 75, 182, 189, 229, 155, 240, 156, 36, 21,
2460 229, 234, 21, 229, -1, 234, -1, 76, -1, 236,
2461 178, 227, 153, 21, 229, -1, 178, 227, 153, 21,
2462 229, -1, 180, 242, -1, 191, 157, 229, 153, 229,
2463 159, -1, 238, 153, 157, 229, 153, 229, 159, -1,
2464 230, -1, 239, 153, 230, -1, 239, -1, -1, 60,
2465 59, -1, 59, -1, 169, 191, 229, 153, 229, -1,
2466 170, 191, 229, 153, 229, -1, 171, 191, 229, 153,
2467 229, -1, 103, 172, 191, 229, 153, 229, -1, 104,
2468 173, 191, 229, 153, 229, -1, 49, 230, -1, 174,
2469 230, 153, 230, -1, 175, 230, 36, 191, -1, 112,
2470 230, 153, 230, 153, 230, -1, 113, 230, 153, 191,
2471 -1, 117, 230, 153, 191, -1, 118, 230, 153, 191,
2472 -1, 114, 230, 153, 230, -1, 115, 230, 153, 230,
2473 153, 230, -1, 116, 230, 153, 230, 153, 230, -1,
2474 111, 238, -1, 241, 182, 189, 229, 155, 240, 156,
2475 -1, 245, -1, 153, 239, -1, -1, 35, -1, -1,
2476 105, 191, 184, -1, 105, 191, 153, 15, 229, 184,
2477 -1, 106, 191, 184, -1, 106, 191, 153, 15, 229,
2478 184, -1, 107, 230, -1, 244, 108, 191, 229, -1,
2479 244, 109, 230, 153, 191, 229, -1, 110, 191, 229,
2480 243, -1
2481};
2482
2483/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2484static const unsigned short int yyrline[] =
2485{
Reid Spencerbb1fd572007-03-21 17:15:50 +00002486 0, 1833, 1833, 1834, 1842, 1843, 1853, 1853, 1853, 1853,
2487 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1857, 1857, 1857,
2488 1861, 1861, 1861, 1861, 1861, 1861, 1865, 1865, 1866, 1866,
2489 1867, 1867, 1868, 1868, 1869, 1869, 1873, 1873, 1874, 1874,
2490 1875, 1875, 1876, 1876, 1877, 1877, 1878, 1878, 1879, 1879,
2491 1880, 1881, 1884, 1884, 1884, 1884, 1888, 1888, 1888, 1888,
2492 1888, 1888, 1888, 1889, 1889, 1889, 1889, 1889, 1889, 1895,
2493 1895, 1895, 1895, 1899, 1899, 1899, 1899, 1903, 1903, 1907,
2494 1907, 1912, 1915, 1920, 1921, 1922, 1923, 1924, 1925, 1926,
2495 1927, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1948,
2496 1949, 1957, 1958, 1966, 1975, 1976, 1983, 1984, 1988, 1992,
2497 2008, 2009, 2016, 2017, 2024, 2032, 2032, 2032, 2032, 2032,
2498 2032, 2032, 2033, 2033, 2033, 2033, 2033, 2038, 2042, 2046,
2499 2051, 2060, 2078, 2084, 2097, 2108, 2112, 2125, 2129, 2143,
2500 2147, 2154, 2155, 2161, 2168, 2180, 2210, 2223, 2246, 2274,
2501 2296, 2307, 2329, 2340, 2349, 2354, 2413, 2420, 2428, 2435,
2502 2442, 2446, 2450, 2459, 2474, 2487, 2496, 2524, 2537, 2546,
2503 2552, 2558, 2569, 2575, 2581, 2592, 2593, 2602, 2603, 2615,
2504 2624, 2625, 2626, 2627, 2628, 2644, 2664, 2666, 2668, 2668,
2505 2675, 2675, 2683, 2683, 2691, 2691, 2700, 2702, 2704, 2709,
2506 2723, 2724, 2728, 2731, 2739, 2743, 2750, 2754, 2758, 2762,
2507 2770, 2770, 2774, 2775, 2779, 2787, 2792, 2800, 2801, 2808,
2508 2815, 2819, 3004, 3004, 3008, 3018, 3018, 3022, 3027, 3028,
2509 3029, 3033, 3034, 3033, 3046, 3047, 3052, 3053, 3054, 3055,
2510 3059, 3063, 3064, 3065, 3066, 3087, 3091, 3105, 3106, 3111,
2511 3111, 3119, 3129, 3132, 3141, 3152, 3157, 3166, 3177, 3177,
2512 3180, 3184, 3188, 3193, 3203, 3221, 3230, 3295, 3299, 3306,
2513 3318, 3333, 3363, 3373, 3383, 3387, 3394, 3395, 3399, 3402,
2514 3408, 3427, 3445, 3461, 3475, 3489, 3500, 3518, 3527, 3536,
2515 3543, 3564, 3588, 3594, 3600, 3606, 3622, 3706, 3714, 3715,
2516 3719, 3720, 3724, 3730, 3737, 3743, 3750, 3757, 3770, 3796
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002517};
2518#endif
2519
2520#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2521/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2522 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2523static const char *const yytname[] =
2524{
2525 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2526 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2527 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2528 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2529 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2530 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2531 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2532 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2533 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2534 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2535 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2536 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2537 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2538 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2539 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2540 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2541 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2542 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2543 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2544 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2545 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2546 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2547 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2548 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2549 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2550 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2551 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2552 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2553 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2554 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2555 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2556 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2557 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2558 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
2559 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5", "@6",
2560 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2561 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2562 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2563 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2564 "OptVolatile", "MemoryInst", 0
2565};
2566#endif
2567
2568# ifdef YYPRINT
2569/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2570 token YYLEX-NUM. */
2571static const unsigned short int yytoknum[] =
2572{
2573 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2574 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2575 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2576 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2577 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2578 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2579 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2580 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2581 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2582 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2583 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2584 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2585 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2586 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2587 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2588 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2589 60, 62, 123, 125, 42, 99
2590};
2591# endif
2592
2593/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2594static const unsigned char yyr1[] =
2595{
2596 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2597 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2598 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2599 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2600 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2601 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2602 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2603 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2604 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2605 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2606 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2607 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2608 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2609 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2610 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2611 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2612 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2613 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2614 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2615 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2616 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2617 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
2618 216, 217, 218, 218, 219, 220, 220, 221, 222, 222,
2619 222, 224, 225, 223, 226, 226, 227, 227, 227, 227,
2620 227, 227, 227, 227, 227, 227, 227, 228, 228, 229,
2621 229, 230, 231, 231, 232, 233, 233, 233, 234, 234,
2622 235, 235, 235, 235, 235, 235, 235, 235, 235, 236,
2623 236, 237, 238, 238, 239, 239, 240, 240, 241, 241,
2624 242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
2625 242, 242, 242, 242, 242, 242, 242, 242, 243, 243,
2626 244, 244, 245, 245, 245, 245, 245, 245, 245, 245
2627};
2628
2629/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2630static const unsigned char yyr2[] =
2631{
2632 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2633 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2634 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2635 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2636 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2637 1, 1, 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, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2641 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2642 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2643 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2644 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2645 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2646 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2647 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2648 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2649 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2650 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2651 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2652 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2653 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
2654 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
2655 1, 0, 0, 5, 0, 1, 1, 1, 1, 1,
2656 1, 1, 1, 1, 3, 1, 5, 1, 1, 1,
2657 1, 2, 2, 2, 3, 2, 0, 1, 1, 1,
2658 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
2659 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
2660 5, 5, 5, 6, 6, 2, 4, 4, 6, 4,
2661 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
2662 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
2663};
2664
2665/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2666 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2667 means the default is an error. */
2668static const unsigned short int yydefact[] =
2669{
2670 198, 0, 90, 184, 1, 183, 231, 83, 84, 85,
2671 86, 87, 88, 89, 0, 91, 256, 180, 181, 256,
2672 210, 211, 0, 0, 0, 90, 0, 186, 228, 0,
2673 0, 92, 93, 94, 95, 96, 97, 0, 0, 257,
2674 253, 82, 225, 226, 227, 252, 0, 0, 0, 0,
2675 196, 0, 0, 0, 0, 0, 0, 0, 81, 229,
2676 230, 232, 199, 182, 98, 2, 3, 111, 115, 116,
2677 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2678 128, 0, 0, 0, 0, 247, 0, 0, 110, 127,
2679 114, 248, 129, 222, 223, 224, 301, 255, 0, 0,
2680 0, 0, 209, 197, 187, 185, 177, 178, 0, 0,
2681 0, 0, 91, 130, 0, 0, 0, 113, 135, 139,
2682 0, 0, 144, 138, 300, 0, 279, 0, 0, 0,
2683 0, 91, 268, 258, 259, 6, 7, 8, 9, 10,
2684 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2685 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2686 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2687 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2688 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
2689 0, 267, 254, 91, 271, 0, 297, 204, 201, 200,
2690 202, 203, 205, 208, 0, 192, 194, 190, 115, 116,
2691 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
2692 0, 0, 0, 188, 233, 0, 0, 0, 0, 0,
2693 134, 220, 143, 141, 0, 0, 285, 278, 261, 260,
2694 0, 0, 72, 76, 71, 75, 70, 74, 69, 73,
2695 77, 78, 0, 0, 26, 27, 28, 29, 30, 31,
2696 32, 33, 34, 35, 0, 50, 51, 46, 47, 48,
2697 49, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2698 45, 0, 101, 101, 306, 0, 0, 295, 0, 0,
2699 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2700 0, 0, 0, 0, 206, 106, 106, 106, 160, 161,
2701 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2702 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2703 0, 0, 0, 0, 156, 155, 106, 112, 112, 137,
2704 0, 140, 219, 213, 216, 217, 0, 0, 131, 236,
2705 237, 238, 243, 239, 240, 241, 242, 234, 0, 245,
2706 250, 249, 251, 0, 262, 0, 0, 0, 0, 0,
2707 302, 0, 304, 299, 0, 0, 0, 0, 0, 0,
2708 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2709 0, 207, 0, 193, 195, 191, 0, 0, 0, 0,
2710 0, 0, 0, 146, 176, 0, 0, 0, 150, 0,
2711 147, 0, 0, 0, 0, 0, 189, 132, 133, 136,
2712 212, 214, 0, 104, 142, 235, 0, 0, 0, 0,
2713 0, 0, 0, 0, 0, 0, 0, 309, 0, 0,
2714 0, 289, 292, 0, 0, 290, 291, 0, 0, 0,
2715 286, 287, 0, 307, 0, 0, 0, 108, 106, 0,
2716 0, 299, 0, 0, 0, 0, 0, 145, 135, 114,
2717 0, 148, 149, 0, 0, 0, 0, 0, 218, 215,
2718 105, 99, 0, 244, 0, 0, 277, 0, 0, 101,
2719 102, 101, 274, 298, 0, 0, 0, 0, 0, 280,
2720 281, 282, 277, 0, 103, 109, 107, 0, 0, 0,
2721 0, 0, 0, 0, 175, 152, 0, 0, 0, 0,
2722 0, 0, 0, 221, 0, 0, 0, 276, 0, 283,
2723 284, 0, 303, 305, 0, 0, 0, 288, 293, 294,
2724 0, 308, 0, 0, 164, 0, 0, 0, 0, 151,
2725 0, 0, 0, 0, 0, 100, 246, 0, 0, 0,
2726 275, 272, 0, 296, 0, 0, 0, 172, 0, 0,
2727 166, 167, 168, 171, 163, 0, 265, 0, 0, 0,
2728 273, 169, 170, 0, 0, 0, 263, 0, 264, 0,
2729 0, 165, 173, 174, 0, 0, 0, 0, 0, 0,
2730 270, 0, 0, 269, 266
2731};
2732
2733/* YYDEFGOTO[NTERM-NUM]. */
2734static const short int yydefgoto[] =
2735{
2736 -1, 85, 312, 329, 330, 331, 264, 281, 332, 333,
2737 219, 220, 252, 221, 25, 15, 37, 523, 370, 457,
2738 481, 393, 458, 86, 87, 222, 89, 90, 120, 234,
2739 404, 359, 405, 108, 1, 2, 3, 336, 307, 305,
2740 306, 63, 200, 50, 103, 204, 91, 421, 344, 345,
2741 346, 38, 95, 16, 44, 17, 61, 18, 28, 112,
2742 426, 360, 92, 362, 492, 19, 40, 41, 191, 192,
2743 578, 97, 287, 527, 528, 193, 194, 437, 195, 196
2744};
2745
2746/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2747 STATE-NUM. */
2748#define YYPACT_NINF -555
2749static const short int yypact[] =
2750{
2751 -555, 136, 58, 247, -555, -555, -555, -555, -555, -555,
2752 -555, -555, -555, -555, 96, 181, 141, -555, -555, -9,
2753 -555, -555, 16, 7, 114, 65, 39, -555, 50, 188,
2754 210, -555, -555, -555, -555, -555, -555, 1357, -19, -555,
2755 -555, 134, -555, -555, -555, -555, 68, 69, 70, 73,
2756 -555, 60, 188, 1357, 4, 4, 4, 4, -555, -555,
2757 -555, -555, -555, -555, -555, -555, -555, 63, -555, -555,
2758 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2759 -555, 222, 224, 1, 171, -555, 134, 84, -555, -555,
2760 -103, -555, -555, -555, -555, -555, 1611, -555, 216, 66,
2761 238, 219, 233, -555, -555, -555, -555, -555, 1418, 1418,
2762 1418, 1459, 181, -555, 100, 101, 737, -555, -555, -103,
2763 -112, 105, 803, -555, -555, 1418, -555, 202, 1479, 13,
2764 221, 181, -555, -555, -555, -555, -555, -555, -555, -555,
2765 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2766 -555, -555, -555, -555, -555, -555, -555, -555, -555, 77,
2767 377, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418,
2768 1418, 1418, 1418, -555, -555, -555, -555, -555, -555, -555,
2769 -555, -555, -555, -555, -555, -555, 1418, 1418, 1418, 1418,
2770 1418, -555, -555, 181, -555, 33, -555, -555, -555, -555,
2771 -555, -555, -555, -555, -15, -555, -555, -555, 36, 158,
2772 262, 164, 264, 167, 266, 169, 268, 269, 270, 204,
2773 271, 274, 579, -555, -555, 1418, 1418, 121, -67, 1418,
2774 -555, 1199, -555, 120, 127, 920, -555, -555, 63, -555,
2775 920, 920, -555, -555, -555, -555, -555, -555, -555, -555,
2776 -555, -555, 920, 1357, -555, -555, -555, -555, -555, -555,
2777 -555, -555, -555, -555, 1418, -555, -555, -555, -555, -555,
2778 -555, -555, -555, -555, -555, -555, -555, -555, -555, -555,
2779 -555, 1418, 142, 143, -555, 920, 147, 153, 154, 155,
2780 157, 165, 166, 168, 170, 920, 920, 920, 173, 275,
2781 1357, 1418, 1418, 293, -555, 174, 174, 174, -555, -555,
2782 -555, -555, -555, -555, -555, -555, -555, -555, 77, 377,
2783 175, 177, 180, 182, 183, 1240, 1520, 757, 296, 192,
2784 193, 199, 203, 207, -555, -555, 174, -45, -71, -555,
2785 161, -103, -555, 134, -555, 176, 209, 1260, -555, -555,
2786 -555, -555, -555, -555, -555, -555, -555, 261, 1459, -555,
2787 -555, -555, -555, 206, -555, 213, 920, 920, 920, -2,
2788 -555, 0, -555, 215, 920, 179, 1418, 1418, 1418, 1418,
2789 1418, 1418, 1418, 217, 218, 223, 1418, 1418, 920, 920,
2790 226, -555, -17, -555, -555, -555, 214, 220, 1459, 1459,
2791 1459, 1459, 1459, -555, -555, -13, 778, -94, -555, -40,
2792 -555, 1459, 1459, 1459, 1459, 1459, -555, -555, -555, -555,
2793 -555, -555, 1301, 346, -555, -555, 357, -69, 361, 362,
2794 229, 234, 235, 920, 382, 920, 1418, -555, 236, 920,
2795 237, -555, -555, 239, 240, -555, -555, 920, 920, 920,
2796 -555, -555, 241, -555, 1418, 367, 390, -555, 174, 1459,
2797 1459, 215, 242, 245, 248, 249, 1459, -555, 254, -16,
2798 -8, -555, -555, 250, 253, 263, 272, 364, -555, -555,
2799 -555, 366, 273, -555, 920, 920, 1418, 920, 920, 276,
2800 -555, 276, -555, 279, 920, 280, 1418, 1418, 1418, -555,
2801 -555, -555, 1418, 920, -555, -555, -555, 281, 282, 283,
2802 1459, 1459, 1459, 1459, -555, -555, 284, 1459, 1459, 1459,
2803 1459, 1418, 423, -555, 416, 288, 285, 279, 290, -555,
2804 -555, 391, -555, -555, 1418, 294, 920, -555, -555, -555,
2805 291, -555, 1459, 1459, -555, 299, 298, 302, 303, -555,
2806 301, 306, 307, 308, 310, -555, -555, 437, 15, 432,
2807 -555, -555, 312, -555, 316, 319, 1459, -555, 1459, 1459,
2808 -555, -555, -555, -555, -555, 920, -555, 1046, 64, 460,
2809 -555, -555, -555, 326, 329, 331, -555, 335, -555, 1046,
2810 920, -555, -555, -555, 468, 337, 132, 920, 470, 472,
2811 -555, 920, 920, -555, -555
2812};
2813
2814/* YYPGOTO[NTERM-NUM]. */
2815static const short int yypgoto[] =
2816{
2817 -555, -555, -555, 398, 399, 400, 198, 200, 402, 403,
2818 -128, -127, -525, -555, 476, 493, -111, -555, -276, 97,
2819 -555, -298, -555, -47, -555, -37, -555, -60, -62, -555,
2820 -99, 300, -308, 61, -555, -555, -555, -555, -555, -555,
2821 -555, 469, -555, -555, -555, -555, 8, -555, 102, -555,
2822 -555, 411, -555, -555, -555, -555, -555, 523, -555, -555,
2823 -555, -554, -11, 112, -124, -555, 508, -555, -68, -555,
2824 -555, -555, -555, 93, 28, -555, -555, 71, -555, -555
2825};
2826
2827/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2828 positive, shift that token. If negative, reduce the rule which
2829 number is the opposite. If zero, do what YYDEFACT says.
2830 If YYTABLE_NINF, syntax error. */
2831#define YYTABLE_NINF -180
2832static const short int yytable[] =
2833{
2834 88, 236, 250, 251, 239, 115, 105, 372, 394, 395,
2835 93, 26, 223, 433, 39, 435, 88, 455, 407, 409,
2836 253, 42, 240, 587, 119, 242, 243, 244, 245, 246,
2837 247, 248, 249, 577, 241, 595, 106, 107, 416, 284,
2838 456, 229, 288, 289, 290, 291, 292, 293, 294, 26,
2839 427, 230, -112, 589, 228, 434, 119, 434, -179, 466,
2840 233, 123, 119, 308, 309, 298, 299, 471, 46, 47,
2841 48, 205, 206, 207, 242, 243, 244, 245, 246, 247,
2842 248, 249, 300, 5, 466, 53, 229, 49, 235, 6,
2843 418, 235, 483, 123, 121, 59, 340, 60, 470, 7,
2844 8, 9, 10, 11, 12, 13, 7, 8, 9, 10,
2845 54, 12, 55, 466, 417, 56, 109, 110, 111, 123,
2846 14, 198, 199, 472, 282, 283, 235, 285, 286, 235,
2847 235, 235, 235, 235, 235, 235, 4, -139, 303, -112,
2848 466, 301, 302, 94, 304, 466, 467, -139, 123, 295,
2849 296, 297, 235, 235, 43, 516, 20, 29, 21, 51,
2850 506, -72, -72, 116, 39, 337, 338, -71, -71, 341,
2851 -70, -70, -69, -69, 576, 52, 65, 66, 390, 117,
2852 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2853 78, 58, 79, 20, 343, 21, 254, 255, 256, 257,
2854 258, 259, 260, 261, 262, 263, 366, 310, 311, 133,
2855 134, 335, 62, 532, 64, 533, 88, 102, -113, 80,
2856 98, 99, 100, 588, 361, 101, 113, 367, 114, 361,
2857 361, 242, 243, 244, 245, 246, 247, 248, 249, 122,
2858 197, 361, 201, 202, 368, 30, 31, 32, 33, 34,
2859 35, 36, 440, 388, 442, 443, 444, 203, 225, 226,
2860 231, 237, 450, 88, 389, 235, -76, -82, -75, 20,
2861 -74, 21, -73, 347, 361, 313, -79, -80, 6, -82,
2862 -82, 314, 339, 348, 361, 361, 361, 341, -82, -82,
2863 -82, -82, -82, -82, -82, 369, 371, -82, 22, 461,
2864 462, 463, 464, 465, 374, 23, 375, 376, 377, 24,
2865 378, 387, 473, 474, 475, 476, 477, 391, 379, 380,
2866 410, 381, 419, 382, 425, 81, 386, 392, 82, 422,
2867 398, 83, 399, 84, 118, 400, 439, 401, 402, 235,
2868 441, 235, 235, 235, 445, 446, 469, 411, 412, 235,
2869 451, 420, 363, 364, 413, 361, 361, 361, 414, 428,
2870 507, 508, 415, 361, 365, 423, 429, 514, 436, 459,
2871 447, 448, 537, 538, 539, 460, 449, 361, 361, 454,
2872 455, 482, 484, 485, 486, 343, 490, 487, 488, 494,
2873 496, 504, 497, 498, 505, 510, 502, 373, 511, 235,
2874 521, 512, 513, 517, 265, 266, 518, 383, 384, 385,
2875 560, 545, 546, 547, 548, 515, 519, 503, 550, 551,
2876 552, 553, 361, 522, 361, 520, 524, 555, 361, 531,
2877 250, 251, 534, 536, 542, 543, 361, 361, 361, 544,
2878 556, 557, 558, 564, 565, 549, 559, 563, 434, 235,
2879 250, 251, 566, 561, 567, 568, 569, 570, 575, 235,
2880 235, 235, 571, 572, 573, 235, 574, 583, 579, 584,
2881 585, 580, 581, 361, 361, 582, 361, 361, 430, 431,
2882 432, 590, 591, 361, 554, 592, 438, 593, 594, 597,
2883 598, 601, 361, 602, 186, 187, 188, 235, 189, 190,
2884 452, 453, 267, 268, 269, 270, 271, 272, 273, 274,
2885 275, 276, 277, 278, 279, 280, 396, 96, 57, 397,
2886 480, 104, 334, 224, 479, 361, 27, 45, 599, 493,
2887 540, 0, 509, 0, 0, 0, 0, 0, 0, 0,
2888 0, 0, 0, 0, 0, 489, 0, 491, 0, 0,
2889 0, 495, 0, 0, 0, 0, 0, 0, 0, 499,
2890 500, 501, 0, 0, 361, 0, 0, 0, 0, 0,
2891 0, 0, 0, 0, 0, 0, 0, 0, 0, 361,
2892 0, 0, 0, 0, 65, 66, 361, 0, 0, 0,
2893 361, 361, 0, 0, 0, 0, 525, 526, 0, 529,
2894 530, 20, 0, 21, 0, 315, 535, 0, 0, 0,
2895 0, 0, 0, 0, 0, 541, 0, 316, 317, 0,
2896 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2897 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2898 0, 0, 0, 0, 0, 0, 0, 0, 562, 0,
2899 0, 0, 0, 0, 0, 0, 0, 0, 135, 136,
2900 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
2901 147, 148, 149, 150, 151, 152, 153, 154, 155, 156,
2902 157, 158, 318, 319, 0, 0, 0, 586, 0, 320,
2903 0, 321, 0, 322, 323, 324, 0, 0, 0, 0,
2904 0, 0, 596, 0, 0, 0, 0, 0, 0, 600,
2905 0, 0, 0, 603, 604, 0, 0, 0, 173, 174,
2906 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
2907 185, 0, 0, 0, 0, 0, 325, 0, 0, 326,
2908 0, 327, 65, 66, 328, 117, 68, 69, 70, 71,
2909 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2910 0, 21, 65, 66, 0, 117, 208, 209, 210, 211,
2911 212, 213, 214, 215, 216, 217, 218, 0, 79, 20,
2912 0, 21, 0, 65, 66, 80, 117, 208, 209, 210,
2913 211, 212, 213, 214, 215, 216, 217, 218, 0, 79,
2914 20, 0, 21, 0, 0, 80, 0, 0, 65, 66,
2915 0, 117, 68, 69, 70, 71, 72, 73, 74, 75,
2916 76, 77, 78, 0, 79, 20, 80, 21, 0, 0,
2917 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2918 232, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2919 0, 80, 0, 0, 0, 0, 0, 0, 0, 0,
2920 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2921 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2922 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2923 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2924 227, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2925 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2926 408, 0, 0, 349, 350, 65, 66, 351, 0, 0,
2927 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2928 84, 468, 20, 0, 21, 0, 352, 353, 354, 0,
2929 0, 0, 0, 0, 0, 0, 0, 81, 355, 356,
2930 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2931 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2932 0, 357, 0, 0, 0, 0, 0, 0, 0, 0,
2933 0, 0, 0, 0, 0, 0, 0, 0, 0, 135,
2934 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2935 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
2936 156, 157, 158, 318, 319, 0, 0, 0, 0, 0,
2937 320, 0, 321, 0, 322, 323, 324, 0, 0, 0,
2938 0, 0, 0, 0, 0, 0, 0, 0, 0, 349,
2939 350, 0, 0, 351, 0, 0, 0, 0, 0, 173,
2940 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2941 184, 185, 352, 353, 354, 0, 0, 0, 0, 0,
2942 358, 0, 0, 0, 355, 356, 0, 0, 0, 0,
2943 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2944 0, 0, 0, 0, 0, 0, 0, 357, 0, 0,
2945 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2946 0, 0, 0, 0, 0, 135, 136, 137, 138, 139,
2947 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2948 150, 151, 152, 153, 154, 155, 156, 157, 158, 318,
2949 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
2950 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
2951 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2952 0, 0, 0, 0, 0, 173, 174, 175, 176, 177,
2953 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
2954 0, 0, 0, 0, 65, 66, 358, 117, 68, 69,
2955 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2956 79, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2957 0, 0, 0, 0, 0, 0, 342, 0, 0, 0,
2958 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2959 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2960 0, 79, 20, 0, 21, 65, 66, 0, 117, 68,
2961 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2962 0, 79, 20, 0, 21, 0, 0, 0, 80, 0,
2963 0, 0, 0, 0, 0, 0, 0, 424, 0, 0,
2964 0, 0, 0, 0, 0, 0, 65, 66, 80, 117,
2965 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2966 78, 0, 79, 20, 0, 21, 0, 0, 0, 0,
2967 0, 0, 0, 0, 0, 0, 0, 0, 478, 0,
2968 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
2969 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2970 0, 84, 65, 66, 0, 67, 68, 69, 70, 71,
2971 72, 73, 74, 75, 76, 77, 78, 0, 79, 20,
2972 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2973 0, 0, 0, 0, 81, 0, 0, 82, 0, 403,
2974 83, 0, 84, 0, 0, 80, 0, 0, 0, 0,
2975 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2976 83, 0, 84, 65, 66, 0, 117, 68, 69, 70,
2977 71, 72, 73, 74, 75, 76, 77, 78, 0, 79,
2978 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2979 0, 0, 0, 0, 0, 81, 0, 0, 82, 0,
2980 0, 83, 0, 84, 65, 66, 80, 117, 208, 209,
2981 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2982 79, 20, 0, 21, 65, 66, 0, 238, 68, 69,
2983 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
2984 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
2985 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2986 0, 0, 0, 0, 0, 65, 66, 80, 117, 208,
2987 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
2988 0, 79, 20, 0, 21, 0, 0, 0, 0, 0,
2989 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2990 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
2991 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2992 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2993 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2994 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2995 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2996 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2997 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2998 0, 84, 0, 0, 0, 0, 124, 0, 0, 0,
2999 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3000 125, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3001 126, 127, 0, 0, 81, 0, 0, 82, 0, 0,
3002 83, 0, 406, 128, 129, 130, 131, 132, 133, 134,
3003 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
3004 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
3005 155, 156, 157, 158, 159, 160, 161, 162, 163, 0,
3006 0, 164, 165, 166, 167, 168, 169, 170, 171, 172,
3007 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3008 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3009 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
3010 183, 184, 185
3011};
3012
3013static const short int yycheck[] =
3014{
3015 37, 125, 130, 130, 128, 4, 53, 283, 306, 307,
3016 29, 3, 111, 15, 23, 15, 53, 34, 326, 327,
3017 131, 30, 9, 577, 84, 10, 11, 12, 13, 14,
3018 15, 16, 17, 558, 21, 589, 32, 33, 336, 163,
3019 57, 153, 166, 167, 168, 169, 170, 171, 172, 41,
3020 358, 163, 155, 578, 116, 57, 116, 57, 0, 153,
3021 122, 164, 122, 27, 28, 189, 190, 161, 52, 53,
3022 54, 108, 109, 110, 10, 11, 12, 13, 14, 15,
3023 16, 17, 193, 25, 153, 20, 153, 71, 125, 31,
3024 161, 128, 161, 164, 86, 45, 163, 47, 406, 41,
3025 42, 43, 44, 45, 46, 47, 41, 42, 43, 44,
3026 45, 46, 47, 153, 159, 50, 55, 56, 57, 164,
3027 62, 55, 56, 163, 161, 162, 163, 164, 165, 166,
3028 167, 168, 169, 170, 171, 172, 0, 153, 153, 155,
3029 153, 108, 109, 162, 159, 153, 159, 163, 164, 186,
3030 187, 188, 189, 190, 163, 163, 22, 61, 24, 152,
3031 458, 3, 4, 162, 23, 225, 226, 3, 4, 229,
3032 3, 4, 3, 4, 159, 61, 5, 6, 302, 8,
3033 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
3034 19, 152, 21, 22, 231, 24, 119, 120, 121, 122,
3035 123, 124, 125, 126, 127, 128, 253, 3, 4, 77,
3036 78, 222, 24, 489, 4, 491, 253, 157, 155, 48,
3037 152, 152, 152, 159, 235, 152, 4, 264, 4, 240,
3038 241, 10, 11, 12, 13, 14, 15, 16, 17, 155,
3039 24, 252, 4, 24, 281, 64, 65, 66, 67, 68,
3040 69, 70, 376, 300, 378, 379, 380, 24, 158, 158,
3041 155, 59, 386, 300, 301, 302, 4, 20, 4, 22,
3042 4, 24, 4, 153, 285, 4, 7, 7, 31, 32,
3043 33, 7, 161, 156, 295, 296, 297, 347, 41, 42,
3044 43, 44, 45, 46, 47, 153, 153, 50, 51, 398,
3045 399, 400, 401, 402, 157, 58, 153, 153, 153, 62,
3046 153, 36, 411, 412, 413, 414, 415, 24, 153, 153,
3047 24, 153, 161, 153, 63, 154, 153, 153, 157, 153,
3048 155, 160, 155, 162, 163, 155, 157, 155, 155, 376,
3049 377, 378, 379, 380, 381, 382, 406, 155, 155, 386,
3050 387, 343, 240, 241, 155, 366, 367, 368, 155, 153,
3051 459, 460, 155, 374, 252, 156, 153, 466, 153, 155,
3052 153, 153, 496, 497, 498, 155, 153, 388, 389, 153,
3053 34, 24, 21, 21, 155, 422, 4, 153, 153, 153,
3054 153, 24, 153, 153, 4, 153, 155, 285, 153, 436,
3055 36, 153, 153, 153, 27, 28, 153, 295, 296, 297,
3056 534, 510, 511, 512, 513, 161, 153, 454, 517, 518,
3057 519, 520, 433, 57, 435, 153, 153, 4, 439, 153,
3058 558, 558, 153, 153, 153, 153, 447, 448, 449, 156,
3059 24, 153, 157, 542, 543, 161, 156, 156, 57, 486,
3060 578, 578, 153, 159, 156, 153, 153, 156, 21, 496,
3061 497, 498, 156, 156, 156, 502, 156, 566, 36, 568,
3062 569, 159, 156, 484, 485, 156, 487, 488, 366, 367,
3063 368, 21, 156, 494, 521, 156, 374, 156, 153, 21,
3064 153, 21, 503, 21, 96, 96, 96, 534, 96, 96,
3065 388, 389, 125, 126, 127, 128, 129, 130, 131, 132,
3066 133, 134, 135, 136, 137, 138, 318, 41, 25, 319,
3067 423, 52, 222, 112, 422, 536, 3, 19, 596, 436,
3068 502, -1, 461, -1, -1, -1, -1, -1, -1, -1,
3069 -1, -1, -1, -1, -1, 433, -1, 435, -1, -1,
3070 -1, 439, -1, -1, -1, -1, -1, -1, -1, 447,
3071 448, 449, -1, -1, 575, -1, -1, -1, -1, -1,
3072 -1, -1, -1, -1, -1, -1, -1, -1, -1, 590,
3073 -1, -1, -1, -1, 5, 6, 597, -1, -1, -1,
3074 601, 602, -1, -1, -1, -1, 484, 485, -1, 487,
3075 488, 22, -1, 24, -1, 26, 494, -1, -1, -1,
3076 -1, -1, -1, -1, -1, 503, -1, 38, 39, -1,
3077 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3078 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3079 -1, -1, -1, -1, -1, -1, -1, -1, 536, -1,
3080 -1, -1, -1, -1, -1, -1, -1, -1, 79, 80,
3081 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
3082 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
3083 101, 102, 103, 104, -1, -1, -1, 575, -1, 110,
3084 -1, 112, -1, 114, 115, 116, -1, -1, -1, -1,
3085 -1, -1, 590, -1, -1, -1, -1, -1, -1, 597,
3086 -1, -1, -1, 601, 602, -1, -1, -1, 139, 140,
3087 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
3088 151, -1, -1, -1, -1, -1, 157, -1, -1, 160,
3089 -1, 162, 5, 6, 165, 8, 9, 10, 11, 12,
3090 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3091 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3092 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3093 -1, 24, -1, 5, 6, 48, 8, 9, 10, 11,
3094 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
3095 22, -1, 24, -1, -1, 48, -1, -1, 5, 6,
3096 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
3097 17, 18, 19, -1, 21, 22, 48, 24, -1, -1,
3098 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3099 37, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3100 -1, 48, -1, -1, -1, -1, -1, -1, -1, -1,
3101 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3102 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3103 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3104 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3105 163, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3106 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3107 163, -1, -1, 3, 4, 5, 6, 7, -1, -1,
3108 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
3109 162, 163, 22, -1, 24, -1, 26, 27, 28, -1,
3110 -1, -1, -1, -1, -1, -1, -1, 154, 38, 39,
3111 157, -1, -1, 160, -1, 162, -1, -1, -1, -1,
3112 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3113 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
3114 -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
3115 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
3116 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
3117 100, 101, 102, 103, 104, -1, -1, -1, -1, -1,
3118 110, -1, 112, -1, 114, 115, 116, -1, -1, -1,
3119 -1, -1, -1, -1, -1, -1, -1, -1, -1, 3,
3120 4, -1, -1, 7, -1, -1, -1, -1, -1, 139,
3121 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
3122 150, 151, 26, 27, 28, -1, -1, -1, -1, -1,
3123 160, -1, -1, -1, 38, 39, -1, -1, -1, -1,
3124 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3125 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
3126 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3127 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
3128 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3129 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3130 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
3131 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
3132 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3133 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
3134 144, 145, 146, 147, 148, 149, 150, 151, -1, -1,
3135 -1, -1, -1, -1, 5, 6, 160, 8, 9, 10,
3136 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3137 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
3138 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
3139 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
3140 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
3141 -1, 21, 22, -1, 24, 5, 6, -1, 8, 9,
3142 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
3143 -1, 21, 22, -1, 24, -1, -1, -1, 48, -1,
3144 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
3145 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
3146 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
3147 19, -1, 21, 22, -1, 24, -1, -1, -1, -1,
3148 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
3149 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
3150 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
3151 -1, 162, 5, 6, -1, 8, 9, 10, 11, 12,
3152 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3153 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
3154 -1, -1, -1, -1, 154, -1, -1, 157, -1, 159,
3155 160, -1, 162, -1, -1, 48, -1, -1, -1, -1,
3156 -1, -1, -1, -1, 154, -1, -1, 157, -1, -1,
3157 160, -1, 162, 5, 6, -1, 8, 9, 10, 11,
3158 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
3159 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
3160 -1, -1, -1, -1, -1, 154, -1, -1, 157, -1,
3161 -1, 160, -1, 162, 5, 6, 48, 8, 9, 10,
3162 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3163 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
3164 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3165 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
3166 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3167 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
3168 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
3169 -1, 21, 22, -1, 24, -1, -1, -1, -1, -1,
3170 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3171 -1, -1, -1, -1, -1, -1, -1, -1, 48, -1,
3172 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
3173 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3174 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3175 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3176 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
3177 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
3178 -1, -1, -1, 154, -1, -1, 157, -1, -1, 160,
3179 -1, 162, -1, -1, -1, -1, 35, -1, -1, -1,
3180 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3181 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3182 59, 60, -1, -1, 154, -1, -1, 157, -1, -1,
3183 160, -1, 162, 72, 73, 74, 75, 76, 77, 78,
3184 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
3185 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
3186 99, 100, 101, 102, 103, 104, 105, 106, 107, -1,
3187 -1, 110, 111, 112, 113, 114, 115, 116, 117, 118,
3188 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3189 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3190 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
3191 149, 150, 151
3192};
3193
3194/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
3195 symbol of state STATE-NUM. */
3196static const unsigned char yystos[] =
3197{
3198 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
3199 44, 45, 46, 47, 62, 181, 219, 221, 223, 231,
3200 22, 24, 51, 58, 62, 180, 212, 223, 224, 61,
3201 64, 65, 66, 67, 68, 69, 70, 182, 217, 23,
3202 232, 233, 30, 163, 220, 232, 52, 53, 54, 71,
3203 209, 152, 61, 20, 45, 47, 50, 181, 152, 45,
3204 47, 222, 24, 207, 4, 5, 6, 8, 9, 10,
3205 11, 12, 13, 14, 15, 16, 17, 18, 19, 21,
3206 48, 154, 157, 160, 162, 167, 189, 190, 191, 192,
3207 193, 212, 228, 29, 162, 218, 180, 237, 152, 152,
3208 152, 152, 157, 210, 207, 189, 32, 33, 199, 199,
3209 199, 199, 225, 4, 4, 4, 162, 8, 163, 193,
3210 194, 212, 155, 164, 35, 49, 59, 60, 72, 73,
3211 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
3212 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3213 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3214 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
3215 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
3216 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
3217 175, 234, 235, 241, 242, 244, 245, 24, 55, 56,
3218 208, 4, 24, 24, 211, 191, 191, 191, 9, 10,
3219 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
3220 177, 179, 191, 196, 217, 158, 158, 163, 194, 153,
3221 163, 155, 37, 194, 195, 191, 230, 59, 8, 230,
3222 9, 21, 10, 11, 12, 13, 14, 15, 16, 17,
3223 176, 177, 178, 182, 119, 120, 121, 122, 123, 124,
3224 125, 126, 127, 128, 172, 27, 28, 125, 126, 127,
3225 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
3226 138, 173, 191, 191, 230, 191, 191, 238, 230, 230,
3227 230, 230, 230, 230, 230, 191, 191, 191, 230, 230,
3228 182, 108, 109, 153, 159, 205, 206, 204, 27, 28,
3229 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
3230 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
3231 170, 171, 174, 175, 197, 228, 203, 193, 193, 161,
3232 163, 193, 37, 191, 214, 215, 216, 153, 156, 3,
3233 4, 7, 26, 27, 28, 38, 39, 61, 160, 197,
3234 227, 228, 229, 229, 229, 229, 189, 191, 191, 153,
3235 184, 153, 184, 229, 157, 153, 153, 153, 153, 153,
3236 153, 153, 153, 229, 229, 229, 153, 36, 189, 191,
3237 230, 24, 153, 187, 187, 187, 172, 173, 155, 155,
3238 155, 155, 155, 159, 196, 198, 162, 198, 163, 198,
3239 24, 155, 155, 155, 155, 155, 187, 159, 161, 161,
3240 212, 213, 153, 156, 37, 63, 226, 198, 153, 153,
3241 229, 229, 229, 15, 57, 15, 153, 243, 229, 157,
3242 230, 191, 230, 230, 230, 191, 191, 153, 153, 153,
3243 230, 191, 229, 229, 153, 34, 57, 185, 188, 155,
3244 155, 196, 196, 196, 196, 196, 153, 159, 163, 193,
3245 198, 161, 163, 196, 196, 196, 196, 196, 37, 214,
3246 185, 186, 24, 161, 21, 21, 155, 153, 153, 229,
3247 4, 229, 230, 239, 153, 229, 153, 153, 153, 229,
3248 229, 229, 155, 191, 24, 4, 187, 196, 196, 243,
3249 153, 153, 153, 153, 196, 161, 163, 153, 153, 153,
3250 153, 36, 57, 183, 153, 229, 229, 239, 240, 229,
3251 229, 153, 184, 184, 153, 229, 153, 230, 230, 230,
3252 240, 229, 153, 153, 156, 196, 196, 196, 196, 161,
3253 196, 196, 196, 196, 191, 4, 24, 153, 157, 156,
3254 230, 159, 229, 156, 196, 196, 153, 156, 153, 153,
3255 156, 156, 156, 156, 156, 21, 159, 178, 236, 36,
3256 159, 156, 156, 196, 196, 196, 229, 227, 159, 178,
3257 21, 156, 156, 156, 153, 227, 229, 21, 153, 234,
3258 229, 21, 21, 229, 229
3259};
Reid Spencere7c3c602006-11-30 06:36:44 +00003260
3261#define yyerrok (yyerrstatus = 0)
3262#define yyclearin (yychar = YYEMPTY)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003263#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003264#define YYEOF 0
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003265
Reid Spencere7c3c602006-11-30 06:36:44 +00003266#define YYACCEPT goto yyacceptlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003267#define YYABORT goto yyabortlab
3268#define YYERROR goto yyerrorlab
3269
3270
3271/* Like YYERROR except do call yyerror. This remains here temporarily
3272 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003273 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003274
Reid Spencere7c3c602006-11-30 06:36:44 +00003275#define YYFAIL goto yyerrlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003276
Reid Spencere7c3c602006-11-30 06:36:44 +00003277#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003278
3279#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003280do \
3281 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003282 { \
3283 yychar = (Token); \
3284 yylval = (Value); \
3285 yytoken = YYTRANSLATE (yychar); \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003286 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003287 goto yybackup; \
3288 } \
3289 else \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003290 { \
3291 yyerror (YY_("syntax error: cannot back up")); \
3292 YYERROR; \
3293 } \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003294while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003295
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003296
Reid Spencere7c3c602006-11-30 06:36:44 +00003297#define YYTERROR 1
3298#define YYERRCODE 256
3299
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003300
3301/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3302 If N is 0, then set CURRENT to the empty location which ends
3303 the previous symbol: RHS[0] (always defined). */
3304
3305#define YYRHSLOC(Rhs, K) ((Rhs)[K])
3306#ifndef YYLLOC_DEFAULT
3307# define YYLLOC_DEFAULT(Current, Rhs, N) \
3308 do \
3309 if (N) \
3310 { \
3311 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3312 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3313 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3314 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3315 } \
3316 else \
3317 { \
3318 (Current).first_line = (Current).last_line = \
3319 YYRHSLOC (Rhs, 0).last_line; \
3320 (Current).first_column = (Current).last_column = \
3321 YYRHSLOC (Rhs, 0).last_column; \
3322 } \
3323 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003324#endif
3325
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003326
3327/* YY_LOCATION_PRINT -- Print the location on the stream.
3328 This macro was not mandated originally: define only if we know
3329 we won't break user code: when these are the locations we know. */
3330
3331#ifndef YY_LOCATION_PRINT
3332# if YYLTYPE_IS_TRIVIAL
3333# define YY_LOCATION_PRINT(File, Loc) \
3334 fprintf (File, "%d.%d-%d.%d", \
3335 (Loc).first_line, (Loc).first_column, \
3336 (Loc).last_line, (Loc).last_column)
3337# else
3338# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3339# endif
3340#endif
3341
3342
3343/* YYLEX -- calling `yylex' with the right arguments. */
3344
Reid Spencer950bf602007-01-26 08:19:09 +00003345#ifdef YYLEX_PARAM
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003346# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer950bf602007-01-26 08:19:09 +00003347#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003348# define YYLEX yylex ()
Chris Lattner4227bdb2007-02-19 07:34:02 +00003349#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003350
3351/* Enable debugging if requested. */
3352#if YYDEBUG
3353
3354# ifndef YYFPRINTF
3355# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3356# define YYFPRINTF fprintf
3357# endif
3358
3359# define YYDPRINTF(Args) \
3360do { \
3361 if (yydebug) \
3362 YYFPRINTF Args; \
3363} while (0)
3364
3365# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3366do { \
3367 if (yydebug) \
3368 { \
3369 YYFPRINTF (stderr, "%s ", Title); \
3370 yysymprint (stderr, \
3371 Type, Value); \
3372 YYFPRINTF (stderr, "\n"); \
3373 } \
3374} while (0)
3375
3376/*------------------------------------------------------------------.
3377| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3378| TOP (included). |
3379`------------------------------------------------------------------*/
3380
3381#if defined (__STDC__) || defined (__cplusplus)
3382static void
3383yy_stack_print (short int *bottom, short int *top)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003384#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003385static void
3386yy_stack_print (bottom, top)
3387 short int *bottom;
3388 short int *top;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003389#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003390{
3391 YYFPRINTF (stderr, "Stack now");
3392 for (/* Nothing. */; bottom <= top; ++bottom)
3393 YYFPRINTF (stderr, " %d", *bottom);
3394 YYFPRINTF (stderr, "\n");
3395}
3396
3397# define YY_STACK_PRINT(Bottom, Top) \
3398do { \
3399 if (yydebug) \
3400 yy_stack_print ((Bottom), (Top)); \
3401} while (0)
3402
3403
3404/*------------------------------------------------.
3405| Report that the YYRULE is going to be reduced. |
3406`------------------------------------------------*/
3407
3408#if defined (__STDC__) || defined (__cplusplus)
3409static void
3410yy_reduce_print (int yyrule)
3411#else
3412static void
3413yy_reduce_print (yyrule)
3414 int yyrule;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003415#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003416{
3417 int yyi;
3418 unsigned long int yylno = yyrline[yyrule];
3419 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3420 yyrule - 1, yylno);
3421 /* Print the symbols being reduced, and their result. */
3422 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3423 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3424 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3425}
Reid Spencer9d6565a2007-02-15 02:26:10 +00003426
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003427# define YY_REDUCE_PRINT(Rule) \
3428do { \
3429 if (yydebug) \
3430 yy_reduce_print (Rule); \
3431} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00003432
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003433/* Nonzero means print parse trace. It is left uninitialized so that
3434 multiple parsers can coexist. */
3435int yydebug;
3436#else /* !YYDEBUG */
3437# define YYDPRINTF(Args)
3438# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3439# define YY_STACK_PRINT(Bottom, Top)
3440# define YY_REDUCE_PRINT(Rule)
3441#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00003442
Reid Spencer9d6565a2007-02-15 02:26:10 +00003443
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003444/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003445#ifndef YYINITDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003446# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003447#endif
3448
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003449/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3450 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003451
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003452 Do not make this value too large; the results are undefined if
3453 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3454 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003455
3456#ifndef YYMAXDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003457# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003458#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003459
Reid Spencere7c3c602006-11-30 06:36:44 +00003460
3461
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003462#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003463
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003464# ifndef yystrlen
3465# if defined (__GLIBC__) && defined (_STRING_H)
3466# define yystrlen strlen
3467# else
3468/* Return the length of YYSTR. */
3469static YYSIZE_T
3470# if defined (__STDC__) || defined (__cplusplus)
3471yystrlen (const char *yystr)
3472# else
3473yystrlen (yystr)
3474 const char *yystr;
3475# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003476{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003477 const char *yys = yystr;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003478
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003479 while (*yys++ != '\0')
3480 continue;
3481
3482 return yys - yystr - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003483}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003484# endif
3485# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003486
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003487# ifndef yystpcpy
3488# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3489# define yystpcpy stpcpy
3490# else
3491/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3492 YYDEST. */
3493static char *
3494# if defined (__STDC__) || defined (__cplusplus)
3495yystpcpy (char *yydest, const char *yysrc)
3496# else
3497yystpcpy (yydest, yysrc)
3498 char *yydest;
3499 const char *yysrc;
3500# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003501{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003502 char *yyd = yydest;
3503 const char *yys = yysrc;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003504
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003505 while ((*yyd++ = *yys++) != '\0')
3506 continue;
3507
3508 return yyd - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003509}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003510# endif
3511# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003512
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003513# ifndef yytnamerr
3514/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3515 quotes and backslashes, so that it's suitable for yyerror. The
3516 heuristic is that double-quoting is unnecessary unless the string
3517 contains an apostrophe, a comma, or backslash (other than
3518 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3519 null, do not copy; instead, return the length of what the result
3520 would have been. */
3521static YYSIZE_T
3522yytnamerr (char *yyres, const char *yystr)
3523{
3524 if (*yystr == '"')
3525 {
3526 size_t yyn = 0;
3527 char const *yyp = yystr;
3528
3529 for (;;)
3530 switch (*++yyp)
3531 {
3532 case '\'':
3533 case ',':
3534 goto do_not_strip_quotes;
3535
3536 case '\\':
3537 if (*++yyp != '\\')
3538 goto do_not_strip_quotes;
3539 /* Fall through. */
3540 default:
3541 if (yyres)
3542 yyres[yyn] = *yyp;
3543 yyn++;
3544 break;
3545
3546 case '"':
3547 if (yyres)
3548 yyres[yyn] = '\0';
3549 return yyn;
3550 }
3551 do_not_strip_quotes: ;
3552 }
3553
3554 if (! yyres)
3555 return yystrlen (yystr);
3556
3557 return yystpcpy (yyres, yystr) - yyres;
3558}
3559# endif
3560
3561#endif /* YYERROR_VERBOSE */
3562
Reid Spencer9d6565a2007-02-15 02:26:10 +00003563
3564
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003565#if YYDEBUG
3566/*--------------------------------.
3567| Print this symbol on YYOUTPUT. |
3568`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00003569
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003570#if defined (__STDC__) || defined (__cplusplus)
3571static void
3572yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003573#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003574static void
3575yysymprint (yyoutput, yytype, yyvaluep)
3576 FILE *yyoutput;
3577 int yytype;
3578 YYSTYPE *yyvaluep;
3579#endif
3580{
3581 /* Pacify ``unused variable'' warnings. */
3582 (void) yyvaluep;
3583
3584 if (yytype < YYNTOKENS)
3585 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3586 else
3587 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3588
3589
3590# ifdef YYPRINT
3591 if (yytype < YYNTOKENS)
3592 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3593# endif
3594 switch (yytype)
3595 {
3596 default:
3597 break;
3598 }
3599 YYFPRINTF (yyoutput, ")");
3600}
3601
3602#endif /* ! YYDEBUG */
3603/*-----------------------------------------------.
3604| Release the memory associated to this symbol. |
3605`-----------------------------------------------*/
3606
3607#if defined (__STDC__) || defined (__cplusplus)
3608static void
3609yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3610#else
3611static void
3612yydestruct (yymsg, yytype, yyvaluep)
3613 const char *yymsg;
3614 int yytype;
3615 YYSTYPE *yyvaluep;
3616#endif
3617{
3618 /* Pacify ``unused variable'' warnings. */
3619 (void) yyvaluep;
3620
3621 if (!yymsg)
3622 yymsg = "Deleting";
3623 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3624
3625 switch (yytype)
3626 {
3627
3628 default:
3629 break;
3630 }
3631}
3632
3633
3634/* Prevent warnings from -Wmissing-prototypes. */
3635
3636#ifdef YYPARSE_PARAM
3637# if defined (__STDC__) || defined (__cplusplus)
3638int yyparse (void *YYPARSE_PARAM);
3639# else
3640int yyparse ();
3641# endif
3642#else /* ! YYPARSE_PARAM */
3643#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003644int yyparse (void);
Chris Lattner4227bdb2007-02-19 07:34:02 +00003645#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003646int yyparse ();
3647#endif
3648#endif /* ! YYPARSE_PARAM */
3649
3650
3651
3652/* The look-ahead symbol. */
3653int yychar;
3654
3655/* The semantic value of the look-ahead symbol. */
3656YYSTYPE yylval;
3657
3658/* Number of syntax errors so far. */
3659int yynerrs;
3660
3661
3662
3663/*----------.
3664| yyparse. |
3665`----------*/
3666
3667#ifdef YYPARSE_PARAM
3668# if defined (__STDC__) || defined (__cplusplus)
3669int yyparse (void *YYPARSE_PARAM)
3670# else
3671int yyparse (YYPARSE_PARAM)
3672 void *YYPARSE_PARAM;
3673# endif
3674#else /* ! YYPARSE_PARAM */
3675#if defined (__STDC__) || defined (__cplusplus)
3676int
3677yyparse (void)
3678#else
3679int
3680yyparse ()
3681
3682#endif
3683#endif
3684{
3685
3686 int yystate;
3687 int yyn;
3688 int yyresult;
3689 /* Number of tokens to shift before error messages enabled. */
3690 int yyerrstatus;
3691 /* Look-ahead token as an internal (translated) token number. */
3692 int yytoken = 0;
3693
3694 /* Three stacks and their tools:
3695 `yyss': related to states,
3696 `yyvs': related to semantic values,
3697 `yyls': related to locations.
3698
3699 Refer to the stacks thru separate pointers, to allow yyoverflow
3700 to reallocate them elsewhere. */
3701
3702 /* The state stack. */
3703 short int yyssa[YYINITDEPTH];
3704 short int *yyss = yyssa;
3705 short int *yyssp;
3706
3707 /* The semantic value stack. */
3708 YYSTYPE yyvsa[YYINITDEPTH];
3709 YYSTYPE *yyvs = yyvsa;
3710 YYSTYPE *yyvsp;
3711
3712
3713
Chris Lattnercf3d0612007-02-13 06:04:17 +00003714#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003715
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003716 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003717
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003718 /* The variables used to return semantic value and location from the
3719 action routines. */
3720 YYSTYPE yyval;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003721
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003722
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003723 /* When reducing, the number of symbols on the RHS of the reduced
3724 rule. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003725 int yylen;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003726
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003727 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003728
Reid Spencere7c3c602006-11-30 06:36:44 +00003729 yystate = 0;
3730 yyerrstatus = 0;
3731 yynerrs = 0;
3732 yychar = YYEMPTY; /* Cause a token to be read. */
3733
3734 /* Initialize stack pointers.
3735 Waste one element of value and location stack
3736 so that they stay on the same level as the state stack.
3737 The wasted elements are never initialized. */
3738
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003739 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003740 yyvsp = yyvs;
3741
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003742 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003743
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003744/*------------------------------------------------------------.
3745| yynewstate -- Push a new state, which is found in yystate. |
3746`------------------------------------------------------------*/
3747 yynewstate:
3748 /* In all cases, when you get here, the value and location stacks
3749 have just been pushed. so pushing a state here evens the stacks.
3750 */
3751 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003752
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003753 yysetstate:
3754 *yyssp = yystate;
3755
3756 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003757 {
3758 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003759 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003760
3761#ifdef yyoverflow
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003762 {
3763 /* Give user a chance to reallocate the stack. Use copies of
3764 these so that the &'s don't force the real ones into
3765 memory. */
3766 YYSTYPE *yyvs1 = yyvs;
3767 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003768
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003769
3770 /* Each stack pointer address is followed by the size of the
3771 data in use in that stack, in bytes. This used to be a
3772 conditional around just the two extra args, but that might
3773 be undefined if yyoverflow is a macro. */
3774 yyoverflow (YY_("memory exhausted"),
3775 &yyss1, yysize * sizeof (*yyssp),
3776 &yyvs1, yysize * sizeof (*yyvsp),
3777
3778 &yystacksize);
3779
3780 yyss = yyss1;
3781 yyvs = yyvs1;
3782 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003783#else /* no yyoverflow */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003784# ifndef YYSTACK_RELOCATE
3785 goto yyexhaustedlab;
3786# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003787 /* Extend the stack our own way. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003788 if (YYMAXDEPTH <= yystacksize)
3789 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003790 yystacksize *= 2;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003791 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003792 yystacksize = YYMAXDEPTH;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003793
3794 {
3795 short int *yyss1 = yyss;
3796 union yyalloc *yyptr =
3797 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3798 if (! yyptr)
3799 goto yyexhaustedlab;
3800 YYSTACK_RELOCATE (yyss);
3801 YYSTACK_RELOCATE (yyvs);
3802
3803# undef YYSTACK_RELOCATE
3804 if (yyss1 != yyssa)
3805 YYSTACK_FREE (yyss1);
3806 }
3807# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003808#endif /* no yyoverflow */
3809
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003810 yyssp = yyss + yysize - 1;
3811 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003812
3813
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003814 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3815 (unsigned long int) yystacksize));
3816
3817 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003818 YYABORT;
3819 }
3820
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003821 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003822
3823 goto yybackup;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003824
3825/*-----------.
3826| yybackup. |
3827`-----------*/
3828yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003829
Chris Lattnercf3d0612007-02-13 06:04:17 +00003830/* Do appropriate processing given the current state. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003831/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003832/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003833
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003834 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003835
Reid Spencere7c3c602006-11-30 06:36:44 +00003836 yyn = yypact[yystate];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003837 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003838 goto yydefault;
3839
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003840 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003841
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003842 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003843 if (yychar == YYEMPTY)
3844 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003845 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003846 yychar = YYLEX;
3847 }
3848
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003849 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003850 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003851 yychar = yytoken = YYEOF;
3852 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003853 }
3854 else
3855 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003856 yytoken = YYTRANSLATE (yychar);
3857 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003858 }
3859
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003860 /* If the proper action on seeing token YYTOKEN is to reduce or to
3861 detect an error, take that action. */
3862 yyn += yytoken;
3863 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003864 goto yydefault;
3865 yyn = yytable[yyn];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003866 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003867 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003868 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003869 goto yyerrlab;
3870 yyn = -yyn;
3871 goto yyreduce;
3872 }
3873
3874 if (yyn == YYFINAL)
3875 YYACCEPT;
3876
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003877 /* Shift the look-ahead token. */
3878 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencerb7046c72007-01-29 05:41:34 +00003879
Chris Lattnercf3d0612007-02-13 06:04:17 +00003880 /* Discard the token being shifted unless it is eof. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003881 if (yychar != YYEOF)
3882 yychar = YYEMPTY;
3883
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003884 *++yyvsp = yylval;
3885
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003886
3887 /* Count tokens shifted since error; after three, turn off error
3888 status. */
3889 if (yyerrstatus)
3890 yyerrstatus--;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003891
3892 yystate = yyn;
Reid Spencere7c3c602006-11-30 06:36:44 +00003893 goto yynewstate;
3894
Chris Lattner4227bdb2007-02-19 07:34:02 +00003895
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003896/*-----------------------------------------------------------.
3897| yydefault -- do the default action for the current state. |
3898`-----------------------------------------------------------*/
3899yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003900 yyn = yydefact[yystate];
3901 if (yyn == 0)
3902 goto yyerrlab;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003903 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003904
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003905
3906/*-----------------------------.
3907| yyreduce -- Do a reduction. |
3908`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003909yyreduce:
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003910 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003911 yylen = yyr2[yyn];
3912
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003913 /* If YYLEN is nonzero, implement the default value of the action:
3914 `$$ = $1'.
3915
3916 Otherwise, the following line sets YYVAL to garbage.
3917 This behavior is undocumented and Bison
3918 users should not rely upon it. Assigning to YYVAL
3919 unconditionally makes the parser a bit smaller, and it avoids a
3920 GCC warning that YYVAL may be used uninitialized. */
3921 yyval = yyvsp[1-yylen];
3922
3923
3924 YY_REDUCE_PRINT (yyn);
3925 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003926 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003927 case 3:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003928#line 1834 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003929 {
3930 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003931 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003932 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3933 ;}
3934 break;
3935
3936 case 5:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003937#line 1843 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003938 {
3939 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003940 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003941 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3942 ;}
3943 break;
3944
3945 case 26:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003946#line 1865 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003947 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3948 break;
3949
3950 case 27:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003951#line 1865 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003952 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3953 break;
3954
3955 case 28:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003956#line 1866 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003957 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3958 break;
3959
3960 case 29:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003961#line 1866 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003962 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3963 break;
3964
3965 case 30:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003966#line 1867 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003967 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3968 break;
3969
3970 case 31:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003971#line 1867 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003972 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
3973 break;
3974
3975 case 32:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003976#line 1868 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003977 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
3978 break;
3979
3980 case 33:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003981#line 1868 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003982 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
3983 break;
3984
3985 case 34:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003986#line 1869 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003987 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
3988 break;
3989
3990 case 35:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003991#line 1869 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003992 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
3993 break;
3994
3995 case 36:
Reid Spencerbb1fd572007-03-21 17:15:50 +00003996#line 1873 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003997 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
3998 break;
3999
4000 case 37:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004001#line 1873 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004002 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
4003 break;
4004
4005 case 38:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004006#line 1874 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004007 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
4008 break;
4009
4010 case 39:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004011#line 1874 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004012 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
4013 break;
4014
4015 case 40:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004016#line 1875 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004017 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
4018 break;
4019
4020 case 41:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004021#line 1875 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004022 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
4023 break;
4024
4025 case 42:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004026#line 1876 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004027 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
4028 break;
4029
4030 case 43:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004031#line 1876 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004032 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
4033 break;
4034
4035 case 44:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004036#line 1877 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004037 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
4038 break;
4039
4040 case 45:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004041#line 1877 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004042 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
4043 break;
4044
4045 case 46:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004046#line 1878 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004047 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
4048 break;
4049
4050 case 47:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004051#line 1878 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004052 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
4053 break;
4054
4055 case 48:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004056#line 1879 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004057 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
4058 break;
4059
4060 case 49:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004061#line 1879 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004062 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
4063 break;
4064
4065 case 50:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004066#line 1880 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004067 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
4068 break;
4069
4070 case 51:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004071#line 1881 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004072 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
4073 break;
4074
4075 case 81:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004076#line 1912 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004077 {
4078 (yyval.StrVal) = (yyvsp[-1].StrVal);
4079 ;}
4080 break;
4081
4082 case 82:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004083#line 1915 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004084 {
4085 (yyval.StrVal) = 0;
4086 ;}
4087 break;
4088
4089 case 83:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004090#line 1920 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004091 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
4092 break;
4093
4094 case 84:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004095#line 1921 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004096 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
4097 break;
4098
4099 case 85:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004100#line 1922 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004101 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
4102 break;
4103
4104 case 86:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004105#line 1923 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004106 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
4107 break;
4108
4109 case 87:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004110#line 1924 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004111 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
4112 break;
4113
4114 case 88:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004115#line 1925 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004116 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
4117 break;
4118
4119 case 89:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004120#line 1926 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004121 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
4122 break;
4123
4124 case 90:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004125#line 1927 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004126 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
4127 break;
4128
4129 case 91:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004130#line 1931 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004131 { (yyval.UIntVal) = OldCallingConv::C; ;}
4132 break;
4133
4134 case 92:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004135#line 1932 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004136 { (yyval.UIntVal) = OldCallingConv::C; ;}
4137 break;
4138
4139 case 93:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004140#line 1933 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004141 { (yyval.UIntVal) = OldCallingConv::CSRet; ;}
4142 break;
4143
4144 case 94:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004145#line 1934 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004146 { (yyval.UIntVal) = OldCallingConv::Fast; ;}
4147 break;
4148
4149 case 95:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004150#line 1935 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004151 { (yyval.UIntVal) = OldCallingConv::Cold; ;}
4152 break;
4153
4154 case 96:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004155#line 1936 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004156 { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
4157 break;
4158
4159 case 97:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004160#line 1937 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004161 { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
4162 break;
4163
4164 case 98:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004165#line 1938 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004166 {
4167 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004168 error("Calling conv too large");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004169 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4170 ;}
4171 break;
4172
4173 case 99:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004174#line 1948 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004175 { (yyval.UIntVal) = 0; ;}
4176 break;
4177
4178 case 100:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004179#line 1949 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004180 {
4181 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4182 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004183 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004184 ;}
4185 break;
4186
4187 case 101:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004188#line 1957 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004189 { (yyval.UIntVal) = 0; ;}
4190 break;
4191
4192 case 102:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004193#line 1958 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004194 {
4195 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4196 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004197 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004198 ;}
4199 break;
4200
4201 case 103:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004202#line 1966 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004203 {
4204 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
4205 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00004206 error("Invalid character in section name");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004207 (yyval.StrVal) = (yyvsp[0].StrVal);
4208 ;}
4209 break;
4210
4211 case 104:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004212#line 1975 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004213 { (yyval.StrVal) = 0; ;}
4214 break;
4215
4216 case 105:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004217#line 1976 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004218 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
4219 break;
4220
4221 case 106:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004222#line 1983 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004223 {;}
4224 break;
4225
4226 case 107:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004227#line 1984 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004228 {;}
4229 break;
4230
4231 case 108:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004232#line 1988 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004233 {
4234 CurGV->setSection((yyvsp[0].StrVal));
4235 free((yyvsp[0].StrVal));
4236 ;}
4237 break;
4238
4239 case 109:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004240#line 1992 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004241 {
4242 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004243 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004244 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004245
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004246 ;}
4247 break;
4248
4249 case 111:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004250#line 2009 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004251 {
4252 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004253 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004254 ;}
4255 break;
4256
4257 case 113:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004258#line 2017 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004259 {
4260 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004261 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004262 ;}
4263 break;
4264
4265 case 114:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004266#line 2024 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004267 {
Reid Spencer950bf602007-01-26 08:19:09 +00004268 if (!UpRefs.empty())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004269 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription());
4270 (yyval.TypeVal) = (yyvsp[0].TypeVal);
4271 ;}
4272 break;
4273
4274 case 127:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004275#line 2038 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004276 {
4277 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004278 (yyval.TypeVal).S.copy((yyvsp[0].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004279 ;}
4280 break;
4281
4282 case 128:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004283#line 2042 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004284 {
4285 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004286 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004287 ;}
4288 break;
4289
4290 case 129:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004291#line 2046 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004292 { // Named types are also simple types...
Reid Spencerbb1fd572007-03-21 17:15:50 +00004293 (yyval.TypeVal).S.copy(getTypeSign((yyvsp[0].ValIDVal)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004294 const Type* tmp = getType((yyvsp[0].ValIDVal));
4295 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004296 ;}
4297 break;
4298
4299 case 130:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004300#line 2051 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004301 { // Type UpReference
4302 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004303 error("Value out of range");
4304 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004305 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
4306 (yyval.TypeVal).PAT = new PATypeHolder(OT);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004307 (yyval.TypeVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00004308 UR_OUT("New Upreference!\n");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004309 ;}
4310 break;
4311
4312 case 131:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004313#line 2060 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004314 { // Function derived type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004315 (yyval.TypeVal).S.makeComposite((yyvsp[-3].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004316 std::vector<const Type*> Params;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004317 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4318 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004319 Params.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004320 (yyval.TypeVal).S.add(I->S);
Reid Spencer52402b02007-01-02 05:45:11 +00004321 }
Reid Spencerb7046c72007-01-29 05:41:34 +00004322 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00004323 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4324 if (isVarArg) Params.pop_back();
4325
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004326 (yyval.TypeVal).PAT = new PATypeHolder(
4327 HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg,
Reid Spencerbb1fd572007-03-21 17:15:50 +00004328 ParamAttrs), (yyval.TypeVal).S));
4329 delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004330 delete (yyvsp[-1].TypeList); // Delete the argument list
4331 ;}
4332 break;
4333
4334 case 132:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004335#line 2078 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004336 { // Sized array type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004337 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004338 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(),
Reid Spencerbb1fd572007-03-21 17:15:50 +00004339 (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004340 delete (yyvsp[-1].TypeVal).PAT;
4341 ;}
4342 break;
4343
4344 case 133:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004345#line 2084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004346 { // Vector type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004347 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get();
4348 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
4349 error("Unsigned result not equal to signed result");
4350 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4351 error("Elements of a VectorType must be integer or floating point");
4352 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
4353 error("VectorType length should be a power of 2");
4354 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
4355 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4356 (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S));
4357 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004358 ;}
4359 break;
4360
4361 case 134:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004362#line 2097 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004363 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004364 std::vector<const Type*> Elements;
Reid Spencerbb1fd572007-03-21 17:15:50 +00004365 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004366 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
Reid Spencerbb1fd572007-03-21 17:15:50 +00004367 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004368 Elements.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004369 (yyval.TypeVal).S.add(I->S);
4370 }
4371 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004372 delete (yyvsp[-1].TypeList);
4373 ;}
4374 break;
4375
4376 case 135:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004377#line 2108 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004378 { // Empty structure type?
4379 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004380 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004381 ;}
4382 break;
4383
4384 case 136:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004385#line 2112 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004386 { // Packed Structure type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004387 (yyval.TypeVal).S.makeComposite();
Reid Spencer950bf602007-01-26 08:19:09 +00004388 std::vector<const Type*> Elements;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004389 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4390 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004391 Elements.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004392 (yyval.TypeVal).S.add(I->S);
Reid Spencered96d1e2007-02-08 09:08:52 +00004393 delete I->PAT;
Reid Spencer52402b02007-01-02 05:45:11 +00004394 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00004395 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
4396 (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004397 delete (yyvsp[-2].TypeList);
4398 ;}
4399 break;
4400
4401 case 137:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004402#line 2125 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004403 { // Empty packed structure type?
4404 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004405 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004406 ;}
4407 break;
4408
4409 case 138:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004410#line 2129 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004411 { // Pointer type?
4412 if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004413 error("Cannot form a pointer to a basic block");
Reid Spencerbb1fd572007-03-21 17:15:50 +00004414 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
4415 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get()),
4416 (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004417 delete (yyvsp[-1].TypeVal).PAT;
4418 ;}
4419 break;
4420
4421 case 139:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004422#line 2143 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004423 {
4424 (yyval.TypeList) = new std::list<PATypeInfo>();
4425 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4426 ;}
4427 break;
4428
4429 case 140:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004430#line 2147 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004431 {
4432 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4433 ;}
4434 break;
4435
4436 case 142:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004437#line 2155 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004438 {
Reid Spencer950bf602007-01-26 08:19:09 +00004439 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004440 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004441 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004442 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4443 ;}
4444 break;
4445
4446 case 143:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004447#line 2161 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004448 {
4449 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencer950bf602007-01-26 08:19:09 +00004450 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004451 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004452 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004453 (yyval.TypeList)->push_back(VoidTI);
4454 ;}
4455 break;
4456
4457 case 144:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004458#line 2168 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004459 {
4460 (yyval.TypeList) = new std::list<PATypeInfo>();
4461 ;}
4462 break;
4463
4464 case 145:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004465#line 2180 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004466 { // Nonempty unsized arr
4467 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004468 if (ATy == 0)
4469 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004470 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004471 const Type *ETy = ATy->getElementType();
4472 int NumElements = ATy->getNumElements();
4473
4474 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004475 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004476 error("Type mismatch: constant sized array initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004477 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004478 itostr(NumElements) + "");
4479
4480 // Verify all elements are correct type!
4481 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004482 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4483 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004484 const Type* ValTy = C->getType();
4485 if (ETy != ValTy)
4486 error("Element #" + utostr(i) + " is not of type '" +
4487 ETy->getDescription() +"' as required!\nIt is of type '"+
4488 ValTy->getDescription() + "'");
4489 Elems.push_back(C);
4490 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004491 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004492 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004493 delete (yyvsp[-3].TypeVal).PAT;
4494 delete (yyvsp[-1].ConstVector);
4495 ;}
4496 break;
4497
4498 case 146:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004499#line 2210 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004500 {
4501 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004502 if (ATy == 0)
4503 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004504 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004505 int NumElements = ATy->getNumElements();
4506 if (NumElements != -1 && NumElements != 0)
4507 error("Type mismatch: constant sized array initialized with 0"
4508 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004509 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004510 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004511 delete (yyvsp[-2].TypeVal).PAT;
4512 ;}
4513 break;
4514
4515 case 147:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004516#line 2223 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004517 {
4518 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004519 if (ATy == 0)
4520 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004521 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004522 int NumElements = ATy->getNumElements();
4523 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4524 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4525 error("String arrays require type i8, not '" + ETy->getDescription() +
4526 "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004527 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4528 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004529 error("Can't build string constant of size " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004530 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004531 itostr(NumElements) + "");
4532 std::vector<Constant*> Vals;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004533 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004534 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004535 free((yyvsp[0].StrVal));
4536 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004537 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004538 delete (yyvsp[-2].TypeVal).PAT;
4539 ;}
4540 break;
4541
4542 case 148:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004543#line 2246 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004544 { // Nonempty unsized arr
4545 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004546 if (PTy == 0)
4547 error("Cannot make packed constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004548 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004549 const Type *ETy = PTy->getElementType();
4550 int NumElements = PTy->getNumElements();
4551 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004552 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004553 error("Type mismatch: constant sized packed initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004554 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004555 itostr(NumElements) + "");
4556 // Verify all elements are correct type!
4557 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004558 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4559 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004560 const Type* ValTy = C->getType();
4561 if (ETy != ValTy)
4562 error("Element #" + utostr(i) + " is not of type '" +
4563 ETy->getDescription() +"' as required!\nIt is of type '"+
4564 ValTy->getDescription() + "'");
4565 Elems.push_back(C);
4566 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004567 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004568 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004569 delete (yyvsp[-3].TypeVal).PAT;
4570 delete (yyvsp[-1].ConstVector);
4571 ;}
4572 break;
4573
4574 case 149:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004575#line 2274 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004576 {
4577 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004578 if (STy == 0)
4579 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004580 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
4581 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004582 error("Illegal number of initializers for structure type");
4583
4584 // Check to ensure that constants are compatible with the type initializer!
4585 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004586 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4587 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004588 if (C->getType() != STy->getElementType(i))
4589 error("Expected type '" + STy->getElementType(i)->getDescription() +
4590 "' for element #" + utostr(i) + " of structure initializer");
4591 Fields.push_back(C);
4592 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004593 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004594 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004595 delete (yyvsp[-3].TypeVal).PAT;
4596 delete (yyvsp[-1].ConstVector);
4597 ;}
4598 break;
4599
4600 case 150:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004601#line 2296 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004602 {
4603 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004604 if (STy == 0)
4605 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004606 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004607 if (STy->getNumContainedTypes() != 0)
4608 error("Illegal number of initializers for structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004609 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004610 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004611 delete (yyvsp[-2].TypeVal).PAT;
4612 ;}
4613 break;
4614
4615 case 151:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004616#line 2307 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004617 {
4618 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004619 if (STy == 0)
4620 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004621 (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'");
4622 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004623 error("Illegal number of initializers for packed structure type");
4624
4625 // Check to ensure that constants are compatible with the type initializer!
4626 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004627 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4628 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004629 if (C->getType() != STy->getElementType(i))
4630 error("Expected type '" + STy->getElementType(i)->getDescription() +
4631 "' for element #" + utostr(i) + " of packed struct initializer");
4632 Fields.push_back(C);
4633 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004634 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004635 (yyval.ConstVal).S.copy((yyvsp[-5].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004636 delete (yyvsp[-5].TypeVal).PAT;
4637 delete (yyvsp[-2].ConstVector);
4638 ;}
4639 break;
4640
4641 case 152:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004642#line 2329 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004643 {
4644 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004645 if (STy == 0)
4646 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004647 (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004648 if (STy->getNumContainedTypes() != 0)
4649 error("Illegal number of initializers for packed structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004650 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004651 (yyval.ConstVal).S.copy((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004652 delete (yyvsp[-4].TypeVal).PAT;
4653 ;}
4654 break;
4655
4656 case 153:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004657#line 2340 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004658 {
4659 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004660 if (PTy == 0)
4661 error("Cannot make null pointer constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004662 (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'");
4663 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004664 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004665 delete (yyvsp[-1].TypeVal).PAT;
4666 ;}
4667 break;
4668
4669 case 154:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004670#line 2349 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004671 {
4672 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004673 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004674 delete (yyvsp[-1].TypeVal).PAT;
4675 ;}
4676 break;
4677
4678 case 155:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004679#line 2354 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004680 {
4681 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004682 if (Ty == 0)
4683 error("Global const reference must be a pointer type, not" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004684 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004685
4686 // ConstExprs can exist in the body of a function, thus creating
4687 // GlobalValues whenever they refer to a variable. Because we are in
4688 // the context of a function, getExistingValue will search the functions
4689 // symbol table instead of the module symbol table for the global symbol,
4690 // which throws things all off. To get around this, we just tell
4691 // getExistingValue that we are at global scope here.
4692 //
4693 Function *SavedCurFn = CurFun.CurrentFunction;
4694 CurFun.CurrentFunction = 0;
Reid Spencerbb1fd572007-03-21 17:15:50 +00004695 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004696 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004697 CurFun.CurrentFunction = SavedCurFn;
4698
4699 // If this is an initializer for a constant pointer, which is referencing a
4700 // (currently) undefined variable, create a stub now that shall be replaced
4701 // in the future with the right type of variable.
4702 //
4703 if (V == 0) {
4704 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4705 const PointerType *PT = cast<PointerType>(Ty);
4706
4707 // First check to see if the forward references value is already created!
4708 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004709 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004710
4711 if (I != CurModule.GlobalRefs.end()) {
4712 V = I->second; // Placeholder already exists, use it...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004713 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004714 } else {
4715 std::string Name;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004716 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004717
4718 // Create the forward referenced global.
4719 GlobalValue *GV;
4720 if (const FunctionType *FTy =
4721 dyn_cast<FunctionType>(PT->getElementType())) {
4722 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4723 CurModule.CurrentModule);
4724 } else {
4725 GV = new GlobalVariable(PT->getElementType(), false,
4726 GlobalValue::ExternalLinkage, 0,
4727 Name, CurModule.CurrentModule);
4728 }
4729
4730 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004731 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004732 V = GV;
4733 }
4734 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004735 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004736 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004737 delete (yyvsp[-1].TypeVal).PAT; // Free the type handle
4738 ;}
4739 break;
4740
4741 case 156:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004742#line 2413 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004743 {
4744 if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004745 error("Mismatched types for constant expression");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004746 (yyval.ConstVal) = (yyvsp[0].ConstVal);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004747 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004748 delete (yyvsp[-1].TypeVal).PAT;
4749 ;}
4750 break;
4751
4752 case 157:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004753#line 2420 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004754 {
4755 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004756 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4757 error("Cannot create a null initialized value of this type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004758 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004759 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004760 delete (yyvsp[-1].TypeVal).PAT;
4761 ;}
4762 break;
4763
4764 case 158:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004765#line 2428 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004766 { // integral constants
4767 const Type *Ty = (yyvsp[-1].PrimType).T;
4768 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004769 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004770 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004771 (yyval.ConstVal).S.makeSigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004772 ;}
4773 break;
4774
4775 case 159:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004776#line 2435 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004777 { // integral constants
4778 const Type *Ty = (yyvsp[-1].PrimType).T;
4779 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004780 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004781 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004782 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004783 ;}
4784 break;
4785
4786 case 160:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004787#line 2442 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004788 { // Boolean constants
4789 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004790 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004791 ;}
4792 break;
4793
4794 case 161:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004795#line 2446 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004796 { // Boolean constants
4797 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004798 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004799 ;}
4800 break;
4801
4802 case 162:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004803#line 2450 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004804 { // Float & Double constants
4805 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004806 error("Floating point constant invalid for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004807 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004808 (yyval.ConstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004809 ;}
4810 break;
4811
4812 case 163:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004813#line 2459 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004814 {
4815 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4816 const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00004817 Signedness SrcSign((yyvsp[-3].ConstVal).S);
4818 Signedness DstSign((yyvsp[-1].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004819 if (!SrcTy->isFirstClassType())
4820 error("cast constant expression from a non-primitive type: '" +
4821 SrcTy->getDescription() + "'");
4822 if (!DstTy->isFirstClassType())
4823 error("cast constant expression to a non-primitive type: '" +
4824 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004825 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004826 (yyval.ConstVal).S.copy(DstSign);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004827 delete (yyvsp[-1].TypeVal).PAT;
4828 ;}
4829 break;
4830
4831 case 164:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004832#line 2474 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004833 {
4834 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004835 if (!isa<PointerType>(Ty))
4836 error("GetElementPtr requires a pointer operand");
4837
4838 std::vector<Value*> VIndices;
4839 std::vector<Constant*> CIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004840 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004841
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004842 delete (yyvsp[-1].ValueList);
4843 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, &CIndices[0], CIndices.size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004844 (yyval.ConstVal).S.copy(getElementSign((yyvsp[-2].ConstVal), CIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004845 ;}
4846 break;
4847
4848 case 165:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004849#line 2487 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004850 {
4851 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4852 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004853 error("Select condition must be bool type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004854 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004855 error("Select operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004856 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004857 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004858 ;}
4859 break;
4860
4861 case 166:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004862#line 2496 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004863 {
4864 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4865 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004866 error("Binary operator types must match");
4867 // First, make sure we're dealing with the right opcode by upgrading from
4868 // obsolete versions.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004869 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004870
4871 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4872 // To retain backward compatibility with these early compilers, we emit a
4873 // cast to the appropriate integer type automatically if we are in the
4874 // broken case. See PR424 for more information.
4875 if (!isa<PointerType>(Ty)) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004876 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004877 } else {
4878 const Type *IntPtrTy = 0;
4879 switch (CurModule.CurrentModule->getPointerSize()) {
4880 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4881 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4882 default: error("invalid pointer binary constant expr");
4883 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004884 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4885 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4886 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4887 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004888 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00004889 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004890 ;}
4891 break;
4892
4893 case 167:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004894#line 2524 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004895 {
4896 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4897 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004898 error("Logical operator types must match");
4899 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00004900 if (!isa<VectorType>(Ty) ||
4901 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004902 error("Logical operator requires integer operands");
4903 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004904 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4905 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004906 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004907 ;}
4908 break;
4909
4910 case 168:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004911#line 2537 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004912 {
4913 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4914 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004915 error("setcc operand types must match");
4916 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004917 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4918 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004919 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004920 ;}
4921 break;
4922
4923 case 169:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004924#line 2546 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004925 {
4926 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004927 error("icmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004928 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004929 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004930 ;}
4931 break;
4932
4933 case 170:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004934#line 2552 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004935 {
4936 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004937 error("fcmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004938 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004939 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004940 ;}
4941 break;
4942
4943 case 171:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004944#line 2558 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004945 {
4946 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4947 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004948 error("Shift count for shift constant must be unsigned byte");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004949 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4950 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004951 error("Shift constant expression requires integer operand");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004952 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4953 (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 +00004954 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004955 ;}
4956 break;
4957
4958 case 172:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004959#line 2569 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004960 {
4961 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004962 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004963 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004964 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004965 ;}
4966 break;
4967
4968 case 173:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004969#line 2575 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004970 {
4971 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004972 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004973 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004974 (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004975 ;}
4976 break;
4977
4978 case 174:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004979#line 2581 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004980 {
4981 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004982 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004983 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004984 (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004985 ;}
4986 break;
4987
4988 case 175:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004989#line 2592 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004990 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
4991 break;
4992
4993 case 176:
Reid Spencerbb1fd572007-03-21 17:15:50 +00004994#line 2593 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004995 {
4996 (yyval.ConstVector) = new std::vector<ConstInfo>();
4997 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
4998 ;}
4999 break;
5000
5001 case 177:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005002#line 2602 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005003 { (yyval.BoolVal) = false; ;}
5004 break;
5005
5006 case 178:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005007#line 2603 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005008 { (yyval.BoolVal) = true; ;}
5009 break;
5010
5011 case 179:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005012#line 2615 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005013 {
5014 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005015 CurModule.ModuleDone();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005016 ;}
5017 break;
5018
5019 case 180:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005020#line 2624 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005021 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
5022 break;
5023
5024 case 181:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005025#line 2625 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005026 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
5027 break;
5028
5029 case 182:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005030#line 2626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005031 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
5032 break;
5033
5034 case 183:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005035#line 2627 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005036 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
5037 break;
5038
5039 case 184:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005040#line 2628 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005041 {
5042 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer950bf602007-01-26 08:19:09 +00005043 // Emit an error if there are any unresolved types left.
5044 if (!CurModule.LateResolveTypes.empty()) {
5045 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5046 if (DID.Type == ValID::NameVal) {
5047 error("Reference to an undefined type: '"+DID.getName() + "'");
5048 } else {
5049 error("Reference to an undefined type: #" + itostr(DID.Num));
5050 }
5051 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005052 ;}
5053 break;
5054
5055 case 185:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005056#line 2644 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005057 {
Reid Spencer950bf602007-01-26 08:19:09 +00005058 // Eagerly resolve types. This is not an optimization, this is a
5059 // requirement that is due to the fact that we could have this:
5060 //
5061 // %list = type { %list * }
5062 // %list = type { %list * } ; repeated type decl
5063 //
5064 // If types are not resolved eagerly, then the two types will not be
5065 // determined to be the same type!
5066 //
Reid Spencerbb1fd572007-03-21 17:15:50 +00005067 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].TypeVal).PAT->get(), (yyvsp[0].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00005068
Reid Spencerbb1fd572007-03-21 17:15:50 +00005069 if (!setTypeName((yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
5070 // If this is a numbered type that is not a redefinition, add it to the
5071 // slot table.
5072 CurModule.Types.push_back((yyvsp[0].TypeVal).PAT->get());
5073 CurModule.TypeSigns.push_back((yyvsp[0].TypeVal).S);
Reid Spencera50d5962006-12-02 04:11:07 +00005074 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005075 delete (yyvsp[0].TypeVal).PAT;
5076 ;}
5077 break;
5078
5079 case 186:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005080#line 2664 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005081 { // Function prototypes can be in const pool
5082 ;}
5083 break;
5084
5085 case 187:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005086#line 2666 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005087 { // Asm blocks can be in the const pool
5088 ;}
5089 break;
5090
5091 case 188:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005092#line 2668 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005093 {
5094 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005095 error("Global value initializer is not a constant");
Reid Spencerbb1fd572007-03-21 17:15:50 +00005096 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 +00005097 ;}
5098 break;
5099
5100 case 189:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005101#line 2672 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005102 {
Reid Spencer950bf602007-01-26 08:19:09 +00005103 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005104 ;}
5105 break;
5106
5107 case 190:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005108#line 2675 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005109 {
5110 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005111 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5112 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005113 delete (yyvsp[0].TypeVal).PAT;
5114 ;}
5115 break;
5116
5117 case 191:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005118#line 2680 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005119 {
Reid Spencer950bf602007-01-26 08:19:09 +00005120 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005121 ;}
5122 break;
5123
5124 case 192:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005125#line 2683 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005126 {
5127 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005128 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (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 193:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005135#line 2688 "/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 194:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005142#line 2691 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005143 {
5144 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005145 CurGV =
Reid Spencerbb1fd572007-03-21 17:15:50 +00005146 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5147 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005148 delete (yyvsp[0].TypeVal).PAT;
5149 ;}
5150 break;
5151
5152 case 195:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005153#line 2697 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005154 {
Reid Spencer950bf602007-01-26 08:19:09 +00005155 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005156 ;}
5157 break;
5158
5159 case 196:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005160#line 2700 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005161 {
5162 ;}
5163 break;
5164
5165 case 197:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005166#line 2702 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005167 {
5168 ;}
5169 break;
5170
5171 case 198:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005172#line 2704 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005173 {
5174 ;}
5175 break;
5176
5177 case 199:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005178#line 2709 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005179 {
Reid Spencer950bf602007-01-26 08:19:09 +00005180 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005181 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
5182 std::string NewAsm((yyvsp[0].StrVal), EndStr);
5183 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005184
5185 if (AsmSoFar.empty())
5186 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5187 else
5188 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005189 ;}
5190 break;
5191
5192 case 200:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005193#line 2723 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005194 { (yyval.Endianness) = Module::BigEndian; ;}
5195 break;
5196
5197 case 201:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005198#line 2724 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005199 { (yyval.Endianness) = Module::LittleEndian; ;}
5200 break;
5201
5202 case 202:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005203#line 2728 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005204 {
5205 CurModule.setEndianness((yyvsp[0].Endianness));
5206 ;}
5207 break;
5208
5209 case 203:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005210#line 2731 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005211 {
5212 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00005213 CurModule.setPointerSize(Module::Pointer32);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005214 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00005215 CurModule.setPointerSize(Module::Pointer64);
5216 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005217 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
5218 ;}
5219 break;
Reid Spencer9d6565a2007-02-15 02:26:10 +00005220
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005221 case 204:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005222#line 2739 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005223 {
5224 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
5225 free((yyvsp[0].StrVal));
5226 ;}
5227 break;
5228
5229 case 205:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005230#line 2743 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005231 {
5232 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
5233 free((yyvsp[0].StrVal));
5234 ;}
5235 break;
5236
5237 case 207:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005238#line 2754 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005239 {
5240 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5241 free((yyvsp[0].StrVal));
5242 ;}
5243 break;
5244
5245 case 208:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005246#line 2758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005247 {
5248 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5249 free((yyvsp[0].StrVal));
5250 ;}
5251 break;
5252
5253 case 209:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005254#line 2762 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005255 { ;}
5256 break;
5257
5258 case 213:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005259#line 2775 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005260 { (yyval.StrVal) = 0; ;}
5261 break;
5262
5263 case 214:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005264#line 2779 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005265 {
5266 if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy)
5267 error("void typed arguments are invalid");
5268 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
5269 ;}
5270 break;
5271
5272 case 215:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005273#line 2787 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005274 {
5275 (yyval.ArgList) = (yyvsp[-2].ArgList);
5276 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5277 delete (yyvsp[0].ArgVal);
5278 ;}
5279 break;
5280
5281 case 216:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005282#line 2792 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005283 {
5284 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5285 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5286 delete (yyvsp[0].ArgVal);
5287 ;}
5288 break;
5289
5290 case 217:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005291#line 2800 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005292 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
5293 break;
5294
5295 case 218:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005296#line 2801 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005297 {
5298 (yyval.ArgList) = (yyvsp[-2].ArgList);
5299 PATypeInfo VoidTI;
5300 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005301 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005302 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5303 ;}
5304 break;
5305
5306 case 219:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005307#line 2808 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005308 {
5309 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5310 PATypeInfo VoidTI;
5311 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005312 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005313 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5314 ;}
5315 break;
5316
5317 case 220:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005318#line 2815 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005319 { (yyval.ArgList) = 0; ;}
5320 break;
5321
5322 case 221:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005323#line 2819 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005324 {
5325 UnEscapeLexed((yyvsp[-5].StrVal));
5326 std::string FunctionName((yyvsp[-5].StrVal));
5327 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
5328
5329 const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005330
5331 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5332 error("LLVM functions cannot return aggregate types");
5333
Reid Spencerbb1fd572007-03-21 17:15:50 +00005334 Signedness FTySign;
5335 FTySign.makeComposite((yyvsp[-6].TypeVal).S);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005336 std::vector<const Type*> ParamTyList;
Reid Spencer950bf602007-01-26 08:19:09 +00005337
5338 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5339 // i8*. We check here for those names and override the parameter list
5340 // types to ensure the prototype is correct.
5341 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005342 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00005343 } else if (FunctionName == "llvm.va_copy") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005344 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5345 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005346 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005347 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005348 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005349 const Type *Ty = I->first.PAT->get();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005350 ParamTyList.push_back(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005351 FTySign.add(I->first.S);
Reid Spencer950bf602007-01-26 08:19:09 +00005352 }
5353 }
5354
Reid Spenceref9b9a72007-02-05 20:47:22 +00005355 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5356 if (isVarArg)
5357 ParamTyList.pop_back();
Reid Spencer950bf602007-01-26 08:19:09 +00005358
Reid Spencerb7046c72007-01-29 05:41:34 +00005359 // Convert the CSRet calling convention into the corresponding parameter
5360 // attribute.
5361 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005362 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00005363 ParamAttrs.push_back(FunctionType::NoAttributeSet); // result
5364 ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
5365 }
5366
Reid Spenceref9b9a72007-02-05 20:47:22 +00005367 const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
Reid Spencerb7046c72007-01-29 05:41:34 +00005368 ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005369 const PointerType *PFT = PointerType::get(FT);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005370 delete (yyvsp[-6].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005371
5372 ValID ID;
5373 if (!FunctionName.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005374 ID = ValID::create((char*)FunctionName.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00005375 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005376 ID = ValID::create((int)CurModule.Values[PFT].size());
Reid Spencer950bf602007-01-26 08:19:09 +00005377 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005378 ID.S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00005379
5380 Function *Fn = 0;
Reid Spencered96d1e2007-02-08 09:08:52 +00005381 Module* M = CurModule.CurrentModule;
5382
Reid Spencer950bf602007-01-26 08:19:09 +00005383 // See if this function was forward referenced. If so, recycle the object.
5384 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5385 // Move the function to the end of the list, from whereever it was
5386 // previously inserted.
5387 Fn = cast<Function>(FWRef);
Reid Spencered96d1e2007-02-08 09:08:52 +00005388 M->getFunctionList().remove(Fn);
5389 M->getFunctionList().push_back(Fn);
5390 } else if (!FunctionName.empty()) {
5391 GlobalValue *Conflict = M->getFunction(FunctionName);
5392 if (!Conflict)
5393 Conflict = M->getNamedGlobal(FunctionName);
5394 if (Conflict && PFT == Conflict->getType()) {
5395 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5396 // We have two function definitions that conflict, same type, same
5397 // name. We should really check to make sure that this is the result
5398 // of integer type planes collapsing and generate an error if it is
5399 // not, but we'll just rename on the assumption that it is. However,
5400 // let's do it intelligently and rename the internal linkage one
5401 // if there is one.
5402 std::string NewName(makeNameUnique(FunctionName));
5403 if (Conflict->hasInternalLinkage()) {
5404 Conflict->setName(NewName);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005405 RenameMapKey Key =
5406 makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005407 CurModule.RenameMap[Key] = NewName;
5408 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5409 InsertValue(Fn, CurModule.Values);
5410 } else {
5411 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5412 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005413 RenameMapKey Key =
5414 makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005415 CurModule.RenameMap[Key] = NewName;
5416 }
5417 } else {
5418 // If they are not both definitions, then just use the function we
5419 // found since the types are the same.
5420 Fn = cast<Function>(Conflict);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005421
Reid Spencered96d1e2007-02-08 09:08:52 +00005422 // Make sure to strip off any argument names so we can't get
5423 // conflicts.
5424 if (Fn->isDeclaration())
5425 for (Function::arg_iterator AI = Fn->arg_begin(),
5426 AE = Fn->arg_end(); AI != AE; ++AI)
5427 AI->setName("");
5428 }
5429 } else if (Conflict) {
5430 // We have two globals with the same name and different types.
5431 // Previously, this was permitted because the symbol table had
5432 // "type planes" and names only needed to be distinct within a
5433 // type plane. After PR411 was fixed, this is no loner the case.
5434 // To resolve this we must rename one of the two.
5435 if (Conflict->hasInternalLinkage()) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005436 // We can safely rename the Conflict.
5437 RenameMapKey Key =
5438 makeRenameMapKey(Conflict->getName(), Conflict->getType(),
5439 CurModule.NamedValueSigns[Conflict->getName()]);
Reid Spencered96d1e2007-02-08 09:08:52 +00005440 Conflict->setName(makeNameUnique(Conflict->getName()));
Reid Spencered96d1e2007-02-08 09:08:52 +00005441 CurModule.RenameMap[Key] = Conflict->getName();
5442 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5443 InsertValue(Fn, CurModule.Values);
5444 } else if (CurFun.Linkage == GlobalValue::InternalLinkage) {
5445 // We can safely rename the function we're defining
5446 std::string NewName = makeNameUnique(FunctionName);
5447 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5448 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005449 RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005450 CurModule.RenameMap[Key] = NewName;
5451 } else {
5452 // We can't quietly rename either of these things, but we must
5453 // rename one of them. Generate a warning about the renaming and
5454 // elect to rename the thing we're now defining.
5455 std::string NewName = makeNameUnique(FunctionName);
5456 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5457 "' may cause linkage errors");
5458 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5459 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005460 RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005461 CurModule.RenameMap[Key] = NewName;
5462 }
Reid Spenceref9b9a72007-02-05 20:47:22 +00005463 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005464 // There's no conflict, just define the function
5465 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5466 InsertValue(Fn, CurModule.Values);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005467 }
Reid Spencer950bf602007-01-26 08:19:09 +00005468 }
5469
5470 CurFun.FunctionStart(Fn);
5471
5472 if (CurFun.isDeclare) {
5473 // If we have declaration, always overwrite linkage. This will allow us
5474 // to correctly handle cases, when pointer to function is passed as
5475 // argument to another function.
5476 Fn->setLinkage(CurFun.Linkage);
5477 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005478 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5479 Fn->setAlignment((yyvsp[0].UIntVal));
5480 if ((yyvsp[-1].StrVal)) {
5481 Fn->setSection((yyvsp[-1].StrVal));
5482 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005483 }
5484
5485 // Add all of the arguments we parsed to the function...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005486 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005487 if (isVarArg) { // Nuke the last entry
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005488 assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5489 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5490 delete (yyvsp[-3].ArgList)->back().first.PAT;
5491 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005492 }
5493 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005494 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005495 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
5496 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005497 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005498 delete I->first.PAT; // Delete the typeholder...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005499 ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
5500 setValueName(VI, I->second); // Insert arg into symtab...
Reid Spencer950bf602007-01-26 08:19:09 +00005501 InsertValue(ArgIt);
5502 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005503 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005504 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005505 ;}
5506 break;
5507
5508 case 224:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005509#line 3008 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005510 {
5511 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005512
5513 // Make sure that we keep track of the linkage type even if there was a
5514 // previous "declare".
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005515 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
5516 ;}
5517 break;
5518
5519 case 227:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005520#line 3022 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005521 {
5522 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5523 ;}
5524 break;
5525
5526 case 228:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005527#line 3027 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005528 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5529 break;
5530
5531 case 229:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005532#line 3028 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005533 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
5534 break;
5535
5536 case 230:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005537#line 3029 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005538 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
5539 break;
5540
5541 case 231:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005542#line 3033 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005543 { CurFun.isDeclare = true; ;}
5544 break;
5545
5546 case 232:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005547#line 3034 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005548 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5549 break;
5550
5551 case 233:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005552#line 3034 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005553 {
5554 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005555 CurFun.FunctionDone();
5556
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005557 ;}
5558 break;
5559
5560 case 234:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005561#line 3046 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005562 { (yyval.BoolVal) = false; ;}
5563 break;
5564
5565 case 235:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005566#line 3047 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005567 { (yyval.BoolVal) = true; ;}
5568 break;
5569
5570 case 236:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005571#line 3052 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5572 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005573 break;
5574
5575 case 237:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005576#line 3053 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005577 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5578 break;
5579
5580 case 238:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005581#line 3054 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005582 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5583 break;
5584
5585 case 239:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005586#line 3055 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5587 {
5588 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true));
5589 (yyval.ValIDVal).S.makeUnsigned();
5590 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005591 break;
5592
5593 case 240:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005594#line 3059 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5595 {
5596 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false));
5597 (yyval.ValIDVal).S.makeUnsigned();
5598 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005599 break;
5600
5601 case 241:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005602#line 3063 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005603 { (yyval.ValIDVal) = ValID::createNull(); ;}
5604 break;
5605
5606 case 242:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005607#line 3064 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005608 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5609 break;
5610
5611 case 243:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005612#line 3065 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005613 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5614 break;
5615
5616 case 244:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005617#line 3066 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005618 { // Nonempty unsized packed vector
5619 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5620 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005621 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005622 (yyval.ValIDVal).S.makeComposite((*(yyvsp[-1].ConstVector))[0].S);
5623 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S));
Reid Spencer950bf602007-01-26 08:19:09 +00005624
5625 // Verify all elements are correct type!
5626 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005627 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5628 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005629 const Type *CTy = C->getType();
5630 if (ETy != CTy)
5631 error("Element #" + utostr(i) + " is not of type '" +
5632 ETy->getDescription() +"' as required!\nIt is of type '" +
5633 CTy->getDescription() + "'");
5634 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005635 }
Reid Spencer5eb77c72007-03-15 03:26:42 +00005636 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005637 delete PTy; delete (yyvsp[-1].ConstVector);
5638 ;}
5639 break;
5640
5641 case 245:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005642#line 3087 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005643 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005644 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005645 (yyval.ValIDVal).S.copy((yyvsp[0].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005646 ;}
5647 break;
5648
5649 case 246:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005650#line 3091 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005651 {
5652 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5653 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5654 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5655 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5656 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5657 free((yyvsp[-2].StrVal));
5658 free((yyvsp[0].StrVal));
5659 ;}
5660 break;
5661
5662 case 247:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005663#line 3105 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5664 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005665 break;
5666
5667 case 248:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005668#line 3106 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
5669 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005670 break;
5671
5672 case 251:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005673#line 3119 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005674 {
5675 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005676 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer5eb77c72007-03-15 03:26:42 +00005677 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005678 (yyval.ValueVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005679 delete (yyvsp[-1].TypeVal).PAT;
5680 ;}
5681 break;
5682
5683 case 252:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005684#line 3129 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005685 {
5686 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5687 ;}
5688 break;
5689
5690 case 253:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005691#line 3132 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005692 { // Do not allow functions with 0 basic blocks
5693 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5694 ;}
5695 break;
5696
5697 case 254:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005698#line 3141 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005699 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005700 ValueInfo VI; VI.V = (yyvsp[0].TermInstVal).TI; VI.S.copy((yyvsp[0].TermInstVal).S);
5701 setValueName(VI, (yyvsp[-1].StrVal));
5702 InsertValue((yyvsp[0].TermInstVal).TI);
5703 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal).TI);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005704 InsertValue((yyvsp[-2].BasicBlockVal));
5705 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5706 ;}
5707 break;
5708
5709 case 255:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005710#line 3152 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005711 {
5712 if ((yyvsp[0].InstVal).I)
5713 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5714 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5715 ;}
5716 break;
5717
5718 case 256:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005719#line 3157 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005720 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005721 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
Reid Spencer950bf602007-01-26 08:19:09 +00005722 // Make sure to move the basic block to the correct location in the
5723 // function, instead of leaving it inserted wherever it was first
5724 // referenced.
5725 Function::BasicBlockListType &BBL =
5726 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005727 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5728 ;}
5729 break;
5730
5731 case 257:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005732#line 3166 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005733 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005734 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005735 // Make sure to move the basic block to the correct location in the
5736 // function, instead of leaving it inserted wherever it was first
5737 // referenced.
5738 Function::BasicBlockListType &BBL =
5739 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005740 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5741 ;}
5742 break;
5743
5744 case 260:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005745#line 3180 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005746 { // Return with a result...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005747 (yyval.TermInstVal).TI = new ReturnInst((yyvsp[0].ValueVal).V);
5748 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005749 ;}
5750 break;
5751
5752 case 261:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005753#line 3184 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005754 { // Return with no result...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005755 (yyval.TermInstVal).TI = new ReturnInst();
5756 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005757 ;}
5758 break;
5759
5760 case 262:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005761#line 3188 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005762 { // Unconditional Branch...
5763 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005764 (yyval.TermInstVal).TI = new BranchInst(tmpBB);
5765 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005766 ;}
5767 break;
5768
5769 case 263:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005770#line 3193 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005771 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005772 (yyvsp[-3].ValIDVal).S.makeSignless();
5773 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005774 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5775 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005776 (yyvsp[-6].ValIDVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005777 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005778 (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5779 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005780 ;}
5781 break;
5782
5783 case 264:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005784#line 3203 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005785 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005786 (yyvsp[-6].ValIDVal).S.copy((yyvsp[-7].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005787 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005788 (yyvsp[-3].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005789 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5790 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00005791 (yyval.TermInstVal).TI = S;
5792 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005793 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5794 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005795 for (; I != E; ++I) {
5796 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5797 S->addCase(CI, I->second);
5798 else
5799 error("Switch case is constant, but not a simple integer");
5800 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005801 delete (yyvsp[-1].JumpTable);
5802 ;}
5803 break;
5804
5805 case 265:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005806#line 3221 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005807 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005808 (yyvsp[-5].ValIDVal).S.copy((yyvsp[-6].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005809 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005810 (yyvsp[-2].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005811 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005812 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005813 (yyval.TermInstVal).TI = S;
5814 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005815 ;}
5816 break;
5817
5818 case 266:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005819#line 3231 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005820 {
Reid Spencer950bf602007-01-26 08:19:09 +00005821 const PointerType *PFTy;
5822 const FunctionType *Ty;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005823 Signedness FTySign;
Reid Spencer950bf602007-01-26 08:19:09 +00005824
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005825 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005826 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5827 // Pull out the types of all of the arguments...
5828 std::vector<const Type*> ParamTypes;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005829 FTySign.makeComposite((yyvsp[-10].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005830 if ((yyvsp[-7].ValueList)) {
5831 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005832 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005833 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00005834 FTySign.add(I->S);
5835 }
Reid Spencer950bf602007-01-26 08:19:09 +00005836 }
Reid Spencerb7046c72007-01-29 05:41:34 +00005837 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005838 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00005839 ParamAttrs.push_back(FunctionType::NoAttributeSet);
5840 ParamAttrs.push_back(FunctionType::StructRetAttribute);
5841 }
Reid Spencer950bf602007-01-26 08:19:09 +00005842 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5843 if (isVarArg) ParamTypes.pop_back();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005844 Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005845 PFTy = PointerType::get(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005846 (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S);
5847 } else {
5848 FTySign = (yyvsp[-10].TypeVal).S;
5849 (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 +00005850 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005851 (yyvsp[-9].ValIDVal).S.makeComposite(FTySign);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005852 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5853 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5854 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005855
5856 // Create the call node...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005857 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencerbb1fd572007-03-21 17:15:50 +00005858 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0);
Reid Spencer950bf602007-01-26 08:19:09 +00005859 } else { // Has arguments?
5860 // Loop through FunctionType's arguments and ensure they are specified
5861 // correctly!
5862 //
5863 FunctionType::param_iterator I = Ty->param_begin();
5864 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005865 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005866
5867 std::vector<Value*> Args;
5868 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5869 if ((*ArgI).V->getType() != *I)
5870 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5871 (*I)->getDescription() + "'");
5872 Args.push_back((*ArgI).V);
5873 }
5874
5875 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5876 error("Invalid number of parameters detected");
5877
Reid Spencerbb1fd572007-03-21 17:15:50 +00005878 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00005879 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005880 cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005881 delete (yyvsp[-10].TypeVal).PAT;
5882 delete (yyvsp[-7].ValueList);
5883 ;}
5884 break;
5885
5886 case 267:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005887#line 3295 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005888 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005889 (yyval.TermInstVal).TI = new UnwindInst();
5890 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005891 ;}
5892 break;
5893
5894 case 268:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005895#line 3299 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005896 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005897 (yyval.TermInstVal).TI = new UnreachableInst();
5898 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005899 ;}
5900 break;
5901
5902 case 269:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005903#line 3306 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005904 {
5905 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005906 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005907 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005908
5909 if (V == 0)
5910 error("May only switch on a constant pool value");
5911
Reid Spencerbb1fd572007-03-21 17:15:50 +00005912 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005913 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5914 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5915 ;}
5916 break;
5917
5918 case 270:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005919#line 3318 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005920 {
5921 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005922 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005923 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005924
5925 if (V == 0)
5926 error("May only switch on a constant pool value");
5927
Reid Spencerbb1fd572007-03-21 17:15:50 +00005928 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005929 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5930 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5931 ;}
5932 break;
5933
5934 case 271:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005935#line 3333 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005936 {
Reid Spencer950bf602007-01-26 08:19:09 +00005937 bool omit = false;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005938 if ((yyvsp[-1].StrVal))
5939 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005940 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005941 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005942 // This is a useless bit cast causing a name redefinition. It is
5943 // a bit cast from a type to the same type of an operand with the
5944 // same name as the name we would give this instruction. Since this
5945 // instruction results in no code generation, it is safe to omit
5946 // the instruction. This situation can occur because of collapsed
5947 // type planes. For example:
5948 // %X = add int %Y, %Z
5949 // %X = cast int %Y to uint
5950 // After upgrade, this looks like:
5951 // %X = add i32 %Y, %Z
5952 // %X = bitcast i32 to i32
5953 // The bitcast is clearly useless so we omit it.
5954 omit = true;
5955 if (omit) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005956 (yyval.InstVal).I = 0;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005957 (yyval.InstVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00005958 } else {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005959 ValueInfo VI; VI.V = (yyvsp[0].InstVal).I; VI.S.copy((yyvsp[0].InstVal).S);
5960 setValueName(VI, (yyvsp[-1].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005961 InsertValue((yyvsp[0].InstVal).I);
5962 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005963 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005964 ;}
5965 break;
5966
5967 case 272:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005968#line 3363 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005969 { // Used for PHI nodes
5970 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005971 (yyval.PHIList).S.copy((yyvsp[-5].TypeVal).S);
5972 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-5].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005973 Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005974 (yyvsp[-1].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005975 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5976 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5977 delete (yyvsp[-5].TypeVal).PAT;
5978 ;}
5979 break;
5980
5981 case 273:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005982#line 3373 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005983 {
5984 (yyval.PHIList) = (yyvsp[-6].PHIList);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005985 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-6].PHIList).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005986 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005987 (yyvsp[-1].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005988 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
5989 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
5990 ;}
5991 break;
5992
5993 case 274:
Reid Spencerbb1fd572007-03-21 17:15:50 +00005994#line 3383 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005995 { // Used for call statements, and memory insts...
5996 (yyval.ValueList) = new std::vector<ValueInfo>();
5997 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5998 ;}
5999 break;
6000
6001 case 275:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006002#line 3387 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006003 {
6004 (yyval.ValueList) = (yyvsp[-2].ValueList);
6005 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
6006 ;}
6007 break;
6008
6009 case 277:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006010#line 3395 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006011 { (yyval.ValueList) = 0; ;}
6012 break;
6013
6014 case 278:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006015#line 3399 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006016 {
6017 (yyval.BoolVal) = true;
6018 ;}
6019 break;
6020
6021 case 279:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006022#line 3402 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006023 {
6024 (yyval.BoolVal) = false;
6025 ;}
6026 break;
6027
6028 case 280:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006029#line 3408 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006030 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006031 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6032 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006033 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006034 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
Reid Spencer950bf602007-01-26 08:19:09 +00006035 error("Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer9d6565a2007-02-15 02:26:10 +00006036 if (isa<VectorType>(Ty) &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006037 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Chris Lattner4227bdb2007-02-19 07:34:02 +00006038 error("Remainder not supported on vector types");
Reid Spencer950bf602007-01-26 08:19:09 +00006039 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006040 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
6041 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6042 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
6043 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
6044 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006045 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006046 (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006047 delete (yyvsp[-3].TypeVal).PAT;
6048 ;}
6049 break;
6050
6051 case 281:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006052#line 3427 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006053 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006054 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6055 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006056 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006057 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00006058 if (!isa<VectorType>(Ty) ||
6059 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006060 error("Logical operator requires integral operands");
6061 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006062 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
6063 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6064 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6065 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
6066 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006067 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006068 (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006069 delete (yyvsp[-3].TypeVal).PAT;
6070 ;}
6071 break;
6072
6073 case 282:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006074#line 3445 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006075 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006076 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6077 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006078 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006079 if(isa<VectorType>(Ty))
6080 error("VectorTypes currently not supported in setcc instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006081 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006082 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
6083 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6084 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6085 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
6086 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006087 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006088 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006089 delete (yyvsp[-3].TypeVal).PAT;
6090 ;}
6091 break;
6092
6093 case 283:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006094#line 3461 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006095 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006096 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6097 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006098 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006099 if (isa<VectorType>(Ty))
6100 error("VectorTypes currently not supported in icmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006101 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
6102 error("icmp requires integer or pointer typed operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006103 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6104 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6105 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006106 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006107 delete (yyvsp[-3].TypeVal).PAT;
6108 ;}
6109 break;
6110
6111 case 284:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006112#line 3475 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006113 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006114 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6115 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006116 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006117 if (isa<VectorType>(Ty))
6118 error("VectorTypes currently not supported in fcmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006119 else if (!Ty->isFloatingPoint())
6120 error("fcmp instruction requires floating point operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006121 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6122 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6123 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006124 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006125 delete (yyvsp[-3].TypeVal).PAT;
6126 ;}
6127 break;
6128
6129 case 285:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006130#line 3489 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006131 {
Reid Spencer950bf602007-01-26 08:19:09 +00006132 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006133 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006134 Value *Ones = ConstantInt::getAllOnesValue(Ty);
6135 if (Ones == 0)
6136 error("Expected integral type for not instruction");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006137 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
6138 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006139 error("Could not create a xor instruction");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006140 (yyval.InstVal).S.copy((yyvsp[0].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006141 ;}
6142 break;
6143
6144 case 286:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006145#line 3500 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006146 {
6147 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
6148 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00006149 error("Shift amount must be int8");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006150 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
Reid Spencer832254e2007-02-02 02:16:23 +00006151 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006152 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00006153 Value* ShiftAmt = 0;
6154 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006155 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
Reid Spencer832254e2007-02-02 02:16:23 +00006156 ShiftAmt = ConstantExpr::getZExt(C, Ty);
6157 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006158 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
Reid Spencer832254e2007-02-02 02:16:23 +00006159 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006160 ShiftAmt = (yyvsp[0].ValueVal).V;
6161 (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 +00006162 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006163 ;}
6164 break;
6165
6166 case 287:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006167#line 3518 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006168 {
6169 const Type *DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006170 if (!DstTy->isFirstClassType())
6171 error("cast instruction to a non-primitive type: '" +
6172 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006173 (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 +00006174 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006175 delete (yyvsp[0].TypeVal).PAT;
6176 ;}
6177 break;
6178
6179 case 288:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006180#line 3527 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006181 {
6182 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
6183 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00006184 error("select condition must be bool");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006185 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00006186 error("select value types should match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006187 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006188 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006189 ;}
6190 break;
6191
6192 case 289:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006193#line 3536 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006194 {
6195 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006196 NewVarArgs = true;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006197 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006198 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006199 delete (yyvsp[0].TypeVal).PAT;
6200 ;}
6201 break;
6202
6203 case 290:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006204#line 3543 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006205 {
6206 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
6207 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006208 ObsoleteVarArgs = true;
6209 Function* NF = cast<Function>(CurModule.CurrentModule->
6210 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6211
6212 //b = vaarg a, t ->
6213 //foo = alloca 1 of t
6214 //bar = vacopy a
6215 //store bar -> foo
6216 //b = vaarg foo, t
6217 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
6218 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006219 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006220 CurBB->getInstList().push_back(bar);
6221 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006222 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006223 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006224 delete (yyvsp[0].TypeVal).PAT;
6225 ;}
6226 break;
6227
6228 case 291:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006229#line 3564 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006230 {
6231 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
6232 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006233 ObsoleteVarArgs = true;
6234 Function* NF = cast<Function>(CurModule.CurrentModule->
6235 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6236
6237 //b = vanext a, t ->
6238 //foo = alloca 1 of t
6239 //bar = vacopy a
6240 //store bar -> foo
6241 //tmp = vaarg foo, t
6242 //b = load foo
6243 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
6244 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006245 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006246 CurBB->getInstList().push_back(bar);
6247 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6248 Instruction* tmp = new VAArgInst(foo, DstTy);
6249 CurBB->getInstList().push_back(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006250 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006251 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006252 delete (yyvsp[0].TypeVal).PAT;
6253 ;}
6254 break;
6255
6256 case 292:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006257#line 3588 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006258 {
6259 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006260 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006261 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006262 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006263 ;}
6264 break;
6265
6266 case 293:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006267#line 3594 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006268 {
6269 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006270 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006271 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006272 (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006273 ;}
6274 break;
6275
6276 case 294:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006277#line 3600 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006278 {
6279 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006280 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006281 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006282 (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006283 ;}
6284 break;
6285
6286 case 295:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006287#line 3606 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006288 {
6289 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006290 if (!Ty->isFirstClassType())
6291 error("PHI node operands must be of first class type");
6292 PHINode *PHI = new PHINode(Ty);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006293 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
6294 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
6295 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00006296 error("All elements of a PHI node must be of the same type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006297 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
6298 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00006299 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006300 (yyval.InstVal).I = PHI;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006301 (yyval.InstVal).S.copy((yyvsp[0].PHIList).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006302 delete (yyvsp[0].PHIList).P; // Free the list...
6303 ;}
6304 break;
Reid Spencer950bf602007-01-26 08:19:09 +00006305
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006306 case 296:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006307#line 3622 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006308 {
Reid Spencer950bf602007-01-26 08:19:09 +00006309 // Handle the short call syntax
6310 const PointerType *PFTy;
6311 const FunctionType *FTy;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006312 Signedness FTySign;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006313 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006314 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6315 // Pull out the types of all of the arguments...
6316 std::vector<const Type*> ParamTypes;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006317 FTySign.makeComposite((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006318 if ((yyvsp[-1].ValueList)) {
6319 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006320 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00006321 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006322 FTySign.add(I->S);
6323 }
Reid Spencer950bf602007-01-26 08:19:09 +00006324 }
6325
Reid Spencerb7046c72007-01-29 05:41:34 +00006326 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006327 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
Reid Spencerb7046c72007-01-29 05:41:34 +00006328 ParamAttrs.push_back(FunctionType::NoAttributeSet);
6329 ParamAttrs.push_back(FunctionType::StructRetAttribute);
6330 }
Reid Spencer950bf602007-01-26 08:19:09 +00006331 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6332 if (isVarArg) ParamTypes.pop_back();
6333
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006334 const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006335 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6336 error("Functions cannot return aggregate types");
6337
Reid Spencerb7046c72007-01-29 05:41:34 +00006338 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00006339 PFTy = PointerType::get(FTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006340 (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S);
6341 } else {
6342 FTySign = (yyvsp[-4].TypeVal).S;
6343 (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 +00006344 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00006345 (yyvsp[-3].ValIDVal).S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00006346
6347 // First upgrade any intrinsic calls.
6348 std::vector<Value*> Args;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006349 if ((yyvsp[-1].ValueList))
6350 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
6351 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
6352 Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006353
6354 // If we got an upgraded intrinsic
6355 if (Inst) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006356 (yyval.InstVal).I = Inst;
Reid Spencer950bf602007-01-26 08:19:09 +00006357 } else {
6358 // Get the function we're calling
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006359 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006360
6361 // Check the argument values match
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006362 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006363 // Make sure no arguments is a good thing!
6364 if (FTy->getNumParams() != 0)
6365 error("No arguments passed to a function that expects arguments");
6366 } else { // Has arguments?
6367 // Loop through FunctionType's arguments and ensure they are specified
6368 // correctly!
6369 //
6370 FunctionType::param_iterator I = FTy->param_begin();
6371 FunctionType::param_iterator E = FTy->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006372 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006373
6374 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6375 if ((*ArgI).V->getType() != *I)
6376 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6377 (*I)->getDescription() + "'");
6378
6379 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6380 error("Invalid number of parameters detected");
6381 }
6382
6383 // Create the call instruction
Chris Lattnercf3d0612007-02-13 06:04:17 +00006384 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006385 CI->setTailCall((yyvsp[-6].BoolVal));
6386 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
6387 (yyval.InstVal).I = CI;
Reid Spencer950bf602007-01-26 08:19:09 +00006388 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006389 delete (yyvsp[-4].TypeVal).PAT;
6390 delete (yyvsp[-1].ValueList);
6391 ;}
6392 break;
6393
6394 case 297:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006395#line 3706 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006396 {
6397 (yyval.InstVal) = (yyvsp[0].InstVal);
6398 ;}
6399 break;
6400
6401 case 298:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006402#line 3714 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006403 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
6404 break;
6405
6406 case 299:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006407#line 3715 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006408 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6409 break;
6410
6411 case 300:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006412#line 3719 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006413 { (yyval.BoolVal) = true; ;}
6414 break;
6415
6416 case 301:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006417#line 3720 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006418 { (yyval.BoolVal) = false; ;}
6419 break;
6420
6421 case 302:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006422#line 3724 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006423 {
6424 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006425 (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006426 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6427 delete (yyvsp[-1].TypeVal).PAT;
6428 ;}
6429 break;
6430
6431 case 303:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006432#line 3730 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006433 {
6434 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006435 (yyvsp[-1].ValIDVal).S.makeUnsigned();
6436 (yyval.InstVal).S.makeComposite((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006437 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6438 delete (yyvsp[-4].TypeVal).PAT;
6439 ;}
6440 break;
6441
6442 case 304:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006443#line 3737 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006444 {
6445 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006446 (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006447 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6448 delete (yyvsp[-1].TypeVal).PAT;
6449 ;}
6450 break;
6451
6452 case 305:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006453#line 3743 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006454 {
6455 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006456 (yyvsp[-1].ValIDVal).S.makeUnsigned();
6457 (yyval.InstVal).S.makeComposite((yyvsp[-2].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006458 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6459 delete (yyvsp[-4].TypeVal).PAT;
6460 ;}
6461 break;
6462
6463 case 306:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006464#line 3750 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006465 {
6466 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006467 if (!isa<PointerType>(PTy))
6468 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006469 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006470 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006471 ;}
6472 break;
6473
6474 case 307:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006475#line 3757 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006476 {
6477 const Type* Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006478 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00006479 if (!isa<PointerType>(Ty))
6480 error("Can't load from nonpointer type: " + Ty->getDescription());
6481 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6482 error("Can't load from pointer of non-first-class type: " +
6483 Ty->getDescription());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006484 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6485 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006486 (yyval.InstVal).S.copy((yyvsp[-1].TypeVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006487 delete (yyvsp[-1].TypeVal).PAT;
6488 ;}
6489 break;
6490
6491 case 308:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006492#line 3770 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006493 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006494 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006495 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencered96d1e2007-02-08 09:08:52 +00006496 if (!PTy)
6497 error("Can't store to a nonpointer type: " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006498 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencered96d1e2007-02-08 09:08:52 +00006499 const Type *ElTy = PTy->getElementType();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006500 Value *StoreVal = (yyvsp[-3].ValueVal).V;
6501 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6502 if (ElTy != (yyvsp[-3].ValueVal).V->getType()) {
6503 StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy);
Reid Spencered96d1e2007-02-08 09:08:52 +00006504 if (!StoreVal)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006505 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencered96d1e2007-02-08 09:08:52 +00006506 "' into space of type '" + ElTy->getDescription() + "'");
6507 else {
6508 PTy = PointerType::get(StoreVal->getType());
6509 if (Constant *C = dyn_cast<Constant>(tmpVal))
6510 tmpVal = ConstantExpr::getBitCast(C, PTy);
6511 else
6512 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6513 }
6514 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006515 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006516 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006517 delete (yyvsp[-1].TypeVal).PAT;
6518 ;}
6519 break;
6520
6521 case 309:
Reid Spencerbb1fd572007-03-21 17:15:50 +00006522#line 3796 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006523 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006524 (yyvsp[-1].ValIDVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006525 const Type* Ty = (yyvsp[-2].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006526 if (!isa<PointerType>(Ty))
6527 error("getelementptr insn requires pointer operand");
6528
6529 std::vector<Value*> VIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006530 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006531
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006532 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
6533 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006534 ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[-2].TypeVal).S);
6535 (yyval.InstVal).S.copy(getElementSign(VI, VIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006536 delete (yyvsp[-2].TypeVal).PAT;
6537 delete (yyvsp[0].ValueList);
6538 ;}
6539 break;
6540
6541
6542 default: break;
6543 }
6544
6545/* Line 1126 of yacc.c. */
Reid Spencerbb1fd572007-03-21 17:15:50 +00006546#line 6547 "UpgradeParser.tab.c"
Chris Lattnercf3d0612007-02-13 06:04:17 +00006547
6548 yyvsp -= yylen;
6549 yyssp -= yylen;
Reid Spencerb7046c72007-01-29 05:41:34 +00006550
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006551
6552 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006553
6554 *++yyvsp = yyval;
6555
6556
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006557 /* Now `shift' the result of the reduction. Determine what state
6558 that goes to, based on the state we popped back to and the rule
6559 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006560
6561 yyn = yyr1[yyn];
6562
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006563 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6564 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006565 yystate = yytable[yystate];
6566 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006567 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006568
6569 goto yynewstate;
6570
6571
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006572/*------------------------------------.
6573| yyerrlab -- here on detecting error |
6574`------------------------------------*/
6575yyerrlab:
6576 /* If not already recovering from an error, report this error. */
6577 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006578 {
6579 ++yynerrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006580#if YYERROR_VERBOSE
Chris Lattnercf3d0612007-02-13 06:04:17 +00006581 yyn = yypact[yystate];
6582
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006583 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006584 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006585 int yytype = YYTRANSLATE (yychar);
6586 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6587 YYSIZE_T yysize = yysize0;
6588 YYSIZE_T yysize1;
6589 int yysize_overflow = 0;
6590 char *yymsg = 0;
6591# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6592 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6593 int yyx;
Chris Lattnercf3d0612007-02-13 06:04:17 +00006594
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006595#if 0
6596 /* This is so xgettext sees the translatable formats that are
6597 constructed on the fly. */
6598 YY_("syntax error, unexpected %s");
6599 YY_("syntax error, unexpected %s, expecting %s");
6600 YY_("syntax error, unexpected %s, expecting %s or %s");
6601 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6602 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6603#endif
6604 char *yyfmt;
6605 char const *yyf;
6606 static char const yyunexpected[] = "syntax error, unexpected %s";
6607 static char const yyexpecting[] = ", expecting %s";
6608 static char const yyor[] = " or %s";
6609 char yyformat[sizeof yyunexpected
6610 + sizeof yyexpecting - 1
6611 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6612 * (sizeof yyor - 1))];
6613 char const *yyprefix = yyexpecting;
6614
6615 /* Start YYX at -YYN if negative to avoid negative indexes in
6616 YYCHECK. */
6617 int yyxbegin = yyn < 0 ? -yyn : 0;
6618
6619 /* Stay within bounds of both yycheck and yytname. */
6620 int yychecklim = YYLAST - yyn;
6621 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6622 int yycount = 1;
6623
6624 yyarg[0] = yytname[yytype];
6625 yyfmt = yystpcpy (yyformat, yyunexpected);
6626
6627 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6628 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6629 {
6630 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6631 {
6632 yycount = 1;
6633 yysize = yysize0;
6634 yyformat[sizeof yyunexpected - 1] = '\0';
6635 break;
6636 }
6637 yyarg[yycount++] = yytname[yyx];
6638 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6639 yysize_overflow |= yysize1 < yysize;
6640 yysize = yysize1;
6641 yyfmt = yystpcpy (yyfmt, yyprefix);
6642 yyprefix = yyor;
6643 }
6644
6645 yyf = YY_(yyformat);
6646 yysize1 = yysize + yystrlen (yyf);
6647 yysize_overflow |= yysize1 < yysize;
6648 yysize = yysize1;
6649
6650 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6651 yymsg = (char *) YYSTACK_ALLOC (yysize);
6652 if (yymsg)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006653 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006654 /* Avoid sprintf, as that infringes on the user's name space.
6655 Don't have undefined behavior even if the translation
6656 produced a string with the wrong number of "%s"s. */
6657 char *yyp = yymsg;
6658 int yyi = 0;
6659 while ((*yyp = *yyf))
Chris Lattnercf3d0612007-02-13 06:04:17 +00006660 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006661 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6662 {
6663 yyp += yytnamerr (yyp, yyarg[yyi++]);
6664 yyf += 2;
6665 }
6666 else
6667 {
6668 yyp++;
6669 yyf++;
6670 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006671 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006672 yyerror (yymsg);
6673 YYSTACK_FREE (yymsg);
Chris Lattnercf3d0612007-02-13 06:04:17 +00006674 }
6675 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006676 {
6677 yyerror (YY_("syntax error"));
6678 goto yyexhaustedlab;
6679 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006680 }
6681 else
6682#endif /* YYERROR_VERBOSE */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006683 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006684 }
Reid Spencer950bf602007-01-26 08:19:09 +00006685
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006686
Reid Spencer950bf602007-01-26 08:19:09 +00006687
6688 if (yyerrstatus == 3)
6689 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006690 /* If just tried and failed to reuse look-ahead token after an
6691 error, discard it. */
Reid Spencer950bf602007-01-26 08:19:09 +00006692
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006693 if (yychar <= YYEOF)
6694 {
6695 /* Return failure if at end of input. */
6696 if (yychar == YYEOF)
6697 YYABORT;
6698 }
6699 else
6700 {
6701 yydestruct ("Error: discarding", yytoken, &yylval);
6702 yychar = YYEMPTY;
6703 }
6704 }
6705
6706 /* Else will try to reuse look-ahead token after shifting the error
6707 token. */
6708 goto yyerrlab1;
6709
6710
6711/*---------------------------------------------------.
6712| yyerrorlab -- error raised explicitly by YYERROR. |
6713`---------------------------------------------------*/
6714yyerrorlab:
6715
6716 /* Pacify compilers like GCC when the user code never invokes
6717 YYERROR and the label yyerrorlab therefore never appears in user
6718 code. */
6719 if (0)
6720 goto yyerrorlab;
6721
6722yyvsp -= yylen;
6723 yyssp -= yylen;
6724 yystate = *yyssp;
6725 goto yyerrlab1;
6726
6727
6728/*-------------------------------------------------------------.
6729| yyerrlab1 -- common code for both syntax error and YYERROR. |
6730`-------------------------------------------------------------*/
6731yyerrlab1:
6732 yyerrstatus = 3; /* Each real token shifted decrements this. */
6733
6734 for (;;)
6735 {
6736 yyn = yypact[yystate];
6737 if (yyn != YYPACT_NINF)
6738 {
6739 yyn += YYTERROR;
6740 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6741 {
6742 yyn = yytable[yyn];
6743 if (0 < yyn)
6744 break;
6745 }
6746 }
6747
6748 /* Pop the current state because it cannot handle the error token. */
6749 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006750 YYABORT;
6751
6752
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006753 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6754 YYPOPSTACK;
6755 yystate = *yyssp;
6756 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006757 }
6758
6759 if (yyn == YYFINAL)
6760 YYACCEPT;
6761
6762 *++yyvsp = yylval;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006763
6764
6765 /* Shift the error token. */
6766 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer950bf602007-01-26 08:19:09 +00006767
Reid Spencere7c3c602006-11-30 06:36:44 +00006768 yystate = yyn;
6769 goto yynewstate;
6770
Chris Lattner4227bdb2007-02-19 07:34:02 +00006771
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006772/*-------------------------------------.
6773| yyacceptlab -- YYACCEPT comes here. |
6774`-------------------------------------*/
6775yyacceptlab:
6776 yyresult = 0;
6777 goto yyreturn;
6778
6779/*-----------------------------------.
6780| yyabortlab -- YYABORT comes here. |
6781`-----------------------------------*/
6782yyabortlab:
6783 yyresult = 1;
6784 goto yyreturn;
6785
6786#ifndef yyoverflow
6787/*-------------------------------------------------.
6788| yyexhaustedlab -- memory exhaustion comes here. |
6789`-------------------------------------------------*/
6790yyexhaustedlab:
6791 yyerror (YY_("memory exhausted"));
6792 yyresult = 2;
6793 /* Fall through. */
Chris Lattner4227bdb2007-02-19 07:34:02 +00006794#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006795
6796yyreturn:
6797 if (yychar != YYEOF && yychar != YYEMPTY)
6798 yydestruct ("Cleanup: discarding lookahead",
6799 yytoken, &yylval);
6800 while (yyssp != yyss)
6801 {
6802 yydestruct ("Cleanup: popping",
6803 yystos[*yyssp], yyvsp);
6804 YYPOPSTACK;
Chris Lattner4227bdb2007-02-19 07:34:02 +00006805 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006806#ifndef yyoverflow
6807 if (yyss != yyssa)
6808 YYSTACK_FREE (yyss);
6809#endif
6810 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006811}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006812
6813
Reid Spencerbb1fd572007-03-21 17:15:50 +00006814#line 3814 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006815
6816
6817int yyerror(const char *ErrorMsg) {
6818 std::string where
6819 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006820 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006821 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6822 if (yychar != YYEMPTY && yychar != 0)
6823 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6824 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006825 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006826 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006827 exit(1);
6828}
Reid Spencer319a7302007-01-05 17:20:02 +00006829
Reid Spencer30d0c582007-01-15 00:26:18 +00006830void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006831 std::string where
6832 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006833 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006834 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6835 if (yychar != YYEMPTY && yychar != 0)
6836 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6837 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006838 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6839}
6840
Reid Spencer950bf602007-01-26 08:19:09 +00006841void error(const std::string& ErrorMsg, int LineNo) {
6842 if (LineNo == -1) LineNo = Upgradelineno;
6843 Upgradelineno = LineNo;
6844 yyerror(ErrorMsg.c_str());
6845}
6846
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006847