blob: dda1bed2f297bc273fb9e535d84fcc6668a19b98 [file] [log] [blame]
Chandler Carruth02202192007-08-04 01:56:21 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Chandler Carruth02202192007-08-04 01:56:21 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00007
Reid Spencer3fae7ba2007-03-14 23:13:06 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
Reid Spencere7c3c602006-11-30 06:36:44 +000012
Reid Spencer3fae7ba2007-03-14 23:13:06 +000013 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
Chandler Carruth02202192007-08-04 01:56:21 +000020 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +000022
Chandler Carruth02202192007-08-04 01:56:21 +000023/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
Reid Spencer3fae7ba2007-03-14 23:13:06 +000032
Chandler Carruth02202192007-08-04 01:56:21 +000033 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +000038
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
Chandler Carruth02202192007-08-04 01:56:21 +000049/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
Reid Spencer3fae7ba2007-03-14 23:13:06 +000052/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
Chandler Carruth02202192007-08-04 01:56:21 +000061/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000062#define yyparse Upgradeparse
Reid Spencer3fae7ba2007-03-14 23:13:06 +000063#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000064#define yyerror Upgradeerror
Reid Spencer3fae7ba2007-03-14 23:13:06 +000065#define yylval Upgradelval
66#define yychar Upgradechar
Reid Spencere7c3c602006-11-30 06:36:44 +000067#define yydebug Upgradedebug
68#define yynerrs Upgradenerrs
69
Reid Spencer3fae7ba2007-03-14 23:13:06 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 SINTVAL = 260,
80 UINTVAL = 261,
81 FPVAL = 262,
82 VOID = 263,
83 BOOL = 264,
84 SBYTE = 265,
85 UBYTE = 266,
86 SHORT = 267,
87 USHORT = 268,
88 INT = 269,
89 UINT = 270,
90 LONG = 271,
91 ULONG = 272,
92 FLOAT = 273,
93 DOUBLE = 274,
94 TYPE = 275,
95 LABEL = 276,
96 VAR_ID = 277,
97 LABELSTR = 278,
98 STRINGCONSTANT = 279,
99 IMPLEMENTATION = 280,
100 ZEROINITIALIZER = 281,
101 TRUETOK = 282,
102 FALSETOK = 283,
103 BEGINTOK = 284,
104 ENDTOK = 285,
105 DECLARE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 VOLATILE = 290,
110 TO = 291,
111 DOTDOTDOT = 292,
112 NULL_TOK = 293,
113 UNDEF = 294,
114 CONST = 295,
115 INTERNAL = 296,
116 LINKONCE = 297,
117 WEAK = 298,
118 APPENDING = 299,
119 DLLIMPORT = 300,
120 DLLEXPORT = 301,
121 EXTERN_WEAK = 302,
122 OPAQUE = 303,
123 NOT = 304,
124 EXTERNAL = 305,
125 TARGET = 306,
126 TRIPLE = 307,
127 ENDIAN = 308,
128 POINTERSIZE = 309,
129 LITTLE = 310,
130 BIG = 311,
131 ALIGN = 312,
132 DEPLIBS = 313,
133 CALL = 314,
134 TAIL = 315,
135 ASM_TOK = 316,
136 MODULE = 317,
137 SIDEEFFECT = 318,
138 CC_TOK = 319,
139 CCC_TOK = 320,
140 CSRETCC_TOK = 321,
141 FASTCC_TOK = 322,
142 COLDCC_TOK = 323,
143 X86_STDCALLCC_TOK = 324,
144 X86_FASTCALLCC_TOK = 325,
145 DATALAYOUT = 326,
146 RET = 327,
147 BR = 328,
148 SWITCH = 329,
149 INVOKE = 330,
150 UNREACHABLE = 331,
151 UNWIND = 332,
152 EXCEPT = 333,
153 ADD = 334,
154 SUB = 335,
155 MUL = 336,
156 DIV = 337,
157 UDIV = 338,
158 SDIV = 339,
159 FDIV = 340,
160 REM = 341,
161 UREM = 342,
162 SREM = 343,
163 FREM = 344,
164 AND = 345,
165 OR = 346,
166 XOR = 347,
167 SHL = 348,
168 SHR = 349,
169 ASHR = 350,
170 LSHR = 351,
171 SETLE = 352,
172 SETGE = 353,
173 SETLT = 354,
174 SETGT = 355,
175 SETEQ = 356,
176 SETNE = 357,
177 ICMP = 358,
178 FCMP = 359,
179 MALLOC = 360,
180 ALLOCA = 361,
181 FREE = 362,
182 LOAD = 363,
183 STORE = 364,
184 GETELEMENTPTR = 365,
185 PHI_TOK = 366,
186 SELECT = 367,
187 VAARG = 368,
188 EXTRACTELEMENT = 369,
189 INSERTELEMENT = 370,
190 SHUFFLEVECTOR = 371,
191 VAARG_old = 372,
192 VANEXT_old = 373,
193 EQ = 374,
194 NE = 375,
195 SLT = 376,
196 SGT = 377,
197 SLE = 378,
198 SGE = 379,
199 ULT = 380,
200 UGT = 381,
201 ULE = 382,
202 UGE = 383,
203 OEQ = 384,
204 ONE = 385,
205 OLT = 386,
206 OGT = 387,
207 OLE = 388,
208 OGE = 389,
209 ORD = 390,
210 UNO = 391,
211 UEQ = 392,
212 UNE = 393,
213 CAST = 394,
214 TRUNC = 395,
215 ZEXT = 396,
216 SEXT = 397,
217 FPTRUNC = 398,
218 FPEXT = 399,
219 FPTOUI = 400,
220 FPTOSI = 401,
221 UITOFP = 402,
222 SITOFP = 403,
223 PTRTOINT = 404,
224 INTTOPTR = 405,
225 BITCAST = 406
226 };
227#endif
Chandler Carruth02202192007-08-04 01:56:21 +0000228/* Tokens. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +0000229#define ESINT64VAL 258
230#define EUINT64VAL 259
231#define SINTVAL 260
232#define UINTVAL 261
233#define FPVAL 262
234#define VOID 263
235#define BOOL 264
236#define SBYTE 265
237#define UBYTE 266
238#define SHORT 267
239#define USHORT 268
240#define INT 269
241#define UINT 270
242#define LONG 271
243#define ULONG 272
244#define FLOAT 273
245#define DOUBLE 274
246#define TYPE 275
247#define LABEL 276
248#define VAR_ID 277
249#define LABELSTR 278
250#define STRINGCONSTANT 279
251#define IMPLEMENTATION 280
252#define ZEROINITIALIZER 281
253#define TRUETOK 282
254#define FALSETOK 283
255#define BEGINTOK 284
256#define ENDTOK 285
257#define DECLARE 286
258#define GLOBAL 287
259#define CONSTANT 288
260#define SECTION 289
261#define VOLATILE 290
262#define TO 291
263#define DOTDOTDOT 292
264#define NULL_TOK 293
265#define UNDEF 294
266#define CONST 295
267#define INTERNAL 296
268#define LINKONCE 297
269#define WEAK 298
270#define APPENDING 299
271#define DLLIMPORT 300
272#define DLLEXPORT 301
273#define EXTERN_WEAK 302
274#define OPAQUE 303
275#define NOT 304
276#define EXTERNAL 305
277#define TARGET 306
278#define TRIPLE 307
279#define ENDIAN 308
280#define POINTERSIZE 309
281#define LITTLE 310
282#define BIG 311
283#define ALIGN 312
284#define DEPLIBS 313
285#define CALL 314
286#define TAIL 315
287#define ASM_TOK 316
288#define MODULE 317
289#define SIDEEFFECT 318
290#define CC_TOK 319
291#define CCC_TOK 320
292#define CSRETCC_TOK 321
293#define FASTCC_TOK 322
294#define COLDCC_TOK 323
295#define X86_STDCALLCC_TOK 324
296#define X86_FASTCALLCC_TOK 325
297#define DATALAYOUT 326
298#define RET 327
299#define BR 328
300#define SWITCH 329
301#define INVOKE 330
302#define UNREACHABLE 331
303#define UNWIND 332
304#define EXCEPT 333
305#define ADD 334
306#define SUB 335
307#define MUL 336
308#define DIV 337
309#define UDIV 338
310#define SDIV 339
311#define FDIV 340
312#define REM 341
313#define UREM 342
314#define SREM 343
315#define FREM 344
316#define AND 345
317#define OR 346
318#define XOR 347
319#define SHL 348
320#define SHR 349
321#define ASHR 350
322#define LSHR 351
323#define SETLE 352
324#define SETGE 353
325#define SETLT 354
326#define SETGT 355
327#define SETEQ 356
328#define SETNE 357
329#define ICMP 358
330#define FCMP 359
331#define MALLOC 360
332#define ALLOCA 361
333#define FREE 362
334#define LOAD 363
335#define STORE 364
336#define GETELEMENTPTR 365
337#define PHI_TOK 366
338#define SELECT 367
339#define VAARG 368
340#define EXTRACTELEMENT 369
341#define INSERTELEMENT 370
342#define SHUFFLEVECTOR 371
343#define VAARG_old 372
344#define VANEXT_old 373
345#define EQ 374
346#define NE 375
347#define SLT 376
348#define SGT 377
349#define SLE 378
350#define SGE 379
351#define ULT 380
352#define UGT 381
353#define ULE 382
354#define UGE 383
355#define OEQ 384
356#define ONE 385
357#define OLT 386
358#define OGT 387
359#define OLE 388
360#define OGE 389
361#define ORD 390
362#define UNO 391
363#define UEQ 392
364#define UNE 393
365#define CAST 394
366#define TRUNC 395
367#define ZEXT 396
368#define SEXT 397
369#define FPTRUNC 398
370#define FPEXT 399
371#define FPTOUI 400
372#define FPTOSI 401
373#define UITOFP 402
374#define SITOFP 403
375#define PTRTOINT 404
376#define INTTOPTR 405
377#define BITCAST 406
378
379
380
381
382/* Copy the first part of user declarations. */
Chandler Carruth02202192007-08-04 01:56:21 +0000383#line 14 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +0000384
385#include "UpgradeInternals.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000386#include "llvm/CallingConv.h"
387#include "llvm/InlineAsm.h"
388#include "llvm/Instructions.h"
389#include "llvm/Module.h"
Reid Spencer7b5d4662007-04-09 06:16:21 +0000390#include "llvm/ParameterAttributes.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000391#include "llvm/ValueSymbolTable.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000392#include "llvm/Support/GetElementPtrTypeIterator.h"
393#include "llvm/ADT/STLExtras.h"
394#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000395#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000396#include <iostream>
Chris Lattner8adde282007-02-11 21:40:10 +0000397#include <map>
Reid Spencer950bf602007-01-26 08:19:09 +0000398#include <list>
399#include <utility>
400
401// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
402// relating to upreferences in the input stream.
403//
404//#define DEBUG_UPREFS 1
405#ifdef DEBUG_UPREFS
406#define UR_OUT(X) std::cerr << X
407#else
408#define UR_OUT(X)
409#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000410
Reid Spencere77e35e2006-12-01 20:26:20 +0000411#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000412#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000413#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000414
Reid Spencer950bf602007-01-26 08:19:09 +0000415int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000416int yyparse();
417
Reid Spencer950bf602007-01-26 08:19:09 +0000418int yyerror(const char*);
419static void warning(const std::string& WarningMsg);
420
421namespace llvm {
422
Reid Spencer950bf602007-01-26 08:19:09 +0000423std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000424static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000425
Reid Spencer71d2ec92006-12-31 06:02:26 +0000426// This bool controls whether attributes are ever added to function declarations
427// definitions and calls.
428static bool AddAttributes = false;
429
Reid Spencer950bf602007-01-26 08:19:09 +0000430static Module *ParserResult;
431static bool ObsoleteVarArgs;
432static bool NewVarArgs;
433static BasicBlock *CurBB;
434static GlobalVariable *CurGV;
Reid Spencer7eea8ff2007-05-18 05:48:07 +0000435static unsigned lastCallingConv;
Reid Spencera50d5962006-12-02 04:11:07 +0000436
Reid Spencer950bf602007-01-26 08:19:09 +0000437// This contains info used when building the body of a function. It is
438// destroyed when the function is completed.
439//
440typedef std::vector<Value *> ValueList; // Numbered defs
441
Reid Spencerbb1fd572007-03-21 17:15:50 +0000442typedef std::pair<std::string,TypeInfo> RenameMapKey;
Reid Spencer950bf602007-01-26 08:19:09 +0000443typedef std::map<RenameMapKey,std::string> RenameMapType;
444
445static void
446ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
447 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
448
449static struct PerModuleInfo {
450 Module *CurrentModule;
451 std::map<const Type *, ValueList> Values; // Module level numbered definitions
452 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencerbb1fd572007-03-21 17:15:50 +0000453 std::vector<PATypeHolder> Types;
454 std::vector<Signedness> TypeSigns;
455 std::map<std::string,Signedness> NamedTypeSigns;
456 std::map<std::string,Signedness> NamedValueSigns;
Reid Spencer950bf602007-01-26 08:19:09 +0000457 std::map<ValID, PATypeHolder> LateResolveTypes;
458 static Module::Endianness Endian;
459 static Module::PointerSize PointerSize;
460 RenameMapType RenameMap;
461
462 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
463 /// how they were referenced and on which line of the input they came from so
464 /// that we can resolve them later and print error messages as appropriate.
465 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
466
467 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
468 // references to global values. Global values may be referenced before they
469 // are defined, and if so, the temporary object that they represent is held
470 // here. This is used for forward references of GlobalValues.
471 //
472 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
473 GlobalRefsType;
474 GlobalRefsType GlobalRefs;
475
476 void ModuleDone() {
477 // If we could not resolve some functions at function compilation time
478 // (calls to functions before they are defined), resolve them now... Types
479 // are resolved when the constant pool has been completely parsed.
480 //
481 ResolveDefinitions(LateResolveValues);
482
483 // Check to make sure that all global value forward references have been
484 // resolved!
485 //
486 if (!GlobalRefs.empty()) {
487 std::string UndefinedReferences = "Unresolved global references exist:\n";
488
489 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
490 I != E; ++I) {
491 UndefinedReferences += " " + I->first.first->getDescription() + " " +
492 I->first.second.getName() + "\n";
493 }
494 error(UndefinedReferences);
495 return;
496 }
497
498 if (CurrentModule->getDataLayout().empty()) {
499 std::string dataLayout;
500 if (Endian != Module::AnyEndianness)
501 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
502 if (PointerSize != Module::AnyPointerSize) {
503 if (!dataLayout.empty())
504 dataLayout += "-";
505 dataLayout.append(PointerSize == Module::Pointer64 ?
506 "p:64:64" : "p:32:32");
507 }
508 CurrentModule->setDataLayout(dataLayout);
509 }
510
511 Values.clear(); // Clear out function local definitions
512 Types.clear();
Reid Spencerbb1fd572007-03-21 17:15:50 +0000513 TypeSigns.clear();
514 NamedTypeSigns.clear();
515 NamedValueSigns.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000516 CurrentModule = 0;
517 }
518
519 // GetForwardRefForGlobal - Check to see if there is a forward reference
520 // for this global. If so, remove it from the GlobalRefs map and return it.
521 // If not, just return null.
522 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
523 // Check to see if there is a forward reference to this global variable...
524 // if there is, eliminate it and patch the reference to use the new def'n.
525 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
526 GlobalValue *Ret = 0;
527 if (I != GlobalRefs.end()) {
528 Ret = I->second;
529 GlobalRefs.erase(I);
530 }
531 return Ret;
532 }
533 void setEndianness(Module::Endianness E) { Endian = E; }
534 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
535} CurModule;
536
537Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
538Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
539
540static struct PerFunctionInfo {
541 Function *CurrentFunction; // Pointer to current function being created
542
543 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
544 std::map<const Type*, ValueList> LateResolveValues;
545 bool isDeclare; // Is this function a forward declararation?
546 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
547
548 /// BBForwardRefs - When we see forward references to basic blocks, keep
549 /// track of them here.
550 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
551 std::vector<BasicBlock*> NumberedBlocks;
552 RenameMapType RenameMap;
Reid Spencer950bf602007-01-26 08:19:09 +0000553 unsigned NextBBNum;
554
555 inline PerFunctionInfo() {
556 CurrentFunction = 0;
557 isDeclare = false;
558 Linkage = GlobalValue::ExternalLinkage;
559 }
560
561 inline void FunctionStart(Function *M) {
562 CurrentFunction = M;
563 NextBBNum = 0;
564 }
565
566 void FunctionDone() {
567 NumberedBlocks.clear();
568
569 // Any forward referenced blocks left?
570 if (!BBForwardRefs.empty()) {
571 error("Undefined reference to label " +
572 BBForwardRefs.begin()->first->getName());
573 return;
574 }
575
576 // Resolve all forward references now.
577 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
578
579 Values.clear(); // Clear out function local definitions
580 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000581 CurrentFunction = 0;
582 isDeclare = false;
583 Linkage = GlobalValue::ExternalLinkage;
584 }
585} CurFun; // Info for the current function...
586
587static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
588
Reid Spencerbb1fd572007-03-21 17:15:50 +0000589/// This function is just a utility to make a Key value for the rename map.
590/// The Key is a combination of the name, type, Signedness of the original
591/// value (global/function). This just constructs the key and ensures that
592/// named Signedness values are resolved to the actual Signedness.
593/// @brief Make a key for the RenameMaps
594static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty,
595 const Signedness &Sign) {
596 TypeInfo TI;
597 TI.T = Ty;
598 if (Sign.isNamed())
599 // Don't allow Named Signedness nodes because they won't match. The actual
600 // Signedness must be looked up in the NamedTypeSigns map.
601 TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]);
602 else
603 TI.S.copy(Sign);
604 return std::make_pair(Name, TI);
605}
606
Reid Spencer950bf602007-01-26 08:19:09 +0000607
608//===----------------------------------------------------------------------===//
609// Code to handle definitions of all the types
610//===----------------------------------------------------------------------===//
611
612static int InsertValue(Value *V,
613 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
614 if (V->hasName()) return -1; // Is this a numbered definition?
615
616 // Yes, insert the value into the value table...
617 ValueList &List = ValueTab[V->getType()];
618 List.push_back(V);
619 return List.size()-1;
620}
621
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000622static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000623 switch (D.Type) {
624 case ValID::NumberVal: // Is it a numbered definition?
625 // Module constants occupy the lowest numbered slots...
626 if ((unsigned)D.Num < CurModule.Types.size()) {
627 return CurModule.Types[(unsigned)D.Num];
628 }
629 break;
630 case ValID::NameVal: // Is it a named definition?
631 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
Reid Spencer950bf602007-01-26 08:19:09 +0000632 return N;
633 }
634 break;
635 default:
636 error("Internal parser error: Invalid symbol type reference");
637 return 0;
638 }
639
640 // If we reached here, we referenced either a symbol that we don't know about
641 // or an id number that hasn't been read yet. We may be referencing something
642 // forward, so just create an entry to be resolved later and get to it...
643 //
644 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
645
Reid Spencer950bf602007-01-26 08:19:09 +0000646 if (inFunctionScope()) {
647 if (D.Type == ValID::NameVal) {
648 error("Reference to an undefined type: '" + D.getName() + "'");
649 return 0;
650 } else {
651 error("Reference to an undefined type: #" + itostr(D.Num));
652 return 0;
653 }
654 }
655
656 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
657 if (I != CurModule.LateResolveTypes.end())
658 return I->second;
659
660 Type *Typ = OpaqueType::get();
661 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
662 return Typ;
Reid Spencerbb1fd572007-03-21 17:15:50 +0000663}
664
665/// This is like the getType method except that instead of looking up the type
666/// for a given ID, it looks up that type's sign.
667/// @brief Get the signedness of a referenced type
668static Signedness getTypeSign(const ValID &D) {
669 switch (D.Type) {
670 case ValID::NumberVal: // Is it a numbered definition?
671 // Module constants occupy the lowest numbered slots...
672 if ((unsigned)D.Num < CurModule.TypeSigns.size()) {
673 return CurModule.TypeSigns[(unsigned)D.Num];
674 }
675 break;
676 case ValID::NameVal: { // Is it a named definition?
677 std::map<std::string,Signedness>::const_iterator I =
678 CurModule.NamedTypeSigns.find(D.Name);
679 if (I != CurModule.NamedTypeSigns.end())
680 return I->second;
681 // Perhaps its a named forward .. just cache the name
682 Signedness S;
683 S.makeNamed(D.Name);
684 return S;
685 }
686 default:
687 break;
688 }
689 // If we don't find it, its signless
690 Signedness S;
691 S.makeSignless();
692 return S;
693}
694
695/// This function is analagous to getElementType in LLVM. It provides the same
696/// function except that it looks up the Signedness instead of the type. This is
697/// used when processing GEP instructions that need to extract the type of an
698/// indexed struct/array/ptr member.
699/// @brief Look up an element's sign.
700static Signedness getElementSign(const ValueInfo& VI,
701 const std::vector<Value*> &Indices) {
702 const Type *Ptr = VI.V->getType();
703 assert(isa<PointerType>(Ptr) && "Need pointer type");
704
705 unsigned CurIdx = 0;
706 Signedness S(VI.S);
707 while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
708 if (CurIdx == Indices.size())
709 break;
710
711 Value *Index = Indices[CurIdx++];
712 assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type");
713 Ptr = CT->getTypeAtIndex(Index);
714 if (const Type* Ty = Ptr->getForwardedType())
715 Ptr = Ty;
716 assert(S.isComposite() && "Bad Signedness type");
717 if (isa<StructType>(CT)) {
718 S = S.get(cast<ConstantInt>(Index)->getZExtValue());
719 } else {
720 S = S.get(0UL);
721 }
722 if (S.isNamed())
723 S = CurModule.NamedTypeSigns[S.getName()];
724 }
725 Signedness Result;
726 Result.makeComposite(S);
727 return Result;
728}
729
730/// This function just translates a ConstantInfo into a ValueInfo and calls
731/// getElementSign(ValueInfo,...). Its just a convenience.
732/// @brief ConstantInfo version of getElementSign.
733static Signedness getElementSign(const ConstInfo& CI,
734 const std::vector<Constant*> &Indices) {
735 ValueInfo VI;
736 VI.V = CI.C;
737 VI.S.copy(CI.S);
738 std::vector<Value*> Idx;
739 for (unsigned i = 0; i < Indices.size(); ++i)
740 Idx.push_back(Indices[i]);
741 Signedness result = getElementSign(VI, Idx);
742 VI.destroy();
743 return result;
744}
Reid Spencer950bf602007-01-26 08:19:09 +0000745
Reid Spencered96d1e2007-02-08 09:08:52 +0000746/// This function determines if two function types differ only in their use of
747/// the sret parameter attribute in the first argument. If they are identical
748/// in all other respects, it returns true. Otherwise, it returns false.
Reid Spencerbb1fd572007-03-21 17:15:50 +0000749static bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
750 const FunctionType *F2) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000751 if (F1->getReturnType() != F2->getReturnType() ||
Reid Spencer7b5d4662007-04-09 06:16:21 +0000752 F1->getNumParams() != F2->getNumParams())
Reid Spencered96d1e2007-02-08 09:08:52 +0000753 return false;
Reid Spencer7eea8ff2007-05-18 05:48:07 +0000754 const ParamAttrsList *PAL1 = F1->getParamAttrs();
755 const ParamAttrsList *PAL2 = F2->getParamAttrs();
756 if (PAL1 && !PAL2 || PAL2 && !PAL1)
757 return false;
758 if (PAL1 && PAL2 && ((PAL1->size() != PAL2->size()) ||
759 (PAL1->getParamAttrs(0) != PAL2->getParamAttrs(0))))
Reid Spencer7b5d4662007-04-09 06:16:21 +0000760 return false;
Reid Spencer18da0722007-04-11 02:44:20 +0000761 unsigned SRetMask = ~unsigned(ParamAttr::StructRet);
Reid Spencered96d1e2007-02-08 09:08:52 +0000762 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
Reid Spencer7eea8ff2007-05-18 05:48:07 +0000763 if (F1->getParamType(i) != F2->getParamType(i) || (PAL1 && PAL2 &&
764 (unsigned(PAL1->getParamAttrs(i+1)) & SRetMask !=
765 unsigned(PAL2->getParamAttrs(i+1)) & SRetMask)))
Reid Spencered96d1e2007-02-08 09:08:52 +0000766 return false;
767 }
768 return true;
769}
770
Reid Spencerbb1fd572007-03-21 17:15:50 +0000771/// This function determines if the type of V and Ty differ only by the SRet
772/// parameter attribute. This is a more generalized case of
773/// FuncTysDIfferOnlyBySRet since it doesn't require FunctionType arguments.
774static bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) {
775 if (V->getType() == Ty)
776 return true;
777 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
778 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
779 if (PF1 && PF2) {
780 const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType());
781 const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType());
782 if (FT1 && FT2)
783 return FuncTysDifferOnlyBySRet(FT1, FT2);
784 }
785 return false;
786}
787
Reid Spencered96d1e2007-02-08 09:08:52 +0000788// The upgrade of csretcc to sret param attribute may have caused a function
789// to not be found because the param attribute changed the type of the called
790// function. This helper function, used in getExistingValue, detects that
Reid Spencerbb1fd572007-03-21 17:15:50 +0000791// situation and bitcasts the function to the correct type.
Reid Spencered96d1e2007-02-08 09:08:52 +0000792static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
793 // Handle degenerate cases
794 if (!V)
795 return 0;
796 if (V->getType() == Ty)
797 return V;
798
Reid Spencered96d1e2007-02-08 09:08:52 +0000799 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
800 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
801 if (PF1 && PF2) {
Reid Spencerbb1fd572007-03-21 17:15:50 +0000802 const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType());
803 const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType());
Reid Spencer7b5d4662007-04-09 06:16:21 +0000804 if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) {
805 const ParamAttrsList *PAL2 = FT2->getParamAttrs();
Reid Spencer18da0722007-04-11 02:44:20 +0000806 if (PAL2 && PAL2->paramHasAttr(1, ParamAttr::StructRet))
Reid Spencerbb1fd572007-03-21 17:15:50 +0000807 return V;
Reid Spencered96d1e2007-02-08 09:08:52 +0000808 else if (Constant *C = dyn_cast<Constant>(V))
Reid Spencerbb1fd572007-03-21 17:15:50 +0000809 return ConstantExpr::getBitCast(C, PF1);
Reid Spencered96d1e2007-02-08 09:08:52 +0000810 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000811 return new BitCastInst(V, PF1, "upgrd.cast", CurBB);
Reid Spencer7b5d4662007-04-09 06:16:21 +0000812 }
Reid Spencerbb1fd572007-03-21 17:15:50 +0000813
Reid Spencered96d1e2007-02-08 09:08:52 +0000814 }
Reid Spencerbb1fd572007-03-21 17:15:50 +0000815 return 0;
Reid Spencered96d1e2007-02-08 09:08:52 +0000816}
817
Reid Spencer950bf602007-01-26 08:19:09 +0000818// getExistingValue - Look up the value specified by the provided type and
819// the provided ValID. If the value exists and has already been defined, return
820// it. Otherwise return null.
821//
822static Value *getExistingValue(const Type *Ty, const ValID &D) {
823 if (isa<FunctionType>(Ty)) {
824 error("Functions are not values and must be referenced as pointers");
825 }
826
827 switch (D.Type) {
828 case ValID::NumberVal: { // Is it a numbered definition?
829 unsigned Num = (unsigned)D.Num;
830
831 // Module constants occupy the lowest numbered slots...
832 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
833 if (VI != CurModule.Values.end()) {
834 if (Num < VI->second.size())
835 return VI->second[Num];
836 Num -= VI->second.size();
837 }
838
839 // Make sure that our type is within bounds
840 VI = CurFun.Values.find(Ty);
841 if (VI == CurFun.Values.end()) return 0;
842
843 // Check that the number is within bounds...
844 if (VI->second.size() <= Num) return 0;
845
846 return VI->second[Num];
847 }
848
849 case ValID::NameVal: { // Is it a named definition?
850 // Get the name out of the ID
Reid Spencerbb1fd572007-03-21 17:15:50 +0000851 RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
852 Value *V = 0;
Reid Spencer950bf602007-01-26 08:19:09 +0000853 if (inFunctionScope()) {
854 // See if the name was renamed
855 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
856 std::string LookupName;
857 if (I != CurFun.RenameMap.end())
858 LookupName = I->second;
859 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000860 LookupName = D.Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000861 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
862 V = SymTab.lookup(LookupName);
Reid Spencerbb1fd572007-03-21 17:15:50 +0000863 if (V && V->getType() != Ty)
864 V = handleSRetFuncTypeMerge(V, Ty);
865 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
Reid Spencer950bf602007-01-26 08:19:09 +0000866 }
867 if (!V) {
868 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
869 std::string LookupName;
870 if (I != CurModule.RenameMap.end())
871 LookupName = I->second;
872 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000873 LookupName = D.Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000874 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
Reid Spencerbb1fd572007-03-21 17:15:50 +0000875 if (V && V->getType() != Ty)
876 V = handleSRetFuncTypeMerge(V, Ty);
877 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
Reid Spencer950bf602007-01-26 08:19:09 +0000878 }
Reid Spenceref9b9a72007-02-05 20:47:22 +0000879 if (!V)
Reid Spencer950bf602007-01-26 08:19:09 +0000880 return 0;
881
882 D.destroy(); // Free old strdup'd memory...
883 return V;
884 }
885
886 // Check to make sure that "Ty" is an integral type, and that our
887 // value will fit into the specified type...
888 case ValID::ConstSIntVal: // Is it a constant pool reference??
889 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
890 error("Signed integral constant '" + itostr(D.ConstPool64) +
891 "' is invalid for type '" + Ty->getDescription() + "'");
892 }
893 return ConstantInt::get(Ty, D.ConstPool64);
894
895 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
896 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
897 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
898 error("Integral constant '" + utostr(D.UConstPool64) +
899 "' is invalid or out of range");
900 else // This is really a signed reference. Transmogrify.
901 return ConstantInt::get(Ty, D.ConstPool64);
902 } else
903 return ConstantInt::get(Ty, D.UConstPool64);
904
905 case ValID::ConstFPVal: // Is it a floating point const pool reference?
906 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
907 error("FP constant invalid for type");
908 return ConstantFP::get(Ty, D.ConstPoolFP);
909
910 case ValID::ConstNullVal: // Is it a null value?
911 if (!isa<PointerType>(Ty))
912 error("Cannot create a a non pointer null");
913 return ConstantPointerNull::get(cast<PointerType>(Ty));
914
915 case ValID::ConstUndefVal: // Is it an undef value?
916 return UndefValue::get(Ty);
917
918 case ValID::ConstZeroVal: // Is it a zero value?
919 return Constant::getNullValue(Ty);
920
921 case ValID::ConstantVal: // Fully resolved constant?
922 if (D.ConstantValue->getType() != Ty)
923 error("Constant expression type different from required type");
924 return D.ConstantValue;
925
926 case ValID::InlineAsmVal: { // Inline asm expression
927 const PointerType *PTy = dyn_cast<PointerType>(Ty);
928 const FunctionType *FTy =
929 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
930 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
931 error("Invalid type for asm constraint string");
932 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
933 D.IAD->HasSideEffects);
934 D.destroy(); // Free InlineAsmDescriptor.
935 return IA;
936 }
937 default:
938 assert(0 && "Unhandled case");
939 return 0;
940 } // End of switch
941
942 assert(0 && "Unhandled case");
943 return 0;
944}
945
946// getVal - This function is identical to getExistingValue, except that if a
947// value is not already defined, it "improvises" by creating a placeholder var
948// that looks and acts just like the requested variable. When the value is
949// defined later, all uses of the placeholder variable are replaced with the
950// real thing.
951//
952static Value *getVal(const Type *Ty, const ValID &ID) {
953 if (Ty == Type::LabelTy)
954 error("Cannot use a basic block here");
955
956 // See if the value has already been defined.
957 Value *V = getExistingValue(Ty, ID);
958 if (V) return V;
959
960 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
961 error("Invalid use of a composite type");
962
963 // If we reached here, we referenced either a symbol that we don't know about
964 // or an id number that hasn't been read yet. We may be referencing something
965 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000966 V = new Argument(Ty);
967
968 // Remember where this forward reference came from. FIXME, shouldn't we try
969 // to recycle these things??
970 CurModule.PlaceHolderInfo.insert(
Reid Spenceref9b9a72007-02-05 20:47:22 +0000971 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
Reid Spencer950bf602007-01-26 08:19:09 +0000972
973 if (inFunctionScope())
974 InsertValue(V, CurFun.LateResolveValues);
975 else
976 InsertValue(V, CurModule.LateResolveValues);
977 return V;
978}
979
Reid Spencered96d1e2007-02-08 09:08:52 +0000980/// @brief This just makes any name given to it unique, up to MAX_UINT times.
981static std::string makeNameUnique(const std::string& Name) {
982 static unsigned UniqueNameCounter = 1;
983 std::string Result(Name);
984 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
985 return Result;
986}
987
Reid Spencer950bf602007-01-26 08:19:09 +0000988/// getBBVal - This is used for two purposes:
989/// * If isDefinition is true, a new basic block with the specified ID is being
990/// defined.
991/// * If isDefinition is true, this is a reference to a basic block, which may
992/// or may not be a forward reference.
993///
994static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
995 assert(inFunctionScope() && "Can't get basic block at global scope");
996
997 std::string Name;
998 BasicBlock *BB = 0;
999 switch (ID.Type) {
1000 default:
1001 error("Illegal label reference " + ID.getName());
1002 break;
1003 case ValID::NumberVal: // Is it a numbered definition?
1004 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
1005 CurFun.NumberedBlocks.resize(ID.Num+1);
1006 BB = CurFun.NumberedBlocks[ID.Num];
1007 break;
1008 case ValID::NameVal: // Is it a named definition?
1009 Name = ID.Name;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001010 if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001011 if (N->getType() != Type::LabelTy) {
1012 // Register names didn't use to conflict with basic block names
1013 // because of type planes. Now they all have to be unique. So, we just
1014 // rename the register and treat this name as if no basic block
1015 // had been found.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001016 RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00001017 N->setName(makeNameUnique(N->getName()));
1018 CurModule.RenameMap[Key] = N->getName();
1019 BB = 0;
1020 } else {
1021 BB = cast<BasicBlock>(N);
1022 }
Reid Spencer950bf602007-01-26 08:19:09 +00001023 }
1024 break;
1025 }
1026
1027 // See if the block has already been defined.
1028 if (BB) {
1029 // If this is the definition of the block, make sure the existing value was
1030 // just a forward reference. If it was a forward reference, there will be
1031 // an entry for it in the PlaceHolderInfo map.
1032 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
1033 // The existing value was a definition, not a forward reference.
1034 error("Redefinition of label " + ID.getName());
1035
1036 ID.destroy(); // Free strdup'd memory.
1037 return BB;
1038 }
1039
1040 // Otherwise this block has not been seen before.
1041 BB = new BasicBlock("", CurFun.CurrentFunction);
1042 if (ID.Type == ValID::NameVal) {
1043 BB->setName(ID.Name);
1044 } else {
1045 CurFun.NumberedBlocks[ID.Num] = BB;
1046 }
1047
1048 // If this is not a definition, keep track of it so we can use it as a forward
1049 // reference.
1050 if (!isDefinition) {
1051 // Remember where this forward reference came from.
1052 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
1053 } else {
1054 // The forward declaration could have been inserted anywhere in the
1055 // function: insert it into the correct place now.
1056 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
1057 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
1058 }
1059 ID.destroy();
1060 return BB;
1061}
1062
1063
1064//===----------------------------------------------------------------------===//
1065// Code to handle forward references in instructions
1066//===----------------------------------------------------------------------===//
1067//
1068// This code handles the late binding needed with statements that reference
1069// values not defined yet... for example, a forward branch, or the PHI node for
1070// a loop body.
1071//
1072// This keeps a table (CurFun.LateResolveValues) of all such forward references
1073// and back patchs after we are done.
1074//
1075
1076// ResolveDefinitions - If we could not resolve some defs at parsing
1077// time (forward branches, phi functions for loops, etc...) resolve the
1078// defs now...
1079//
1080static void
1081ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
1082 std::map<const Type*,ValueList> *FutureLateResolvers) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001083
Reid Spencer950bf602007-01-26 08:19:09 +00001084 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1085 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
1086 E = LateResolvers.end(); LRI != E; ++LRI) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001087 const Type* Ty = LRI->first;
Reid Spencer950bf602007-01-26 08:19:09 +00001088 ValueList &List = LRI->second;
1089 while (!List.empty()) {
1090 Value *V = List.back();
1091 List.pop_back();
1092
1093 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1094 CurModule.PlaceHolderInfo.find(V);
1095 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
1096
1097 ValID &DID = PHI->second.first;
1098
Reid Spencered96d1e2007-02-08 09:08:52 +00001099 Value *TheRealValue = getExistingValue(Ty, DID);
Reid Spencer950bf602007-01-26 08:19:09 +00001100 if (TheRealValue) {
1101 V->replaceAllUsesWith(TheRealValue);
1102 delete V;
1103 CurModule.PlaceHolderInfo.erase(PHI);
1104 } else if (FutureLateResolvers) {
1105 // Functions have their unresolved items forwarded to the module late
1106 // resolver table
1107 InsertValue(V, *FutureLateResolvers);
1108 } else {
1109 if (DID.Type == ValID::NameVal) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001110 error("Reference to an invalid definition: '" + DID.getName() +
1111 "' of type '" + V->getType()->getDescription() + "'",
1112 PHI->second.second);
Reid Spencer7de2e012007-01-29 19:08:46 +00001113 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001114 } else {
1115 error("Reference to an invalid definition: #" +
1116 itostr(DID.Num) + " of type '" +
1117 V->getType()->getDescription() + "'", PHI->second.second);
1118 return;
1119 }
1120 }
1121 }
1122 }
1123
1124 LateResolvers.clear();
1125}
1126
Reid Spencerbb1fd572007-03-21 17:15:50 +00001127/// This function is used for type resolution and upref handling. When a type
1128/// becomes concrete, this function is called to adjust the signedness for the
1129/// concrete type.
1130static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
1131 std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
1132 if (!TyName.empty())
1133 CurModule.NamedTypeSigns[TyName] = Sign;
1134}
1135
1136/// ResolveTypeTo - A brand new type was just declared. This means that (if
1137/// name is not null) things referencing Name can be resolved. Otherwise,
1138/// things refering to the number can be resolved. Do this now.
1139static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
Reid Spencer950bf602007-01-26 08:19:09 +00001140 ValID D;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001141 if (Name)
1142 D = ValID::create(Name);
1143 else
1144 D = ValID::create((int)CurModule.Types.size());
1145 D.S.copy(Sign);
1146
Reid Spencerbaba98a2007-04-11 12:10:58 +00001147 if (Name)
1148 CurModule.NamedTypeSigns[Name] = Sign;
Reid Spencer950bf602007-01-26 08:19:09 +00001149
1150 std::map<ValID, PATypeHolder>::iterator I =
1151 CurModule.LateResolveTypes.find(D);
1152 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00001153 const Type *OldTy = I->second.get();
1154 ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
Reid Spencer950bf602007-01-26 08:19:09 +00001155 CurModule.LateResolveTypes.erase(I);
1156 }
1157}
1158
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001159/// This is the implementation portion of TypeHasInteger. It traverses the
1160/// type given, avoiding recursive types, and returns true as soon as it finds
1161/// an integer type. If no integer type is found, it returns false.
1162static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
1163 // Handle some easy cases
1164 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
1165 return false;
1166 if (Ty->isInteger())
1167 return true;
1168 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
1169 return STy->getElementType()->isInteger();
1170
1171 // Avoid type structure recursion
1172 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
1173 I != E; ++I)
1174 if (Ty == *I)
1175 return false;
1176
1177 // Push us on the type stack
1178 Stack.push_back(Ty);
1179
1180 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1181 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1182 return true;
1183 FunctionType::param_iterator I = FTy->param_begin();
1184 FunctionType::param_iterator E = FTy->param_end();
1185 for (; I != E; ++I)
1186 if (TypeHasIntegerI(*I, Stack))
1187 return true;
1188 return false;
1189 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1190 StructType::element_iterator I = STy->element_begin();
1191 StructType::element_iterator E = STy->element_end();
1192 for (; I != E; ++I) {
1193 if (TypeHasIntegerI(*I, Stack))
1194 return true;
1195 }
1196 return false;
1197 }
1198 // There shouldn't be anything else, but its definitely not integer
1199 assert(0 && "What type is this?");
1200 return false;
1201}
1202
1203/// This is the interface to TypeHasIntegerI. It just provides the type stack,
1204/// to avoid recursion, and then calls TypeHasIntegerI.
1205static inline bool TypeHasInteger(const Type *Ty) {
1206 std::vector<const Type*> TyStack;
1207 return TypeHasIntegerI(Ty, TyStack);
1208}
1209
Reid Spencer950bf602007-01-26 08:19:09 +00001210// setValueName - Set the specified value to the name given. The name may be
1211// null potentially, in which case this is a noop. The string passed in is
1212// assumed to be a malloc'd string buffer, and is free'd by this function.
1213//
Reid Spencerbb1fd572007-03-21 17:15:50 +00001214static void setValueName(const ValueInfo &V, char *NameStr) {
Reid Spencer950bf602007-01-26 08:19:09 +00001215 if (NameStr) {
1216 std::string Name(NameStr); // Copy string
1217 free(NameStr); // Free old string
1218
Reid Spencerbb1fd572007-03-21 17:15:50 +00001219 if (V.V->getType() == Type::VoidTy) {
Reid Spencer950bf602007-01-26 08:19:09 +00001220 error("Can't assign name '" + Name + "' to value with void type");
1221 return;
1222 }
1223
Reid Spencer950bf602007-01-26 08:19:09 +00001224 assert(inFunctionScope() && "Must be in function scope");
1225
1226 // Search the function's symbol table for an existing value of this name
Reid Spenceref9b9a72007-02-05 20:47:22 +00001227 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1228 Value* Existing = ST.lookup(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001229 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001230 // An existing value of the same name was found. This might have happened
1231 // because of the integer type planes collapsing in LLVM 2.0.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001232 if (Existing->getType() == V.V->getType() &&
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001233 !TypeHasInteger(Existing->getType())) {
1234 // If the type does not contain any integers in them then this can't be
1235 // a type plane collapsing issue. It truly is a redefinition and we
1236 // should error out as the assembly is invalid.
1237 error("Redefinition of value named '" + Name + "' of type '" +
Reid Spencerbb1fd572007-03-21 17:15:50 +00001238 V.V->getType()->getDescription() + "'");
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001239 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001240 }
1241 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1242 // function, regardless of Type. Previously re-use of names was okay as
1243 // long as they were distinct types. With type planes collapsing because
1244 // of the signedness change and because of PR411, this can no longer be
1245 // supported. We must search the entire symbol table for a conflicting
1246 // name and make the name unique. No warning is needed as this can't
1247 // cause a problem.
1248 std::string NewName = makeNameUnique(Name);
1249 // We're changing the name but it will probably be used by other
1250 // instructions as operands later on. Consequently we have to retain
1251 // a mapping of the renaming that we're doing.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001252 RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
Reid Spencer950bf602007-01-26 08:19:09 +00001253 CurFun.RenameMap[Key] = NewName;
1254 Name = NewName;
1255 }
1256
1257 // Set the name.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001258 V.V->setName(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001259 }
1260}
1261
1262/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1263/// this is a declaration, otherwise it is a definition.
1264static GlobalVariable *
1265ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1266 bool isConstantGlobal, const Type *Ty,
Reid Spencerbb1fd572007-03-21 17:15:50 +00001267 Constant *Initializer,
1268 const Signedness &Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001269 if (isa<FunctionType>(Ty))
1270 error("Cannot declare global vars of function type");
1271
1272 const PointerType *PTy = PointerType::get(Ty);
1273
1274 std::string Name;
1275 if (NameStr) {
1276 Name = NameStr; // Copy string
1277 free(NameStr); // Free old string
1278 }
1279
1280 // See if this global value was forward referenced. If so, recycle the
1281 // object.
1282 ValID ID;
1283 if (!Name.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00001284 ID = ValID::create((char*)Name.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00001285 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00001286 ID = ValID::create((int)CurModule.Values[PTy].size());
Reid Spencer950bf602007-01-26 08:19:09 +00001287 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00001288 ID.S.makeComposite(Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001289
1290 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1291 // Move the global to the end of the list, from whereever it was
1292 // previously inserted.
1293 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1294 CurModule.CurrentModule->getGlobalList().remove(GV);
1295 CurModule.CurrentModule->getGlobalList().push_back(GV);
1296 GV->setInitializer(Initializer);
1297 GV->setLinkage(Linkage);
1298 GV->setConstant(isConstantGlobal);
1299 InsertValue(GV, CurModule.Values);
1300 return GV;
1301 }
1302
1303 // If this global has a name, check to see if there is already a definition
1304 // of this global in the module and emit warnings if there are conflicts.
1305 if (!Name.empty()) {
1306 // The global has a name. See if there's an existing one of the same name.
Reid Spencere59f4932007-04-16 03:05:01 +00001307 if (CurModule.CurrentModule->getNamedGlobal(Name) ||
1308 CurModule.CurrentModule->getFunction(Name)) {
1309 // We found an existing global of the same name. This isn't allowed
Reid Spencer950bf602007-01-26 08:19:09 +00001310 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1311 // can at least compile. This can happen because of type planes
1312 // There is alread a global of the same name which means there is a
1313 // conflict. Let's see what we can do about it.
1314 std::string NewName(makeNameUnique(Name));
Reid Spencerbb1fd572007-03-21 17:15:50 +00001315 if (Linkage != GlobalValue::InternalLinkage) {
Reid Spencer950bf602007-01-26 08:19:09 +00001316 // The linkage of this gval is external so we can't reliably rename
1317 // it because it could potentially create a linking problem.
1318 // However, we can't leave the name conflict in the output either or
1319 // it won't assemble with LLVM 2.0. So, all we can do is rename
1320 // this one to something unique and emit a warning about the problem.
1321 warning("Renaming global variable '" + Name + "' to '" + NewName +
1322 "' may cause linkage errors");
1323 }
1324
1325 // Put the renaming in the global rename map
Reid Spencerbb1fd572007-03-21 17:15:50 +00001326 RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
Reid Spencer950bf602007-01-26 08:19:09 +00001327 CurModule.RenameMap[Key] = NewName;
1328
1329 // Rename it
1330 Name = NewName;
1331 }
1332 }
1333
1334 // Otherwise there is no existing GV to use, create one now.
1335 GlobalVariable *GV =
1336 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1337 CurModule.CurrentModule);
1338 InsertValue(GV, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00001339 // Remember the sign of this global.
1340 CurModule.NamedValueSigns[Name] = ID.S;
Reid Spencer950bf602007-01-26 08:19:09 +00001341 return GV;
1342}
1343
1344// setTypeName - Set the specified type to the name given. The name may be
1345// null potentially, in which case this is a noop. The string passed in is
1346// assumed to be a malloc'd string buffer, and is freed by this function.
1347//
1348// This function returns true if the type has already been defined, but is
1349// allowed to be redefined in the specified context. If the name is a new name
1350// for the type plane, it is inserted and false is returned.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001351static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
Reid Spencer950bf602007-01-26 08:19:09 +00001352 assert(!inFunctionScope() && "Can't give types function-local names");
1353 if (NameStr == 0) return false;
1354
1355 std::string Name(NameStr); // Copy string
1356 free(NameStr); // Free old string
1357
Reid Spencerbb1fd572007-03-21 17:15:50 +00001358 const Type* Ty = TI.PAT->get();
1359
Reid Spencer950bf602007-01-26 08:19:09 +00001360 // We don't allow assigning names to void type
Reid Spencerbb1fd572007-03-21 17:15:50 +00001361 if (Ty == Type::VoidTy) {
Reid Spencer950bf602007-01-26 08:19:09 +00001362 error("Can't assign name '" + Name + "' to the void type");
1363 return false;
1364 }
1365
1366 // Set the type name, checking for conflicts as we do so.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001367 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
1368
1369 // Save the sign information for later use
1370 CurModule.NamedTypeSigns[Name] = TI.S;
Reid Spencer950bf602007-01-26 08:19:09 +00001371
1372 if (AlreadyExists) { // Inserting a name that is already defined???
1373 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1374 assert(Existing && "Conflict but no matching type?");
1375
1376 // There is only one case where this is allowed: when we are refining an
1377 // opaque type. In this case, Existing will be an opaque type.
1378 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1379 // We ARE replacing an opaque type!
Reid Spencerbb1fd572007-03-21 17:15:50 +00001380 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00001381 return true;
1382 }
1383
1384 // Otherwise, this is an attempt to redefine a type. That's okay if
1385 // the redefinition is identical to the original. This will be so if
1386 // Existing and T point to the same Type object. In this one case we
1387 // allow the equivalent redefinition.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001388 if (Existing == Ty) return true; // Yes, it's equal.
Reid Spencer950bf602007-01-26 08:19:09 +00001389
1390 // Any other kind of (non-equivalent) redefinition is an error.
1391 error("Redefinition of type named '" + Name + "' in the '" +
Reid Spencerbb1fd572007-03-21 17:15:50 +00001392 Ty->getDescription() + "' type plane");
Reid Spencer950bf602007-01-26 08:19:09 +00001393 }
1394
1395 return false;
1396}
1397
1398//===----------------------------------------------------------------------===//
1399// Code for handling upreferences in type names...
1400//
1401
1402// TypeContains - Returns true if Ty directly contains E in it.
1403//
1404static bool TypeContains(const Type *Ty, const Type *E) {
1405 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1406 E) != Ty->subtype_end();
1407}
1408
1409namespace {
1410 struct UpRefRecord {
1411 // NestingLevel - The number of nesting levels that need to be popped before
1412 // this type is resolved.
1413 unsigned NestingLevel;
1414
1415 // LastContainedTy - This is the type at the current binding level for the
1416 // type. Every time we reduce the nesting level, this gets updated.
1417 const Type *LastContainedTy;
1418
1419 // UpRefTy - This is the actual opaque type that the upreference is
1420 // represented with.
1421 OpaqueType *UpRefTy;
1422
1423 UpRefRecord(unsigned NL, OpaqueType *URTy)
Reid Spencerbb1fd572007-03-21 17:15:50 +00001424 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
Reid Spencer950bf602007-01-26 08:19:09 +00001425 };
1426}
1427
1428// UpRefs - A list of the outstanding upreferences that need to be resolved.
1429static std::vector<UpRefRecord> UpRefs;
1430
1431/// HandleUpRefs - Every time we finish a new layer of types, this function is
1432/// called. It loops through the UpRefs vector, which is a list of the
1433/// currently active types. For each type, if the up reference is contained in
1434/// the newly completed type, we decrement the level count. When the level
1435/// count reaches zero, the upreferenced type is the type that is passed in:
1436/// thus we can complete the cycle.
1437///
Reid Spencerbb1fd572007-03-21 17:15:50 +00001438static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001439 // If Ty isn't abstract, or if there are no up-references in it, then there is
1440 // nothing to resolve here.
1441 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1442
1443 PATypeHolder Ty(ty);
1444 UR_OUT("Type '" << Ty->getDescription() <<
1445 "' newly formed. Resolving upreferences.\n" <<
1446 UpRefs.size() << " upreferences active!\n");
1447
1448 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1449 // to zero), we resolve them all together before we resolve them to Ty. At
1450 // the end of the loop, if there is anything to resolve to Ty, it will be in
1451 // this variable.
1452 OpaqueType *TypeToResolve = 0;
1453
Reid Spencerbb1fd572007-03-21 17:15:50 +00001454 unsigned i = 0;
1455 for (; i != UpRefs.size(); ++i) {
Reid Spencer950bf602007-01-26 08:19:09 +00001456 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001457 << UpRefs[i].UpRefTy->getDescription() << ") = "
1458 << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
Reid Spencer950bf602007-01-26 08:19:09 +00001459 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1460 // Decrement level of upreference
1461 unsigned Level = --UpRefs[i].NestingLevel;
1462 UpRefs[i].LastContainedTy = Ty;
1463 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1464 if (Level == 0) { // Upreference should be resolved!
1465 if (!TypeToResolve) {
1466 TypeToResolve = UpRefs[i].UpRefTy;
1467 } else {
1468 UR_OUT(" * Resolving upreference for "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001469 << UpRefs[i].UpRefTy->getDescription() << "\n";
1470 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1471 ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001472 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1473 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1474 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1475 }
1476 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1477 --i; // Do not skip the next element...
1478 }
1479 }
1480 }
1481
1482 if (TypeToResolve) {
1483 UR_OUT(" * Resolving upreference for "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001484 << UpRefs[i].UpRefTy->getDescription() << "\n";
Reid Spencer950bf602007-01-26 08:19:09 +00001485 std::string OldName = TypeToResolve->getDescription());
Reid Spencerbb1fd572007-03-21 17:15:50 +00001486 ResolveTypeSign(TypeToResolve, Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001487 TypeToResolve->refineAbstractTypeTo(Ty);
1488 }
1489
1490 return Ty;
1491}
1492
Reid Spencerbb1fd572007-03-21 17:15:50 +00001493bool Signedness::operator<(const Signedness &that) const {
1494 if (isNamed()) {
1495 if (that.isNamed())
1496 return *(this->name) < *(that.name);
1497 else
1498 return CurModule.NamedTypeSigns[*name] < that;
1499 } else if (that.isNamed()) {
1500 return *this < CurModule.NamedTypeSigns[*that.name];
1501 }
1502
1503 if (isComposite() && that.isComposite()) {
1504 if (sv->size() == that.sv->size()) {
1505 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1506 SignVector::const_iterator thatI = that.sv->begin(),
1507 thatE = that.sv->end();
1508 for (; thisI != thisE; ++thisI, ++thatI) {
1509 if (*thisI < *thatI)
1510 return true;
1511 else if (!(*thisI == *thatI))
1512 return false;
1513 }
1514 return false;
1515 }
1516 return sv->size() < that.sv->size();
1517 }
1518 return kind < that.kind;
1519}
1520
1521bool Signedness::operator==(const Signedness &that) const {
1522 if (isNamed())
1523 if (that.isNamed())
1524 return *(this->name) == *(that.name);
1525 else
1526 return CurModule.NamedTypeSigns[*(this->name)] == that;
1527 else if (that.isNamed())
1528 return *this == CurModule.NamedTypeSigns[*(that.name)];
1529 if (isComposite() && that.isComposite()) {
1530 if (sv->size() == that.sv->size()) {
1531 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1532 SignVector::const_iterator thatI = that.sv->begin(),
1533 thatE = that.sv->end();
1534 for (; thisI != thisE; ++thisI, ++thatI) {
1535 if (!(*thisI == *thatI))
1536 return false;
1537 }
1538 return true;
1539 }
1540 return false;
1541 }
1542 return kind == that.kind;
1543}
1544
1545void Signedness::copy(const Signedness &that) {
1546 if (that.isNamed()) {
1547 kind = Named;
1548 name = new std::string(*that.name);
1549 } else if (that.isComposite()) {
1550 kind = Composite;
1551 sv = new SignVector();
1552 *sv = *that.sv;
1553 } else {
1554 kind = that.kind;
1555 sv = 0;
1556 }
1557}
1558
1559void Signedness::destroy() {
1560 if (isNamed()) {
1561 delete name;
1562 } else if (isComposite()) {
1563 delete sv;
1564 }
1565}
1566
Evan Cheng2b484202007-03-22 07:43:51 +00001567#ifndef NDEBUG
Reid Spencerbb1fd572007-03-21 17:15:50 +00001568void Signedness::dump() const {
1569 if (isComposite()) {
1570 if (sv->size() == 1) {
1571 (*sv)[0].dump();
1572 std::cerr << "*";
1573 } else {
1574 std::cerr << "{ " ;
1575 for (unsigned i = 0; i < sv->size(); ++i) {
1576 if (i != 0)
1577 std::cerr << ", ";
1578 (*sv)[i].dump();
1579 }
1580 std::cerr << "} " ;
1581 }
1582 } else if (isNamed()) {
1583 std::cerr << *name;
1584 } else if (isSigned()) {
1585 std::cerr << "S";
1586 } else if (isUnsigned()) {
1587 std::cerr << "U";
1588 } else
1589 std::cerr << ".";
1590}
Evan Cheng2b484202007-03-22 07:43:51 +00001591#endif
Reid Spencerbb1fd572007-03-21 17:15:50 +00001592
Reid Spencer950bf602007-01-26 08:19:09 +00001593static inline Instruction::TermOps
1594getTermOp(TermOps op) {
1595 switch (op) {
1596 default : assert(0 && "Invalid OldTermOp");
1597 case RetOp : return Instruction::Ret;
1598 case BrOp : return Instruction::Br;
1599 case SwitchOp : return Instruction::Switch;
1600 case InvokeOp : return Instruction::Invoke;
1601 case UnwindOp : return Instruction::Unwind;
1602 case UnreachableOp: return Instruction::Unreachable;
1603 }
1604}
1605
1606static inline Instruction::BinaryOps
Reid Spencerbb1fd572007-03-21 17:15:50 +00001607getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001608 switch (op) {
1609 default : assert(0 && "Invalid OldBinaryOps");
1610 case SetEQ :
1611 case SetNE :
1612 case SetLE :
1613 case SetGE :
1614 case SetLT :
1615 case SetGT : assert(0 && "Should use getCompareOp");
1616 case AddOp : return Instruction::Add;
1617 case SubOp : return Instruction::Sub;
1618 case MulOp : return Instruction::Mul;
1619 case DivOp : {
1620 // This is an obsolete instruction so we must upgrade it based on the
1621 // types of its operands.
1622 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001623 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001624 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001625 isFP = PTy->getElementType()->isFloatingPoint();
1626 if (isFP)
1627 return Instruction::FDiv;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001628 else if (Sign.isSigned())
Reid Spencer950bf602007-01-26 08:19:09 +00001629 return Instruction::SDiv;
1630 return Instruction::UDiv;
1631 }
1632 case UDivOp : return Instruction::UDiv;
1633 case SDivOp : return Instruction::SDiv;
1634 case FDivOp : return Instruction::FDiv;
1635 case RemOp : {
1636 // This is an obsolete instruction so we must upgrade it based on the
1637 // types of its operands.
1638 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001639 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001640 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001641 isFP = PTy->getElementType()->isFloatingPoint();
1642 // Select correct opcode
1643 if (isFP)
1644 return Instruction::FRem;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001645 else if (Sign.isSigned())
Reid Spencer950bf602007-01-26 08:19:09 +00001646 return Instruction::SRem;
1647 return Instruction::URem;
1648 }
1649 case URemOp : return Instruction::URem;
1650 case SRemOp : return Instruction::SRem;
1651 case FRemOp : return Instruction::FRem;
Reid Spencer832254e2007-02-02 02:16:23 +00001652 case LShrOp : return Instruction::LShr;
1653 case AShrOp : return Instruction::AShr;
1654 case ShlOp : return Instruction::Shl;
1655 case ShrOp :
Reid Spencerbb1fd572007-03-21 17:15:50 +00001656 if (Sign.isSigned())
Reid Spencer832254e2007-02-02 02:16:23 +00001657 return Instruction::AShr;
1658 return Instruction::LShr;
Reid Spencer950bf602007-01-26 08:19:09 +00001659 case AndOp : return Instruction::And;
1660 case OrOp : return Instruction::Or;
1661 case XorOp : return Instruction::Xor;
1662 }
1663}
1664
1665static inline Instruction::OtherOps
1666getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
Reid Spencerbb1fd572007-03-21 17:15:50 +00001667 const Signedness &Sign) {
1668 bool isSigned = Sign.isSigned();
Reid Spencer950bf602007-01-26 08:19:09 +00001669 bool isFP = Ty->isFloatingPoint();
1670 switch (op) {
1671 default : assert(0 && "Invalid OldSetCC");
1672 case SetEQ :
1673 if (isFP) {
1674 predicate = FCmpInst::FCMP_OEQ;
1675 return Instruction::FCmp;
1676 } else {
1677 predicate = ICmpInst::ICMP_EQ;
1678 return Instruction::ICmp;
1679 }
1680 case SetNE :
1681 if (isFP) {
1682 predicate = FCmpInst::FCMP_UNE;
1683 return Instruction::FCmp;
1684 } else {
1685 predicate = ICmpInst::ICMP_NE;
1686 return Instruction::ICmp;
1687 }
1688 case SetLE :
1689 if (isFP) {
1690 predicate = FCmpInst::FCMP_OLE;
1691 return Instruction::FCmp;
1692 } else {
1693 if (isSigned)
1694 predicate = ICmpInst::ICMP_SLE;
1695 else
1696 predicate = ICmpInst::ICMP_ULE;
1697 return Instruction::ICmp;
1698 }
1699 case SetGE :
1700 if (isFP) {
1701 predicate = FCmpInst::FCMP_OGE;
1702 return Instruction::FCmp;
1703 } else {
1704 if (isSigned)
1705 predicate = ICmpInst::ICMP_SGE;
1706 else
1707 predicate = ICmpInst::ICMP_UGE;
1708 return Instruction::ICmp;
1709 }
1710 case SetLT :
1711 if (isFP) {
1712 predicate = FCmpInst::FCMP_OLT;
1713 return Instruction::FCmp;
1714 } else {
1715 if (isSigned)
1716 predicate = ICmpInst::ICMP_SLT;
1717 else
1718 predicate = ICmpInst::ICMP_ULT;
1719 return Instruction::ICmp;
1720 }
1721 case SetGT :
1722 if (isFP) {
1723 predicate = FCmpInst::FCMP_OGT;
1724 return Instruction::FCmp;
1725 } else {
1726 if (isSigned)
1727 predicate = ICmpInst::ICMP_SGT;
1728 else
1729 predicate = ICmpInst::ICMP_UGT;
1730 return Instruction::ICmp;
1731 }
1732 }
1733}
1734
1735static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1736 switch (op) {
1737 default : assert(0 && "Invalid OldMemoryOps");
1738 case MallocOp : return Instruction::Malloc;
1739 case FreeOp : return Instruction::Free;
1740 case AllocaOp : return Instruction::Alloca;
1741 case LoadOp : return Instruction::Load;
1742 case StoreOp : return Instruction::Store;
1743 case GetElementPtrOp : return Instruction::GetElementPtr;
1744 }
1745}
1746
1747static inline Instruction::OtherOps
Reid Spencerbb1fd572007-03-21 17:15:50 +00001748getOtherOp(OtherOps op, const Signedness &Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001749 switch (op) {
1750 default : assert(0 && "Invalid OldOtherOps");
1751 case PHIOp : return Instruction::PHI;
1752 case CallOp : return Instruction::Call;
Reid Spencer950bf602007-01-26 08:19:09 +00001753 case SelectOp : return Instruction::Select;
1754 case UserOp1 : return Instruction::UserOp1;
1755 case UserOp2 : return Instruction::UserOp2;
1756 case VAArg : return Instruction::VAArg;
1757 case ExtractElementOp : return Instruction::ExtractElement;
1758 case InsertElementOp : return Instruction::InsertElement;
1759 case ShuffleVectorOp : return Instruction::ShuffleVector;
1760 case ICmpOp : return Instruction::ICmp;
1761 case FCmpOp : return Instruction::FCmp;
Reid Spencer950bf602007-01-26 08:19:09 +00001762 };
1763}
1764
1765static inline Value*
Reid Spencerbb1fd572007-03-21 17:15:50 +00001766getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
1767 const Signedness &DstSign, bool ForceInstruction = false) {
Reid Spencer950bf602007-01-26 08:19:09 +00001768 Instruction::CastOps Opcode;
1769 const Type* SrcTy = Src->getType();
1770 if (op == CastOp) {
1771 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1772 // fp -> ptr cast is no longer supported but we must upgrade this
1773 // by doing a double cast: fp -> int -> ptr
1774 SrcTy = Type::Int64Ty;
1775 Opcode = Instruction::IntToPtr;
1776 if (isa<Constant>(Src)) {
1777 Src = ConstantExpr::getCast(Instruction::FPToUI,
1778 cast<Constant>(Src), SrcTy);
1779 } else {
1780 std::string NewName(makeNameUnique(Src->getName()));
1781 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1782 }
1783 } else if (isa<IntegerType>(DstTy) &&
1784 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1785 // cast type %x to bool was previously defined as setne type %x, null
1786 // The cast semantic is now to truncate, not compare so we must retain
1787 // the original intent by replacing the cast with a setne
1788 Constant* Null = Constant::getNullValue(SrcTy);
1789 Instruction::OtherOps Opcode = Instruction::ICmp;
1790 unsigned short predicate = ICmpInst::ICMP_NE;
1791 if (SrcTy->isFloatingPoint()) {
1792 Opcode = Instruction::FCmp;
1793 predicate = FCmpInst::FCMP_ONE;
1794 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1795 error("Invalid cast to bool");
1796 }
1797 if (isa<Constant>(Src) && !ForceInstruction)
1798 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1799 else
1800 return CmpInst::create(Opcode, predicate, Src, Null);
1801 }
1802 // Determine the opcode to use by calling CastInst::getCastOpcode
1803 Opcode =
Reid Spencerbb1fd572007-03-21 17:15:50 +00001804 CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
1805 DstSign.isSigned());
Reid Spencer950bf602007-01-26 08:19:09 +00001806
1807 } else switch (op) {
1808 default: assert(0 && "Invalid cast token");
1809 case TruncOp: Opcode = Instruction::Trunc; break;
1810 case ZExtOp: Opcode = Instruction::ZExt; break;
1811 case SExtOp: Opcode = Instruction::SExt; break;
1812 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1813 case FPExtOp: Opcode = Instruction::FPExt; break;
1814 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1815 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1816 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1817 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1818 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1819 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1820 case BitCastOp: Opcode = Instruction::BitCast; break;
1821 }
1822
1823 if (isa<Constant>(Src) && !ForceInstruction)
1824 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1825 return CastInst::create(Opcode, Src, DstTy);
1826}
1827
1828static Instruction *
1829upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1830 std::vector<Value*>& Args) {
1831
1832 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
Reid Spencer7eea8ff2007-05-18 05:48:07 +00001833 if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' ||
1834 Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.')
1835 return 0;
1836
Reid Spencer41b213e2007-04-02 01:14:00 +00001837 switch (Name[5]) {
1838 case 'i':
1839 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1840 if (Args.size() != 2)
1841 error("Invalid prototype for " + Name);
1842 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1843 }
1844 break;
Reid Spencer8166a6c2007-04-02 02:08:35 +00001845
Reid Spencer41b213e2007-04-02 01:14:00 +00001846 case 'v' : {
1847 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1848 std::vector<const Type*> Params;
1849 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1850 if (Args.size() != 1)
1851 error("Invalid prototype for " + Name + " prototype");
1852 Params.push_back(PtrTy);
1853 const FunctionType *FTy =
1854 FunctionType::get(Type::VoidTy, Params, false);
1855 const PointerType *PFTy = PointerType::get(FTy);
1856 Value* Func = getVal(PFTy, ID);
1857 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
David Greene718fda32007-08-01 03:59:32 +00001858 return new CallInst(Func, Args.begin(), Args.end());
Reid Spencer41b213e2007-04-02 01:14:00 +00001859 } else if (Name == "llvm.va_copy") {
1860 if (Args.size() != 2)
1861 error("Invalid prototype for " + Name + " prototype");
1862 Params.push_back(PtrTy);
1863 Params.push_back(PtrTy);
1864 const FunctionType *FTy =
1865 FunctionType::get(Type::VoidTy, Params, false);
1866 const PointerType *PFTy = PointerType::get(FTy);
1867 Value* Func = getVal(PFTy, ID);
1868 std::string InstName0(makeNameUnique("va0"));
1869 std::string InstName1(makeNameUnique("va1"));
1870 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1871 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
David Greene718fda32007-08-01 03:59:32 +00001872 return new CallInst(Func, Args.begin(), Args.end());
Reid Spencer41b213e2007-04-02 01:14:00 +00001873 }
Reid Spencer950bf602007-01-26 08:19:09 +00001874 }
1875 }
1876 return 0;
1877}
1878
Reid Spencerff0e4482007-04-16 00:40:57 +00001879const Type* upgradeGEPCEIndices(const Type* PTy,
1880 std::vector<ValueInfo> *Indices,
1881 std::vector<Constant*> &Result) {
1882 const Type *Ty = PTy;
1883 Result.clear();
1884 for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
1885 Constant *Index = cast<Constant>((*Indices)[i].V);
1886
1887 if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
1888 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1889 // struct indices to i32 struct indices with ZExt for compatibility.
1890 if (CI->getBitWidth() < 32)
1891 Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
1892 }
1893
1894 if (isa<SequentialType>(Ty)) {
1895 // Make sure that unsigned SequentialType indices are zext'd to
1896 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1897 // all indices for SequentialType elements. We must retain the same
1898 // semantic (zext) for unsigned types.
1899 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
1900 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
1901 Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty);
1902 }
1903 }
1904 }
1905 Result.push_back(Index);
1906 Ty = GetElementPtrInst::getIndexedType(PTy, (Value**)&Result[0],
1907 Result.size(),true);
1908 if (!Ty)
1909 error("Index list invalid for constant getelementptr");
1910 }
1911 return Ty;
1912}
1913
1914const Type* upgradeGEPInstIndices(const Type* PTy,
1915 std::vector<ValueInfo> *Indices,
1916 std::vector<Value*> &Result) {
1917 const Type *Ty = PTy;
1918 Result.clear();
1919 for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
1920 Value *Index = (*Indices)[i].V;
1921
1922 if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
1923 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1924 // struct indices to i32 struct indices with ZExt for compatibility.
1925 if (CI->getBitWidth() < 32)
1926 Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
1927 }
1928
1929
1930 if (isa<StructType>(Ty)) { // Only change struct indices
1931 if (!isa<Constant>(Index)) {
1932 error("Invalid non-constant structure index");
1933 return 0;
1934 }
Reid Spencer950bf602007-01-26 08:19:09 +00001935 } else {
1936 // Make sure that unsigned SequentialType indices are zext'd to
1937 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1938 // all indices for SequentialType elements. We must retain the same
1939 // semantic (zext) for unsigned types.
Reid Spencerff0e4482007-04-16 00:40:57 +00001940 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00001941 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
Reid Spencerff0e4482007-04-16 00:40:57 +00001942 if (isa<Constant>(Index))
Reid Spencer950bf602007-01-26 08:19:09 +00001943 Index = ConstantExpr::getCast(Instruction::ZExt,
1944 cast<Constant>(Index), Type::Int64Ty);
1945 else
1946 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001947 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001948 }
Reid Spencerff0e4482007-04-16 00:40:57 +00001949 }
Reid Spencer950bf602007-01-26 08:19:09 +00001950 }
Reid Spencerff0e4482007-04-16 00:40:57 +00001951 Result.push_back(Index);
1952 Ty = GetElementPtrInst::getIndexedType(PTy, &Result[0], Result.size(),true);
1953 if (!Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00001954 error("Index list invalid for constant getelementptr");
Reid Spencerff0e4482007-04-16 00:40:57 +00001955 }
1956 return Ty;
Reid Spencer950bf602007-01-26 08:19:09 +00001957}
1958
Reid Spencerb7046c72007-01-29 05:41:34 +00001959unsigned upgradeCallingConv(unsigned CC) {
1960 switch (CC) {
1961 case OldCallingConv::C : return CallingConv::C;
1962 case OldCallingConv::CSRet : return CallingConv::C;
1963 case OldCallingConv::Fast : return CallingConv::Fast;
1964 case OldCallingConv::Cold : return CallingConv::Cold;
1965 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1966 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1967 default:
1968 return CC;
1969 }
1970}
1971
Reid Spencer950bf602007-01-26 08:19:09 +00001972Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1973 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001974{
1975 Upgradelineno = 1;
1976 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001977 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001978 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001979 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001980 ObsoleteVarArgs = false;
1981 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001982
Reid Spencer950bf602007-01-26 08:19:09 +00001983 CurModule.CurrentModule = new Module(CurFilename);
1984
1985 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001986 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001987 if (ParserResult)
1988 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001989 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001990 return 0;
1991 }
1992
Reid Spencer950bf602007-01-26 08:19:09 +00001993 // Check to make sure that parsing produced a result
1994 if (!ParserResult) {
1995 std::cerr << "llvm-upgrade: no parse result.\n";
1996 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001997 }
1998
Reid Spencer950bf602007-01-26 08:19:09 +00001999 // Reset ParserResult variable while saving its value for the result.
2000 Module *Result = ParserResult;
2001 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00002002
Reid Spencer950bf602007-01-26 08:19:09 +00002003 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00002004 {
Reid Spencer950bf602007-01-26 08:19:09 +00002005 Function* F;
Reid Spencer688b0492007-02-05 21:19:13 +00002006 if ((F = Result->getFunction("llvm.va_start"))
Reid Spencer950bf602007-01-26 08:19:09 +00002007 && F->getFunctionType()->getNumParams() == 0)
2008 ObsoleteVarArgs = true;
Reid Spencer688b0492007-02-05 21:19:13 +00002009 if((F = Result->getFunction("llvm.va_copy"))
Reid Spencer950bf602007-01-26 08:19:09 +00002010 && F->getFunctionType()->getNumParams() == 1)
2011 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00002012 }
Reid Spencer319a7302007-01-05 17:20:02 +00002013
Reid Spencer950bf602007-01-26 08:19:09 +00002014 if (ObsoleteVarArgs && NewVarArgs) {
2015 error("This file is corrupt: it uses both new and old style varargs");
2016 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00002017 }
Reid Spencer319a7302007-01-05 17:20:02 +00002018
Reid Spencer950bf602007-01-26 08:19:09 +00002019 if(ObsoleteVarArgs) {
Reid Spencer688b0492007-02-05 21:19:13 +00002020 if(Function* F = Result->getFunction("llvm.va_start")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002021 if (F->arg_size() != 0) {
2022 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00002023 return 0;
2024 }
Reid Spencer950bf602007-01-26 08:19:09 +00002025
2026 //foo = va_start()
2027 // ->
2028 //bar = alloca typeof(foo)
2029 //va_start(bar)
2030 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00002031
Reid Spencer950bf602007-01-26 08:19:09 +00002032 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2033 const Type* ArgTy = F->getFunctionType()->getReturnType();
2034 const Type* ArgTyPtr = PointerType::get(ArgTy);
2035 Function* NF = cast<Function>(Result->getOrInsertFunction(
2036 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
2037
2038 while (!F->use_empty()) {
2039 CallInst* CI = cast<CallInst>(F->use_back());
2040 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
2041 new CallInst(NF, bar, "", CI);
2042 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
2043 CI->replaceAllUsesWith(foo);
2044 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00002045 }
Reid Spencer950bf602007-01-26 08:19:09 +00002046 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00002047 }
Reid Spencer950bf602007-01-26 08:19:09 +00002048
Reid Spencer688b0492007-02-05 21:19:13 +00002049 if(Function* F = Result->getFunction("llvm.va_end")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002050 if(F->arg_size() != 1) {
2051 error("Obsolete va_end takes 1 argument");
2052 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00002053 }
Reid Spencerf8383de2007-01-06 06:04:32 +00002054
Reid Spencer950bf602007-01-26 08:19:09 +00002055 //vaend foo
2056 // ->
2057 //bar = alloca 1 of typeof(foo)
2058 //vaend bar
2059 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2060 const Type* ArgTy = F->getFunctionType()->getParamType(0);
2061 const Type* ArgTyPtr = PointerType::get(ArgTy);
2062 Function* NF = cast<Function>(Result->getOrInsertFunction(
2063 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00002064
Reid Spencer950bf602007-01-26 08:19:09 +00002065 while (!F->use_empty()) {
2066 CallInst* CI = cast<CallInst>(F->use_back());
2067 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
2068 new StoreInst(CI->getOperand(1), bar, CI);
2069 new CallInst(NF, bar, "", CI);
2070 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00002071 }
Reid Spencer950bf602007-01-26 08:19:09 +00002072 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00002073 }
Reid Spencer950bf602007-01-26 08:19:09 +00002074
Reid Spencer688b0492007-02-05 21:19:13 +00002075 if(Function* F = Result->getFunction("llvm.va_copy")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002076 if(F->arg_size() != 1) {
2077 error("Obsolete va_copy takes 1 argument");
2078 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00002079 }
Reid Spencer950bf602007-01-26 08:19:09 +00002080 //foo = vacopy(bar)
2081 // ->
2082 //a = alloca 1 of typeof(foo)
2083 //b = alloca 1 of typeof(foo)
2084 //store bar -> b
2085 //vacopy(a, b)
2086 //foo = load a
2087
2088 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2089 const Type* ArgTy = F->getFunctionType()->getReturnType();
2090 const Type* ArgTyPtr = PointerType::get(ArgTy);
2091 Function* NF = cast<Function>(Result->getOrInsertFunction(
2092 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00002093
Reid Spencer950bf602007-01-26 08:19:09 +00002094 while (!F->use_empty()) {
2095 CallInst* CI = cast<CallInst>(F->use_back());
David Greene718fda32007-08-01 03:59:32 +00002096 SmallVector<Value *, 2> Args;
2097 Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI));
2098 Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI));
2099 new StoreInst(CI->getOperand(1), Args[1], CI);
2100 new CallInst(NF, Args.begin(), Args.end(), "", CI);
2101 Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
Reid Spencer950bf602007-01-26 08:19:09 +00002102 CI->replaceAllUsesWith(foo);
2103 CI->getParent()->getInstList().erase(CI);
2104 }
2105 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00002106 }
2107 }
2108
Reid Spencer52402b02007-01-02 05:45:11 +00002109 return Result;
2110}
2111
Reid Spencer950bf602007-01-26 08:19:09 +00002112} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00002113
Reid Spencer950bf602007-01-26 08:19:09 +00002114using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00002115
2116
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002117
2118/* Enabling traces. */
2119#ifndef YYDEBUG
2120# define YYDEBUG 0
2121#endif
2122
2123/* Enabling verbose error messages. */
2124#ifdef YYERROR_VERBOSE
2125# undef YYERROR_VERBOSE
2126# define YYERROR_VERBOSE 1
2127#else
2128# define YYERROR_VERBOSE 0
2129#endif
2130
Chandler Carruth02202192007-08-04 01:56:21 +00002131/* Enabling the token table. */
2132#ifndef YYTOKEN_TABLE
2133# define YYTOKEN_TABLE 0
2134#endif
2135
2136#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
2137typedef union YYSTYPE
2138#line 1748 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
2139{
Reid Spencer950bf602007-01-26 08:19:09 +00002140 llvm::Module *ModuleVal;
2141 llvm::Function *FunctionVal;
2142 std::pair<llvm::PATypeInfo, char*> *ArgVal;
2143 llvm::BasicBlock *BasicBlockVal;
Reid Spencerbb1fd572007-03-21 17:15:50 +00002144 llvm::TermInstInfo TermInstVal;
Reid Spencer950bf602007-01-26 08:19:09 +00002145 llvm::InstrInfo InstVal;
2146 llvm::ConstInfo ConstVal;
2147 llvm::ValueInfo ValueVal;
2148 llvm::PATypeInfo TypeVal;
2149 llvm::TypeInfo PrimType;
2150 llvm::PHIListInfo PHIList;
2151 std::list<llvm::PATypeInfo> *TypeList;
2152 std::vector<llvm::ValueInfo> *ValueList;
2153 std::vector<llvm::ConstInfo> *ConstVector;
2154
2155
2156 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
2157 // Represent the RHS of PHI node
2158 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
2159
2160 llvm::GlobalValue::LinkageTypes Linkage;
2161 int64_t SInt64Val;
2162 uint64_t UInt64Val;
2163 int SIntVal;
2164 unsigned UIntVal;
2165 double FPVal;
2166 bool BoolVal;
2167
2168 char *StrVal; // This memory is strdup'd!
2169 llvm::ValID ValIDVal; // strdup'd memory maybe!
2170
2171 llvm::BinaryOps BinaryOpVal;
2172 llvm::TermOps TermOpVal;
2173 llvm::MemoryOps MemOpVal;
2174 llvm::OtherOps OtherOpVal;
2175 llvm::CastOps CastOpVal;
2176 llvm::ICmpInst::Predicate IPred;
2177 llvm::FCmpInst::Predicate FPred;
2178 llvm::Module::Endianness Endianness;
Chandler Carruth02202192007-08-04 01:56:21 +00002179}
2180/* Line 187 of yacc.c. */
2181#line 2182 "UpgradeParser.tab.c"
2182 YYSTYPE;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002183# define yystype YYSTYPE /* obsolescent; will be withdrawn */
2184# define YYSTYPE_IS_DECLARED 1
2185# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00002186#endif
2187
Reid Spencer950bf602007-01-26 08:19:09 +00002188
Reid Spencere7c3c602006-11-30 06:36:44 +00002189
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002190/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002191
2192
Chandler Carruth02202192007-08-04 01:56:21 +00002193/* Line 216 of yacc.c. */
2194#line 2195 "UpgradeParser.tab.c"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002195
Chandler Carruth02202192007-08-04 01:56:21 +00002196#ifdef short
2197# undef short
2198#endif
2199
2200#ifdef YYTYPE_UINT8
2201typedef YYTYPE_UINT8 yytype_uint8;
2202#else
2203typedef unsigned char yytype_uint8;
2204#endif
2205
2206#ifdef YYTYPE_INT8
2207typedef YYTYPE_INT8 yytype_int8;
2208#elif (defined __STDC__ || defined __C99__FUNC__ \
2209 || defined __cplusplus || defined _MSC_VER)
2210typedef signed char yytype_int8;
2211#else
2212typedef short int yytype_int8;
2213#endif
2214
2215#ifdef YYTYPE_UINT16
2216typedef YYTYPE_UINT16 yytype_uint16;
2217#else
2218typedef unsigned short int yytype_uint16;
2219#endif
2220
2221#ifdef YYTYPE_INT16
2222typedef YYTYPE_INT16 yytype_int16;
2223#else
2224typedef short int yytype_int16;
2225#endif
2226
2227#ifndef YYSIZE_T
2228# ifdef __SIZE_TYPE__
2229# define YYSIZE_T __SIZE_TYPE__
2230# elif defined size_t
2231# define YYSIZE_T size_t
2232# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
2233 || defined __cplusplus || defined _MSC_VER)
2234# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2235# define YYSIZE_T size_t
2236# else
2237# define YYSIZE_T unsigned int
2238# endif
2239#endif
2240
2241#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
2242
2243#ifndef YY_
2244# if YYENABLE_NLS
2245# if ENABLE_NLS
2246# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
2247# define YY_(msgid) dgettext ("bison-runtime", msgid)
2248# endif
2249# endif
2250# ifndef YY_
2251# define YY_(msgid) msgid
2252# endif
2253#endif
2254
2255/* Suppress unused-variable warnings by "using" E. */
2256#if ! defined lint || defined __GNUC__
2257# define YYUSE(e) ((void) (e))
2258#else
2259# define YYUSE(e) /* empty */
2260#endif
2261
2262/* Identity function, used to suppress warnings about constant conditions. */
2263#ifndef lint
2264# define YYID(n) (n)
2265#else
2266#if (defined __STDC__ || defined __C99__FUNC__ \
2267 || defined __cplusplus || defined _MSC_VER)
2268static int
2269YYID (int i)
2270#else
2271static int
2272YYID (i)
2273 int i;
2274#endif
2275{
2276 return i;
2277}
2278#endif
2279
2280#if ! defined yyoverflow || YYERROR_VERBOSE
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002281
2282/* The parser invokes alloca or malloc; define the necessary symbols. */
2283
2284# ifdef YYSTACK_USE_ALLOCA
2285# if YYSTACK_USE_ALLOCA
2286# ifdef __GNUC__
2287# define YYSTACK_ALLOC __builtin_alloca
Chandler Carruth02202192007-08-04 01:56:21 +00002288# elif defined __BUILTIN_VA_ARG_INCR
2289# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
2290# elif defined _AIX
2291# define YYSTACK_ALLOC __alloca
2292# elif defined _MSC_VER
2293# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
2294# define alloca _alloca
2295# else
2296# define YYSTACK_ALLOC alloca
2297# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2298 || defined __cplusplus || defined _MSC_VER)
2299# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2300# ifndef _STDLIB_H
2301# define _STDLIB_H 1
2302# endif
2303# endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002304# endif
2305# endif
2306# endif
2307
2308# ifdef YYSTACK_ALLOC
Chandler Carruth02202192007-08-04 01:56:21 +00002309 /* Pacify GCC's `empty if-body' warning. */
2310# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
2311# ifndef YYSTACK_ALLOC_MAXIMUM
2312 /* The OS might guarantee only one guard page at the bottom of the stack,
2313 and a page size can be as small as 4096 bytes. So we cannot safely
2314 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
2315 to allow for a few compiler-allocated temporary stack slots. */
2316# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002317# endif
Chandler Carruth02202192007-08-04 01:56:21 +00002318# else
2319# define YYSTACK_ALLOC YYMALLOC
2320# define YYSTACK_FREE YYFREE
2321# ifndef YYSTACK_ALLOC_MAXIMUM
2322# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
2323# endif
2324# if (defined __cplusplus && ! defined _STDLIB_H \
2325 && ! ((defined YYMALLOC || defined malloc) \
2326 && (defined YYFREE || defined free)))
2327# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2328# ifndef _STDLIB_H
2329# define _STDLIB_H 1
2330# endif
2331# endif
2332# ifndef YYMALLOC
2333# define YYMALLOC malloc
2334# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2335 || defined __cplusplus || defined _MSC_VER)
2336void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
2337# endif
2338# endif
2339# ifndef YYFREE
2340# define YYFREE free
2341# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
2342 || defined __cplusplus || defined _MSC_VER)
2343void free (void *); /* INFRINGES ON USER NAME SPACE */
2344# endif
2345# endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002346# endif
Chandler Carruth02202192007-08-04 01:56:21 +00002347#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002348
2349
Chandler Carruth02202192007-08-04 01:56:21 +00002350#if (! defined yyoverflow \
2351 && (! defined __cplusplus \
2352 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002353
2354/* A type that is properly aligned for any stack member. */
2355union yyalloc
2356{
Chandler Carruth02202192007-08-04 01:56:21 +00002357 yytype_int16 yyss;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002358 YYSTYPE yyvs;
2359 };
2360
2361/* The size of the maximum gap between one aligned stack and the next. */
2362# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2363
2364/* The size of an array large to enough to hold all stacks, each with
2365 N elements. */
2366# define YYSTACK_BYTES(N) \
Chandler Carruth02202192007-08-04 01:56:21 +00002367 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002368 + YYSTACK_GAP_MAXIMUM)
2369
2370/* Copy COUNT objects from FROM to TO. The source and destination do
2371 not overlap. */
2372# ifndef YYCOPY
Chandler Carruth02202192007-08-04 01:56:21 +00002373# if defined __GNUC__ && 1 < __GNUC__
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002374# define YYCOPY(To, From, Count) \
2375 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2376# else
2377# define YYCOPY(To, From, Count) \
2378 do \
2379 { \
Chandler Carruth02202192007-08-04 01:56:21 +00002380 YYSIZE_T yyi; \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002381 for (yyi = 0; yyi < (Count); yyi++) \
2382 (To)[yyi] = (From)[yyi]; \
2383 } \
Chandler Carruth02202192007-08-04 01:56:21 +00002384 while (YYID (0))
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002385# endif
2386# endif
2387
2388/* Relocate STACK from its old location to the new one. The
2389 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2390 elements in the stack, and YYPTR gives the new location of the
2391 stack. Advance YYPTR to a properly aligned location for the next
2392 stack. */
2393# define YYSTACK_RELOCATE(Stack) \
2394 do \
2395 { \
2396 YYSIZE_T yynewbytes; \
2397 YYCOPY (&yyptr->Stack, Stack, yysize); \
2398 Stack = &yyptr->Stack; \
2399 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2400 yyptr += yynewbytes / sizeof (*yyptr); \
2401 } \
Chandler Carruth02202192007-08-04 01:56:21 +00002402 while (YYID (0))
Chris Lattnercf3d0612007-02-13 06:04:17 +00002403
Reid Spencere7c3c602006-11-30 06:36:44 +00002404#endif
2405
Chandler Carruth02202192007-08-04 01:56:21 +00002406/* YYFINAL -- State number of the termination state. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002407#define YYFINAL 4
2408/* YYLAST -- Last index in YYTABLE. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002409#define YYLAST 1630
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002410
Chandler Carruth02202192007-08-04 01:56:21 +00002411/* YYNTOKENS -- Number of terminals. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002412#define YYNTOKENS 166
Chandler Carruth02202192007-08-04 01:56:21 +00002413/* YYNNTS -- Number of nonterminals. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002414#define YYNNTS 81
Chandler Carruth02202192007-08-04 01:56:21 +00002415/* YYNRULES -- Number of rules. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002416#define YYNRULES 310
Chandler Carruth02202192007-08-04 01:56:21 +00002417/* YYNRULES -- Number of states. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002418#define YYNSTATES 606
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002419
2420/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2421#define YYUNDEFTOK 2
2422#define YYMAXUTOK 406
2423
Chandler Carruth02202192007-08-04 01:56:21 +00002424#define YYTRANSLATE(YYX) \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002425 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2426
2427/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Chandler Carruth02202192007-08-04 01:56:21 +00002428static const yytype_uint8 yytranslate[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002429{
2430 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2434 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2436 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2439 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2442 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2455 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2456 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2457 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2458 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2459 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2460 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2461 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2462 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2463 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2464 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2465 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2466 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2467 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2468 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2469 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2470 145, 146, 147, 148, 149, 150, 151
2471};
2472
2473#if YYDEBUG
2474/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2475 YYRHS. */
Chandler Carruth02202192007-08-04 01:56:21 +00002476static const yytype_uint16 yyprhs[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002477{
2478 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2479 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2480 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2481 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2482 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2483 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2484 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2485 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2486 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2487 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2488 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2489 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2490 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2491 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2492 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2493 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2494 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2495 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2496 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2497 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2498 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2499 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002500 622, 623, 632, 634, 636, 637, 642, 644, 646, 649,
2501 650, 652, 654, 655, 656, 662, 663, 665, 667, 669,
2502 671, 673, 675, 677, 679, 681, 685, 687, 693, 695,
2503 697, 699, 701, 704, 707, 710, 714, 717, 718, 720,
2504 722, 724, 727, 730, 734, 744, 754, 763, 777, 779,
2505 781, 788, 794, 797, 804, 812, 814, 818, 820, 821,
2506 824, 826, 832, 838, 844, 851, 858, 861, 866, 871,
2507 878, 883, 888, 893, 898, 905, 912, 915, 923, 925,
2508 928, 929, 931, 932, 936, 943, 947, 954, 957, 962,
2509 969
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002510};
2511
Chandler Carruth02202192007-08-04 01:56:21 +00002512/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2513static const yytype_int16 yyrhs[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002514{
2515 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2516 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2517 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2518 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2519 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2520 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2521 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2522 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2523 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2524 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2525 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2526 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2527 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2528 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2529 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2530 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2531 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2532 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2533 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2534 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2535 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2536 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2537 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2538 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2539 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002540 -1, 19, -1, 21, -1, 192, -1, 48, -1, 229,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002541 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2542 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2543 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2544 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2545 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2546 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2547 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2548 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2549 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2550 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002551 191, 39, -1, 191, 229, -1, 191, 197, -1, 191,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002552 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2553 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002554 36, 191, 156, -1, 110, 155, 196, 244, 156, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002555 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2556 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2557 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2558 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2559 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2560 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2561 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2562 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2563 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002564 201, 222, -1, 201, 224, -1, 201, 62, 61, 207,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002565 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002566 -1, 202, 224, -1, 202, 62, 61, 207, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002567 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2568 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2569 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2570 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2571 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2572 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2573 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2574 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2575 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2576 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2577 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002578 183, -1, 29, -1, 162, -1, -1, 181, 220, 217,
2579 218, -1, 30, -1, 163, -1, 232, 221, -1, -1,
2580 45, -1, 47, -1, -1, -1, 31, 225, 223, 226,
2581 217, -1, -1, 63, -1, 3, -1, 4, -1, 7,
2582 -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
2583 -1, 160, 198, 161, -1, 197, -1, 61, 227, 24,
2584 153, 24, -1, 167, -1, 212, -1, 229, -1, 228,
2585 -1, 191, 230, -1, 232, 233, -1, 219, 233, -1,
2586 234, 180, 236, -1, 234, 238, -1, -1, 23, -1,
2587 77, -1, 78, -1, 72, 231, -1, 72, 8, -1,
2588 73, 21, 230, -1, 73, 9, 230, 153, 21, 230,
2589 153, 21, 230, -1, 74, 178, 230, 153, 21, 230,
2590 157, 237, 159, -1, 74, 178, 230, 153, 21, 230,
2591 157, 159, -1, 75, 182, 189, 230, 155, 241, 156,
2592 36, 21, 230, 235, 21, 230, -1, 235, -1, 76,
2593 -1, 237, 178, 228, 153, 21, 230, -1, 178, 228,
2594 153, 21, 230, -1, 180, 243, -1, 191, 157, 230,
2595 153, 230, 159, -1, 239, 153, 157, 230, 153, 230,
2596 159, -1, 231, -1, 240, 153, 231, -1, 240, -1,
2597 -1, 60, 59, -1, 59, -1, 169, 191, 230, 153,
2598 230, -1, 170, 191, 230, 153, 230, -1, 171, 191,
2599 230, 153, 230, -1, 103, 172, 191, 230, 153, 230,
2600 -1, 104, 173, 191, 230, 153, 230, -1, 49, 231,
2601 -1, 174, 231, 153, 231, -1, 175, 231, 36, 191,
2602 -1, 112, 231, 153, 231, 153, 231, -1, 113, 231,
2603 153, 191, -1, 117, 231, 153, 191, -1, 118, 231,
2604 153, 191, -1, 114, 231, 153, 231, -1, 115, 231,
2605 153, 231, 153, 231, -1, 116, 231, 153, 231, 153,
2606 231, -1, 111, 239, -1, 242, 182, 189, 230, 155,
2607 241, 156, -1, 246, -1, 153, 240, -1, -1, 35,
2608 -1, -1, 105, 191, 184, -1, 105, 191, 153, 15,
2609 230, 184, -1, 106, 191, 184, -1, 106, 191, 153,
2610 15, 230, 184, -1, 107, 231, -1, 245, 108, 191,
2611 230, -1, 245, 109, 231, 153, 191, 230, -1, 110,
2612 191, 230, 244, -1
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002613};
2614
2615/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Chandler Carruth02202192007-08-04 01:56:21 +00002616static const yytype_uint16 yyrline[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002617{
Chandler Carruth02202192007-08-04 01:56:21 +00002618 0, 1888, 1888, 1889, 1897, 1898, 1908, 1908, 1908, 1908,
2619 1908, 1908, 1908, 1908, 1908, 1908, 1908, 1912, 1912, 1912,
2620 1916, 1916, 1916, 1916, 1916, 1916, 1920, 1920, 1921, 1921,
2621 1922, 1922, 1923, 1923, 1924, 1924, 1928, 1928, 1929, 1929,
2622 1930, 1930, 1931, 1931, 1932, 1932, 1933, 1933, 1934, 1934,
2623 1935, 1936, 1939, 1939, 1939, 1939, 1943, 1943, 1943, 1943,
2624 1943, 1943, 1943, 1944, 1944, 1944, 1944, 1944, 1944, 1950,
2625 1950, 1950, 1950, 1954, 1954, 1954, 1954, 1958, 1958, 1962,
2626 1962, 1967, 1970, 1975, 1976, 1977, 1978, 1979, 1980, 1981,
2627 1982, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 2003,
2628 2004, 2012, 2013, 2021, 2030, 2031, 2038, 2039, 2043, 2047,
2629 2063, 2064, 2071, 2072, 2079, 2087, 2087, 2087, 2087, 2087,
2630 2087, 2087, 2088, 2088, 2088, 2088, 2088, 2093, 2097, 2101,
2631 2106, 2115, 2142, 2148, 2161, 2172, 2176, 2189, 2193, 2207,
2632 2211, 2218, 2219, 2225, 2232, 2244, 2274, 2287, 2310, 2338,
2633 2360, 2371, 2393, 2404, 2413, 2418, 2477, 2484, 2492, 2499,
2634 2506, 2510, 2514, 2523, 2538, 2550, 2559, 2587, 2600, 2609,
2635 2615, 2621, 2632, 2638, 2644, 2655, 2656, 2665, 2666, 2678,
2636 2687, 2688, 2689, 2690, 2691, 2707, 2727, 2729, 2731, 2731,
2637 2738, 2738, 2746, 2746, 2754, 2754, 2763, 2765, 2767, 2772,
2638 2786, 2787, 2791, 2794, 2802, 2806, 2813, 2817, 2821, 2825,
2639 2833, 2833, 2837, 2838, 2842, 2850, 2855, 2863, 2864, 2871,
2640 2878, 2882, 3072, 3072, 3076, 3076, 3086, 3086, 3090, 3095,
2641 3096, 3097, 3101, 3102, 3101, 3114, 3115, 3120, 3121, 3122,
2642 3123, 3127, 3131, 3132, 3133, 3134, 3155, 3159, 3173, 3174,
2643 3179, 3179, 3187, 3197, 3200, 3209, 3220, 3225, 3234, 3245,
2644 3245, 3248, 3252, 3256, 3261, 3271, 3289, 3298, 3371, 3375,
2645 3382, 3394, 3409, 3439, 3449, 3459, 3463, 3470, 3471, 3475,
2646 3478, 3484, 3503, 3521, 3537, 3551, 3565, 3576, 3594, 3603,
2647 3612, 3619, 3640, 3664, 3670, 3676, 3682, 3698, 3791, 3799,
2648 3800, 3804, 3805, 3809, 3815, 3822, 3828, 3835, 3842, 3855,
2649 3881
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002650};
2651#endif
2652
Chandler Carruth02202192007-08-04 01:56:21 +00002653#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2654/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2655 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002656static const char *const yytname[] =
2657{
2658 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2659 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2660 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2661 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2662 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2663 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2664 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2665 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2666 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2667 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2668 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2669 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2670 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2671 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2672 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2673 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2674 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2675 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2676 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2677 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2678 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2679 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2680 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2681 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2682 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2683 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2684 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2685 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2686 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2687 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2688 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2689 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2690 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2691 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
Reid Spencerd2920cd2007-03-21 17:27:53 +00002692 "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7",
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002693 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2694 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2695 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2696 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2697 "OptVolatile", "MemoryInst", 0
2698};
2699#endif
2700
2701# ifdef YYPRINT
2702/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2703 token YYLEX-NUM. */
Chandler Carruth02202192007-08-04 01:56:21 +00002704static const yytype_uint16 yytoknum[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002705{
2706 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2707 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2708 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2709 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2710 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2711 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2712 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2713 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2714 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2715 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2716 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2717 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2718 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2719 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2720 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2721 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2722 60, 62, 123, 125, 42, 99
2723};
2724# endif
2725
2726/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Chandler Carruth02202192007-08-04 01:56:21 +00002727static const yytype_uint8 yyr1[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002728{
2729 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2730 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2731 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2732 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2733 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2734 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2735 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2736 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2737 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2738 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2739 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2740 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2741 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2742 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2743 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2744 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2745 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2746 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2747 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2748 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2749 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2750 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002751 216, 217, 218, 218, 220, 219, 221, 221, 222, 223,
2752 223, 223, 225, 226, 224, 227, 227, 228, 228, 228,
2753 228, 228, 228, 228, 228, 228, 228, 228, 229, 229,
2754 230, 230, 231, 232, 232, 233, 234, 234, 234, 235,
2755 235, 236, 236, 236, 236, 236, 236, 236, 236, 236,
2756 237, 237, 238, 239, 239, 240, 240, 241, 241, 242,
2757 242, 243, 243, 243, 243, 243, 243, 243, 243, 243,
2758 243, 243, 243, 243, 243, 243, 243, 243, 243, 244,
2759 244, 245, 245, 246, 246, 246, 246, 246, 246, 246,
2760 246
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002761};
2762
2763/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Chandler Carruth02202192007-08-04 01:56:21 +00002764static const yytype_uint8 yyr2[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002765{
2766 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2767 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2768 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2769 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2770 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2771 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2772 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2773 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2774 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2775 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2776 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2777 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2778 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2779 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2780 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2781 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2782 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2783 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2784 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2785 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2786 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2787 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002788 0, 8, 1, 1, 0, 4, 1, 1, 2, 0,
2789 1, 1, 0, 0, 5, 0, 1, 1, 1, 1,
2790 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
2791 1, 1, 2, 2, 2, 3, 2, 0, 1, 1,
2792 1, 2, 2, 3, 9, 9, 8, 13, 1, 1,
2793 6, 5, 2, 6, 7, 1, 3, 1, 0, 2,
2794 1, 5, 5, 5, 6, 6, 2, 4, 4, 6,
2795 4, 4, 4, 4, 6, 6, 2, 7, 1, 2,
2796 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
2797 4
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002798};
2799
2800/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2801 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2802 means the default is an error. */
Chandler Carruth02202192007-08-04 01:56:21 +00002803static const yytype_uint16 yydefact[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002804{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002805 198, 0, 90, 184, 1, 183, 232, 83, 84, 85,
2806 86, 87, 88, 89, 0, 224, 257, 180, 181, 257,
2807 210, 211, 0, 0, 0, 90, 0, 186, 229, 0,
2808 91, 258, 254, 82, 226, 227, 228, 253, 0, 0,
2809 0, 0, 196, 0, 0, 0, 0, 0, 0, 0,
2810 81, 230, 231, 233, 199, 182, 0, 92, 93, 94,
2811 95, 96, 97, 0, 0, 302, 256, 0, 0, 0,
2812 0, 209, 197, 187, 2, 3, 111, 115, 116, 117,
2813 118, 119, 120, 121, 122, 123, 124, 125, 126, 128,
2814 0, 0, 0, 0, 248, 185, 0, 110, 127, 114,
2815 249, 129, 177, 178, 0, 0, 0, 0, 91, 98,
2816 0, 222, 223, 225, 301, 0, 280, 0, 0, 0,
2817 0, 91, 269, 259, 260, 6, 7, 8, 9, 10,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002818 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2819 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2820 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2821 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2822 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002823 0, 268, 255, 91, 272, 0, 298, 204, 201, 200,
2824 202, 203, 205, 208, 0, 130, 0, 0, 0, 113,
2825 135, 139, 0, 144, 138, 192, 194, 190, 115, 116,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002826 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002827 0, 0, 0, 188, 234, 0, 0, 286, 279, 262,
2828 261, 0, 0, 72, 76, 71, 75, 70, 74, 69,
2829 73, 77, 78, 0, 0, 26, 27, 28, 29, 30,
2830 31, 32, 33, 34, 35, 0, 50, 51, 46, 47,
2831 48, 49, 36, 37, 38, 39, 40, 41, 42, 43,
2832 44, 45, 0, 101, 101, 307, 0, 0, 296, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002833 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002834 0, 0, 0, 0, 0, 206, 0, 0, 0, 0,
2835 0, 134, 143, 141, 0, 106, 106, 106, 160, 161,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002836 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2837 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002838 0, 0, 0, 0, 156, 155, 106, 220, 237, 238,
2839 239, 244, 240, 241, 242, 243, 235, 0, 246, 251,
2840 250, 252, 0, 263, 0, 0, 0, 0, 0, 303,
2841 0, 305, 300, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002842 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002843 207, 112, 112, 137, 0, 140, 0, 131, 0, 193,
2844 195, 191, 0, 0, 0, 0, 0, 0, 0, 146,
2845 176, 0, 0, 0, 150, 0, 147, 0, 0, 0,
2846 0, 0, 189, 219, 213, 216, 217, 0, 236, 0,
2847 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2848 310, 0, 0, 0, 290, 293, 0, 0, 291, 292,
2849 0, 0, 0, 287, 288, 0, 308, 0, 132, 133,
2850 136, 142, 0, 0, 108, 106, 0, 0, 300, 0,
2851 0, 0, 0, 0, 145, 135, 114, 0, 148, 149,
2852 0, 0, 0, 0, 0, 212, 214, 0, 104, 0,
2853 245, 0, 0, 278, 0, 0, 101, 102, 101, 275,
2854 299, 0, 0, 0, 0, 0, 281, 282, 283, 278,
2855 0, 103, 109, 107, 0, 0, 0, 0, 0, 0,
2856 0, 175, 152, 0, 0, 0, 0, 0, 0, 218,
2857 215, 105, 99, 0, 0, 0, 277, 0, 284, 285,
2858 0, 304, 306, 0, 0, 0, 289, 294, 295, 0,
2859 309, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2860 0, 0, 0, 0, 0, 221, 247, 0, 0, 0,
2861 276, 273, 0, 297, 0, 0, 0, 172, 0, 0,
2862 166, 167, 168, 171, 163, 100, 0, 266, 0, 0,
2863 0, 274, 169, 170, 0, 0, 0, 264, 0, 265,
2864 0, 0, 165, 173, 174, 0, 0, 0, 0, 0,
2865 0, 271, 0, 0, 270, 267
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002866};
2867
Chandler Carruth02202192007-08-04 01:56:21 +00002868/* YYDEFGOTO[NTERM-NUM]. */
2869static const yytype_int16 yydefgoto[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002870{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002871 -1, 94, 312, 329, 330, 331, 255, 272, 332, 333,
2872 219, 220, 243, 221, 25, 15, 63, 555, 359, 454,
2873 522, 389, 455, 95, 96, 222, 98, 99, 202, 304,
2874 400, 348, 401, 104, 1, 2, 3, 336, 307, 305,
2875 306, 55, 190, 42, 72, 194, 100, 476, 415, 416,
2876 417, 64, 113, 16, 30, 36, 17, 53, 18, 28,
2877 108, 419, 349, 101, 351, 489, 19, 32, 33, 181,
2878 182, 579, 66, 278, 526, 527, 183, 184, 430, 185,
2879 186
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002880};
2881
2882/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2883 STATE-NUM. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002884#define YYPACT_NINF -542
Chandler Carruth02202192007-08-04 01:56:21 +00002885static const yytype_int16 yypact[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002886{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002887 -542, 13, 162, 567, -542, -542, -542, -542, -542, -542,
2888 -542, -542, -542, -542, 83, -542, 19, -542, -542, -14,
2889 -542, -542, 50, -87, 87, 233, 27, -542, 123, 141,
2890 175, -542, -542, 98, -542, -542, -542, -542, 33, 40,
2891 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156,
2892 -542, -542, -542, -542, -542, -542, 221, -542, -542, -542,
2893 -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226,
2894 227, 235, -542, -542, -542, -542, 81, -542, -542, -542,
2895 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2896 256, 257, 4, 15, -542, -542, 108, -542, -542, 12,
2897 -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542,
2898 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116,
2899 479, 175, -542, -542, -542, -542, -542, -542, -542, -542,
2900 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2901 -542, -542, -542, -542, -542, -542, -542, -542, -542, 355,
2902 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306,
2903 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542,
2904 -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306,
2905 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542,
2906 -542, -542, -542, -542, -13, -542, 110, 111, 75, -542,
2907 -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208,
2908 266, 210, 267, 212, 268, 230, 277, 275, 278, 246,
2909 280, 279, 566, -542, -542, 136, 766, -542, -542, 81,
2910 -542, 766, 766, -542, -542, -542, -542, -542, -542, -542,
2911 -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542,
2912 -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542,
2913 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2914 -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147,
2915 148, 149, 151, 152, 158, 160, 766, 766, 766, 161,
2916 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27,
2917 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542,
2918 -542, -542, -542, -542, -542, -542, -542, -542, 355, 429,
2919 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184,
2920 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542,
2921 -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542,
2922 -542, -542, 193, -542, 194, 766, 766, 766, 7, -542,
2923 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306,
2924 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207,
2925 -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542,
2926 -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542,
2927 -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326,
2928 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337,
2929 -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306,
2930 -542, 223, 766, 224, -542, -542, 225, 234, -542, -542,
2931 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542,
2932 -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236,
2933 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542,
2934 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252,
2935 -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542,
2936 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306,
2937 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326,
2938 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542,
2939 -542, -542, 368, 402, 274, 276, 259, 287, -542, -542,
2940 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290,
2941 -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296,
2942 297, 299, 302, 303, 430, -542, -542, 414, 41, 425,
2943 -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326,
2944 -542, -542, -542, -542, -542, -542, 766, -542, 893, 144,
2945 448, -542, -542, -542, 314, 315, 316, -542, 331, -542,
2946 893, 766, -542, -542, -542, 464, 334, 180, 766, 481,
2947 482, -542, 766, 766, -542, -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002948};
2949
2950/* YYPGOTO[NTERM-NUM]. */
Chandler Carruth02202192007-08-04 01:56:21 +00002951static const yytype_int16 yypgoto[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002952{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002953 -542, -542, -542, 435, 439, 441, 191, 197, 442, 445,
2954 -119, -116, -541, -542, 478, 489, -107, -542, -267, 37,
2955 -542, -238, -542, -60, -542, -45, -542, -74, -51, -542,
2956 -101, 300, -252, 134, -542, -542, -542, -542, -542, -542,
2957 -542, 473, -542, -542, -542, -542, 8, -542, 46, -542,
2958 -542, 410, -542, -542, -542, -542, -542, -542, 518, -542,
2959 -542, -542, -528, 142, -90, -113, -542, 505, -542, -72,
2960 -542, -542, -542, -542, 97, 28, -542, -542, 70, -542,
2961 -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002962};
2963
2964/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2965 positive, shift that token. If negative, reduce the rule which
2966 number is the opposite. If zero, do what YYDEFACT says.
2967 If YYTABLE_NINF, syntax error. */
2968#define YYTABLE_NINF -180
Chandler Carruth02202192007-08-04 01:56:21 +00002969static const yytype_int16 yytable[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002970{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002971 97, 241, 227, 110, 242, 230, 223, 361, 197, 31,
2972 111, 26, 449, 4, 244, 204, 34, 578, 97, 201,
2973 74, 75, 426, 199, 77, 78, 79, 80, 81, 82,
2974 83, 84, 85, 86, 87, 428, 88, 20, 590, 21,
2975 275, 26, 31, 279, 280, 281, 282, 283, 284, 285,
2976 588, 233, 234, 235, 236, 237, 238, 239, 240, 205,
2977 206, 207, 596, 89, 427, 43, 289, 290, 390, 391,
2978 226, 463, 300, 226, 403, 405, 291, 427, 452, 468,
2979 74, 75, 301, 199, 77, 78, 79, 80, 81, 82,
2980 83, 84, 85, 86, 87, 420, 88, 20, 412, 21,
2981 448, 453, 38, 39, 40, 204, 273, 274, 226, 276,
2982 277, 226, 226, 226, 226, 226, 226, 226, 225, 463,
2983 20, 41, 21, 89, 201, 231, 300, 480, -139, 201,
2984 -112, 286, 287, 288, 226, 226, 384, 232, -139, 204,
2985 294, 352, 353, 112, 29, 463, 295, 299, 44, 35,
2986 467, 464, 303, 354, 233, 234, 235, 236, 237, 238,
2987 239, 240, -179, 463, 463, 54, 198, -112, 51, 90,
2988 52, 71, 91, 469, 513, 92, 204, 93, 200, 50,
2989 379, 105, 106, 107, 355, 67, 362, 5, 102, 103,
2990 188, 189, 68, 6, 292, 293, 372, 373, 374, 97,
2991 577, 308, 309, 7, 8, 9, 10, 11, 12, 13,
2992 356, -72, -72, -71, -71, -70, -70, 503, 69, 531,
2993 70, 532, 381, 382, 14, 109, 385, 357, 187, 90,
2994 191, 377, 91, -69, -69, 92, -113, 93, 298, 56,
2995 57, 58, 59, 60, 61, 62, 97, 378, 226, 310,
2996 311, 192, 433, 45, 435, 436, 437, 123, 124, 193,
2997 195, 196, 443, 203, 228, 423, 424, 425, 296, 297,
2998 -76, -75, -74, 431, 7, 8, 9, 10, 46, 12,
2999 47, -73, -79, 48, 313, -80, 314, 445, 446, 363,
3000 358, 337, 414, 458, 459, 460, 461, 462, 360, 364,
3001 365, 366, 367, 589, 368, 369, 470, 471, 472, 473,
3002 474, 370, 385, 371, 375, 380, 383, 376, 386, 387,
3003 226, 434, 226, 226, 226, 438, 439, 394, 466, 388,
3004 226, 444, 395, 396, 397, 406, 486, 398, 488, 407,
3005 408, 409, 492, 410, 411, 418, 421, 422, 429, 432,
3006 496, 497, 498, 440, 441, 504, 505, 450, 456, 442,
3007 447, 479, 511, 481, 335, 478, 457, 477, 350, 482,
3008 483, 484, 485, 350, 350, 487, 491, 493, 494, 502,
3009 536, 537, 538, 499, 226, 350, 501, 495, 518, 507,
3010 508, 524, 525, 509, 528, 529, 510, 514, 515, 512,
3011 516, 534, 500, 517, 452, 523, 544, 545, 546, 547,
3012 540, 530, 533, 549, 550, 551, 552, 535, 350, 543,
3013 560, 548, 475, 541, 542, 554, 556, 557, 350, 350,
3014 350, 427, 414, 558, 575, 576, 566, 568, 226, 241,
3015 564, 565, 242, 559, 561, 562, 563, 569, 226, 226,
3016 226, 567, 570, 571, 226, 572, 256, 257, 573, 574,
3017 241, 580, 582, 242, 581, 584, 583, 585, 586, 591,
3018 592, 593, 594, 553, 245, 246, 247, 248, 249, 250,
3019 251, 252, 253, 254, 595, 598, 587, 599, 226, 233,
3020 234, 235, 236, 237, 238, 239, 240, 350, 350, 350,
3021 176, 597, 602, 603, 177, 350, 178, 179, 601, 392,
3022 180, 65, 604, 605, 49, 521, 393, 73, 224, 350,
3023 350, 27, 334, 520, 37, 600, 490, 539, 506, 0,
3024 0, 0, 0, 0, 74, 75, 0, 199, 208, 209,
3025 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
3026 88, 20, 0, 21, 258, 259, 260, 261, 262, 263,
3027 264, 265, 266, 267, 268, 269, 270, 271, 350, 0,
3028 350, 74, 75, 0, 350, 0, 0, 89, 0, 0,
3029 0, 0, 350, 350, 350, 0, 0, -82, 20, 20,
3030 21, 21, 315, 0, 0, 0, 0, 0, 6, -82,
3031 -82, 0, 0, 0, 316, 317, 0, 0, -82, -82,
3032 -82, -82, -82, -82, -82, 0, 0, -82, 22, 0,
3033 0, 0, 0, 350, 350, 23, 350, 350, 0, 24,
3034 0, 0, 0, 350, 0, 0, 0, 0, 0, 0,
3035 0, 0, 350, 0, 0, 125, 126, 127, 128, 129,
3036 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
3037 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
3038 319, 0, 0, 0, 0, 0, 320, 350, 321, 0,
3039 322, 323, 324, 90, 0, 0, 91, 0, 0, 92,
3040 0, 93, 404, 0, 0, 0, 0, 0, 0, 0,
3041 0, 0, 0, 0, 0, 163, 164, 165, 166, 167,
3042 168, 169, 170, 171, 172, 173, 174, 175, 350, 0,
3043 0, 0, 0, 325, 0, 0, 326, 0, 327, 0,
3044 0, 328, 0, 350, 0, 0, 0, 0, 0, 0,
3045 350, 0, 0, 0, 350, 350, 74, 75, 0, 199,
3046 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
3047 218, 0, 88, 20, 0, 21, 0, 0, 0, 338,
3048 339, 74, 75, 340, 0, 0, 0, 0, 0, 0,
3049 0, 0, 0, 0, 0, 0, 0, 0, 20, 89,
3050 21, 0, 341, 342, 343, 0, 0, 0, 0, 0,
3051 0, 0, 0, 0, 344, 345, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003052 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003053 0, 0, 0, 0, 0, 0, 0, 346, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003054 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003055 0, 0, 0, 0, 0, 125, 126, 127, 128, 129,
3056 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
3057 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003058 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
3059 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003060 0, 0, 0, 0, 0, 90, 338, 339, 91, 0,
3061 340, 92, 0, 93, 465, 163, 164, 165, 166, 167,
3062 168, 169, 170, 171, 172, 173, 174, 175, 0, 341,
3063 342, 343, 0, 0, 0, 0, 347, 0, 0, 0,
3064 0, 344, 345, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003065 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003066 0, 0, 0, 0, 346, 0, 0, 0, 0, 0,
3067 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3068 0, 0, 125, 126, 127, 128, 129, 130, 131, 132,
3069 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
3070 143, 144, 145, 146, 147, 148, 318, 319, 0, 0,
3071 0, 0, 0, 320, 0, 321, 0, 322, 323, 324,
3072 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3073 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3074 0, 0, 163, 164, 165, 166, 167, 168, 169, 170,
3075 171, 172, 173, 174, 175, 0, 0, 0, 0, 0,
3076 0, 74, 75, 347, 199, 77, 78, 79, 80, 81,
3077 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
3078 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3079 0, 0, 0, 302, 0, 0, 0, 0, 0, 0,
3080 0, 0, 74, 75, 89, 199, 208, 209, 210, 211,
3081 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3082 0, 21, 74, 75, 0, 199, 77, 78, 79, 80,
3083 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3084 0, 21, 0, 0, 0, 89, 0, 0, 0, 0,
3085 0, 0, 0, 0, 413, 0, 0, 0, 0, 0,
3086 0, 0, 0, 74, 75, 89, 199, 77, 78, 79,
3087 80, 81, 82, 83, 84, 85, 86, 87, 0, 88,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003088 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003089 0, 0, 0, 0, 0, 451, 0, 0, 0, 0,
3090 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
3091 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
3092 74, 75, 0, 199, 77, 78, 79, 80, 81, 82,
3093 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003094 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003095 0, 90, 519, 0, 91, 0, 399, 92, 0, 93,
3096 0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
3097 0, 90, 0, 0, 91, 0, 0, 92, 0, 93,
3098 74, 75, 0, 76, 77, 78, 79, 80, 81, 82,
3099 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
3100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3101 0, 0, 90, 0, 0, 91, 0, 0, 92, 0,
3102 93, 74, 75, 89, 199, 77, 78, 79, 80, 81,
3103 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
3104 21, 74, 75, 0, 199, 208, 209, 210, 211, 212,
3105 213, 214, 215, 216, 217, 218, 0, 88, 20, 0,
3106 21, 0, 0, 0, 89, 0, 0, 0, 0, 90,
3107 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3108 0, 0, 74, 75, 89, 229, 77, 78, 79, 80,
3109 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3110 0, 21, 74, 75, 0, 199, 208, 209, 210, 211,
3111 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3112 0, 21, 0, 0, 0, 89, 0, 0, 0, 90,
3113 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3114 0, 0, 0, 0, 0, 89, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003117 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003119 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003122 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
3123 0, 90, 0, 0, 91, 0, 0, 92, 115, 93,
3124 0, 0, 0, 0, 0, 0, 0, 0, 116, 117,
3125 0, 90, 0, 0, 91, 0, 0, 92, 0, 402,
3126 0, 118, 119, 120, 121, 122, 123, 124, 125, 126,
3127 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3128 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
3129 147, 148, 149, 150, 151, 152, 153, 0, 0, 154,
3130 155, 156, 157, 158, 159, 160, 161, 162, 0, 0,
3131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3132 0, 0, 0, 0, 0, 0, 0, 0, 163, 164,
3133 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
3134 175
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003135};
3136
Chandler Carruth02202192007-08-04 01:56:21 +00003137static const yytype_int16 yycheck[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003138{
Reid Spencerd2920cd2007-03-21 17:27:53 +00003139 45, 120, 115, 63, 120, 118, 107, 274, 4, 23,
3140 29, 3, 161, 0, 121, 164, 30, 558, 63, 93,
3141 5, 6, 15, 8, 9, 10, 11, 12, 13, 14,
3142 15, 16, 17, 18, 19, 15, 21, 22, 579, 24,
3143 153, 33, 23, 156, 157, 158, 159, 160, 161, 162,
3144 578, 10, 11, 12, 13, 14, 15, 16, 17, 104,
3145 105, 106, 590, 48, 57, 152, 179, 180, 306, 307,
3146 115, 153, 153, 118, 326, 327, 183, 57, 34, 161,
3147 5, 6, 163, 8, 9, 10, 11, 12, 13, 14,
3148 15, 16, 17, 18, 19, 347, 21, 22, 336, 24,
3149 159, 57, 52, 53, 54, 164, 151, 152, 153, 154,
3150 155, 156, 157, 158, 159, 160, 161, 162, 110, 153,
3151 22, 71, 24, 48, 198, 9, 153, 161, 153, 203,
3152 155, 176, 177, 178, 179, 180, 163, 21, 163, 164,
3153 153, 231, 232, 162, 61, 153, 159, 198, 61, 163,
3154 402, 159, 203, 243, 10, 11, 12, 13, 14, 15,
3155 16, 17, 0, 153, 153, 24, 162, 155, 45, 154,
3156 47, 157, 157, 163, 163, 160, 164, 162, 163, 152,
3157 293, 47, 48, 49, 244, 152, 276, 25, 32, 33,
3158 55, 56, 152, 31, 108, 109, 286, 287, 288, 244,
3159 159, 27, 28, 41, 42, 43, 44, 45, 46, 47,
3160 255, 3, 4, 3, 4, 3, 4, 455, 152, 486,
3161 152, 488, 296, 297, 62, 4, 300, 272, 24, 154,
3162 4, 291, 157, 3, 4, 160, 155, 162, 163, 64,
3163 65, 66, 67, 68, 69, 70, 291, 292, 293, 3,
3164 4, 24, 365, 20, 367, 368, 369, 77, 78, 24,
3165 4, 4, 375, 155, 59, 355, 356, 357, 158, 158,
3166 4, 4, 4, 363, 41, 42, 43, 44, 45, 46,
3167 47, 4, 7, 50, 4, 7, 7, 377, 378, 157,
3168 153, 155, 337, 394, 395, 396, 397, 398, 153, 153,
3169 153, 153, 153, 159, 153, 153, 407, 408, 409, 410,
3170 411, 153, 386, 153, 153, 24, 161, 36, 153, 156,
3171 365, 366, 367, 368, 369, 370, 371, 155, 402, 153,
3172 375, 376, 155, 155, 155, 24, 426, 155, 428, 155,
3173 155, 155, 432, 155, 155, 63, 153, 153, 153, 157,
3174 440, 441, 442, 153, 153, 456, 457, 161, 155, 153,
3175 153, 24, 463, 21, 222, 156, 155, 153, 226, 21,
3176 155, 153, 153, 231, 232, 4, 153, 153, 153, 4,
3177 493, 494, 495, 155, 429, 243, 24, 153, 36, 153,
3178 153, 481, 482, 153, 484, 485, 153, 153, 153, 161,
3179 153, 491, 447, 153, 34, 153, 507, 508, 509, 510,
3180 500, 153, 153, 514, 515, 516, 517, 153, 276, 156,
3181 533, 161, 414, 153, 153, 57, 24, 153, 286, 287,
3182 288, 57, 477, 157, 4, 21, 153, 153, 483, 558,
3183 541, 542, 558, 156, 159, 535, 156, 153, 493, 494,
3184 495, 156, 156, 156, 499, 156, 27, 28, 156, 156,
3185 579, 36, 156, 579, 159, 566, 156, 568, 569, 21,
3186 156, 156, 156, 518, 119, 120, 121, 122, 123, 124,
3187 125, 126, 127, 128, 153, 21, 576, 153, 533, 10,
3188 11, 12, 13, 14, 15, 16, 17, 355, 356, 357,
3189 65, 591, 21, 21, 65, 363, 65, 65, 598, 318,
3190 65, 33, 602, 603, 25, 478, 319, 44, 108, 377,
3191 378, 3, 222, 477, 19, 597, 429, 499, 458, -1,
3192 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
3193 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3194 21, 22, -1, 24, 125, 126, 127, 128, 129, 130,
3195 131, 132, 133, 134, 135, 136, 137, 138, 426, -1,
3196 428, 5, 6, -1, 432, -1, -1, 48, -1, -1,
3197 -1, -1, 440, 441, 442, -1, -1, 20, 22, 22,
3198 24, 24, 26, -1, -1, -1, -1, -1, 31, 32,
3199 33, -1, -1, -1, 38, 39, -1, -1, 41, 42,
3200 43, 44, 45, 46, 47, -1, -1, 50, 51, -1,
3201 -1, -1, -1, 481, 482, 58, 484, 485, -1, 62,
3202 -1, -1, -1, 491, -1, -1, -1, -1, -1, -1,
3203 -1, -1, 500, -1, -1, 79, 80, 81, 82, 83,
3204 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3205 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3206 104, -1, -1, -1, -1, -1, 110, 535, 112, -1,
3207 114, 115, 116, 154, -1, -1, 157, -1, -1, 160,
3208 -1, 162, 163, -1, -1, -1, -1, -1, -1, -1,
3209 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
3210 144, 145, 146, 147, 148, 149, 150, 151, 576, -1,
3211 -1, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3212 -1, 165, -1, 591, -1, -1, -1, -1, -1, -1,
3213 598, -1, -1, -1, 602, 603, 5, 6, -1, 8,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003214 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003215 19, -1, 21, 22, -1, 24, -1, -1, -1, 3,
3216 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
3217 -1, -1, -1, -1, -1, -1, -1, -1, 22, 48,
3218 24, -1, 26, 27, 28, -1, -1, -1, -1, -1,
3219 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003220 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3221 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
3222 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3223 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
3224 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3225 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3226 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
3227 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003228 -1, -1, -1, -1, -1, 154, 3, 4, 157, -1,
3229 7, 160, -1, 162, 163, 139, 140, 141, 142, 143,
3230 144, 145, 146, 147, 148, 149, 150, 151, -1, 26,
3231 27, 28, -1, -1, -1, -1, 160, -1, -1, -1,
3232 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003233 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003234 -1, -1, -1, -1, 61, -1, -1, -1, -1, -1,
3235 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3236 -1, -1, 79, 80, 81, 82, 83, 84, 85, 86,
3237 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
3238 97, 98, 99, 100, 101, 102, 103, 104, -1, -1,
3239 -1, -1, -1, 110, -1, 112, -1, 114, 115, 116,
3240 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3241 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3242 -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
3243 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
3244 -1, 5, 6, 160, 8, 9, 10, 11, 12, 13,
3245 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3246 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3247 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
3248 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003249 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003250 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3251 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3252 -1, 24, -1, -1, -1, 48, -1, -1, -1, -1,
3253 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
3254 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003255 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
3256 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003257 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
3258 -1, -1, -1, -1, -1, -1, 48, -1, -1, -1,
3259 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3260 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3261 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
3262 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3263 -1, 154, 37, -1, 157, -1, 159, 160, -1, 162,
3264 -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003265 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003266 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3267 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003268 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003269 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003270 162, 5, 6, 48, 8, 9, 10, 11, 12, 13,
3271 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3272 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
3273 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3274 24, -1, -1, -1, 48, -1, -1, -1, -1, 154,
3275 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3276 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
3277 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3278 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3279 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3280 -1, 24, -1, -1, -1, 48, -1, -1, -1, 154,
3281 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3282 -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003283 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3284 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003285 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003287 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003290 -1, -1, -1, -1, 35, -1, -1, -1, -1, -1,
3291 -1, 154, -1, -1, 157, -1, -1, 160, 49, 162,
3292 -1, -1, -1, -1, -1, -1, -1, -1, 59, 60,
3293 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3294 -1, 72, 73, 74, 75, 76, 77, 78, 79, 80,
3295 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
3296 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
3297 101, 102, 103, 104, 105, 106, 107, -1, -1, 110,
3298 111, 112, 113, 114, 115, 116, 117, 118, -1, -1,
3299 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3300 -1, -1, -1, -1, -1, -1, -1, -1, 139, 140,
3301 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
3302 151
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003303};
3304
3305/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
3306 symbol of state STATE-NUM. */
Chandler Carruth02202192007-08-04 01:56:21 +00003307static const yytype_uint8 yystos[] =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003308{
3309 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003310 44, 45, 46, 47, 62, 181, 219, 222, 224, 232,
3311 22, 24, 51, 58, 62, 180, 212, 224, 225, 61,
3312 220, 23, 233, 234, 30, 163, 221, 233, 52, 53,
3313 54, 71, 209, 152, 61, 20, 45, 47, 50, 181,
3314 152, 45, 47, 223, 24, 207, 64, 65, 66, 67,
3315 68, 69, 70, 182, 217, 180, 238, 152, 152, 152,
3316 152, 157, 210, 207, 5, 6, 8, 9, 10, 11,
3317 12, 13, 14, 15, 16, 17, 18, 19, 21, 48,
3318 154, 157, 160, 162, 167, 189, 190, 191, 192, 193,
3319 212, 229, 32, 33, 199, 199, 199, 199, 226, 4,
3320 189, 29, 162, 218, 35, 49, 59, 60, 72, 73,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003321 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
3322 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3323 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3324 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
3325 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
3326 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003327 175, 235, 236, 242, 243, 245, 246, 24, 55, 56,
3328 208, 4, 24, 24, 211, 4, 4, 4, 162, 8,
3329 163, 193, 194, 155, 164, 191, 191, 191, 9, 10,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003330 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003331 177, 179, 191, 196, 217, 212, 191, 231, 59, 8,
3332 231, 9, 21, 10, 11, 12, 13, 14, 15, 16,
3333 17, 176, 177, 178, 182, 119, 120, 121, 122, 123,
3334 124, 125, 126, 127, 128, 172, 27, 28, 125, 126,
3335 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3336 137, 138, 173, 191, 191, 231, 191, 191, 239, 231,
3337 231, 231, 231, 231, 231, 231, 191, 191, 191, 231,
3338 231, 182, 108, 109, 153, 159, 158, 158, 163, 194,
3339 153, 163, 37, 194, 195, 205, 206, 204, 27, 28,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003340 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
3341 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003342 170, 171, 174, 175, 197, 229, 203, 155, 3, 4,
3343 7, 26, 27, 28, 38, 39, 61, 160, 197, 228,
3344 229, 230, 230, 230, 230, 189, 191, 191, 153, 184,
3345 153, 184, 230, 157, 153, 153, 153, 153, 153, 153,
3346 153, 153, 230, 230, 230, 153, 36, 189, 191, 231,
3347 24, 193, 193, 161, 163, 193, 153, 156, 153, 187,
3348 187, 187, 172, 173, 155, 155, 155, 155, 155, 159,
3349 196, 198, 162, 198, 163, 198, 24, 155, 155, 155,
3350 155, 155, 187, 37, 191, 214, 215, 216, 63, 227,
3351 198, 153, 153, 230, 230, 230, 15, 57, 15, 153,
3352 244, 230, 157, 231, 191, 231, 231, 231, 191, 191,
3353 153, 153, 153, 231, 191, 230, 230, 153, 159, 161,
3354 161, 37, 34, 57, 185, 188, 155, 155, 196, 196,
3355 196, 196, 196, 153, 159, 163, 193, 198, 161, 163,
3356 196, 196, 196, 196, 196, 212, 213, 153, 156, 24,
3357 161, 21, 21, 155, 153, 153, 230, 4, 230, 231,
3358 240, 153, 230, 153, 153, 153, 230, 230, 230, 155,
3359 191, 24, 4, 187, 196, 196, 244, 153, 153, 153,
3360 153, 196, 161, 163, 153, 153, 153, 153, 36, 37,
3361 214, 185, 186, 153, 230, 230, 240, 241, 230, 230,
3362 153, 184, 184, 153, 230, 153, 231, 231, 231, 241,
3363 230, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3364 196, 196, 196, 191, 57, 183, 24, 153, 157, 156,
3365 231, 159, 230, 156, 196, 196, 153, 156, 153, 153,
3366 156, 156, 156, 156, 156, 4, 21, 159, 178, 237,
3367 36, 159, 156, 156, 196, 196, 196, 230, 228, 159,
3368 178, 21, 156, 156, 156, 153, 228, 230, 21, 153,
3369 235, 230, 21, 21, 230, 230
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003370};
Reid Spencere7c3c602006-11-30 06:36:44 +00003371
3372#define yyerrok (yyerrstatus = 0)
3373#define yyclearin (yychar = YYEMPTY)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003374#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003375#define YYEOF 0
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003376
Reid Spencere7c3c602006-11-30 06:36:44 +00003377#define YYACCEPT goto yyacceptlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003378#define YYABORT goto yyabortlab
3379#define YYERROR goto yyerrorlab
3380
3381
3382/* Like YYERROR except do call yyerror. This remains here temporarily
3383 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003384 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003385
Reid Spencere7c3c602006-11-30 06:36:44 +00003386#define YYFAIL goto yyerrlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003387
Reid Spencere7c3c602006-11-30 06:36:44 +00003388#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003389
3390#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003391do \
3392 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003393 { \
3394 yychar = (Token); \
3395 yylval = (Value); \
3396 yytoken = YYTRANSLATE (yychar); \
Chandler Carruth02202192007-08-04 01:56:21 +00003397 YYPOPSTACK (1); \
Reid Spencere7c3c602006-11-30 06:36:44 +00003398 goto yybackup; \
3399 } \
3400 else \
Chandler Carruth02202192007-08-04 01:56:21 +00003401 { \
3402 yyerror (YY_("syntax error: cannot back up")); \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003403 YYERROR; \
3404 } \
Chandler Carruth02202192007-08-04 01:56:21 +00003405while (YYID (0))
3406
Reid Spencere7c3c602006-11-30 06:36:44 +00003407
Reid Spencere7c3c602006-11-30 06:36:44 +00003408#define YYTERROR 1
3409#define YYERRCODE 256
3410
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003411
Chandler Carruth02202192007-08-04 01:56:21 +00003412/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3413 If N is 0, then set CURRENT to the empty location which ends
3414 the previous symbol: RHS[0] (always defined). */
3415
3416#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003417#ifndef YYLLOC_DEFAULT
Chandler Carruth02202192007-08-04 01:56:21 +00003418# define YYLLOC_DEFAULT(Current, Rhs, N) \
3419 do \
3420 if (YYID (N)) \
3421 { \
3422 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3423 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3424 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3425 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3426 } \
3427 else \
3428 { \
3429 (Current).first_line = (Current).last_line = \
3430 YYRHSLOC (Rhs, 0).last_line; \
3431 (Current).first_column = (Current).last_column = \
3432 YYRHSLOC (Rhs, 0).last_column; \
3433 } \
3434 while (YYID (0))
Reid Spencere7c3c602006-11-30 06:36:44 +00003435#endif
3436
Chandler Carruth02202192007-08-04 01:56:21 +00003437
3438/* YY_LOCATION_PRINT -- Print the location on the stream.
3439 This macro was not mandated originally: define only if we know
3440 we won't break user code: when these are the locations we know. */
3441
3442#ifndef YY_LOCATION_PRINT
3443# if YYLTYPE_IS_TRIVIAL
3444# define YY_LOCATION_PRINT(File, Loc) \
3445 fprintf (File, "%d.%d-%d.%d", \
3446 (Loc).first_line, (Loc).first_column, \
3447 (Loc).last_line, (Loc).last_column)
3448# else
3449# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3450# endif
3451#endif
3452
3453
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003454/* YYLEX -- calling `yylex' with the right arguments. */
3455
Reid Spencer950bf602007-01-26 08:19:09 +00003456#ifdef YYLEX_PARAM
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003457# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer950bf602007-01-26 08:19:09 +00003458#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003459# define YYLEX yylex ()
Chris Lattner4227bdb2007-02-19 07:34:02 +00003460#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003461
3462/* Enable debugging if requested. */
3463#if YYDEBUG
3464
3465# ifndef YYFPRINTF
3466# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3467# define YYFPRINTF fprintf
3468# endif
3469
3470# define YYDPRINTF(Args) \
3471do { \
3472 if (yydebug) \
3473 YYFPRINTF Args; \
Chandler Carruth02202192007-08-04 01:56:21 +00003474} while (YYID (0))
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003475
Chandler Carruth02202192007-08-04 01:56:21 +00003476# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3477do { \
3478 if (yydebug) \
3479 { \
3480 YYFPRINTF (stderr, "%s ", Title); \
3481 yy_symbol_print (stderr, \
3482 Type, Value); \
3483 YYFPRINTF (stderr, "\n"); \
3484 } \
3485} while (YYID (0))
David Greene718fda32007-08-01 03:59:32 +00003486
Chandler Carruth02202192007-08-04 01:56:21 +00003487
3488/*--------------------------------.
3489| Print this symbol on YYOUTPUT. |
3490`--------------------------------*/
3491
3492/*ARGSUSED*/
3493#if (defined __STDC__ || defined __C99__FUNC__ \
3494 || defined __cplusplus || defined _MSC_VER)
3495static void
3496yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3497#else
3498static void
3499yy_symbol_value_print (yyoutput, yytype, yyvaluep)
3500 FILE *yyoutput;
3501 int yytype;
3502 YYSTYPE const * const yyvaluep;
3503#endif
3504{
3505 if (!yyvaluep)
3506 return;
3507# ifdef YYPRINT
3508 if (yytype < YYNTOKENS)
3509 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3510# else
3511 YYUSE (yyoutput);
3512# endif
3513 switch (yytype)
3514 {
3515 default:
3516 break;
3517 }
3518}
3519
3520
3521/*--------------------------------.
3522| Print this symbol on YYOUTPUT. |
3523`--------------------------------*/
3524
3525#if (defined __STDC__ || defined __C99__FUNC__ \
3526 || defined __cplusplus || defined _MSC_VER)
3527static void
3528yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
3529#else
3530static void
3531yy_symbol_print (yyoutput, yytype, yyvaluep)
3532 FILE *yyoutput;
3533 int yytype;
3534 YYSTYPE const * const yyvaluep;
3535#endif
3536{
3537 if (yytype < YYNTOKENS)
3538 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3539 else
3540 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3541
3542 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
3543 YYFPRINTF (yyoutput, ")");
3544}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003545
3546/*------------------------------------------------------------------.
3547| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3548| TOP (included). |
3549`------------------------------------------------------------------*/
3550
Chandler Carruth02202192007-08-04 01:56:21 +00003551#if (defined __STDC__ || defined __C99__FUNC__ \
3552 || defined __cplusplus || defined _MSC_VER)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003553static void
Chandler Carruth02202192007-08-04 01:56:21 +00003554yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003555#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003556static void
3557yy_stack_print (bottom, top)
Chandler Carruth02202192007-08-04 01:56:21 +00003558 yytype_int16 *bottom;
3559 yytype_int16 *top;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003560#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003561{
3562 YYFPRINTF (stderr, "Stack now");
Chandler Carruth02202192007-08-04 01:56:21 +00003563 for (; bottom <= top; ++bottom)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003564 YYFPRINTF (stderr, " %d", *bottom);
3565 YYFPRINTF (stderr, "\n");
3566}
3567
3568# define YY_STACK_PRINT(Bottom, Top) \
3569do { \
3570 if (yydebug) \
3571 yy_stack_print ((Bottom), (Top)); \
Chandler Carruth02202192007-08-04 01:56:21 +00003572} while (YYID (0))
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003573
3574
3575/*------------------------------------------------.
3576| Report that the YYRULE is going to be reduced. |
3577`------------------------------------------------*/
3578
Chandler Carruth02202192007-08-04 01:56:21 +00003579#if (defined __STDC__ || defined __C99__FUNC__ \
3580 || defined __cplusplus || defined _MSC_VER)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003581static void
Chandler Carruth02202192007-08-04 01:56:21 +00003582yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003583#else
3584static void
Chandler Carruth02202192007-08-04 01:56:21 +00003585yy_reduce_print (yyvsp, yyrule)
3586 YYSTYPE *yyvsp;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003587 int yyrule;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003588#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003589{
Chandler Carruth02202192007-08-04 01:56:21 +00003590 int yynrhs = yyr2[yyrule];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003591 int yyi;
Chandler Carruth02202192007-08-04 01:56:21 +00003592 unsigned long int yylno = yyrline[yyrule];
3593 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3594 yyrule - 1, yylno);
3595 /* The symbols being reduced. */
3596 for (yyi = 0; yyi < yynrhs; yyi++)
3597 {
3598 fprintf (stderr, " $%d = ", yyi + 1);
3599 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3600 &(yyvsp[(yyi + 1) - (yynrhs)])
3601 );
3602 fprintf (stderr, "\n");
3603 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003604}
Reid Spencer9d6565a2007-02-15 02:26:10 +00003605
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003606# define YY_REDUCE_PRINT(Rule) \
3607do { \
3608 if (yydebug) \
Chandler Carruth02202192007-08-04 01:56:21 +00003609 yy_reduce_print (yyvsp, Rule); \
3610} while (YYID (0))
Reid Spencer9d6565a2007-02-15 02:26:10 +00003611
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003612/* Nonzero means print parse trace. It is left uninitialized so that
3613 multiple parsers can coexist. */
3614int yydebug;
3615#else /* !YYDEBUG */
3616# define YYDPRINTF(Args)
Chandler Carruth02202192007-08-04 01:56:21 +00003617# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003618# define YY_STACK_PRINT(Bottom, Top)
3619# define YY_REDUCE_PRINT(Rule)
3620#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00003621
Reid Spencer9d6565a2007-02-15 02:26:10 +00003622
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003623/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003624#ifndef YYINITDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003625# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003626#endif
3627
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003628/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3629 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003630
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003631 Do not make this value too large; the results are undefined if
Chandler Carruth02202192007-08-04 01:56:21 +00003632 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003633 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003634
3635#ifndef YYMAXDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003636# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003637#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003638
Reid Spencere7c3c602006-11-30 06:36:44 +00003639
3640
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003641#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003642
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003643# ifndef yystrlen
Chandler Carruth02202192007-08-04 01:56:21 +00003644# if defined __GLIBC__ && defined _STRING_H
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003645# define yystrlen strlen
3646# else
3647/* Return the length of YYSTR. */
Chandler Carruth02202192007-08-04 01:56:21 +00003648#if (defined __STDC__ || defined __C99__FUNC__ \
3649 || defined __cplusplus || defined _MSC_VER)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003650static YYSIZE_T
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003651yystrlen (const char *yystr)
Chandler Carruth02202192007-08-04 01:56:21 +00003652#else
3653static YYSIZE_T
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003654yystrlen (yystr)
Chandler Carruth02202192007-08-04 01:56:21 +00003655 const char *yystr;
3656#endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003657{
Chandler Carruth02202192007-08-04 01:56:21 +00003658 YYSIZE_T yylen;
3659 for (yylen = 0; yystr[yylen]; yylen++)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003660 continue;
Chandler Carruth02202192007-08-04 01:56:21 +00003661 return yylen;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003662}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003663# endif
3664# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003665
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003666# ifndef yystpcpy
Chandler Carruth02202192007-08-04 01:56:21 +00003667# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003668# define yystpcpy stpcpy
3669# else
3670/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3671 YYDEST. */
Chandler Carruth02202192007-08-04 01:56:21 +00003672#if (defined __STDC__ || defined __C99__FUNC__ \
3673 || defined __cplusplus || defined _MSC_VER)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003674static char *
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003675yystpcpy (char *yydest, const char *yysrc)
Chandler Carruth02202192007-08-04 01:56:21 +00003676#else
3677static char *
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003678yystpcpy (yydest, yysrc)
Chandler Carruth02202192007-08-04 01:56:21 +00003679 char *yydest;
3680 const char *yysrc;
3681#endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003682{
Chandler Carruth02202192007-08-04 01:56:21 +00003683 char *yyd = yydest;
3684 const char *yys = yysrc;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003685
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003686 while ((*yyd++ = *yys++) != '\0')
3687 continue;
3688
3689 return yyd - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003690}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003691# endif
3692# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003693
Chandler Carruth02202192007-08-04 01:56:21 +00003694# ifndef yytnamerr
3695/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3696 quotes and backslashes, so that it's suitable for yyerror. The
3697 heuristic is that double-quoting is unnecessary unless the string
3698 contains an apostrophe, a comma, or backslash (other than
3699 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3700 null, do not copy; instead, return the length of what the result
3701 would have been. */
3702static YYSIZE_T
3703yytnamerr (char *yyres, const char *yystr)
3704{
3705 if (*yystr == '"')
3706 {
3707 YYSIZE_T yyn = 0;
3708 char const *yyp = yystr;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003709
Chandler Carruth02202192007-08-04 01:56:21 +00003710 for (;;)
3711 switch (*++yyp)
3712 {
3713 case '\'':
3714 case ',':
3715 goto do_not_strip_quotes;
3716
3717 case '\\':
3718 if (*++yyp != '\\')
3719 goto do_not_strip_quotes;
3720 /* Fall through. */
3721 default:
3722 if (yyres)
3723 yyres[yyn] = *yyp;
3724 yyn++;
3725 break;
3726
3727 case '"':
3728 if (yyres)
3729 yyres[yyn] = '\0';
3730 return yyn;
3731 }
3732 do_not_strip_quotes: ;
3733 }
3734
3735 if (! yyres)
3736 return yystrlen (yystr);
3737
3738 return yystpcpy (yyres, yystr) - yyres;
3739}
3740# endif
3741
3742/* Copy into YYRESULT an error message about the unexpected token
3743 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3744 including the terminating null byte. If YYRESULT is null, do not
3745 copy anything; just return the number of bytes that would be
3746 copied. As a special case, return 0 if an ordinary "syntax error"
3747 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3748 size calculation. */
3749static YYSIZE_T
3750yysyntax_error (char *yyresult, int yystate, int yychar)
3751{
3752 int yyn = yypact[yystate];
3753
3754 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3755 return 0;
3756 else
3757 {
3758 int yytype = YYTRANSLATE (yychar);
3759 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3760 YYSIZE_T yysize = yysize0;
3761 YYSIZE_T yysize1;
3762 int yysize_overflow = 0;
3763 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3764 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3765 int yyx;
3766
3767# if 0
3768 /* This is so xgettext sees the translatable formats that are
3769 constructed on the fly. */
3770 YY_("syntax error, unexpected %s");
3771 YY_("syntax error, unexpected %s, expecting %s");
3772 YY_("syntax error, unexpected %s, expecting %s or %s");
3773 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3774 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3775# endif
3776 char *yyfmt;
3777 char const *yyf;
3778 static char const yyunexpected[] = "syntax error, unexpected %s";
3779 static char const yyexpecting[] = ", expecting %s";
3780 static char const yyor[] = " or %s";
3781 char yyformat[sizeof yyunexpected
3782 + sizeof yyexpecting - 1
3783 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3784 * (sizeof yyor - 1))];
3785 char const *yyprefix = yyexpecting;
3786
3787 /* Start YYX at -YYN if negative to avoid negative indexes in
3788 YYCHECK. */
3789 int yyxbegin = yyn < 0 ? -yyn : 0;
3790
3791 /* Stay within bounds of both yycheck and yytname. */
3792 int yychecklim = YYLAST - yyn + 1;
3793 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3794 int yycount = 1;
3795
3796 yyarg[0] = yytname[yytype];
3797 yyfmt = yystpcpy (yyformat, yyunexpected);
3798
3799 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3800 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3801 {
3802 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3803 {
3804 yycount = 1;
3805 yysize = yysize0;
3806 yyformat[sizeof yyunexpected - 1] = '\0';
3807 break;
3808 }
3809 yyarg[yycount++] = yytname[yyx];
3810 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3811 yysize_overflow |= (yysize1 < yysize);
3812 yysize = yysize1;
3813 yyfmt = yystpcpy (yyfmt, yyprefix);
3814 yyprefix = yyor;
3815 }
3816
3817 yyf = YY_(yyformat);
3818 yysize1 = yysize + yystrlen (yyf);
3819 yysize_overflow |= (yysize1 < yysize);
3820 yysize = yysize1;
3821
3822 if (yysize_overflow)
3823 return YYSIZE_MAXIMUM;
3824
3825 if (yyresult)
3826 {
3827 /* Avoid sprintf, as that infringes on the user's name space.
3828 Don't have undefined behavior even if the translation
3829 produced a string with the wrong number of "%s"s. */
3830 char *yyp = yyresult;
3831 int yyi = 0;
3832 while ((*yyp = *yyf) != '\0')
3833 {
3834 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3835 {
3836 yyp += yytnamerr (yyp, yyarg[yyi++]);
3837 yyf += 2;
3838 }
3839 else
3840 {
3841 yyp++;
3842 yyf++;
3843 }
3844 }
3845 }
3846 return yysize;
3847 }
3848}
3849#endif /* YYERROR_VERBOSE */
Reid Spencer9d6565a2007-02-15 02:26:10 +00003850
3851
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003852/*-----------------------------------------------.
3853| Release the memory associated to this symbol. |
3854`-----------------------------------------------*/
3855
Chandler Carruth02202192007-08-04 01:56:21 +00003856/*ARGSUSED*/
3857#if (defined __STDC__ || defined __C99__FUNC__ \
3858 || defined __cplusplus || defined _MSC_VER)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003859static void
Chandler Carruth02202192007-08-04 01:56:21 +00003860yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003861#else
3862static void
Chandler Carruth02202192007-08-04 01:56:21 +00003863yydestruct (yymsg, yytype, yyvaluep)
3864 const char *yymsg;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003865 int yytype;
3866 YYSTYPE *yyvaluep;
3867#endif
3868{
Chandler Carruth02202192007-08-04 01:56:21 +00003869 YYUSE (yyvaluep);
3870
3871 if (!yymsg)
3872 yymsg = "Deleting";
3873 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003874
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003875 switch (yytype)
3876 {
3877
3878 default:
Chandler Carruth02202192007-08-04 01:56:21 +00003879 break;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003880 }
3881}
3882
3883
3884/* Prevent warnings from -Wmissing-prototypes. */
3885
3886#ifdef YYPARSE_PARAM
Chandler Carruth02202192007-08-04 01:56:21 +00003887#if defined __STDC__ || defined __cplusplus
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003888int yyparse (void *YYPARSE_PARAM);
Chandler Carruth02202192007-08-04 01:56:21 +00003889#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003890int yyparse ();
Chandler Carruth02202192007-08-04 01:56:21 +00003891#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003892#else /* ! YYPARSE_PARAM */
Chandler Carruth02202192007-08-04 01:56:21 +00003893#if defined __STDC__ || defined __cplusplus
Reid Spencere7c3c602006-11-30 06:36:44 +00003894int yyparse (void);
Chris Lattner4227bdb2007-02-19 07:34:02 +00003895#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003896int yyparse ();
3897#endif
3898#endif /* ! YYPARSE_PARAM */
3899
3900
3901
Chandler Carruth02202192007-08-04 01:56:21 +00003902/* The look-ahead symbol. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003903int yychar;
3904
Chandler Carruth02202192007-08-04 01:56:21 +00003905/* The semantic value of the look-ahead symbol. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003906YYSTYPE yylval;
3907
3908/* Number of syntax errors so far. */
3909int yynerrs;
3910
3911
3912
3913/*----------.
3914| yyparse. |
3915`----------*/
3916
3917#ifdef YYPARSE_PARAM
Chandler Carruth02202192007-08-04 01:56:21 +00003918#if (defined __STDC__ || defined __C99__FUNC__ \
3919 || defined __cplusplus || defined _MSC_VER)
3920int
3921yyparse (void *YYPARSE_PARAM)
3922#else
3923int
3924yyparse (YYPARSE_PARAM)
3925 void *YYPARSE_PARAM;
3926#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003927#else /* ! YYPARSE_PARAM */
Chandler Carruth02202192007-08-04 01:56:21 +00003928#if (defined __STDC__ || defined __C99__FUNC__ \
3929 || defined __cplusplus || defined _MSC_VER)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003930int
3931yyparse (void)
3932#else
3933int
3934yyparse ()
3935
3936#endif
3937#endif
3938{
3939
Chandler Carruth02202192007-08-04 01:56:21 +00003940 int yystate;
3941 int yyn;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003942 int yyresult;
3943 /* Number of tokens to shift before error messages enabled. */
3944 int yyerrstatus;
Chandler Carruth02202192007-08-04 01:56:21 +00003945 /* Look-ahead token as an internal (translated) token number. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003946 int yytoken = 0;
Chandler Carruth02202192007-08-04 01:56:21 +00003947#if YYERROR_VERBOSE
3948 /* Buffer for error messages, and its allocated size. */
3949 char yymsgbuf[128];
3950 char *yymsg = yymsgbuf;
3951 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3952#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003953
3954 /* Three stacks and their tools:
3955 `yyss': related to states,
3956 `yyvs': related to semantic values,
3957 `yyls': related to locations.
3958
3959 Refer to the stacks thru separate pointers, to allow yyoverflow
3960 to reallocate them elsewhere. */
3961
3962 /* The state stack. */
Chandler Carruth02202192007-08-04 01:56:21 +00003963 yytype_int16 yyssa[YYINITDEPTH];
3964 yytype_int16 *yyss = yyssa;
3965 yytype_int16 *yyssp;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003966
3967 /* The semantic value stack. */
3968 YYSTYPE yyvsa[YYINITDEPTH];
3969 YYSTYPE *yyvs = yyvsa;
Chandler Carruth02202192007-08-04 01:56:21 +00003970 YYSTYPE *yyvsp;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003971
3972
3973
Chandler Carruth02202192007-08-04 01:56:21 +00003974#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
Reid Spencere7c3c602006-11-30 06:36:44 +00003975
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003976 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003977
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003978 /* The variables used to return semantic value and location from the
3979 action routines. */
3980 YYSTYPE yyval;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003981
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003982
Chandler Carruth02202192007-08-04 01:56:21 +00003983 /* The number of symbols on the RHS of the reduced rule.
3984 Keep to zero when no symbol should be popped. */
3985 int yylen = 0;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003986
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003987 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003988
Reid Spencere7c3c602006-11-30 06:36:44 +00003989 yystate = 0;
3990 yyerrstatus = 0;
3991 yynerrs = 0;
3992 yychar = YYEMPTY; /* Cause a token to be read. */
3993
3994 /* Initialize stack pointers.
3995 Waste one element of value and location stack
3996 so that they stay on the same level as the state stack.
3997 The wasted elements are never initialized. */
3998
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003999 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00004000 yyvsp = yyvs;
4001
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004002 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00004003
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004004/*------------------------------------------------------------.
4005| yynewstate -- Push a new state, which is found in yystate. |
4006`------------------------------------------------------------*/
4007 yynewstate:
4008 /* In all cases, when you get here, the value and location stacks
Chandler Carruth02202192007-08-04 01:56:21 +00004009 have just been pushed. So pushing a state here evens the stacks. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004010 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00004011
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004012 yysetstate:
4013 *yyssp = yystate;
4014
4015 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00004016 {
4017 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004018 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00004019
4020#ifdef yyoverflow
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004021 {
Chandler Carruth02202192007-08-04 01:56:21 +00004022 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004023 these so that the &'s don't force the real ones into
4024 memory. */
4025 YYSTYPE *yyvs1 = yyvs;
Chandler Carruth02202192007-08-04 01:56:21 +00004026 yytype_int16 *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00004027
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004028
4029 /* Each stack pointer address is followed by the size of the
4030 data in use in that stack, in bytes. This used to be a
4031 conditional around just the two extra args, but that might
4032 be undefined if yyoverflow is a macro. */
Chandler Carruth02202192007-08-04 01:56:21 +00004033 yyoverflow (YY_("memory exhausted"),
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004034 &yyss1, yysize * sizeof (*yyssp),
4035 &yyvs1, yysize * sizeof (*yyvsp),
4036
4037 &yystacksize);
4038
4039 yyss = yyss1;
4040 yyvs = yyvs1;
4041 }
Reid Spencere7c3c602006-11-30 06:36:44 +00004042#else /* no yyoverflow */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004043# ifndef YYSTACK_RELOCATE
Chandler Carruth02202192007-08-04 01:56:21 +00004044 goto yyexhaustedlab;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004045# else
Reid Spencere7c3c602006-11-30 06:36:44 +00004046 /* Extend the stack our own way. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004047 if (YYMAXDEPTH <= yystacksize)
Chandler Carruth02202192007-08-04 01:56:21 +00004048 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00004049 yystacksize *= 2;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004050 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00004051 yystacksize = YYMAXDEPTH;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004052
4053 {
Chandler Carruth02202192007-08-04 01:56:21 +00004054 yytype_int16 *yyss1 = yyss;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004055 union yyalloc *yyptr =
4056 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
4057 if (! yyptr)
Chandler Carruth02202192007-08-04 01:56:21 +00004058 goto yyexhaustedlab;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004059 YYSTACK_RELOCATE (yyss);
4060 YYSTACK_RELOCATE (yyvs);
4061
4062# undef YYSTACK_RELOCATE
4063 if (yyss1 != yyssa)
4064 YYSTACK_FREE (yyss1);
4065 }
4066# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00004067#endif /* no yyoverflow */
4068
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004069 yyssp = yyss + yysize - 1;
4070 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00004071
4072
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004073 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
4074 (unsigned long int) yystacksize));
4075
4076 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00004077 YYABORT;
4078 }
4079
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004080 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00004081
4082 goto yybackup;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004083
4084/*-----------.
4085| yybackup. |
4086`-----------*/
4087yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00004088
Chandler Carruth02202192007-08-04 01:56:21 +00004089 /* Do appropriate processing given the current state. Read a
4090 look-ahead token if we need one and don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00004091
Chandler Carruth02202192007-08-04 01:56:21 +00004092 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencere7c3c602006-11-30 06:36:44 +00004093 yyn = yypact[yystate];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004094 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00004095 goto yydefault;
4096
Chandler Carruth02202192007-08-04 01:56:21 +00004097 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00004098
Chandler Carruth02202192007-08-04 01:56:21 +00004099 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00004100 if (yychar == YYEMPTY)
4101 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004102 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00004103 yychar = YYLEX;
4104 }
4105
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004106 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00004107 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004108 yychar = yytoken = YYEOF;
4109 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00004110 }
4111 else
4112 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004113 yytoken = YYTRANSLATE (yychar);
Chandler Carruth02202192007-08-04 01:56:21 +00004114 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00004115 }
4116
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004117 /* If the proper action on seeing token YYTOKEN is to reduce or to
4118 detect an error, take that action. */
4119 yyn += yytoken;
4120 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00004121 goto yydefault;
4122 yyn = yytable[yyn];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004123 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00004124 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004125 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00004126 goto yyerrlab;
4127 yyn = -yyn;
4128 goto yyreduce;
4129 }
4130
4131 if (yyn == YYFINAL)
4132 YYACCEPT;
4133
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004134 /* Count tokens shifted since error; after three, turn off error
4135 status. */
4136 if (yyerrstatus)
4137 yyerrstatus--;
Chris Lattnercf3d0612007-02-13 06:04:17 +00004138
Chandler Carruth02202192007-08-04 01:56:21 +00004139 /* Shift the look-ahead token. */
4140 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
4141
4142 /* Discard the shifted token unless it is eof. */
4143 if (yychar != YYEOF)
4144 yychar = YYEMPTY;
4145
Chris Lattnercf3d0612007-02-13 06:04:17 +00004146 yystate = yyn;
Chandler Carruth02202192007-08-04 01:56:21 +00004147 *++yyvsp = yylval;
4148
Reid Spencere7c3c602006-11-30 06:36:44 +00004149 goto yynewstate;
4150
Chris Lattner4227bdb2007-02-19 07:34:02 +00004151
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004152/*-----------------------------------------------------------.
4153| yydefault -- do the default action for the current state. |
4154`-----------------------------------------------------------*/
4155yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00004156 yyn = yydefact[yystate];
4157 if (yyn == 0)
4158 goto yyerrlab;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004159 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00004160
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004161
4162/*-----------------------------.
4163| yyreduce -- Do a reduction. |
4164`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00004165yyreduce:
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004166 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00004167 yylen = yyr2[yyn];
4168
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004169 /* If YYLEN is nonzero, implement the default value of the action:
4170 `$$ = $1'.
4171
4172 Otherwise, the following line sets YYVAL to garbage.
4173 This behavior is undocumented and Bison
4174 users should not rely upon it. Assigning to YYVAL
4175 unconditionally makes the parser a bit smaller, and it avoids a
4176 GCC warning that YYVAL may be used uninitialized. */
4177 yyval = yyvsp[1-yylen];
4178
4179
4180 YY_REDUCE_PRINT (yyn);
4181 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00004182 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004183 case 3:
Chandler Carruth02202192007-08-04 01:56:21 +00004184#line 1889 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004185 {
Chandler Carruth02202192007-08-04 01:56:21 +00004186 if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00004187 error("Value too large for type");
Chandler Carruth02202192007-08-04 01:56:21 +00004188 (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004189 ;}
4190 break;
4191
4192 case 5:
Chandler Carruth02202192007-08-04 01:56:21 +00004193#line 1898 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004194 {
Chandler Carruth02202192007-08-04 01:56:21 +00004195 if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00004196 error("Value too large for type");
Chandler Carruth02202192007-08-04 01:56:21 +00004197 (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004198 ;}
4199 break;
4200
4201 case 26:
Chandler Carruth02202192007-08-04 01:56:21 +00004202#line 1920 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4203 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004204 break;
4205
4206 case 27:
Chandler Carruth02202192007-08-04 01:56:21 +00004207#line 1920 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4208 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004209 break;
4210
4211 case 28:
Chandler Carruth02202192007-08-04 01:56:21 +00004212#line 1921 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4213 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004214 break;
4215
4216 case 29:
Chandler Carruth02202192007-08-04 01:56:21 +00004217#line 1921 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4218 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004219 break;
4220
4221 case 30:
Chandler Carruth02202192007-08-04 01:56:21 +00004222#line 1922 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4223 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004224 break;
4225
4226 case 31:
Chandler Carruth02202192007-08-04 01:56:21 +00004227#line 1922 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4228 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004229 break;
4230
4231 case 32:
Chandler Carruth02202192007-08-04 01:56:21 +00004232#line 1923 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4233 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004234 break;
4235
4236 case 33:
Chandler Carruth02202192007-08-04 01:56:21 +00004237#line 1923 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4238 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004239 break;
4240
4241 case 34:
Chandler Carruth02202192007-08-04 01:56:21 +00004242#line 1924 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4243 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004244 break;
4245
4246 case 35:
Chandler Carruth02202192007-08-04 01:56:21 +00004247#line 1924 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4248 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004249 break;
4250
4251 case 36:
Chandler Carruth02202192007-08-04 01:56:21 +00004252#line 1928 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4253 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004254 break;
4255
4256 case 37:
Chandler Carruth02202192007-08-04 01:56:21 +00004257#line 1928 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4258 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004259 break;
4260
4261 case 38:
Chandler Carruth02202192007-08-04 01:56:21 +00004262#line 1929 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4263 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004264 break;
4265
4266 case 39:
Chandler Carruth02202192007-08-04 01:56:21 +00004267#line 1929 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4268 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004269 break;
4270
4271 case 40:
Chandler Carruth02202192007-08-04 01:56:21 +00004272#line 1930 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4273 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004274 break;
4275
4276 case 41:
Chandler Carruth02202192007-08-04 01:56:21 +00004277#line 1930 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4278 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004279 break;
4280
4281 case 42:
Chandler Carruth02202192007-08-04 01:56:21 +00004282#line 1931 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4283 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004284 break;
4285
4286 case 43:
Chandler Carruth02202192007-08-04 01:56:21 +00004287#line 1931 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4288 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004289 break;
4290
4291 case 44:
Chandler Carruth02202192007-08-04 01:56:21 +00004292#line 1932 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4293 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004294 break;
4295
4296 case 45:
Chandler Carruth02202192007-08-04 01:56:21 +00004297#line 1932 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4298 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004299 break;
4300
4301 case 46:
Chandler Carruth02202192007-08-04 01:56:21 +00004302#line 1933 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4303 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004304 break;
4305
4306 case 47:
Chandler Carruth02202192007-08-04 01:56:21 +00004307#line 1933 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4308 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004309 break;
4310
4311 case 48:
Chandler Carruth02202192007-08-04 01:56:21 +00004312#line 1934 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4313 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004314 break;
4315
4316 case 49:
Chandler Carruth02202192007-08-04 01:56:21 +00004317#line 1934 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4318 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004319 break;
4320
4321 case 50:
Chandler Carruth02202192007-08-04 01:56:21 +00004322#line 1935 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4323 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004324 break;
4325
4326 case 51:
Chandler Carruth02202192007-08-04 01:56:21 +00004327#line 1936 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4328 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004329 break;
4330
4331 case 81:
Chandler Carruth02202192007-08-04 01:56:21 +00004332#line 1967 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004333 {
Chandler Carruth02202192007-08-04 01:56:21 +00004334 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004335 ;}
4336 break;
4337
4338 case 82:
Chandler Carruth02202192007-08-04 01:56:21 +00004339#line 1970 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004340 {
Chandler Carruth02202192007-08-04 01:56:21 +00004341 (yyval.StrVal) = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004342 ;}
4343 break;
4344
4345 case 83:
Chandler Carruth02202192007-08-04 01:56:21 +00004346#line 1975 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4347 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004348 break;
4349
4350 case 84:
Chandler Carruth02202192007-08-04 01:56:21 +00004351#line 1976 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4352 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004353 break;
4354
4355 case 85:
Chandler Carruth02202192007-08-04 01:56:21 +00004356#line 1977 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4357 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004358 break;
4359
4360 case 86:
Chandler Carruth02202192007-08-04 01:56:21 +00004361#line 1978 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4362 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004363 break;
4364
4365 case 87:
Chandler Carruth02202192007-08-04 01:56:21 +00004366#line 1979 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4367 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004368 break;
4369
4370 case 88:
Chandler Carruth02202192007-08-04 01:56:21 +00004371#line 1980 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4372 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004373 break;
4374
4375 case 89:
Chandler Carruth02202192007-08-04 01:56:21 +00004376#line 1981 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4377 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004378 break;
4379
4380 case 90:
Chandler Carruth02202192007-08-04 01:56:21 +00004381#line 1982 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4382 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004383 break;
4384
4385 case 91:
Chandler Carruth02202192007-08-04 01:56:21 +00004386#line 1986 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4387 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004388 break;
4389
Reid Spencere59f4932007-04-16 03:05:01 +00004390 case 92:
Chandler Carruth02202192007-08-04 01:56:21 +00004391#line 1987 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4392 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;}
Reid Spencere59f4932007-04-16 03:05:01 +00004393 break;
4394
4395 case 93:
Chandler Carruth02202192007-08-04 01:56:21 +00004396#line 1988 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4397 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::CSRet; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004398 break;
4399
4400 case 94:
Chandler Carruth02202192007-08-04 01:56:21 +00004401#line 1989 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4402 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Fast; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004403 break;
4404
4405 case 95:
Chandler Carruth02202192007-08-04 01:56:21 +00004406#line 1990 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4407 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Cold; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004408 break;
4409
4410 case 96:
Chandler Carruth02202192007-08-04 01:56:21 +00004411#line 1991 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4412 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_StdCall; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004413 break;
4414
4415 case 97:
Chandler Carruth02202192007-08-04 01:56:21 +00004416#line 1992 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4417 { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_FastCall; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004418 break;
4419
4420 case 98:
Chandler Carruth02202192007-08-04 01:56:21 +00004421#line 1993 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004422 {
Chandler Carruth02202192007-08-04 01:56:21 +00004423 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004424 error("Calling conv too large");
Chandler Carruth02202192007-08-04 01:56:21 +00004425 (yyval.UIntVal) = lastCallingConv = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004426 ;}
4427 break;
4428
4429 case 99:
Chandler Carruth02202192007-08-04 01:56:21 +00004430#line 2003 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4431 { (yyval.UIntVal) = 0; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004432 break;
4433
4434 case 100:
Chandler Carruth02202192007-08-04 01:56:21 +00004435#line 2004 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004436 {
Chandler Carruth02202192007-08-04 01:56:21 +00004437 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
4438 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004439 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004440 ;}
4441 break;
4442
4443 case 101:
Chandler Carruth02202192007-08-04 01:56:21 +00004444#line 2012 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4445 { (yyval.UIntVal) = 0; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004446 break;
4447
4448 case 102:
Chandler Carruth02202192007-08-04 01:56:21 +00004449#line 2013 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004450 {
Chandler Carruth02202192007-08-04 01:56:21 +00004451 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
4452 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004453 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004454 ;}
4455 break;
4456
4457 case 103:
Chandler Carruth02202192007-08-04 01:56:21 +00004458#line 2021 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004459 {
Chandler Carruth02202192007-08-04 01:56:21 +00004460 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
4461 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00004462 error("Invalid character in section name");
Chandler Carruth02202192007-08-04 01:56:21 +00004463 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004464 ;}
4465 break;
4466
4467 case 104:
Chandler Carruth02202192007-08-04 01:56:21 +00004468#line 2030 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4469 { (yyval.StrVal) = 0; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004470 break;
4471
4472 case 105:
Chandler Carruth02202192007-08-04 01:56:21 +00004473#line 2031 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
4474 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004475 break;
4476
4477 case 106:
Chandler Carruth02202192007-08-04 01:56:21 +00004478#line 2038 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004479 {;}
4480 break;
4481
Reid Spencere59f4932007-04-16 03:05:01 +00004482 case 107:
Chandler Carruth02202192007-08-04 01:56:21 +00004483#line 2039 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere59f4932007-04-16 03:05:01 +00004484 {;}
4485 break;
4486
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004487 case 108:
Chandler Carruth02202192007-08-04 01:56:21 +00004488#line 2043 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004489 {
Chandler Carruth02202192007-08-04 01:56:21 +00004490 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
4491 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004492 ;}
4493 break;
4494
4495 case 109:
Chandler Carruth02202192007-08-04 01:56:21 +00004496#line 2047 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004497 {
Chandler Carruth02202192007-08-04 01:56:21 +00004498 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004499 error("Alignment must be a power of two");
Chandler Carruth02202192007-08-04 01:56:21 +00004500 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004501
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004502 ;}
4503 break;
4504
4505 case 111:
Chandler Carruth02202192007-08-04 01:56:21 +00004506#line 2064 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004507 {
Chandler Carruth02202192007-08-04 01:56:21 +00004508 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4509 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004510 ;}
4511 break;
4512
4513 case 113:
Chandler Carruth02202192007-08-04 01:56:21 +00004514#line 2072 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004515 {
Chandler Carruth02202192007-08-04 01:56:21 +00004516 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4517 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004518 ;}
4519 break;
4520
4521 case 114:
Chandler Carruth02202192007-08-04 01:56:21 +00004522#line 2079 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004523 {
Reid Spencer950bf602007-01-26 08:19:09 +00004524 if (!UpRefs.empty())
Chandler Carruth02202192007-08-04 01:56:21 +00004525 error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).PAT)->getDescription());
4526 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004527 ;}
4528 break;
4529
4530 case 127:
Chandler Carruth02202192007-08-04 01:56:21 +00004531#line 2093 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004532 {
Chandler Carruth02202192007-08-04 01:56:21 +00004533 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
4534 (yyval.TypeVal).S.copy((yyvsp[(1) - (1)].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004535 ;}
4536 break;
4537
4538 case 128:
Chandler Carruth02202192007-08-04 01:56:21 +00004539#line 2097 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004540 {
Chandler Carruth02202192007-08-04 01:56:21 +00004541 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
4542 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004543 ;}
4544 break;
4545
4546 case 129:
Chandler Carruth02202192007-08-04 01:56:21 +00004547#line 2101 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004548 { // Named types are also simple types...
Chandler Carruth02202192007-08-04 01:56:21 +00004549 (yyval.TypeVal).S.copy(getTypeSign((yyvsp[(1) - (1)].ValIDVal)));
4550 const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
4551 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004552 ;}
4553 break;
4554
4555 case 130:
Chandler Carruth02202192007-08-04 01:56:21 +00004556#line 2106 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004557 { // Type UpReference
Chandler Carruth02202192007-08-04 01:56:21 +00004558 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004559 error("Value out of range");
4560 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chandler Carruth02202192007-08-04 01:56:21 +00004561 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4562 (yyval.TypeVal).PAT = new PATypeHolder(OT);
4563 (yyval.TypeVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00004564 UR_OUT("New Upreference!\n");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004565 ;}
4566 break;
4567
4568 case 131:
Chandler Carruth02202192007-08-04 01:56:21 +00004569#line 2115 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004570 { // Function derived type?
Chandler Carruth02202192007-08-04 01:56:21 +00004571 (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (4)].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004572 std::vector<const Type*> Params;
Chandler Carruth02202192007-08-04 01:56:21 +00004573 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
4574 E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004575 Params.push_back(I->PAT->get());
Chandler Carruth02202192007-08-04 01:56:21 +00004576 (yyval.TypeVal).S.add(I->S);
Reid Spencer52402b02007-01-02 05:45:11 +00004577 }
Reid Spencer950bf602007-01-26 08:19:09 +00004578 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4579 if (isVarArg) Params.pop_back();
4580
Reid Spencer7eea8ff2007-05-18 05:48:07 +00004581 ParamAttrsList *PAL = 0;
4582 if (lastCallingConv == OldCallingConv::CSRet) {
4583 ParamAttrsVector Attrs;
4584 ParamAttrsWithIndex PAWI;
4585 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
4586 Attrs.push_back(PAWI);
4587 PAL = ParamAttrsList::get(Attrs);
4588 }
4589
Reid Spencer7b5d4662007-04-09 06:16:21 +00004590 const FunctionType *FTy =
Chandler Carruth02202192007-08-04 01:56:21 +00004591 FunctionType::get((yyvsp[(1) - (4)].TypeVal).PAT->get(), Params, isVarArg, PAL);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004592
Chandler Carruth02202192007-08-04 01:56:21 +00004593 (yyval.TypeVal).PAT = new PATypeHolder( HandleUpRefs(FTy, (yyval.TypeVal).S) );
4594 delete (yyvsp[(1) - (4)].TypeVal).PAT; // Delete the return type handle
4595 delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004596 ;}
4597 break;
4598
4599 case 132:
Chandler Carruth02202192007-08-04 01:56:21 +00004600#line 2142 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004601 { // Sized array type?
Chandler Carruth02202192007-08-04 01:56:21 +00004602 (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S);
4603 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).PAT->get(),
4604 (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S));
4605 delete (yyvsp[(4) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004606 ;}
4607 break;
4608
4609 case 133:
Chandler Carruth02202192007-08-04 01:56:21 +00004610#line 2148 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004611 { // Vector type?
Chandler Carruth02202192007-08-04 01:56:21 +00004612 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).PAT->get();
4613 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Reid Spencerbb1fd572007-03-21 17:15:50 +00004614 error("Unsigned result not equal to signed result");
4615 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4616 error("Elements of a VectorType must be integer or floating point");
Chandler Carruth02202192007-08-04 01:56:21 +00004617 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Reid Spencerbb1fd572007-03-21 17:15:50 +00004618 error("VectorType length should be a power of 2");
Chandler Carruth02202192007-08-04 01:56:21 +00004619 (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S);
4620 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4621 (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S));
4622 delete (yyvsp[(4) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004623 ;}
4624 break;
4625
4626 case 134:
Chandler Carruth02202192007-08-04 01:56:21 +00004627#line 2161 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004628 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004629 std::vector<const Type*> Elements;
Chandler Carruth02202192007-08-04 01:56:21 +00004630 (yyval.TypeVal).S.makeComposite();
4631 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4632 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004633 Elements.push_back(I->PAT->get());
Chandler Carruth02202192007-08-04 01:56:21 +00004634 (yyval.TypeVal).S.add(I->S);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004635 }
Chandler Carruth02202192007-08-04 01:56:21 +00004636 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S));
4637 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004638 ;}
4639 break;
4640
4641 case 135:
Chandler Carruth02202192007-08-04 01:56:21 +00004642#line 2172 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004643 { // Empty structure type?
Chandler Carruth02202192007-08-04 01:56:21 +00004644 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
4645 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004646 ;}
4647 break;
4648
4649 case 136:
Chandler Carruth02202192007-08-04 01:56:21 +00004650#line 2176 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004651 { // Packed Structure type?
Chandler Carruth02202192007-08-04 01:56:21 +00004652 (yyval.TypeVal).S.makeComposite();
Reid Spencer950bf602007-01-26 08:19:09 +00004653 std::vector<const Type*> Elements;
Chandler Carruth02202192007-08-04 01:56:21 +00004654 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4655 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004656 Elements.push_back(I->PAT->get());
Chandler Carruth02202192007-08-04 01:56:21 +00004657 (yyval.TypeVal).S.add(I->S);
Reid Spencered96d1e2007-02-08 09:08:52 +00004658 delete I->PAT;
Reid Spencer52402b02007-01-02 05:45:11 +00004659 }
Chandler Carruth02202192007-08-04 01:56:21 +00004660 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
4661 (yyval.TypeVal).S));
4662 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004663 ;}
4664 break;
4665
4666 case 137:
Chandler Carruth02202192007-08-04 01:56:21 +00004667#line 2189 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004668 { // Empty packed structure type?
Chandler Carruth02202192007-08-04 01:56:21 +00004669 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
4670 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004671 ;}
4672 break;
4673
4674 case 138:
Chandler Carruth02202192007-08-04 01:56:21 +00004675#line 2193 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004676 { // Pointer type?
Chandler Carruth02202192007-08-04 01:56:21 +00004677 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004678 error("Cannot form a pointer to a basic block");
Chandler Carruth02202192007-08-04 01:56:21 +00004679 (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (2)].TypeVal).S);
4680 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).PAT->get()),
4681 (yyval.TypeVal).S));
4682 delete (yyvsp[(1) - (2)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004683 ;}
4684 break;
4685
4686 case 139:
Chandler Carruth02202192007-08-04 01:56:21 +00004687#line 2207 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004688 {
Chandler Carruth02202192007-08-04 01:56:21 +00004689 (yyval.TypeList) = new std::list<PATypeInfo>();
4690 (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004691 ;}
4692 break;
4693
4694 case 140:
Chandler Carruth02202192007-08-04 01:56:21 +00004695#line 2211 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004696 {
Chandler Carruth02202192007-08-04 01:56:21 +00004697 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004698 ;}
4699 break;
4700
4701 case 142:
Chandler Carruth02202192007-08-04 01:56:21 +00004702#line 2219 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004703 {
Reid Spencer950bf602007-01-26 08:19:09 +00004704 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004705 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004706 VoidTI.S.makeSignless();
Chandler Carruth02202192007-08-04 01:56:21 +00004707 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004708 ;}
4709 break;
4710
4711 case 143:
Chandler Carruth02202192007-08-04 01:56:21 +00004712#line 2225 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004713 {
Chandler Carruth02202192007-08-04 01:56:21 +00004714 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencer950bf602007-01-26 08:19:09 +00004715 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004716 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004717 VoidTI.S.makeSignless();
Chandler Carruth02202192007-08-04 01:56:21 +00004718 (yyval.TypeList)->push_back(VoidTI);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004719 ;}
4720 break;
4721
4722 case 144:
Chandler Carruth02202192007-08-04 01:56:21 +00004723#line 2232 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004724 {
Chandler Carruth02202192007-08-04 01:56:21 +00004725 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004726 ;}
4727 break;
4728
4729 case 145:
Chandler Carruth02202192007-08-04 01:56:21 +00004730#line 2244 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004731 { // Nonempty unsized arr
Chandler Carruth02202192007-08-04 01:56:21 +00004732 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004733 if (ATy == 0)
4734 error("Cannot make array constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004735 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004736 const Type *ETy = ATy->getElementType();
4737 int NumElements = ATy->getNumElements();
4738
4739 // Verify that we have the correct size...
Chandler Carruth02202192007-08-04 01:56:21 +00004740 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004741 error("Type mismatch: constant sized array initialized with " +
Chandler Carruth02202192007-08-04 01:56:21 +00004742 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004743 itostr(NumElements) + "");
4744
4745 // Verify all elements are correct type!
4746 std::vector<Constant*> Elems;
Chandler Carruth02202192007-08-04 01:56:21 +00004747 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4748 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004749 const Type* ValTy = C->getType();
4750 if (ETy != ValTy)
4751 error("Element #" + utostr(i) + " is not of type '" +
4752 ETy->getDescription() +"' as required!\nIt is of type '"+
4753 ValTy->getDescription() + "'");
4754 Elems.push_back(C);
4755 }
Chandler Carruth02202192007-08-04 01:56:21 +00004756 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
4757 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4758 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4759 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004760 ;}
4761 break;
4762
4763 case 146:
Chandler Carruth02202192007-08-04 01:56:21 +00004764#line 2274 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004765 {
Chandler Carruth02202192007-08-04 01:56:21 +00004766 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004767 if (ATy == 0)
4768 error("Cannot make array constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004769 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004770 int NumElements = ATy->getNumElements();
4771 if (NumElements != -1 && NumElements != 0)
4772 error("Type mismatch: constant sized array initialized with 0"
4773 " arguments, but has size of " + itostr(NumElements) +"");
Chandler Carruth02202192007-08-04 01:56:21 +00004774 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
4775 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4776 delete (yyvsp[(1) - (3)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004777 ;}
4778 break;
4779
4780 case 147:
Chandler Carruth02202192007-08-04 01:56:21 +00004781#line 2287 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004782 {
Chandler Carruth02202192007-08-04 01:56:21 +00004783 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004784 if (ATy == 0)
4785 error("Cannot make array constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004786 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004787 int NumElements = ATy->getNumElements();
4788 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4789 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4790 error("String arrays require type i8, not '" + ETy->getDescription() +
4791 "'");
Chandler Carruth02202192007-08-04 01:56:21 +00004792 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4793 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004794 error("Can't build string constant of size " +
Chandler Carruth02202192007-08-04 01:56:21 +00004795 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004796 itostr(NumElements) + "");
4797 std::vector<Constant*> Vals;
Chandler Carruth02202192007-08-04 01:56:21 +00004798 for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004799 Vals.push_back(ConstantInt::get(ETy, *C));
Chandler Carruth02202192007-08-04 01:56:21 +00004800 free((yyvsp[(3) - (3)].StrVal));
4801 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
4802 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4803 delete (yyvsp[(1) - (3)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004804 ;}
4805 break;
4806
4807 case 148:
Chandler Carruth02202192007-08-04 01:56:21 +00004808#line 2310 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004809 { // Nonempty unsized arr
Chandler Carruth02202192007-08-04 01:56:21 +00004810 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004811 if (PTy == 0)
4812 error("Cannot make packed constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004813 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004814 const Type *ETy = PTy->getElementType();
4815 int NumElements = PTy->getNumElements();
4816 // Verify that we have the correct size...
Chandler Carruth02202192007-08-04 01:56:21 +00004817 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004818 error("Type mismatch: constant sized packed initialized with " +
Chandler Carruth02202192007-08-04 01:56:21 +00004819 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004820 itostr(NumElements) + "");
4821 // Verify all elements are correct type!
4822 std::vector<Constant*> Elems;
Chandler Carruth02202192007-08-04 01:56:21 +00004823 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4824 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004825 const Type* ValTy = C->getType();
4826 if (ETy != ValTy)
4827 error("Element #" + utostr(i) + " is not of type '" +
4828 ETy->getDescription() +"' as required!\nIt is of type '"+
4829 ValTy->getDescription() + "'");
4830 Elems.push_back(C);
4831 }
Chandler Carruth02202192007-08-04 01:56:21 +00004832 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
4833 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4834 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4835 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004836 ;}
4837 break;
4838
4839 case 149:
Chandler Carruth02202192007-08-04 01:56:21 +00004840#line 2338 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004841 {
Chandler Carruth02202192007-08-04 01:56:21 +00004842 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004843 if (STy == 0)
4844 error("Cannot make struct constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004845 (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
4846 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004847 error("Illegal number of initializers for structure type");
4848
4849 // Check to ensure that constants are compatible with the type initializer!
4850 std::vector<Constant*> Fields;
Chandler Carruth02202192007-08-04 01:56:21 +00004851 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
4852 Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004853 if (C->getType() != STy->getElementType(i))
4854 error("Expected type '" + STy->getElementType(i)->getDescription() +
4855 "' for element #" + utostr(i) + " of structure initializer");
4856 Fields.push_back(C);
4857 }
Chandler Carruth02202192007-08-04 01:56:21 +00004858 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4859 (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
4860 delete (yyvsp[(1) - (4)].TypeVal).PAT;
4861 delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004862 ;}
4863 break;
4864
4865 case 150:
Chandler Carruth02202192007-08-04 01:56:21 +00004866#line 2360 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004867 {
Chandler Carruth02202192007-08-04 01:56:21 +00004868 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004869 if (STy == 0)
4870 error("Cannot make struct constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004871 (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004872 if (STy->getNumContainedTypes() != 0)
4873 error("Illegal number of initializers for structure type");
Chandler Carruth02202192007-08-04 01:56:21 +00004874 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4875 (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
4876 delete (yyvsp[(1) - (3)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004877 ;}
4878 break;
4879
4880 case 151:
Chandler Carruth02202192007-08-04 01:56:21 +00004881#line 2371 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004882 {
Chandler Carruth02202192007-08-04 01:56:21 +00004883 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004884 if (STy == 0)
4885 error("Cannot make packed struct constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004886 (yyvsp[(1) - (6)].TypeVal).PAT->get()->getDescription() + "'");
4887 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004888 error("Illegal number of initializers for packed structure type");
4889
4890 // Check to ensure that constants are compatible with the type initializer!
4891 std::vector<Constant*> Fields;
Chandler Carruth02202192007-08-04 01:56:21 +00004892 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
4893 Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004894 if (C->getType() != STy->getElementType(i))
4895 error("Expected type '" + STy->getElementType(i)->getDescription() +
4896 "' for element #" + utostr(i) + " of packed struct initializer");
4897 Fields.push_back(C);
4898 }
Chandler Carruth02202192007-08-04 01:56:21 +00004899 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
4900 (yyval.ConstVal).S.copy((yyvsp[(1) - (6)].TypeVal).S);
4901 delete (yyvsp[(1) - (6)].TypeVal).PAT;
4902 delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004903 ;}
4904 break;
4905
4906 case 152:
Chandler Carruth02202192007-08-04 01:56:21 +00004907#line 2393 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004908 {
Chandler Carruth02202192007-08-04 01:56:21 +00004909 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004910 if (STy == 0)
4911 error("Cannot make packed struct constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004912 (yyvsp[(1) - (5)].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004913 if (STy->getNumContainedTypes() != 0)
4914 error("Illegal number of initializers for packed structure type");
Chandler Carruth02202192007-08-04 01:56:21 +00004915 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
4916 (yyval.ConstVal).S.copy((yyvsp[(1) - (5)].TypeVal).S);
4917 delete (yyvsp[(1) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004918 ;}
4919 break;
4920
4921 case 153:
Chandler Carruth02202192007-08-04 01:56:21 +00004922#line 2404 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004923 {
Chandler Carruth02202192007-08-04 01:56:21 +00004924 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004925 if (PTy == 0)
4926 error("Cannot make null pointer constant with type: '" +
Chandler Carruth02202192007-08-04 01:56:21 +00004927 (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription() + "'");
4928 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
4929 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4930 delete (yyvsp[(1) - (2)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004931 ;}
4932 break;
4933
4934 case 154:
Chandler Carruth02202192007-08-04 01:56:21 +00004935#line 2413 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004936 {
Chandler Carruth02202192007-08-04 01:56:21 +00004937 (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).PAT->get());
4938 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4939 delete (yyvsp[(1) - (2)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004940 ;}
4941 break;
4942
4943 case 155:
Chandler Carruth02202192007-08-04 01:56:21 +00004944#line 2418 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004945 {
Chandler Carruth02202192007-08-04 01:56:21 +00004946 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004947 if (Ty == 0)
4948 error("Global const reference must be a pointer type, not" +
Chandler Carruth02202192007-08-04 01:56:21 +00004949 (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004950
4951 // ConstExprs can exist in the body of a function, thus creating
4952 // GlobalValues whenever they refer to a variable. Because we are in
4953 // the context of a function, getExistingValue will search the functions
4954 // symbol table instead of the module symbol table for the global symbol,
4955 // which throws things all off. To get around this, we just tell
4956 // getExistingValue that we are at global scope here.
4957 //
4958 Function *SavedCurFn = CurFun.CurrentFunction;
4959 CurFun.CurrentFunction = 0;
Chandler Carruth02202192007-08-04 01:56:21 +00004960 (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
4961 Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004962 CurFun.CurrentFunction = SavedCurFn;
4963
4964 // If this is an initializer for a constant pointer, which is referencing a
4965 // (currently) undefined variable, create a stub now that shall be replaced
4966 // in the future with the right type of variable.
4967 //
4968 if (V == 0) {
4969 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4970 const PointerType *PT = cast<PointerType>(Ty);
4971
4972 // First check to see if the forward references value is already created!
4973 PerModuleInfo::GlobalRefsType::iterator I =
Chandler Carruth02202192007-08-04 01:56:21 +00004974 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004975
4976 if (I != CurModule.GlobalRefs.end()) {
4977 V = I->second; // Placeholder already exists, use it...
Chandler Carruth02202192007-08-04 01:56:21 +00004978 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004979 } else {
4980 std::string Name;
Chandler Carruth02202192007-08-04 01:56:21 +00004981 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004982
4983 // Create the forward referenced global.
4984 GlobalValue *GV;
4985 if (const FunctionType *FTy =
4986 dyn_cast<FunctionType>(PT->getElementType())) {
4987 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4988 CurModule.CurrentModule);
4989 } else {
4990 GV = new GlobalVariable(PT->getElementType(), false,
4991 GlobalValue::ExternalLinkage, 0,
4992 Name, CurModule.CurrentModule);
4993 }
4994
4995 // Keep track of the fact that we have a forward ref to recycle it
Chandler Carruth02202192007-08-04 01:56:21 +00004996 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004997 V = GV;
4998 }
4999 }
Chandler Carruth02202192007-08-04 01:56:21 +00005000 (yyval.ConstVal).C = cast<GlobalValue>(V);
5001 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5002 delete (yyvsp[(1) - (2)].TypeVal).PAT; // Free the type handle
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005003 ;}
5004 break;
5005
5006 case 156:
Chandler Carruth02202192007-08-04 01:56:21 +00005007#line 2477 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005008 {
Chandler Carruth02202192007-08-04 01:56:21 +00005009 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005010 error("Mismatched types for constant expression");
Chandler Carruth02202192007-08-04 01:56:21 +00005011 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
5012 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5013 delete (yyvsp[(1) - (2)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005014 ;}
5015 break;
5016
5017 case 157:
Chandler Carruth02202192007-08-04 01:56:21 +00005018#line 2484 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005019 {
Chandler Carruth02202192007-08-04 01:56:21 +00005020 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005021 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
5022 error("Cannot create a null initialized value of this type");
Chandler Carruth02202192007-08-04 01:56:21 +00005023 (yyval.ConstVal).C = Constant::getNullValue(Ty);
5024 (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5025 delete (yyvsp[(1) - (2)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005026 ;}
5027 break;
5028
5029 case 158:
Chandler Carruth02202192007-08-04 01:56:21 +00005030#line 2492 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005031 { // integral constants
Chandler Carruth02202192007-08-04 01:56:21 +00005032 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
5033 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00005034 error("Constant value doesn't fit in type");
Chandler Carruth02202192007-08-04 01:56:21 +00005035 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
5036 (yyval.ConstVal).S.makeSigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005037 ;}
5038 break;
5039
5040 case 159:
Chandler Carruth02202192007-08-04 01:56:21 +00005041#line 2499 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005042 { // integral constants
Chandler Carruth02202192007-08-04 01:56:21 +00005043 const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
5044 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00005045 error("Constant value doesn't fit in type");
Chandler Carruth02202192007-08-04 01:56:21 +00005046 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
5047 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005048 ;}
5049 break;
5050
5051 case 160:
Chandler Carruth02202192007-08-04 01:56:21 +00005052#line 2506 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005053 { // Boolean constants
Chandler Carruth02202192007-08-04 01:56:21 +00005054 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
5055 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005056 ;}
5057 break;
5058
5059 case 161:
Chandler Carruth02202192007-08-04 01:56:21 +00005060#line 2510 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005061 { // Boolean constants
Chandler Carruth02202192007-08-04 01:56:21 +00005062 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
5063 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005064 ;}
5065 break;
5066
5067 case 162:
Chandler Carruth02202192007-08-04 01:56:21 +00005068#line 2514 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005069 { // Float & Double constants
Chandler Carruth02202192007-08-04 01:56:21 +00005070 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00005071 error("Floating point constant invalid for type");
Chandler Carruth02202192007-08-04 01:56:21 +00005072 (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, (yyvsp[(2) - (2)].FPVal));
5073 (yyval.ConstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005074 ;}
5075 break;
5076
5077 case 163:
Chandler Carruth02202192007-08-04 01:56:21 +00005078#line 2523 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005079 {
Chandler Carruth02202192007-08-04 01:56:21 +00005080 const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
5081 const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).PAT->get();
5082 Signedness SrcSign((yyvsp[(3) - (6)].ConstVal).S);
5083 Signedness DstSign((yyvsp[(5) - (6)].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00005084 if (!SrcTy->isFirstClassType())
5085 error("cast constant expression from a non-primitive type: '" +
5086 SrcTy->getDescription() + "'");
5087 if (!DstTy->isFirstClassType())
5088 error("cast constant expression to a non-primitive type: '" +
5089 DstTy->getDescription() + "'");
Chandler Carruth02202192007-08-04 01:56:21 +00005090 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign));
5091 (yyval.ConstVal).S.copy(DstSign);
5092 delete (yyvsp[(5) - (6)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005093 ;}
5094 break;
5095
5096 case 164:
Chandler Carruth02202192007-08-04 01:56:21 +00005097#line 2538 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005098 {
Chandler Carruth02202192007-08-04 01:56:21 +00005099 const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00005100 if (!isa<PointerType>(Ty))
5101 error("GetElementPtr requires a pointer operand");
5102
Reid Spencer950bf602007-01-26 08:19:09 +00005103 std::vector<Constant*> CIndices;
Chandler Carruth02202192007-08-04 01:56:21 +00005104 upgradeGEPCEIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00005105
Chandler Carruth02202192007-08-04 01:56:21 +00005106 delete (yyvsp[(4) - (5)].ValueList);
5107 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, &CIndices[0], CIndices.size());
5108 (yyval.ConstVal).S.copy(getElementSign((yyvsp[(3) - (5)].ConstVal), CIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005109 ;}
5110 break;
5111
5112 case 165:
Chandler Carruth02202192007-08-04 01:56:21 +00005113#line 2550 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005114 {
Chandler Carruth02202192007-08-04 01:56:21 +00005115 if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
5116 cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00005117 error("Select condition must be bool type");
Chandler Carruth02202192007-08-04 01:56:21 +00005118 if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005119 error("Select operand types must match");
Chandler Carruth02202192007-08-04 01:56:21 +00005120 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5121 (yyval.ConstVal).S.copy((yyvsp[(5) - (8)].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005122 ;}
5123 break;
5124
5125 case 166:
Chandler Carruth02202192007-08-04 01:56:21 +00005126#line 2559 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005127 {
Chandler Carruth02202192007-08-04 01:56:21 +00005128 const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5129 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005130 error("Binary operator types must match");
5131 // First, make sure we're dealing with the right opcode by upgrading from
5132 // obsolete versions.
Chandler Carruth02202192007-08-04 01:56:21 +00005133 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00005134
5135 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
5136 // To retain backward compatibility with these early compilers, we emit a
5137 // cast to the appropriate integer type automatically if we are in the
5138 // broken case. See PR424 for more information.
5139 if (!isa<PointerType>(Ty)) {
Chandler Carruth02202192007-08-04 01:56:21 +00005140 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00005141 } else {
5142 const Type *IntPtrTy = 0;
5143 switch (CurModule.CurrentModule->getPointerSize()) {
5144 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
5145 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
5146 default: error("invalid pointer binary constant expr");
5147 }
Chandler Carruth02202192007-08-04 01:56:21 +00005148 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
5149 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
5150 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
5151 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00005152 }
Chandler Carruth02202192007-08-04 01:56:21 +00005153 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005154 ;}
5155 break;
5156
5157 case 167:
Chandler Carruth02202192007-08-04 01:56:21 +00005158#line 2587 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005159 {
Chandler Carruth02202192007-08-04 01:56:21 +00005160 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5161 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005162 error("Logical operator types must match");
5163 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00005164 if (!isa<VectorType>(Ty) ||
5165 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005166 error("Logical operator requires integer operands");
5167 }
Chandler Carruth02202192007-08-04 01:56:21 +00005168 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
5169 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5170 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005171 ;}
5172 break;
5173
5174 case 168:
Chandler Carruth02202192007-08-04 01:56:21 +00005175#line 2600 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005176 {
Chandler Carruth02202192007-08-04 01:56:21 +00005177 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5178 if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005179 error("setcc operand types must match");
5180 unsigned short pred;
Chandler Carruth02202192007-08-04 01:56:21 +00005181 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
5182 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5183 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005184 ;}
5185 break;
5186
5187 case 169:
Chandler Carruth02202192007-08-04 01:56:21 +00005188#line 2609 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005189 {
Chandler Carruth02202192007-08-04 01:56:21 +00005190 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005191 error("icmp operand types must match");
Chandler Carruth02202192007-08-04 01:56:21 +00005192 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
5193 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005194 ;}
5195 break;
5196
5197 case 170:
Chandler Carruth02202192007-08-04 01:56:21 +00005198#line 2615 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005199 {
Chandler Carruth02202192007-08-04 01:56:21 +00005200 if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00005201 error("fcmp operand types must match");
Chandler Carruth02202192007-08-04 01:56:21 +00005202 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
5203 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005204 ;}
5205 break;
5206
5207 case 171:
Chandler Carruth02202192007-08-04 01:56:21 +00005208#line 2621 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005209 {
Chandler Carruth02202192007-08-04 01:56:21 +00005210 if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
5211 cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00005212 error("Shift count for shift constant must be unsigned byte");
Chandler Carruth02202192007-08-04 01:56:21 +00005213 const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
5214 if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00005215 error("Shift constant expression requires integer operand");
Chandler Carruth02202192007-08-04 01:56:21 +00005216 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[(5) - (6)].ConstVal).C, Ty);
5217 (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S), (yyvsp[(3) - (6)].ConstVal).C, ShiftAmt);
5218 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005219 ;}
5220 break;
5221
5222 case 172:
Chandler Carruth02202192007-08-04 01:56:21 +00005223#line 2632 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005224 {
Chandler Carruth02202192007-08-04 01:56:21 +00005225 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00005226 error("Invalid extractelement operands");
Chandler Carruth02202192007-08-04 01:56:21 +00005227 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
5228 (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005229 ;}
5230 break;
5231
5232 case 173:
Chandler Carruth02202192007-08-04 01:56:21 +00005233#line 2638 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005234 {
Chandler Carruth02202192007-08-04 01:56:21 +00005235 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00005236 error("Invalid insertelement operands");
Chandler Carruth02202192007-08-04 01:56:21 +00005237 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5238 (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005239 ;}
5240 break;
5241
5242 case 174:
Chandler Carruth02202192007-08-04 01:56:21 +00005243#line 2644 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005244 {
Chandler Carruth02202192007-08-04 01:56:21 +00005245 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00005246 error("Invalid shufflevector operands");
Chandler Carruth02202192007-08-04 01:56:21 +00005247 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
5248 (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005249 ;}
5250 break;
5251
5252 case 175:
Chandler Carruth02202192007-08-04 01:56:21 +00005253#line 2655 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5254 { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005255 break;
5256
5257 case 176:
Chandler Carruth02202192007-08-04 01:56:21 +00005258#line 2656 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005259 {
Chandler Carruth02202192007-08-04 01:56:21 +00005260 (yyval.ConstVector) = new std::vector<ConstInfo>();
5261 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005262 ;}
5263 break;
5264
5265 case 177:
Chandler Carruth02202192007-08-04 01:56:21 +00005266#line 2665 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5267 { (yyval.BoolVal) = false; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005268 break;
5269
5270 case 178:
Chandler Carruth02202192007-08-04 01:56:21 +00005271#line 2666 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5272 { (yyval.BoolVal) = true; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005273 break;
5274
5275 case 179:
Chandler Carruth02202192007-08-04 01:56:21 +00005276#line 2678 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005277 {
Chandler Carruth02202192007-08-04 01:56:21 +00005278 (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005279 CurModule.ModuleDone();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005280 ;}
5281 break;
5282
5283 case 180:
Chandler Carruth02202192007-08-04 01:56:21 +00005284#line 2687 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5285 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005286 break;
5287
5288 case 181:
Chandler Carruth02202192007-08-04 01:56:21 +00005289#line 2688 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5290 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005291 break;
5292
5293 case 182:
Chandler Carruth02202192007-08-04 01:56:21 +00005294#line 2689 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5295 { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005296 break;
5297
5298 case 183:
Chandler Carruth02202192007-08-04 01:56:21 +00005299#line 2690 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5300 { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005301 break;
5302
5303 case 184:
Chandler Carruth02202192007-08-04 01:56:21 +00005304#line 2691 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005305 {
Chandler Carruth02202192007-08-04 01:56:21 +00005306 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer950bf602007-01-26 08:19:09 +00005307 // Emit an error if there are any unresolved types left.
5308 if (!CurModule.LateResolveTypes.empty()) {
5309 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5310 if (DID.Type == ValID::NameVal) {
5311 error("Reference to an undefined type: '"+DID.getName() + "'");
5312 } else {
5313 error("Reference to an undefined type: #" + itostr(DID.Num));
5314 }
5315 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005316 ;}
5317 break;
5318
5319 case 185:
Chandler Carruth02202192007-08-04 01:56:21 +00005320#line 2707 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005321 {
Reid Spencer950bf602007-01-26 08:19:09 +00005322 // Eagerly resolve types. This is not an optimization, this is a
5323 // requirement that is due to the fact that we could have this:
5324 //
5325 // %list = type { %list * }
5326 // %list = type { %list * } ; repeated type decl
5327 //
5328 // If types are not resolved eagerly, then the two types will not be
5329 // determined to be the same type!
5330 //
Chandler Carruth02202192007-08-04 01:56:21 +00005331 ResolveTypeTo((yyvsp[(2) - (4)].StrVal), (yyvsp[(4) - (4)].TypeVal).PAT->get(), (yyvsp[(4) - (4)].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00005332
Chandler Carruth02202192007-08-04 01:56:21 +00005333 if (!setTypeName((yyvsp[(4) - (4)].TypeVal), (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005334 // If this is a numbered type that is not a redefinition, add it to the
5335 // slot table.
Chandler Carruth02202192007-08-04 01:56:21 +00005336 CurModule.Types.push_back((yyvsp[(4) - (4)].TypeVal).PAT->get());
5337 CurModule.TypeSigns.push_back((yyvsp[(4) - (4)].TypeVal).S);
Reid Spencera50d5962006-12-02 04:11:07 +00005338 }
Chandler Carruth02202192007-08-04 01:56:21 +00005339 delete (yyvsp[(4) - (4)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005340 ;}
5341 break;
5342
5343 case 186:
Chandler Carruth02202192007-08-04 01:56:21 +00005344#line 2727 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005345 { // Function prototypes can be in const pool
5346 ;}
5347 break;
5348
5349 case 187:
Chandler Carruth02202192007-08-04 01:56:21 +00005350#line 2729 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005351 { // Asm blocks can be in the const pool
5352 ;}
5353 break;
5354
5355 case 188:
Chandler Carruth02202192007-08-04 01:56:21 +00005356#line 2731 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005357 {
Chandler Carruth02202192007-08-04 01:56:21 +00005358 if ((yyvsp[(5) - (5)].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005359 error("Global value initializer is not a constant");
Chandler Carruth02202192007-08-04 01:56:21 +00005360 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), (yyvsp[(3) - (5)].Linkage), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal).C->getType(), (yyvsp[(5) - (5)].ConstVal).C, (yyvsp[(5) - (5)].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005361 ;}
5362 break;
5363
5364 case 189:
Chandler Carruth02202192007-08-04 01:56:21 +00005365#line 2735 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005366 {
Reid Spencer950bf602007-01-26 08:19:09 +00005367 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005368 ;}
5369 break;
5370
5371 case 190:
Chandler Carruth02202192007-08-04 01:56:21 +00005372#line 2738 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005373 {
Chandler Carruth02202192007-08-04 01:56:21 +00005374 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
5375 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5376 (yyvsp[(5) - (5)].TypeVal).S);
5377 delete (yyvsp[(5) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005378 ;}
5379 break;
5380
5381 case 191:
Chandler Carruth02202192007-08-04 01:56:21 +00005382#line 2743 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005383 {
Reid Spencer950bf602007-01-26 08:19:09 +00005384 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005385 ;}
5386 break;
5387
5388 case 192:
Chandler Carruth02202192007-08-04 01:56:21 +00005389#line 2746 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005390 {
Chandler Carruth02202192007-08-04 01:56:21 +00005391 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
5392 CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5393 (yyvsp[(5) - (5)].TypeVal).S);
5394 delete (yyvsp[(5) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005395 ;}
5396 break;
5397
5398 case 193:
Chandler Carruth02202192007-08-04 01:56:21 +00005399#line 2751 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005400 {
Reid Spencer950bf602007-01-26 08:19:09 +00005401 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005402 ;}
5403 break;
5404
5405 case 194:
Chandler Carruth02202192007-08-04 01:56:21 +00005406#line 2754 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005407 {
Chandler Carruth02202192007-08-04 01:56:21 +00005408 const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005409 CurGV =
Chandler Carruth02202192007-08-04 01:56:21 +00005410 ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
5411 (yyvsp[(5) - (5)].TypeVal).S);
5412 delete (yyvsp[(5) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005413 ;}
5414 break;
5415
5416 case 195:
Chandler Carruth02202192007-08-04 01:56:21 +00005417#line 2760 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005418 {
Reid Spencer950bf602007-01-26 08:19:09 +00005419 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005420 ;}
5421 break;
5422
5423 case 196:
Chandler Carruth02202192007-08-04 01:56:21 +00005424#line 2763 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005425 {
5426 ;}
5427 break;
5428
5429 case 197:
Chandler Carruth02202192007-08-04 01:56:21 +00005430#line 2765 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005431 {
5432 ;}
5433 break;
5434
5435 case 198:
Chandler Carruth02202192007-08-04 01:56:21 +00005436#line 2767 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005437 {
5438 ;}
5439 break;
5440
5441 case 199:
Chandler Carruth02202192007-08-04 01:56:21 +00005442#line 2772 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005443 {
Reid Spencer950bf602007-01-26 08:19:09 +00005444 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chandler Carruth02202192007-08-04 01:56:21 +00005445 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
5446 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
5447 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005448
5449 if (AsmSoFar.empty())
5450 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5451 else
5452 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005453 ;}
5454 break;
5455
5456 case 200:
Chandler Carruth02202192007-08-04 01:56:21 +00005457#line 2786 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5458 { (yyval.Endianness) = Module::BigEndian; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005459 break;
5460
5461 case 201:
Chandler Carruth02202192007-08-04 01:56:21 +00005462#line 2787 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5463 { (yyval.Endianness) = Module::LittleEndian; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005464 break;
5465
5466 case 202:
Chandler Carruth02202192007-08-04 01:56:21 +00005467#line 2791 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005468 {
Chandler Carruth02202192007-08-04 01:56:21 +00005469 CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005470 ;}
5471 break;
5472
5473 case 203:
Chandler Carruth02202192007-08-04 01:56:21 +00005474#line 2794 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005475 {
Chandler Carruth02202192007-08-04 01:56:21 +00005476 if ((yyvsp[(3) - (3)].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00005477 CurModule.setPointerSize(Module::Pointer32);
Chandler Carruth02202192007-08-04 01:56:21 +00005478 else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00005479 CurModule.setPointerSize(Module::Pointer64);
5480 else
Chandler Carruth02202192007-08-04 01:56:21 +00005481 error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005482 ;}
5483 break;
Reid Spencer9d6565a2007-02-15 02:26:10 +00005484
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005485 case 204:
Chandler Carruth02202192007-08-04 01:56:21 +00005486#line 2802 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005487 {
Chandler Carruth02202192007-08-04 01:56:21 +00005488 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
5489 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005490 ;}
5491 break;
5492
5493 case 205:
Chandler Carruth02202192007-08-04 01:56:21 +00005494#line 2806 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005495 {
Chandler Carruth02202192007-08-04 01:56:21 +00005496 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
5497 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005498 ;}
5499 break;
5500
5501 case 207:
Chandler Carruth02202192007-08-04 01:56:21 +00005502#line 2817 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005503 {
Chandler Carruth02202192007-08-04 01:56:21 +00005504 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
5505 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005506 ;}
5507 break;
5508
5509 case 208:
Chandler Carruth02202192007-08-04 01:56:21 +00005510#line 2821 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005511 {
Chandler Carruth02202192007-08-04 01:56:21 +00005512 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
5513 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005514 ;}
5515 break;
5516
5517 case 209:
Chandler Carruth02202192007-08-04 01:56:21 +00005518#line 2825 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005519 { ;}
5520 break;
5521
5522 case 213:
Chandler Carruth02202192007-08-04 01:56:21 +00005523#line 2838 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5524 { (yyval.StrVal) = 0; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005525 break;
5526
5527 case 214:
Chandler Carruth02202192007-08-04 01:56:21 +00005528#line 2842 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005529 {
Chandler Carruth02202192007-08-04 01:56:21 +00005530 if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::VoidTy)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005531 error("void typed arguments are invalid");
Chandler Carruth02202192007-08-04 01:56:21 +00005532 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005533 ;}
5534 break;
5535
5536 case 215:
Chandler Carruth02202192007-08-04 01:56:21 +00005537#line 2850 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005538 {
Chandler Carruth02202192007-08-04 01:56:21 +00005539 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
5540 (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
5541 delete (yyvsp[(3) - (3)].ArgVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005542 ;}
5543 break;
5544
5545 case 216:
Chandler Carruth02202192007-08-04 01:56:21 +00005546#line 2855 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005547 {
Chandler Carruth02202192007-08-04 01:56:21 +00005548 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5549 (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
5550 delete (yyvsp[(1) - (1)].ArgVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005551 ;}
5552 break;
5553
5554 case 217:
Chandler Carruth02202192007-08-04 01:56:21 +00005555#line 2863 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5556 { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005557 break;
5558
5559 case 218:
Chandler Carruth02202192007-08-04 01:56:21 +00005560#line 2864 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005561 {
Chandler Carruth02202192007-08-04 01:56:21 +00005562 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005563 PATypeInfo VoidTI;
5564 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005565 VoidTI.S.makeSignless();
Chandler Carruth02202192007-08-04 01:56:21 +00005566 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005567 ;}
5568 break;
5569
5570 case 219:
Chandler Carruth02202192007-08-04 01:56:21 +00005571#line 2871 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005572 {
Chandler Carruth02202192007-08-04 01:56:21 +00005573 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005574 PATypeInfo VoidTI;
5575 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005576 VoidTI.S.makeSignless();
Chandler Carruth02202192007-08-04 01:56:21 +00005577 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005578 ;}
5579 break;
5580
5581 case 220:
Chandler Carruth02202192007-08-04 01:56:21 +00005582#line 2878 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5583 { (yyval.ArgList) = 0; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005584 break;
5585
5586 case 221:
Chandler Carruth02202192007-08-04 01:56:21 +00005587#line 2882 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005588 {
Chandler Carruth02202192007-08-04 01:56:21 +00005589 UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
5590 std::string FunctionName((yyvsp[(3) - (8)].StrVal));
5591 free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory!
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005592
Chandler Carruth02202192007-08-04 01:56:21 +00005593 const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005594
5595 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5596 error("LLVM functions cannot return aggregate types");
5597
Reid Spencerbb1fd572007-03-21 17:15:50 +00005598 Signedness FTySign;
Chandler Carruth02202192007-08-04 01:56:21 +00005599 FTySign.makeComposite((yyvsp[(2) - (8)].TypeVal).S);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005600 std::vector<const Type*> ParamTyList;
Reid Spencer950bf602007-01-26 08:19:09 +00005601
5602 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5603 // i8*. We check here for those names and override the parameter list
5604 // types to ensure the prototype is correct.
5605 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005606 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00005607 } else if (FunctionName == "llvm.va_copy") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005608 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5609 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Chandler Carruth02202192007-08-04 01:56:21 +00005610 } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005611 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Chandler Carruth02202192007-08-04 01:56:21 +00005612 I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005613 const Type *Ty = I->first.PAT->get();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005614 ParamTyList.push_back(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005615 FTySign.add(I->first.S);
Reid Spencer950bf602007-01-26 08:19:09 +00005616 }
5617 }
5618
Reid Spenceref9b9a72007-02-05 20:47:22 +00005619 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5620 if (isVarArg)
5621 ParamTyList.pop_back();
Reid Spencer950bf602007-01-26 08:19:09 +00005622
Reid Spencerb7046c72007-01-29 05:41:34 +00005623 // Convert the CSRet calling convention into the corresponding parameter
5624 // attribute.
Reid Spencer7eea8ff2007-05-18 05:48:07 +00005625 ParamAttrsList *PAL = 0;
Chandler Carruth02202192007-08-04 01:56:21 +00005626 if ((yyvsp[(1) - (8)].UIntVal) == OldCallingConv::CSRet) {
Reid Spencer7eea8ff2007-05-18 05:48:07 +00005627 ParamAttrsVector Attrs;
5628 ParamAttrsWithIndex PAWI;
5629 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
5630 Attrs.push_back(PAWI);
5631 PAL = ParamAttrsList::get(Attrs);
Reid Spencerb7046c72007-01-29 05:41:34 +00005632 }
5633
Reid Spencer7b5d4662007-04-09 06:16:21 +00005634 const FunctionType *FT =
Reid Spencer7eea8ff2007-05-18 05:48:07 +00005635 FunctionType::get(RetTy, ParamTyList, isVarArg, PAL);
Reid Spencer950bf602007-01-26 08:19:09 +00005636 const PointerType *PFT = PointerType::get(FT);
Chandler Carruth02202192007-08-04 01:56:21 +00005637 delete (yyvsp[(2) - (8)].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005638
5639 ValID ID;
5640 if (!FunctionName.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005641 ID = ValID::create((char*)FunctionName.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00005642 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005643 ID = ValID::create((int)CurModule.Values[PFT].size());
Reid Spencer950bf602007-01-26 08:19:09 +00005644 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005645 ID.S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00005646
5647 Function *Fn = 0;
Reid Spencered96d1e2007-02-08 09:08:52 +00005648 Module* M = CurModule.CurrentModule;
5649
Reid Spencer950bf602007-01-26 08:19:09 +00005650 // See if this function was forward referenced. If so, recycle the object.
5651 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5652 // Move the function to the end of the list, from whereever it was
5653 // previously inserted.
5654 Fn = cast<Function>(FWRef);
Reid Spencered96d1e2007-02-08 09:08:52 +00005655 M->getFunctionList().remove(Fn);
5656 M->getFunctionList().push_back(Fn);
5657 } else if (!FunctionName.empty()) {
5658 GlobalValue *Conflict = M->getFunction(FunctionName);
5659 if (!Conflict)
5660 Conflict = M->getNamedGlobal(FunctionName);
5661 if (Conflict && PFT == Conflict->getType()) {
5662 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5663 // We have two function definitions that conflict, same type, same
5664 // name. We should really check to make sure that this is the result
5665 // of integer type planes collapsing and generate an error if it is
5666 // not, but we'll just rename on the assumption that it is. However,
5667 // let's do it intelligently and rename the internal linkage one
5668 // if there is one.
5669 std::string NewName(makeNameUnique(FunctionName));
5670 if (Conflict->hasInternalLinkage()) {
5671 Conflict->setName(NewName);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005672 RenameMapKey Key =
5673 makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005674 CurModule.RenameMap[Key] = NewName;
5675 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5676 InsertValue(Fn, CurModule.Values);
5677 } else {
5678 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5679 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005680 RenameMapKey Key =
5681 makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005682 CurModule.RenameMap[Key] = NewName;
5683 }
5684 } else {
5685 // If they are not both definitions, then just use the function we
5686 // found since the types are the same.
5687 Fn = cast<Function>(Conflict);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005688
Reid Spencered96d1e2007-02-08 09:08:52 +00005689 // Make sure to strip off any argument names so we can't get
5690 // conflicts.
5691 if (Fn->isDeclaration())
5692 for (Function::arg_iterator AI = Fn->arg_begin(),
5693 AE = Fn->arg_end(); AI != AE; ++AI)
5694 AI->setName("");
5695 }
5696 } else if (Conflict) {
Reid Spencere59f4932007-04-16 03:05:01 +00005697 // We have two globals with the same name and different types.
Reid Spencered96d1e2007-02-08 09:08:52 +00005698 // Previously, this was permitted because the symbol table had
5699 // "type planes" and names only needed to be distinct within a
5700 // type plane. After PR411 was fixed, this is no loner the case.
5701 // To resolve this we must rename one of the two.
5702 if (Conflict->hasInternalLinkage()) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005703 // We can safely rename the Conflict.
5704 RenameMapKey Key =
5705 makeRenameMapKey(Conflict->getName(), Conflict->getType(),
5706 CurModule.NamedValueSigns[Conflict->getName()]);
Reid Spencered96d1e2007-02-08 09:08:52 +00005707 Conflict->setName(makeNameUnique(Conflict->getName()));
Reid Spencered96d1e2007-02-08 09:08:52 +00005708 CurModule.RenameMap[Key] = Conflict->getName();
5709 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5710 InsertValue(Fn, CurModule.Values);
Reid Spencerd2920cd2007-03-21 17:27:53 +00005711 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005712 // We can't quietly rename either of these things, but we must
Reid Spencerd2920cd2007-03-21 17:27:53 +00005713 // rename one of them. Only if the function's linkage is internal can
5714 // we forgo a warning message about the renamed function.
Reid Spencered96d1e2007-02-08 09:08:52 +00005715 std::string NewName = makeNameUnique(FunctionName);
Reid Spencerd2920cd2007-03-21 17:27:53 +00005716 if (CurFun.Linkage != GlobalValue::InternalLinkage) {
5717 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5718 "' may cause linkage errors");
5719 }
5720 // Elect to rename the thing we're now defining.
Reid Spencered96d1e2007-02-08 09:08:52 +00005721 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5722 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005723 RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005724 CurModule.RenameMap[Key] = NewName;
Reid Spencerd2920cd2007-03-21 17:27:53 +00005725 }
Reid Spenceref9b9a72007-02-05 20:47:22 +00005726 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005727 // There's no conflict, just define the function
5728 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5729 InsertValue(Fn, CurModule.Values);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005730 }
Reid Spencere59f4932007-04-16 03:05:01 +00005731 } else {
5732 // There's no conflict, just define the function
5733 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5734 InsertValue(Fn, CurModule.Values);
Reid Spencer950bf602007-01-26 08:19:09 +00005735 }
5736
Reid Spencere59f4932007-04-16 03:05:01 +00005737
Reid Spencer950bf602007-01-26 08:19:09 +00005738 CurFun.FunctionStart(Fn);
5739
5740 if (CurFun.isDeclare) {
5741 // If we have declaration, always overwrite linkage. This will allow us
5742 // to correctly handle cases, when pointer to function is passed as
5743 // argument to another function.
5744 Fn->setLinkage(CurFun.Linkage);
5745 }
Chandler Carruth02202192007-08-04 01:56:21 +00005746 Fn->setCallingConv(upgradeCallingConv((yyvsp[(1) - (8)].UIntVal)));
5747 Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
5748 if ((yyvsp[(7) - (8)].StrVal)) {
5749 Fn->setSection((yyvsp[(7) - (8)].StrVal));
5750 free((yyvsp[(7) - (8)].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005751 }
5752
5753 // Add all of the arguments we parsed to the function...
Chandler Carruth02202192007-08-04 01:56:21 +00005754 if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005755 if (isVarArg) { // Nuke the last entry
Chandler Carruth02202192007-08-04 01:56:21 +00005756 assert((yyvsp[(5) - (8)].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5757 (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
5758 delete (yyvsp[(5) - (8)].ArgList)->back().first.PAT;
5759 (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005760 }
5761 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005762 Function::arg_iterator ArgEnd = Fn->arg_end();
Chandler Carruth02202192007-08-04 01:56:21 +00005763 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[(5) - (8)].ArgList)->begin();
5764 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[(5) - (8)].ArgList)->end();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005765 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005766 delete I->first.PAT; // Delete the typeholder...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005767 ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
5768 setValueName(VI, I->second); // Insert arg into symtab...
Reid Spencer950bf602007-01-26 08:19:09 +00005769 InsertValue(ArgIt);
5770 }
Chandler Carruth02202192007-08-04 01:56:21 +00005771 delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005772 }
Reid Spencer7eea8ff2007-05-18 05:48:07 +00005773 lastCallingConv = OldCallingConv::C;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005774 ;}
5775 break;
5776
5777 case 224:
Chandler Carruth02202192007-08-04 01:56:21 +00005778#line 3076 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5779 { CurFun.Linkage = (yyvsp[(1) - (1)].Linkage); ;}
Reid Spencerd2920cd2007-03-21 17:27:53 +00005780 break;
5781
5782 case 225:
Chandler Carruth02202192007-08-04 01:56:21 +00005783#line 3076 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005784 {
Chandler Carruth02202192007-08-04 01:56:21 +00005785 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005786
5787 // Make sure that we keep track of the linkage type even if there was a
5788 // previous "declare".
Chandler Carruth02202192007-08-04 01:56:21 +00005789 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005790 ;}
5791 break;
5792
Reid Spencerd2920cd2007-03-21 17:27:53 +00005793 case 228:
Chandler Carruth02202192007-08-04 01:56:21 +00005794#line 3090 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005795 {
Chandler Carruth02202192007-08-04 01:56:21 +00005796 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005797 ;}
5798 break;
5799
Reid Spencerd2920cd2007-03-21 17:27:53 +00005800 case 229:
Chandler Carruth02202192007-08-04 01:56:21 +00005801#line 3095 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5802 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005803 break;
5804
Reid Spencerd2920cd2007-03-21 17:27:53 +00005805 case 230:
Chandler Carruth02202192007-08-04 01:56:21 +00005806#line 3096 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5807 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005808 break;
5809
Reid Spencerd2920cd2007-03-21 17:27:53 +00005810 case 231:
Chandler Carruth02202192007-08-04 01:56:21 +00005811#line 3097 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5812 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005813 break;
5814
Reid Spencerd2920cd2007-03-21 17:27:53 +00005815 case 232:
Chandler Carruth02202192007-08-04 01:56:21 +00005816#line 3101 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005817 { CurFun.isDeclare = true; ;}
5818 break;
5819
Reid Spencerd2920cd2007-03-21 17:27:53 +00005820 case 233:
Chandler Carruth02202192007-08-04 01:56:21 +00005821#line 3102 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5822 { CurFun.Linkage = (yyvsp[(3) - (3)].Linkage); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005823 break;
5824
Reid Spencerd2920cd2007-03-21 17:27:53 +00005825 case 234:
Chandler Carruth02202192007-08-04 01:56:21 +00005826#line 3102 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005827 {
Chandler Carruth02202192007-08-04 01:56:21 +00005828 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005829 CurFun.FunctionDone();
5830
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005831 ;}
5832 break;
5833
Reid Spencerd2920cd2007-03-21 17:27:53 +00005834 case 235:
Chandler Carruth02202192007-08-04 01:56:21 +00005835#line 3114 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5836 { (yyval.BoolVal) = false; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005837 break;
5838
Reid Spencerd2920cd2007-03-21 17:27:53 +00005839 case 236:
Chandler Carruth02202192007-08-04 01:56:21 +00005840#line 3115 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5841 { (yyval.BoolVal) = true; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005842 break;
5843
Reid Spencerd2920cd2007-03-21 17:27:53 +00005844 case 237:
Chandler Carruth02202192007-08-04 01:56:21 +00005845#line 3120 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5846 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005847 break;
5848
Reid Spencerd2920cd2007-03-21 17:27:53 +00005849 case 238:
Chandler Carruth02202192007-08-04 01:56:21 +00005850#line 3121 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5851 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005852 break;
5853
Reid Spencerd2920cd2007-03-21 17:27:53 +00005854 case 239:
Chandler Carruth02202192007-08-04 01:56:21 +00005855#line 3122 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5856 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005857 break;
5858
Reid Spencerd2920cd2007-03-21 17:27:53 +00005859 case 240:
Chandler Carruth02202192007-08-04 01:56:21 +00005860#line 3123 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005861 {
Chandler Carruth02202192007-08-04 01:56:21 +00005862 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true));
5863 (yyval.ValIDVal).S.makeUnsigned();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005864 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005865 break;
5866
Reid Spencerd2920cd2007-03-21 17:27:53 +00005867 case 241:
Chandler Carruth02202192007-08-04 01:56:21 +00005868#line 3127 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005869 {
Chandler Carruth02202192007-08-04 01:56:21 +00005870 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false));
5871 (yyval.ValIDVal).S.makeUnsigned();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005872 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005873 break;
5874
Reid Spencerd2920cd2007-03-21 17:27:53 +00005875 case 242:
Chandler Carruth02202192007-08-04 01:56:21 +00005876#line 3131 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5877 { (yyval.ValIDVal) = ValID::createNull(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005878 break;
5879
Reid Spencerd2920cd2007-03-21 17:27:53 +00005880 case 243:
Chandler Carruth02202192007-08-04 01:56:21 +00005881#line 3132 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5882 { (yyval.ValIDVal) = ValID::createUndef(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005883 break;
5884
Reid Spencerd2920cd2007-03-21 17:27:53 +00005885 case 244:
Chandler Carruth02202192007-08-04 01:56:21 +00005886#line 3133 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5887 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005888 break;
5889
Reid Spencerd2920cd2007-03-21 17:27:53 +00005890 case 245:
Chandler Carruth02202192007-08-04 01:56:21 +00005891#line 3134 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005892 { // Nonempty unsized packed vector
Chandler Carruth02202192007-08-04 01:56:21 +00005893 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
5894 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005895 VectorType* pt = VectorType::get(ETy, NumElements);
Chandler Carruth02202192007-08-04 01:56:21 +00005896 (yyval.ValIDVal).S.makeComposite((*(yyvsp[(2) - (3)].ConstVector))[0].S);
5897 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S));
Reid Spencer950bf602007-01-26 08:19:09 +00005898
5899 // Verify all elements are correct type!
5900 std::vector<Constant*> Elems;
Chandler Carruth02202192007-08-04 01:56:21 +00005901 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5902 Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005903 const Type *CTy = C->getType();
5904 if (ETy != CTy)
5905 error("Element #" + utostr(i) + " is not of type '" +
5906 ETy->getDescription() +"' as required!\nIt is of type '" +
5907 CTy->getDescription() + "'");
5908 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005909 }
Chandler Carruth02202192007-08-04 01:56:21 +00005910 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
5911 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005912 ;}
5913 break;
5914
Reid Spencerd2920cd2007-03-21 17:27:53 +00005915 case 246:
Chandler Carruth02202192007-08-04 01:56:21 +00005916#line 3155 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005917 {
Chandler Carruth02202192007-08-04 01:56:21 +00005918 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
5919 (yyval.ValIDVal).S.copy((yyvsp[(1) - (1)].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005920 ;}
5921 break;
5922
Reid Spencerd2920cd2007-03-21 17:27:53 +00005923 case 247:
Chandler Carruth02202192007-08-04 01:56:21 +00005924#line 3159 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005925 {
Chandler Carruth02202192007-08-04 01:56:21 +00005926 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5927 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5928 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5929 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5930 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5931 free((yyvsp[(3) - (5)].StrVal));
5932 free((yyvsp[(5) - (5)].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005933 ;}
5934 break;
5935
Reid Spencerd2920cd2007-03-21 17:27:53 +00005936 case 248:
Chandler Carruth02202192007-08-04 01:56:21 +00005937#line 3173 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5938 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005939 break;
5940
Reid Spencerd2920cd2007-03-21 17:27:53 +00005941 case 249:
Chandler Carruth02202192007-08-04 01:56:21 +00005942#line 3174 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
5943 { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005944 break;
5945
Reid Spencerd2920cd2007-03-21 17:27:53 +00005946 case 252:
Chandler Carruth02202192007-08-04 01:56:21 +00005947#line 3187 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005948 {
Chandler Carruth02202192007-08-04 01:56:21 +00005949 const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get();
5950 (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5951 (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
5952 (yyval.ValueVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
5953 delete (yyvsp[(1) - (2)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005954 ;}
5955 break;
5956
Reid Spencerd2920cd2007-03-21 17:27:53 +00005957 case 253:
Chandler Carruth02202192007-08-04 01:56:21 +00005958#line 3197 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005959 {
Chandler Carruth02202192007-08-04 01:56:21 +00005960 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005961 ;}
5962 break;
5963
Reid Spencerd2920cd2007-03-21 17:27:53 +00005964 case 254:
Chandler Carruth02202192007-08-04 01:56:21 +00005965#line 3200 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005966 { // Do not allow functions with 0 basic blocks
Chandler Carruth02202192007-08-04 01:56:21 +00005967 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005968 ;}
5969 break;
5970
Reid Spencerd2920cd2007-03-21 17:27:53 +00005971 case 255:
Chandler Carruth02202192007-08-04 01:56:21 +00005972#line 3209 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005973 {
Chandler Carruth02202192007-08-04 01:56:21 +00005974 ValueInfo VI; VI.V = (yyvsp[(3) - (3)].TermInstVal).TI; VI.S.copy((yyvsp[(3) - (3)].TermInstVal).S);
5975 setValueName(VI, (yyvsp[(2) - (3)].StrVal));
5976 InsertValue((yyvsp[(3) - (3)].TermInstVal).TI);
5977 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal).TI);
5978 InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
5979 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005980 ;}
5981 break;
5982
Reid Spencerd2920cd2007-03-21 17:27:53 +00005983 case 256:
Chandler Carruth02202192007-08-04 01:56:21 +00005984#line 3220 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005985 {
Chandler Carruth02202192007-08-04 01:56:21 +00005986 if ((yyvsp[(2) - (2)].InstVal).I)
5987 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
5988 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005989 ;}
5990 break;
5991
Reid Spencerd2920cd2007-03-21 17:27:53 +00005992 case 257:
Chandler Carruth02202192007-08-04 01:56:21 +00005993#line 3225 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005994 {
Chandler Carruth02202192007-08-04 01:56:21 +00005995 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
Reid Spencer950bf602007-01-26 08:19:09 +00005996 // Make sure to move the basic block to the correct location in the
5997 // function, instead of leaving it inserted wherever it was first
5998 // referenced.
5999 Function::BasicBlockListType &BBL =
6000 CurFun.CurrentFunction->getBasicBlockList();
Chandler Carruth02202192007-08-04 01:56:21 +00006001 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006002 ;}
6003 break;
6004
Reid Spencerd2920cd2007-03-21 17:27:53 +00006005 case 258:
Chandler Carruth02202192007-08-04 01:56:21 +00006006#line 3234 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006007 {
Chandler Carruth02202192007-08-04 01:56:21 +00006008 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00006009 // Make sure to move the basic block to the correct location in the
6010 // function, instead of leaving it inserted wherever it was first
6011 // referenced.
6012 Function::BasicBlockListType &BBL =
6013 CurFun.CurrentFunction->getBasicBlockList();
Chandler Carruth02202192007-08-04 01:56:21 +00006014 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006015 ;}
6016 break;
6017
Reid Spencerd2920cd2007-03-21 17:27:53 +00006018 case 261:
Chandler Carruth02202192007-08-04 01:56:21 +00006019#line 3248 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006020 { // Return with a result...
Chandler Carruth02202192007-08-04 01:56:21 +00006021 (yyval.TermInstVal).TI = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
6022 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006023 ;}
6024 break;
6025
Reid Spencerd2920cd2007-03-21 17:27:53 +00006026 case 262:
Chandler Carruth02202192007-08-04 01:56:21 +00006027#line 3252 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006028 { // Return with no result...
Chandler Carruth02202192007-08-04 01:56:21 +00006029 (yyval.TermInstVal).TI = new ReturnInst();
6030 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006031 ;}
6032 break;
6033
Reid Spencerd2920cd2007-03-21 17:27:53 +00006034 case 263:
Chandler Carruth02202192007-08-04 01:56:21 +00006035#line 3256 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006036 { // Unconditional Branch...
Chandler Carruth02202192007-08-04 01:56:21 +00006037 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
6038 (yyval.TermInstVal).TI = new BranchInst(tmpBB);
6039 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006040 ;}
6041 break;
6042
Reid Spencerd2920cd2007-03-21 17:27:53 +00006043 case 264:
Chandler Carruth02202192007-08-04 01:56:21 +00006044#line 3261 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006045 {
Chandler Carruth02202192007-08-04 01:56:21 +00006046 (yyvsp[(6) - (9)].ValIDVal).S.makeSignless();
6047 (yyvsp[(9) - (9)].ValIDVal).S.makeSignless();
6048 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6049 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
6050 (yyvsp[(3) - (9)].ValIDVal).S.makeUnsigned();
6051 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
6052 (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
6053 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006054 ;}
6055 break;
6056
Reid Spencerd2920cd2007-03-21 17:27:53 +00006057 case 265:
Chandler Carruth02202192007-08-04 01:56:21 +00006058#line 3271 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006059 {
Chandler Carruth02202192007-08-04 01:56:21 +00006060 (yyvsp[(3) - (9)].ValIDVal).S.copy((yyvsp[(2) - (9)].PrimType).S);
6061 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
6062 (yyvsp[(6) - (9)].ValIDVal).S.makeSignless();
6063 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
6064 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
6065 (yyval.TermInstVal).TI = S;
6066 (yyval.TermInstVal).S.makeSignless();
6067 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
6068 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006069 for (; I != E; ++I) {
6070 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
6071 S->addCase(CI, I->second);
6072 else
6073 error("Switch case is constant, but not a simple integer");
6074 }
Chandler Carruth02202192007-08-04 01:56:21 +00006075 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006076 ;}
6077 break;
6078
Reid Spencerd2920cd2007-03-21 17:27:53 +00006079 case 266:
Chandler Carruth02202192007-08-04 01:56:21 +00006080#line 3289 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006081 {
Chandler Carruth02202192007-08-04 01:56:21 +00006082 (yyvsp[(3) - (8)].ValIDVal).S.copy((yyvsp[(2) - (8)].PrimType).S);
6083 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
6084 (yyvsp[(6) - (8)].ValIDVal).S.makeSignless();
6085 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006086 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chandler Carruth02202192007-08-04 01:56:21 +00006087 (yyval.TermInstVal).TI = S;
6088 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006089 ;}
6090 break;
6091
Reid Spencerd2920cd2007-03-21 17:27:53 +00006092 case 267:
Chandler Carruth02202192007-08-04 01:56:21 +00006093#line 3299 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006094 {
Reid Spencer950bf602007-01-26 08:19:09 +00006095 const PointerType *PFTy;
6096 const FunctionType *Ty;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006097 Signedness FTySign;
Reid Spencer950bf602007-01-26 08:19:09 +00006098
Chandler Carruth02202192007-08-04 01:56:21 +00006099 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006100 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6101 // Pull out the types of all of the arguments...
6102 std::vector<const Type*> ParamTypes;
Chandler Carruth02202192007-08-04 01:56:21 +00006103 FTySign.makeComposite((yyvsp[(3) - (13)].TypeVal).S);
6104 if ((yyvsp[(6) - (13)].ValueList)) {
6105 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006106 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00006107 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006108 FTySign.add(I->S);
6109 }
Reid Spencer950bf602007-01-26 08:19:09 +00006110 }
Reid Spencer7eea8ff2007-05-18 05:48:07 +00006111 ParamAttrsList *PAL = 0;
Chandler Carruth02202192007-08-04 01:56:21 +00006112 if ((yyvsp[(2) - (13)].UIntVal) == OldCallingConv::CSRet) {
Reid Spencer7eea8ff2007-05-18 05:48:07 +00006113 ParamAttrsVector Attrs;
6114 ParamAttrsWithIndex PAWI;
6115 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
6116 Attrs.push_back(PAWI);
6117 PAL = ParamAttrsList::get(Attrs);
Reid Spencerb7046c72007-01-29 05:41:34 +00006118 }
Reid Spencer950bf602007-01-26 08:19:09 +00006119 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6120 if (isVarArg) ParamTypes.pop_back();
Chandler Carruth02202192007-08-04 01:56:21 +00006121 Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).PAT->get(), ParamTypes, isVarArg, PAL);
Reid Spencer950bf602007-01-26 08:19:09 +00006122 PFTy = PointerType::get(Ty);
Chandler Carruth02202192007-08-04 01:56:21 +00006123 (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006124 } else {
Chandler Carruth02202192007-08-04 01:56:21 +00006125 FTySign = (yyvsp[(3) - (13)].TypeVal).S;
Reid Spencera3b12dd2007-04-07 16:14:01 +00006126 // Get the signedness of the result type. $3 is the pointer to the
6127 // function type so we get the 0th element to extract the function type,
6128 // and then the 0th element again to get the result type.
Chandler Carruth02202192007-08-04 01:56:21 +00006129 (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S.get(0).get(0));
Reid Spencer950bf602007-01-26 08:19:09 +00006130 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00006131
Chandler Carruth02202192007-08-04 01:56:21 +00006132 (yyvsp[(4) - (13)].ValIDVal).S.makeComposite(FTySign);
6133 Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling...
6134 BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
6135 BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006136
6137 // Create the call node...
Chandler Carruth02202192007-08-04 01:56:21 +00006138 if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments?
6139 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0);
Reid Spencer950bf602007-01-26 08:19:09 +00006140 } else { // Has arguments?
6141 // Loop through FunctionType's arguments and ensure they are specified
6142 // correctly!
6143 //
6144 FunctionType::param_iterator I = Ty->param_begin();
6145 FunctionType::param_iterator E = Ty->param_end();
Chandler Carruth02202192007-08-04 01:56:21 +00006146 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006147
6148 std::vector<Value*> Args;
6149 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
6150 if ((*ArgI).V->getType() != *I)
6151 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6152 (*I)->getDescription() + "'");
6153 Args.push_back((*ArgI).V);
6154 }
6155
6156 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
6157 error("Invalid number of parameters detected");
6158
Chandler Carruth02202192007-08-04 01:56:21 +00006159 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00006160 }
Chandler Carruth02202192007-08-04 01:56:21 +00006161 cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[(2) - (13)].UIntVal)));
6162 delete (yyvsp[(3) - (13)].TypeVal).PAT;
6163 delete (yyvsp[(6) - (13)].ValueList);
Reid Spencer7eea8ff2007-05-18 05:48:07 +00006164 lastCallingConv = OldCallingConv::C;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006165 ;}
6166 break;
6167
Reid Spencerd2920cd2007-03-21 17:27:53 +00006168 case 268:
Chandler Carruth02202192007-08-04 01:56:21 +00006169#line 3371 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006170 {
Chandler Carruth02202192007-08-04 01:56:21 +00006171 (yyval.TermInstVal).TI = new UnwindInst();
6172 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006173 ;}
6174 break;
6175
Reid Spencerd2920cd2007-03-21 17:27:53 +00006176 case 269:
Chandler Carruth02202192007-08-04 01:56:21 +00006177#line 3375 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006178 {
Chandler Carruth02202192007-08-04 01:56:21 +00006179 (yyval.TermInstVal).TI = new UnreachableInst();
6180 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006181 ;}
6182 break;
6183
Reid Spencerd2920cd2007-03-21 17:27:53 +00006184 case 270:
Chandler Carruth02202192007-08-04 01:56:21 +00006185#line 3382 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006186 {
Chandler Carruth02202192007-08-04 01:56:21 +00006187 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
6188 (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(2) - (6)].PrimType).S);
6189 Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00006190
6191 if (V == 0)
6192 error("May only switch on a constant pool value");
6193
Chandler Carruth02202192007-08-04 01:56:21 +00006194 (yyvsp[(6) - (6)].ValIDVal).S.makeSignless();
6195 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
6196 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006197 ;}
6198 break;
6199
Reid Spencerd2920cd2007-03-21 17:27:53 +00006200 case 271:
Chandler Carruth02202192007-08-04 01:56:21 +00006201#line 3394 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006202 {
Chandler Carruth02202192007-08-04 01:56:21 +00006203 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
6204 (yyvsp[(2) - (5)].ValIDVal).S.copy((yyvsp[(1) - (5)].PrimType).S);
6205 Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00006206
6207 if (V == 0)
6208 error("May only switch on a constant pool value");
6209
Chandler Carruth02202192007-08-04 01:56:21 +00006210 (yyvsp[(5) - (5)].ValIDVal).S.makeSignless();
6211 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
6212 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006213 ;}
6214 break;
6215
Reid Spencerd2920cd2007-03-21 17:27:53 +00006216 case 272:
Chandler Carruth02202192007-08-04 01:56:21 +00006217#line 3409 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006218 {
Reid Spencer950bf602007-01-26 08:19:09 +00006219 bool omit = false;
Chandler Carruth02202192007-08-04 01:56:21 +00006220 if ((yyvsp[(1) - (2)].StrVal))
6221 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00006222 if (BCI->getSrcTy() == BCI->getDestTy() &&
Chandler Carruth02202192007-08-04 01:56:21 +00006223 BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00006224 // This is a useless bit cast causing a name redefinition. It is
6225 // a bit cast from a type to the same type of an operand with the
6226 // same name as the name we would give this instruction. Since this
6227 // instruction results in no code generation, it is safe to omit
6228 // the instruction. This situation can occur because of collapsed
6229 // type planes. For example:
6230 // %X = add int %Y, %Z
6231 // %X = cast int %Y to uint
6232 // After upgrade, this looks like:
6233 // %X = add i32 %Y, %Z
6234 // %X = bitcast i32 to i32
6235 // The bitcast is clearly useless so we omit it.
6236 omit = true;
6237 if (omit) {
Chandler Carruth02202192007-08-04 01:56:21 +00006238 (yyval.InstVal).I = 0;
6239 (yyval.InstVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00006240 } else {
Chandler Carruth02202192007-08-04 01:56:21 +00006241 ValueInfo VI; VI.V = (yyvsp[(2) - (2)].InstVal).I; VI.S.copy((yyvsp[(2) - (2)].InstVal).S);
6242 setValueName(VI, (yyvsp[(1) - (2)].StrVal));
6243 InsertValue((yyvsp[(2) - (2)].InstVal).I);
6244 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00006245 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006246 ;}
6247 break;
6248
Reid Spencerd2920cd2007-03-21 17:27:53 +00006249 case 273:
Chandler Carruth02202192007-08-04 01:56:21 +00006250#line 3439 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006251 { // Used for PHI nodes
Chandler Carruth02202192007-08-04 01:56:21 +00006252 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
6253 (yyval.PHIList).S.copy((yyvsp[(1) - (6)].TypeVal).S);
6254 (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(1) - (6)].TypeVal).S);
6255 Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).PAT->get(), (yyvsp[(3) - (6)].ValIDVal));
6256 (yyvsp[(5) - (6)].ValIDVal).S.makeSignless();
6257 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
6258 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
6259 delete (yyvsp[(1) - (6)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006260 ;}
6261 break;
6262
Reid Spencerd2920cd2007-03-21 17:27:53 +00006263 case 274:
Chandler Carruth02202192007-08-04 01:56:21 +00006264#line 3449 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006265 {
Chandler Carruth02202192007-08-04 01:56:21 +00006266 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
6267 (yyvsp[(4) - (7)].ValIDVal).S.copy((yyvsp[(1) - (7)].PHIList).S);
6268 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
6269 (yyvsp[(6) - (7)].ValIDVal).S.makeSignless();
6270 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
6271 (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006272 ;}
6273 break;
6274
Reid Spencerd2920cd2007-03-21 17:27:53 +00006275 case 275:
Chandler Carruth02202192007-08-04 01:56:21 +00006276#line 3459 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006277 { // Used for call statements, and memory insts...
Chandler Carruth02202192007-08-04 01:56:21 +00006278 (yyval.ValueList) = new std::vector<ValueInfo>();
6279 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006280 ;}
6281 break;
6282
Reid Spencerd2920cd2007-03-21 17:27:53 +00006283 case 276:
Chandler Carruth02202192007-08-04 01:56:21 +00006284#line 3463 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006285 {
Chandler Carruth02202192007-08-04 01:56:21 +00006286 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
6287 (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006288 ;}
6289 break;
6290
Reid Spencerd2920cd2007-03-21 17:27:53 +00006291 case 278:
Chandler Carruth02202192007-08-04 01:56:21 +00006292#line 3471 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6293 { (yyval.ValueList) = 0; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006294 break;
6295
Reid Spencerd2920cd2007-03-21 17:27:53 +00006296 case 279:
Chandler Carruth02202192007-08-04 01:56:21 +00006297#line 3475 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006298 {
Chandler Carruth02202192007-08-04 01:56:21 +00006299 (yyval.BoolVal) = true;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006300 ;}
6301 break;
6302
Reid Spencerd2920cd2007-03-21 17:27:53 +00006303 case 280:
Chandler Carruth02202192007-08-04 01:56:21 +00006304#line 3478 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006305 {
Chandler Carruth02202192007-08-04 01:56:21 +00006306 (yyval.BoolVal) = false;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006307 ;}
6308 break;
6309
Reid Spencerd2920cd2007-03-21 17:27:53 +00006310 case 281:
Chandler Carruth02202192007-08-04 01:56:21 +00006311#line 3484 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006312 {
Chandler Carruth02202192007-08-04 01:56:21 +00006313 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6314 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6315 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006316 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
Reid Spencer950bf602007-01-26 08:19:09 +00006317 error("Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer9d6565a2007-02-15 02:26:10 +00006318 if (isa<VectorType>(Ty) &&
Chandler Carruth02202192007-08-04 01:56:21 +00006319 ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp))
Chris Lattner4227bdb2007-02-19 07:34:02 +00006320 error("Remainder not supported on vector types");
Reid Spencer950bf602007-01-26 08:19:09 +00006321 // Upgrade the opcode from obsolete versions before we do anything with it.
Chandler Carruth02202192007-08-04 01:56:21 +00006322 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
6323 Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6324 Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6325 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
6326 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006327 error("binary operator returned null");
Chandler Carruth02202192007-08-04 01:56:21 +00006328 (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6329 delete (yyvsp[(2) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006330 ;}
6331 break;
6332
Reid Spencerd2920cd2007-03-21 17:27:53 +00006333 case 282:
Chandler Carruth02202192007-08-04 01:56:21 +00006334#line 3503 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006335 {
Chandler Carruth02202192007-08-04 01:56:21 +00006336 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6337 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6338 const Type *Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006339 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00006340 if (!isa<VectorType>(Ty) ||
6341 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006342 error("Logical operator requires integral operands");
6343 }
Chandler Carruth02202192007-08-04 01:56:21 +00006344 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
6345 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6346 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6347 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
6348 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006349 error("binary operator returned null");
Chandler Carruth02202192007-08-04 01:56:21 +00006350 (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6351 delete (yyvsp[(2) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006352 ;}
6353 break;
6354
Reid Spencerd2920cd2007-03-21 17:27:53 +00006355 case 283:
Chandler Carruth02202192007-08-04 01:56:21 +00006356#line 3521 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006357 {
Chandler Carruth02202192007-08-04 01:56:21 +00006358 (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6359 (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
6360 const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006361 if(isa<VectorType>(Ty))
6362 error("VectorTypes currently not supported in setcc instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006363 unsigned short pred;
Chandler Carruth02202192007-08-04 01:56:21 +00006364 Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
6365 Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
6366 Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
6367 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
6368 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006369 error("binary operator returned null");
Chandler Carruth02202192007-08-04 01:56:21 +00006370 (yyval.InstVal).S.makeUnsigned();
6371 delete (yyvsp[(2) - (5)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006372 ;}
6373 break;
6374
Reid Spencerd2920cd2007-03-21 17:27:53 +00006375 case 284:
Chandler Carruth02202192007-08-04 01:56:21 +00006376#line 3537 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006377 {
Chandler Carruth02202192007-08-04 01:56:21 +00006378 (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6379 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6380 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006381 if (isa<VectorType>(Ty))
6382 error("VectorTypes currently not supported in icmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006383 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
6384 error("icmp requires integer or pointer typed operands");
Chandler Carruth02202192007-08-04 01:56:21 +00006385 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
6386 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
6387 (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
6388 (yyval.InstVal).S.makeUnsigned();
6389 delete (yyvsp[(3) - (6)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006390 ;}
6391 break;
6392
Reid Spencerd2920cd2007-03-21 17:27:53 +00006393 case 285:
Chandler Carruth02202192007-08-04 01:56:21 +00006394#line 3551 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006395 {
Chandler Carruth02202192007-08-04 01:56:21 +00006396 (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6397 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
6398 const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006399 if (isa<VectorType>(Ty))
6400 error("VectorTypes currently not supported in fcmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006401 else if (!Ty->isFloatingPoint())
6402 error("fcmp instruction requires floating point operands");
Chandler Carruth02202192007-08-04 01:56:21 +00006403 Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
6404 Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
6405 (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
6406 (yyval.InstVal).S.makeUnsigned();
6407 delete (yyvsp[(3) - (6)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006408 ;}
6409 break;
6410
Reid Spencerd2920cd2007-03-21 17:27:53 +00006411 case 286:
Chandler Carruth02202192007-08-04 01:56:21 +00006412#line 3565 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006413 {
Reid Spencer950bf602007-01-26 08:19:09 +00006414 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Chandler Carruth02202192007-08-04 01:56:21 +00006415 const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006416 Value *Ones = ConstantInt::getAllOnesValue(Ty);
6417 if (Ones == 0)
6418 error("Expected integral type for not instruction");
Chandler Carruth02202192007-08-04 01:56:21 +00006419 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
6420 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006421 error("Could not create a xor instruction");
Chandler Carruth02202192007-08-04 01:56:21 +00006422 (yyval.InstVal).S.copy((yyvsp[(2) - (2)].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006423 ;}
6424 break;
6425
Reid Spencerd2920cd2007-03-21 17:27:53 +00006426 case 287:
Chandler Carruth02202192007-08-04 01:56:21 +00006427#line 3576 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006428 {
Chandler Carruth02202192007-08-04 01:56:21 +00006429 if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
6430 cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00006431 error("Shift amount must be int8");
Chandler Carruth02202192007-08-04 01:56:21 +00006432 const Type* Ty = (yyvsp[(2) - (4)].ValueVal).V->getType();
Reid Spencer832254e2007-02-02 02:16:23 +00006433 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006434 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00006435 Value* ShiftAmt = 0;
6436 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
Chandler Carruth02202192007-08-04 01:56:21 +00006437 if (Constant *C = dyn_cast<Constant>((yyvsp[(4) - (4)].ValueVal).V))
Reid Spencer832254e2007-02-02 02:16:23 +00006438 ShiftAmt = ConstantExpr::getZExt(C, Ty);
6439 else
Chandler Carruth02202192007-08-04 01:56:21 +00006440 ShiftAmt = new ZExtInst((yyvsp[(4) - (4)].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
Reid Spencer832254e2007-02-02 02:16:23 +00006441 else
Chandler Carruth02202192007-08-04 01:56:21 +00006442 ShiftAmt = (yyvsp[(4) - (4)].ValueVal).V;
6443 (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[(1) - (4)].BinaryOpVal), Ty, (yyvsp[(2) - (4)].ValueVal).S), (yyvsp[(2) - (4)].ValueVal).V, ShiftAmt);
6444 (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006445 ;}
6446 break;
6447
Reid Spencerd2920cd2007-03-21 17:27:53 +00006448 case 288:
Chandler Carruth02202192007-08-04 01:56:21 +00006449#line 3594 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006450 {
Chandler Carruth02202192007-08-04 01:56:21 +00006451 const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006452 if (!DstTy->isFirstClassType())
6453 error("cast instruction to a non-primitive type: '" +
6454 DstTy->getDescription() + "'");
Chandler Carruth02202192007-08-04 01:56:21 +00006455 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[(1) - (4)].CastOpVal), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(2) - (4)].ValueVal).S, DstTy, (yyvsp[(4) - (4)].TypeVal).S, true));
6456 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6457 delete (yyvsp[(4) - (4)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006458 ;}
6459 break;
6460
Reid Spencerd2920cd2007-03-21 17:27:53 +00006461 case 289:
Chandler Carruth02202192007-08-04 01:56:21 +00006462#line 3603 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006463 {
Chandler Carruth02202192007-08-04 01:56:21 +00006464 if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
6465 cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00006466 error("select condition must be bool");
Chandler Carruth02202192007-08-04 01:56:21 +00006467 if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00006468 error("select value types should match");
Chandler Carruth02202192007-08-04 01:56:21 +00006469 (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6470 (yyval.InstVal).S.copy((yyvsp[(4) - (6)].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006471 ;}
6472 break;
6473
Reid Spencerd2920cd2007-03-21 17:27:53 +00006474 case 290:
Chandler Carruth02202192007-08-04 01:56:21 +00006475#line 3612 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006476 {
Chandler Carruth02202192007-08-04 01:56:21 +00006477 const Type *Ty = (yyvsp[(4) - (4)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006478 NewVarArgs = true;
Chandler Carruth02202192007-08-04 01:56:21 +00006479 (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
6480 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6481 delete (yyvsp[(4) - (4)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006482 ;}
6483 break;
6484
Reid Spencerd2920cd2007-03-21 17:27:53 +00006485 case 291:
Chandler Carruth02202192007-08-04 01:56:21 +00006486#line 3619 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006487 {
Chandler Carruth02202192007-08-04 01:56:21 +00006488 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
6489 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006490 ObsoleteVarArgs = true;
6491 Function* NF = cast<Function>(CurModule.CurrentModule->
6492 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6493
6494 //b = vaarg a, t ->
6495 //foo = alloca 1 of t
6496 //bar = vacopy a
6497 //store bar -> foo
6498 //b = vaarg foo, t
6499 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
6500 CurBB->getInstList().push_back(foo);
Chandler Carruth02202192007-08-04 01:56:21 +00006501 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006502 CurBB->getInstList().push_back(bar);
6503 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Chandler Carruth02202192007-08-04 01:56:21 +00006504 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
6505 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6506 delete (yyvsp[(4) - (4)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006507 ;}
6508 break;
6509
Reid Spencerd2920cd2007-03-21 17:27:53 +00006510 case 292:
Chandler Carruth02202192007-08-04 01:56:21 +00006511#line 3640 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006512 {
Chandler Carruth02202192007-08-04 01:56:21 +00006513 const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
6514 const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006515 ObsoleteVarArgs = true;
6516 Function* NF = cast<Function>(CurModule.CurrentModule->
6517 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6518
6519 //b = vanext a, t ->
6520 //foo = alloca 1 of t
6521 //bar = vacopy a
6522 //store bar -> foo
6523 //tmp = vaarg foo, t
6524 //b = load foo
6525 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
6526 CurBB->getInstList().push_back(foo);
Chandler Carruth02202192007-08-04 01:56:21 +00006527 CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006528 CurBB->getInstList().push_back(bar);
6529 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6530 Instruction* tmp = new VAArgInst(foo, DstTy);
6531 CurBB->getInstList().push_back(tmp);
Chandler Carruth02202192007-08-04 01:56:21 +00006532 (yyval.InstVal).I = new LoadInst(foo);
6533 (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
6534 delete (yyvsp[(4) - (4)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006535 ;}
6536 break;
6537
Reid Spencerd2920cd2007-03-21 17:27:53 +00006538 case 293:
Chandler Carruth02202192007-08-04 01:56:21 +00006539#line 3664 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006540 {
Chandler Carruth02202192007-08-04 01:56:21 +00006541 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006542 error("Invalid extractelement operands");
Chandler Carruth02202192007-08-04 01:56:21 +00006543 (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
6544 (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006545 ;}
6546 break;
6547
Reid Spencerd2920cd2007-03-21 17:27:53 +00006548 case 294:
Chandler Carruth02202192007-08-04 01:56:21 +00006549#line 3670 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006550 {
Chandler Carruth02202192007-08-04 01:56:21 +00006551 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006552 error("Invalid insertelement operands");
Chandler Carruth02202192007-08-04 01:56:21 +00006553 (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6554 (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006555 ;}
6556 break;
6557
Reid Spencerd2920cd2007-03-21 17:27:53 +00006558 case 295:
Chandler Carruth02202192007-08-04 01:56:21 +00006559#line 3676 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006560 {
Chandler Carruth02202192007-08-04 01:56:21 +00006561 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006562 error("Invalid shufflevector operands");
Chandler Carruth02202192007-08-04 01:56:21 +00006563 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
6564 (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006565 ;}
6566 break;
6567
Reid Spencerd2920cd2007-03-21 17:27:53 +00006568 case 296:
Chandler Carruth02202192007-08-04 01:56:21 +00006569#line 3682 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006570 {
Chandler Carruth02202192007-08-04 01:56:21 +00006571 const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006572 if (!Ty->isFirstClassType())
6573 error("PHI node operands must be of first class type");
6574 PHINode *PHI = new PHINode(Ty);
Chandler Carruth02202192007-08-04 01:56:21 +00006575 PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
6576 while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
6577 if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00006578 error("All elements of a PHI node must be of the same type");
Chandler Carruth02202192007-08-04 01:56:21 +00006579 PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
6580 (yyvsp[(2) - (2)].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00006581 }
Chandler Carruth02202192007-08-04 01:56:21 +00006582 (yyval.InstVal).I = PHI;
6583 (yyval.InstVal).S.copy((yyvsp[(2) - (2)].PHIList).S);
6584 delete (yyvsp[(2) - (2)].PHIList).P; // Free the list...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006585 ;}
6586 break;
Reid Spencer950bf602007-01-26 08:19:09 +00006587
Reid Spencerd2920cd2007-03-21 17:27:53 +00006588 case 297:
Chandler Carruth02202192007-08-04 01:56:21 +00006589#line 3698 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006590 {
Reid Spencer950bf602007-01-26 08:19:09 +00006591 // Handle the short call syntax
6592 const PointerType *PFTy;
6593 const FunctionType *FTy;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006594 Signedness FTySign;
Chandler Carruth02202192007-08-04 01:56:21 +00006595 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006596 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6597 // Pull out the types of all of the arguments...
6598 std::vector<const Type*> ParamTypes;
Chandler Carruth02202192007-08-04 01:56:21 +00006599 FTySign.makeComposite((yyvsp[(3) - (7)].TypeVal).S);
6600 if ((yyvsp[(6) - (7)].ValueList)) {
6601 for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006602 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00006603 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006604 FTySign.add(I->S);
6605 }
Reid Spencer950bf602007-01-26 08:19:09 +00006606 }
6607
6608 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6609 if (isVarArg) ParamTypes.pop_back();
6610
Chandler Carruth02202192007-08-04 01:56:21 +00006611 const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006612 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6613 error("Functions cannot return aggregate types");
6614
Reid Spencer7b5d4662007-04-09 06:16:21 +00006615 // Deal with CSRetCC
Reid Spencer7eea8ff2007-05-18 05:48:07 +00006616 ParamAttrsList *PAL = 0;
Chandler Carruth02202192007-08-04 01:56:21 +00006617 if ((yyvsp[(2) - (7)].UIntVal) == OldCallingConv::CSRet) {
Reid Spencer7eea8ff2007-05-18 05:48:07 +00006618 ParamAttrsVector Attrs;
6619 ParamAttrsWithIndex PAWI;
6620 PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
6621 Attrs.push_back(PAWI);
6622 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00006623 }
6624
Reid Spencer7eea8ff2007-05-18 05:48:07 +00006625 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, PAL);
Reid Spencer950bf602007-01-26 08:19:09 +00006626 PFTy = PointerType::get(FTy);
Chandler Carruth02202192007-08-04 01:56:21 +00006627 (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006628 } else {
Chandler Carruth02202192007-08-04 01:56:21 +00006629 FTySign = (yyvsp[(3) - (7)].TypeVal).S;
Reid Spencera3b12dd2007-04-07 16:14:01 +00006630 // Get the signedness of the result type. $3 is the pointer to the
6631 // function type so we get the 0th element to extract the function type,
6632 // and then the 0th element again to get the result type.
Chandler Carruth02202192007-08-04 01:56:21 +00006633 (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S.get(0).get(0));
Reid Spencer950bf602007-01-26 08:19:09 +00006634 }
Chandler Carruth02202192007-08-04 01:56:21 +00006635 (yyvsp[(4) - (7)].ValIDVal).S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00006636
6637 // First upgrade any intrinsic calls.
6638 std::vector<Value*> Args;
Chandler Carruth02202192007-08-04 01:56:21 +00006639 if ((yyvsp[(6) - (7)].ValueList))
6640 for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i)
6641 Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
6642 Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[(4) - (7)].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006643
6644 // If we got an upgraded intrinsic
6645 if (Inst) {
Chandler Carruth02202192007-08-04 01:56:21 +00006646 (yyval.InstVal).I = Inst;
Reid Spencer950bf602007-01-26 08:19:09 +00006647 } else {
6648 // Get the function we're calling
Chandler Carruth02202192007-08-04 01:56:21 +00006649 Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006650
6651 // Check the argument values match
Chandler Carruth02202192007-08-04 01:56:21 +00006652 if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006653 // Make sure no arguments is a good thing!
6654 if (FTy->getNumParams() != 0)
6655 error("No arguments passed to a function that expects arguments");
6656 } else { // Has arguments?
6657 // Loop through FunctionType's arguments and ensure they are specified
6658 // correctly!
6659 //
6660 FunctionType::param_iterator I = FTy->param_begin();
6661 FunctionType::param_iterator E = FTy->param_end();
Chandler Carruth02202192007-08-04 01:56:21 +00006662 std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006663
6664 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6665 if ((*ArgI).V->getType() != *I)
6666 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6667 (*I)->getDescription() + "'");
6668
6669 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6670 error("Invalid number of parameters detected");
6671 }
6672
6673 // Create the call instruction
David Greene718fda32007-08-01 03:59:32 +00006674 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chandler Carruth02202192007-08-04 01:56:21 +00006675 CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
6676 CI->setCallingConv(upgradeCallingConv((yyvsp[(2) - (7)].UIntVal)));
6677 (yyval.InstVal).I = CI;
Reid Spencer950bf602007-01-26 08:19:09 +00006678 }
Chandler Carruth02202192007-08-04 01:56:21 +00006679 delete (yyvsp[(3) - (7)].TypeVal).PAT;
6680 delete (yyvsp[(6) - (7)].ValueList);
Reid Spencer7eea8ff2007-05-18 05:48:07 +00006681 lastCallingConv = OldCallingConv::C;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006682 ;}
6683 break;
6684
Reid Spencerd2920cd2007-03-21 17:27:53 +00006685 case 298:
Chandler Carruth02202192007-08-04 01:56:21 +00006686#line 3791 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006687 {
Chandler Carruth02202192007-08-04 01:56:21 +00006688 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006689 ;}
6690 break;
6691
Reid Spencerd2920cd2007-03-21 17:27:53 +00006692 case 299:
Chandler Carruth02202192007-08-04 01:56:21 +00006693#line 3799 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6694 { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006695 break;
6696
Reid Spencerd2920cd2007-03-21 17:27:53 +00006697 case 300:
Chandler Carruth02202192007-08-04 01:56:21 +00006698#line 3800 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6699 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006700 break;
6701
Reid Spencerd2920cd2007-03-21 17:27:53 +00006702 case 301:
Chandler Carruth02202192007-08-04 01:56:21 +00006703#line 3804 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6704 { (yyval.BoolVal) = true; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006705 break;
6706
Reid Spencerd2920cd2007-03-21 17:27:53 +00006707 case 302:
Chandler Carruth02202192007-08-04 01:56:21 +00006708#line 3805 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
6709 { (yyval.BoolVal) = false; ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006710 break;
6711
Reid Spencerd2920cd2007-03-21 17:27:53 +00006712 case 303:
Chandler Carruth02202192007-08-04 01:56:21 +00006713#line 3809 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006714 {
Chandler Carruth02202192007-08-04 01:56:21 +00006715 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get();
6716 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S);
6717 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6718 delete (yyvsp[(2) - (3)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006719 ;}
6720 break;
6721
Reid Spencerd2920cd2007-03-21 17:27:53 +00006722 case 304:
Chandler Carruth02202192007-08-04 01:56:21 +00006723#line 3815 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006724 {
Chandler Carruth02202192007-08-04 01:56:21 +00006725 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get();
6726 (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned();
6727 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (6)].TypeVal).S);
6728 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6729 delete (yyvsp[(2) - (6)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006730 ;}
6731 break;
6732
Reid Spencerd2920cd2007-03-21 17:27:53 +00006733 case 305:
Chandler Carruth02202192007-08-04 01:56:21 +00006734#line 3822 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006735 {
Chandler Carruth02202192007-08-04 01:56:21 +00006736 const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get();
6737 (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S);
6738 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
6739 delete (yyvsp[(2) - (3)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006740 ;}
6741 break;
6742
Reid Spencerd2920cd2007-03-21 17:27:53 +00006743 case 306:
Chandler Carruth02202192007-08-04 01:56:21 +00006744#line 3828 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006745 {
Chandler Carruth02202192007-08-04 01:56:21 +00006746 const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get();
6747 (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned();
6748 (yyval.InstVal).S.makeComposite((yyvsp[(4) - (6)].PrimType).S);
6749 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
6750 delete (yyvsp[(2) - (6)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006751 ;}
6752 break;
6753
Reid Spencerd2920cd2007-03-21 17:27:53 +00006754 case 307:
Chandler Carruth02202192007-08-04 01:56:21 +00006755#line 3835 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006756 {
Chandler Carruth02202192007-08-04 01:56:21 +00006757 const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006758 if (!isa<PointerType>(PTy))
6759 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Chandler Carruth02202192007-08-04 01:56:21 +00006760 (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
6761 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006762 ;}
6763 break;
6764
Reid Spencerd2920cd2007-03-21 17:27:53 +00006765 case 308:
Chandler Carruth02202192007-08-04 01:56:21 +00006766#line 3842 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006767 {
Chandler Carruth02202192007-08-04 01:56:21 +00006768 const Type* Ty = (yyvsp[(3) - (4)].TypeVal).PAT->get();
6769 (yyvsp[(4) - (4)].ValIDVal).S.copy((yyvsp[(3) - (4)].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00006770 if (!isa<PointerType>(Ty))
6771 error("Can't load from nonpointer type: " + Ty->getDescription());
6772 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6773 error("Can't load from pointer of non-first-class type: " +
6774 Ty->getDescription());
Chandler Carruth02202192007-08-04 01:56:21 +00006775 Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
6776 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
6777 (yyval.InstVal).S.copy((yyvsp[(3) - (4)].TypeVal).S.get(0));
6778 delete (yyvsp[(3) - (4)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006779 ;}
6780 break;
6781
Reid Spencerd2920cd2007-03-21 17:27:53 +00006782 case 309:
Chandler Carruth02202192007-08-04 01:56:21 +00006783#line 3855 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006784 {
Chandler Carruth02202192007-08-04 01:56:21 +00006785 (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(5) - (6)].TypeVal).S);
6786 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).PAT->get());
Reid Spencered96d1e2007-02-08 09:08:52 +00006787 if (!PTy)
6788 error("Can't store to a nonpointer type: " +
Chandler Carruth02202192007-08-04 01:56:21 +00006789 (yyvsp[(5) - (6)].TypeVal).PAT->get()->getDescription());
Reid Spencered96d1e2007-02-08 09:08:52 +00006790 const Type *ElTy = PTy->getElementType();
Chandler Carruth02202192007-08-04 01:56:21 +00006791 Value *StoreVal = (yyvsp[(3) - (6)].ValueVal).V;
6792 Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
6793 if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType()) {
6794 StoreVal = handleSRetFuncTypeMerge((yyvsp[(3) - (6)].ValueVal).V, ElTy);
Reid Spencered96d1e2007-02-08 09:08:52 +00006795 if (!StoreVal)
Chandler Carruth02202192007-08-04 01:56:21 +00006796 error("Can't store '" + (yyvsp[(3) - (6)].ValueVal).V->getType()->getDescription() +
Reid Spencered96d1e2007-02-08 09:08:52 +00006797 "' into space of type '" + ElTy->getDescription() + "'");
6798 else {
6799 PTy = PointerType::get(StoreVal->getType());
6800 if (Constant *C = dyn_cast<Constant>(tmpVal))
6801 tmpVal = ConstantExpr::getBitCast(C, PTy);
6802 else
6803 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6804 }
6805 }
Chandler Carruth02202192007-08-04 01:56:21 +00006806 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[(1) - (6)].BoolVal));
6807 (yyval.InstVal).S.makeSignless();
6808 delete (yyvsp[(5) - (6)].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006809 ;}
6810 break;
6811
Reid Spencerd2920cd2007-03-21 17:27:53 +00006812 case 310:
Chandler Carruth02202192007-08-04 01:56:21 +00006813#line 3881 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006814 {
Chandler Carruth02202192007-08-04 01:56:21 +00006815 (yyvsp[(3) - (4)].ValIDVal).S.copy((yyvsp[(2) - (4)].TypeVal).S);
6816 const Type* Ty = (yyvsp[(2) - (4)].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006817 if (!isa<PointerType>(Ty))
6818 error("getelementptr insn requires pointer operand");
6819
6820 std::vector<Value*> VIndices;
Chandler Carruth02202192007-08-04 01:56:21 +00006821 upgradeGEPInstIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006822
Chandler Carruth02202192007-08-04 01:56:21 +00006823 Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
6824 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size());
6825 ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[(2) - (4)].TypeVal).S);
6826 (yyval.InstVal).S.copy(getElementSign(VI, VIndices));
6827 delete (yyvsp[(2) - (4)].TypeVal).PAT;
6828 delete (yyvsp[(4) - (4)].ValueList);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006829 ;}
6830 break;
6831
6832
Chandler Carruth02202192007-08-04 01:56:21 +00006833/* Line 1267 of yacc.c. */
6834#line 6835 "UpgradeParser.tab.c"
6835 default: break;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006836 }
Chandler Carruth02202192007-08-04 01:56:21 +00006837 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006838
Chandler Carruth02202192007-08-04 01:56:21 +00006839 YYPOPSTACK (yylen);
6840 yylen = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006841 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006842
6843 *++yyvsp = yyval;
6844
6845
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006846 /* Now `shift' the result of the reduction. Determine what state
6847 that goes to, based on the state we popped back to and the rule
6848 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006849
6850 yyn = yyr1[yyn];
6851
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006852 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6853 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006854 yystate = yytable[yystate];
6855 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006856 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006857
6858 goto yynewstate;
6859
6860
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006861/*------------------------------------.
6862| yyerrlab -- here on detecting error |
6863`------------------------------------*/
6864yyerrlab:
6865 /* If not already recovering from an error, report this error. */
6866 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006867 {
6868 ++yynerrs;
Chandler Carruth02202192007-08-04 01:56:21 +00006869#if ! YYERROR_VERBOSE
6870 yyerror (YY_("syntax error"));
6871#else
6872 {
6873 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6874 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6875 {
6876 YYSIZE_T yyalloc = 2 * yysize;
6877 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6878 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6879 if (yymsg != yymsgbuf)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006880 YYSTACK_FREE (yymsg);
Chandler Carruth02202192007-08-04 01:56:21 +00006881 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6882 if (yymsg)
6883 yymsg_alloc = yyalloc;
6884 else
6885 {
6886 yymsg = yymsgbuf;
6887 yymsg_alloc = sizeof yymsgbuf;
6888 }
6889 }
6890
6891 if (0 < yysize && yysize <= yymsg_alloc)
6892 {
6893 (void) yysyntax_error (yymsg, yystate, yychar);
6894 yyerror (yymsg);
6895 }
6896 else
6897 {
6898 yyerror (YY_("syntax error"));
6899 if (yysize != 0)
6900 goto yyexhaustedlab;
6901 }
6902 }
6903#endif
Reid Spencere7c3c602006-11-30 06:36:44 +00006904 }
Reid Spencer950bf602007-01-26 08:19:09 +00006905
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006906
Reid Spencer950bf602007-01-26 08:19:09 +00006907
6908 if (yyerrstatus == 3)
6909 {
Chandler Carruth02202192007-08-04 01:56:21 +00006910 /* If just tried and failed to reuse look-ahead token after an
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006911 error, discard it. */
Reid Spencer950bf602007-01-26 08:19:09 +00006912
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006913 if (yychar <= YYEOF)
Chandler Carruth02202192007-08-04 01:56:21 +00006914 {
6915 /* Return failure if at end of input. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006916 if (yychar == YYEOF)
Chandler Carruth02202192007-08-04 01:56:21 +00006917 YYABORT;
6918 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006919 else
6920 {
Chandler Carruth02202192007-08-04 01:56:21 +00006921 yydestruct ("Error: discarding",
6922 yytoken, &yylval);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006923 yychar = YYEMPTY;
6924 }
6925 }
6926
Chandler Carruth02202192007-08-04 01:56:21 +00006927 /* Else will try to reuse look-ahead token after shifting the error
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006928 token. */
6929 goto yyerrlab1;
6930
6931
6932/*---------------------------------------------------.
6933| yyerrorlab -- error raised explicitly by YYERROR. |
6934`---------------------------------------------------*/
6935yyerrorlab:
6936
Chandler Carruth02202192007-08-04 01:56:21 +00006937 /* Pacify compilers like GCC when the user code never invokes
6938 YYERROR and the label yyerrorlab therefore never appears in user
6939 code. */
6940 if (/*CONSTCOND*/ 0)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006941 goto yyerrorlab;
6942
Chandler Carruth02202192007-08-04 01:56:21 +00006943 /* Do not reclaim the symbols of the rule which action triggered
6944 this YYERROR. */
6945 YYPOPSTACK (yylen);
6946 yylen = 0;
6947 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006948 yystate = *yyssp;
6949 goto yyerrlab1;
6950
6951
6952/*-------------------------------------------------------------.
6953| yyerrlab1 -- common code for both syntax error and YYERROR. |
6954`-------------------------------------------------------------*/
6955yyerrlab1:
6956 yyerrstatus = 3; /* Each real token shifted decrements this. */
6957
6958 for (;;)
6959 {
6960 yyn = yypact[yystate];
6961 if (yyn != YYPACT_NINF)
6962 {
6963 yyn += YYTERROR;
6964 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6965 {
6966 yyn = yytable[yyn];
6967 if (0 < yyn)
6968 break;
6969 }
6970 }
6971
6972 /* Pop the current state because it cannot handle the error token. */
6973 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006974 YYABORT;
6975
Chandler Carruth02202192007-08-04 01:56:21 +00006976
6977 yydestruct ("Error: popping",
6978 yystos[yystate], yyvsp);
6979 YYPOPSTACK (1);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006980 yystate = *yyssp;
6981 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006982 }
6983
6984 if (yyn == YYFINAL)
6985 YYACCEPT;
6986
6987 *++yyvsp = yylval;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006988
6989
Chandler Carruth02202192007-08-04 01:56:21 +00006990 /* Shift the error token. */
6991 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6992
Reid Spencere7c3c602006-11-30 06:36:44 +00006993 yystate = yyn;
6994 goto yynewstate;
6995
Chris Lattner4227bdb2007-02-19 07:34:02 +00006996
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006997/*-------------------------------------.
6998| yyacceptlab -- YYACCEPT comes here. |
6999`-------------------------------------*/
7000yyacceptlab:
7001 yyresult = 0;
7002 goto yyreturn;
7003
7004/*-----------------------------------.
7005| yyabortlab -- YYABORT comes here. |
7006`-----------------------------------*/
7007yyabortlab:
7008 yyresult = 1;
7009 goto yyreturn;
7010
7011#ifndef yyoverflow
Chandler Carruth02202192007-08-04 01:56:21 +00007012/*-------------------------------------------------.
7013| yyexhaustedlab -- memory exhaustion comes here. |
7014`-------------------------------------------------*/
7015yyexhaustedlab:
7016 yyerror (YY_("memory exhausted"));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00007017 yyresult = 2;
7018 /* Fall through. */
Chris Lattner4227bdb2007-02-19 07:34:02 +00007019#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00007020
7021yyreturn:
Chandler Carruth02202192007-08-04 01:56:21 +00007022 if (yychar != YYEOF && yychar != YYEMPTY)
7023 yydestruct ("Cleanup: discarding lookahead",
7024 yytoken, &yylval);
7025 /* Do not reclaim the symbols of the rule which action triggered
7026 this YYABORT or YYACCEPT. */
7027 YYPOPSTACK (yylen);
7028 YY_STACK_PRINT (yyss, yyssp);
7029 while (yyssp != yyss)
7030 {
7031 yydestruct ("Cleanup: popping",
7032 yystos[*yyssp], yyvsp);
7033 YYPOPSTACK (1);
7034 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00007035#ifndef yyoverflow
7036 if (yyss != yyssa)
7037 YYSTACK_FREE (yyss);
7038#endif
Chandler Carruth02202192007-08-04 01:56:21 +00007039#if YYERROR_VERBOSE
7040 if (yymsg != yymsgbuf)
7041 YYSTACK_FREE (yymsg);
7042#endif
7043 /* Make sure YYID is used. */
7044 return YYID (yyresult);
Reid Spencere7c3c602006-11-30 06:36:44 +00007045}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00007046
7047
Chandler Carruth02202192007-08-04 01:56:21 +00007048#line 3899 "/home/chandlerc/code/compilers/llvm/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00007049
7050
7051int yyerror(const char *ErrorMsg) {
7052 std::string where
7053 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00007054 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00007055 std::string errMsg = where + "error: " + std::string(ErrorMsg);
7056 if (yychar != YYEMPTY && yychar != 0)
7057 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
7058 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00007059 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00007060 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00007061 exit(1);
7062}
Reid Spencer319a7302007-01-05 17:20:02 +00007063
Reid Spencer30d0c582007-01-15 00:26:18 +00007064void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00007065 std::string where
7066 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00007067 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00007068 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
7069 if (yychar != YYEMPTY && yychar != 0)
7070 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
7071 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00007072 std::cerr << "llvm-upgrade: " << errMsg << '\n';
7073}
7074
Reid Spencer950bf602007-01-26 08:19:09 +00007075void error(const std::string& ErrorMsg, int LineNo) {
7076 if (LineNo == -1) LineNo = Upgradelineno;
7077 Upgradelineno = LineNo;
7078 yyerror(ErrorMsg.c_str());
7079}
7080
Reid Spencer3fae7ba2007-03-14 23:13:06 +00007081